OpenSDN source code
vm_interface_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 "vm_interface_index.h"
14 #include "resource_manager/resource_manager_types.h"
16 
18  const boost::uuids::uuid &uuid, const std::string &interface_name):
19  IndexResourceKey(rm, Resource::INTERFACE_INDEX), uuid_(uuid),
20  interface_name_(interface_name) {
21 
22 }
23 
25  IndexResourceData *index_data = static_cast<IndexResourceData *>(data);
26  if (op == ResourceBackupReq::DEL) {
27  rm()->backup_mgr()->
28  sandesh_maps().DeleteVmInterfaceResourceEntry(index_data->index());
29  } else {
30  VmInterfaceIndexResource backup_data;
31  backup_data.set_uuid(UuidToString(uuid_));
32  backup_data.set_interface_name(interface_name_);
33  backup_data.set_time_stamp(UTCTimestampUsec());
34  rm()->backup_mgr()->
35  sandesh_maps().AddVmInterfaceResourceEntry(index_data->index(),
36  backup_data);
37  }
39  TriggerBackup();
40 
41 }
43  const VmInterfaceIndexResourceKey *vm_key =
44  static_cast<const VmInterfaceIndexResourceKey *>(&rhs);
45  if (uuid_ != vm_key->uuid_)
46  return uuid_ < vm_key->uuid_;
47  return interface_name_ < vm_key->interface_name_;
48 }
uint32_t index() const
ResourceSandeshMaps & sandesh_maps()
ResourceManager * rm()
ResourceBackupManager * backup_mgr()
VmInterfaceBackUpResourceTable & vm_interface_index_table()
Definition: sandesh_map.h:282
VmInterfaceIndexResourceKey(ResourceManager *rm, const boost::uuids::uuid &uuid, const std::string &interface_name)
virtual void Backup(ResourceData *data, uint16_t op)
virtual bool IsLess(const ResourceKey &rhs) const
static std::string UuidToString(const boost::uuids::uuid &id)
Definition: string_util.h:139
static uint64_t UTCTimestampUsec()
Definition: time_util.h:14
boost::uuids::uuid uuid