Skip to content

Commit

Permalink
Merge branch 'master' into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
micafer authored Mar 24, 2022
2 parents d37ec78 + 736af22 commit 6249c81
Show file tree
Hide file tree
Showing 14 changed files with 108 additions and 106 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ All the information about this chart is available at the [IM chart README](https

### 3.1 REQUISITES

IM is based on Python, so Python 2.7 or higher (Python 3.5 or higher recommended) runtime and
IM is based on Python, so Python 2.7 or higher (Python 3.6 or higher recommended) runtime and
standard library must be installed in the system.

If you use pip to install the IM, all the requisites will be installed.
Expand Down Expand Up @@ -172,7 +172,7 @@ Azure python SDK (https://azure.microsoft.com/es-es/develop/python/) is used to
Microsoft Azure platform. The easiest way is to install all the required packages with pip:

```sh
$ pip install msrest msrestazure azure-common azure-mgmt-storage azure-mgmt-compute azure-mgmt-network azure-mgmt-resource azure-mgmt-dns
$ pip install msrest msrestazure azure-common azure-mgmt-storage azure-mgmt-compute azure-mgmt-network azure-mgmt-resource azure-mgmt-dns azure-identity
```

The VMware vSphere API Python Bindings (https://github.com/vmware/pyvmomi/) are needed by the vSphere
Expand Down
4 changes: 3 additions & 1 deletion doc/source/client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ The :program:`im_client` is called like this::
Authorization File
------------------

To access the IM service an authenticatio file must be created.
To access the IM service an authentication file must be created.
It must have one line per authentication element. **It must have at least
one line with the authentication data for the IM service** and another
one for the Cloud/s provider/s the user want to access.
Expand Down Expand Up @@ -410,6 +410,8 @@ An example of the auth file::
# InfrastructureManager auth
type = InfrastructureManager; username = user; password: pass
type = InfrastructureManager: token = access_token_value
# Having at least one of the two lines above is mandatory for all auth files.
# The lines below are concrete examples for each infrastructure. Please add only the ones that are relevant to you.
# Vault auth
type = Vault; host = https://vault.com:8200; token = access_token_value; role = role; path = path
# OpenNebula site
Expand Down
4 changes: 2 additions & 2 deletions doc/source/gstarted.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ In this first examples we will use the IM-client tool to create, manage and fina

Authentication file
^^^^^^^^^^^^^^^^^^^
To access the IM service an authenticatio file must be created. It must have one line per authentication element.
To access the IM service an authentication file must be created. It must have one line per authentication element.
**It must have at least one line with the authentication data for the IM service** and another one for the Cloud/s
provider/s the user want to access.

An example to access an OpenNebula and/or an OpenStack site::

id = im; type = InfrastructureManager; username = user; password = pass
id = im; type = InfrastructureManager; username = user; password = pass # mandatory
id = one; type = OpenNebula; host = osenserver:2633; username = user; password = pass
id = ost; type = OpenStack; host = https://ostserver:5000; username = user; password = pass; tenant = tenant

Expand Down
2 changes: 1 addition & 1 deletion test/integration/TestREST.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ def test_94_get_outputs(self):
msg="ERROR getting TOSCA outputs:" + resp.text)
res = json.loads(resp.text)
server_url = str(res['outputs']['server_url'][0])
self.assertRegexpMatches(
self.assertRegex(
server_url, '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', msg="Unexpected outputs: " + resp.text)

def test_95_add_tosca(self):
Expand Down
10 changes: 5 additions & 5 deletions test/unit/connectors/Azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def test_20_launch(self, save_data, credentials, network_client, compute_client,
self.assertEqual(json_vm_req['os_profile']['admin_password'], 'pass')
self.assertEqual(json_vm_req['os_profile']['admin_password'], 'pass')
self.assertEqual(nclient.subnets.begin_create_or_update.call_args_list[0][0][3]['address_prefix'],
'10.0.1.0/24')
'10.0.1.0/24')

radl_data = """
network net1 (outbound = 'yes')
Expand Down Expand Up @@ -279,7 +279,7 @@ def test_20_launch(self, save_data, credentials, network_client, compute_client,
json_vm_req = cclient.virtual_machines.begin_create_or_update.call_args_list[5][0][2]
self.assertEqual(json_vm_req['storage_profile']['os_disk']['os_type'], 'linux')
self.assertEqual(nclient.subnets.begin_create_or_update.call_args_list[2][0][3]['address_prefix'],
'192.168.1.0/24')
'192.168.1.0/24')

radl_data = """
network net1 (outbound = 'yes')
Expand Down Expand Up @@ -405,10 +405,10 @@ def test_30_updateVMInfo(self, credentials, dns_client, compute_client, network_

self.assertTrue(success, msg="ERROR: updating VM info.")
self.assertEqual(dclient.zones.create_or_update.call_args_list,
[call('rg0', 'domain.com', {'location': 'global'})])
[call('rg0', 'domain.com', {'location': 'global'})])
self.assertEqual(dclient.record_sets.create_or_update.call_args_list,
[call('rg0', 'domain.com', 'test', 'A',
{'arecords': [{'ipv4_address': '13.0.0.1'}], 'ttl': 300})])
[call('rg0', 'domain.com', 'test', 'A',
{'arecords': [{'ipv4_address': '13.0.0.1'}], 'ttl': 300})])
self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())

@patch('IM.connectors.Azure.ComputeManagementClient')
Expand Down
2 changes: 1 addition & 1 deletion test/unit/connectors/CloudStack.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def test_30_updateVMInfo(self, get_driver):
success, vm = osc_cloud.updateVMInfo(vm, auth)

self.assertTrue(success, msg="ERROR: updating VM info.")
self.assertEquals(vm.info.systems[0].getValue("net_interface.0.ip"), "8.8.8.8")
self.assertEqual(vm.info.systems[0].getValue("net_interface.0.ip"), "8.8.8.8")
self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())

