def test_list_firewall_rule(self, node_client):
     node_client.return_value.ex_get_network_domain.return_value = load_dd_obj('network_domain.json')
     node_client.return_value.ex_list_firewall_rules.return_value = load_dd_obj('firewall_rule_list.json')
     result = self.runner.invoke(cli, ['network', 'list_firewall_rules', '--networkDomainId', 'fake_network_domain'])
     print(result.output)
     self.assertTrue('Name: CCDEFAULT.BlockOutboundMailIPv4Secure' in result.output)
     self.assertEqual(result.exit_code, 0)
 def test_server_modify_disk_filters(self, node_client):
     node_client.return_value.list_nodes.return_value = load_dd_obj('single_node_list.json')
     node_client.return_value.ex_get_node_by_id.return_value = load_dd_obj('node.json')
     node_client.return_value.ex_change_storage_size.return_value = True
     result = self.runner.invoke(cli,
                                 ['server', 'modify_disk', '--diskId', '0', '--size', 50,
                                  '--serverFilterIpv6', '::1'])
     self.assertTrue('Successfully modified disk' in result.output)
     self.assertTrue(result.exit_code == 0)
 def test_server_remove_disk_filters(self, node_client):
     node_client.return_value.list_nodes.return_value = load_dd_obj('single_node_list.json')
     node_client.return_value.ex_get_node_by_id.return_value = load_dd_obj('node.json')
     node_client.return_value.ex_remove_storage_from_node.return_value = True
     result = self.runner.invoke(cli,
                                 ['server', 'remove_disk', '--diskId', '0',
                                  '--serverFilterIpv6', '::1'])
     self.assertTrue('Removed disk' in result.output)
     self.assertTrue(result.exit_code == 0)
 def test_server_modify_disk_return_False(self, node_client):
     node_client.return_value.list_nodes.return_value = load_dd_obj('single_node_list.json')
     node_client.return_value.ex_get_node_by_id.return_value = load_dd_obj('node.json')
     node_client.return_value.ex_change_storage_size.return_value = False
     result = self.runner.invoke(cli,
                                 ['server', 'modify_disk', '--diskId', '0', '--size', 50,
                                  '--serverFilterIpv6', '::1'])
     self.assertTrue('Something went wrong attempting to modify disk' in result.output)
     self.assertTrue(result.exit_code == 1)
示例#5
0
 def test_server_remove_disk_filters(self, node_client):
     node_client.return_value.list_nodes.return_value = load_dd_obj(
         'single_node_list.json')
     node_client.return_value.ex_get_node_by_id.return_value = load_dd_obj(
         'node.json')
     node_client.return_value.ex_remove_storage_from_node.return_value = True
     result = self.runner.invoke(cli, [
         'server', 'remove_disk', '--diskId', '0', '--serverFilterIpv6',
         '::1'
     ])
     self.assertTrue('Removed disk' in result.output)
     self.assertTrue(result.exit_code == 0)
示例#6
0
 def test_server_modify_disk_filters(self, node_client):
     node_client.return_value.list_nodes.return_value = load_dd_obj(
         'single_node_list.json')
     node_client.return_value.ex_get_node_by_id.return_value = load_dd_obj(
         'node.json')
     node_client.return_value.ex_change_storage_size.return_value = True
     result = self.runner.invoke(cli, [
         'server', 'modify_disk', '--diskId', '0', '--size', 50,
         '--serverFilterIpv6', '::1'
     ])
     self.assertTrue('Successfully modified disk' in result.output)
     self.assertTrue(result.exit_code == 0)
