Skip to main content

EC4SAP Python Client

Project description

# EC4SAP Python Client

## Summary

This Python client provides an API to access the EC4SAP environment in an easy way. It is written in Python 2.7 (a port to Python 3 will follow later). The API is based on the Python client provided by Abiquo.

GIT Repositories:


## Get started

1. Install Abiquo-API
2. Clone EC4SAP Repository from Swisscom Gitlab (contact Werder Christian, INI-DOS-DPS-TCL for access)
3. Adapt the config (see below)
4. Write some code, have fun

##### Example 1: get all VMs accessable by the current user and export it as a .csv (no admin rights needed)

from ec4sap import config
from ec4sap.abiquo_api import *
from ec4sap.abiquo_env import *
env = ABIQUO_ENV("int")
vm = ABQ_VM(env).scanAllTenant(keys=config.CSV_FORMAT_VM)
print vm.csvHeader()
for i in range(vm.count()): print vm.csvRow(i)

## Setup an environment
EC4SAP Python Client uses OAuth1 to authenticate your client in Abiquo. Compared to Oauth2, which is used by the portal to authenticate an user, these credentials are stored fix in the user context of of Abiquo and do not expire. To use the client it is neccessary to register the Application in your EC4SAP user context. This will be made via console (see below).

First you need an active OAuth2 Token (Authentication Bearer) - this is the hardest part of the job:
1. Login to your desired EC4SAP Environment (DEV/INT/PRD)
2. Open the Developer Console of your browser (F12 on Chrome)
3. Search for a MOS enabled VM
4. Select the "Virtual Machine Services" in the context menu of the VM
5. Search for the Parameter "Authorization: Bearer ..." in the Request Header of the CMS-Orch API Request (e.q. ".../Folders?...")

With this token you are now able to Register your application in Abiquo and generate a set of OAuth1 tokens:
1. Start the EC4SAP Console (
2. Set the desired Environment (most probably prd and/or int)

>>> set env int

3. Register your application (name e.q. MyApp is free choosable)

>>> reg MyApp 43ee89a5-049d-4f39-b66a-6b72df75a89d
OK: Registration of application 'MyApp' successful

Application Name : MyApp
Application Key : 54b57f1c-5020-4a3f-9ba4-a3fdc3bb6845
Application Secret : xUl5d2byGZitToXQQg9wtvXIAlVAhxjhjaDt8K8p
Acess Token : abfc24f9-4a7c-456c-906c-9c7438dc5eee
Access Secret : oU6vbpHDnItSt1cQJYdeIDTAXanvCEM3EDJ4L5UQUt3BW0ucoOU7Wj/I1rE+fU4TehKrQy35tJEnaeNLLQs9SlwIZBTBeoeT2hzLwcHDkVg=

4. The tokens are now stored locally and your EC4SAP Client is ready. If you need more than one environmemnt you can start over at Nr.1

Project details

Download files

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

Source Distributions

No source distribution files available for this release. See tutorial on generating distribution archives.

Built Distribution

ec4sap_client-0.1.3-py2-none-any.whl (21.1 kB view hashes)

Uploaded py2

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page