Skip to content

Commit

Permalink
Merge branch 'devel' of https://github.com/grycap/im-client into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
micafer committed Apr 1, 2022
2 parents 52ec869 + 088ce5e commit 2fd7425
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![PyPI](https://img.shields.io/pypi/v/im-client.svg)](https://pypi.org/project/im-client)
[![Build Status](http://jenkins.i3m.upv.es/buildStatus/icon?job=grycap/im-client-unit-py3)](http://jenkins.i3m.upv.es:8080/job/grycap/job/im-client-unit-py3/)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/c74628a2fc134c2683d3fc57b571ce09)](https://www.codacy.com/app/micafer/im-client?utm_source=github.com&utm_medium=referral&utm_content=grycap/im-client&utm_campaign=Badge_Grade)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/c74628a2fc134c2683d3fc57b571ce09)](https://www.codacy.com/gh/grycap/im-client/dashboard?utm_source=github.com&utm_medium=referral&utm_content=grycap/im-client&utm_campaign=Badge_Grade)
[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/c74628a2fc134c2683d3fc57b571ce09)](https://www.codacy.com/app/micafer/im-client?utm_source=github.com&utm_medium=referral&utm_content=grycap/im-client&utm_campaign=Badge_Coverage)
[![License](https://img.shields.io/badge/license-GPL%20v3.0-brightgreen.svg)](LICENSE)
[![Docs](https://img.shields.io/badge/docs-latest-brightgreen.svg)](https://imdocs.readthedocs.io/en/latest/client.html)
Expand Down Expand Up @@ -340,10 +340,12 @@ im_client.py [-u|--xmlrpc-url <url>] [-r|--restapi-url <url>] [-v|--verify-ssl]
with a "configured" state or 1 otherwise.

``create_wait_outputs <radlfile>``
This operation is a combination of the create, wait and getoutputs functions. First create the infrastructure,
then waits for it to be configured, and finally get the TOSCA outputs. In case of failure in infrastructure
creation none will be returned. In case of error waiting or getting the outputs only the infrastructure ID
will be returned.
This operation is a combination of the create, wait and getoutputs functions. First it creates the
infrastructure using the specified ``inputfile``, then waits for it to be configured, and finally
gets the TOSCA outputs. In case of failure in then infrastructure creation step only the error message
will be returned. The results will be returned to stdout in json format::

{"infid": "ID", "error": "Error message"}

``change_auth <infId> <newAuthFile> [overwrite]``
This operation enables to change the owner of infrastructure with ID ``infId`` using the authentication
Expand Down
2 changes: 1 addition & 1 deletion im_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ def change_auth(self):

if self.options.restapi:
headers = {"Authorization": self.rest_auth_data}
url = "%s/infrastructures/%s/authentication" % (self.options.restapi, inf_id)
url = "%s/infrastructures/%s/authorization" % (self.options.restapi, inf_id)
if overwrite:
url += "?overwrite=1"
resp = requests.request("POST", url, verify=self.options.verify,
Expand Down
1 change: 1 addition & 0 deletions test/files/auth_new.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type = InfrastructureManager; username = user1; password = pass1
18 changes: 18 additions & 0 deletions test/unit/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ def get_response(method, url, verify, cert=None, headers=None, data=None):
resp.status_code = 200
resp.text = ('{ "uri-list": [ { "uri" : "http://localhost/infid/vms/1" }]}')
resp.json.return_value = json.loads(resp.text)
elif url == "/infrastructures/infid/authorization":
resp.status_code = 200
resp.text = ""
else:
resp.status_code = 404
elif method == "DELETE":
Expand Down Expand Up @@ -1191,6 +1194,21 @@ def test_create_wait_outputs(self, requests):
self.assertEqual(output, {"infid": "inf1", "output1": "value1" , "output2": "value2"})
sys.stdout = oldstdout

@patch('requests.request')
def test_change_user(self, requests):
"""
Test create_wait_outputs operation
"""
requests.side_effect = self.get_response
options = MagicMock()
options.auth_file = get_abs_path("../../auth.dat")
options.restapi = "https://localhost:8800"
options.xmlrpc = None
options.quiet = True
parser = MagicMock()

res = main("change_auth", options, ["infid", get_abs_path("../files/auth_new.dat")], parser)
self.assertEquals(res, True)


if __name__ == '__main__':
Expand Down

0 comments on commit 2fd7425

Please sign in to comment.