Metadata-Version: 2.1
Name: esi-leap
Version: 0.2.11
Summary: ESI provider
Author: ESI
Author-email: esi@lists.massopen.cloud
License: Apache License, Version 2.0
Classifier: Environment :: Console
Classifier: Environment :: OpenStack
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: AUTHORS
Requires-Dist: pbr!=2.1.0,>=2.0.0
Requires-Dist: alembic>=1.4.2
Requires-Dist: Babel!=2.4.0,>=2.3.4
Requires-Dist: eventlet>=0.33.3
Requires-Dist: iso8601>=0.1.11
Requires-Dist: keystoneauth1>=3.4.0
Requires-Dist: keystonemiddleware>=4.17.0
Requires-Dist: kombu!=4.0.2,>=4.0.0
Requires-Dist: openstacksdk<1.3.0
Requires-Dist: oslo.concurrency>=3.26.0
Requires-Dist: oslo.config>=5.2.0
Requires-Dist: oslo.db>=4.27.0
Requires-Dist: oslo.i18n>=3.15.3
Requires-Dist: oslo.log>=3.36.0
Requires-Dist: oslo.messaging>=5.29.0
Requires-Dist: oslo.middleware>=3.31.0
Requires-Dist: oslo.policy>=1.30.0
Requires-Dist: oslo.serialization!=2.19.1,>=2.18.0
Requires-Dist: oslo.service!=1.28.1,>=1.24.0
Requires-Dist: oslo.upgradecheck>=0.1.0
Requires-Dist: oslo.utils>=3.33.0
Requires-Dist: oslo.versionedobjects>=1.31.2
Requires-Dist: osprofiler>=1.5.0
Requires-Dist: netaddr>=0.7.18
Requires-Dist: python-ironicclient>=2.3.0
Requires-Dist: python-keystoneclient>=3.8.0
Requires-Dist: pecan!=1.0.2,!=1.0.3,!=1.0.4,!=1.2,>=1.0.0
Requires-Dist: sqlalchemy-migrate>=0.11.0
Requires-Dist: requests>=2.18.4
Requires-Dist: Routes>=2.3.1
Requires-Dist: six>=1.10.0
Requires-Dist: SQLAlchemy!=1.1.5,!=1.1.6,!=1.1.7,!=1.1.8,<2.0,>=1.0.10
Requires-Dist: stevedore>=1.20.0
Requires-Dist: WebOb>=1.7.1
Requires-Dist: WSME>=0.8.0
Requires-Dist: importlib-metadata<5.0.0; python_version < "3.8"

# esi-leap