@patch('libcloud.compute.drivers.cloudstack.CloudStackNodeDriver')
Expand Down
4 changes: 2 additions & 2 deletions test/unit/connectors/Docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def test_30_updateVMInfo(self, requests):
success, vm = docker_cloud.updateVMInfo(vm, auth)

self.assertTrue(success, msg="ERROR: updating VM info.")
self.assertEquals(vm.info.systems[0].getValue("net_interface.1.ip"), "10.0.0.1")
self.assertEqual(vm.info.systems[0].getValue("net_interface.1.ip"), "10.0.0.1")
self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())

self.activate_swarm()
Expand All @@ -232,7 +232,7 @@ def test_30_updateVMInfo(self, requests):
docker_cloud._swarm = None

self.assertTrue(success, msg="ERROR: updating VM info.")
self.assertEquals(vm.info.systems[0].getValue("net_interface.1.ip"), "10.0.0.1")
self.assertEqual(vm.info.systems[0].getValue("net_interface.1.ip"), "10.0.0.1")
self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())

@patch('requests.request')
Expand Down
48 changes: 24 additions & 24 deletions test/unit/connectors/EC2.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,10 @@ def test_20_launch(self, save_data, blockdevicemapping, VPCConnection, get_regio
success, _ = res[0]
self.assertTrue(success, msg="ERROR: launching a VM.")
self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())
self.assertEquals(len(conn.create_security_group.call_args_list), 3)
self.assertEquals(conn.create_security_group.call_args_list[0][0][0], "im-%s" % inf.id)
self.assertEquals(conn.create_security_group.call_args_list[1][0][0], "sgname")
self.assertEquals(conn.create_security_group.call_args_list[2][0][0], "im-%s-net2" % inf.id)
self.assertEqual(len(conn.create_security_group.call_args_list), 3)
self.assertEqual(conn.create_security_group.call_args_list[0][0][0], "im-%s" % inf.id)
self.assertEqual(conn.create_security_group.call_args_list[1][0][0], "sgname")
self.assertEqual(conn.create_security_group.call_args_list[2][0][0], "im-%s-net2" % inf.id)

