9 #include <pugixml/pugixml.hpp>
10 #include <boost/uuid/uuid.hpp>
12 #include <test/test_cmn_util.h>
13 #include <pkt/test/test_pkt_util.h>
24 using namespace boost::uuids;
28 const string &name,
const uuid &
id,
29 const xml_node &node) {
30 if (
type ==
"global-vrouter-config")
32 if (
type ==
"virtual-network" ||
type ==
"vn")
34 if (
type ==
"virtual-machine" ||
type ==
"vm")
38 if (
type ==
"virtual-machine-interface" ||
type ==
"vm-interface"
41 if (
type ==
"ethernet-interface" ||
type ==
"eth-port")
45 if (
type ==
"routing-instance" ||
type ==
"vrf")
47 if (
type ==
"access-control-list" ||
type ==
"acl")
49 if (
type ==
"pkt-parse")
53 if (
type ==
"l3-route")
59 const uuid &
id,
const xml_node &node,
61 if (
type ==
"global-vrouter-config")
63 if (
type ==
"virtual-network" ||
type ==
"vn")
65 if (
type ==
"virtual-machine" ||
type ==
"vm")
67 if (
type ==
"virtual-machine-interface" ||
type ==
"vm-interface"
70 if (
type ==
"ethernet-interface" ||
type ==
"eth-port")
72 if (
type ==
"routing-instance" ||
type ==
"vrf")
74 if (
type ==
"access-control-list" ||
type ==
"acl")
76 if (
type ==
"virtual-machine-interface-routing-instance" ||
79 if (
type ==
"fdb" ||
type ==
"l2-route")
81 if (
type ==
"l3-route")
83 if (
type ==
"sg" ||
type ==
"securiy-group")
85 if (
type ==
"iip" ||
type ==
"instance-ip")
114 test->
AddConfigEntry(
"virtual-machine-interface-routing-instance",
152 const xml_node &node,
193 return "global-vrouter-config";
200 const xml_node &node,
223 xml_node n1 = n.append_child(
"virtual-network-properties");
227 xml_node n1 = n.append_child(
"virtual-network-properties");
249 return "virtual-network";
256 const xml_node &node,
283 return "virtual-machine";
291 const xml_node &node,
344 xml_attribute attr =
node().attribute(
"fat-flow");
345 for (;attr != xml_attribute(); attr = attr.next_attribute()) {
346 if (std::string(attr.name()) ==
"fat-flow") {
347 uint32_t value = attr.as_uint();
361 xml_node n1 = n.append_child(
"virtual-machine-interface-mac-address");
366 n1 = n.append_child(
"virtual-machine-interface-properties");
372 n1 = n.append_child(
"virtual-machine-interface-fat-flow-protocols");
373 std::vector<uint16_t>::const_iterator it =
fat_flow_port_.begin();
375 xml_node n2 = n1.append_child(
"fat-flow-protocol");
384 boost::system::error_code ec;
400 LinkXmlNode(parent,
"virtual-machine-interface-routing-instance",
401 str,
"routing-instance",
vrf_);
404 "virtual-machine-interface-routing-instance", str);
421 return "virtual-machine-interface";
429 const xml_node &node,
453 return "physical-interface";
457 cout <<
"Create Ethernet Interface" << endl;
464 const xml_node &node,
498 return "routing-instance";
505 const xml_node &node,
522 xml_node n1 = n.append_child(
"value");
537 return "virtual-machine-interface-routing-instance";
544 const xml_node &node,
556 for (xml_node n =
node().first_child(); n; n = n.next_sibling()) {
557 if (strcmp(n.name(),
"ace") != 0) {
606 xml_node n1 = n.append_child(
"access-control-list-entries");
611 xml_node n2 = n1.append_child(
"acl-rule");
613 xml_node n3 = n2.append_child(
"match-condition");
616 xml_node n4 = n3.append_child(
"src-address");
628 xml_node n5 = n4.append_child(
"subnet");
633 n4 = n3.append_child(
"dst-address");
643 xml_node n5 = n4.append_child(
"subnet");
649 n4 = n3.append_child(
"src-port");
657 n4 = n3.append_child(
"dst-port");
665 n3 = n2.append_child(
"action-list");
680 return "access-control-list";
687 const xml_node &node,
713 str =
"ingress-access-control-list-" +
ingress_;
718 str =
"egress-access-control-list-" +
egress_;
732 return "security-group";
739 const xml_node &node,
778 const xml_node &node,
816 "virtual-machine-interface",
vmi_);
829 return "instance-ip";
836 const xml_node &node,
849 cout <<
"Attribute \"mac\" not specified for nova. Skipping"
856 cout <<
"Attribute \"vm-uuid\" not specified for nova. Skipping"
863 cout <<
"Attribute \"vn-uuid\" not specified for nova. Skipping"
870 cout <<
"Attribute \"vm_name\" not specified for nova. Skipping"
876 cout <<
"Attribute \"ip\" not specified for nova. Skipping"
900 boost::system::error_code ec;
912 const xml_node &node) :
940 return "global-vrouter-config";
948 const xml_node &node) :
950 vxlan_id_ref_(false) {
997 return "virtual-network";
1005 const xml_node &node) :
1021 return "virtual-machine";
1029 const xml_node &node) :
1031 flood_unknown_unicast_() {
1048 return (vxlan == NULL);
1070 if (
vrf_.empty() ==
false) {
1098 const xml_node &node) :
1123 return "VM-Sub-Intf";
1153 if (
active_.empty() ==
false) {
1154 if (boost::iequals(
active_,
"true") ||
1155 (boost::iequals(
active_,
"0") ==
false)){
1156 if (VmPortActive(
id()) ==
false)
1159 if (VmPortActive(
id()) ==
true)
1194 return "virtual-machine-interface";
1202 const xml_node &node) :
1218 return "eth-interface";
1225 const xml_node &node) :
1241 if (
present() && (vrf == NULL)) {
1243 }
else if (!
present() && (vrf != NULL)) {
1260 return (vrf->
vn() == NULL);
1263 if (vrf->
vn() == NULL)
1277 const xml_node &node) :
1290 return AclFind(
id());
1292 return !AclFind(
id());
1297 return "access-control-list";
1304 const xml_node &node) :
1320 cout <<
"Attribute \"sip\" not specified for Flow. Skipping" << endl;
1325 cout <<
"Attribute \"dip\" not specified for Flow. Skipping" << endl;
1331 cout <<
"Attribute \"proto\" not specified for Flow. Skipping"
1342 cout <<
"Attribute \"sport\" not specified for Flow. Skipping"
1348 cout <<
"Attribute \"dport\" not specified for Flow. Skipping"
1349 << endl;
return false;
1370 if (str ==
"pass") {
1374 if (str ==
"deny") {
1388 cout <<
" flow <" <<
name() <<
"> not found with nh=" <<
nh_id_
1389 <<
" (key: vrf=" <<
vrf_ <<
" " <<
sip_ <<
" -> " <<
dip_
1402 cout <<
" ==> MATCHES with nh=\"" << nh->
id() <<
"\""
1403 <<
" (nh type=" << nh->
GetType()
1404 <<
", " << nh->
ToString() <<
")" << endl;
1407 if (found ==
false) {
1408 cout <<
" ==> no nexthop index yields this flow; the flow itself was"
1409 " not created (check the packet, not the nh)" << endl;
1420 uint32_t matches = 0;
1429 if (result == NULL) {
1431 *found_nh = nh->
id();
1437 cout <<
" flow <" <<
name() <<
"> matches " << matches
1438 <<
" nexthops; the key is ambiguous -- specify nh= explicitly"
1447 uint16_t used_nh =
nh_id_;
1454 if (
deleted_ ==
"true" && flow == NULL) {
1459 return (flow == NULL);
1469 cout <<
" flow <" <<
name() <<
"> resolved to nh=" << used_nh << endl;
1504 (flow->
data().
rpf_nh.get()->id() != nh_id))) {
1512 return (
"flow <" +
name() +
">");
1527 const xml_node &node,
1538 cout <<
"Attribute \"mac\" not specified. Skipping" << endl;
1543 cout <<
"Attribute \"vrf_\" not specified. Skipping" << endl;
1584 sg_list.push_back(
sg_id_);
1604 vn_list.insert(
vn_);
1611 vn_list, sg_list, tag_list,
1616 Ip4Address::from_string(
ip_),
1626 const xml_node &node) :
1635 cout <<
"Attribute \"mac\" not specified. Skipping" << endl;
1640 cout <<
"Attribute \"vrf_\" not specified. Skipping" << endl;
1645 cout <<
"Attribute \"vn\" not specified. Skipping" << endl;
1651 boost::system::error_code ec;
1652 ip_ = IpAddress::from_string(addr, ec);
1670 return (rt == NULL);
1682 return (
"FDB <" +
name() +
">");
1686 const xml_node &node,
1697 cout <<
"Attribute \"ip\" not specified. Skipping" << endl;
1702 cout <<
"Attribute \"vrf_\" not specified. Skipping" << endl;
1744 sg_list.push_back(
sg_id_);
1763 vn_list.insert(
vn_);
1770 vn_list, sg_list, tag_list,
1782 const xml_node &node) :
1791 cout <<
"Attribute \"mac\" not specified. Skipping" << endl;
1796 cout <<
"Attribute \"vrf_\" not specified. Skipping" << endl;
1801 cout <<
"Attribute \"vn\" not specified. Skipping" << endl;
1807 boost::system::error_code ec;
1808 ip_ = IpAddress::from_string(addr, ec);
1826 return (rt == NULL);
1838 return (
"IP route <" +
name() +
">");
boost::asio::ip::address_v4 Ip4Address
std::vector< uint64_t > 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
FlowEntry * FindFlowAnyNh(uint16_t *found_nh)
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
NextHopTable * nexthop_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)
virtual DBEntry * GetNext(const DBEntryBase *entry)
virtual DBEntry * GetFirst()
virtual DBTablePartBase * GetTablePartition(const DBRequestKey *key)
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
virtual std::string ToString() const
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)