def test_create_port_secgroup(self):
     """Create port: --security-group sg1_id netid."""
     resource = 'port'
     cmd = port.CreatePort(test_cli20.MyApp(sys.stdout), None)
     name = 'myname'
     myid = 'myid'
     netid = 'netid'
     args = ['--security-group', 'sg1_id', netid]
     position_names = ['network_id', 'security_groups']
     position_values = [netid, ['sg1_id']]
     self._test_create_resource(resource, cmd, name, myid, args,
                                position_names, position_values)
Esempio n. 2
0
 def test_create_port(self):
     """Create port: netid."""
     resource = 'port'
     cmd = port.CreatePort(test_cli20.MyApp(sys.stdout), None)
     name = 'myname'
     myid = 'myid'
     netid = 'netid'
     args = [netid]
     position_names = ['network_id']
     position_values = []
     position_values.extend([netid])
     self._test_create_resource(resource, cmd, name, myid, args,
                                position_names, position_values)
 def test_create_port_with_qos_policy(self):
     """Create port: --qos-policy mypolicy."""
     resource = 'port'
     cmd = port.CreatePort(test_cli20.MyApp(sys.stdout), None)
     name = 'myname'
     myid = 'myid'
     netid = 'netid'
     qos_policy_name = 'mypolicy'
     args = [netid, '--qos-policy', qos_policy_name]
     position_names = ['network_id', 'qos_policy_id']
     position_values = [netid, qos_policy_name]
     self._test_create_resource(resource, cmd, name, myid, args,
                                position_names, position_values)
Esempio n. 4
0
 def test_create_port_with_dns_name(self):
     # Create port: --dns-name my-port.
     resource = 'port'
     cmd = port.CreatePort(test_cli20.MyApp(sys.stdout), None)
     name = 'myname'
     myid = 'myid'
     netid = 'netid'
     dns_name_name = 'my-port'
     args = [netid, '--dns-name', dns_name_name]
     position_names = ['network_id', 'dns_name']
     position_values = [netid, dns_name_name]
     self._test_create_resource(resource, cmd, name, myid, args,
                                position_names, position_values)
Esempio n. 5
0
 def test_create_port_secgroups_list(self):
     # Create port: netid <security_groups>
     # The <security_groups> are --security-groups list=true sg_id1 sg_id2
     resource = 'port'
     cmd = port.CreatePort(test_cli20.MyApp(sys.stdout), None)
     name = 'myname'
     myid = 'myid'
     netid = 'netid'
     args = [netid, '--security-groups', 'list=true', 'sg_id1', 'sg_id2']
     position_names = ['network_id', 'security_groups']
     position_values = [netid, ['sg_id1', 'sg_id2']]
     self._test_create_resource(resource, cmd, name, myid, args,
                                position_names, position_values)
Esempio n. 6
0
 def test_create_port_tags(self):
     """Create port: netid mac_address device_id --tags a b."""
     resource = 'port'
     cmd = port.CreatePort(test_cli20.MyApp(sys.stdout), None)
     name = 'myname'
     myid = 'myid'
     netid = 'netid'
     args = [netid, '--tags', 'a', 'b']
     position_names = ['network_id']
     position_values = []
     position_values.extend([netid])
     self._test_create_resource(resource, cmd, name, myid, args,
                                position_names, position_values,
                                tags=['a', 'b'])
Esempio n. 7
0
    def test_create_port_full(self):
        """Create port: --mac_address mac --device_id deviceid netid."""
        resource = 'port'
        cmd = port.CreatePort(test_cli20.MyApp(sys.stdout), None)
        name = 'myname'
        myid = 'myid'
        netid = 'netid'
        args = ['--mac_address', 'mac', '--device_id', 'deviceid', netid]
        position_names = ['network_id', 'mac_address', 'device_id']
        position_values = [netid, 'mac', 'deviceid']
        self._test_create_resource(resource, cmd, name, myid, args,
                                   position_names, position_values)

        # Test dashed options
        args = ['--mac-address', 'mac', '--device-id', 'deviceid', netid]
        position_names = ['network_id', 'mac_address', 'device_id']
        self._test_create_resource(resource, cmd, name, myid, args,
                                   position_names, position_values)
    def test_create_port_with_binding_profile(self):
        resource = 'port'
        cmd = port.CreatePort(test_cli20.MyApp(sys.stdout), None)
        name = 'myname'
        myid = 'myid'
        netid = 'netid'
        args = ['--binding_profile', '{"foo":"bar"}', netid]
        position_names = ['binding:profile', 'network_id']
        position_values = [{'foo': 'bar'}, netid]
        self._test_create_resource(resource, cmd, name, myid, args,
                                   position_names, position_values)

        # Test dashed options
        args = ['--binding-profile', '{"foo":"bar"}', netid]
        position_names = ['binding:profile', 'network_id']
        position_values = [{'foo': 'bar'}, netid]
        self._test_create_resource(resource, cmd, name, myid, args,
                                   position_names, position_values)
    def test_create_port_vnic_type_macvtap(self):
        """Create port: --vnic_type macvtap netid."""
        resource = 'port'
        cmd = port.CreatePort(test_cli20.MyApp(sys.stdout), None)
        name = 'myname'
        myid = 'myid'
        netid = 'netid'
        args = ['--vnic_type', 'macvtap', netid]
        position_names = ['binding:vnic_type', 'network_id']
        position_values = ['macvtap', netid]
        self._test_create_resource(resource, cmd, name, myid, args,
                                   position_names, position_values)

        # Test dashed options
        args = ['--vnic-type', 'macvtap', netid]
        position_names = ['binding:vnic_type', 'network_id']
        position_values = ['macvtap', netid]
        self._test_create_resource(resource, cmd, name, myid, args,
                                   position_names, position_values)