# Check the case that we do not use VPC
radl_data = """
Expand Down Expand Up @@ -225,10 +225,10 @@ def test_20_launch(self, save_data, blockdevicemapping, VPCConnection, get_regio
self.assertTrue(success, msg="ERROR: launching a VM.")
# check the instance_type selected is correct
self.assertIn(".micro", conn.run_instances.call_args_list[1][1]["instance_type"])
self.assertEquals(conn.create_vpc.call_args_list[0][0][0], "10.0.128.0/22")
self.assertEquals(conn.create_subnet.call_args_list[0][0], ('vpc-id', '10.0.128.0/24'))
self.assertEquals(conn.create_subnet.call_args_list[1][0], ('vpc-id', '10.0.129.0/24'))
self.assertEquals(conn.create_subnet.call_args_list[2][0], ('vpc-id', '10.0.130.0/24'))
self.assertEqual(conn.create_vpc.call_args_list[0][0][0], "10.0.128.0/22")
self.assertEqual(conn.create_subnet.call_args_list[0][0], ('vpc-id', '10.0.128.0/24'))
self.assertEqual(conn.create_subnet.call_args_list[1][0], ('vpc-id', '10.0.129.0/24'))
self.assertEqual(conn.create_subnet.call_args_list[2][0], ('vpc-id', '10.0.130.0/24'))

self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())

Expand Down Expand Up @@ -400,11 +400,11 @@ def test_30_updateVMInfo(self, record_sets, connect_to_region, get_connection):
self.assertTrue(success, msg="ERROR: updating VM info.")
self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())

self.assertEquals(dns_conn.create_zone.call_count, 1)
self.assertEquals(dns_conn.create_zone.call_args_list[0][0][0], "domain.com.")
self.assertEquals(changes.add_change.call_args_list, [call('CREATE', 'test.domain.com.', 'A')])
self.assertEquals(change.add_value.call_args_list, [call('158.42.1.1')])
self.assertEquals(conn.create_route.call_args_list, [call('routet-id', '10.0.10.0/24', instance_id='int-id')])
self.assertEqual(dns_conn.create_zone.call_count, 1)
self.assertEqual(dns_conn.create_zone.call_args_list[0][0][0], "domain.com.")
self.assertEqual(changes.add_change.call_args_list, [call('CREATE', 'test.domain.com.', 'A')])
self.assertEqual(change.add_value.call_args_list, [call('158.42.1.1')])
self.assertEqual(conn.create_route.call_args_list, [call('routet-id', '10.0.10.0/24', instance_id='int-id')])

@patch('IM.connectors.EC2.EC2CloudConnector.get_connection')
def test_30_updateVMInfo_spot(self, get_connection):
Expand Down Expand Up @@ -690,17 +690,17 @@ def test_60_finalize(self, record_sets, connect_to_region, sleep, get_connection
self.assertTrue(success, msg="ERROR: finalizing VM info.")
self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())

self.assertEquals(dns_conn.delete_hosted_zone.call_count, 1)
self.assertEquals(dns_conn.delete_hosted_zone.call_args_list[0][0][0], zone.id)
self.assertEquals(changes.add_change.call_args_list, [call('DELETE', 'test.domain.com.', 'A')])
self.assertEquals(change.add_value.call_args_list, [call('158.42.1.1')])
self.assertEquals(sg.delete.call_args_list, [call()])
self.assertEquals(sg1.delete.call_args_list, [])
self.assertEquals(sg2.delete.call_args_list, [call()])
self.assertEquals(conn.delete_subnet.call_args_list, [call('subnet-id')])
self.assertEquals(conn.delete_vpc.call_args_list, [call('vpc-id')])
self.assertEquals(conn.delete_internet_gateway.call_args_list, [call('ig-id')])
self.assertEquals(conn.detach_internet_gateway.call_args_list, [call('ig-id', 'vpc-id')])
self.assertEqual(dns_conn.delete_hosted_zone.call_count, 1)
self.assertEqual(dns_conn.delete_hosted_zone.call_args_list[0][0][0], zone.id)
self.assertEqual(changes.add_change.call_args_list, [call('DELETE', 'test.domain.com.', 'A')])
self.assertEqual(change.add_value.call_args_list, [call('158.42.1.1')])
self.assertEqual(sg.delete.call_args_list, [call()])
self.assertEqual(sg1.delete.call_args_list, [])
self.assertEqual(sg2.delete.call_args_list, [call()])
self.assertEqual(conn.delete_subnet.call_args_list, [call('subnet-id')])
self.assertEqual(conn.delete_vpc.call_args_list, [call('vpc-id')])
self.assertEqual(conn.delete_internet_gateway.call_args_list, [call('ig-id')])
self.assertEqual(conn.detach_internet_gateway.call_args_list, [call('ig-id', 'vpc-id')])

@patch('IM.connectors.EC2.EC2CloudConnector.get_connection')
@patch('time.sleep')
Expand Down
8 changes: 4 additions & 4 deletions test/unit/connectors/Fogbow.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,10 @@ def test_30_updateVMInfo(self, sleep, requests):

self.assertTrue(success, msg="ERROR: updating VM info.")
self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())
self.assertEquals(vm.info.systems[0].getValue("net_interface.1.ip"), "10.0.0.1")
self.assertEquals(vm.info.systems[0].getValue("net_interface.0.ip"), "8.8.8.8")
self.assertEquals(vm.info.systems[0].getValue("memory.size"), 1073741824)
self.assertEquals(vm.info.systems[0].getValue("disk.1.device"), "/dev/sdb")
self.assertEqual(vm.info.systems[0].getValue("net_interface.1.ip"), "10.0.0.1")
self.assertEqual(vm.info.systems[0].getValue("net_interface.0.ip"), "8.8.8.8")
self.assertEqual(vm.info.systems[0].getValue("memory.size"), 1073741824)
self.assertEqual(vm.info.systems[0].getValue("disk.1.device"), "/dev/sdb")

data = json.loads(requests.call_args_list[1][1]["data"])
self.assertEqual(data["computeId"], '1')
Expand Down
40 changes: 20 additions & 20 deletions test/unit/connectors/GCE.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,14 +296,14 @@ def test_30_updateVMInfo(self, get_dns_driver, get_driver):

self.assertTrue(success, msg="ERROR: updating VM info.")

self.assertEquals(dns_driver.create_zone.call_count, 1)
self.assertEquals(dns_driver.create_record.call_count, 1)
self.assertEquals(dns_driver.create_zone.call_args_list[0], call('domain.com.'))
self.assertEquals(dns_driver.create_record.call_args_list[0][0][0], 'test.domain.com.')
self.assertEquals(dns_driver.create_record.call_args_list[0][0][2], 'A')
self.assertEquals(dns_driver.create_record.call_args_list[0][0][3], {'rrdatas': ['158.42.1.1'], 'ttl': 300})
self.assertEquals(vm.info.systems[0].getValue('gpu.count'), 1)
self.assertEquals(vm.info.systems[0].getValue('gpu.model'), 'nvidia-tesla-v100')
self.assertEqual(dns_driver.create_zone.call_count, 1)
self.assertEqual(dns_driver.create_record.call_count, 1)
self.assertEqual(dns_driver.create_zone.call_args_list[0], call('domain.com.'))
self.assertEqual(dns_driver.create_record.call_args_list[0][0][0], 'test.domain.com.')
self.assertEqual(dns_driver.create_record.call_args_list[0][0][2], 'A')
self.assertEqual(dns_driver.create_record.call_args_list[0][0][3], {'rrdatas': ['158.42.1.1'], 'ttl': 300})
self.assertEqual(vm.info.systems[0].getValue('gpu.count'), 1)
self.assertEqual(vm.info.systems[0].getValue('gpu.model'), 'nvidia-tesla-v100')

self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())

Expand All @@ -327,7 +327,7 @@ def test_40_stop(self, get_driver):

self.assertTrue(success, msg="ERROR: stopping VM info.")
self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())
self.assertEquals(driver.ex_stop_node.call_args_list, [call(node)])
self.assertEqual(driver.ex_stop_node.call_args_list, [call(node)])

@patch('libcloud.compute.drivers.gce.GCENodeDriver')
def test_50_start(self, get_driver):
Expand All @@ -349,7 +349,7 @@ def test_50_start(self, get_driver):

self.assertTrue(success, msg="ERROR: stopping VM info.")
self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())
self.assertEquals(driver.ex_start_node.call_args_list, [call(node)])
self.assertEqual(driver.ex_start_node.call_args_list, [call(node)])

@patch('libcloud.compute.drivers.gce.GCENodeDriver')
def test_52_reboot(self, get_driver):
Expand All @@ -371,7 +371,7 @@ def test_52_reboot(self, get_driver):

self.assertTrue(success, msg="ERROR: stopping VM info.")
self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())
self.assertEquals(driver.reboot_node.call_args_list, [call(node)])
self.assertEqual(driver.reboot_node.call_args_list, [call(node)])

@patch('libcloud.compute.drivers.gce.GCENodeDriver')
@patch('libcloud.dns.drivers.google.GoogleDNSDriver')
Expand Down Expand Up @@ -439,12 +439,12 @@ def test_60_finalize(self, sleep, get_dns_driver, get_driver):

self.assertTrue(success, msg="ERROR: finalizing VM info.")
self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())
self.assertEquals(dns_driver.delete_record.call_count, 1)
self.assertEquals(dns_driver.delete_record.call_args_list[0][0][0].name, 'test.domain.com.')
self.assertEquals(node.destroy.call_args_list, [call()])
self.assertEquals(net.destroy.call_args_list, [call()])
self.assertEquals(fw.destroy.call_args_list, [call()])
self.assertEquals(route.destroy.call_args_list, [call()])
self.assertEqual(dns_driver.delete_record.call_count, 1)
self.assertEqual(dns_driver.delete_record.call_args_list[0][0][0].name, 'test.domain.com.')
self.assertEqual(node.destroy.call_args_list, [call()])
self.assertEqual(net.destroy.call_args_list, [call()])
self.assertEqual(fw.destroy.call_args_list, [call()])
self.assertEqual(route.destroy.call_args_list, [call()])

def test_70_get_custom_instance(self):
radl_data = """
Expand All @@ -462,16 +462,16 @@ def test_70_get_custom_instance(self):
driver = MagicMock()
driver.list_sizes.return_value = [size]
instance = gce_cloud.get_instance_type(driver, radl.systems[0])
self.assertEquals(instance.name, "custom-2-2048")
self.assertEquals(instance.extra['selfLink'], "/some/path/custom-2-2048")
self.assertEqual(instance.name, "custom-2-2048")
self.assertEqual(instance.extra['selfLink'], "/some/path/custom-2-2048")

