OpenSDN source code
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
vm_interface_index.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 Juniper Networks, Inc. All rights reserved.
3  */
4 
5 #include "cmn/agent.h"
6 #include "cmn/agent_cmn.h"
7 #include <sandesh/sandesh_types.h>
8 #include <sandesh/sandesh.h>
12 #include "vm_interface_index.h"
13 #include "resource_manager/resource_manager_types.h"
15 
17  const boost::uuids::uuid &uuid, const std::string &interface_name):
18  IndexResourceKey(rm, Resource::INTERFACE_INDEX), uuid_(uuid),
19  interface_name_(interface_name) {
20 
21 }
22 
24  IndexResourceData *index_data = static_cast<IndexResourceData *>(data);
25  if (op == ResourceBackupReq::DEL) {
26  rm()->backup_mgr()->
27  sandesh_maps().DeleteVmInterfaceResourceEntry(index_data->index());
28  } else {
29  VmInterfaceIndexResource backup_data;
30  backup_data.set_uuid(UuidToString(uuid_));
31  backup_data.set_interface_name(interface_name_);
32  backup_data.set_time_stamp(UTCTimestampUsec());
33  rm()->backup_mgr()->
34  sandesh_maps().AddVmInterfaceResourceEntry(index_data->index(),
35  backup_data);
36  }
38  TriggerBackup();
39 
40 }
42  const VmInterfaceIndexResourceKey *vm_key =
43  static_cast<const VmInterfaceIndexResourceKey *>(&rhs);
44  if (uuid_ != vm_key->uuid_)
45  return uuid_ < vm_key->uuid_;
46  return interface_name_ < vm_key->interface_name_;
47 }
VmInterfaceBackUpResourceTable & vm_interface_index_table()
Definition: sandesh_map.h:281
virtual void Backup(ResourceData *data, uint16_t op)
boost::uuids::uuid uuid
static std::string UuidToString(const boost::uuids::uuid &id)
Definition: string_util.h:138
ResourceManager * rm()
virtual bool IsLess(const ResourceKey &rhs) const
ResourceBackupManager * backup_mgr()
static uint64_t UTCTimestampUsec()
Definition: time_util.h:13
ResourceSandeshMaps & sandesh_maps()
uint32_t index() const
VmInterfaceIndexResourceKey(ResourceManager *rm, const boost::uuids::uuid &uuid, const std::string &interface_name)