Skip to content

Commit

Permalink
Merge branch 'master' into indigo3
Browse files Browse the repository at this point in the history
  • Loading branch information
micafer authored Nov 17, 2017
2 parents 4633907 + 17da0bf commit e0161a8
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 92 deletions.
107 changes: 48 additions & 59 deletions IM/InfrastructureManager.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion IM/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
'InfrastructureInfo', 'InfrastructureManager', 'recipe', 'request', 'REST', 'retry',
'ServiceRequests', 'SSH', 'SSHRetry', 'timedcall', 'UnixHTTPAdapter', 'uriparse',
'VirtualMachine', 'VMRC', 'xmlobject']
__version__ = '1.6.4'
__version__ = '1.6.5'
__author__ = 'Miguel Caballer'
22 changes: 22 additions & 0 deletions IM/ansible_utils/ansible_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ def get_play_prereqs_2(self, options):

variable_manager = VariableManager()
variable_manager.extra_vars = self.extra_vars
variable_manager.options_vars = {'ansible_version': self.version_info(ansible_version)}

# Add this to avoid the Ansible bug: no host vars as host is not in inventory
# In version 2.0.1 it must be fixed
Expand Down Expand Up @@ -186,9 +187,30 @@ def get_play_prereqs_2_4(self, options):
# the code, ensuring a consistent view of global variables
variable_manager = VariableManager(loader=loader, inventory=inventory)
variable_manager.extra_vars = self.extra_vars
variable_manager.options_vars = {'ansible_version': self.version_info(ansible_version)}

return loader, inventory, variable_manager

def version_info(self, ansible_version_string):
''' return full ansible version info '''
ansible_ver = ansible_version_string.split()[0]
ansible_versions = ansible_ver.split('.')
for counter in range(len(ansible_versions)):
if ansible_versions[counter] == "":
ansible_versions[counter] = 0
try:
ansible_versions[counter] = int(ansible_versions[counter])
except:
pass
if len(ansible_versions) < 3:
for counter in range(len(ansible_versions), 3):
ansible_versions.append(0)
return {'string': ansible_version_string.strip(),
'full': ansible_ver,
'major': ansible_versions[0],
'minor': ansible_versions[1],
'revision': ansible_versions[2]}

def launch_playbook_v2(self):
''' run ansible-playbook operations v2.X'''
# create parser for CLI options
Expand Down
18 changes: 8 additions & 10 deletions IM/connectors/Azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,20 +148,18 @@ def get_instance_type(self, system, credentials, subscription_id):
instace_types = list(compute_client.virtual_machine_sizes.list(location))
instace_types.sort(key=lambda x: (x.number_of_cores, x.memory_in_mb, x.resource_disk_size_in_mb))

res = None
default = None
for instace_type in instace_types:
if instace_type.name == self.INSTANCE_TYPE:
default = instace_type
# get the instance type with the lowest Memory
if res is None:
str_compare = "instace_type.number_of_cores " + cpu_op + " cpu "
str_compare += " and instace_type.memory_in_mb " + memory_op + " memory "
str_compare += " and instace_type.resource_disk_size_in_mb " + disk_free_op + " disk_free"

if eval(str_compare):
if not instance_type_name or instace_type.name == instance_type_name:
return instace_type

str_compare = "instace_type.number_of_cores " + cpu_op + " cpu "
str_compare += " and instace_type.memory_in_mb " + memory_op + " memory "
str_compare += " and instace_type.resource_disk_size_in_mb " + disk_free_op + " disk_free"

if eval(str_compare):
if not instance_type_name or instace_type.name == instance_type_name:
return instace_type

return default

Expand Down
2 changes: 1 addition & 1 deletion IM/connectors/OCCI.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def manage_public_ips(self, vm, auth_data):
self.MAX_ADD_IP_COUNT)
else:
self.log_error("Error adding public IP the VM: Max number of retries reached.")
self.error_messages += "Error adding public IP the VM: Max number of retries reached.\n"
# self.error_messages += "Error adding public IP the VM: Max number of retries reached.\n"
# this is a total fail, stop contextualization
vm.configured = False
vm.inf.set_configured(False)
Expand Down
26 changes: 11 additions & 15 deletions IM/connectors/OpenStack.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,22 +175,18 @@ def get_instance_type(self, sizes, radl):
disk_free = radl.getFeature('disk.0.free_size').getValue('G')
disk_free_op = radl.getFeature('memory.size').getLogOperator()