示例#7
0
 def test_server_modify_disk_return_False(self, node_client):
     node_client.return_value.list_nodes.return_value = load_dd_obj(
         'single_node_list.json')
     node_client.return_value.ex_get_node_by_id.return_value = load_dd_obj(
         'node.json')
     node_client.return_value.ex_change_storage_size.return_value = False
     result = self.runner.invoke(cli, [
         'server', 'modify_disk', '--diskId', '0', '--size', 50,
         '--serverFilterIpv6', '::1'
     ])
     self.assertTrue(
         'Something went wrong attempting to modify disk' in result.output)
     self.assertTrue(result.exit_code == 1)
 def test_list_firewall_rule(self, node_client):
     node_client.return_value.ex_get_network_domain.return_value = load_dd_obj(
         'network_domain.json')
     node_client.return_value.ex_list_firewall_rules.return_value = load_dd_obj(
         'firewall_rule_list.json')
     result = self.runner.invoke(cli, [
         'network', 'list_firewall_rules', '--networkDomainId',
         'fake_network_domain'
     ])
     print(result.output)
     self.assertTrue(
         'Name: CCDEFAULT.BlockOutboundMailIPv4Secure' in result.output)
     self.assertEqual(result.exit_code, 0)
 def test_vlan_list(self, node_client):
     node_client.return_value.ex_list_vlans.return_value = load_dd_obj(
         'vlan_list.json')
     result = self.runner.invoke(cli, ['network', 'list_vlans'])
     self.assertTrue(
         'ID: 56389c71-cc03-4e7a-a72f-cc219f0649c8' in result.output)
     self.assertEqual(result.exit_code, 0)
示例#10
0
 def test_network_list(self, node_client):
     node_client.return_value.ex_list_networks.return_value = load_dd_obj(
         'network_list.json')
     result = self.runner.invoke(cli, ['network', 'list_networks'])
     self.assertTrue(
         'ID: 629aac56-0cea-11e4-b29c-001517c4643e' in result.output)
     self.assertEqual(result.exit_code, 0)
 def test_server_info(self, node_client):
     node_client.return_value.ex_get_node_by_id.return_value = load_dd_obj('node.json')
     result = self.runner.invoke(cli,
                                 ['server', 'info',
                                  '--serverId', '8aeff10c-c918-4021-b2ce-93e4a209418b'])
     self.assertTrue('ID: 8aeff10c-c918-4021-b2ce-93e4a209418b' in result.output)
     self.assertTrue(result.exit_code == 0)
示例#12
0
 def test_server_list_json_output(self, node_client):
     node_client.return_value.list_nodes.return_value = load_dd_obj(
         'node_list.json')
     result = self.runner.invoke(cli,
                                 ['--outputType', 'json', 'server', 'list'])
     json.loads(result.output)
     self.assertEqual(result.exit_code, 0)
示例#13
0
 def test_server_list_idsonly(self, node_client):
     node_client.return_value.list_nodes.return_value = load_dd_obj(
         'node_list.json')
     result = self.runner.invoke(cli, ['server', 'list', '--idsonly'])
     self.assertFalse('Private IPv4: 172.16.2.8' in result.output)
     self.assertTrue(
         'b4ea8995-43a1-4b56-b751-4107b5671713' in result.output)
     self.assertTrue(result.exit_code == 0)
 def test_server_destroy(self, node_client):
     node_client.return_value.ex_get_node_by_id.return_value = load_dd_obj('node.json')
     node_client.return_value.destroy_node.return_value = True
     result = self.runner.invoke(cli,
                                 ['server', 'destroy',
                                  '--serverId', '8aeff10c-c918-4021-b2ce-93e4a209418b'])
     self.assertTrue('is being destroyed' in result.output)
     self.assertTrue(result.exit_code == 0)
 def test_server_reboot_hard_server_filters(self, node_client):
     node_client.return_value.list_nodes.return_value = load_dd_obj('single_node_list.json')
     node_client.return_value.ex_reset.return_value = True
     result = self.runner.invoke(cli,
                                 ['server', 'reboot_hard',
                                  '--serverFilterIpv6', '::1'])
     self.assertTrue('is being rebooted' in result.output)
     self.assertTrue(result.exit_code == 0)
