Skip to content

Commit

Permalink
Merge branch 'devel' of https://github.com/grycap/im into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
micafer committed Jun 30, 2020
2 parents 33463a6 + af7e26d commit 91b5b24
Show file tree
Hide file tree
Showing 7 changed files with 97 additions and 30 deletions.
2 changes: 1 addition & 1 deletion IM/connectors/EC2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
50 changes: 25 additions & 25 deletions IM/connectors/OCCI.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down Expand Up @@ -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":
Expand Down Expand Up @@ -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()
Expand All @@ -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:])
Expand Down Expand Up @@ -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")
Expand All @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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":
Expand Down
20 changes: 17 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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::

Expand Down Expand Up @@ -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).
Expand Down
2 changes: 1 addition & 1 deletion doc/source/client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions doc/source/gstarted.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
29 changes: 29 additions & 0 deletions requirements-tests.txt
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -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"


0 comments on commit 91b5b24

Please sign in to comment.