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