[Python-modules-commits] [python-cs] 01/03: Import python-cs_0.9.0.orig.tar.gz
Vincent Bernat
bernat at moszumanska.debian.org
Sun Dec 25 09:24:27 UTC 2016
This is an automated email from the git hooks/post-receive script.
bernat pushed a commit to annotated tag debian/0.9.0-1
in repository python-cs.
commit 2af3cd5306fac4acc815c84879240d3a5b669742
Author: Vincent Bernat <bernat at debian.org>
Date: Sat Oct 22 14:50:15 2016 +0200
Import python-cs_0.9.0.orig.tar.gz
---
README.rst | 6 ++++++
cs.py | 12 ++++++++++--
setup.py | 2 +-
3 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/README.rst b/README.rst
index 726a63f..9974473 100644
--- a/README.rst
+++ b/README.rst
@@ -41,6 +41,10 @@ From the command-line, this requires some configuration::
endpoint = https://api.exoscale.ch/compute
key = cloudstack api key
secret = cloudstack api secret
+ # Optional ca authority certificate
+ verify = /path/to/certs/exoscale_ca.crt
+ # Optional client PEM certificate
+ cert = /path/to/client_exoscale.pem
Then::
@@ -73,6 +77,8 @@ 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.ini`` file in the current working directory,
* A ``.cloudstack.ini`` file in the home directory.
diff --git a/cs.py b/cs.py
index 862c864..359cd85 100644
--- a/cs.py
+++ b/cs.py
@@ -6,7 +6,6 @@ import hashlib
import hmac
import json
import os
-import requests
import sys
import time
@@ -29,6 +28,8 @@ try:
except ImportError:
pygments = None
+import requests
+
PY2 = sys.version_info < (3, 0)
@@ -90,12 +91,15 @@ class Unauthorized(CloudStackException):
class CloudStack(object):
- def __init__(self, endpoint, key, secret, timeout=10, method='get'):
+ def __init__(self, endpoint, key, secret, timeout=10, method='get',
+ verify=True, cert=None):
self.endpoint = endpoint
self.key = key
self.secret = secret
self.timeout = int(timeout)
self.method = method.lower()
+ self.verify = verify
+ self.cert = cert
def __repr__(self):
return '<CloudStack: {0}>'.format(self.endpoint)
@@ -131,6 +135,8 @@ class CloudStack(object):
response = getattr(requests, self.method)(self.endpoint,
timeout=self.timeout,
+ verify=self.verify,
+ cert=self.cert,
**{kwarg: kwargs})
try:
@@ -191,6 +197,8 @@ def read_config(ini_group=None):
else:
env_conf[key] = os.environ['CLOUDSTACK_{0}'.format(key.upper())]
else:
+ env_conf['verify'] = os.environ.get('CLOUDSTACK_VERIFY', True)
+ env_conf['cert'] = os.environ.get('CLOUDSTACK_CERT', None)
return env_conf
# Config file: $PWD/cloudstack.ini or $HOME/.cloudstack.ini
diff --git a/setup.py b/setup.py
index 2099f98..496ef5f 100644
--- a/setup.py
+++ b/setup.py
@@ -6,7 +6,7 @@ with open('README.rst', 'r') as f:
setup(
name='cs',
- version='0.8.3',
+ version='0.9.0',
url='https://github.com/exoscale/cs',
license='BSD',
author=u'Bruno Renié',
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-cs.git
More information about the Python-modules-commits
mailing list