-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updates to object attributes, addition of functional tests
- Loading branch information
Showing
24 changed files
with
409 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,68 @@ | ||
# esisdk | ||
Unified SDK for ESI | ||
|
||
## Use the SDK in python scripts | ||
### Install ESI SDK: | ||
``` | ||
python setup.py install | ||
``` | ||
|
||
### Create a connection to ESI SDK | ||
|
||
There are several methods to establish a connection using the ESI SDK. Since the ***esi.connection.ESIConnection*** class inherits from ***openstack.connection.Connection***, [methods](https://docs.openstack.org/openstacksdk/latest/user/connection.html) applicable for creating connections in the OpenStack SDK can also be used with the ESI SDK. Below are some common ways to create an ESIConnection: | ||
|
||
**Create a connection using only keyword arguments** | ||
``` | ||
from esi import connection | ||
conn = connection.Connection( | ||
region_name='example-region', | ||
auth={ | ||
'auth_url': 'https://auth.example.com', | ||
'username': 'user', | ||
'password': 'password', | ||
'project_name': 'project_name', | ||
'user_domain_name': 'user_domain_name', | ||
'project_domain_name': 'project_domain_name' | ||
}, | ||
interface='public' | ||
) | ||
``` | ||
**Create a connection from existing CloudRegion** | ||
``` | ||
from esi import connection | ||
import openstack.config | ||
config = openstack.config.get_cloud_region( | ||
cloud='example', | ||
region_name='earth', | ||
) | ||
conn = connection.Connection(config=config) | ||
``` | ||
|
||
### Make API calls | ||
Detailed APIs can be found in the `esi/lease/v1/_proxy.py` file. Below are simple examples demonstrating lease resource CRUD operations. | ||
|
||
**Create a lease** | ||
``` | ||
def lease_create(conn, resource_uuid, project_id, **kwargs): | ||
lease = conn.lease.create_lease(resource_uuid=resource_uuid, | ||
project_id=project_id, | ||
**kwargs) | ||
``` | ||
**List leases** | ||
``` | ||
def lease_list(conn, **kwargs): | ||
leases = conn.lease.leases(**kwargs) | ||
``` | ||
**Update a lease** | ||
``` | ||
def lease_update(conn, lease, **kwargs): | ||
lease_dict = conn.lease.update_lease(lease, **kwargs) | ||
``` | ||
**Delete a lease** | ||
``` | ||
def lease_delete(conn, lease_id): | ||
leases = conn.lease.delete_lease(lease_id) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
### Prerequisites | ||
|
||
These tests are intended to be run against a functioning OpenStack cloud with esi-leap services enabled and running (https://github.com/CCI-MOC/esi-leap). Please set the following environment variables in order to run full tests: | ||
* TestESILEAPLease and TestESILEAPOffer: set `NODE_1_UUID`, `NODE_1_TYPE`, `NODE_2_UUID`, `NODE_2_TYPE` in tox.ini. These nodes should not be associated with any existing leases/offers during testing. | ||
* TestESILEAPEvent: set `LAST_EVENT_ID`, `NODE_1_UUID` and `NODE_1_TYPE` in tox.ini. | ||
* TestESILEAPNode: set `NODE_3_NAME` in tox.ini. This node should be associated with leases/offers. | ||
|
||
The clouds.yaml file should be like this: https://github.com/openstack/openstacksdk/blob/master/doc/source/contributor/clouds.yaml | ||
|
||
### Running the tests | ||
|
||
By default, the functional tests will not run when invoking `tox` with no additional options. To run them, you must specify the 'functional' testenv like this: | ||
|
||
``` | ||
$ tox -e functional | ||
``` | ||
|
||
To run specific tests, | ||
``` | ||
$ tox -e functional -- "test_node_list" | ||
``` | ||
or | ||
``` | ||
$ tox -e functional -- "TestESILEAPOffer" | ||
``` |
Oops, something went wrong.