示例#16
0
 def test_server_list_query(self, node_client):
     node_client.return_value.list_nodes.return_value = load_dd_obj(
         'node_list.json')
     result = self.runner.invoke(
         cli, ['server', 'list', '--query', "ReturnCount:1|ReturnKeys:ID"])
     self.assertEqual(result.exit_code, 0)
     output = os.linesep.join([s for s in result.output.splitlines() if s])
     self.assertEqual(output, 'ID: b4ea8995-43a1-4b56-b751-4107b5671713')
示例#17
0
 def test_server_start_server_filters(self, node_client):
     node_client.return_value.list_nodes.return_value = load_dd_obj(
         'single_node_list.json')
     node_client.return_value.ex_start_node.return_value = True
     result = self.runner.invoke(
         cli, ['server', 'start', '--serverFilterIpv6', '::1'])
     self.assertTrue('is starting' in result.output)
     self.assertTrue(result.exit_code == 0)
 def test_server_shutdown_hard(self, node_client):
     node_client.return_value.ex_get_node_by_id.return_value = load_dd_obj('node.json')
     node_client.return_value.ex_power_off.return_value = True
     result = self.runner.invoke(cli,
                                 ['server', 'shutdown_hard',
                                  '--serverId', '8aeff10c-c918-4021-b2ce-93e4a209418b'])
     self.assertTrue('is shutting down hard' in result.output)
     self.assertTrue(result.exit_code == 0)
示例#19
0
 def test_server_reboot_hard_server_filters(self, node_client):
     node_client.return_value.list_nodes.return_value = load_dd_obj(
         'single_node_list.json')
     node_client.return_value.ex_reset.return_value = True
     result = self.runner.invoke(
         cli, ['server', 'reboot_hard', '--serverFilterIpv6', '::1'])
     self.assertTrue('is being rebooted' in result.output)
     self.assertTrue(result.exit_code == 0)
 def test_server_start_server_filters(self, node_client):
     node_client.return_value.list_nodes.return_value = load_dd_obj('single_node_list.json')
     node_client.return_value.ex_start_node.return_value = True
     result = self.runner.invoke(cli,
                                 ['server', 'start',
                                  '--serverFilterIpv6', '::1'])
     self.assertTrue('is starting' in result.output)
     self.assertTrue(result.exit_code == 0)
 def test_server_start_return_False(self, node_client):
     node_client.return_value.list_nodes.return_value = load_dd_obj('single_node_list.json')
     node_client.return_value.ex_start_node.return_value = False
     result = self.runner.invoke(cli,
                                 ['server', 'start',
                                  '--serverFilterIpv6', '::1'])
     self.assertTrue('Something went wrong when attempting to start' in result.output)
     self.assertTrue(result.exit_code == 1)
 def test_server_add_disk_filters(self, node_client):
     node_client.return_value.list_nodes.return_value = load_dd_obj('single_node_list.json')
     node_client.return_value.ex_add_storage_to_node.return_value = True
     result = self.runner.invoke(cli,
                                 ['server', 'add_disk', '--size', '50', '--speed', 'ECONOMY',
                                  '--serverFilterIpv6', '::1'])
     self.assertTrue('Adding disk' in result.output)
     self.assertTrue(result.exit_code == 0)
 def test_server_add_disk_return_False(self, node_client):
     node_client.return_value.list_nodes.return_value = load_dd_obj('single_node_list.json')
     node_client.return_value.ex_add_storage_to_node.return_value = False
     result = self.runner.invoke(cli,
                                 ['server', 'add_disk', '--size', '50', '--speed', 'ECONOMY',
                                  '--serverFilterIpv6', '::1'])
     self.assertTrue('Something went wrong attempting to add disk' in result.output)
     self.assertTrue(result.exit_code == 1)
 def test_create_vlan(self, node_client):
     node_client.return_value.ex_create_vlan.return_value = load_dd_obj('vlan.json')
     result = self.runner.invoke(cli, ['network', 'create_vlan',
                                       '--networkDomainId', '423c4386-87b4-43c4-9604-88ae237bfc7f',
                                       '--name', 'overlap_vlan',
                                       '--baseIpv4Address', '10.192.238.0'])
     self.assertTrue('eee454f4-562a-4b23-ad57-4cb8b034c8c9' in result.output)
     self.assertEqual(result.exit_code, 0)
 def test_create_network_domain(self, node_client):
     node_client.return_value.ex_create_network_domain.return_value = load_dd_obj('network_domain.json')
     result = self.runner.invoke(cli, ['network', 'create_network_domain',
                                       '--name', 'fake_network_domain',
                                       '--servicePlan', 'ESSENTIALS',
                                       '--datacenterId', 'NA9'])
     self.assertTrue('Network Domain fake_network_domain created' in result.output)
     self.assertEqual(result.exit_code, 0)
