003 File Manager
Current Path:
/usr/local/lib/python3.8/site-packages/libcloud/compute/drivers
usr
/
local
/
lib
/
python3.8
/
site-packages
/
libcloud
/
compute
/
drivers
/
📁
..
📄
__init__.py
(1.18 KB)
📁
__pycache__
📄
abiquo.py
(30.79 KB)
📄
auroracompute.py
(1.99 KB)
📄
azure.py
(110.57 KB)
📄
azure_arm.py
(81.18 KB)
📄
bluebox.py
(7.25 KB)
📄
brightbox.py
(10.6 KB)
📄
bsnl.py
(1.91 KB)
📄
cloudscale.py
(8.64 KB)
📄
cloudsigma.py
(67.16 KB)
📄
cloudstack.py
(159.99 KB)
📄
cloudwatt.py
(4.97 KB)
📄
digitalocean.py
(26.89 KB)
📄
dimensiondata.py
(185.11 KB)
📄
dummy.py
(10.81 KB)
📄
ec2.py
(216.23 KB)
📄
ecp.py
(11.45 KB)
📄
ecs.py
(62.32 KB)
📄
elastichosts.py
(7.27 KB)
📄
elasticstack.py
(15.96 KB)
📄
equinixmetal.py
(33.73 KB)
📄
exoscale.py
(1.13 KB)
📄
gandi.py
(25.69 KB)
📄
gce.py
(381.02 KB)
📄
gig_g8.py
(21.5 KB)
📄
gogrid.py
(14.89 KB)
📄
gridscale.py
(34.55 KB)
📄
gridspot.py
(4.14 KB)
📄
hostvirtual.py
(14.09 KB)
📄
ikoula.py
(1.14 KB)
📄
indosat.py
(1.95 KB)
📄
internetsolutions.py
(2 KB)
📄
joyent.py
(8.02 KB)
📄
kamatera.py
(22.93 KB)
📄
kili.py
(3.12 KB)
📄
ktucloud.py
(3.51 KB)
📄
kubevirt.py
(50.35 KB)
📄
libvirt_driver.py
(14.33 KB)
📄
linode.py
(58.85 KB)
📄
maxihost.py
(8.22 KB)
📄
medone.py
(1.94 KB)
📄
nephoscale.py
(17.28 KB)
📄
ntta.py
(1.96 KB)
📄
nttcis.py
(217.71 KB)
📄
onapp.py
(16.12 KB)
📄
oneandone.py
(56.4 KB)
📄
opennebula.py
(42.33 KB)
📄
openstack.py
(154.85 KB)
📄
outscale.py
(285.94 KB)
📄
ovh.py
(19.11 KB)
📄
profitbricks.py
(117.97 KB)
📄
rackspace.py
(9.22 KB)
📄
rimuhosting.py
(12 KB)
📄
scaleway.py
(23.66 KB)
📄
serverlove.py
(2.87 KB)
📄
skalicloud.py
(2.85 KB)
📄
softlayer.py
(17.5 KB)
📄
upcloud.py
(10.89 KB)
📄
vcl.py
(8.64 KB)
📄
vcloud.py
(92.5 KB)
📄
voxel.py
(10.67 KB)
📄
vpsnet.py
(6.56 KB)
📄
vsphere.py
(76.51 KB)
📄
vultr.py
(28.4 KB)
Editing: cloudwatt.py
# Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """ Cloudwatt driver. """ try: import simplejson as json except ImportError: import json from libcloud.utils.py3 import httplib from libcloud.compute.types import Provider from libcloud.compute.drivers.openstack import OpenStack_1_1_Connection from libcloud.compute.drivers.openstack import OpenStack_1_1_NodeDriver from libcloud.common.openstack_identity import OpenStackIdentityConnection from libcloud.utils.iso8601 import parse_date from libcloud.compute.types import InvalidCredsError, MalformedResponseError __all__ = [ 'CloudwattNodeDriver' ] BASE_URL = 'https://identity.fr1.cloudwatt.com/v2.0' AUTH_URL = BASE_URL + '/tokens' class CloudwattAuthConnection(OpenStackIdentityConnection): """ AuthConnection class for the Cloudwatt driver. """ name = 'Cloudwatt Auth' def __init__(self, *args, **kwargs): self._ex_tenant_id = kwargs.pop('ex_tenant_id') super(CloudwattAuthConnection, self).__init__(*args, **kwargs) def authenticate(self, force=False): reqbody = json.dumps({'auth': { 'passwordCredentials': { 'username': self.user_id, 'password': self.key }, 'tenantId': self._ex_tenant_id }}) resp = self.request('/tokens', data=reqbody, headers={}, method='POST') if resp.status == httplib.UNAUTHORIZED: # HTTP UNAUTHORIZED (401): auth failed raise InvalidCredsError() elif resp.status != httplib.OK: body = 'code: %s body:%s' % (resp.status, resp.body) raise MalformedResponseError('Malformed response', body=body, driver=self.driver) else: try: body = json.loads(resp.body) except Exception as e: raise MalformedResponseError('Failed to parse JSON', e) try: expires = body['access']['token']['expires'] self.auth_token = body['access']['token']['id'] self.auth_token_expires = parse_date(expires) self.urls = body['access']['serviceCatalog'] self.auth_user_info = None except KeyError as e: raise MalformedResponseError('Auth JSON response is \ missing required elements', e) return self class CloudwattConnection(OpenStack_1_1_Connection): """ Connection class for the Cloudwatt driver. """ auth_url = BASE_URL service_region = 'fr1' service_type = 'compute' def __init__(self, *args, **kwargs): self.ex_tenant_id = kwargs.pop('ex_tenant_id') super(CloudwattConnection, self).__init__(*args, **kwargs) osa = CloudwattAuthConnection( auth_url=AUTH_URL, user_id=self.user_id, key=self.key, tenant_name=self._ex_tenant_name, timeout=self.timeout, ex_tenant_id=self.ex_tenant_id, parent_conn=self ) self._osa = osa self._auth_version = '2.0' class CloudwattNodeDriver(OpenStack_1_1_NodeDriver): """ Implements the :class:`NodeDriver`'s for Cloudwatt. """ name = 'Cloudwatt' website = 'https://www.cloudwatt.com/' connectionCls = CloudwattConnection type = Provider.CLOUDWATT def __init__(self, key, secret, tenant_id, secure=True, tenant_name=None, host=None, port=None, **kwargs): """ @inherits: :class:`NodeDriver.__init__` :param tenant_id: ID of tenant required for Cloudwatt auth :type tenant_id: ``str`` """ self.ex_tenant_id = tenant_id self.extra = {} super(CloudwattNodeDriver, self).__init__( key=key, secret=secret, secure=secure, host=host, port=port, **kwargs ) def attach_volume(self, node, volume, device=None): return super(CloudwattNodeDriver, self)\ .attach_volume(node, volume, device) def _ex_connection_class_kwargs(self): """ Includes ``tenant_id`` in Connection. """ return { 'ex_tenant_id': self.ex_tenant_id }
Upload File
Create Folder