esi-leap is an OpenStack service for leasing baremetal nodes, designed to run
on top of [multi-tenant
Ironic](https://docs.openstack.org/ironic/latest/admin/node-multitenancy.html).
It consists of an API that provides endpoints for leasing operations and a
manager service that updates the status of leases and offers as required. See
the [documentation](https://esi.readthedocs.io/en/latest/index.html) for
more info on ESI.


### Installation

To install as a package:
 - `pip install esi-leap`

To install from source:

```
    $ git clone https://github.com/CCI-MOC/esi-leap
    $ cd esi-leap
    $ sudo python setup.py install
```


### Client

esi-leap has a command line client which can be found here:
https://github.com/CCI-MOC/python-esileapclient


### Create the esi-leap Database

The esi-leap service requires a database to store its information. To set this
up using the MySQL database used by other OpenStack services, run the following
commands, replacing \<PASSWORD\> with a suitable password and \<DATABASE\_IP\>
with the IP address of your MySQL database (if you're not sure, use localhost
or 127.0.0.1).

```
    $ mysql -u root -p
    mysql> CREATE USER 'esi_leap'@'<DATABASE_IP>' IDENTIFIED BY '<PASSWORD>';
    mysql> CREATE USER 'esi_leap'@'%' IDENTIFIED BY '<PASSWORD>';
    mysql> CREATE DATABASE esi_leap CHARACTER SET utf8;
    mysql> GRANT ALL PRIVILEGES ON esi_leap.* TO 'esi_leap'@'<DATABASE_IP>';
    mysql> GRANT ALL PRIVILEGES ON esi_leap.* TO 'esi_leap'@'%';
    mysql> FLUSH PRIVILEGES;
```

If you use this method, the resulting database connection string should be:

```
    mysql+pymysql://esi_leap:PASSWORD@DATABASE_IP/esi_leap
```


### Configuration

Run the following commands to generate the configuration file and copy it to
the right place:

```
    $ tox -egenconfig
    $ sudo mkdir /etc/esi-leap
    $ sudo cp etc/esi-leap/esi-leap.conf.sample /etc/esi-leap/esi-leap.conf
```

Edit `/etc/esi-leap/esi-leap.conf` with the proper values. (see sample config
template below):

```
[DEFAULT]

log_dir=/var/log/esi-leap
transport_url=<transport URL for messaging>

[database]
connection=<db connection string>

# End-user authentication configuration
[keystone_authtoken]
www_authenticate_uri=<public Keystone endpoint>
auth_type=password
auth_url=<keystone auth URL>
username=admin
password=<password>
user_domain_name=Default
project_name=admin
project_domain_name=Default

# esi-leap internal authentication configuration
[keystone]
api_endpoint=<admin Keystone endpoint>
auth_type=password
auth_url=<keystone auth URL>
username=esi-leap
password=<password>
user_domain_name=Default
project_name=service
project_domain_name=Default

[oslo_concurrency]
lock_path=<lock dir>

[oslo_messaging_notifications]
driver=messagingv2
transport_url=<transport URL for messaging>

[ironic]                              # ONLY NECESSARY IF USING IRONIC NODES
auth_type = password
api_endpoint = <ironic API endpoint>
auth_url = <keystone auth URL>
project_name = service
project_domain_name = Default
user_domain_name = Default
username = ironic
password = <ironic password>

[dummy_node]                          # ONLY NECESSARY IF USING DUMMY NODES
dummy_node_dir=/tmp/nodes
```


### Create the OpenStack Service

```
    $ openstack user create --domain default --password-prompt esi-leap
    $ openstack role add --project service --user esi-leap admin
    $ openstack service create --name esi-leap lease
    $ openstack endpoint create esi-leap --region RegionOne public http://<YOUR_IP>:7777
```


### Run the Services

Start by instantiating the database:

```
    $ sudo esi-leap-dbsync create_schema
```

Once that's done, you can run the manager and API services:


```
    $ sudo esi-leap-manager
    $ sudo esi-leap-api
```

### Installation using Containerization

By encapsulating the ESI Leap into a container, all the necessary dependencies, configurations and services are bundled into a single package.

Please make sure to follow the instructions in the [Configuration](#configuration) section to generate the esi-leap.conf file.

Make sure to follow the instructions in the [Create Openstack Service](#create-the-openstack-service) to create the OpenStack service and endpoint. 

After that build the container image using the podman build command, as Containerfile is located in the current directory. The syntax is as follows:

```
    $ podman build -t <image-name> -f Containerfile . 
```

Once the container image is built, you can run it using the podman run command. The syntax is as follows:

```
    $ podman run --name <container-name> -p <host-port>:<container-port> -d -v <path-to-esi-leap.conf-file>:/etc/esi-leap <image-name>
```


### Using Dummy Nodes

If you wish to use dummy nodes instead of Ironic nodes, simply specify the `dummy_node_dir`
as specified above. Once you do so, add dummy nodes as follows:

```
cat <<EOF > /tmp/nodes/1718
{
    "project_owner_id": "project id of dummy node owner",
    "server_config": {
        "new attribute XYZ": "This is just a sample list of free-form attributes used for describing a server.",
        "cpu_type": "Intel Xeon",
        "cores": 16,
        "ram_gb": 512,
        "storage_type": "samsung SSD",
        "storage_size_gb": 204
    }
}
EOF
```

`1718` is the dummy node UUID; replace it with whatever you'd like. When creating an offer
for this dummy node, simply specify `resource_type` as `dummy_node` and `resource_uuid` as
`1718`.