示例#26
0
 def test_server_start_return_False(self, node_client):
     node_client.return_value.list_nodes.return_value = load_dd_obj(
         'single_node_list.json')
     node_client.return_value.ex_start_node.return_value = False
     result = self.runner.invoke(
         cli, ['server', 'start', '--serverFilterIpv6', '::1'])
     self.assertTrue(
         'Something went wrong when attempting to start' in result.output)
     self.assertTrue(result.exit_code == 1)
 def test_server_update_ram(self, node_client):
     node_client.return_value.ex_get_node_by_id.return_value = load_dd_obj('node.json')
     node_client.return_value.ex_reconfigure_node.return_value = True
     result = self.runner.invoke(cli,
                                 ['server', 'update_ram',
                                  '--serverId', '8aeff10c-c918-4021-b2ce-93e4a209418b',
                                  '--ramInGB', '8'])
     self.assertTrue('changed to 8GB' in result.output)
     self.assertTrue(result.exit_code == 0)
 def test_server_start_APIException(self, node_client):
     node_client.return_value.ex_get_node_by_id.return_value = load_dd_obj('node.json')
     node_client.return_value.ex_start_node.side_effect = DimensionDataAPIException(
         code='REASON 533', msg='Cannot start server', driver=None)
     result = self.runner.invoke(cli,
                                 ['server', 'start',
                                  '--serverId', '8aeff10c-c918-4021-b2ce-93e4a209418b'])
     self.assertTrue('REASON 533' in result.output)
     self.assertTrue(result.exit_code == 1)
 def test_server_update_cpu_count(self, node_client):
     node_client.return_value.ex_get_node_by_id.return_value = load_dd_obj('node.json')
     node_client.return_value.ex_reconfigure_node.return_value = True
     result = self.runner.invoke(cli,
                                 ['server', 'update_cpu_count',
                                  '--serverId', '8aeff10c-c918-4021-b2ce-93e4a209418b',
                                  '--cpuCount', '4'])
     self.assertTrue('CPU Count changing to 4' in result.output)
     self.assertTrue(result.exit_code == 0)
 def test_server_remove_disk(self, node_client):
     node_client.return_value.ex_get_node_by_id.return_value = load_dd_obj('node.json')
     node_client.return_value.ex_remove_storage_from_node.return_value = True
     result = self.runner.invoke(cli,
                                 ['server', 'remove_disk',
                                  '--serverId', '8aeff10c-c918-4021-b2ce-93e4a209418b',
                                  '--diskId', '0'])
     self.assertTrue('Removed disk' in result.output)
     self.assertTrue(result.exit_code == 0)
 def test_server_add_disk(self, node_client):
     node_client.return_value.ex_get_node_by_id.return_value = load_dd_obj('node.json')
     node_client.return_value.ex_add_storage_to_node.return_value = True
     result = self.runner.invoke(cli,
                                 ['server', 'add_disk',
                                  '--serverId', '8aeff10c-c918-4021-b2ce-93e4a209418b',
                                  '--size', '50', '--speed', 'ECONOMY'])
     self.assertTrue('Adding disk' in result.output)
     self.assertTrue(result.exit_code == 0)
 def test_server_modify_disk_size(self, node_client):
     node_client.return_value.ex_get_node_by_id.return_value = load_dd_obj('node.json')
     node_client.return_value.ex_change_storage_size.return_value = True
     result = self.runner.invoke(cli,
                                 ['server', 'modify_disk',
                                  '--serverId', '8aeff10c-c918-4021-b2ce-93e4a209418b',
                                  '--diskId', '0', '--size', 50])
     self.assertTrue('Successfully modified disk' in result.output)
     self.assertTrue(result.exit_code == 0)
