diff --git a/IM/connectors/Linode.py b/IM/connectors/Linode.py index 9547111ce..2d486e8b0 100644 --- a/IM/connectors/Linode.py +++ b/IM/connectors/Linode.py @@ -132,7 +132,7 @@ def get_instance_type(self, sizes, radl): size.extra['gpus'] and gpu_op(size.extra['gpus'], gpu)) if comparison: - if not instance_type_name or size.name == instance_type_name: + if not instance_type_name or size.id == instance_type_name: return size self.log_error("No compatible size found") @@ -167,6 +167,18 @@ def concrete_system(self, radl_system, str_url, auth_data): else: return None + def get_node_with_id(self, node_id, auth_data): + """ + Get the node with the specified ID + + Arguments: + - node_id(str): ID of the node to get + - auth(Authentication): parsed authentication tokens. + Returns: a :py:class:`libcloud.compute.base.Node` with the node info + """ + driver = self.get_driver(auth_data) + return driver.ex_get_node(node_id) + @staticmethod def get_location(driver, loc): """Return a NodeLocation""" diff --git a/docker-devel/Dockerfile b/docker-devel/Dockerfile index 36de2a809..54ca6294f 100644 --- a/docker-devel/Dockerfile +++ b/docker-devel/Dockerfile @@ -15,9 +15,9 @@ RUN apt-get update && apt-get install --no-install-recommends -y git python3-pip pip3 install pip setuptools --upgrade && \ /usr/local/bin/pip3 install msrest msrestazure azure-common azure-mgmt-storage azure-mgmt-compute azure-mgmt-network azure-mgmt-resource azure-mgmt-dns && \ /usr/local/bin/pip3 install pyOpenSSL cheroot xmltodict pymongo ansible==2.9.15&& \ - # Install it untill changes are merged upstream + # Install it until changes are released cd /tmp && git clone https://github.com/openstack/tosca-parser && /usr/local/bin/pip3 install /tmp/tosca-parser && \ - cd /tmp && git clone https://github.com/micafer/libcloud --branch linodev4 && /usr/local/bin/pip install /tmp/libcloud && \ + cd /tmp && git clone https://github.com/apache/libcloud && /usr/local/bin/pip install /tmp/libcloud && \ cd /tmp && git clone https://github.com/grycap/im.git -b $BRANCH && /usr/local/bin/pip3 install /tmp/im && \ /usr/local/bin/pip3 uninstall pip -y && \ apt-get purge -y git python3-pip && \ diff --git a/docker-py3/Dockerfile b/docker-py3/Dockerfile index 0552a322e..9e4b0eb06 100644 --- a/docker-py3/Dockerfile +++ b/docker-py3/Dockerfile @@ -14,9 +14,9 @@ RUN apt-get update && apt-get install --no-install-recommends -y git python3-pip pip3 install pip setuptools --upgrade && \ /usr/local/bin/pip3 install msrest msrestazure azure-common azure-mgmt-storage azure-mgmt-compute azure-mgmt-network azure-mgmt-resource azure-mgmt-dns && \ /usr/local/bin/pip3 install pyOpenSSL cheroot xmltodict pymongo ansible==2.9.15&& \ - # Install it untill changes are merged upstream + # Install it until changes are released cd /tmp && git clone https://github.com/openstack/tosca-parser && /usr/local/bin/pip3 install /tmp/tosca-parser && \ - cd /tmp && git clone https://github.com/micafer/libcloud --branch linodev4 && /usr/local/bin/pip install /tmp/libcloud && \ + cd /tmp && git clone https://github.com/apache/libcloud && /usr/local/bin/pip install /tmp/libcloud && \ /usr/local/bin/pip3 install IM==1.9.6 && \ /usr/local/bin/pip3 uninstall pip -y && \ apt-get purge -y git python3-pip && \ diff --git a/docker/Dockerfile b/docker/Dockerfile index f5840aff6..959d84c04 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -15,7 +15,7 @@ RUN apt-get update && apt-get install --no-install-recommends -y gcc git python pip install pip --upgrade -I && \ /usr/local/bin/pip install msrest msrestazure azure-common azure-mgmt-storage azure-mgmt-compute azure-mgmt-network azure-mgmt-resource azure-mgmt-dns && \ /usr/local/bin/pip install MySQL-python pyOpenSSL pycrypto xmltodict pymongo && \ - # Install it until changes are merged upstream + # Install it until changes are released cd /tmp && git clone https://github.com/openstack/tosca-parser && /usr/local/bin/pip install /tmp/tosca-parser && \ cd /tmp && git clone https://github.com/apache/libcloud && /usr/local/bin/pip install /tmp/libcloud && \ /usr/local/bin/pip install IM==1.9.6 && \ diff --git a/test/unit/connectors/Linode.py b/test/unit/connectors/Linode.py index 9771a3834..e47ae0502 100755 --- a/test/unit/connectors/Linode.py +++ b/test/unit/connectors/Linode.py @@ -170,7 +170,7 @@ def test_30_updateVMInfo(self, get_driver): inf = MagicMock(['id']) vm = VirtualMachine(inf, "1", linode_cloud.cloud, radl, radl, linode_cloud, 1) - driver = MagicMock(['name', 'list_nodes', 'list_sizes', 'create_volume', 'list_volumes']) + driver = MagicMock(['name', 'ex_get_node', 'list_sizes', 'create_volume', 'list_volumes']) get_driver.return_value = driver driver.name = 'Linode' @@ -181,7 +181,7 @@ def test_30_updateVMInfo(self, get_driver): node.private_ips = ['10.0.0.1'] node.driver = driver node.size = "small" - driver.list_nodes.return_value = [node] + driver.ex_get_node.return_value = node node_size = MagicMock(['id', 'ram', 'price', 'disk', 'extra']) node_size.id = 'small' @@ -213,14 +213,14 @@ def test_40_stop(self, get_driver): inf = MagicMock() vm = VirtualMachine(inf, "1", linode_cloud.cloud, "", "", linode_cloud, 1) - driver = MagicMock(['list_nodes']) + driver = MagicMock(['ex_get_node']) get_driver.return_value = driver node = MagicMock(['id', 'state', 'driver', 'stop_node']) node.id = "1" node.state = NodeState.RUNNING node.driver = driver - driver.list_nodes.return_value = [node] + driver.ex_get_node.return_value = node node.stop_node.return_value = True @@ -237,7 +237,7 @@ def test_50_start(self, get_driver): inf = MagicMock() vm = VirtualMachine(inf, "1", linode_cloud.cloud, "", "", linode_cloud, 1) - driver = MagicMock(['list_nodes']) + driver = MagicMock(['ex_get_node']) get_driver.return_value = driver node = MagicMock(['id', 'state', 'driver', 'start']) @@ -245,7 +245,7 @@ def test_50_start(self, get_driver): node.state = NodeState.RUNNING node.driver = driver node.start.return_value = True - driver.list_nodes.return_value = [node] + driver.ex_get_node.return_value = node success, _ = linode_cloud.start(vm, auth) @@ -282,7 +282,7 @@ def test_55_alter(self, get_driver): inf = MagicMock(['id']) vm = VirtualMachine(inf, "1", linode_cloud.cloud, radl, radl, linode_cloud, 1) - driver = MagicMock(['list_nodes', 'list_sizes', 'ex_resize_node', 'create_volume']) + driver = MagicMock(['ex_get_node', 'list_sizes', 'ex_resize_node', 'create_volume']) get_driver.return_value = driver node = MagicMock(['id', 'state', 'driver', 'size', 'public_ips', 'private_ips']) @@ -292,7 +292,7 @@ def test_55_alter(self, get_driver): node.public_ips = [] node.private_ips = ['10.0.0.1'] node.driver = driver - driver.list_nodes.return_value = [node] + driver.ex_get_node.return_value = node node_size = MagicMock(['id', 'ram', 'price', 'disk', 'extra', 'name']) node_size.ram = 2048 @@ -334,7 +334,7 @@ def test_60_reboot(self, get_driver): inf = MagicMock(['id']) vm = VirtualMachine(inf, "1", linode_cloud.cloud, "", "", linode_cloud, 1) - driver = MagicMock(['list_nodes']) + driver = MagicMock(['ex_get_node']) get_driver.return_value = driver node = MagicMock(['id', 'state', 'driver', 'reboot']) @@ -342,7 +342,7 @@ def test_60_reboot(self, get_driver): node.state = "running" node.driver = driver node.reboot.return_value = True - driver.list_nodes.return_value = [node] + driver.ex_get_node.return_value = node success, _ = linode_cloud.reboot(vm, auth) @@ -364,7 +364,7 @@ def test_70_finalize(self, get_driver): inf = MagicMock(['id']) vm = VirtualMachine(inf, "1", lib_cloud.cloud, radl, radl, lib_cloud, 1) - driver = MagicMock(['list_nodes', 'list_volumes']) + driver = MagicMock(['ex_get_node', 'list_volumes']) get_driver.return_value = driver node = MagicMock(['id', 'state', 'driver', 'destroy']) @@ -372,7 +372,7 @@ def test_70_finalize(self, get_driver): node.state = NodeState.RUNNING node.driver = driver node.destroy.return_value = True - driver.list_nodes.return_value = [node] + driver.ex_get_node.return_value = node volume = MagicMock(['id', 'extra', 'detach', 'destroy']) volume.id = "id"