Skip to main content

Outscale Gateway python SDK

Project description

Outscale Python SDK

This python SDK helps you to perform actions on Outscale API.

You will need to have an Outscale account, please visit Outscale website.

Installation

You can install the pre-built python package through this command:

$ pip install osc-sdk-python

Building

To build the package yourself:

$ make package

You can then install it with:

$ pip install dist/osc_sdk_python-0.13.0-py3-none-any.whl

Configuration & Credentials

When you use the cli you can choose a profile. Profiles can be set with environment variables or in a file. It checks environment variables before loading the file.

In the file, you can set a default profile, naming default. It will be used if you don't precise profile in command line.

Environment variables

$ export OSC_ACCESS_KEY=<ACCESS_KEY>
$ export OSC_SECRET_KEY=<SECRET_KEY>
$ # optional
$ export OSC_REGION=<REGION> (default: eu-west-2)

Credentials files

$ cat ~/.osc/config.json
{
    "default": {
        "access_key": "<ACCESS_KEY>",
        "secret_key": "<SECRET_KEY>",
        "region": "<REGION>"
    },
    "profile_1": {
        "access_key": "<ACCESS_KEY>",
        "secret_key": "<SECRET_KEY>",
        "region": "<REGION>"
    },
    "profile_2": {
        "access_key": "<ACCESS_KEY>",
        "secret_key": "<SECRET_KEY>",
        "region": "<REGION>"
    }
}

Notes:

  • if ~/.osc/config.json is not found, ~/.oapi_credentials will be used
  • Environment variables have priority over Credentials files.

Example

A simple example which prints all your Virtual Machine and Volume ids.

from osc_sdk_python import Gateway

if __name__ == '__main__':
    gw = Gateway()

    print("your virtual machines:")
    for vm in gw.ReadVms()["Vms"]:
        print(vm["VmId"])

    print("\nyour volumes:")
    for volume in gw.ReadVolumes()["Volumes"]:
        print(volume["VolumeId"])

Usage example, check Outscale API documentation for more details.

from osc_sdk_python import Gateway

if __name__ == '__main__':
    gw = Gateway(**{'profile': 'profile_1'})

    # Calls with api Action as method
    result = gw.ReadSecurityGroups(Filters={'SecurityGroupNames': ['default']})
    result = gw.CreateVms(ImageId='ami-3e158364', VmType='tinav4.c2r4')

    # Or raw calls:
    result = gw.raw('ReadVms')
    result = gw.raw('CreateVms', ImageId='ami-xx', BlockDeviceMappings=[{'/dev/sda1': {'Size': 10}}], SecurityGroupIds=['sg-aaa', 'sg-bbb'], Wrong='wrong')

Known Issues

UTF-8

Some people my encounter some issue with utf-8 which looks like this

Problem reading ()osc_sdk_python/osc-api/outscale.yaml:'ascii' codec can't decode byte 0xe2 in position 14856: ordinal not in range(128)

To avoid this issue, configure you locals as follow:

LC_ALL=en_US.UTF-8

if you don't want your locals to be set system wide you can proceed as follow:

LC_ALL=en_US.UTF-8 pip install osc-sdk-python

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

osc_sdk_python-0.13.0.tar.gz (62.9 kB view details)

Uploaded Source

Built Distribution

osc_sdk_python-0.13.0-py3-none-any.whl (63.6 kB view details)

Uploaded Python 3

File details

Details for the file osc_sdk_python-0.13.0.tar.gz.

File metadata

  • Download URL: osc_sdk_python-0.13.0.tar.gz
  • Upload date:
  • Size: 62.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for osc_sdk_python-0.13.0.tar.gz
Algorithm Hash digest
SHA256 e4204986a1ba2b64d794f9fc41deb6986777d474565c6a505219522f45833b6e
MD5 f45b004c6b261785b599873e90f1a842
BLAKE2b-256 7c61bc1cd9e421b23561b8b6e80f414dcaa73f924f7b9c95b11425d6749798a9

See more details on using hashes here.

File details

Details for the file osc_sdk_python-0.13.0-py3-none-any.whl.

File metadata

  • Download URL: osc_sdk_python-0.13.0-py3-none-any.whl
  • Upload date:
  • Size: 63.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for osc_sdk_python-0.13.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fe146738eabc0960bf170e15f40a12b31de865edb305192f4b9ac26eadd01c3f
MD5 1f6c23ffd97cc8ba1c1717d1c25827d2
BLAKE2b-256 0b0e47480d22513678448b4c1427b85fd616528cb46375efd543e7f17dd739fe

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page