示例#33
0
 def test_network_domain_list(self, node_client):
     node_client.return_value.ex_list_network_domains.return_value = load_dd_obj(
         'network_domain_list.json')
     result = self.runner.invoke(cli, ['network', 'list_network_domains'])
     self.assertTrue(
         'ID: a4b58cd5-4968-4b84-ac4c-007a5c1dd6f5' in result.output)
     self.assertTrue(
         'ID: 75b72ac5-0f3e-4c44-96f1-61b6aa5cae43' in result.output)
     self.assertEqual(result.exit_code, 0)
 def test_server_update_cpu_count_server_filters(self, node_client):
     node_client.return_value.list_nodes.return_value = load_dd_obj('single_node_list.json')
     node_client.return_value.ex_reconfigure_node.return_value = True
     result = self.runner.invoke(cli,
                                 ['server', 'update_cpu_count',
                                  '--serverFilterIpv6', '::1',
                                  '--cpuCount', '4'])
     self.assertTrue('CPU Count changing to 4' in result.output)
     self.assertTrue(result.exit_code == 0)
 def test_server_update_ram_server_filters(self, node_client):
     node_client.return_value.list_nodes.return_value = load_dd_obj('single_node_list.json')
     node_client.return_value.ex_reconfigure_node.return_value = True
     result = self.runner.invoke(cli,
                                 ['server', 'update_ram',
                                  '--serverFilterIpv6', '::1',
                                  '--ramInGB', '8'])
     self.assertTrue('changed to 8GB' in result.output)
     self.assertTrue(result.exit_code == 0)
示例#36
0
 def test_create_network(self, node_client):
     node_client.return_value.ex_create_network.return_value = load_dd_obj(
         'network.json')
     result = self.runner.invoke(cli, [
         'network', 'create_network', '--name', 'fake_network',
         '--servicePlan', 'ESSENTIALS', '--datacenterId', 'NA9'
     ])
     self.assertTrue('Network fake_network created' in result.output)
     self.assertEqual(result.exit_code, 0)
示例#37
0
 def test_vlan_list_with_network_domain_id(self, node_client):
     node_client.return_value.ex_list_vlans.return_value = load_dd_obj(
         'vlan_list.json')
     result = self.runner.invoke(cli, [
         'network', 'list_vlans', '--networkDomainId',
         '4b58cd5-4968-4b84-ac4c-007a5c1dd6f5'
     ])
     self.assertTrue(
         'ID: 56389c71-cc03-4e7a-a72f-cc219f0649c8' in result.output)
     self.assertEqual(result.exit_code, 0)
示例#38
0
 def test_server_shutdown_hard(self, node_client):
     node_client.return_value.ex_get_node_by_id.return_value = load_dd_obj(
         'node.json')
     node_client.return_value.ex_power_off.return_value = True
     result = self.runner.invoke(cli, [
         'server', 'shutdown_hard', '--serverId',
         '8aeff10c-c918-4021-b2ce-93e4a209418b'
     ])
     self.assertTrue('is shutting down hard' in result.output)
     self.assertTrue(result.exit_code == 0)
 def test_server_update_cpu_count_APIException(self, node_client):
     node_client.return_value.list_nodes.return_value = load_dd_obj('single_node_list.json')
     node_client.return_value.ex_reconfigure_node.side_effect = DimensionDataAPIException(
         code='REASON 539', msg='No CPU Left', driver=None)
     result = self.runner.invoke(cli,
                                 ['server', 'update_cpu_count',
                                  '--serverFilterIpv6', '::1',
                                  '--cpuCount', '4'])
     self.assertTrue('REASON 539' in result.output)
     self.assertTrue(result.exit_code == 1)
