Skip to content

Commit

Permalink
Merge pull request #505 from grycap/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
micafer authored Nov 30, 2017
2 parents f89379f + 6450f10 commit 32d4811
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 12 deletions.
2 changes: 1 addition & 1 deletion IM/connectors/Azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def get_instance_type(self, system, credentials, subscription_id):
disk_free_op = ">="
if system.getValue('disks.free_size'):
disk_free = system.getFeature('disks.free_size').getValue('M')
disk_free_op = system.getFeature('memory.size').getLogOperator()
disk_free_op = system.getFeature('disks.free_size').getLogOperator()

compute_client = ComputeManagementClient(credentials, subscription_id)
instace_types = list(compute_client.virtual_machine_sizes.list(location))
Expand Down
2 changes: 1 addition & 1 deletion IM/connectors/AzureClassic.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ def get_instance_type(self, system, auth_data):
disk_free_op = ">="
if system.getValue('disks.free_size'):
disk_free = system.getFeature('disks.free_size').getValue('M')
disk_free_op = system.getFeature('memory.size').getLogOperator()
disk_free_op = system.getFeature('disks.free_size').getLogOperator()

instace_types = self.get_all_instance_types(auth_data)

Expand Down
2 changes: 1 addition & 1 deletion IM/connectors/EC2.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def get_instance_type(self, radl, vpc=None):
disk_free_op = ">="
if radl.getValue('disks.free_size'):
disk_free = radl.getFeature('disks.free_size').getValue('G')
disk_free_op = radl.getFeature('memory.size').getLogOperator()
disk_free_op = radl.getFeature('disks.free_size').getLogOperator()

performance = 0
performance_op = ">="
Expand Down
19 changes: 16 additions & 3 deletions IM/connectors/OpenStack.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,19 @@ def __init__(self, cloud_info, inf):
self.add_public_ip_count = 0
LibCloudCloudConnector.__init__(self, cloud_info, inf)

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)
node = driver.ex_get_node_details(node_id)
return node

def get_driver(self, auth_data):
"""
Get the driver from the auth data
Expand Down Expand Up @@ -171,9 +184,9 @@ def get_instance_type(self, sizes, radl):
memory_op = radl.getFeature('memory.size').getLogOperator()
disk_free = 0
disk_free_op = ">="
if radl.getValue('disk.0.free_size'):
disk_free = radl.getFeature('disk.0.free_size').getValue('G')
disk_free_op = radl.getFeature('memory.size').getLogOperator()
if radl.getValue('disks.free_size'):
disk_free = radl.getFeature('disks.free_size').getValue('G')
disk_free_op = radl.getFeature('disks.free_size').getLogOperator()

# get the node size with the lowest price, vcpus and memory
sizes.sort(key=lambda x: (x.price, x.vcpus, x.ram))
Expand Down
12 changes: 6 additions & 6 deletions test/unit/connectors/OpenStack.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def test_30_updateVMInfo(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_details.return_value = node

node_size = MagicMock()
node_size.ram = 512
Expand Down Expand Up @@ -308,7 +308,7 @@ def test_40_stop(self, get_driver):
node.public_ips = ['158.42.1.1']
node.private_ips = ['10.0.0.1']
node.driver = driver
driver.list_nodes.return_value = [node]
driver.ex_get_node_details.return_value = node

driver.ex_stop_node.return_value = True

Expand Down Expand Up @@ -336,7 +336,7 @@ def test_50_start(self, get_driver):
node.public_ips = ['158.42.1.1']
node.private_ips = ['10.0.0.1']
node.driver = driver
driver.list_nodes.return_value = [node]
driver.ex_get_node_details.return_value = node

driver.ex_start_node.return_value = True

Expand Down Expand Up @@ -386,7 +386,7 @@ def test_55_alter(self, get_driver):
node.public_ips = ['158.42.1.1']
node.private_ips = ['10.0.0.1']
node.driver = driver
driver.list_nodes.return_value = [node]
driver.ex_get_node_details.return_value = node

node_size = MagicMock()
node_size.ram = 2048
Expand Down Expand Up @@ -435,7 +435,7 @@ def test_60_finalize(self, sleep, get_driver):
node.private_ips = ['10.0.0.1']
node.driver = driver
node.destroy.return_value = True
driver.list_nodes.return_value = [node]
driver.ex_get_node_details.return_value = node

keypair = MagicMock()
driver.get_key_pair.return_value = keypair
Expand Down Expand Up @@ -468,7 +468,7 @@ def test_70_create_snapshot(self, get_driver):
node = MagicMock()
node.id = "1"
node.driver = driver
driver.list_nodes.return_value = [node]
driver.ex_get_node_details.return_value = node
image = MagicMock()
image.id = "newimage"
driver.create_image.return_value = image
Expand Down

0 comments on commit 32d4811

Please sign in to comment.