size2 = MagicMock()
size2.extra = {"selfLink": "/some/path/sizenamne", "guestCpus": 2}
size2.ram = 2048
size2.name = "sizenamne"
driver.list_sizes.return_value = [size, size2]
instance = gce_cloud.get_instance_type(driver, radl.systems[0])
self.assertEquals(instance.name, "sizenamne")
self.assertEqual(instance.name, "sizenamne")

@patch('libcloud.compute.drivers.gce.GCENodeDriver')
def test_get_cloud_info(self, get_driver):
Expand Down
12 changes: 6 additions & 6 deletions test/unit/connectors/Linode.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,12 @@ def test_30_updateVMInfo(self, get_dns_driver, get_driver):
self.assertEqual(driver.create_volume.call_args_list[0][0][1], 10)
self.assertEqual(driver.create_volume.call_args_list[0][1]['node'], node)

self.assertEquals(dns_driver.create_zone.call_count, 1)
self.assertEquals(dns_driver.create_record.call_count, 1)
self.assertEquals(dns_driver.create_zone.call_args_list[0][0][0], 'domain.com')
self.assertEquals(dns_driver.create_record.call_args_list[0][0][0], 'test')
self.assertEquals(dns_driver.create_record.call_args_list[0][0][2], 'A')
self.assertEquals(dns_driver.create_record.call_args_list[0][0][3], '8.8.8.8')
self.assertEqual(dns_driver.create_zone.call_count, 1)
self.assertEqual(dns_driver.create_record.call_count, 1)
self.assertEqual(dns_driver.create_zone.call_args_list[0][0][0], 'domain.com')
self.assertEqual(dns_driver.create_record.call_args_list[0][0][0], 'test')
self.assertEqual(dns_driver.create_record.call_args_list[0][0][2], 'A')
self.assertEqual(dns_driver.create_record.call_args_list[0][0][3], '8.8.8.8')

self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue())

Expand Down
Loading

0 comments on commit 6249c81

Please sign in to comment.