5 #include <boost/uuid/uuid_io.hpp>
6 #include <vnc_cfg_types.h>
24 #include <multicast_types.h>
27 using boost::assign::map_list_of;
28 using boost::assign::list_of;
47 if (strcasecmp(proto.c_str(),
"ovs"))
76 bool ip_updated =
false;
131 return std::unique_ptr<DBEntry>(
static_cast<DBEntry *
>(dev));
139 dev->
Copy(
this, data);
149 bool ret = dev->
Copy(
this, data);
196 const autogen::PhysicalRouter *router) {
197 boost::system::error_code ec;
200 ip = IpAddress::from_string(router->dataplane_ip(), ec);
201 mip = IpAddress::from_string(router->management_ip(), ec);
203 router->vendor_name(), ip, mip,
"OVS", node);
207 autogen::PhysicalRouter *router = static_cast <autogen::PhysicalRouter *>
209 autogen::IdPermsType id_perms = router->id_perms();
210 CfgUuidSet(id_perms.uuid.uuid_mslong, id_perms.uuid.uuid_lslong, u);
216 autogen::PhysicalRouter *router = static_cast <autogen::PhysicalRouter *>
235 autogen::PhysicalRouter *router = static_cast <autogen::PhysicalRouter *>
265 resp_ =
new SandeshDeviceListResp();
270 SandeshDevice *data) {
272 data->set_fq_name(entry->
fq_name());
273 data->set_name(entry->
name());
274 data->set_vendor(entry->
vendor());
275 data->set_ip_address(entry->
ip().to_string());
277 data->set_master(entry->
master());
282 SandeshDeviceListResp *dev_resp =
283 static_cast<SandeshDeviceListResp *
> (resp);
286 if (name.empty() ||
name_.find(name) != string::npos) {
289 std::vector<SandeshDevice> &list =
290 const_cast<std::vector<SandeshDevice>&
>
291 (dev_resp->get_device_list());
292 list.push_back(data);
299 void SandeshDeviceReq::HandleRequest()
const {
301 sand->DoSandesh(sand);
310 DeviceObjectLogInfo info;
314 case AgentLogEvent::ADD:
315 str.assign(
"Addition ");
317 case AgentLogEvent::DEL:
318 str.assign(
"Deletion ");
320 case AgentLogEvent::CHANGE:
321 str.assign(
"Modification ");
324 str.assign(
"INVALID");
331 info.set_name(
name_);
333 info.set_ip_address(
ip_.to_string());
336 DEVICE_OBJECT_LOG_LOG(
"Device", SandeshLevel::SYS_INFO, info);
342 if (!new_ip.is_unspecified()) {
343 IpToDeviceMap::iterator it =
ip_tree_.find(new_ip);
351 if (!ip.is_unspecified()) {
352 IpToDeviceMap::iterator it =
ip_tree_.find(ip);
360 if (!ip.is_unspecified()) {
361 IpToDeviceMap::iterator it =
ip_tree_.find(ip);
381 const std::string &vrf) {
389 VrfSet &vrf_set = it->second;
390 VrfSet::iterator vit = vrf_set.find(vrf);
391 if (vit == vrf_set.end()) {
401 const std::string &vrf) {
406 VrfSet &vrf_set = it->second;
407 VrfSet::iterator vit = vrf_set.find(vrf);
408 if (vit == vrf_set.end()) {
413 if (vrf_set.size() == 1) {
422 const std::string &vrf) {
448 PhysicalDeviceSet::iterator pit = dev_set.begin();
449 while (pit != dev_set.end()) {
457 ComponentNHList::const_iterator comp_nh_it = clist.begin();
458 for(;comp_nh_it != clist.end(); comp_nh_it++) {
459 if ((*comp_nh_it) == NULL) {
467 ((*comp_nh_it)->nh());
482 new_set.insert(dev->
uuid());
494 PhysicalDeviceSet::iterator pit = dev_set.begin();
495 while (pit != dev_set.end()) {
498 PhysicalDeviceSet::iterator dit = new_set.find(u);
499 if (dit == new_set.end()) {
507 it->second = new_set;
510 void MasterPhysicalDevicesReq::HandleRequest()
const {
511 MasterPhysicalDevicesResp *resp =
new MasterPhysicalDevicesResp();
512 resp->set_context(context());
518 PhysicalDeviceTable::PhysicalDeviceSet::const_iterator it =
520 std::vector<PDeviceData> list;
521 while (it != dev_list.end()) {
523 data.set_uuid(to_string(*it));
524 list.push_back(data);
527 resp->set_dev_list(list);
528 resp->set_more(
false);
virtual bool OperDBDelete(DBEntry *entry, const DBRequest *req)
void SendObjectLog(AgentLogEvent::type event) const
ManagementProtocol protocol() const
const std::string & vendor() const
static Agent * GetInstance()
static void CfgUuidSet(uint64_t ms_long, uint64_t ls_long, boost::uuids::uuid &u)
virtual void SetKey(const DBRequestKey *key)
void UpdateDeviceMastership(const std::string &vrf, ComponentNHList clist, bool del)
DeviceVrfMap device2vrf_map_
void UpdateIpToDevMap(IpAddress old, IpAddress new_ip, PhysicalDevice *p)
virtual KeyPtr GetDBRequestKey() const
std::string GetString(const std::string &key) const
static DBTableBase * CreateTable(DB *db, const std::string &name)
const PhysicalDeviceSet & managed_pd_set() const
std::set< boost::uuids::uuid > PhysicalDeviceSet
PhysicalDeviceSet managed_pd_set_
PhysicalDeviceTable * physical_device_table() const
ConfigManager * config_manager() const
boost::asio::ip::address IpAddress
std::pair< const boost::uuids::uuid, VrfSet > DeviceVrfPair
VrfDevicesMap vrf2devices_map_
std::unique_ptr< DBRequestData > data
static PhysicalDeviceKey * BuildKey(const autogen::PhysicalRouter *router, const boost::uuids::uuid &u)
AgentDBEntry * FindActiveEntry(const DBEntry *key)
bool Enqueue(DBRequest *req)
DBTable * AgentGetTable()
const Ip4Address * GetDip() const
virtual bool OperDBResync(DBEntry *entry, const DBRequest *req)
static std::string UuidToString(const boost::uuids::uuid &id)
void RegisterDBClients(IFMapDependencyManager *dep)
const boost::uuids::uuid & uuid() const
bool DBEntrySandesh(Sandesh *resp, std::string &name) const
void EnqueueDeviceChange(const boost::uuids::uuid &u, bool master)
std::unique_ptr< DBRequestKey > KeyPtr
const IpAddress & ip() const
virtual std::string ToString() const
virtual AgentSandeshPtr GetAgentSandesh(const AgentSandeshArguments *args, const std::string &context)
static string ToString(PhysicalDevice::ManagementProtocol proto)
PhysicalDevice * Find(const boost::uuids::uuid &u)
std::pair< const std::string, PhysicalDeviceSet > VrfDevicesPair
void AddPhysicalDeviceNode(IFMapNode *node)
void AddDeviceToVrfEntry(const boost::uuids::uuid &u, const std::string &vrf)
std::pair< IpAddress, PhysicalDevice * > IpToDevicePair
void set_master(bool value)
std::unique_ptr< DBRequestKey > key
virtual std::unique_ptr< DBEntry > AllocEntry(const DBRequestKey *k) const
class boost::shared_ptr< AgentSandesh > AgentSandeshPtr
bool Copy(PhysicalDeviceTable *table, const PhysicalDeviceData *data)
const std::string & name() const
bool RemoveDeviceToVrfEntry(const boost::uuids::uuid &u, const std::string &vrf)
static void SetDeviceSandeshData(const PhysicalDevice *entry, SandeshDevice *data)
const std::string & fq_name() const
static PhysicalDeviceData * BuildData(Agent *agent, IFMapNode *node, const autogen::PhysicalRouter *router)
PhysicalDevice * IpToPhysicalDevice(IpAddress ip)
IFMapObject * GetObject()
const std::string & name() const
bool ProcessConfig(IFMapNode *node, DBRequest &req, const boost::uuids::uuid &u)
virtual bool IFNodeToUuid(IFMapNode *node, boost::uuids::uuid &u)
std::vector< ComponentNHPtr > ComponentNHList
void DeleteIpToDevEntry(IpAddress ip)
virtual bool OperDBOnChange(DBEntry *entry, const DBRequest *req)
uint32_t GetRefCount() const
virtual bool IsLess(const DBEntry &rhs) const
ManagementProtocol protocol_
std::set< std::string > VrfSet
std::string context() const
virtual DBEntry * OperDBAdd(const DBRequest *req)
static PhysicalDevice::ManagementProtocol FromString(const string &proto)
DeviceSandesh(std::string context, const std::string &name)
virtual bool IFNodeToReq(IFMapNode *node, DBRequest &req, const boost::uuids::uuid &u)
void ResetDeviceMastership(const boost::uuids::uuid &u, const std::string &vrf)
PhysicalDeviceTable(DB *db, const std::string &name)