示例#40
0
 def test_server_update_ram(self, node_client):
     node_client.return_value.ex_get_node_by_id.return_value = load_dd_obj(
         'node.json')
     node_client.return_value.ex_reconfigure_node.return_value = True
     result = self.runner.invoke(cli, [
         'server', 'update_ram', '--serverId',
         '8aeff10c-c918-4021-b2ce-93e4a209418b', '--ramInGB', '8'
     ])
     self.assertTrue('changed to 8GB' in result.output)
     self.assertTrue(result.exit_code == 0)
示例#41
0
 def test_server_info(self, node_client):
     node_client.return_value.ex_get_node_by_id.return_value = load_dd_obj(
         'node.json')
     result = self.runner.invoke(cli, [
         'server', 'info', '--serverId',
         '8aeff10c-c918-4021-b2ce-93e4a209418b'
     ])
     self.assertTrue(
         'ID: 8aeff10c-c918-4021-b2ce-93e4a209418b' in result.output)
     self.assertTrue(result.exit_code == 0)
示例#42
0
 def test_server_update_ram_server_filters(self, node_client):
     node_client.return_value.list_nodes.return_value = load_dd_obj(
         'single_node_list.json')
     node_client.return_value.ex_reconfigure_node.return_value = True
     result = self.runner.invoke(cli, [
         'server', 'update_ram', '--serverFilterIpv6', '::1', '--ramInGB',
         '8'
     ])
     self.assertTrue('changed to 8GB' in result.output)
     self.assertTrue(result.exit_code == 0)
示例#43
0
 def test_server_add_disk_filters(self, node_client):
     node_client.return_value.list_nodes.return_value = load_dd_obj(
         'single_node_list.json')
     node_client.return_value.ex_add_storage_to_node.return_value = True
     result = self.runner.invoke(cli, [
         'server', 'add_disk', '--size', '50', '--speed', 'ECONOMY',
         '--serverFilterIpv6', '::1'
     ])
     self.assertTrue('Adding disk' in result.output)
     self.assertTrue(result.exit_code == 0)
示例#44
0
 def test_server_destroy(self, node_client):
     node_client.return_value.ex_get_node_by_id.return_value = load_dd_obj(
         'node.json')
     node_client.return_value.destroy_node.return_value = True
     result = self.runner.invoke(cli, [
         'server', 'destroy', '--serverId',
         '8aeff10c-c918-4021-b2ce-93e4a209418b'
     ])
     self.assertTrue('is being destroyed' in result.output)
     self.assertTrue(result.exit_code == 0)
示例#45
0
 def test_server_remove_disk(self, node_client):
     node_client.return_value.ex_get_node_by_id.return_value = load_dd_obj(
         'node.json')
     node_client.return_value.ex_remove_storage_from_node.return_value = True
     result = self.runner.invoke(cli, [
         'server', 'remove_disk', '--serverId',
         '8aeff10c-c918-4021-b2ce-93e4a209418b', '--diskId', '0'
     ])
     self.assertTrue('Removed disk' in result.output)
     self.assertTrue(result.exit_code == 0)
 def test_server_add_disk_APIException(self, node_client):
     node_client.return_value.ex_get_node_by_id.return_value = load_dd_obj('node.json')
     node_client.return_value.ex_add_storage_to_node.side_effect = DimensionDataAPIException(
         code='REASON 534', msg='Cannot add disk to server', driver=None)
     result = self.runner.invoke(cli,
                                 ['server', 'add_disk',
                                  '--serverId', '8aeff10c-c918-4021-b2ce-93e4a209418b',
                                  '--size', '50', '--speed', 'ECONOMY'])
     self.assertTrue('REASON 534' in result.output)
     self.assertTrue(result.exit_code == 1)
 def test_server_modify_disk_APIException(self, node_client):
     node_client.return_value.ex_get_node_by_id.return_value = load_dd_obj('node.json')
     node_client.return_value.ex_change_storage_size.side_effect = DimensionDataAPIException(
         code='REASON 536', msg='Cannot remove disk from server', driver=None)
     result = self.runner.invoke(cli,
                                 ['server', 'modify_disk',
                                  '--serverId', '8aeff10c-c918-4021-b2ce-93e4a209418b',
                                  '--diskId', '0', '--size', 50])
     self.assertTrue('REASON 536' in result.output)
     self.assertTrue(result.exit_code == 1)
