Line data Source code
1 : /* 2 : * Copyright (c) 2013 Juniper Networks, Inc. All rights reserved. 3 : */ 4 : 5 : #ifndef vnsw_agent_vm_uve_entry_base_h 6 : #define vnsw_agent_vm_uve_entry_base_h 7 : 8 : #include <string> 9 : #include <vector> 10 : #include <set> 11 : #include <map> 12 : #include <mutex> 13 : 14 : #include <virtual_machine_types.h> 15 : #include <uve/l4_port_bitmap.h> 16 : #include <uve/vm_stat.h> 17 : #include <uve/vm_stat_data.h> 18 : #include <oper/interface_common.h> 19 : #include <oper/interface.h> 20 : #include <oper/vm.h> 21 : 22 : //The class that defines data-structures to store VirtualMachine information 23 : //required for sending VirtualMachine UVE. 24 : class VmUveEntryBase { 25 : public: 26 : 27 : typedef std::set<std::string> InterfaceSet; 28 : 29 : VmUveEntryBase(Agent *agent, const std::string &vm_name); 30 : virtual ~VmUveEntryBase(); 31 0 : const std::string &vm_config_name() const { return vm_config_name_; } 32 26 : bool add_by_vm_notify() const { return add_by_vm_notify_; } 33 12 : void set_add_by_vm_notify(bool value) { add_by_vm_notify_ = value; } 34 : 35 : void InterfaceAdd(const std::string &intf_cfg_name); 36 : void InterfaceDelete(const std::string &intf_cfg_name); 37 : bool FrameVmMsg(const boost::uuids::uuid &u, UveVirtualMachineAgent *uve); 38 : bool Update(const VmEntry *vm); 39 40 : void set_changed(bool val) { changed_ = val; } 40 0 : bool changed() const { return changed_; } 41 0 : void set_deleted(bool value) { deleted_ = value; } 42 26 : bool deleted() const { return deleted_; } 43 18 : void set_renewed(bool value) { renewed_ = value; } 44 0 : bool renewed() const { return renewed_; } 45 14 : void set_vm_name(const std::string name) { vm_name_.assign(name); } 46 : virtual void Reset(); 47 : protected: 48 : 49 : Agent *agent_; 50 : InterfaceSet interface_tree_; 51 : UveVirtualMachineAgent uve_info_; 52 : // UVE entry is changed. Timer must generate UVE for this entry 53 : bool changed_; 54 : bool deleted_; 55 : bool renewed_; 56 : /* For exclusion between kTaskFlowStatsCollector and Agent::Uve */ 57 : std::mutex mutex_; 58 : private: 59 : bool UveVmInterfaceListChanged 60 : (const std::vector<std::string> &new_l) const; 61 : bool UveVmVRouterChanged(const std::string &new_value) const; 62 : 63 : bool add_by_vm_notify_; 64 : std::string vm_config_name_; 65 : std::string vm_name_; /* Name given by Nova during port notification */ 66 : DISALLOW_COPY_AND_ASSIGN(VmUveEntryBase); 67 : }; 68 : #endif // vnsw_agent_vm_uve_entry_base_h