OpenSDN source code
vrf_index.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 Juniper Networks, Inc. All rights reserved.
3  * Copyright Contributors to the OpenSDN project
4  */
5 
6 #include "cmn/agent.h"
7 #include "cmn/agent_cmn.h"
8 #include <sandesh/sandesh_types.h>
9 #include <sandesh/sandesh.h>
13 #include "vrf_index.h"
14 #include "resource_manager/resource_manager_types.h"
16 
18  const string& vrf_name):IndexResourceKey(rm, Resource::VRF_INDEX),
19  vrf_name_(vrf_name) {
20 
21 }
22 
23 void VrfIndexResourceKey::Backup(ResourceData *data, uint16_t op){
24  IndexResourceData *index_data = static_cast<IndexResourceData *>(data);
25  if (op == ResourceBackupReq::DEL) {
26  rm()->backup_mgr()->
27  sandesh_maps().DeleteVrfResourceEntry(index_data->index());
28  } else {
29  VrfIndexResource backup_data;
30  backup_data.set_vrf_name(vrf_name_);
31  backup_data.set_time_stamp(UTCTimestampUsec());
32  rm()->backup_mgr()->
33  sandesh_maps().AddVrfResourceEntry(index_data->index(),
34  backup_data);
35  }
37 
38 }
39 
40 bool VrfIndexResourceKey::IsLess(const ResourceKey &rhs) const {
41  const VrfIndexResourceKey * key = static_cast<const VrfIndexResourceKey*> (&rhs);
42  return vrf_name_ < key->vrf_name_;
43 }
uint32_t index() const
ResourceSandeshMaps & sandesh_maps()
ResourceManager * rm()
ResourceBackupManager * backup_mgr()
VrfBackUpResourceTable & vrf_index_table()
Definition: sandesh_map.h:286
std::string vrf_name_
Definition: vrf_index.h:27
virtual void Backup(ResourceData *data, uint16_t op)
Definition: vrf_index.cc:23
virtual bool IsLess(const ResourceKey &rhs) const
Definition: vrf_index.cc:40
VrfIndexResourceKey(ResourceManager *rm, const string &vrf_name)
Definition: vrf_index.cc:17
static uint64_t UTCTimestampUsec()
Definition: time_util.h:14