diff --git a/IM/connectors/EC2.py b/IM/connectors/EC2.py index fe32bea9d..0317635e2 100644 --- a/IM/connectors/EC2.py +++ b/IM/connectors/EC2.py @@ -1580,7 +1580,7 @@ def get_all_instance_types(self, retries=3, delay=5): else: for instance_type in data: price = 50 - if instance_type['pricing']: + if instance_type['pricing'] and 'us-east-1' in instance_type['pricing']: price = float(instance_type['pricing']['us-east-1']['linux']['ondemand']) disks = 0 disk_space = 0 diff --git a/IM/connectors/OCCI.py b/IM/connectors/OCCI.py index 72eb58926..f5438b806 100644 --- a/IM/connectors/OCCI.py +++ b/IM/connectors/OCCI.py @@ -181,12 +181,12 @@ def get_attached_volumes_from_info(occi_res): # kvm_file0";occi.core.target="/storage/0";occi.core.source="/compute/10";occi.storagelink.deviceid="/dev/hda";occi.storagelink.state="active" lines = occi_res.split("\n") res = [] - for l in lines: - if 'Link:' in l and '/storage/' in l: + for line in lines: + if 'Link:' in line and '/storage/' in line: num_link = None num_storage = None device = None - parts = l.split(';') + parts = line.split(';') for part in parts: kv = part.split('=') if kv[0].strip() == "self": @@ -214,11 +214,11 @@ def get_net_info(occi_res): num_interface = None ip_address = None link = None - for l in lines: - if 'Link:' in l and '/network/public' in l: + for line in lines: + if 'Link:' in line and '/network/public' in line: link_to_public = True - if 'Link:' in l and ('/network/' in l or '/networklink/' in l): - parts = l.split(';') + if 'Link:' in line and ('/network/' in line or '/networklink/' in line): + parts = line.split(';') for part in parts: kv = part.split('=') if kv[0].strip() == "occi.networkinterface.address": @@ -286,9 +286,9 @@ def get_property_from_category(occi_res, category, prop_name): Get a property of an OCCI category returned by an OCCI server """ lines = occi_res.split("\n") - for l in lines: - if l.find('Category: ' + category + ';') != -1: - for elem in l.split(';'): + for line in lines: + if line.find('Category: ' + category + ';') != -1: + for elem in line.split(';'): kv = elem.split('=') if len(kv) == 2: key = kv[0].strip() @@ -304,8 +304,8 @@ def get_floating_pool(occi_data): """ lines = occi_data.split("\n") pools = [] - for l in lines: - if 'http://schemas.openstack.org/network/floatingippool#' in l: + for line in lines: + if 'http://schemas.openstack.org/network/floatingippool#' in line: for elem in l.split(';'): if elem.startswith('Category: '): pools.append(elem[10:]) @@ -337,10 +337,10 @@ def get_net_name(self, auth_data, auth_header, is_public): return os.path.basename(lines[0][17:]) # if not, try to find one with a public ip - for l in lines: - if l.startswith("X-OCCI-Location: "): - net_url = l[17:] - net_name = os.path.basename(l[17:]) + for line in lines: + if line.startswith("X-OCCI-Location: "): + net_url = line[17:] + net_name = os.path.basename(line[17:]) resp = self.create_request('GET', net_url, auth_data, headers) if resp.status_code == 200: net_addr = self.get_occi_attribute_value(resp.text, "occi.network.address") @@ -351,9 +351,9 @@ def get_net_name(self, auth_data, auth_header, is_public): return net_name # if not, try to find one with the expected names - for l in lines: - if l.startswith("X-OCCI-Location: "): - net_name = os.path.basename(l[17:]) + for line in lines: + if line.startswith("X-OCCI-Location: "): + net_name = os.path.basename(line[17:]) if is_public: if net_name.startswith(tuple(self.PUBLIC_NET_NAMES)): return net_name @@ -414,9 +414,9 @@ def get_occi_attribute_value(occi_res, attr_name): Get the value of an OCCI attribute returned by an OCCI server """ lines = occi_res.split("\n") - for l in lines: - if l.find('X-OCCI-Attribute: ' + attr_name + '=') != -1: - return l.split('=')[1].strip('"') + for line in lines: + if line.find('X-OCCI-Attribute: ' + attr_name + '=') != -1: + return line.split('=')[1].strip('"') return None def updateVMInfo(self, vm, auth_data): @@ -510,9 +510,9 @@ def get_scheme(self, occi_info, category, ctype): Get the scheme of an OCCI category contacting with the OCCI server """ lines = occi_info.split("\n") - for l in lines: - if l.find('Category: ' + category) != -1 and l.find(ctype) != -1: - parts = l.split(';') + for line in lines: + if line.find('Category: ' + category) != -1 and line.find(ctype) != -1: + parts = line.split(';') for p in parts: kv = p.split("=") if kv[0].strip() == "scheme": diff --git a/README.md b/README.md index 698b1ca63..46f60d3ac 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Miguel Caballer, Ignacio Blanquer, German Molto, and Carlos de Alfonso. "[Dynami The recommended option to use the Infrastructure Manager service is using the available docker image. A Docker image named `grycap/im` has been created to make easier the deployment of an IM service using the -default configuration. Information about this image can be found here: https://registry.hub.docker.com/u/grycap/im/. +default configuration. Information about this image can be found here: https://hub.docker.com/r/grycap/im/. How to launch the IM service using docker:: @@ -63,9 +63,23 @@ The IM service and web interface can be installed on top of [Kubernetes](https:/ How to install the IM chart: +First add the GRyCAP repo: + +```sh +helm repo add grycap https://grycap.github.io/helm-charts/ +``` + +Then install the IM chart (with Helm v2): + +```sh +helm install --namespace=im --name=im grycap/IM +``` + +Then install the IM chart (with Helm v3): + ```sh -$ helm repo add grycap https://grycap.github.io/helm-charts/ -$ helm install --namespace=im --name=im grycap/IM +kubectl create namespace im +helm install --namespace=im im grycap/IM ``` All the information about this chart is available at the [IM chart README](https://github.com/grycap/helm-charts/blob/master/IM/README.md). diff --git a/doc/source/client.rst b/doc/source/client.rst index b57e5b64f..fca142eda 100644 --- a/doc/source/client.rst +++ b/doc/source/client.rst @@ -48,7 +48,7 @@ user can specify the following parameters:: [im_client] # only set one of the urls #xmlrpc_url=http://localhost:8899 - restapi_url==http://localhost:8800 + restapi_url=http://localhost:8800 auth_file=auth.dat xmlrpc_ssl_ca_certs=/tmp/pki/ca-chain.pem diff --git a/doc/source/gstarted.rst b/doc/source/gstarted.rst index cb9eadb56..646236235 100644 --- a/doc/source/gstarted.rst +++ b/doc/source/gstarted.rst @@ -29,6 +29,8 @@ To access the IM service two client tools can be used (apart from the two APIs): $ sudo docker run -d -p 80:80 --name im-web --link im:im grycap/im-web + Then you can access the im-web interface using the following url: `http://localhost/im-web`. + See full manual in IM Web :ref:`use-web`. In this first examples we will use the IM-client tool to create, manage and finally destroy a single VM. diff --git a/requirements-tests.txt b/requirements-tests.txt new file mode 100644 index 000000000..9a18f93be --- /dev/null +++ b/requirements-tests.txt @@ -0,0 +1,29 @@ +ansible >= 2.4 +paramiko >= 1.14 +PyYAML +cheroot +boto >= 2.29 +apache-libcloud >= 2.6.0 +RADL >= 1.1.2 +bottle +netaddr +requests >= 2.19 +scp +tosca-parser +defusedxml +urllib3>=1.23 +pycodestyle +suds-py3 +xmltodict +mysqlclient +pywinrm +pymongo +msrest +msrestazure +azure-common +azure-mgmt-storage +azure-mgmt-compute +azure-mgmt-network +azure-mgmt-resource +azure-mgmt-dns +pyVmomi \ No newline at end of file diff --git a/tox.ini b/tox.ini new file mode 100644 index 000000000..285c7e6f5 --- /dev/null +++ b/tox.ini @@ -0,0 +1,22 @@ +[tox] +envlist = py3,style,coverage +skipsdist = true + +[testenv] +deps = nose + mock + -r{toxinidir}/requirements-tests.txt +basepython = + {py3,style,coverage}: python3 +whitelist_externals = bash +commands = bash -c "nosetests -v test/unit/*.py test/unit/connectors/*.py" + +[testenv:style] +deps = pycodestyle +commands = pycodestyle --max-line-length=120 --ignore=E402,W504,W605 IM --exclude=doc + pycodestyle --max-line-length=120 --ignore=E402,W504,W605 contextualization --exclude=doc + +[testenv:coverage] +commands = bash -c "nosetests -v test/unit/*.py test/unit/connectors/*.py -v --stop --with-xunit --with-coverage --cover-erase --cover-xml --cover-package=IM,contextualization" + +