8 #include <pugixml/pugixml.hpp>
9 #include <boost/uuid/uuid.hpp>
11 #include <test/test_cmn_util.h>
12 #include <pkt/test/test_pkt_util.h>
23 using namespace boost::uuids;
24 using namespace AgentUtXmlUtils;
27 const string &name,
const uuid &
id,
28 const xml_node &node) {
29 if (type ==
"global-vrouter-config")
31 if (type ==
"virtual-network" || type ==
"vn")
33 if (type ==
"virtual-machine" || type ==
"vm")
37 if (type ==
"virtual-machine-interface" || type ==
"vm-interface"
40 if (type ==
"ethernet-interface" || type ==
"eth-port")
44 if (type ==
"routing-instance" || type ==
"vrf")
46 if (type ==
"access-control-list" || type ==
"acl")
48 if (type ==
"pkt-parse")
52 if (type ==
"l3-route")
58 const uuid &
id,
const xml_node &node,
60 if (type ==
"global-vrouter-config")
62 if (type ==
"virtual-network" || type ==
"vn")
64 if (type ==
"virtual-machine" || type ==
"vm")
66 if (type ==
"virtual-machine-interface" || type ==
"vm-interface"
69 if (type ==
"ethernet-interface" || type ==
"eth-port")
71 if (type ==
"routing-instance" || type ==
"vrf")
73 if (type ==
"access-control-list" || type ==
"acl")
75 if (type ==
"virtual-machine-interface-routing-instance" ||
78 if (type ==
"fdb" || type ==
"l2-route")
80 if (type ==
"l3-route")
82 if (type ==
"sg" || type ==
"securiy-group")
84 if (type ==
"iip" || type ==
"instance-ip")
113 test->
AddConfigEntry(
"virtual-machine-interface-routing-instance",
151 const xml_node &node,
192 return "global-vrouter-config";
199 const xml_node &node,
222 xml_node n1 = n.append_child(
"virtual-network-properties");
226 xml_node n1 = n.append_child(
"virtual-network-properties");
248 return "virtual-network";
255 const xml_node &node,
282 return "virtual-machine";
290 const xml_node &node,
343 xml_attribute attr =
node().attribute(
"fat-flow");
344 for (;attr != xml_attribute(); attr = attr.next_attribute()) {
345 if (std::string(attr.name()) ==
"fat-flow") {
346 uint32_t value = attr.as_uint();
360 xml_node n1 = n.append_child(
"virtual-machine-interface-mac-address");
365 n1 = n.append_child(
"virtual-machine-interface-properties");
371 n1 = n.append_child(
"virtual-machine-interface-fat-flow-protocols");
372 std::vector<uint16_t>::const_iterator it =
fat_flow_port_.begin();
374 xml_node n2 = n1.append_child(
"fat-flow-protocol");
383 boost::system::error_code ec;
399 LinkXmlNode(parent,
"virtual-machine-interface-routing-instance",
400 str,
"routing-instance",
vrf_);
403 "virtual-machine-interface-routing-instance", str);
420 return "virtual-machine-interface";
428 const xml_node &node,
452 return "physical-interface";
456 cout <<
"Create Ethernet Interface" << endl;
463 const xml_node &node,
497 return "routing-instance";
504 const xml_node &node,
521 xml_node n1 = n.append_child(
"value");
536 return "virtual-machine-interface-routing-instance";
543 const xml_node &node,
555 for (xml_node n =
node().first_child(); n; n = n.next_sibling()) {
556 if (strcmp(n.name(),
"ace") != 0) {
605 xml_node n1 = n.append_child(
"access-control-list-entries");
610 xml_node n2 = n1.append_child(
"acl-rule");
612 xml_node n3 = n2.append_child(
"match-condition");
615 xml_node n4 = n3.append_child(
"src-address");
627 xml_node n5 = n4.append_child(
"subnet");
632 n4 = n3.append_child(
"dst-address");
642 xml_node n5 = n4.append_child(
"subnet");
648 n4 = n3.append_child(
"src-port");
656 n4 = n3.append_child(
"dst-port");
664 n3 = n2.append_child(
"action-list");
679 return "access-control-list";
686 const xml_node &node,
712 str =
"ingress-access-control-list-" +
ingress_;
717 str =
"egress-access-control-list-" +
egress_;
731 return "security-group";
738 const xml_node &node,
777 const xml_node &node,
815 "virtual-machine-interface",
vmi_);
828 return "instance-ip";
835 const xml_node &node,
848 cout <<
"Attribute \"mac\" not specified for nova. Skipping"
855 cout <<
"Attribute \"vm-uuid\" not specified for nova. Skipping"
862 cout <<
"Attribute \"vn-uuid\" not specified for nova. Skipping"
869 cout <<
"Attribute \"vm_name\" not specified for nova. Skipping"
875 cout <<
"Attribute \"ip\" not specified for nova. Skipping"
899 boost::system::error_code ec;
911 const xml_node &node) :
939 return "global-vrouter-config";
947 const xml_node &node) :
949 vxlan_id_ref_(false) {
996 return "virtual-network";
1004 const xml_node &node) :
1020 return "virtual-machine";
1028 const xml_node &node) :
1030 flood_unknown_unicast_() {
1047 return (vxlan == NULL);
1069 if (
vrf_.empty() ==
false) {
1097 const xml_node &node) :
1122 return "VM-Sub-Intf";
1152 if (
active_.empty() ==
false) {
1153 if (boost::iequals(
active_,
"true") ||
1154 (boost::iequals(
active_,
"0") ==
false)){
1155 if (VmPortActive(
id()) ==
false)
1158 if (VmPortActive(
id()) ==
true)
1193 return "virtual-machine-interface";
1201 const xml_node &node) :
1217 return "eth-interface";
1224 const xml_node &node) :
1240 if (
present() && (vrf == NULL)) {
1242 }
else if (!
present() && (vrf != NULL)) {
1259 return (vrf->
vn() == NULL);
1262 if (vrf->
vn() == NULL)
1276 const xml_node &node) :
1289 return AclFind(
id());
1291 return !AclFind(
id());
1296 return "access-control-list";
1303 const xml_node &node) :
1312 cout <<
"Attribute \"nh\" not specified for Flow. Skipping" << endl;
1317 cout <<
"Attribute \"sip\" not specified for Flow. Skipping" << endl;
1322 cout <<
"Attribute \"dip\" not specified for Flow. Skipping" << endl;
1328 cout <<
"Attribute \"proto\" not specified for Flow. Skipping"
1339 cout <<
"Attribute \"sport\" not specified for Flow. Skipping"
1345 cout <<
"Attribute \"dport\" not specified for Flow. Skipping"
1346 << endl;
return false;
1367 if (str ==
"pass") {
1371 if (str ==
"deny") {
1382 if (
deleted_ ==
"true" && flow == NULL) {
1387 return (flow == NULL);
1425 (flow->
data().
rpf_nh.get()->id() != nh_id))) {
1433 return (
"flow <" +
name() +
">");
1448 const xml_node &node,
1459 cout <<
"Attribute \"mac\" not specified. Skipping" << endl;
1464 cout <<
"Attribute \"vrf_\" not specified. Skipping" << endl;
1505 sg_list.push_back(
sg_id_);
1525 vn_list.insert(
vn_);
1532 vn_list, sg_list, tag_list,
1537 Ip4Address::from_string(
ip_),
1547 const xml_node &node) :
1556 cout <<
"Attribute \"mac\" not specified. Skipping" << endl;
1561 cout <<
"Attribute \"vrf_\" not specified. Skipping" << endl;
1566 cout <<
"Attribute \"vn\" not specified. Skipping" << endl;
1572 boost::system::error_code ec;
1573 ip_ = IpAddress::from_string(addr, ec);
1591 return (rt == NULL);
1603 return (
"FDB <" +
name() +
">");
1607 const xml_node &node,
1618 cout <<
"Attribute \"ip\" not specified. Skipping" << endl;
1623 cout <<
"Attribute \"vrf_\" not specified. Skipping" << endl;
1665 sg_list.push_back(
sg_id_);
1684 vn_list.insert(
vn_);
1691 vn_list, sg_list, tag_list,
1703 const xml_node &node) :
1712 cout <<
"Attribute \"mac\" not specified. Skipping" << endl;
1717 cout <<
"Attribute \"vrf_\" not specified. Skipping" << endl;
1722 cout <<
"Attribute \"vn\" not specified. Skipping" << endl;
1728 boost::system::error_code ec;
1729 ip_ = IpAddress::from_string(addr, ec);
1747 return (rt == NULL);
1759 return (
"IP route <" +
name() +
">");
virtual const std::string ToString()
virtual const std::string ToString()
virtual void ToString(std::string *str)
VnListType source_vn_list
virtual bool ToXml(pugi::xml_node *parent)
virtual void ToString(std::string *str)
virtual void ToString(std::string *str)
xml_node AddXmlNodeWithIntValue(xml_node *parent, const char *name, int val)
virtual const std::string ToString()
virtual bool ToXml(pugi::xml_node *parent)
static Agent * GetInstance()
bool GetIntAttribute(const xml_node &node, const string &name, int *value)
AgentUtXmlVn(const std::string &name, const boost::uuids::uuid &uuid, const pugi::xml_node &node, AgentUtXmlTestCase *test_case)
std::string & network_id()
virtual void ToString(std::string *str)
uint16_t rx_vlan_id() const
virtual void ToString(std::string *str)
virtual ~AgentUtXmlVnValidate()
boost::uuids::uuid vn_uuid_
const VrfEntry * GetVrf() const
virtual ~AgentUtXmlVmValidate()
AgentUtXmlEthInterface(const std::string &name, const boost::uuids::uuid &uuid, const pugi::xml_node &node, AgentUtXmlTestCase *test_case)
AgentUtXmlGlobalVrouterValidate(const std::string &name, const boost::uuids::uuid &id, const pugi::xml_node &node)
AgentRouteTable * GetEvpnRouteTable(const std::string &vrf_name)
AgentUtXmlEthInterfaceValidate(const std::string &name, const boost::uuids::uuid &id, const pugi::xml_node &node)
AgentUtXmlVmInterface(const std::string &name, const boost::uuids::uuid &uuid, const pugi::xml_node &node, AgentUtXmlTestCase *test_case)
VmInterface::DeviceType device_type() const
static string DeviceTypeToString(VmInterface::DeviceType type)
static void DeleteReq(const Peer *peer, const std::string &vrf_name, const MacAddress &mac, const IpAddress &ip_addr, uint32_t plen, uint32_t ethernet_tag, AgentRouteData *data)
virtual ~AgentUtXmlVrfValidate()
AgentUtXmlVmInterfaceValidate(const std::string &name, const boost::uuids::uuid &id, const pugi::xml_node &node)
virtual ~AgentUtXmlEthInterfaceValidate()
std::vector< int > SecurityGroupList
virtual ~AgentUtXmlVxlanValidate()
virtual bool ToXml(pugi::xml_node *parent)
virtual const std::string ToString()
virtual bool ToXml(pugi::xml_node *parent)
virtual void ToString(std::string *str)
virtual std::string NodeType()
static const uint32_t DROP_FLAGS
AgentUtXmlNode * CreateNode(const string &type, const string &name, const uuid &id, const xml_node &node, AgentUtXmlTestCase *test_case)
AgentUtXmlVmiVrf(const std::string &name, const boost::uuids::uuid &uuid, const pugi::xml_node &node, AgentUtXmlTestCase *test_case)
virtual std::string NodeType()
virtual void ToString(std::string *str)
InetUnicastRouteEntry * FindRoute(const IpAddress &ip)
virtual void ToString(std::string *str)
virtual const std::string ToString()
const string & GetName() const
boost::uuids::uuid vn_uuid_
boost::uuids::uuid vn_uuid_
void NovaIntfAdd(bool op_delete, const uuid &id, const Ip4Address &ip, const uuid &vm_uuid, const uuid vn_uuid, const string &name, const string &mac, const string vm_name)
const std::string & dest_vn_name() const
AgentUtXmlVmValidate(const std::string &name, const boost::uuids::uuid &id, const pugi::xml_node &node)
void AgentUtXmlOperInit(AgentUtXmlTest *test)
virtual bool ToXml(pugi::xml_node *parent)
xml_node AddXmlNodeWithValue(xml_node *parent, const char *name, const string &value)
InetUnicastAgentRouteTable * GetInet4UnicastRouteTable(const std::string &vrf_name)
AgentUtXmlAclValidate(const std::string &name, const pugi::xml_node &node)
virtual void ToString(std::string *str)
AgentUtXmlVxlanValidate(const std::string &name, const boost::uuids::uuid &id, const pugi::xml_node &node)
const std::string & fabric_vrf_name() const
virtual const std::string ToString()
AgentUtXmlVrfValidate(const std::string &name, const pugi::xml_node &node)
virtual ~AgentUtXmlFlowValidate()
virtual const std::string ToString()
xml_node AddXmlNodeWithAttr(xml_node *parent, const char *attr)
BridgeRouteEntry * FindRoute(const MacAddress &mac)
static const uint32_t kRpfDiscardIndex
GlobalVrouter * global_vrouter() const
virtual void ToString(std::string *str)
boost::uuids::uuid vm_uuid_
virtual ~AgentUtXmlAclValidate()
static ControllerVmRoute * MakeControllerVmRoute(const BgpPeer *peer, const string &default_vrf, const Ip4Address &router_id, const string &vrf_name, const Ip4Address &tunnel_dest, TunnelType::TypeBmap bmap, uint32_t label, MacAddress rewrite_dmac, const VnListType &dest_vn_list, const SecurityGroupList &sg_list, const TagList &tag_list, const PathPreference &path_preference, bool ecmp_suppressed, const EcmpLoadBalance &ecmp_load_balance, bool etree_leaf)
void AddIdPerms(pugi::xml_node *parent)
AgentUtXmlAcl(const std::string &name, const boost::uuids::uuid &uuid, const pugi::xml_node &node, AgentUtXmlTestCase *test_case)
boost::uuids::uuid vm_uuid_
virtual std::string NodeType()
const NextHop * GetActiveNextHop() const
Ip4Address router_id() const
virtual const std::string ToString()
void AddConfigEntry(const std::string &name, AgentUtXmlTestConfigCreateFn fn)
const std::string & name() const
virtual std::string NodeType()
AgentRouteTable * GetBridgeRouteTable(const std::string &vrf_name)
const VxLanId * vxlan_id_ref() const
virtual const std::string ToString()
virtual uint32_t wait_count() const
bool GetStringAttribute(const xml_node &node, const string &name, string *value)
const VnEntry * vn() const
~AgentUtXmlEthInterface()
virtual bool ToXml(pugi::xml_node *parent)
virtual void ToString(std::string *str)
int flow_export_rate() const
std::set< std::string > VnListType
AgentUtXmlVnValidate(const std::string &name, const boost::uuids::uuid &id, const pugi::xml_node &node)
static void DeleteReq(const Peer *peer, const string &vrf_name, const IpAddress &addr, uint8_t plen, AgentRouteData *data)
AgentUtXmlL2Route(const std::string &name, const boost::uuids::uuid &uuid, const pugi::xml_node &node, AgentUtXmlTestCase *test_case)
AgentUtXmlInstanceIp(const std::string &name, const boost::uuids::uuid &uuid, const pugi::xml_node &node, AgentUtXmlTestCase *test_case)
int32_t flow_export_rate() const
boost::asio::ip::address_v4 Ip4Address
const NextHop * nexthop() const
virtual bool ToXml(pugi::xml_node *parent)
VrfTable * vrf_table() const
virtual std::string NodeType()
virtual ~AgentUtXmlGlobalVrouterValidate()
std::vector< uint16_t > fat_flow_port_
uint32_t vxlan_id() const
AgentUtXmlValidationNode * CreateValidateNode(const string &type, const string &name, const uuid &id, const xml_node &node)
AgentUtXmlGlobalVrouter(const std::string &name, const boost::uuids::uuid &uuid, const pugi::xml_node &node, AgentUtXmlTestCase *test_case)
AgentUtXmlL3Route(const std::string &name, const boost::uuids::uuid &uuid, const pugi::xml_node &node, AgentUtXmlTestCase *test_case)
bool GetUintAttribute(const xml_node &node, const string &name, uint16_t *value)
VmInterface::VmiType vmi_type() const
AgentUtXmlL3RouteValidate(const std::string &name, const pugi::xml_node &node)
AgentUtXmlL2RouteValidate(const std::string &name, const pugi::xml_node &node)
virtual std::string NodeType()
virtual bool ToXml(pugi::xml_node *parent)
void AddValidateEntry(const std::string &name, AgentUtXmlTestValidateCreateFn fn)
virtual std::string NodeType()
~AgentUtXmlGlobalVrouter()
virtual bool ToXml(pugi::xml_node *parent)
std::string flood_unknown_unicast_
virtual void ToString(std::string *str)
virtual bool ToXml(pugi::xml_node *parent)
virtual std::string NodeType()
virtual bool ToXml(pugi::xml_node *parent)
std::string & flood_unknown_unicast()
const pugi::xml_node & node() const
static TunnelEncapType::Encap TunnelEncapFromString(const std::string &encap)
virtual const std::string ToString()
virtual bool ToXml(pugi::xml_node *parent)
static bool MatchFlowAction(FlowEntry *flow, const string &str)
virtual std::string NodeType()
const boost::uuids::uuid & GetUuid() const
const string & GetName() const
virtual ~AgentUtXmlL2RouteValidate()
virtual bool ToXml(pugi::xml_node *parent)
AgentUtXmlVm(const std::string &name, const boost::uuids::uuid &uuid, const pugi::xml_node &node, AgentUtXmlTestCase *test_case)
std::string & vxlan_mode()
std::string flood_unknown_unicast_
AgentUtXmlTag(const std::string &name, const boost::uuids::uuid &uuid, const pugi::xml_node &node, AgentUtXmlTestCase *test_case)
bool delete_marked() const
static MacAddress FromString(const std::string &str, boost::system::error_code *error=NULL)
virtual void ToString(std::string *str)
virtual std::string NodeType()
virtual ~AgentUtXmlL3RouteValidate()
AgentUtXmlNova(const std::string &name, const boost::uuids::uuid &uuid, const pugi::xml_node &node, AgentUtXmlTestCase *test_case)
virtual const std::string ToString()
virtual std::string NodeType()
virtual uint32_t wait_count() const
static void AddRemoteVmRouteReq(const Peer *peer, const string &vm_vrf, const IpAddress &vm_addr, uint8_t plen, AgentRouteData *data)
virtual ~AgentUtXmlVmInterfaceValidate()
virtual void ToString(std::string *str)
virtual std::string NodeType()
virtual std::string NodeType()
virtual void ToString(std::string *str)
const pugi::xml_node & node() const
AgentUtXmlFlowValidate(const std::string &name, const pugi::xml_node &node)
const std::string & name() const
virtual bool ToXml(pugi::xml_node *parent)
static string VmiTypeToString(VmInterface::VmiType type)
AgentUtXmlSg(const std::string &name, const boost::uuids::uuid &uuid, const pugi::xml_node &node, AgentUtXmlTestCase *test_case)
AgentUtXmlVrf(const std::string &name, const boost::uuids::uuid &uuid, const pugi::xml_node &node, AgentUtXmlTestCase *test_case)
void LinkXmlNode(xml_node *parent, const string <ype, const string lname, const string &rtype, const string rname)
virtual std::string NodeType()
bool flood_unknown_unicast() const
std::vector< int > TagList
static void AddRemoteVmRouteReq(const Peer *peer, const std::string &vrf_name, const MacAddress &mac, const IpAddress &ip_addr, uint32_t plen, uint32_t ethernet_tag, AgentRouteData *data)