/
opt
/
imh-python
/
lib
/
python3.9
/
site-packages
/
libcloud
/
compute
/
drivers
/
/opt/imh-python/lib/python3.9/site-packages/libcloud/compute/drivers
mkdir
upload
Name
Size
Mode
Actions
__pycache__/
-
0755
rm
abiquo.py
31529
0644
edit
dl
rm
auroracompute.py
2040
0644
edit
dl
rm
azure.py
113227
0644
edit
dl
rm
azure_arm.py
83132
0644
edit
dl
rm
bluebox.py
7426
0644
edit
dl
rm
brightbox.py
10859
0644
edit
dl
rm
bsnl.py
1958
0644
edit
dl
rm
cloudscale.py
8844
0644
edit
dl
rm
cloudsigma.py
68769
0644
edit
dl
rm
cloudstack.py
163834
0644
edit
dl
rm
cloudwatt.py
5094
0644
edit
dl
rm
digitalocean.py
27064
0644
edit
dl
rm
dimensiondata.py
189557
0644
edit
dl
rm
dummy.py
11074
0644
edit
dl
rm
ec2.py
219386
0644
edit
dl
rm
ecp.py
11723
0644
edit
dl
rm
ecs.py
63818
0644
edit
dl
rm
elastichosts.py
7441
0644
edit
dl
rm
elasticstack.py
16348
0644
edit
dl
rm
exoscale.py
1159
0644
edit
dl
rm
gandi.py
26305
0644
edit
dl
rm
gce.py
389086
0644
edit
dl
rm
gig_g8.py
22013
0644
edit
dl
rm
gogrid.py
15250
0644
edit
dl
rm
gridscale.py
35381
0644
edit
dl
rm
gridspot.py
4243
0644
edit
dl
rm
hostvirtual.py
14427
0644
edit
dl
rm
ikoula.py
1172
0644
edit
dl
rm
indosat.py
1997
0644
edit
dl
rm
internetsolutions.py
2050
0644
edit
dl
rm
joyent.py
8213
0644
edit
dl
rm
kamatera.py
23481
0644
edit
dl
rm
kili.py
3199
0644
edit
dl
rm
ktucloud.py
3595
0644
edit
dl
rm
kubevirt.py
40678
0644
edit
dl
rm
libvirt_driver.py
14671
0644
edit
dl
rm
linode.py
26646
0644
edit
dl
rm
maxihost.py
8419
0644
edit
dl
rm
medone.py
1984
0644
edit
dl
rm
nephoscale.py
17690
0644
edit
dl
rm
ntta.py
2011
0644
edit
dl
rm
nttcis.py
222933
0644
edit
dl
rm
onapp.py
16503
0644
edit
dl
rm
oneandone.py
57758
0644
edit
dl
rm
opennebula.py
43343
0644
edit
dl
rm
openstack.py
144008
0644
edit
dl
rm
ovh.py
18845
0644
edit
dl
rm
packet.py
33684
0644
edit
dl
rm
profitbricks.py
120806
0644
edit
dl
rm
rackspace.py
9442
0644
edit
dl
rm
rimuhosting.py
12292
0644
edit
dl
rm
scaleway.py
24231
0644
edit
dl
rm
serverlove.py
2934
0644
edit
dl
rm
skalicloud.py
2917
0644
edit
dl
rm
softlayer.py
17921
0644
edit
dl
rm
upcloud.py
11156
0644
edit
dl
rm
vcl.py
8843
0644
edit
dl
rm
vcloud.py
94722
0644
edit
dl
rm
voxel.py
10927
0644
edit
dl
rm
vpsnet.py
6721
0644
edit
dl
rm
vsphere.py
18407
0644
edit
dl
rm
vultr.py
13328
0644
edit
dl
rm
__init__.py
1207
0644
edit
dl
rm
Edit:
/opt/imh-python/lib/python3.9/site-packages/libcloud/compute/drivers/rackspace.py
(9442B)
# 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. """ Rackspace driver """ from libcloud.compute.types import Provider, LibcloudError, VolumeSnapshotState from libcloud.compute.base import NodeLocation, VolumeSnapshot from libcloud.compute.drivers.openstack import OpenStack_1_0_Connection,\ OpenStack_1_0_NodeDriver, OpenStack_1_0_Response from libcloud.compute.drivers.openstack import OpenStack_1_1_Connection,\ OpenStack_1_1_NodeDriver from libcloud.common.rackspace import AUTH_URL from libcloud.utils.iso8601 import parse_date SERVICE_TYPE = 'compute' SERVICE_NAME_GEN1 = 'cloudServers' SERVICE_NAME_GEN2 = 'cloudServersOpenStack' ENDPOINT_ARGS_MAP = { 'dfw': {'service_type': SERVICE_TYPE, 'name': SERVICE_NAME_GEN2, 'region': 'DFW'}, 'ord': {'service_type': SERVICE_TYPE, 'name': SERVICE_NAME_GEN2, 'region': 'ORD'}, 'iad': {'service_type': SERVICE_TYPE, 'name': SERVICE_NAME_GEN2, 'region': 'IAD'}, 'lon': {'service_type': SERVICE_TYPE, 'name': SERVICE_NAME_GEN2, 'region': 'LON'}, 'syd': {'service_type': SERVICE_TYPE, 'name': SERVICE_NAME_GEN2, 'region': 'SYD'}, 'hkg': {'service_type': SERVICE_TYPE, 'name': SERVICE_NAME_GEN2, 'region': 'HKG'}, } class RackspaceFirstGenConnection(OpenStack_1_0_Connection): """ Connection class for the Rackspace first-gen driver. """ responseCls = OpenStack_1_0_Response XML_NAMESPACE = 'http://docs.rackspacecloud.com/servers/api/v1.0' auth_url = AUTH_URL _auth_version = '2.0' cache_busting = True def __init__(self, *args, **kwargs): self.region = kwargs.pop('region', None) super(RackspaceFirstGenConnection, self).__init__(*args, **kwargs) def get_endpoint(self): if '2.0' in self._auth_version: ep = self.service_catalog.get_endpoint(service_type=SERVICE_TYPE, name=SERVICE_NAME_GEN1) else: raise LibcloudError( 'Auth version "%s" not supported' % (self._auth_version)) public_url = ep.url if not public_url: raise LibcloudError('Could not find specified endpoint') # This is a nasty hack, but it's required because of how the # auth system works. # Old US accounts can access UK API endpoint, but they don't # have this endpoint in the service catalog. Same goes for the # old UK accounts and US endpoint. if self.region == 'us': # Old UK account, which only have uk endpoint in the catalog public_url = public_url.replace('https://lon.servers.api', 'https://servers.api') elif self.region == 'uk': # Old US account, which only has us endpoints in the catalog public_url = public_url.replace('https://servers.api', 'https://lon.servers.api') return public_url def get_service_name(self): return SERVICE_NAME_GEN1 class RackspaceFirstGenNodeDriver(OpenStack_1_0_NodeDriver): name = 'Rackspace Cloud (First Gen)' website = 'http://www.rackspace.com' connectionCls = RackspaceFirstGenConnection type = Provider.RACKSPACE_FIRST_GEN api_name = 'rackspace' def __init__(self, key, secret=None, secure=True, host=None, port=None, region='us', **kwargs): """ @inherits: :class:`NodeDriver.__init__` :param region: Region ID which should be used :type region: ``str`` """ if region not in ['us', 'uk']: raise ValueError('Invalid region: %s' % (region)) super(RackspaceFirstGenNodeDriver, self).__init__(key=key, secret=secret, secure=secure, host=host, port=port, region=region, **kwargs) def list_locations(self): """ Lists available locations Locations cannot be set or retrieved via the API, but currently there are two locations, DFW and ORD. @inherits: :class:`OpenStack_1_0_NodeDriver.list_locations` """ if self.region == 'us': locations = [NodeLocation(0, "Rackspace DFW1/ORD1", 'US', self)] elif self.region == 'uk': locations = [NodeLocation(0, 'Rackspace UK London', 'UK', self)] return locations def _ex_connection_class_kwargs(self): kwargs = self.openstack_connection_kwargs() kwargs['region'] = self.region return kwargs class RackspaceConnection(OpenStack_1_1_Connection): """ Connection class for the Rackspace next-gen OpenStack base driver. """ auth_url = AUTH_URL _auth_version = '2.0' def __init__(self, *args, **kwargs): self.region = kwargs.pop('region', None) self.get_endpoint_args = kwargs.pop('get_endpoint_args', None) super(RackspaceConnection, self).__init__(*args, **kwargs) def get_service_name(self): if not self.get_endpoint_args: # if they used ex_force_base_url, assume the Rackspace default return SERVICE_NAME_GEN2 return self.get_endpoint_args.get('name', SERVICE_NAME_GEN2) def get_endpoint(self): if not self.get_endpoint_args: raise LibcloudError( 'RackspaceConnection must have get_endpoint_args set') if '2.0' in self._auth_version: ep = self.service_catalog.get_endpoint(**self.get_endpoint_args) else: raise LibcloudError( 'Auth version "%s" not supported' % (self._auth_version)) public_url = ep.url if not public_url: raise LibcloudError('Could not find specified endpoint') return public_url class RackspaceNodeDriver(OpenStack_1_1_NodeDriver): name = 'Rackspace Cloud (Next Gen)' website = 'http://www.rackspace.com' connectionCls = RackspaceConnection type = Provider.RACKSPACE _networks_url_prefix = '/os-networksv2' def __init__(self, key, secret=None, secure=True, host=None, port=None, region='dfw', **kwargs): """ @inherits: :class:`NodeDriver.__init__` :param region: ID of the region which should be used. :type region: ``str`` """ valid_regions = ENDPOINT_ARGS_MAP.keys() if region not in valid_regions: raise ValueError('Invalid region: %s' % (region)) if region == 'lon': self.api_name = 'rackspacenovalon' elif region == 'syd': self.api_name = 'rackspacenovasyd' else: self.api_name = 'rackspacenovaus' super(RackspaceNodeDriver, self).__init__(key=key, secret=secret, secure=secure, host=host, port=port, region=region, **kwargs) def _to_snapshot(self, api_node): if 'snapshot' in api_node: api_node = api_node['snapshot'] extra = {'volume_id': api_node['volumeId'], 'name': api_node['displayName'], 'created': api_node['createdAt'], 'description': api_node['displayDescription'], 'status': api_node['status']} state = self.SNAPSHOT_STATE_MAP.get( api_node['status'], VolumeSnapshotState.UNKNOWN ) try: created_td = parse_date(api_node['createdAt']) except ValueError: created_td = None snapshot = VolumeSnapshot(id=api_node['id'], driver=self, size=api_node['size'], extra=extra, created=created_td, state=state, name=api_node['displayName']) return snapshot def _ex_connection_class_kwargs(self): endpoint_args = ENDPOINT_ARGS_MAP[self.region] kwargs = self.openstack_connection_kwargs() kwargs['region'] = self.region kwargs['get_endpoint_args'] = endpoint_args return kwargs
Save
cmd:
run