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 "vrf_index.h" 13 : #include "resource_manager/resource_manager_types.h" 14 : #include "resource_manager/resource_backup.h" 15 : 16 12 : VrfIndexResourceKey::VrfIndexResourceKey (ResourceManager *rm, 17 12 : const string& vrf_name):IndexResourceKey(rm, Resource::VRF_INDEX), 18 12 : vrf_name_(vrf_name) { 19 : 20 12 : } 21 : 22 0 : void VrfIndexResourceKey::Backup(ResourceData *data, uint16_t op){ 23 0 : IndexResourceData *index_data = static_cast<IndexResourceData *>(data); 24 0 : if (op == ResourceBackupReq::DEL) { 25 : rm()->backup_mgr()-> 26 0 : sandesh_maps().DeleteVrfResourceEntry(index_data->index()); 27 : } else { 28 0 : VrfIndexResource backup_data; 29 0 : backup_data.set_vrf_name(vrf_name_); 30 0 : backup_data.set_time_stamp(UTCTimestampUsec()); 31 : rm()->backup_mgr()-> 32 0 : sandesh_maps().AddVrfResourceEntry(index_data->index(), 33 : backup_data); 34 0 : } 35 0 : rm()->backup_mgr()->sandesh_maps().vrf_index_table().TriggerBackup(); 36 : 37 0 : } 38 : 39 104 : bool VrfIndexResourceKey::IsLess(const ResourceKey &rhs) const { 40 104 : const VrfIndexResourceKey * key = static_cast<const VrfIndexResourceKey*> (&rhs); 41 104 : return vrf_name_ < key->vrf_name_; 42 : }