cs
A simple, yet powerful CloudStack API client for python and the command-line.
Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.4%) to scientific vocabulary
Keywords
cloudstack
cloudstack-api
cloudstack-cli
Keywords from Contributors
interactive
kafka
serializer
packaging
network-simulation
human
shellcodes
hacking
autograding
observability
Last synced: 11 months ago
·
JSON representation
Repository
A simple, yet powerful CloudStack API client for python and the command-line.
Basic Info
Statistics
- Stars: 87
- Watchers: 20
- Forks: 39
- Open Issues: 0
- Releases: 2
Topics
cloudstack
cloudstack-api
cloudstack-cli
Created about 12 years ago
· Last pushed about 1 year ago
Metadata Files
Readme
License
README.rst
.. image:: https://github.com/ngine-io/cs/actions/workflows/main.yml/badge.svg
:alt: CI
:target: https://github.com/ngine-io/cs/actions/workflows/main.yml
.. image:: https://img.shields.io/pypi/v/cs.svg
:alt: PyPi
:target: https://pypi.org/project/cs/
.. image:: https://img.shields.io/pypi/pyversions/cs.svg
:alt: Python versions
:target: https://pypi.org/project/cs/
.. image:: https://img.shields.io/pypi/dw/cs.svg
:alt: Downloads / Week
:target: https://pypi.org/project/cs/
.. image:: https://img.shields.io/pypi/l/cs.svg
:alt: License
:target: https://pypi.org/project/cs/
CS - Python CloudStack API client
=================================
A simple, yet powerful CloudStack API client for python and the command-line.
* Async support.
* All present and future CloudStack API calls and parameters are supported.
* Syntax highlight in the command-line client if Pygments is installed.
* BSD license.
Installation
------------
::
pip install cs
# with the colored output
pip install cs[highlight]
# with the async support
pip install cs[async]
# with both
pip install cs[async,highlight]
Usage
-----
In Python:
.. code-block:: python
from cs import CloudStack
cs = CloudStack(endpoint='https://cloudstack.example.com/client/api',
key='cloudstack api key',
secret='cloudstack api secret')
vms = cs.listVirtualMachines()
cs.createSecurityGroup(name='web', description='HTTP traffic')
From the command-line, this requires some configuration:
.. code-block:: console
cat $HOME/.cloudstack.ini
.. code-block:: ini
[cloudstack]
endpoint = https://cloudstack.example.com/client/api
key = cloudstack api key
secret = cloudstack api secret
# Optional ca authority certificate
verify = /path/to/certs/ca.crt
# Optional client PEM certificate
cert = /path/to/client.pem
# If you need to pass the certificate and key as separate files
cert_key = /path/to/client_key.pem
Then:
.. code-block:: console
$ cs listVirtualMachines
.. code-block:: json
{
"count": 1,
"virtualmachine": [
{
"account": "...",
...
}
]
}
.. code-block:: console
$ cs authorizeSecurityGroupIngress \
cidrlist="0.0.0.0/0" endport=443 startport=443 \
securitygroupname="blah blah" protocol=tcp
The command-line client polls when async results are returned. To disable
polling, use the ``--async`` flag.
To find the list CloudStack API calls go to
http://cloudstack.apache.org/api.html
Configuration
-------------
Configuration is read from several locations, in the following order:
* The ``CLOUDSTACK_ENDPOINT``, ``CLOUDSTACK_KEY``, ``CLOUDSTACK_SECRET`` and
``CLOUDSTACK_METHOD`` environment variables,
* A ``CLOUDSTACK_CONFIG`` environment variable pointing to an ``.ini`` file,
* A ``CLOUDSTACK_VERIFY`` (optional) environment variable pointing to a CA authority cert file,
* A ``CLOUDSTACK_CERT`` (optional) environment variable pointing to a client PEM cert file,
* A ``CLOUDSTACK_CERT_KEY`` (optional) environment variable pointing to a client PEM certificate key file,
* A ``cloudstack.ini`` file in the current working directory,
* A ``.cloudstack.ini`` file in the home directory.
To use that configuration scheme from your Python code:
.. code-block:: python
from cs import CloudStack, read_config
cs = CloudStack(**read_config())
Note that ``read_config()`` can raise ``SystemExit`` if no configuration is
found.
``CLOUDSTACK_METHOD`` or the ``method`` entry in the configuration file can be
used to change the HTTP verb used to make CloudStack requests. By default,
requests are made with the GET method but CloudStack supports POST requests.
POST can be useful to overcome some length limits in the CloudStack API.
``CLOUDSTACK_TIMEOUT`` or the ``timeout`` entry in the configuration file can
be used to change the HTTP timeout when making CloudStack requests (in
seconds). The default value is 10.
``CLOUDSTACK_RETRY`` or the ``retry`` entry in the configuration file
(integer) can be used to retry ``list`` and ``queryAsync`` requests on
failure. The default value is 0, meaning no retry.
``CLOUDSTACK_JOB_TIMEOUT`` or the `job_timeout`` entry in the configuration file
(float) can be used to set how long an async call is retried assuming ``fetch_result`` is set to true). The default value is ``None``, it waits forever.
``CLOUDSTACK_POLL_INTERVAL`` or the ``poll_interval`` entry in the configuration file (number of seconds, float) can be used to set how frequently polling an async job result is done. The default value is 2.
``CLOUDSTACK_EXPIRATION`` or the ``expiration`` entry in the configuration file
(integer) can be used to set how long a signature is valid. By default, it picks
10 minutes but may be deactivated using any negative value, e.g. -1.
``CLOUDSTACK_DANGEROUS_NO_TLS_VERIFY`` or the ``dangerous_no_tls_verify`` entry
in the configuration file (boolean) can be used to deactivate the TLS verification
made when using the HTTPS protocol.
Multiple credentials can be set in ``.cloudstack.ini``. This allows selecting
the credentials or endpoint to use with a command-line flag.
.. code-block:: ini
[cloudstack]
endpoint = https://some-host/api/v1
key = api key
secret = api secret
[region-example]
endpoint = https://cloudstack.example.com/client/api
key = api key
secret = api secret
Usage::
$ cs listVirtualMachines --region=region-example
Optionally ``CLOUDSTACK_REGION`` can be used to overwrite the default region ``cloudstack``.
For the power users that don't want to put any secrets on disk,
``CLOUDSTACK_OVERRIDES`` let you pick which key will be set from the
environment even if present in the ini file.
Pagination
----------
CloudStack paginates requests. ``cs`` is able to abstract away the pagination
logic to allow fetching large result sets in one go. This is done with the
``fetch_list`` parameter::
$ cs listVirtualMachines fetch_list=true
Or in Python::
cs.listVirtualMachines(fetch_list=True)
Tracing HTTP requests
---------------------
Once in a while, it could be useful to understand, see what HTTP calls are made
under the hood. The ``trace`` flag (or ``CLOUDSTACK_TRACE``) does just that::
$ cs --trace listVirtualMachines
$ cs -t listZones
Async client
------------
``cs`` provides the ``AIOCloudStack`` class for async/await calls in Python
3.5+.
.. code-block:: python
import asyncio
from cs import AIOCloudStack, read_config
cs = AIOCloudStack(**read_config())
async def main():
vms = await cs.listVirtualMachines(fetch_list=True)
print(vms)
asyncio.run(main())
Async deployment of multiple VMs
________________________________
.. code-block:: python
import asyncio
from cs import AIOCloudStack, read_config
cs = AIOCloudStack(**read_config())
machine = {"zoneid": ..., "serviceofferingid": ..., "templateid": ...}
async def main():
tasks = asyncio.gather(*(cs.deployVirtualMachine(name=f"vm-{i}",
**machine,
fetch_result=True)
for i in range(5)))
results = await tasks
# Destroy all of them, but skip waiting on the job results
await asyncio.gather(*(cs.destroyVirtualMachine(id=result['virtualmachine']['id'])
for result in results))
asyncio.run(main())
Release Procedure
-----------------
.. code-block:: shell-session
mktmpenv -p /usr/bin/python3
pip install -U twine wheel build
cd ./cs
rm -rf build dist
python -m build
twine upload dist/*
Links
-----
* CloudStack API: http://cloudstack.apache.org/api.html
Owner
- Name: ngine
- Login: ngine-io
- Kind: organization
- Location: Switzerland
- Website: https://www.ngine.io
- Repositories: 10
- Profile: https://github.com/ngine-io
Engineering Cloud Computing
GitHub Events
Total
- Create event: 14
- Issues event: 1
- Release event: 2
- Delete event: 10
- Issue comment event: 13
- Push event: 34
- Pull request review event: 2
- Pull request event: 22
- Fork event: 2
Last Year
- Create event: 14
- Issues event: 1
- Release event: 2
- Delete event: 10
- Issue comment event: 13
- Push event: 34
- Pull request review event: 2
- Pull request event: 22
- Fork event: 2
Committers
Last synced: about 1 year ago
Top Committers
| Name | Commits | |
|---|---|---|
| Bruno Renié | b****e@g****m | 76 |
| Yoan Blanc | y****c@e****h | 64 |
| René Moser | m****l@r****t | 18 |
| Marc-Aurèle Brothier | m@b****g | 7 |
| Yoan Blanc | y****n@d****h | 7 |
| Rene Moser | r****r@s****h | 6 |
| Vincent Bernat | v****t@b****m | 5 |
| Marc Falzon | f****m | 4 |
| Marc Falzon | m****c@e****m | 3 |
| Anders Åslund | a****d@k****m | 2 |
| Atsushi Sasaki | a****1@g****m | 2 |
| dependabot[bot] | 4****] | 2 |
| Stefano Marengo | s****m | 2 |
| Roman Inflianskas | r****f@p****e | 2 |
| Phsm Qwerty | me@n****t | 2 |
| Bertrand Cachet | b****t@g****m | 1 |
| Chris Glass | c****s@e****h | 1 |
| Anders Åslund | a****d@m****m | 1 |
| Ivan Grishaev | i****n@g****e | 1 |
| Pierre-Emmanuel Jacquier | 1****J | 1 |
| Vojtech Cima | v****a | 1 |
| ujjwalsh | u****p@g****m | 1 |
Committer Domains (Top 20 + Academic)
exoscale.ch: 2
grishaev.me: 1
me.com: 1
nek0.net: 1
pm.me: 1
klarna.com: 1
exoscale.com: 1
bernat.im: 1
swisstxt.ch: 1
dosimple.ch: 1
brothier.org: 1
renemoser.net: 1
Issues and Pull Requests
Last synced: 11 months ago
All Time
- Total issues: 26
- Total pull requests: 118
- Average time to close issues: 10 months
- Average time to close pull requests: 12 days
- Total issue authors: 17
- Total pull request authors: 21
- Average comments per issue: 2.73
- Average comments per pull request: 1.12
- Merged pull requests: 103
- Bot issues: 0
- Bot pull requests: 3
Past Year
- Issues: 1
- Pull requests: 14
- Average time to close issues: 3 months
- Average time to close pull requests: 5 days
- Issue authors: 1
- Pull request authors: 3
- Average comments per issue: 17.0
- Average comments per pull request: 0.07
- Merged pull requests: 14
- Bot issues: 0
- Bot pull requests: 3
Top Authors
Issue Authors
- synergiator (7)
- greut (3)
- rominf (2)
- xuanyuanaosheng (1)
- jeffallen (1)
- l00mi (1)
- xied75 (1)
- PaulAngus (1)
- Kuschranini (1)
- onitake (1)
- sebgoa (1)
- nathanmcgarvey (1)
- igorfernandes (1)
- waza-ari (1)
- MBuffenoir (1)
Pull Request Authors
- greut (46)
- resmo (27)
- brutasse (10)
- marcaurele (10)
- vincentbernat (4)
- rominf (4)
- falzm (4)
- synergiator (3)
- dependabot[bot] (3)
- atsaki (2)
- ste-m (2)
- id (1)
- pierre-emmanuelJ (1)
- phsm (1)
- chrisglass (1)
Top Labels
Issue Labels
enhancement (1)
bug (1)
Pull Request Labels
enhancement (5)
bug (5)
dependencies (3)
github_actions (3)
HOLD :hand: (1)
Packages
- Total packages: 2
-
Total downloads:
- pypi 15,448 last-month
- Total docker downloads: 28
-
Total dependent packages: 4
(may contain duplicates) -
Total dependent repositories: 237
(may contain duplicates) - Total versions: 67
- Total maintainers: 2
pypi.org: cs
A simple yet powerful CloudStack API client for Python and the command-line.
- Homepage: https://github.com/ngine-io/cs
- Documentation: https://cs.readthedocs.io/
- License: BSD
-
Latest release: 3.4.0
published about 1 year ago
Rankings
Dependent repos count: 1.0%
Dependent packages count: 1.9%
Downloads: 2.8%
Docker downloads count: 3.6%
Average: 3.9%
Forks count: 6.6%
Stargazers count: 7.6%
Last synced:
11 months ago
proxy.golang.org: github.com/ngine-io/cs
- Documentation: https://pkg.go.dev/github.com/ngine-io/cs#section-documentation
- License: bsd-3-clause
-
Latest release: v3.4.0+incompatible
published about 1 year ago
Rankings
Dependent packages count: 5.4%
Average: 5.6%
Dependent repos count: 5.8%
Last synced:
11 months ago