Skip to content

Commit

Permalink
Merge pull request #1568 from grycap/flask
Browse files Browse the repository at this point in the history
Flask #1569
  • Loading branch information
micafer authored Jun 6, 2024
2 parents ce4d038 + 1ef4b5b commit 646ab8f
Show file tree
Hide file tree
Showing 14 changed files with 659 additions and 1,085 deletions.
539 changes: 188 additions & 351 deletions IM/REST.py

Large diffs are not rendered by default.

19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,23 +161,22 @@ pipelining = True

### 3.2 OPTIONAL PACKAGES

The Bottle framework (<http://bottlepy.org/>) is used for the REST API.
It is typically available as the ``python-bottle`` system package or ``bottle``
pip package.
The Flask framework (<https://flask.palletsprojects.com/>) is used for the REST API.
It is typically available as the ``python3-flask`` and ``python3-werkzeug`` system
packages or ``flask`` and ``werkzeug`` pip packages.

The CherryPy Web framework (<http://www.cherrypy.org/>), is needed for the REST
API. It is typically available as the ``python-cherrypy`` or
``python-cherrypy3`` system package or ``CherryPy`` pip package.
In newer versions (9.0 and later) the functionality has been moved to the
``cheroot`` library (<https://github.com/cherrypy/cheroot>) it can be
installed using pip.
API. It is typically available as the ``python3-cherrypy`` system package or
``CherryPy`` pip package. In newer versions (9.0 and later) the functionality
has been moved to the ``cheroot`` library (<https://github.com/cherrypy/cheroot>).
It is typically available ``python3-cheroot`` system package or ``cheroot`` pip package.

Apache-libcloud (<http://libcloud.apache.org/>) 3.0 or later is used in the
LibCloud, OpenStack and GCE connectors. It is typically available as the
``python-libcloud`` system package or ``apache-libcloud`` pip package.
``python3-libcloud`` system package or ``apache-libcloud`` pip package.

Boto (<http://boto.readthedocs.org>) 2.29.0 or later is used as interface to
Amazon EC2. It is available as package named ``python-boto`` in Debian based
Amazon EC2. It is available as package named ``python3-boto`` in Debian based
distributions or ``boto`` pip package. It can also be downloaded from boto
GitHub repository (<https://github.com/boto/boto>).
Download the file and copy the boto subdirectory into the IM install path.
Expand Down
2 changes: 2 additions & 0 deletions contextualization/conf-ansible.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@
pip:
name: pip>18.0,<21.0
executable: pip3
# in some old distros we need to trust in the pypi to avoid SSL errors
extra_args: --trusted-host files.pythonhosted.org --trusted-host pypi.org --trusted-host pypi.python.org
when: ansible_python_version is version('3.7', '<')

- name: Upgrade pip in py3.7-py3.8
Expand Down
3 changes: 3 additions & 0 deletions doc/source/REST.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ password are not valid, it is returned the HTTP error code 401. In case that Vau
support has been configured (:ref:`vault-creds`) also a Bearer authorization header
is supported, using the same access token to authenticate with the Vault server.

In case of using EGI Check-in authentication, see :ref:`egi-auth` to know how to get
a valid token.

Next tables summaries the resources and the HTTP methods available.

+-------------+------------------------------------+------------------------------------+-------------------------------------------+
Expand Down
21 changes: 18 additions & 3 deletions doc/source/client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,10 @@ So the auth line will be like that::

id = ost; type = OpenStack; host = https://ostserver:5000; username = indigo-dc; tenant = oidc; password = iam_token_value; auth_version = 3.x_oidc_access_token

EGI FedCloud specific parameters
*******************************
.. _egi-auth:

EGI Cloud Compute specific parameters
*************************************

To use the EGI CheckIn to authenticate with a Keystone server properly configured the parameters are the following (see
more info at `EGI Documentation <https://docs.egi.eu/users/cloud-compute/openstack/#authentication>`_):
Expand All @@ -486,9 +488,22 @@ From IM version 1.10.2 the EGI connector is available and you can also use this
id = egi; type = EGI; host = CESGA; vo = vo.access.egi.eu; token = egi_aai_token_value

In this case the information needed to access the OpenStack API of the EGI FedCloud site will be obtained from
`AppDB REST API <https://appdb.egi.eu/rest/1.0>`_). This connector is recommended for non advanced users. If you
`AppDB REST API <https://appdb.egi.eu/rest/1.0>`_. This connector is recommended for non advanced users. If you
can get the data to access the OpenStack API directly it is recommened to use it.

There are several ways to get the EGI AAI token:

* One of them is using the `oidc-agent <https://github.com/indigo-dc/oidc-agent>`_, configuring the
`EGI CheckIn as a provider <https://indigo-dc.gitbook.io/oidc-agent/user/oidc-gen/provider/egi>`_.
Then you can get the token using the command keyworkd in the auth file::

token = command(oidc-token OIDC_ACCOUNT)

* Another way is using the IM-Dashboard (:ref:`use-dashboard`). In the "Advanced" menu, the "Settings"
item enables getting the some configuration settings as the OIDC issuer or the current user's
access token.


Open Telekom Cloud
++++++++++++++++++

Expand Down
13 changes: 7 additions & 6 deletions doc/source/manual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,17 @@ Finally, check the next values in the Ansible configuration file
Optional Packages
-----------------

* `The Bottle framework <http://bottlepy.org/>`_ is used for the REST API.
It is typically available as the 'python-bottle' package.
* `The Flask framework <https://flask.palletsprojects.com/>`_ is used for the REST API.
It is typically available as the 'python3-flask' and 'python3-werkzeug' packages.
* `The CherryPy Web framework <http://www.cherrypy.org/>`_, is needed for the REST API.
It is typically available as the 'python-cherrypy' or 'python-cherrypy3' package.
In newer versions (9.0 and later) the functionality has been moved `the cheroot
library <https://github.com/cherrypy/cheroot>`_ it can be installed using pip.
It is typically available as the 'python3-cherrypy' package. In newer versions (9.0
and later) the functionality has been moved `the cheroot
library <https://github.com/cherrypy/cheroot>`_. It is typically available as the
'python3-cherrot' package.
* `apache-libcloud <http://libcloud.apache.org/>`_ 3.0 or later is used in the
LibCloud, OpenStack, EGI and GCE connectors.
* `boto <http://boto.readthedocs.org>`_ 2.29.0 or later is used as interface to
Amazon EC2. It is available as package named ``python-boto`` in Debian based
Amazon EC2. It is available as package named 'python3-boto' in Debian based
distributions. It can also be downloaded from `boto GitHub repository <https://github.com/boto/boto>`_.
Download the file and copy the boto subdirectory into the IM install path.
* `pyOpenSSL <https://www.pyopenssl.org/>`_ is needed to secure the REST API
Expand Down
8 changes: 4 additions & 4 deletions im_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,14 +367,14 @@ def im_stop():
Function to safely stop the service
"""
try:
# Assure that the IM data are correctly saved
InfrastructureManager.logger.info('Stopping Infrastructure Manager daemon...')
InfrastructureManager.stop()

if Config.ACTIVATE_REST:
# we have to stop the REST server
import IM.REST
IM.REST.stop()

# Assure that the IM data are correctly saved
InfrastructureManager.logger.info('Stopping Infrastructure Manager daemon...')
InfrastructureManager.stop()
except Exception:
InfrastructureManager.logger.exception("Error stopping Infrastructure Manager daemon")

Expand Down
12 changes: 0 additions & 12 deletions packages/generate_deb.sh

This file was deleted.

7 changes: 0 additions & 7 deletions packages/generate_rpm.sh

This file was deleted.

3 changes: 2 additions & 1 deletion requirements-tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ cheroot
boto >= 2.29
apache-libcloud >= 3.3.1
RADL >= 1.3.3
bottle
flask
werkzeug
netaddr
requests >= 2.19
scp
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
description="IM is a tool to manage virtual infrastructures on Cloud deployments",
platforms=["any"],
install_requires=["ansible >=2.4", "paramiko >= 1.14", "PyYAML", suds_pkg, sqlite_pkg, "cheroot",
"boto >= 2.29", "apache-libcloud >= 3.2.0", "RADL >= 1.3.3", "bottle", "netaddr",
"boto >= 2.29", "apache-libcloud >= 3.2.0", "RADL >= 1.3.3", "flask", "netaddr",
"requests >= 2.19", "scp", "tosca-parser", 'defusedxml', 'urllib3>=1.23', 'hvac',
'psutil', 'scar', 'requests-cache >= 1.0.0', 'packaging']
'psutil', 'scar', 'requests-cache >= 1.0.0', 'packaging', 'werkzeug']
)
6 changes: 6 additions & 0 deletions test/unit/AppDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
from urlparse import urlparse
except ImportError:
from urllib.parse import urlparse

import sys

sys.path.append("..")
sys.path.append(".")

from IM.AppDB import AppDB
from mock import patch, MagicMock

Expand Down
Loading

0 comments on commit 646ab8f

Please sign in to comment.