示例#48
0
 def test_server_update_cpu_count(self, node_client):
     node_client.return_value.ex_get_node_by_id.return_value = load_dd_obj(
         'node.json')
     node_client.return_value.ex_reconfigure_node.return_value = True
     result = self.runner.invoke(cli, [
         'server', 'update_cpu_count', '--serverId',
         '8aeff10c-c918-4021-b2ce-93e4a209418b', '--cpuCount', '4'
     ])
     self.assertTrue('CPU Count changing to 4' in result.output)
     self.assertTrue(result.exit_code == 0)
示例#49
0
 def test_server_update_cpu_count_server_filters(self, node_client):
     node_client.return_value.list_nodes.return_value = load_dd_obj(
         'single_node_list.json')
     node_client.return_value.ex_reconfigure_node.return_value = True
     result = self.runner.invoke(cli, [
         'server', 'update_cpu_count', '--serverFilterIpv6', '::1',
         '--cpuCount', '4'
     ])
     self.assertTrue('CPU Count changing to 4' in result.output)
     self.assertTrue(result.exit_code == 0)
示例#50
0
 def test_create_vlan(self, node_client):
     node_client.return_value.ex_create_vlan.return_value = load_dd_obj(
         'vlan.json')
     result = self.runner.invoke(cli, [
         'network', 'create_vlan', '--networkDomainId',
         '423c4386-87b4-43c4-9604-88ae237bfc7f', '--name', 'overlap_vlan',
         '--baseIpv4Address', '10.192.238.0'
     ])
     self.assertTrue(
         'eee454f4-562a-4b23-ad57-4cb8b034c8c9' in result.output)
     self.assertEqual(result.exit_code, 0)
示例#51
0
 def test_server_add_disk(self, node_client):
     node_client.return_value.ex_get_node_by_id.return_value = load_dd_obj(
         'node.json')
     node_client.return_value.ex_add_storage_to_node.return_value = True
     result = self.runner.invoke(cli, [
         'server', 'add_disk', '--serverId',
         '8aeff10c-c918-4021-b2ce-93e4a209418b', '--size', '50', '--speed',
         'ECONOMY'
     ])
     self.assertTrue('Adding disk' in result.output)
     self.assertTrue(result.exit_code == 0)
示例#52
0
 def test_server_start_APIException(self, node_client):
     node_client.return_value.ex_get_node_by_id.return_value = load_dd_obj(
         'node.json')
     node_client.return_value.ex_start_node.side_effect = DimensionDataAPIException(
         code='REASON 533', msg='Cannot start server', driver=None)
     result = self.runner.invoke(cli, [
         'server', 'start', '--serverId',
         '8aeff10c-c918-4021-b2ce-93e4a209418b'
     ])
     self.assertTrue('REASON 533' in result.output)
     self.assertTrue(result.exit_code == 1)
示例#53
0
 def test_server_update_cpu_count_APIException(self, node_client):
     node_client.return_value.list_nodes.return_value = load_dd_obj(
         'single_node_list.json')
     node_client.return_value.ex_reconfigure_node.side_effect = DimensionDataAPIException(
         code='REASON 539', msg='No CPU Left', driver=None)
     result = self.runner.invoke(cli, [
         'server', 'update_cpu_count', '--serverFilterIpv6', '::1',
         '--cpuCount', '4'
     ])
     self.assertTrue('REASON 539' in result.output)
     self.assertTrue(result.exit_code == 1)
