Skip to content

Commit

Permalink
Don't pick v6 ip address for BGPaaS clients
Browse files Browse the repository at this point in the history
Don't select a v6 address while picking address for BGPaaS because it is not supported by the back end.
Also, don't create default-bgp-as-a-service object

Closes-Bug: 1543713
Closes-Bug: 1543715

Change-Id: I85abefb812efc8818641935e6e57cb77f3b1f1d6
  • Loading branch information
Sachin Bansal committed Feb 10, 2016
1 parent b1b4855 commit c126f39
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 19 deletions.
1 change: 1 addition & 0 deletions src/config/api-server/vnc_cfg_api_server.py
Expand Up @@ -1268,6 +1268,7 @@ def __init__(self, args_str=None):
self.get_resource_class('logical-interface').generate_default_instance = False
self.get_resource_class('api-access-list').generate_default_instance = False
self.get_resource_class('dsa-rule').generate_default_instance = False
self.get_resource_class('bgp-as-a-service').generate_default_instance = False

for act_res in _ACTION_RESOURCES:
link = LinkObject('action', self._base_url, act_res['uri'],
Expand Down
24 changes: 14 additions & 10 deletions src/config/schema-transformer/config_db.py
Expand Up @@ -3082,17 +3082,15 @@ def get_any_instance_ip_address(self, ip_version=0):
continue
if not ip.service_instance_ip:
continue
if not ip_version or IPAddress(ip.address).version == ip_version:
if not ip_version or ip.ip_version == ip_version:
return ip.address
return None
# end get_any_instance_ip_address

def get_primary_instance_ip_address(self):
def get_primary_instance_ip_address(self, ip_version=4):
for ip_name in self.instance_ips:
ip = InstanceIpST.get(ip_name)
if ip.address is None:
continue
if ip.is_primary():
if ip.is_primary() and ip.address and ip_version == ip.ip_version:
return ip.address
return None
# end get_primary_instance_ip_address
Expand Down Expand Up @@ -3234,16 +3232,16 @@ def recreate_vrf_assign_table(self):
for ip_name in self.instance_ips:
ip = InstanceIpST.get(ip_name)
if ip and ip.address:
ip_list.append(ip.address)
ip_list.append(ip)
for ip_name in self.floating_ips:
ip = FloatingIpST.get(ip_name)
if ip and ip.address:
ip_list.append(ip.address)
ip_list.append(ip)
for ip in ip_list:
if IPAddress(ip).version == 6:
address = AddressType(subnet=SubnetType(ip, 128))
if ip.ip_version == 6:
address = AddressType(subnet=SubnetType(ip.address, 128))
else:
address = AddressType(subnet=SubnetType(ip, 32))
address = AddressType(subnet=SubnetType(ip.address, 32))

mc = MatchConditionType(src_address=address,
protocol='any',
Expand Down Expand Up @@ -3321,12 +3319,15 @@ def __init__(self, name, obj=None):
self.name = name
self.is_secondary = False
self.virtual_machine_interfaces = set()
self.ip_version = None
self.update(obj)
# end __init

def update(self, obj=None):
self.obj = obj or self.read_vnc_obj(fq_name=self.name)
self.address = self.obj.get_instance_ip_address()
if self.address:
self.ip_version = IPAddress(self.address).version
self.service_instance_ip = self.obj.get_service_instance_ip()
self.is_secondary = self.obj.get_instance_ip_secondary() or False
self.update_multiple_refs('virtual_machine_interface', self.obj)
Expand Down Expand Up @@ -3361,12 +3362,15 @@ class FloatingIpST(DBBaseST):
def __init__(self, name, obj=None):
self.name = name
self.virtual_machine_interface = None
self.ip_version = None
self.update(obj)
# end __init

def update(self, obj=None):
self.obj = obj or self.read_vnc_obj(fq_name=self.name)
self.address = self.obj.get_floating_ip_address()
if self.address:
self.ip_version = IPAddress(self.address).version
self.update_single_ref('virtual_machine_interface', self.obj)
# end update

Expand Down
37 changes: 28 additions & 9 deletions src/config/schema-transformer/test/test_service.py
Expand Up @@ -2469,7 +2469,8 @@ def test_misc(self):
def test_bgpaas(self):
# create vn1
vn1_name = self.id() + 'vn1'
vn1_obj = self.create_virtual_network(vn1_name, '10.0.0.0/24')
vn1_obj = self.create_virtual_network(vn1_name,
['10.0.0.0/24', '1000::/16'])

project_name = ['default-domain', 'default-project']
project_obj = self._vnc_lib.project_read(fq_name=project_name)
Expand All @@ -2478,31 +2479,49 @@ def test_bgpaas(self):
port_obj.add_virtual_network(vn1_obj)
self._vnc_lib.virtual_machine_interface_create(port_obj)

v6_obj = InstanceIp(name=port_name+'-v6')
v6_obj.set_virtual_machine_interface(port_obj)
v6_obj.set_virtual_network(vn1_obj)
v6_obj.set_instance_ip_family('v6')
self._vnc_lib.instance_ip_create(v6_obj)

v4_obj = InstanceIp(name=port_name+'-v4')
v4_obj.set_virtual_machine_interface(port_obj)
v4_obj.set_virtual_network(vn1_obj)
v4_obj.set_instance_ip_family('v4')
self._vnc_lib.instance_ip_create(v4_obj)

bgpaas_name = self.id() + 'bgp1'
bgpaas = BgpAsAService(bgpaas_name, parent_obj=project_obj)
bgpaas.add_virtual_machine_interface(port_obj)
self._vnc_lib.bgp_as_a_service_create(bgpaas)

router1_name = vn1_obj.get_fq_name_str() + ':' + vn1_name + ':' + port_name
self.wait_to_get_object(config_db.BgpAsAServiceST,
bgpaas.get_fq_name_str())
self.wait_to_get_object(config_db.BgpRouterST,
vn1_obj.get_fq_name_str() + ':' + vn1_name + ':' + port_name)
self.wait_to_get_object(config_db.BgpRouterST, router1_name)
router1_obj = self._vnc_lib.bgp_router_read(fq_name_str=router1_name)
self.assertEqual(router1_obj.get_bgp_router_parameters().address,
'10.0.0.252')

port2_name = self.id() + 'p2'
port2_obj = VirtualMachineInterface(port2_name, parent_obj=project_obj)
port2_obj.add_virtual_network(vn1_obj)
self._vnc_lib.virtual_machine_interface_create(port2_obj)
bgpaas.add_virtual_machine_interface(port2_obj)
self._vnc_lib.bgp_as_a_service_update(bgpaas)
self.wait_to_get_object(config_db.BgpRouterST,
vn1_obj.get_fq_name_str() + ':' + vn1_name + ':' + port2_name)
router2_name = vn1_obj.get_fq_name_str() + ':' + vn1_name + ':' + port2_name
self.wait_to_get_object(config_db.BgpRouterST, router2_name)

bgpaas.del_virtual_machine_interface(port_obj)
self._vnc_lib.bgp_as_a_service_update(bgpaas)
self.wait_to_delete_object(config_db.BgpRouterST,
vn1_obj.get_fq_name_str() + ':' + vn1_name + ':' + port_name)
self.wait_to_delete_object(config_db.BgpRouterST, router1_name)
self._vnc_lib.bgp_as_a_service_delete(id=bgpaas.uuid)
self.wait_to_delete_object(config_db.BgpRouterST,
vn1_obj.get_fq_name_str() + ':' + vn1_name + ':' + port2_name)
self.wait_to_delete_object(config_db.BgpRouterST, router2_name)

self._vnc_lib.instance_ip_delete(id=v6_obj.uuid)
self._vnc_lib.instance_ip_delete(id=v4_obj.uuid)
self._vnc_lib.virtual_machine_interface_delete(id=port_obj.uuid)
self._vnc_lib.virtual_machine_interface_delete(id=port2_obj.uuid)
# end test_bgpaas
# end class TestRouteTable

0 comments on commit c126f39

Please sign in to comment.