Esempio n. 1
0
 def test_update_port_security_group_off(self):
     """Update port: --no-security-groups myid."""
     resource = 'port'
     cmd = port.UpdatePort(test_cli20.MyApp(sys.stdout), None)
     self._test_update_resource(resource, cmd, 'myid',
                                ['--no-security-groups', 'myid'],
                                {'security_groups': []})
Esempio n. 2
0
 def test_update_port_secgroup(self):
     resource = 'port'
     cmd = port.UpdatePort(test_cli20.MyApp(sys.stdout), None)
     myid = 'myid'
     args = ['--security-group', 'sg1_id', myid]
     updatefields = {'security_groups': ['sg1_id']}
     self._test_update_resource(resource, cmd, myid, args, updatefields)
Esempio n. 3
0
 def test_update_port_extra_dhcp_opts(self):
     """Update port: myid --extra_dhcp_opt."""
     resource = 'port'
     myid = 'myid'
     args = [
         myid, '--extra-dhcp-opt',
         "opt_name=bootfile-name,opt_value=pxelinux.0", '--extra-dhcp-opt',
         "opt_name=tftp-server,opt_value=123.123.123.123",
         '--extra-dhcp-opt',
         "opt_name=server-ip-address,opt_value=123.123.123.45"
     ]
     updatedfields = {
         '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'
         }]
     }
     cmd = port.UpdatePort(test_cli20.MyApp(sys.stdout), None)
     self._test_update_resource(resource, cmd, myid, args, updatedfields)
 def test_update_port_allowed_address_pairs_off(self):
     """Update port: --no-allowed-address-pairs."""
     resource = 'port'
     cmd = port.UpdatePort(test_cli20.MyApp(sys.stdout), None)
     self._test_update_resource(resource, cmd, 'myid',
                                ['--no-allowed-address-pairs', 'myid'],
                                {'allowed_address_pairs': []})
 def test_delete_extra_dhcp_opts_from_port(self):
     resource = 'port'
     myid = 'myid'
     args = [
         myid, '--extra-dhcp-opt', "opt_name=bootfile-name,opt_value=null",
         '--extra-dhcp-opt',
         "opt_name=tftp-server,opt_value=123.123.123.123",
         '--extra-dhcp-opt',
         "opt_name=server-ip-address,opt_value=123.123.123.45"
     ]
     # the client code will change the null to None and send to server,
     # where its interpreted as delete the DHCP option on the port.
     updatedfields = {
         'extra_dhcp_opts': [{
             'opt_name': 'bootfile-name',
             'opt_value': None
         }, {
             'opt_name': 'tftp-server',
             'opt_value': '123.123.123.123'
         }, {
             'opt_name': 'server-ip-address',
             'opt_value': '123.123.123.45'
         }]
     }
     cmd = port.UpdatePort(test_cli20.MyApp(sys.stdout), None)
     self._test_update_resource(resource, cmd, myid, args, updatedfields)
 def test_update_port_allowed_address_pair(self):
     """Update port:
     --allowed-address-pair
     ip_address=addr0,mac_address=mac0
     --allowed-address-pair
     ip_address_addr1,mac_address=mac1
     """
     resource = 'port'
     cmd = port.UpdatePort(test_cli20.MyApp(sys.stdout), None)
     myid = 'myid'
     pairs = [{
         'ip_address': '123.123.123.123',
         'mac_address': '10:00:00:00:00:00'
     }, {
         'ip_address': '123.123.123.45',
         'mac_address': '10:00:00:00:00:01'
     }]
     args = [
         myid, '--allowed-address-pair',
         'ip_address=123.123.123.123,mac_address=10:00:00:00:00:00',
         '--allowed-address-pair',
         'ip_address=123.123.123.45,mac_address=10:00:00:00:00:01'
     ]
     updatefields = {'allowed_address_pairs': pairs}
     self._test_update_resource(resource, cmd, myid, args, updatefields)
 def test_update_port_device_id_device_owner(self):
     resource = 'port'
     cmd = port.UpdatePort(test_cli20.MyApp(sys.stdout), None)
     myid = 'myid'
     args = ['--device-id', 'dev_id', '--device-owner', 'fake', myid]
     updatefields = {'device_id': 'dev_id', 'device_owner': 'fake'}
     self._test_update_resource(resource, cmd, myid, args, updatefields)
 def test_update_port_extra_dhcp_opts_ip_version(self):
     """Update port: myid --extra_dhcp_opt."""
     resource = 'port'
     myid = 'myid'
     args = [
         myid, '--extra-dhcp-opt',
         "opt_name=bootfile-name,opt_value=pxelinux.0,ip_version=4",
         '--extra-dhcp-opt',
         "opt_name=tftp-server,opt_value=2001:192:168::1,ip_version=6",
         '--extra-dhcp-opt',
         "opt_name=server-ip-address,opt_value=null,ip_version=4"
     ]
     updatedfields = {
         'extra_dhcp_opts': [{
             'opt_name': 'bootfile-name',
             'opt_value': 'pxelinux.0',
             'ip_version': '4'
         }, {
             'opt_name': 'tftp-server',
             'opt_value': '2001:192:168::1',
             'ip_version': '6'
         }, {
             'opt_name': 'server-ip-address',
             'opt_value': None,
             'ip_version': '4'
         }]
     }
     cmd = port.UpdatePort(test_cli20.MyApp(sys.stdout), None)
     self._test_update_resource(resource, cmd, myid, args, updatedfields)