示例#54
0
 def test_server_add_disk_return_False(self, node_client):
     node_client.return_value.list_nodes.return_value = load_dd_obj(
         'single_node_list.json')
     node_client.return_value.ex_add_storage_to_node.return_value = False
     result = self.runner.invoke(cli, [
         'server', 'add_disk', '--size', '50', '--speed', 'ECONOMY',
         '--serverFilterIpv6', '::1'
     ])
     self.assertTrue(
         'Something went wrong attempting to add disk' in result.output)
     self.assertTrue(result.exit_code == 1)
示例#55
0
 def test_server_modify_disk_size(self, node_client):
     node_client.return_value.ex_get_node_by_id.return_value = load_dd_obj(
         'node.json')
     node_client.return_value.ex_change_storage_size.return_value = True
     result = self.runner.invoke(cli, [
         'server', 'modify_disk', '--serverId',
         '8aeff10c-c918-4021-b2ce-93e4a209418b', '--diskId', '0', '--size',
         50
     ])
     self.assertTrue('Successfully modified disk' in result.output)
     self.assertTrue(result.exit_code == 0)
 def test_server_create_node(self, node_client):
     node_client.return_value.create_node.return_value = load_dd_obj('create_node.json')
     result = self.runner.invoke(cli,
                                 ['server', 'create', '--name', 'didata_cli_test',
                                  '--imageId', '294cad61-0857-4124-8ff6-45f4e6643646',
                                  '--administratorPassword', 'fakepassword',
                                  '--description', 'fakedescription',
                                  '--networkDomainId', 'b53b2ad4-ca8b-4abd-9140-72d6b137a6b4',
                                  '--vlanId', 'f04e4e2c-a52e-45d3-8037-9f1b1e234c05'])
     self.assertTrue('8aeff10c-c918-4021-b2ce-93e4a209418b' in result.output)
     self.assertTrue(result.exit_code == 0)
 def test_create_firewall_rule(self, node_client):
     node_client.return_value.ex_get_network_domain.return_value = load_dd_obj('network_domain.json')
     node_client.return_value.ex_create_firewall_rule.return_value = True
     result = self.runner.invoke(cli, ['network', 'create_firewall_rule',
                                       '--name', 'my_fake_rule',
                                       '--networkDomainId', 'fake_network_domain',
                                       '--ipVersion', 'IPV4',
                                       '--action', 'DROP',
                                       '--protocol', 'TCP',
                                       '--sourceIP', 'ANY',
                                       '--sourceStartPort', 'ANY',
                                       '--destinationIP', '10.1.1.15',
                                       '--destinationStartPort', 'ANY',
                                       '--position', 'LAST'])
     self.assertTrue('Firewall rule my_fake_rule created' in result.output)
     self.assertEqual(result.exit_code, 0)
 def test_server_list_query(self, node_client):
     node_client.return_value.list_nodes.return_value = load_dd_obj('node_list.json')
     result = self.runner.invoke(cli, ['server', 'list', '--query', "ReturnCount:1|ReturnKeys:ID"])
     self.assertEqual(result.exit_code, 0)
     output = os.linesep.join([s for s in result.output.splitlines() if s])
     self.assertEqual(output, 'ID: b4ea8995-43a1-4b56-b751-4107b5671713')
 def test_server_list_idsonly(self, node_client):
     node_client.return_value.list_nodes.return_value = load_dd_obj('node_list.json')
     result = self.runner.invoke(cli, ['server', 'list', '--idsonly'])
     self.assertFalse('Private IPv4: 172.16.2.8' in result.output)
     self.assertTrue('b4ea8995-43a1-4b56-b751-4107b5671713' in result.output)
     self.assertTrue(result.exit_code == 0)
 def test_server_list_empty(self, node_client):
     node_client.return_value.list_nodes.return_value = load_dd_obj('node_list_empty.json')
     result = self.runner.invoke(cli, ['server', 'list'])
     self.assertEqual(result.exit_code, 0)
     self.assertTrue('No nodes found', result.output)