diff --git a/src/config/common/svc_info.py b/src/config/common/svc_info.py index 717aa1f70ce..8b1be12cce4 100644 --- a/src/config/common/svc_info.py +++ b/src/config/common/svc_info.py @@ -24,33 +24,6 @@ _SNAT_SVC_TYPE = 'source-nat' _LB_SVC_TYPE = 'loadbalancer' -def get_left_vn(parent_str, vn): - if vn is None: - return None - if vn == "": - return(parent_str + ':' + _SVC_VN_LEFT) - else: - return vn -# end get_left_vn - -def get_right_vn(parent_str, vn): - if vn is None: - return None - if vn == "": - return(parent_str + ':' + _SVC_VN_RIGHT) - else: - return vn -# end get_right_vn - -def get_management_vn(parent_str, vn): - if vn is None: - return None - if vn == "": - return(parent_str + ':' + _SVC_VN_MGMT) - else: - return vn -# end get_management_vn - def get_management_if_str(): return _MGMT_STR diff --git a/src/config/schema-transformer/to_bgp.py b/src/config/schema-transformer/to_bgp.py index 2e3603bf79c..5cca2eb41be 100644 --- a/src/config/schema-transformer/to_bgp.py +++ b/src/config/schema-transformer/to_bgp.py @@ -131,6 +131,35 @@ def locate(cls, name, *args): # end DictST +def get_si_vns(si_obj, si_props): + left_vn = None + right_vn = None + + st_refs = si_obj.get_service_template_refs() + uuid = st_refs[0]['uuid'] + st_obj = _vnc_lib.service_template_read(id=uuid) + st_props = st_obj.get_service_template_properties() + if st_props.get_ordered_interfaces(): + st_if_list = st_props.get_interface_type() + si_if_list = si_props.get_interface_list() + for idx in range(0, len(st_if_list)): + st_if = st_if_list[idx] + si_if = si_if_list[idx] + if st_if.get_service_interface_type() == 'left': + left_vn = si_if.get_virtual_network() + elif st_if.get_service_interface_type() == 'right': + right_vn = si_if.get_virtual_network() + else: + left_vn = si_props.get_left_virtual_network() + right_vn = si_props.get_right_virtual_network() + + if left_vn == "": + left_vn = parent_str + ':' + svc_info.get_left_vn_name() + if right_vn == "": + right_vn = parent_str + ':' + svc_info.get_right_vn_name() + + return left_vn, right_vn +# end get_si_vns def _access_control_list_update(acl_obj, name, obj, entries): if acl_obj is None: @@ -685,10 +714,7 @@ def _get_routing_instance_from_route(self, next_hop): _sandesh._logger.debug("%s: route table next hop must be service " "instance with auto policy", self.name) return None - left_vn_str = svc_info.get_left_vn(si.get_parent_fq_name_str(), - si_props.left_virtual_network) - right_vn_str = svc_info.get_right_vn(si.get_parent_fq_name_str(), - si_props.right_virtual_network) + left_vn_str, right_vn_str = get_si_vns(si, si_props) if (not left_vn_str or not right_vn_str): _sandesh._logger.debug("%s: route table next hop service instance " "must have left and right virtual networks", @@ -2914,10 +2940,7 @@ def add_service_instance_properties(self, idents, meta): return si = _vnc_lib.service_instance_read(fq_name_str=si_name) si_props = si.get_service_instance_properties() - left_vn_str = svc_info.get_left_vn(si.get_parent_fq_name_str(), - si_props.left_virtual_network) - right_vn_str = svc_info.get_right_vn(si.get_parent_fq_name_str(), - si_props.right_virtual_network) + left_vn_str, right_vn_str = get_si_vns(si, si_props) if (not left_vn_str or not right_vn_str): _sandesh._logger.debug( "%s: route table next hop service instance must " diff --git a/src/config/svc-monitor/svc_monitor/instance_manager.py b/src/config/svc-monitor/svc_monitor/instance_manager.py index 4aed71a44c9..52d26392285 100644 --- a/src/config/svc-monitor/svc_monitor/instance_manager.py +++ b/src/config/svc-monitor/svc_monitor/instance_manager.py @@ -527,7 +527,9 @@ def _create_snat_vn(self, proj_obj, si_obj, si_props, vn_fq_name_str): vn_id = self._create_svc_vn(vn_name, snat_cidr, proj_obj) if vn_fq_name_str != ':'.join(vn_fq_name): - si_props.set_left_virtual_network(':'.join(vn_fq_name)) + left_if = ServiceInstanceInterfaceType( + virtual_network=':'.join(vn_fq_name)) + si_props.insert_interface_list(0, left_if) si_obj.set_service_instance_properties(si_props) self._vnc_lib.service_instance_update(si_obj) self.logger.log("Info: SI %s updated with left vn %s" % diff --git a/src/config/vnc_openstack/vnc_openstack/neutron_plugin_db.py b/src/config/vnc_openstack/vnc_openstack/neutron_plugin_db.py index fad7194333f..a841ddc0ff2 100644 --- a/src/config/vnc_openstack/vnc_openstack/neutron_plugin_db.py +++ b/src/config/vnc_openstack/vnc_openstack/neutron_plugin_db.py @@ -2906,10 +2906,16 @@ def _router_set_external_gateway(self, router_obj, ext_net_obj): si_created = True #TODO(ethuleau): For the fail-over SNAT set scale out to 2 si_prop_obj = ServiceInstanceType( - right_virtual_network=ext_net_obj.get_fq_name_str(), scale_out=ServiceScaleOutType(max_instances=1, auto_scale=True), auto_policy=True) + + # set right interface in order of [left, right] to match template + left_if = ServiceInstanceInterfaceType() + right_if = ServiceInstanceInterfaceType( + virtual_network=ext_net_obj.get_fq_name_str()) + si_prop_obj.set_interface_list([left_if, right_if]) + si_obj.set_service_instance_properties(si_prop_obj) si_obj.set_service_template(st_obj) if si_created: diff --git a/src/vnsw/agent/oper/service_instance.cc b/src/vnsw/agent/oper/service_instance.cc index 3547cfb4354..98099243912 100644 --- a/src/vnsw/agent/oper/service_instance.cc +++ b/src/vnsw/agent/oper/service_instance.cc @@ -177,20 +177,14 @@ static void FindAndSetInterfaces( const autogen::ServiceInstanceType &si_properties = svc_instance->properties(); - properties->interface_count = 0; /* * The outside virtual-network is always specified (by the * process that creates the service-instance). - */ - if (si_properties.right_virtual_network.length()) { - properties->interface_count += 1; - } - /* * The inside virtual-network is optional for loadbalancer. */ - if (si_properties.left_virtual_network.length()) { - properties->interface_count += 1; - } + properties->interface_count = si_properties.interface_list.size(); + std::string left_netname = si_properties.interface_list[0].virtual_network; + std::string right_netname = si_properties.interface_list[1].virtual_network; /* * Lookup for VMI nodes @@ -211,11 +205,11 @@ static void FindAndSetInterfaces( } std::string netname = vn_node->name(); - if (netname == si_properties.left_virtual_network) { + if (netname == left_netname) { properties->vmi_inside = IdPermsGetUuid(vmi->id_perms()); properties->mac_addr_inside = vmi->mac_addresses().at(0); properties->ip_addr_inside = FindInterfaceIp(graph, adj); - } else if (netname == si_properties.right_virtual_network) { + } else if (netname == right_netname) { properties->vmi_outside = IdPermsGetUuid(vmi->id_perms()); properties->mac_addr_outside = vmi->mac_addresses().at(0); properties->ip_addr_outside = FindInterfaceIp(graph, adj); @@ -231,11 +225,11 @@ static void FindAndSetInterfaces( const autogen::VnSubnetsType &subnets = ipam->data(); for (unsigned int i = 0; i < subnets.ipam_subnets.size(); ++i) { int prefix_len = subnets.ipam_subnets[i].subnet.ip_prefix_len; - if (netname == si_properties.left_virtual_network && + if (netname == left_netname && SubNetContainsIpv4(subnets.ipam_subnets[i], properties->ip_addr_inside)) { properties->ip_prefix_len_inside = prefix_len; - } else if (netname == si_properties.right_virtual_network && + } else if (netname == right_netname && SubNetContainsIpv4(subnets.ipam_subnets[i], properties->ip_addr_outside)) { properties->ip_prefix_len_outside = prefix_len;