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;
 
   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() + 
">");
 
boost::asio::ip::address_v4 Ip4Address
std::vector< int > TagList
std::vector< int > SecurityGroupList
std::set< std::string > VnListType
const NextHop * GetActiveNextHop() const
const std::string & dest_vn_name() const
virtual ~AgentUtXmlAclValidate()
virtual const std::string ToString()
AgentUtXmlAclValidate(const std::string &name, const pugi::xml_node &node)
virtual std::string NodeType()
AgentUtXmlAcl(const std::string &name, const boost::uuids::uuid &uuid, const pugi::xml_node &node, AgentUtXmlTestCase *test_case)
virtual bool ToXml(pugi::xml_node *parent)
virtual void ToString(std::string *str)
virtual void ToString(std::string *str)
void AddIdPerms(pugi::xml_node *parent)
virtual const std::string ToString()
virtual ~AgentUtXmlEthInterfaceValidate()
AgentUtXmlEthInterfaceValidate(const std::string &name, const boost::uuids::uuid &id, const pugi::xml_node &node)
virtual void ToString(std::string *str)
~AgentUtXmlEthInterface()
virtual std::string NodeType()
virtual bool ToXml(pugi::xml_node *parent)
AgentUtXmlEthInterface(const std::string &name, const boost::uuids::uuid &uuid, const pugi::xml_node &node, AgentUtXmlTestCase *test_case)
virtual uint32_t wait_count() const
virtual ~AgentUtXmlFlowValidate()
AgentUtXmlFlowValidate(const std::string &name, const pugi::xml_node &node)
virtual const std::string ToString()
virtual ~AgentUtXmlGlobalVrouterValidate()
virtual const std::string ToString()
AgentUtXmlGlobalVrouterValidate(const std::string &name, const boost::uuids::uuid &id, const pugi::xml_node &node)
int flow_export_rate() const
AgentUtXmlGlobalVrouter(const std::string &name, const boost::uuids::uuid &uuid, const pugi::xml_node &node, AgentUtXmlTestCase *test_case)
virtual bool ToXml(pugi::xml_node *parent)
virtual void ToString(std::string *str)
~AgentUtXmlGlobalVrouter()
virtual std::string NodeType()
std::string & vxlan_mode()
AgentUtXmlInstanceIp(const std::string &name, const boost::uuids::uuid &uuid, const pugi::xml_node &node, AgentUtXmlTestCase *test_case)
virtual void ToString(std::string *str)
virtual std::string NodeType()
virtual bool ToXml(pugi::xml_node *parent)
virtual const std::string ToString()
virtual ~AgentUtXmlL2RouteValidate()
AgentUtXmlL2RouteValidate(const std::string &name, const pugi::xml_node &node)
virtual void ToString(std::string *str)
virtual std::string NodeType()
virtual bool ToXml(pugi::xml_node *parent)
AgentUtXmlL2Route(const std::string &name, const boost::uuids::uuid &uuid, const pugi::xml_node &node, AgentUtXmlTestCase *test_case)
virtual const std::string ToString()
AgentUtXmlL3RouteValidate(const std::string &name, const pugi::xml_node &node)
virtual ~AgentUtXmlL3RouteValidate()
virtual std::string NodeType()
AgentUtXmlL3Route(const std::string &name, const boost::uuids::uuid &uuid, const pugi::xml_node &node, AgentUtXmlTestCase *test_case)
virtual bool ToXml(pugi::xml_node *parent)
virtual void ToString(std::string *str)
const pugi::xml_node & node() const
const std::string & name() const
boost::uuids::uuid vn_uuid_
AgentUtXmlNova(const std::string &name, const boost::uuids::uuid &uuid, const pugi::xml_node &node, AgentUtXmlTestCase *test_case)
virtual std::string NodeType()
virtual bool ToXml(pugi::xml_node *parent)
virtual void ToString(std::string *str)
boost::uuids::uuid vm_uuid_
virtual void ToString(std::string *str)
virtual std::string NodeType()
virtual bool ToXml(pugi::xml_node *parent)
AgentUtXmlSg(const std::string &name, const boost::uuids::uuid &uuid, const pugi::xml_node &node, AgentUtXmlTestCase *test_case)
AgentUtXmlTag(const std::string &name, const boost::uuids::uuid &uuid, const pugi::xml_node &node, AgentUtXmlTestCase *test_case)
virtual std::string NodeType()
virtual bool ToXml(pugi::xml_node *parent)
virtual void ToString(std::string *str)
void AddValidateEntry(const std::string &name, AgentUtXmlTestValidateCreateFn fn)
void AddConfigEntry(const std::string &name, AgentUtXmlTestConfigCreateFn fn)
const pugi::xml_node & node() const
virtual uint32_t wait_count() const
const std::string & name() const
bool delete_marked() const
boost::uuids::uuid vn_uuid_
AgentUtXmlVmInterfaceValidate(const std::string &name, const boost::uuids::uuid &id, const pugi::xml_node &node)
virtual ~AgentUtXmlVmInterfaceValidate()
virtual const std::string ToString()
boost::uuids::uuid vm_uuid_
std::vector< uint16_t > fat_flow_port_
AgentUtXmlVmInterface(const std::string &name, const boost::uuids::uuid &uuid, const pugi::xml_node &node, AgentUtXmlTestCase *test_case)
boost::uuids::uuid vn_uuid_
virtual bool ToXml(pugi::xml_node *parent)
virtual std::string NodeType()
virtual void ToString(std::string *str)
virtual const std::string ToString()
AgentUtXmlVmValidate(const std::string &name, const boost::uuids::uuid &id, const pugi::xml_node &node)
virtual ~AgentUtXmlVmValidate()
virtual std::string NodeType()
virtual void ToString(std::string *str)
AgentUtXmlVm(const std::string &name, const boost::uuids::uuid &uuid, const pugi::xml_node &node, AgentUtXmlTestCase *test_case)
virtual bool ToXml(pugi::xml_node *parent)
virtual bool ToXml(pugi::xml_node *parent)
virtual std::string NodeType()
AgentUtXmlVmiVrf(const std::string &name, const boost::uuids::uuid &uuid, const pugi::xml_node &node, AgentUtXmlTestCase *test_case)
virtual void ToString(std::string *str)
virtual const std::string ToString()
virtual ~AgentUtXmlVnValidate()
AgentUtXmlVnValidate(const std::string &name, const boost::uuids::uuid &id, const pugi::xml_node &node)
AgentUtXmlVn(const std::string &name, const boost::uuids::uuid &uuid, const pugi::xml_node &node, AgentUtXmlTestCase *test_case)
std::string & network_id()
std::string & flood_unknown_unicast()
std::string flood_unknown_unicast_
virtual void ToString(std::string *str)
virtual std::string NodeType()
virtual bool ToXml(pugi::xml_node *parent)
AgentUtXmlVrfValidate(const std::string &name, const pugi::xml_node &node)
virtual ~AgentUtXmlVrfValidate()
virtual const std::string ToString()
virtual bool ToXml(pugi::xml_node *parent)
virtual std::string NodeType()
AgentUtXmlVrf(const std::string &name, const boost::uuids::uuid &uuid, const pugi::xml_node &node, AgentUtXmlTestCase *test_case)
virtual void ToString(std::string *str)
virtual ~AgentUtXmlVxlanValidate()
AgentUtXmlVxlanValidate(const std::string &name, const boost::uuids::uuid &id, const pugi::xml_node &node)
virtual const std::string ToString()
std::string flood_unknown_unicast_
VrfTable * vrf_table() const
static Agent * GetInstance()
const std::string & fabric_vrf_name() const
Ip4Address router_id() const
BridgeRouteEntry * FindRoute(const MacAddress &mac)
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)
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)
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)
int32_t flow_export_rate() const
InetUnicastRouteEntry * FindRoute(const IpAddress &ip)
static void AddRemoteVmRouteReq(const Peer *peer, const string &vm_vrf, const IpAddress &vm_addr, uint8_t plen, AgentRouteData *data)
static void DeleteReq(const Peer *peer, const string &vrf_name, const IpAddress &addr, uint8_t plen, AgentRouteData *data)
static MacAddress FromString(const std::string &str, boost::system::error_code *error=NULL)
static const uint32_t kRpfDiscardIndex
GlobalVrouter * global_vrouter() const
static const uint32_t DROP_FLAGS
static TunnelEncapType::Encap TunnelEncapFromString(const std::string &encap)
VmInterface::VmiType vmi_type() const
VmInterface::DeviceType device_type() const
uint16_t rx_vlan_id() const
const VnEntry * vn() const
const boost::uuids::uuid & GetUuid() const
const string & GetName() const
const VxLanId * vxlan_id_ref() const
const string & GetName() const
bool flood_unknown_unicast() const
const VrfEntry * GetVrf() const
AgentRouteTable * GetEvpnRouteTable(const std::string &vrf_name)
AgentRouteTable * GetBridgeRouteTable(const std::string &vrf_name)
InetUnicastAgentRouteTable * GetInet4UnicastRouteTable(const std::string &vrf_name)
const NextHop * nexthop() const
uint32_t vxlan_id() const
bool GetIntAttribute(const xml_node &node, const string &name, int *value)
bool GetUintAttribute(const xml_node &node, const string &name, uint16_t *value)
xml_node AddXmlNodeWithValue(xml_node *parent, const char *name, const string &value)
xml_node AddXmlNodeWithIntValue(xml_node *parent, const char *name, int val)
void LinkXmlNode(xml_node *parent, const string <ype, const string lname, const string &rtype, const string rname)
xml_node AddXmlNodeWithAttr(xml_node *parent, const char *attr)
bool GetStringAttribute(const xml_node &node, const string &name, string *value)
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)
VnListType source_vn_list
static string DeviceTypeToString(VmInterface::DeviceType type)
AgentUtXmlNode * CreateNode(const string &type, const string &name, const uuid &id, const xml_node &node, AgentUtXmlTestCase *test_case)
static string VmiTypeToString(VmInterface::VmiType type)
static bool MatchFlowAction(FlowEntry *flow, const string &str)
void AgentUtXmlOperInit(AgentUtXmlTest *test)
AgentUtXmlValidationNode * CreateValidateNode(const string &type, const string &name, const uuid &id, const xml_node &node)