Added more tests for mcp1.0 for greater coverage
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/e23061f5 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/e23061f5 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/e23061f5 Branch: refs/heads/trunk Commit: e23061f53a703cf22ef113d03061aed747bd4c74 Parents: aa6ad8f Author: mitch <[email protected]> Authored: Mon Nov 26 21:51:45 2018 -0500 Committer: mitch <[email protected]> Committed: Mon Nov 26 21:51:45 2018 -0500 ---------------------------------------------------------------------- libcloud/compute/drivers/nttcis.py | 2 +- .../fixtures/nttcis/networkWithLocation.xml | 19 +++ libcloud/test/compute/test_nttcis.py | 135 +++++++++++++++++++ 3 files changed, 155 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/e23061f5/libcloud/compute/drivers/nttcis.py ---------------------------------------------------------------------- diff --git a/libcloud/compute/drivers/nttcis.py b/libcloud/compute/drivers/nttcis.py index 9810958..8f7deef 100644 --- a/libcloud/compute/drivers/nttcis.py +++ b/libcloud/compute/drivers/nttcis.py @@ -922,7 +922,7 @@ class NttCisNodeDriver(NodeDriver): return self._to_networks( self.connection - .request_with_orgId_api_1('networkWithLocation%s' % url_ext) + .request_with_orgId_api_2('networkWithLocation%s' % url_ext) .object) def import_image(self, ovf_package_name, name, http://git-wip-us.apache.org/repos/asf/libcloud/blob/e23061f5/libcloud/test/compute/fixtures/nttcis/networkWithLocation.xml ---------------------------------------------------------------------- diff --git a/libcloud/test/compute/fixtures/nttcis/networkWithLocation.xml b/libcloud/test/compute/fixtures/nttcis/networkWithLocation.xml new file mode 100644 index 0000000..227def2 --- /dev/null +++ b/libcloud/test/compute/fixtures/nttcis/networkWithLocation.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8" standalone="yes"?> +<ns3:NetworkWithLocations xmlns:ns16="http://oec.api.opsource.net/schemas/reset" xmlns:ns14="http://oec.api.opsource.net/schemas/multigeo" xmlns:ns15="http://oec.api.opsource.net/schemas/support" xmlns:ns9="http://oec.api.opsource.net/schemas/directory" xmlns:ns5="http://oec.api.opsource.net/schemas/vip" xmlns:ns12="http://oec.api.opsource.net/schemas/admin" xmlns:ns13="http://oec.api.opsource.net/schemas/general" xmlns:ns6="http://oec.api.opsource.net/schemas/organization" xmlns:ns7="http://oec.api.opsource.net/schemas/whitelabel" xmlns:ns10="http://oec.api.opsource.net/schemas/storage" xmlns:ns8="http://oec.api.opsource.net/schemas/backup" xmlns:ns11="http://oec.api.opsource.net/schemas/serverbootstrap" xmlns:ns2="http://oec.api.opsource.net/schemas/server" xmlns:ns1="http://oec.api.opsource.net/schemas/datacenter" xmlns:ns4="http://oec.api.opsource.net/schemas/manualimport" xmlns:ns3="http://oec.api.opsource.net/schemas/network"> + <ns3:network> + <ns3:id>4bba37be-506f-11e3-b29c-001517c4643e</ns3:id> + <ns3:name>test-net1</ns3:name> + <ns3:description>Test Network.</ns3:description> + <ns3:location>NA5</ns3:location> + <ns3:privateNet>10.192.176.0</ns3:privateNet> + <ns3:multicast>false</ns3:multicast> + </ns3:network> + <ns3:network> + <ns3:id>208e3a8e-9d2f-11e2-b29c-001517c4643e</ns3:id> + <ns3:name>Test Network</ns3:name> + <ns3:description>Network description</ns3:description> + <ns3:location>NA9</ns3:location> + <ns3:privateNet>10.172.74.0</ns3:privateNet> + <ns3:multicast>false</ns3:multicast> + </ns3:network> +</ns3:NetworkWithLocations> http://git-wip-us.apache.org/repos/asf/libcloud/blob/e23061f5/libcloud/test/compute/test_nttcis.py ---------------------------------------------------------------------- diff --git a/libcloud/test/compute/test_nttcis.py b/libcloud/test/compute/test_nttcis.py index cff7094..7f894bd 100644 --- a/libcloud/test/compute/test_nttcis.py +++ b/libcloud/test/compute/test_nttcis.py @@ -9,6 +9,8 @@ from libcloud.common.types import InvalidCredsError from libcloud.common.nttcis import NttCisAPIException, NetworkDomainServicePlan from libcloud.common.nttcis import NttCisServerCpuSpecification, NttCisServerDisk, NttCisServerVMWareTools from libcloud.common.nttcis import NttCisTag, NttCisTagKey +from libcloud.common.nttcis import NttCisServerCpuSpecification +from libcloud.common.nttcis import NttCisServerDisk from libcloud.common.nttcis import NttCisIpAddress, \ NttCisIpAddressList, NttCisChildIpAddressList, \ NttCisPortList, NttCisPort, NttCisChildPortList @@ -247,6 +249,134 @@ def test_ex_list_customer_images(driver): assert images[0].extra['OS_displayName'] == 'REDHAT6/64' +def test_create_mcp1_node_optional_param(driver): + root_pw = NodeAuthPassword('pass123') + image = driver.list_images()[0] + network = driver.ex_list_networks()[0] + cpu_spec = NttCisServerCpuSpecification(cpu_count='4', + cores_per_socket='2', + performance='STANDARD') + disks = [NttCisServerDisk(scsi_id='0', speed='HIGHPERFORMANCE')] + node = driver.create_node(name='test2', image=image, auth=root_pw, + ex_description='test2 node', + ex_network=network, + ex_is_started=False, + ex_memory_gb=8, + ex_disks=disks, + ex_cpu_specification=cpu_spec, + ex_primary_dns='10.0.0.5', + ex_secondary_dns='10.0.0.6' + ) + assert node.id == 'e75ead52-692f-4314-8725-c8a4f4d13a87' + assert node.extra['status'].action == 'DEPLOY_SERVER' + + +def test_create_mcp1_node_response_no_pass_random_gen(driver): + image = driver.list_images()[0] + network = driver.ex_list_networks()[0] + node = driver.create_node(name='test2', image=image, auth=None, + ex_description='test2 node', + ex_network=network, + ex_is_started=False) + assert node.id == 'e75ead52-692f-4314-8725-c8a4f4d13a87' + assert node.extra['status'].action == 'DEPLOY_SERVER' + assert 'password' in node.extra + + +def test_create_mcp1_node_response_no_pass_customer_windows(driver): + image = driver.ex_list_customer_images()[1] + network = driver.ex_list_networks()[0] + node = driver.create_node(name='test2', image=image, auth=None, + ex_description='test2 node', ex_network=network, + ex_is_started=False) + assert node.id == 'e75ead52-692f-4314-8725-c8a4f4d13a87' + assert node.extra['status'].action == 'DEPLOY_SERVER' + assert 'password' in node.extra + + +def test_create_mcp1_node_response_no_pass_customer_windows_STR(driver): + image = driver.ex_list_customer_images()[1].id + network = driver.ex_list_networks()[0] + node = driver.create_node(name='test2', image=image, auth=None, + ex_description='test2 node', ex_network=network, + ex_is_started=False) + assert node.id == 'e75ead52-692f-4314-8725-c8a4f4d13a87' + assert node.extra['status'].action == 'DEPLOY_SERVER' + assert 'password' in node.extra + + +def test_create_mcp1_node_response_no_pass_customer_linux(driver): + image = driver.ex_list_customer_images()[0] + network = driver.ex_list_networks()[0] + node = driver.create_node(name='test2', image=image, auth=None, + ex_description='test2 node', ex_network=network, + ex_is_started=False) + assert node.id == 'e75ead52-692f-4314-8725-c8a4f4d13a87' + assert node.extra['status'].action == 'DEPLOY_SERVER' + assert 'password' not in node.extra + + +def test_create_mcp1_node_response_no_pass_customer_linux_STR(driver): + image = driver.ex_list_customer_images()[0].id + network = driver.ex_list_networks()[0] + node = driver.create_node(name='test2', image=image, auth=None, + ex_description='test2 node', ex_network=network, + ex_is_started=False) + assert node.id == 'e75ead52-692f-4314-8725-c8a4f4d13a87' + assert node.extra['status'].action == 'DEPLOY_SERVER' + assert 'password' not in node.extra + + +def test_create_mcp1_node_response_STR(driver): + rootPw = 'pass123' + image = driver.list_images()[0].id + network = driver.ex_list_networks()[0].id + node = driver.create_node(name='test2', image=image, auth=rootPw, + ex_description='test2 node', ex_network=network, + ex_is_started=False) + assert node.id == 'e75ead52-692f-4314-8725-c8a4f4d13a87' + assert node.extra['status'].action == 'DEPLOY_SERVER' + + +def test_create_mcp1_node_no_network(driver): + rootPw = NodeAuthPassword('pass123') + image = driver.list_images()[0] + with pytest.raises(InvalidRequestError): + driver.create_node(name='test2', + image=image, + auth=rootPw, + ex_description='test2 node', + ex_network=None, + ex_is_started=False) + + +def test_create_node_mcp1_ipv4(driver): + rootPw = NodeAuthPassword('pass123') + image = driver.list_images()[0] + node = driver.create_node(name='test2', + image=image, + auth=rootPw, + ex_description='test2 node', + ex_network='fakenetwork', + ex_primary_ipv4='10.0.0.1', + ex_is_started=False) + assert node.id == 'e75ead52-692f-4314-8725-c8a4f4d13a87' + assert node.extra['status'].action == 'DEPLOY_SERVER' + + +def test_create_node_mcp1_network(driver): + rootPw = NodeAuthPassword('pass123') + image = driver.list_images()[0] + node = driver.create_node(name='test2', + image=image, + auth=rootPw, + ex_description='test2 node', + ex_network='fakenetwork', + ex_is_started=False) + assert node.id == 'e75ead52-692f-4314-8725-c8a4f4d13a87' + assert node.extra['status'].action == 'DEPLOY_SERVER' + + def test_create_node_response_network_domain(driver): rootPw = NodeAuthPassword('pass123') location = driver.ex_get_location_by_id('NA9') @@ -1706,6 +1836,11 @@ class NttCisMockHttp(MockHttp): body = self.fixtures.load('oec_0_9_myaccount.xml') return (httplib.OK, body, {}, httplib.responses[httplib.OK]) + def _caas_2_7_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_networkWithLocation(self, method, url, body, headers): + body = self.fixtures.load( + 'networkWithLocation.xml') + return (httplib.OK, body, {}, httplib.responses[httplib.OK]) + def _caas_2_7_8a8f6abc_2745_4d8a_9cbc_8dabe5a7d0e4_server(self, method, url, body, headers): body = self.fixtures.load( 'server.xml')
