Line data Source code
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> 9 : #include "resource_manager/resource_manager.h" 10 : #include "resource_manager/resource_table.h" 11 : #include "resource_manager/resource_cmn.h" 12 : #include "vm_interface_index.h" 13 : #include "resource_manager/resource_manager_types.h" 14 : #include "resource_manager/resource_backup.h" 15 : 16 27 : VmInterfaceIndexResourceKey::VmInterfaceIndexResourceKey(ResourceManager *rm, 17 27 : const boost::uuids::uuid &uuid, const std::string &interface_name): 18 27 : IndexResourceKey(rm, Resource::INTERFACE_INDEX), uuid_(uuid), 19 27 : interface_name_(interface_name) { 20 : 21 27 : } 22 : 23 0 : void VmInterfaceIndexResourceKey::Backup(ResourceData *data, uint16_t op){ 24 0 : IndexResourceData *index_data = static_cast<IndexResourceData *>(data); 25 0 : if (op == ResourceBackupReq::DEL) { 26 : rm()->backup_mgr()-> 27 0 : sandesh_maps().DeleteVmInterfaceResourceEntry(index_data->index()); 28 : } else { 29 0 : VmInterfaceIndexResource backup_data; 30 0 : backup_data.set_uuid(UuidToString(uuid_)); 31 0 : backup_data.set_interface_name(interface_name_); 32 0 : backup_data.set_time_stamp(UTCTimestampUsec()); 33 : rm()->backup_mgr()-> 34 0 : sandesh_maps().AddVmInterfaceResourceEntry(index_data->index(), 35 : backup_data); 36 0 : } 37 0 : rm()->backup_mgr()->sandesh_maps().vm_interface_index_table(). 38 0 : TriggerBackup(); 39 : 40 0 : } 41 369 : bool VmInterfaceIndexResourceKey::IsLess(const ResourceKey &rhs) const { 42 369 : const VmInterfaceIndexResourceKey *vm_key = 43 : static_cast<const VmInterfaceIndexResourceKey *>(&rhs); 44 369 : if (uuid_ != vm_key->uuid_) 45 175 : return uuid_ < vm_key->uuid_; 46 194 : return interface_name_ < vm_key->interface_name_; 47 : }