Esempio n. 10
0
    def test_create_port_vnic_type_direct_physical(self):
        # Create port: --vnic_type direct-physical netid.
        resource = 'port'
        cmd = port.CreatePort(test_cli20.MyApp(sys.stdout), None)
        name = 'myname'
        myid = 'myid'
        netid = 'netid'
        args = ['--vnic_type', 'direct-physical', netid]
        position_names = ['binding:vnic_type', 'network_id']
        position_values = ['direct-physical', netid]
        self._test_create_resource(resource, cmd, name, myid, args,
                                   position_names, position_values)

        # Test dashed options
        args = ['--vnic-type', 'direct-physical', netid]
        position_names = ['binding:vnic_type', 'network_id']
        position_values = ['direct-physical', netid]
        self._test_create_resource(resource, cmd, name, myid, args,
                                   position_names, position_values)
Esempio n. 11
0
    def test_create_port_tenant(self):
        """Create port: --tenant_id tenantid netid."""
        resource = 'port'
        cmd = port.CreatePort(test_cli20.MyApp(sys.stdout), None)
        name = 'myname'
        myid = 'myid'
        netid = 'netid'
        args = ['--tenant_id', 'tenantid', netid, ]
        position_names = ['network_id']
        position_values = []
        position_values.extend([netid])
        self._test_create_resource(resource, cmd, name, myid, args,
                                   position_names, position_values,
                                   tenant_id='tenantid')

        # Test dashed options
        args = ['--tenant-id', 'tenantid', netid, ]
        self._test_create_resource(resource, cmd, name, myid, args,
                                   position_names, position_values,
                                   tenant_id='tenantid')
Esempio n. 12
0
 def test_create_port_with_allowed_address_pair_ipaddr(self):
     # Create port:
     # --allowed-address-pair ip_address=addr0
     # --allowed-address-pair ip_address=addr1
     resource = 'port'
     cmd = port.CreatePort(test_cli20.MyApp(sys.stdout), None)
     name = 'myname'
     myid = 'myid'
     netid = 'netid'
     pairs = [{'ip_address': '123.123.123.123'},
              {'ip_address': '123.123.123.45'}]
     args = [netid,
             '--allowed-address-pair',
             'ip_address=123.123.123.123',
             '--allowed-address-pair',
             'ip_address=123.123.123.45']
     position_names = ['network_id', 'allowed_address_pairs']
     position_values = [netid, pairs]
     position_values.extend([netid])
     self._test_create_resource(resource, cmd, name, myid, args,
                                position_names, position_values)
Esempio n. 13
0
 def test_create_port_extra_dhcp_opts_args(self):
     """Create port: netid --extra_dhcp_opt."""
     resource = 'port'
     cmd = port.CreatePort(test_cli20.MyApp(sys.stdout), None)
     name = 'myname'
     myid = 'myid'
     netid = 'netid'
     extra_dhcp_opts = [{'opt_name': 'bootfile-name',
                         'opt_value': 'pxelinux.0'},
                        {'opt_name': 'tftp-server',
                         'opt_value': '123.123.123.123'},
                        {'opt_name': 'server-ip-address',
                         'opt_value': '123.123.123.45'}]
     args = [netid]
     for dhcp_opt in extra_dhcp_opts:
         args += ['--extra-dhcp-opt',
                  ('opt_name=%(opt_name)s,opt_value=%(opt_value)s' %
                   dhcp_opt)]
     position_names = ['network_id', 'extra_dhcp_opts']
     position_values = [netid, extra_dhcp_opts]
     position_values.extend([netid])
     self._test_create_resource(resource, cmd, name, myid, args,
                                position_names, position_values)