grycap / im-client

IM - Infrastructure Manager client
http://www.grycap.upv.es/im
GNU General Public License v3.0
6 stars 2 forks source link
cloud-computing contextualization virtual-infrastructures

IM - Infrastructure Manager client

PyPI Tests Codacy Badge Codacy Badge License Docs SQAaaS badge

IM is a tool that ease the access and the usability of IaaS clouds by automating the VMI selection, deployment, configuration, software installation, monitoring and update of Virtual Appliances. It supports APIs from a large number of virtual platforms, making user applications cloud-agnostic. In addition it integrates a contextualization system to enable the installation and configuration of all the user required applications providing the user with a fully functional infrastructure.

Usage: im_client.py \
         [-u|--xmlrpc-url <url>] \
         [-r|--restapi-url <url>] \
         [-v|--verify-ssl] \
         [-a|--auth_file <filename>] \
         operation op_parameters

Achievements

SQAaaS badge

This software has received a gold badge according to the Software Quality Baseline criteria defined by the EOSC-Synergy project.

1 INSTALLATION

1.1 REQUISITES

IM is based on python, so Python 3 or higher runtime and standard library must be installed in the system.

It is also required the RADL parser, available in pip as the 'RADL' package. It is also required the Python Requests library available as 'python-requests' in O.S. packages or 'requests' in pip.

1.2 OPTIONAL PACKAGES

In case of using the SSL secured version of the XMLRPC API the SpringPython framework must be installed.

1.3 INSTALLING

1.3.1 FROM PIP

You only have to call the install command of the pip tool with the IM-client package.

pip install IM-client

1.3.2 FROM SOURCE

You only need to install the tar-gziped file to any directoy:

tar xvzf IM-client-X.XX.tar.gz

1.3.3 IM-Client Docker image

The IM Client has an official Docker container image available in Github Container Registry that can be used instead of installing the CLI. You can download it by typing:

sudo docker pull ghcr.io/grycap/im-client

You can exploit all the potential of the IM Client as if you download the CLI and run it on your computer:

docker run --rm -ti -v "$PWD:/tmp/im" ghcr.io/grycap/im-client \
      -r https://server.com:8800 -a /tmp/im/auth.dat list
docker run --rm -ti -v "$PWD:/tmp/im" ghcr.io/grycap/im-client \
      -r https://server.com:8800 -a /tmp/im/auth.dat create /tmp/im/somefile.radl

1.4 CONFIGURATION

To avoid typing the parameters in all the client calls. The user can define a config file "im_client.cfg" in the current directory or a file ".im_client.cfg" in their home directory. In the config file the user can specify the following parameters:

[im_client]
# only set one of the urls
#xmlrpc_url=http://localhost:8899
restapi_url=http://localhost:8800
auth_file=auth.dat
xmlrpc_ssl_ca_certs=/tmp/pki/ca-chain.pem

1.4.1 AUTH FILE

The authorization file stores in plain text the credentials to access the cloud providers, the IM service and the VMRC service. Each line of the file is composed by pairs of key and value separated by semicolon, and refers to a single credential. The key and value should be separated by " = ", that is an equals sign preceded and followed by one white space at least, like this:

id = id_value ; type = zzzz ; username = xxxx ; password = yyyy

Remember that the InfrastructureManager auth line is mandatory, like this:

id = im ; type = InfrastructureManager ; username = xxxx ; password = yyyy

or using an OIDC token:

id = im ; type = InfrastructureManager ; token = xxxxxx

Values can contain "=", and "\n" is replaced by carriage return. The available keys are:

OpenStack addicional fields

OpenStack has a set of addicional fields to access a cloud site:

An example of the auth file:

# OpenNebula site
id = one; type = OpenNebula; host = osenserver:2633; username = user; password = pass
# OpenStack site using standard user, password, tenant format
id = ost; type = OpenStack; host = https://ostserver:5000; username = user; password = pass; tenant = tenant
# OpenStack site using VOMS proxy authentication
id = ostvoms; type = OpenStack; proxy = file(/tmp/proxy.pem); host = https://keystone:5000; tenant = tname
# OpenStack site using OIDC authentication for EGI Sites
id = ost; type = OpenStack; host = https://ostserver:5000; username = egi.eu; tenant = openid; password = command(oidc-token OIDC_ACCOUNT); auth_version = 3.x_oidc_access_token; domain = project_name_or_id
# IM auth data
id = im; type = InfrastructureManager; username = user; password = pass
# VMRC auth data
id = vmrc; type = VMRC; host = http://server:8080/vmrc; username = user; password = pass
# EC2 auth data
id = ec2; type = EC2; username = ACCESS_KEY; password = SECRET_KEY
# Google compute auth data
id = gce; type = GCE; username = username.apps.googleusercontent.com; password = pass; project = projectname
# Docker site with certificates
id = docker; type = Docker; host = http://host:2375; public_key = file(/tmp/cert.pem); private_key = file(/tmp/key.pem)
# Docker site without SSL security
id = docker; type = Docker; host = http://host:2375
# OCCI VOMS site auth data
id = occi; type = OCCI; proxy = file(/tmp/proxy.pem); host = https://server.com:11443
# OCCI OIDC site auth data
id = occi; type = OCCI; token = token; host = https://server.com:11443
# Azure (RM) site auth data
id = azure; type = Azure; subscription_id = subscription-id; username = user@domain.com; password = pass
# Kubernetes site auth data
id = kub; type = Kubernetes; host = http://server:8080; username = user; password = pass
# FogBow auth data
id = fog; type = FogBow; host = http://server:8182; proxy = file(/tmp/proxy.pem)
# Azure Classic auth data
id = azurecla; type = AzureClassic; subscription_id = subscription_id; public_key = file(/tmp/cert.pem); private_key = file(/tmp/key.pem)

1.4 INVOCATION

The programim_client is called like this:

Usage: im_client.py \
         [-u|--xmlrpc-url <url>] \
         [-r|--restapi-url <url>] \
         [-v|--verify-ssl] \
         [-a|--auth_file <filename>] \
         operation op_parameters
         {"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 data from file newAuthFile. The overwrite parameter is optional and is a flag to specify if the authentication data will be overwrited or will be appended. The default value is 0.

1.5 PYTHON CLIENT

IMClient can also be used as a Python library to access IM (since version 1.7.0):

   from imclient import IMClient

   auth = IMClient.read_auth_data("/path/auth.dat")
   client = IMClient.init_client("https://im.egi.eu/im", auth)
   inf_desc = """
      network public (outbound = 'yes')

      system node (
      cpu.count>=2 and
      memory.size>=4g and
      net_interface.0.connection = 'public' and
      disk.0.os.name='linux' and
      disk.0.image.url = 'appdb://SCAI/egi.ubuntu.20.04?vo.access.egi.eu'
      )

      configure wn (
      @begin
      ---
      - tasks:
         - debug: msg="Configured!"
      @end
      )

      deploy node 1
   """
   success, inf_id = client.create(inf_desc)
   ...
   success, err = client.destroy(inf_id)