Add provider network options to osc network create
The following patch adds the provider network options to OSC "network create". Change-Id: Ib8449c00ee4b4285889588f03ddd7a686ce8f987 Partial-Bug: #1545537
This commit is contained in:
		@@ -18,6 +18,9 @@ Create new network
 | 
			
		||||
        [--share | --no-share]
 | 
			
		||||
        [--availability-zone-hint <availability-zone>]
 | 
			
		||||
        [--external [--default | --no-default] | --internal]
 | 
			
		||||
        [--provider-network-type <provider-network-type>]
 | 
			
		||||
        [--provider-physical-network <provider-physical-network>]
 | 
			
		||||
        [--provider-segmentation-id <provider-segmentation-id>]
 | 
			
		||||
        <name>
 | 
			
		||||
 | 
			
		||||
.. option:: --project <project>
 | 
			
		||||
@@ -83,6 +86,22 @@ Create new network
 | 
			
		||||
    By default, no network is set as an external network.
 | 
			
		||||
    (Network v2 only)
 | 
			
		||||
 | 
			
		||||
.. option:: --provider-network-type <provider-network-type>
 | 
			
		||||
 | 
			
		||||
    The physical mechanism by which the virtual network is implemented.
 | 
			
		||||
    The supported options are: flat, gre, local, vlan, vxlan
 | 
			
		||||
    (Network v2 only)
 | 
			
		||||
 | 
			
		||||
.. option:: --provider-physical-network <provider-physical-network>
 | 
			
		||||
 | 
			
		||||
    Name of the physical network over which the virtual network is implemented
 | 
			
		||||
    (Network v2 only)
 | 
			
		||||
 | 
			
		||||
.. option:: --provider-segmentation-id <provider-segmentation-id>
 | 
			
		||||
 | 
			
		||||
    VLAN ID for VLAN networks or tunnel-id for GRE/VXLAN networks
 | 
			
		||||
    (Network v2 only)
 | 
			
		||||
 | 
			
		||||
.. _network_create-name:
 | 
			
		||||
.. describe:: <name>
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -165,6 +165,26 @@ class CreateNetwork(common.NetworkAndComputeShowOne):
 | 
			
		||||
            action='store_true',
 | 
			
		||||
            help='Do not use the network as the default external network.'
 | 
			
		||||
                 'By default, no network is set as an external network.')
 | 
			
		||||
        parser.add_argument(
 | 
			
		||||
            '--provider-network-type',
 | 
			
		||||
            metavar='<provider-network-type>',
 | 
			
		||||
            choices=['flat', 'gre', 'local',
 | 
			
		||||
                     'vlan', 'vxlan'],
 | 
			
		||||
            help='The physical mechanism by which the virtual network '
 | 
			
		||||
                 'is implemented. The supported options are: '
 | 
			
		||||
                 'flat, gre, local, vlan, vxlan')
 | 
			
		||||
        parser.add_argument(
 | 
			
		||||
            '--provider-physical-network',
 | 
			
		||||
            metavar='<provider-physical-network>',
 | 
			
		||||
            dest='physical_network',
 | 
			
		||||
            help='Name of the physical network over which the virtual '
 | 
			
		||||
                 'network is implemented')
 | 
			
		||||
        parser.add_argument(
 | 
			
		||||
            '--provider-segmentation-id',
 | 
			
		||||
            metavar='<provider-segmentation-id>',
 | 
			
		||||
            dest='segmentation_id',
 | 
			
		||||
            help='VLAN ID for VLAN networks or tunnel-id for GRE/VXLAN '
 | 
			
		||||
                 'networks')
 | 
			
		||||
        return parser
 | 
			
		||||
 | 
			
		||||
    def update_parser_compute(self, parser):
 | 
			
		||||
@@ -185,6 +205,12 @@ class CreateNetwork(common.NetworkAndComputeShowOne):
 | 
			
		||||
                attrs['is_default'] = False
 | 
			
		||||
            if parsed_args.default:
 | 
			
		||||
                attrs['is_default'] = True
 | 
			
		||||
        if parsed_args.provider_network_type:
 | 
			
		||||
            attrs['provider:network_type'] = parsed_args.provider_network_type
 | 
			
		||||
        if parsed_args.physical_network:
 | 
			
		||||
            attrs['provider:physical_network'] = parsed_args.physical_network
 | 
			
		||||
        if parsed_args.segmentation_id:
 | 
			
		||||
            attrs['provider:segmentation_id'] = parsed_args.segmentation_id
 | 
			
		||||
        obj = client.create_network(**attrs)
 | 
			
		||||
        columns = _get_columns(obj)
 | 
			
		||||
        data = utils.get_item_properties(obj, columns, formatters=_formatters)
 | 
			
		||||
 
 | 
			
		||||
@@ -142,6 +142,9 @@ class TestCreateNetworkIdentityV3(TestNetwork):
 | 
			
		||||
            "--project-domain", identity_fakes_v3.domain_name,
 | 
			
		||||
            "--availability-zone-hint", "nova",
 | 
			
		||||
            "--external", "--default",
 | 
			
		||||
            "--provider-network-type", "vlan",
 | 
			
		||||
            "--provider-physical-network", "physnet1",
 | 
			
		||||
            "--provider-segmentation-id", "400",
 | 
			
		||||
            self._network.name,
 | 
			
		||||
        ]
 | 
			
		||||
        verifylist = [
 | 
			
		||||
@@ -152,6 +155,9 @@ class TestCreateNetworkIdentityV3(TestNetwork):
 | 
			
		||||
            ('availability_zone_hints', ["nova"]),
 | 
			
		||||
            ('external', True),
 | 
			
		||||
            ('default', True),
 | 
			
		||||
            ('provider_network_type', 'vlan'),
 | 
			
		||||
            ('physical_network', 'physnet1'),
 | 
			
		||||
            ('segmentation_id', '400'),
 | 
			
		||||
            ('name', self._network.name),
 | 
			
		||||
        ]
 | 
			
		||||
 | 
			
		||||
@@ -166,6 +172,9 @@ class TestCreateNetworkIdentityV3(TestNetwork):
 | 
			
		||||
            'tenant_id': identity_fakes_v3.project_id,
 | 
			
		||||
            'is_default': True,
 | 
			
		||||
            'router:external': True,
 | 
			
		||||
            'provider:network_type': 'vlan',
 | 
			
		||||
            'provider:physical_network': 'physnet1',
 | 
			
		||||
            'provider:segmentation_id': '400',
 | 
			
		||||
        })
 | 
			
		||||
        self.assertEqual(self.columns, columns)
 | 
			
		||||
        self.assertEqual(self.data, data)
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,9 @@
 | 
			
		||||
---
 | 
			
		||||
features:
 | 
			
		||||
  - |
 | 
			
		||||
    New options have been added to the ``network create`` command
 | 
			
		||||
    to support provider network functionality.
 | 
			
		||||
    These options are ``--provider-network-type``, ``--provider-physical-network``,
 | 
			
		||||
    and ``--provider-segmentation-id``.
 | 
			
		||||
    These options are available for Networkv2 only
 | 
			
		||||
    [Bug `1545537 <https://bugs.launchpad.net/bugs/1545537>`_]
 | 
			
		||||
		Reference in New Issue
	
	Block a user