Skip to content

Commit

Permalink
Merge pull request #1094 from grycap/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
micafer authored Dec 17, 2020
2 parents 592b2e4 + 2bb0e77 commit d5389a0
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 18 deletions.
14 changes: 13 additions & 1 deletion IM/connectors/Linode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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"""
Expand Down
4 changes: 2 additions & 2 deletions docker-devel/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand Down
4 changes: 2 additions & 2 deletions docker-py3/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand Down
24 changes: 12 additions & 12 deletions test/unit/connectors/Linode.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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'
Expand Down Expand Up @@ -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

Expand All @@ -237,15 +237,15 @@ 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'])
node.id = "1"
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)

Expand Down Expand Up @@ -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'])
Expand All @@ -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
Expand Down Expand Up @@ -334,15 +334,15 @@ 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'])
node.id = "1"
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)

Expand All @@ -364,15 +364,15 @@ 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'])
node.id = "1"
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"
Expand Down

0 comments on commit d5389a0

Please sign in to comment.