Skip to main content

EC4SAP Python Client

Summary

This Python client provides an API to access the Swisscom 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 EC4SAP client with 'pip install ec4sap-client' - for the cli you will need to install globally (sudo)
  2. Adapt the config (see below)
  3. 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

The 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 (console.py)
  2. Set the desired Environment (most probably prd and/or int)
>>> set env int
  1. 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    : 123-456-789
Application Secret : xxxxxxxxxxxxxxxxx
Acess Token        : abc-def-ghi
Access Secret      : xxxxxxxxxxxxxxxxx
  1. 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

Metadata

Release files for ec4sap-client 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for ec4sap-client 0.5.1
File Interpreter ABI Platform
ec4sap_client-0.5.1-py2-none-any.whl Python 2 none any Details

Release files / ec4sap_client-0.5.1-py2-none-any.whl

Download URL ec4sap_client-0.5.1-py2-none-any.whl
Size 28.7 kB
Tags Python 2
SHA-256 checksum
How to use checksums
ebba8b262d9cc787e4e115154d15f58557fedcfc5118b4ecb40f10c9775eeac6
BLAKE2b-256 checksum
How to use checksums
72d3363d28e041c48ae4af0cebaf1484fabf5e8ffb771271829d213bdaa66b14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.16

Release history Release notifications | RSS feed

This release

0.5.1 This release

1 release file

0.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page