From 93fd7c0b3d24d81736f38b2fbc4f11131b44b983 Mon Sep 17 00:00:00 2001 From: micafer Date: Wed, 9 May 2018 17:25:54 +0200 Subject: [PATCH 01/18] Raise error if no username nor token is provided --- IM/InfrastructureManager.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/IM/InfrastructureManager.py b/IM/InfrastructureManager.py index ecb83dcbb..de4725960 100644 --- a/IM/InfrastructureManager.py +++ b/IM/InfrastructureManager.py @@ -1221,10 +1221,12 @@ def check_auth_data(auth): # First check if an OIDC token is included if "token" in im_auth[0]: InfrastructureManager.check_oidc_token(im_auth[0]) - else: + elif "username" in im_auth[0]: if im_auth[0]['username'].startswith(IM.InfrastructureInfo.InfrastructureInfo.OPENID_USER_PREFIX): # This is a OpenID user do not enable to get data using user/pass creds raise IncorrectVMCrecentialsException("Invalid username used for the InfrastructureManager.") + else: + raise IncorrectVMCrecentialsException("No username nor token for the InfrastructureManager.") # Now check if the user is in authorized if not InfrastructureManager.check_im_user(im_auth): From 21a530f1a1a191a9277ede43a5873598a9d84a5b Mon Sep 17 00:00:00 2001 From: micafer Date: Wed, 9 May 2018 17:26:15 +0200 Subject: [PATCH 02/18] Update doc --- doc/source/client.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/source/client.rst b/doc/source/client.rst index 2d903d50e..8a00d47ef 100644 --- a/doc/source/client.rst +++ b/doc/source/client.rst @@ -46,9 +46,11 @@ The :program:`im_client` is called like this:: ``list`` List the infrastructure IDs created by the user. - ``create radlfile`` + ``create radlfile async_flag`` Create an infrastructure using RADL specified in the file with path - ``radlfile``. + ``radlfile``. The ``async_flag`` parameter is optional + and is a flag to specify if the creation call will wait the resources + to be created or return immediately the id of the infrastructure. ``destroy infId`` Destroy the infrastructure with ID ``infId``. From b805c44d5acd974585cd9a4c6781de7c369ebcfd Mon Sep 17 00:00:00 2001 From: micafer Date: Wed, 9 May 2018 17:27:59 +0200 Subject: [PATCH 03/18] Improve the log messages --- IM/VirtualMachine.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/IM/VirtualMachine.py b/IM/VirtualMachine.py index dd6efa674..ca6b6684c 100644 --- a/IM/VirtualMachine.py +++ b/IM/VirtualMachine.py @@ -581,13 +581,13 @@ def setIps(self, public_ips, private_ips, remove_old=False): if real_public_ips: vm_system.setValue('net_interface.%s.connection' % num_net, public_net.id) if len(real_public_ips) > 1: - self.logger.warn("Node with more that one public IP!") - self.logger.debug(real_public_ips) + self.log_warn("Node with more that one public IP!") + self.log_debug(real_public_ips) if len(real_public_ips) == 2: ip1 = IPAddress(real_public_ips[0]) ip2 = IPAddress(real_public_ips[1]) if ip1.version != ip2.version: - self.logger.info("It seems that there are one IPv4 and other IPv6. Get the IPv4 one.") + self.log_info("It seems that there are one IPv4 and other IPv6. Get the IPv4 one.") if ip1.version == 4: vm_system.setValue('net_interface.%s.ip' % num_net, str(real_public_ips[0])) vm_system.setValue('net_interface.%s.ipv6' % num_net, str(real_public_ips[1])) @@ -595,10 +595,10 @@ def setIps(self, public_ips, private_ips, remove_old=False): vm_system.setValue('net_interface.%s.ip' % num_net, str(real_public_ips[1])) vm_system.setValue('net_interface.%s.ipv6' % num_net, str(real_public_ips[0])) else: - self.logger.info("It seems that both are from the same version first one will be used") + self.log_info("It seems that both are from the same version first one will be used") vm_system.setValue('net_interface.%s.ip' % num_net, str(real_public_ips[0])) else: - self.logger.info("It seems that there are more that 2 last ones will be used") + self.log_info("It seems that there are more that 2 last ones will be used") for ip in real_public_ips: if IPAddress(ip).version == 4: vm_system.setValue('net_interface.%s.ip' % num_net, str(ip)) @@ -606,7 +606,11 @@ def setIps(self, public_ips, private_ips, remove_old=False): vm_system.setValue('net_interface.%s.ipv6' % num_net, str(ip)) else: # The usual case - vm_system.setValue('net_interface.%s.ip' % num_net, str(real_public_ips[0])) + if IPAddress(real_public_ips[0]).version == 6: + self.log_warn("Node only with one IPv6!!") + vm_system.setValue('net_interface.%s.ipv6' % num_net, str(real_public_ips[0])) + else: + vm_system.setValue('net_interface.%s.ip' % num_net, str(real_public_ips[0])) if private_ips: private_net_map = {} From 7516b45601ab79ac9543dd151bbad6aeba7acada Mon Sep 17 00:00:00 2001 From: micafer Date: Fri, 11 May 2018 13:23:10 +0200 Subject: [PATCH 04/18] Minor changes --- IM/connectors/OpenStack.py | 2 +- doc/source/web.rst | 32 +++++++++++++++++++++++++++++++- test/unit/test_im_logic.py | 7 +++++++ 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/IM/connectors/OpenStack.py b/IM/connectors/OpenStack.py index 368d59bf2..9ffc268e5 100644 --- a/IM/connectors/OpenStack.py +++ b/IM/connectors/OpenStack.py @@ -860,7 +860,7 @@ def finalize(self, vm, last, auth_data): return (True, "") - def delete_security_groups(self, driver, inf, timeout=90, delay=10): + def delete_security_groups(self, driver, inf, timeout=180, delay=10): """ Delete the SG of this inf """ diff --git a/doc/source/web.rst b/doc/source/web.rst index b5506a753..4923a40af 100644 --- a/doc/source/web.rst +++ b/doc/source/web.rst @@ -16,6 +16,16 @@ Configuration The web interface reads the configuration from :file:`$IM_WEB_PATH/config.php`. It has the following variables: +.. confval:: im_use_rest + + Flag to set the usage of the REST API instead of the XML-RPC one. + The default value is `false`. + +.. confval:: im_use_ssl + + Flag to set the usage of the APIs using HTTPS protocol instead of the standard HTTP. + The default value is `false`. + .. confval:: im_host Hostname or IP address of the host with the IM service. @@ -36,6 +46,26 @@ the following variables: Location of the IM service recipes D.B. To use that feature the IM recipes file must accesible to the web server The default value is `""`. +.. confval:: openid_issuer + + OpenID Issuer supported use "" to disable OpenID support. + The default value is `""`. + +.. confval:: openid_name + + OpenID Issuer name. + The default value is `""`. + +.. confval:: CLIENT_ID + + OpenID Client data. + The default value is `""`. + +.. confval:: CLIENT_SECRET + + OpenID Client data. + The default value is `""`. + Docker Image ------------ @@ -47,7 +77,7 @@ This container is prepaired to work linked with the IM service container `grycap * First launch the IM service specifying the name "im": ```sh -sudo docker run -d -p 8899:8899 --name im grycap/im +sudo docker run -d -p 8899:8899 -p 8800:8800 --name im grycap/im ```` * Then launch the im-web container linking to the im: diff --git a/test/unit/test_im_logic.py b/test/unit/test_im_logic.py index 8a76bd87f..386fda59e 100755 --- a/test/unit/test_im_logic.py +++ b/test/unit/test_im_logic.py @@ -258,6 +258,13 @@ def test_inf_creation_errors(self): deploy wn 1 """ + # this case raises an exception + auth0 = Authentication([{'type': 'InfrastructureManager', 'password': 'tests'}]) + with self.assertRaises(Exception) as ex: + IM.CreateInfrastructure(radl, auth0) + + self.assertEqual(str(ex.exception), "No username nor token for the InfrastructureManager.") + # this case raises an exception auth0 = Authentication([{'type': 'InfrastructureManager', 'username': 'test', 'password': 'tests'}]) From 6ce33624109b3151cfc4b3770590d158ee7e46e6 Mon Sep 17 00:00:00 2001 From: micafer Date: Mon, 14 May 2018 15:50:35 +0200 Subject: [PATCH 05/18] Fix #604 --- IM/connectors/Azure.py | 20 ++++++++++++-------- test/unit/connectors/Azure.py | 5 +++++ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/IM/connectors/Azure.py b/IM/connectors/Azure.py index 6c05e3b46..9877c55a1 100644 --- a/IM/connectors/Azure.py +++ b/IM/connectors/Azure.py @@ -66,12 +66,12 @@ class AzureCloudConnector(CloudConnector): } POWER_STATE_MAP = { - 'Deallocated': VirtualMachine.OFF, - 'Deallocating': VirtualMachine.OFF, - 'Running': VirtualMachine.RUNNING, - 'Starting': VirtualMachine.PENDING, - 'Started': VirtualMachine.PENDING, - 'Stopped': VirtualMachine.STOPPED + 'PowerState/deallocated': VirtualMachine.OFF, + 'PowerState/deallocating': VirtualMachine.OFF, + 'PowerState/running': VirtualMachine.RUNNING, + 'PowerState/starting': VirtualMachine.PENDING, + 'PowerState/started': VirtualMachine.PENDING, + 'PowerState/stopped': VirtualMachine.STOPPED } def __init__(self, cloud_info, inf): @@ -645,14 +645,18 @@ def updateVMInfo(self, vm, auth_data): credentials, subscription_id = self.get_credentials(auth_data) compute_client = ComputeManagementClient(credentials, subscription_id) # Get one the virtual machine by name - virtual_machine = compute_client.virtual_machines.get(group_name, vm_name) + virtual_machine = compute_client.virtual_machines.get(group_name, vm_name, expand='instanceView') except Exception as ex: self.log_exception("Error getting the VM info: " + vm.id) return (False, "Error getting the VM info: " + vm.id + ". " + str(ex)) self.log_info("VM info: " + vm.id + " obtained.") vm.state = self.PROVISION_STATE_MAP.get(virtual_machine.provisioning_state, VirtualMachine.UNKNOWN) - self.log_info("The VM state is: " + vm.state) + + if vm.state == VirtualMachine.RUNNING: + vm.state = self.POWER_STATE_MAP.get(virtual_machine.instance_view.statuses[1].code, VirtualMachine.UNKNOWN) + + self.log_debug("The VM state is: " + vm.state) instance_type = self.get_instance_type_by_name(virtual_machine.hardware_profile.vm_size, virtual_machine.location, credentials, subscription_id) diff --git a/test/unit/connectors/Azure.py b/test/unit/connectors/Azure.py index 531bc83fe..260136084 100755 --- a/test/unit/connectors/Azure.py +++ b/test/unit/connectors/Azure.py @@ -252,6 +252,11 @@ def test_30_updateVMInfo(self, credentials, dns_client, compute_client, network_ avm.provisioning_state = "Succeeded" avm.hardware_profile.vm_size = "instance_type1" avm.location = "northeurope" + status1 = MagicMock() + status1.code = "ProvisioningState/succeeded" + status2 = MagicMock() + status2.code = "PowerState/running" + avm.instance_view.statuses = [status1, status2] ni = MagicMock() ni.id = "/subscriptions/subscription-id/resourceGroups/rg0/providers/Microsoft.Network/networkInterfaces/ni-0" avm.network_profile.network_interfaces = [ni] From d1e1da1e68c9d0f6696bb993d63799a81aee7ea1 Mon Sep 17 00:00:00 2001 From: micafer Date: Mon, 14 May 2018 16:42:13 +0200 Subject: [PATCH 06/18] Fix #597 --- IM/VirtualMachine.py | 5 ++++- IM/connectors/OpenStack.py | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/IM/VirtualMachine.py b/IM/VirtualMachine.py index ca6b6684c..f81625f05 100644 --- a/IM/VirtualMachine.py +++ b/IM/VirtualMachine.py @@ -668,7 +668,10 @@ def setIps(self, public_ips, private_ips, remove_old=False): # this VM num_net = self.getNumNetworkIfaces() - vm_system.setValue('net_interface.%s.ip' % num_net, str(private_ip)) + if IPAddress(private_ip).version == 6: + vm_system.setValue('net_interface.%s.ipv6' % num_net, str(private_ip)) + else: + vm_system.setValue('net_interface.%s.ip' % num_net, str(private_ip)) vm_system.setValue('net_interface.%s.connection' % num_net, private_net.id) def get_ssh(self, retry=False): diff --git a/IM/connectors/OpenStack.py b/IM/connectors/OpenStack.py index 9ffc268e5..1480fb21f 100644 --- a/IM/connectors/OpenStack.py +++ b/IM/connectors/OpenStack.py @@ -366,7 +366,10 @@ def setIPsFromInstance(self, vm, node): net_name = system.getValue("net_interface." + str(i) + ".connection") if net_name in map_nets: ip = map_nets[net_name] - system.setValue("net_interface." + str(i) + ".ip", ip) + if IPAddress(ip).version == 6: + system.setValue("net_interface." + str(i) + ".ipv6", ip) + else: + system.setValue("net_interface." + str(i) + ".ip", ip) ips_assigned.append(ip) i += 1 @@ -377,7 +380,10 @@ def setIPsFromInstance(self, vm, node): if net_name != '#UNMAPPED#': if ip not in ips_assigned: num_net = system.getNumNetworkIfaces() - system.setValue('net_interface.' + str(num_net) + '.ip', ip) + if IPAddress(ip).version == 6: + system.setValue('net_interface.' + str(num_net) + '.ipv6', ip) + else: + system.setValue('net_interface.' + str(num_net) + '.ip', ip) system.setValue('net_interface.' + str(num_net) + '.connection', net_name) else: pub_ips = [] From e8cbecc754bf73a20653f990c8ba0c09825cf43f Mon Sep 17 00:00:00 2001 From: micafer Date: Mon, 14 May 2018 16:45:40 +0200 Subject: [PATCH 07/18] Fix #604 --- IM/connectors/Azure.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/IM/connectors/Azure.py b/IM/connectors/Azure.py index 9877c55a1..32a0afb5f 100644 --- a/IM/connectors/Azure.py +++ b/IM/connectors/Azure.py @@ -647,13 +647,21 @@ def updateVMInfo(self, vm, auth_data): # Get one the virtual machine by name virtual_machine = compute_client.virtual_machines.get(group_name, vm_name, expand='instanceView') except Exception as ex: + self.log_warn("The VM does not exists.") + # check if the RG still exists + if self.get_rg(group_name, credentials, subscription_id): + self.log_info("But the RG %s does exits. Retun OFF." % group_name) + vm.state = VirtualMachine.OFF + return (True, vm) + self.log_exception("Error getting the VM info: " + vm.id) return (False, "Error getting the VM info: " + vm.id + ". " + str(ex)) self.log_info("VM info: " + vm.id + " obtained.") vm.state = self.PROVISION_STATE_MAP.get(virtual_machine.provisioning_state, VirtualMachine.UNKNOWN) - if vm.state == VirtualMachine.RUNNING: + if (vm.state == VirtualMachine.RUNNING and virtual_machine.instance_view and + len(virtual_machine.instance_view.statuses) > 1): vm.state = self.POWER_STATE_MAP.get(virtual_machine.instance_view.statuses[1].code, VirtualMachine.UNKNOWN) self.log_debug("The VM state is: " + vm.state) From 451c5a0a59624859215ced149efe0234f6c250ed Mon Sep 17 00:00:00 2001 From: micafer Date: Mon, 14 May 2018 16:55:03 +0200 Subject: [PATCH 08/18] style change --- test/unit/test_im_logic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/test_im_logic.py b/test/unit/test_im_logic.py index 386fda59e..6ef02633b 100755 --- a/test/unit/test_im_logic.py +++ b/test/unit/test_im_logic.py @@ -263,7 +263,7 @@ def test_inf_creation_errors(self): with self.assertRaises(Exception) as ex: IM.CreateInfrastructure(radl, auth0) - self.assertEqual(str(ex.exception), "No username nor token for the InfrastructureManager.") + self.assertEqual(str(ex.exception), "No username nor token for the InfrastructureManager.") # this case raises an exception auth0 = Authentication([{'type': 'InfrastructureManager', 'username': 'test', From 99b1bc1a896e9279d71c67d93ffda73b544ac86e Mon Sep 17 00:00:00 2001 From: micafer Date: Mon, 14 May 2018 16:55:32 +0200 Subject: [PATCH 09/18] Fix #597 on ONE --- IM/connectors/OpenNebula.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/IM/connectors/OpenNebula.py b/IM/connectors/OpenNebula.py index acdabbbd6..94d203c48 100644 --- a/IM/connectors/OpenNebula.py +++ b/IM/connectors/OpenNebula.py @@ -286,7 +286,11 @@ def setIPsFromTemplate(self, vm, template): net = vm.info.get_network_by_id(net_name) provider_id = net.getValue("provider_id") if provider_id == nic.NETWORK: - system.setValue("net_interface." + str(i) + ".ip", str(nic.IP)) + ip = str(nic.IP) + if IPAddress(ip).version == 6: + system.setValue("net_interface." + str(i) + ".ipv6", ip) + else: + system.setValue("net_interface." + str(i) + ".ip", ip) break i += 1 From 357e4c9b38a98db9d4b755c3ff2477a2d77cc6cf Mon Sep 17 00:00:00 2001 From: micafer Date: Tue, 15 May 2018 08:06:37 +0200 Subject: [PATCH 10/18] Set version 1.7.1 --- IM/__init__.py | 2 +- changelog | 6 +++++- docker-devel/Dockerfile | 2 +- docker-py3/Dockerfile | 7 +++++-- docker/Dockerfile | 4 ++-- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/IM/__init__.py b/IM/__init__.py index fae67446d..7ddfe83e0 100644 --- a/IM/__init__.py +++ b/IM/__init__.py @@ -19,5 +19,5 @@ 'InfrastructureInfo', 'InfrastructureManager', 'recipe', 'request', 'REST', 'retry', 'ServiceRequests', 'SSH', 'SSHRetry', 'timedcall', 'UnixHTTPAdapter', 'uriparse', 'VirtualMachine', 'VMRC', 'xmlobject'] -__version__ = '1.7.0' +__version__ = '1.7.1' __author__ = 'Miguel Caballer' diff --git a/changelog b/changelog index 2b87349d9..3a0c18cfa 100644 --- a/changelog +++ b/changelog @@ -404,4 +404,8 @@ IM 1.7.0: * Add export and import functions in REST API * Change in the DB schema in the case of MySQL DB. This command must be made in the current DB: - ALTER TABLE `inf_list` ADD COLUMN `rowid` INT AUTO_INCREMENT UNIQUE FIRST; \ No newline at end of file + ALTER TABLE `inf_list` ADD COLUMN `rowid` INT AUTO_INCREMENT UNIQUE FIRST; + +IM 1.7.1: + * Fix problems with nodes with IPv6 in OpenStack conn. + * Fix Azure conn does not get the correct state (in case of suspended VMs). diff --git a/docker-devel/Dockerfile b/docker-devel/Dockerfile index 623e1d3b5..06c21e72c 100644 --- a/docker-devel/Dockerfile +++ b/docker-devel/Dockerfile @@ -2,7 +2,7 @@ FROM grycap/jenkins:ubuntu16.04-im ARG BRANCH=devel MAINTAINER Miguel Caballer -LABEL version="1.7.0" +LABEL version="1.7.1" LABEL description="Container image to run the IM service. (http://www.grycap.upv.es/im)" EXPOSE 8899 8800 diff --git a/docker-py3/Dockerfile b/docker-py3/Dockerfile index 758576331..7599a6f0c 100644 --- a/docker-py3/Dockerfile +++ b/docker-py3/Dockerfile @@ -1,7 +1,7 @@ # Dockerfile to create a container with the IM service FROM ubuntu:16.04 LABEL maintainer="Miguel Caballer " -LABEL version="1.6.4" +LABEL version="1.7.1" LABEL description="Container image to run the IM service. (http://www.grycap.upv.es/im)" EXPOSE 8899 8800 @@ -16,11 +16,14 @@ RUN pip3 install msrest msrestazure azure-common azure-mgmt-storage azure-mgmt-c # Install IM RUN apt-get update && apt-get install --no-install-recommends -y gcc libssl-dev libffi-dev libsqlite3-dev && \ - pip3 install IM==1.6.4 && \ + pip3 install IM==1.6.1 && \ apt-get remove -y gcc libssl-dev libffi-dev libsqlite3-dev python-dev python-pip && \ apt-get autoremove -y && \ rm -rf /var/lib/apt/lists/* +# Force requests to be version 2.11.1 to avoid SSL ca errors with proxy files +RUN pip3 install requests==2.11.1 + # Copy a ansible.cfg with correct minimum values COPY ansible.cfg /etc/ansible/ansible.cfg diff --git a/docker/Dockerfile b/docker/Dockerfile index 16515c4aa..e8c68dd8b 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,7 +1,7 @@ # Dockerfile to create a container with the IM service FROM ubuntu:18.04 LABEL maintainer="Miguel Caballer " -LABEL version="1.7.0" +LABEL version="1.7.1" LABEL description="Container image to run the IM service. (http://www.grycap.upv.es/im)" EXPOSE 8899 8800 @@ -18,7 +18,7 @@ RUN pip install msrest msrestazure azure-common azure-mgmt-storage azure-mgmt-co RUN apt-get update && apt-get install --no-install-recommends -y gcc libmysqld-dev libssl-dev libffi-dev libsqlite3-dev libmysqlclient20 && \ pip install pycrypto && \ pip install MySQL-python && \ - pip install IM==1.7.0 && \ + pip install IM==1.7.1 && \ apt-get purge -y gcc libmysqld-dev libssl-dev libffi-dev libsqlite3-dev python-dev python-pip && \ apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* && rm -rf ~/.cache/ From d30aaaa31b8a637ff0f2c63ae6d896d805f6dde2 Mon Sep 17 00:00:00 2001 From: micafer Date: Tue, 15 May 2018 08:06:54 +0200 Subject: [PATCH 11/18] Minor changes --- IM/connectors/EC2.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/IM/connectors/EC2.py b/IM/connectors/EC2.py index 5059c68e3..2f3e3d09e 100644 --- a/IM/connectors/EC2.py +++ b/IM/connectors/EC2.py @@ -1009,10 +1009,8 @@ def setIPsFromInstance(self, vm, instance): # It will be used if it is different to the public IP of the # instance if str(address.public_ip) != instance.ip_address: - vm_system.setValue( - 'net_interface.' + str(num_nets) + '.ip', str(instance.ip_address)) - vm_system.setValue( - 'net_interface.' + str(num_nets) + '.connection', public_net.id) + vm_system.setValue('net_interface.' + str(num_nets) + '.ip', str(instance.ip_address)) + vm_system.setValue('net_interface.' + str(num_nets) + '.connection', public_net.id) num_pub_nets += 1 num_nets += 1 @@ -1020,8 +1018,7 @@ def setIPsFromInstance(self, vm, instance): n = 0 requested_ips = [] while vm.getRequestedSystem().getValue("net_interface." + str(n) + ".connection"): - net_conn = vm.getRequestedSystem().getValue( - 'net_interface.' + str(n) + '.connection') + net_conn = vm.getRequestedSystem().getValue('net_interface.' + str(n) + '.connection') if vm.info.get_network_by_id(net_conn).isPublic(): fixed_ip = vm.getRequestedSystem().getValue("net_interface." + str(n) + ".ip") requested_ips.append(fixed_ip) From 380b52117aa835681bca5df3a859de4063e3a2b7 Mon Sep 17 00:00:00 2001 From: micafer Date: Tue, 15 May 2018 08:51:39 +0200 Subject: [PATCH 12/18] add -o StrictHostKeyChecking=no option --- README.md | 9 ++------- contextualization/conf-ansible.yml | 4 ++-- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 0d649e8b3..c4bec76bb 100644 --- a/README.md +++ b/README.md @@ -54,11 +54,6 @@ transport = smart host_key_checking = False nocolor = 1 -# For old versions 1.X -sudo_user = root -sudo_exe = sudo - -# For new versions 2.X become_user = root become_method = sudo @@ -69,9 +64,9 @@ record_host_keys=False [ssh_connection] # Only in systems with OpenSSH support to ControlPersist -ssh_args = -o ControlMaster=auto -o ControlPersist=900s +ssh_args = -o ControlMaster=auto -o ControlPersist=900s -o StrictHostKeyChecking=no # In systems with older versions of OpenSSH (RHEL 6, CentOS 6, SLES 10 or SLES 11) -#ssh_args = +#ssh_args = -o StrictHostKeyChecking=no pipelining = True ``` diff --git a/contextualization/conf-ansible.yml b/contextualization/conf-ansible.yml index 21d65f0c4..ab029b5f2 100644 --- a/contextualization/conf-ansible.yml +++ b/contextualization/conf-ansible.yml @@ -157,11 +157,11 @@ when: (ansible_os_family == "RedHat" and ansible_distribution_major_version|int < 6) or (ansible_os_family == "Suse" and ansible_distribution_major_version|int < 10) - name: Change ssh_args to set ControlPersist to 15 min in ansible.cfg - ini_file: dest=/etc/ansible/ansible.cfg section=ssh_connection option=ssh_args value="-o ControlMaster=auto -o ControlPersist=900s" + ini_file: dest=/etc/ansible/ansible.cfg section=ssh_connection option=ssh_args value="-o ControlMaster=auto -o ControlPersist=900s -o StrictHostKeyChecking=no" when: ansible_os_family == "Debian" or (ansible_os_family == "RedHat" and ansible_distribution_major_version|int >= 7) or (ansible_os_family == "Suse" and ansible_distribution_major_version|int >= 12) - name: Change ssh_args to remove ControlPersist in REL 6 and older in ansible.cfg - ini_file: dest=/etc/ansible/ansible.cfg section=ssh_connection option=ssh_args value="" + ini_file: dest=/etc/ansible/ansible.cfg section=ssh_connection option=ssh_args value="-o StrictHostKeyChecking=no" when: (ansible_os_family == "RedHat" and ansible_distribution_major_version|int < 7) or (ansible_os_family == "Suse" and ansible_distribution_major_version|int < 12) - name: Activate SSH pipelining in ansible.cfg From 5bbdd59c89e40942386575b9ffb4ab2d4b958743 Mon Sep 17 00:00:00 2001 From: micafer Date: Tue, 15 May 2018 10:17:26 +0200 Subject: [PATCH 13/18] Minor change --- IM/connectors/Azure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IM/connectors/Azure.py b/IM/connectors/Azure.py index 32a0afb5f..4bf007f1e 100644 --- a/IM/connectors/Azure.py +++ b/IM/connectors/Azure.py @@ -650,7 +650,7 @@ def updateVMInfo(self, vm, auth_data): self.log_warn("The VM does not exists.") # check if the RG still exists if self.get_rg(group_name, credentials, subscription_id): - self.log_info("But the RG %s does exits. Retun OFF." % group_name) + self.log_info("But the RG %s does exits. Return OFF." % group_name) vm.state = VirtualMachine.OFF return (True, vm) From 6238bbe1e3dc2d258b500e1dfdf97ee5d667530a Mon Sep 17 00:00:00 2001 From: micafer Date: Tue, 15 May 2018 12:31:12 +0200 Subject: [PATCH 14/18] Minor changes --- README.md | 4 ++-- contextualization/conf-ansible.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c4bec76bb..bb5e173f9 100644 --- a/README.md +++ b/README.md @@ -64,9 +64,9 @@ record_host_keys=False [ssh_connection] # Only in systems with OpenSSH support to ControlPersist -ssh_args = -o ControlMaster=auto -o ControlPersist=900s -o StrictHostKeyChecking=no +ssh_args = -o ControlMaster=auto -o ControlPersist=900s -o UserKnownHostsFile=/dev/null # In systems with older versions of OpenSSH (RHEL 6, CentOS 6, SLES 10 or SLES 11) -#ssh_args = -o StrictHostKeyChecking=no +#ssh_args = -o UserKnownHostsFile=/dev/null pipelining = True ``` diff --git a/contextualization/conf-ansible.yml b/contextualization/conf-ansible.yml index ab029b5f2..88babdb30 100644 --- a/contextualization/conf-ansible.yml +++ b/contextualization/conf-ansible.yml @@ -157,11 +157,11 @@ when: (ansible_os_family == "RedHat" and ansible_distribution_major_version|int < 6) or (ansible_os_family == "Suse" and ansible_distribution_major_version|int < 10) - name: Change ssh_args to set ControlPersist to 15 min in ansible.cfg - ini_file: dest=/etc/ansible/ansible.cfg section=ssh_connection option=ssh_args value="-o ControlMaster=auto -o ControlPersist=900s -o StrictHostKeyChecking=no" + ini_file: dest=/etc/ansible/ansible.cfg section=ssh_connection option=ssh_args value="-o ControlMaster=auto -o ControlPersist=900s -o UserKnownHostsFile=/dev/null" when: ansible_os_family == "Debian" or (ansible_os_family == "RedHat" and ansible_distribution_major_version|int >= 7) or (ansible_os_family == "Suse" and ansible_distribution_major_version|int >= 12) - name: Change ssh_args to remove ControlPersist in REL 6 and older in ansible.cfg - ini_file: dest=/etc/ansible/ansible.cfg section=ssh_connection option=ssh_args value="-o StrictHostKeyChecking=no" + ini_file: dest=/etc/ansible/ansible.cfg section=ssh_connection option=ssh_args value="-o UserKnownHostsFile=/dev/null" when: (ansible_os_family == "RedHat" and ansible_distribution_major_version|int < 7) or (ansible_os_family == "Suse" and ansible_distribution_major_version|int < 12) - name: Activate SSH pipelining in ansible.cfg From f4ce85f26e1b3a0d3463bfb17347b84295968b1f Mon Sep 17 00:00:00 2001 From: micafer Date: Tue, 15 May 2018 15:20:54 +0200 Subject: [PATCH 15/18] Fix #607 --- IM/connectors/OpenStack.py | 31 +++++++++++++++++++++++++++++-- test/unit/connectors/OpenStack.py | 4 ++-- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/IM/connectors/OpenStack.py b/IM/connectors/OpenStack.py index 1480fb21f..5517d3781 100644 --- a/IM/connectors/OpenStack.py +++ b/IM/connectors/OpenStack.py @@ -289,26 +289,41 @@ def map_radl_ost_networks(self, radl_nets, ost_nets): if net_name: for radl_net in radl_nets: net_provider_id = radl_net.getValue('provider_id') + if net_provider_id: + parts = net_provider_id.split(".") + if len(parts) > 1: + net_provider_id = parts[0] if net_name == net_provider_id: - res[radl_net.id] = ip - break + if radl_net.isPublic() == is_public: + res[radl_net.id] = ip + break + else: + # the ip not matches the is_public value + res["#UNMAPPED#"].append(ip) else: if radl_net.id not in res: if radl_net.isPublic() == is_public: res[radl_net.id] = ip radl_net.setValue('provider_id', net_name) + if ip in res["#UNMAPPED#"]: + res["#UNMAPPED#"].remove(ip) break else: # the ip not matches the is_public value res["#UNMAPPED#"].append(ip) else: # It seems to be a floating IP + added = False for radl_net in radl_nets: if radl_net.id not in res and radl_net.isPublic() == is_public: res[radl_net.id] = ip + added = True break + if not added: + res["#UNMAPPED#"].append(ip) + return res def get_node_floating_ips(self, node): @@ -451,6 +466,10 @@ def get_networks(self, driver, radl): else: # First check if the user has specified a provider ID if net_provider_id: + parts = net_provider_id.split(".") + if len(parts) > 1: + net_provider_id = parts[0] + for net in ost_nets: if net.name == net_provider_id: if net.name not in used_nets: @@ -630,6 +649,14 @@ def manage_elastic_ips(self, vm, node, public_ips): if net.isPublic(): fixed_ip = vm.getRequestedSystem().getValue("net_interface." + str(n) + ".ip") pool_name = net.getValue("pool_name") + + if not pool_name: + net_provider_id = net.getValue("provider_id") + if net_provider_id: + parts = net_provider_id.split(".") + if len(parts) > 1: + pool_name = parts[1] + requested_ips.append((fixed_ip, pool_name)) n += 1 diff --git a/test/unit/connectors/OpenStack.py b/test/unit/connectors/OpenStack.py index 277b529b4..21c92c77e 100755 --- a/test/unit/connectors/OpenStack.py +++ b/test/unit/connectors/OpenStack.py @@ -206,7 +206,7 @@ def test_20_launch(self, save_data, get_driver): @patch('libcloud.compute.drivers.openstack.OpenStackNodeDriver') def test_30_updateVMInfo(self, get_driver): radl_data = """ - network net (outbound = 'yes') + network net (outbound = 'yes' and provider_id = 'os-lan.pool1') system test ( cpu.arch='x86_64' and cpu.count=1 and @@ -214,7 +214,7 @@ def test_30_updateVMInfo(self, get_driver): net_interface.0.connection = 'net' and net_interface.0.dns_name = 'test' and disk.0.os.name = 'linux' and - disk.0.image.url = 'one://server.com/1' and + disk.0.image.url = 'ost://server.com/ami-id' and disk.0.os.credentials.username = 'user' and disk.0.os.credentials.password = 'pass' )""" From 8a955e7506a8f4fc7010c44591ee7dadb8d43500 Mon Sep 17 00:00:00 2001 From: micafer Date: Tue, 15 May 2018 15:21:18 +0200 Subject: [PATCH 16/18] Style change --- scripts/db_1_5_0_to_1_7_0.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/db_1_5_0_to_1_7_0.py b/scripts/db_1_5_0_to_1_7_0.py index b6176fa5c..57188bacf 100644 --- a/scripts/db_1_5_0_to_1_7_0.py +++ b/scripts/db_1_5_0_to_1_7_0.py @@ -43,4 +43,4 @@ sys.stderr.write("Error connecting with DB: %s\n" % Config.DATA_DB) sys.exit(-1) - sys.exit(0) \ No newline at end of file + sys.exit(0) From aed90f61f520eee820d3bca27e645b7c49c44347 Mon Sep 17 00:00:00 2001 From: micafer Date: Wed, 16 May 2018 08:47:25 +0200 Subject: [PATCH 17/18] Update changelog --- changelog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/changelog b/changelog index 3a0c18cfa..a9aa832f0 100644 --- a/changelog +++ b/changelog @@ -409,3 +409,6 @@ IM 1.7.0: IM 1.7.1: * Fix problems with nodes with IPv6 in OpenStack conn. * Fix Azure conn does not get the correct state (in case of suspended VMs). + * Enable to specify pool_name in the network provider_ip in OpenStack conn. + + From dc6aa93ea06d430cfa0358866755b380b56cdb78 Mon Sep 17 00:00:00 2001 From: micafer Date: Wed, 16 May 2018 10:13:03 +0200 Subject: [PATCH 18/18] Style changes --- IM/config.py | 2 ++ IM/db.py | 1 + IM/request.py | 1 + contextualization/ctxt_agent.py | 1 + contextualization/ctxt_agent_dist.py | 1 + im_service.py | 1 + scripts/db_1_4_to_1_5.py | 1 + scripts/delete_old_infs.py | 1 + test/functional/test_im.py | 1 + test/integration/QuickTestIM.py | 1 + test/integration/TestIM.py | 1 + test/integration/TestREST.py | 1 + test/integration/TestREST_JSON.py | 1 + test/loadtest/LoadTest.py | 1 + test/loadtest/LoadTestR.py | 1 + test/loadtest/LoadTestREST.py | 1 + test/loadtest/LoadTestRESTR.py | 1 + test/unit/REST.py | 1 + test/unit/ServiceRequests.py | 1 + test/unit/Tosca.py | 1 + test/unit/VMRC.py | 1 + test/unit/connectors/GCE.py | 1 + test/unit/connectors/OpenNebula.py | 1 + test/unit/db.py | 1 + test/unit/onetts.py | 1 + test/unit/openid.py | 1 + test/unit/recipe.py | 1 + test/unit/test_ansible.py | 1 + test/unit/test_ctxt_agent.py | 1 + test/unit/test_ctxt_agent_dist.py | 1 + test/unit/test_im_logic.py | 1 + test/unit/timedcall.py | 1 + test/unit/tts.py | 2 ++ test/unit/xmlobject.py | 1 + 34 files changed, 36 insertions(+) diff --git a/IM/config.py b/IM/config.py index 78654caf0..d47450d00 100644 --- a/IM/config.py +++ b/IM/config.py @@ -103,6 +103,7 @@ class Config: VM_NUM_USE_CTXT_DIST = 30 DELAY_BETWEEN_VM_RETRIES = 5 + config = ConfigParser() config.read([Config.IM_PATH + '/../im.cfg', Config.IM_PATH + '/../etc/im.cfg', '/etc/im/im.cfg']) @@ -128,6 +129,7 @@ class ConfigOpenNebula: IMAGE_UNAME = '' TTS_URL = 'https://localhost:8443' + if config.has_section("OpenNebula"): parse_options(config, 'OpenNebula', ConfigOpenNebula) diff --git a/IM/db.py b/IM/db.py index ac98b3142..dcb8a0113 100644 --- a/IM/db.py +++ b/IM/db.py @@ -227,6 +227,7 @@ def table_exists(self, table_name): else: return True + try: class IntegrityError(sqlite.IntegrityError): """ Class to return IntegrityError independently of the DB used""" diff --git a/IM/request.py b/IM/request.py index f6421b243..7bf4a507b 100644 --- a/IM/request.py +++ b/IM/request.py @@ -280,6 +280,7 @@ def serve_forever_in_thread(self): self.__thread.daemon = True self.__thread.start() + if Config.XMLRCP_SSL: class AsyncSSLXMLRPCServer(ThreadingMixIn, SSLSimpleXMLRPCServer): diff --git a/contextualization/ctxt_agent.py b/contextualization/ctxt_agent.py index 89de58edf..a8877d372 100644 --- a/contextualization/ctxt_agent.py +++ b/contextualization/ctxt_agent.py @@ -630,6 +630,7 @@ def run(general_conf_file, vm_conf_file): return res_data['OK'] + if __name__ == "__main__": parser = argparse.ArgumentParser(description='Contextualization Agent.') parser.add_argument('general', type=str, nargs=1) diff --git a/contextualization/ctxt_agent_dist.py b/contextualization/ctxt_agent_dist.py index b5635ea72..4ff3fe390 100755 --- a/contextualization/ctxt_agent_dist.py +++ b/contextualization/ctxt_agent_dist.py @@ -960,6 +960,7 @@ def run(general_conf_file, vm_conf_file, local): return res_data['OK'] + if __name__ == "__main__": parser = argparse.ArgumentParser(description='Contextualization Agent.') parser.add_argument('general', type=str, nargs=1) diff --git a/im_service.py b/im_service.py index c0ed75964..a64566e60 100755 --- a/im_service.py +++ b/im_service.py @@ -373,6 +373,7 @@ def signal_int_handler(signal, frame): """ im_stop() + if __name__ == "__main__": parser = argparse.ArgumentParser(description='IM service') parser.add_argument('--version', help='Show IM service version.', dest="version", diff --git a/scripts/db_1_4_to_1_5.py b/scripts/db_1_4_to_1_5.py index 5b2699486..e83588266 100644 --- a/scripts/db_1_4_to_1_5.py +++ b/scripts/db_1_4_to_1_5.py @@ -105,6 +105,7 @@ def complete_data(): vm.cloud_connector = None vm.inf = None + if __name__ == "__main__": if not Config.DATA_DB: sys.stderr.write("No DATA_DB defined in the im.cfg file!!") diff --git a/scripts/delete_old_infs.py b/scripts/delete_old_infs.py index 16e77d25b..268e1238f 100644 --- a/scripts/delete_old_infs.py +++ b/scripts/delete_old_infs.py @@ -36,6 +36,7 @@ def delete_data_from_db(db_url, date): sys.stderr.write("ERROR connecting with the database!.") sys.exit(-1) + if __name__ == "__main__": if not Config.DATA_DB: sys.stderr.write("No DATA_DB defined in the im.cfg file!!\n") diff --git a/test/functional/test_im.py b/test/functional/test_im.py index 4d35c32ec..11ee3ab34 100755 --- a/test/functional/test_im.py +++ b/test/functional/test_im.py @@ -182,5 +182,6 @@ def test_inf_lifecycle(self): IM.DestroyInfrastructure(infId, auth0) + if __name__ == "__main__": unittest.main() diff --git a/test/integration/QuickTestIM.py b/test/integration/QuickTestIM.py index 3c39df082..cb97e4049 100755 --- a/test/integration/QuickTestIM.py +++ b/test/integration/QuickTestIM.py @@ -541,5 +541,6 @@ def test_75_destroy(self): self.assertTrue( success, msg="ERROR calling DestroyInfrastructure: " + str(res)) + if __name__ == '__main__': unittest.main() diff --git a/test/integration/TestIM.py b/test/integration/TestIM.py index 4ab98780f..e30e962b7 100755 --- a/test/integration/TestIM.py +++ b/test/integration/TestIM.py @@ -685,5 +685,6 @@ def test_95_destroy(self): self.assertTrue( success, msg="ERROR calling DestroyInfrastructure: " + str(res)) + if __name__ == '__main__': unittest.main() diff --git a/test/integration/TestREST.py b/test/integration/TestREST.py index 05b8885b0..d16eb4747 100755 --- a/test/integration/TestREST.py +++ b/test/integration/TestREST.py @@ -477,5 +477,6 @@ def test_98_destroy(self): self.assertEqual(resp.status_code, 200, msg="ERROR destroying the infrastructure:" + resp.text) + if __name__ == '__main__': unittest.main() diff --git a/test/integration/TestREST_JSON.py b/test/integration/TestREST_JSON.py index e7cd9c7c4..f6bb54494 100755 --- a/test/integration/TestREST_JSON.py +++ b/test/integration/TestREST_JSON.py @@ -201,5 +201,6 @@ def test_95_destroy(self): self.assertEqual(resp.status_code, 200, msg="ERROR destroying the infrastructure:" + resp.text) + if __name__ == '__main__': unittest.main() diff --git a/test/loadtest/LoadTest.py b/test/loadtest/LoadTest.py index 129debdf3..684401f13 100755 --- a/test/loadtest/LoadTest.py +++ b/test/loadtest/LoadTest.py @@ -371,6 +371,7 @@ def test(num_client): now = datetime.datetime.now() print(now, ": End client num: %d" % num_client) + if __name__ == '__main__': MAX_THREADS = 1 MAX_CLIENTS = 1 diff --git a/test/loadtest/LoadTestR.py b/test/loadtest/LoadTestR.py index 00025968c..5567ccd89 100755 --- a/test/loadtest/LoadTestR.py +++ b/test/loadtest/LoadTestR.py @@ -118,6 +118,7 @@ def test(num_client): now = datetime.datetime.now() print(now, ": End client num: %d" % num_client) + if __name__ == '__main__': MAX_THREADS = 1 MAX_CLIENTS = 1 diff --git a/test/loadtest/LoadTestREST.py b/test/loadtest/LoadTestREST.py index d7da5e14e..ba105ea92 100755 --- a/test/loadtest/LoadTestREST.py +++ b/test/loadtest/LoadTestREST.py @@ -330,6 +330,7 @@ def test(num_client): now = datetime.datetime.now() print(now, ": End client num: %d" % num_client) + if __name__ == '__main__': MAX_THREADS = 1 MAX_CLIENTS = 1 diff --git a/test/loadtest/LoadTestRESTR.py b/test/loadtest/LoadTestRESTR.py index d668767df..ae2041c5a 100755 --- a/test/loadtest/LoadTestRESTR.py +++ b/test/loadtest/LoadTestRESTR.py @@ -120,6 +120,7 @@ def test(num_client): now = datetime.datetime.now() print(now, ": End client num: %d" % num_client) + if __name__ == '__main__': MAX_THREADS = 1 MAX_CLIENTS = 1 diff --git a/test/unit/REST.py b/test/unit/REST.py index 585b09df6..a3650da77 100755 --- a/test/unit/REST.py +++ b/test/unit/REST.py @@ -779,5 +779,6 @@ def test_format_output(self, get_media_type): info = format_output(["1", "2"]) self.assertEqual(info, 'Unsupported Accept Media Types: application/zip') + if __name__ == "__main__": unittest.main() diff --git a/test/unit/ServiceRequests.py b/test/unit/ServiceRequests.py index a17935161..ce2c6b283 100755 --- a/test/unit/ServiceRequests.py +++ b/test/unit/ServiceRequests.py @@ -172,5 +172,6 @@ def test_version(self, inflist): req = IM.ServiceRequests.IMBaseRequest.create_request(IM.ServiceRequests.IMBaseRequest.GET_VERSION) req._call_function() + if __name__ == '__main__': unittest.main() diff --git a/test/unit/Tosca.py b/test/unit/Tosca.py index b679acc02..89b8546ca 100755 --- a/test/unit/Tosca.py +++ b/test/unit/Tosca.py @@ -92,5 +92,6 @@ def test_tosca_get_outputs(self): 'token': 'pass', 'user': 'ubuntu'}}) + if __name__ == "__main__": unittest.main() diff --git a/test/unit/VMRC.py b/test/unit/VMRC.py index c37770265..219f0bb86 100755 --- a/test/unit/VMRC.py +++ b/test/unit/VMRC.py @@ -98,5 +98,6 @@ def test_list_vm(self, suds_cli): self.assertEqual(res_radl[0].getValue("disk.0.os.credentials.password"), "pass") self.assertEqual(res_radl[0].getValue("disk.0.os.credentials.username"), "user") + if __name__ == '__main__': unittest.main() diff --git a/test/unit/connectors/GCE.py b/test/unit/connectors/GCE.py index 169ba302d..d57f4e8cf 100755 --- a/test/unit/connectors/GCE.py +++ b/test/unit/connectors/GCE.py @@ -406,5 +406,6 @@ def test_70_get_custom_instance(self): instance = gce_cloud.get_instance_type(sizes, radl.systems[0]) self.assertEquals(instance.name, "sizenamne") + if __name__ == '__main__': unittest.main() diff --git a/test/unit/connectors/OpenNebula.py b/test/unit/connectors/OpenNebula.py index dbcb45a4d..9c60c8e1d 100755 --- a/test/unit/connectors/OpenNebula.py +++ b/test/unit/connectors/OpenNebula.py @@ -390,5 +390,6 @@ def test_80_delete_image(self, sleep, getONEVersion, server_proxy): self.assertEqual(one_server.one.image.delete.call_args_list[1], call('user:pass', 1)) self.assertNotIn("ERROR", self.log.getvalue(), msg="ERROR found in log: %s" % self.log.getvalue()) + if __name__ == '__main__': unittest.main() diff --git a/test/unit/db.py b/test/unit/db.py index 29b438c1b..95b411c13 100644 --- a/test/unit/db.py +++ b/test/unit/db.py @@ -62,5 +62,6 @@ def test_db(self, mdb_conn): db.close() + if __name__ == '__main__': unittest.main() diff --git a/test/unit/onetts.py b/test/unit/onetts.py index 7017ead4b..917a50e10 100755 --- a/test/unit/onetts.py +++ b/test/unit/onetts.py @@ -47,5 +47,6 @@ def test_list_providers(self, ttscli): self.assertEqual(username, "username", msg="ERROR: getting one auth from TTS, incorrect username.") self.assertEqual(password, "password", msg="ERROR: getting one auth from TTS, incorrect password.") + if __name__ == '__main__': unittest.main() diff --git a/test/unit/openid.py b/test/unit/openid.py index 70a3061a0..514cf59c1 100755 --- a/test/unit/openid.py +++ b/test/unit/openid.py @@ -74,5 +74,6 @@ def test_get_token_introspection(self, requests): self.assertTrue(success) self.assertEqual(json.loads(token_info), token_info_resp) + if __name__ == '__main__': unittest.main() diff --git a/test/unit/recipe.py b/test/unit/recipe.py index 1957c6afc..ad2f416da 100755 --- a/test/unit/recipe.py +++ b/test/unit/recipe.py @@ -51,5 +51,6 @@ def test_recipe(self, DataBase): self.assertEqual(res[0][1], "mod") self.assertEqual(res[0][2], "gmod") + if __name__ == '__main__': unittest.main() diff --git a/test/unit/test_ansible.py b/test/unit/test_ansible.py index c16125931..f1a575714 100755 --- a/test/unit/test_ansible.py +++ b/test/unit/test_ansible.py @@ -49,5 +49,6 @@ def test_ansible_thread(self): self.assertIn("changed=2", output.getvalue()) print(output.getvalue()) + if __name__ == '__main__': unittest.main() diff --git a/test/unit/test_ctxt_agent.py b/test/unit/test_ctxt_agent.py index 6bcbbf7b0..f3f7e94bc 100755 --- a/test/unit/test_ctxt_agent.py +++ b/test/unit/test_ctxt_agent.py @@ -242,5 +242,6 @@ def test_90_replace_vm_ip(self): data = f.read() self.assertIn(" ansible_host=%s ansible_ssh_host=%s \n" % (vm_data['ctxt_ip'], vm_data['ctxt_ip']), data) + if __name__ == '__main__': unittest.main() diff --git a/test/unit/test_ctxt_agent_dist.py b/test/unit/test_ctxt_agent_dist.py index a8d7103fb..9ed1a9eed 100755 --- a/test/unit/test_ctxt_agent_dist.py +++ b/test/unit/test_ctxt_agent_dist.py @@ -279,5 +279,6 @@ def test_90_replace_vm_ip(self): self.assertIn(" ansible_host=%s \n" % vm_data['ctxt_ip'], data) self.assertIn(" ansible_ssh_host=%s \n" % vm_data['ctxt_ip'], data) + if __name__ == '__main__': unittest.main() diff --git a/test/unit/test_im_logic.py b/test/unit/test_im_logic.py index 6ef02633b..486136bd7 100755 --- a/test/unit/test_im_logic.py +++ b/test/unit/test_im_logic.py @@ -1210,5 +1210,6 @@ def test_create_async(self): IM.DestroyInfrastructure(infId, auth0) + if __name__ == "__main__": unittest.main() diff --git a/test/unit/timedcall.py b/test/unit/timedcall.py index 74abc2413..dae9b27b0 100755 --- a/test/unit/timedcall.py +++ b/test/unit/timedcall.py @@ -57,5 +57,6 @@ def test_timer(self): time.sleep(0.1) self.assertEqual(res, 4) + if __name__ == '__main__': unittest.main() diff --git a/test/unit/tts.py b/test/unit/tts.py index d71efe58e..57ebe19a1 100755 --- a/test/unit/tts.py +++ b/test/unit/tts.py @@ -108,5 +108,7 @@ def test_request_credential(self, requests): self.assertTrue(success, msg="ERROR: getting credentials: %s." % cred) self.assertEqual(cred, expected_cred, msg="ERROR: getting credentials: Unexpected credetials.") + + if __name__ == '__main__': unittest.main() diff --git a/test/unit/xmlobject.py b/test/unit/xmlobject.py index 126173479..8b05716ce 100755 --- a/test/unit/xmlobject.py +++ b/test/unit/xmlobject.py @@ -78,5 +78,6 @@ def test_timed_call(self): '512\n\n') self.assertEqual(res, expected) + if __name__ == '__main__': unittest.main()