Add apic-no-external-cidrs field to OpenStack CLI network resource
Change-Id: I56013000c1dc2d1fc8bd6ca1b3878f92258e5864
(cherry picked from commit ea99955aa2)
			
			
This commit is contained in:
		
				
					committed by
					
						
						Sayali Vidyadhar Naval
					
				
			
			
				
	
			
			
			
						parent
						
							760173e725
						
					
				
				
					commit
					ac84bbeb7e
				
			@@ -88,6 +88,9 @@ def _get_attrs_network_extension(client_manager, parsed_args):
 | 
			
		||||
        if parsed_args.apic_external_cidrs:
 | 
			
		||||
            attrs['apic:external_cidrs'
 | 
			
		||||
                  ] = parsed_args.apic_external_cidrs.split(",")
 | 
			
		||||
        if 'apic_no_external_cidrs' in parsed_args and \
 | 
			
		||||
           parsed_args.apic_no_external_cidrs:
 | 
			
		||||
            attrs['apic:external_cidrs'] = []
 | 
			
		||||
    return attrs
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -423,10 +426,20 @@ class SetNetworkExtension(hooks.CommandHook):
 | 
			
		||||
            help=_("APIC external CIDRS for external network\n"
 | 
			
		||||
                   "For external type networks only\n"
 | 
			
		||||
                   "Data is passed as comma separated valid ip subnets\n"
 | 
			
		||||
                   "Need to pass the --external argument wth this field\n"
 | 
			
		||||
                   "Default value is ['0.0.0.0/0']\n"
 | 
			
		||||
                   "Syntax Example: 10.10.10.0/24 "
 | 
			
		||||
                   "or 10.10.10.0/24,20.20.20.0/24 ")
 | 
			
		||||
        )
 | 
			
		||||
        parser.add_argument(
 | 
			
		||||
            '--apic-no-external-cidrs',
 | 
			
		||||
            dest='apic_no_external_cidrs',
 | 
			
		||||
            action='store_true',
 | 
			
		||||
            help=_("Reset APIC external CIDRS for external network\n"
 | 
			
		||||
                   "For external type networks only\n"
 | 
			
		||||
                   "Need to pass the --external argument wth this field\n"
 | 
			
		||||
                   "Resets the apic:external_cidrs field to 0.0.0.0/0 ")
 | 
			
		||||
        )
 | 
			
		||||
        return parser
 | 
			
		||||
 | 
			
		||||
    def get_epilog(self):
 | 
			
		||||
 
 | 
			
		||||
@@ -34,6 +34,7 @@ class TestNetworkCreate(test_network.TestNetwork, test_cli20.CLITestV20Base):
 | 
			
		||||
    def test_create_default_options(self):
 | 
			
		||||
        arglist = [
 | 
			
		||||
            self._network.name,
 | 
			
		||||
            "--external",
 | 
			
		||||
        ]
 | 
			
		||||
        verifylist = [
 | 
			
		||||
            ('name', self._network.name),
 | 
			
		||||
@@ -62,6 +63,7 @@ class TestNetworkCreate(test_network.TestNetwork, test_cli20.CLITestV20Base):
 | 
			
		||||
        self.network.create_network.assert_called_once_with(**{
 | 
			
		||||
            'admin_state_up': True,
 | 
			
		||||
            'name': self._network.name,
 | 
			
		||||
            'router:external': True,
 | 
			
		||||
        })
 | 
			
		||||
 | 
			
		||||
    def test_create_all_options(self):
 | 
			
		||||
@@ -235,3 +237,41 @@ class TestNetworkSet(test_network.TestNetwork, test_cli20.CLITestV20Base):
 | 
			
		||||
        self.network.update_network.assert_called_once_with(
 | 
			
		||||
            self._network, **attrs)
 | 
			
		||||
        self.assertIsNone(result)
 | 
			
		||||
 | 
			
		||||
    def test_set_apic_no_external_cidrs(self):
 | 
			
		||||
        arglist = [
 | 
			
		||||
            self._network.name,
 | 
			
		||||
            "--external",
 | 
			
		||||
            "--apic-no-external-cidrs",
 | 
			
		||||
        ]
 | 
			
		||||
        verifylist = [
 | 
			
		||||
            ('network', self._network.name),
 | 
			
		||||
            ('external', True),
 | 
			
		||||
            ('apic_nested_domain_name', None),
 | 
			
		||||
            ('apic_nested_domain_type', None),
 | 
			
		||||
            ('apic_external_cidrs', None),
 | 
			
		||||
            ('apic_no_external_cidrs', True),
 | 
			
		||||
            ('apic_bgp_enable', None),
 | 
			
		||||
            ('apic_bgp_asn', None),
 | 
			
		||||
            ('apic_bgp_type', None),
 | 
			
		||||
            ('apic_nested_domain_infra_vlan', None),
 | 
			
		||||
            ('apic_nested_domain_allowed_vlans', None),
 | 
			
		||||
            ('apic_nested_domain_service_vlan', None),
 | 
			
		||||
            ('apic_nested_domain_node_network_vlan', None),
 | 
			
		||||
            ('apic_extra_provided_contracts', None),
 | 
			
		||||
            ('apic_extra_consumed_contracts', None),
 | 
			
		||||
            ('apic_policy_enforcement_pref', None),
 | 
			
		||||
        ]
 | 
			
		||||
        set_ext = network_ext.SetNetworkExtension(self.app)
 | 
			
		||||
        parsed_args = self.check_parser_ext(
 | 
			
		||||
            self.cmd, arglist, verifylist, set_ext)
 | 
			
		||||
        result = self.cmd.take_action(parsed_args)
 | 
			
		||||
 | 
			
		||||
        attrs = {
 | 
			
		||||
            'router:external': True,
 | 
			
		||||
            'apic:external_cidrs': [],
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        self.network.update_network.assert_called_once_with(
 | 
			
		||||
            self._network, **attrs)
 | 
			
		||||
        self.assertIsNone(result)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user