Esempio n. 9
0
 def test_update_port_with_no_dns_name(self):
     # Update port: myid --no-dns-name
     resource = 'port'
     cmd = port.UpdatePort(test_cli20.MyApp(sys.stdout), None)
     self._test_update_resource(resource, cmd, 'myid',
                                ['myid', '--no-dns-name'],
                                {'dns_name': "", })
Esempio n. 10
0
 def test_update_port_with_no_qos_policy(self):
     # Update port: myid --no-qos-policy.
     resource = 'port'
     cmd = port.UpdatePort(test_cli20.MyApp(sys.stdout), None)
     self._test_update_resource(resource, cmd, 'myid',
                                ['myid', '--no-qos-policy'],
                                {'qos_policy_id': None, })
Esempio n. 11
0
 def test_update_port(self):
     """Update port: myid --name myname --tags a b."""
     resource = 'port'
     cmd = port.UpdatePort(test_cli20.MyApp(sys.stdout), None)
     self._test_update_resource(resource, cmd, 'myid',
                                ['myid', '--name', 'myname',
                                 '--tags', 'a', 'b'],
                                {'name': 'myname', 'tags': ['a', 'b'], }
                                )
Esempio n. 12
0
 def test_update_port(self):
     # Update port: myid --name myname --admin-state-up False --tags a b.
     resource = 'port'
     cmd = port.UpdatePort(test_cli20.MyApp(sys.stdout), None)
     self._test_update_resource(resource, cmd, 'myid', [
         'myid', '--name', 'myname', '--admin-state-up', 'False', '--tags',
         'a', 'b'
     ], {
         'name': 'myname',
         'admin_state_up': 'False',
         'tags': ['a', 'b'],
     })
Esempio n. 13
0
 def test_update_port_fixed_ip(self):
     resource = 'port'
     cmd = port.UpdatePort(test_cli20.MyApp(sys.stdout), None)
     myid = 'myid'
     net_id = 'net_id'
     ip_addr = '123.123.123.123'
     args = [myid,
             '--fixed-ip', "network_id=%(net_id)s,ip_address=%(ip_addr)s" %
             {'net_id': net_id,
              'ip_addr': ip_addr}]
     updated_fields = {"fixed_ips": [{'network_id': net_id,
                                      'ip_address': ip_addr}]}
     self._test_update_resource(resource, cmd, myid, args, updated_fields)
Esempio n. 14
0
 def test_update_port_allowed_address_pair_ipaddr(self):
     # Update port(ip_address only):
     # --allowed-address-pairs ip_address=addr0
     # --allowed-address-pairs ip_address=addr1
     import sys
     resource = 'port'
     cmd = port.UpdatePort(test_cli20.MyApp(sys.stdout), None)
     myid = 'myid'
     pairs = [{'ip_address': '123.123.123.123'},
              {'ip_address': '123.123.123.45'}]
     args = [myid,
             '--allowed-address-pair',
             'ip_address=123.123.123.123',
             '--allowed-address-pair',
             'ip_address=123.123.123.45']
     updatefields = {'allowed_address_pairs': pairs}
     self._test_update_resource(resource, cmd, myid, args, updatefields)