res = None
# get the node size with the lowest price, vcpus and memory
sizes.sort(key=lambda x: (x.price, x.vcpus, x.ram))
for size in sizes:
# get the node size with the lowest price and memory (in the case
# of the price is not set)
if res is None or (size.price <= res.price and size.ram <= res.ram):
str_compare = "size.ram " + memory_op + " memory"
str_compare += " and size.vcpus " + cpu_op + " cpu "
str_compare += " and size.disk " + disk_free_op + " disk_free"
if eval(str_compare):
if not instance_type_name or size.name == instance_type_name:
res = size

if res is None:
self.log_error("No compatible size found")

return res
str_compare = "size.ram " + memory_op + " memory"
str_compare += " and size.vcpus " + cpu_op + " cpu "
str_compare += " and size.disk " + disk_free_op + " disk_free"
if eval(str_compare):
if not instance_type_name or size.name == instance_type_name:
return size

self.log_error("No compatible size found")
return None

def concreteSystem(self, radl_system, auth_data):
image_urls = radl_system.getValue("disk.0.image.url")
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
============================

* Version ![PyPI](https://img.shields.io/pypi/v/im.svg)
* PyPI ![PypI](https://img.shields.io/pypi/dm/IM.svg)
* Build Status [![Build Status](http://jenkins.i3m.upv.es/buildStatus/icon?job=grycap/im-unit)](http://jenkins.i3m.upv.es/job/grycap/job/im-unit/)

IM is a tool that deploys complex and customized virtual infrastructures on IaaS
Expand Down
4 changes: 4 additions & 0 deletions changelog
Original file line number Diff line number Diff line change
Expand Up @@ -358,3 +358,7 @@ IM 1.6.4
* Decrease timeout getting ansible process results.
* Enable to get the initial infrastructure contextualization log.

IM 1.6.5
* Homogenize Inf ID log message
* Fix error cpu.count parameter is ignored in OpenStack conn.
* Fix ansible_version is not available in ctxt process.
5 changes: 3 additions & 2 deletions doc/source/client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,10 @@ The :program:`im_client` is called like this::
Stop (but not remove) the specified virtual machine ``vmId`` associated to the infrastructure with ID
infrastructure with ID ``infId``.

``sshvm infId vmId``
``sshvm infId vmId [show_only]``
Connect with SSH with the specified virtual machine ``vmId`` associated to the infrastructure with ID
infrastructure with ID ``infId``.
infrastructure with ID ``infId``. The ``show_only`` parameter is optional and is a flag to specify if ssh
command will only be shown in stdout instead of executed.

``export infId delete``
Export the data of the infrastructure with ID ``infId``. The ``delete`` parameter is optional
Expand Down
2 changes: 1 addition & 1 deletion docker-devel/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
FROM grycap/jenkins:ubuntu16.04-im
ARG BRANCH=devel
MAINTAINER Miguel Caballer <[email protected]>
LABEL version="1.6.4"
LABEL version="1.6.5"
LABEL description="Container image to run the IM service. (http://www.grycap.upv.es/im)"

EXPOSE 8899 8800
Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Dockerfile to create a container with the IM service
FROM ubuntu:16.04
LABEL maintainer="Miguel Caballer <[email protected]>"
LABEL version="1.6.4"
LABEL version="1.6.5"
LABEL description="Container image to run the IM service. (http://www.grycap.upv.es/im)"
EXPOSE 8899 8800

Expand All @@ -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 && \
pip install MySQL-python && \
pip install xmltodict && \
pip install IM==1.6.4 && \
pip install IM==1.6.5 && \
apt-get remove -y gcc libmysqld-dev libssl-dev libffi-dev libsqlite3-dev python-dev python-pip && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/*
Expand Down
1 change: 1 addition & 0 deletions test/files/test.radl
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ configure test (
- easy_install: name=jmespath
tasks:
- debug: msg="NODENAME = {{NODENAME}}"
- debug: msg="VERSION = {{ansible_version.major}}"
- shell: test -d "/mnt/disk/lost+found"

@end
Expand Down

0 comments on commit e0161a8

Please sign in to comment.