/
types.py
379 lines (333 loc) · 11.4 KB
/
types.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
# 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.
"""
Base types used by other parts of libcloud
"""
from libcloud.common.types import Type
from libcloud.common.types import LibcloudError, MalformedResponseError
from libcloud.common.types import InvalidCredsError, InvalidCredsException
__all__ = [
"Provider",
"NodeState",
"DeploymentError",
"DeploymentException",
# @@TR: should the unused imports below be exported?
"LibcloudError",
"MalformedResponseError",
"InvalidCredsError",
"InvalidCredsException",
"OLD_CONSTANT_TO_NEW_MAPPING"
]
class Provider(Type):
"""
Defines for each of the supported providers
Non-Dummy drivers are sorted in alphabetical order. Please preserve this
ordering when adding new drivers.
:cvar DUMMY: Example provider
:cvar ABIQUO: Abiquo driver
:cvar ALIYUN_ECS: Aliyun ECS driver.
:cvar AURORACOMPUTE: Aurora Compute driver.
:cvar AZURE: Azure (classic) driver.
:cvar AZURE_ARM: Azure Resource Manager (modern) driver.
:cvar BLUEBOX: Bluebox
:cvar CLOUDSIGMA: CloudSigma
:cvar CLOUDSCALE: cloudscale.ch
:cvar CLOUDSTACK: CloudStack
:cvar DIMENSIONDATA: Dimension Data Cloud
:cvar EC2: Amazon AWS.
:cvar ECP: Enomaly
:cvar ELASTICHOSTS: ElasticHosts.com
:cvar EXOSCALE: Exoscale driver.
:cvar GCE: Google Compute Engine
:cvar GOGRID: GoGrid
:cvar GRIDSCALE: gridscale
:cvar GRIDSPOT: Gridspot driver
:cvar IBM: IBM Developer Cloud
:cvar IKOULA: Ikoula driver.
:cvar JOYENT: Joyent driver
:cvar KAMATERA: Kamatera driver
:cvar KTUCLOUD: kt ucloud driver
:cvar KUBEVIRT: kubevirt driver
:cvar LIBVIRT: Libvirt driver
:cvar LINODE: Linode.com
:cvar NEPHOSCALE: NephoScale driver
:cvar NIMBUS: Nimbus
:cvar NINEFOLD: Ninefold
:cvar NTTC-CIS: NTT Communications CIS
:cvar OPENNEBULA: OpenNebula.org
:cvar OPSOURCE: Opsource Cloud
:cvar OUTSCALE_INC: Outscale INC driver.
:cvar OUTSCALE_SAS: Outscale SAS driver.
:cvar OUTSCALE_SDK: Outscale SDK driver.
:cvar PROFIT_BRICKS: ProfitBricks driver.
:cvar RACKSPACE: Rackspace next-gen OpenStack based Cloud Servers
:cvar RACKSPACE_FIRST_GEN: Rackspace First Gen Cloud Servers
:cvar RIMUHOSTING: RimuHosting.com
:cvar TERREMARK: Terremark
:cvar UPCLOUD: UpCloud
:cvar VCL: VCL driver
:cvar VCLOUD: vmware vCloud
:cvar VPSNET: VPS.net
:cvar VSphere: VSphere driver.
:cvar VULTR: vultr driver.
"""
AZURE = 'azure'
AZURE_ARM = 'azure_arm'
DUMMY = 'dummy'
ABIQUO = 'abiquo'
ALIYUN_ECS = 'aliyun_ecs'
AURORACOMPUTE = 'aurora_compute'
BLUEBOX = 'bluebox'
BRIGHTBOX = 'brightbox'
BSNL = 'bsnl'
CISCOCCS = 'ciscoccs'
CLOUDFRAMES = 'cloudframes'
CLOUDSIGMA = 'cloudsigma'
CLOUDSCALE = 'cloudscale'
CLOUDSTACK = 'cloudstack'
DIGITAL_OCEAN = 'digitalocean'
DIMENSIONDATA = 'dimensiondata'
EC2 = 'ec2'
ECP = 'ecp'
ELASTICHOSTS = 'elastichosts'
EQUINIXMETAL = 'equinixmetal'
EUCALYPTUS = 'eucalyptus'
EXOSCALE = 'exoscale'
GANDI = 'gandi'
GCE = 'gce'
GIG_G8 = 'gig_g8'
GOGRID = 'gogrid'
GRIDSCALE = 'gridscale'
GRIDSPOT = 'gridspot'
HOSTVIRTUAL = 'hostvirtual'
IBM = 'ibm'
IKOULA = 'ikoula'
INDOSAT = 'indosat'
INTERNETSOLUTIONS = 'internetsolutions'
JOYENT = 'joyent'
KAMATERA = 'kamatera'
KTUCLOUD = 'ktucloud'
KUBEVIRT = 'kubevirt'
LIBVIRT = 'libvirt'
LINODE = 'linode'
MAXIHOST = 'maxihost'
MEDONE = 'medone'
NEPHOSCALE = 'nephoscale'
NIMBUS = 'nimbus'
NINEFOLD = 'ninefold'
NTTA = 'ntta'
NTTCIS = 'nttcis'
ONEANDONE = 'oneandone'
OPENNEBULA = 'opennebula'
OPENSTACK = 'openstack'
OPSOURCE = 'opsource'
OUTSCALE_INC = 'outscale_inc'
OUTSCALE_SAS = 'outscale_sas'
OUTSCALE = 'outscale'
OVH = 'ovh'
PROFIT_BRICKS = 'profitbricks'
RACKSPACE = 'rackspace'
RACKSPACE_FIRST_GEN = 'rackspace_first_gen'
RIMUHOSTING = 'rimuhosting'
RUNABOVE = 'runabove'
SCALEWAY = 'scaleway'
SERVERLOVE = 'serverlove'
SKALICLOUD = 'skalicloud'
SOFTLAYER = 'softlayer'
TERREMARK = 'terremark'
UPCLOUD = 'upcloud'
VCL = 'vcl'
VCLOUD = 'vcloud'
VOXEL = 'voxel'
VPSNET = 'vpsnet'
VSPHERE = 'vsphere'
VULTR = 'vultr'
# OpenStack based providers
CLOUDWATT = 'cloudwatt'
HPCLOUD = 'hpcloud'
KILI = 'kili'
ONAPP = 'onapp'
# Deprecated constants which aren't supported anymore
RACKSPACE_UK = 'rackspace_uk'
RACKSPACE_NOVA_BETA = 'rackspace_nova_beta'
RACKSPACE_NOVA_DFW = 'rackspace_nova_dfw'
RACKSPACE_NOVA_LON = 'rackspace_nova_lon'
RACKSPACE_NOVA_ORD = 'rackspace_nova_ord'
EC2_US_EAST = 'ec2_us_east'
EC2_US_EAST_OHIO = 'ec2_us_east_ohio'
EC2_EU = 'ec2_eu_west' # deprecated name
EC2_EU_WEST = 'ec2_eu_west'
EC2_EU_WEST2 = 'ec2_eu_west_london'
EC2_US_WEST = 'ec2_us_west'
EC2_AP_SOUTHEAST = 'ec2_ap_southeast'
EC2_AP_NORTHEAST = 'ec2_ap_northeast'
EC2_AP_NORTHEAST1 = 'ec2_ap_northeast_1'
EC2_AP_NORTHEAST2 = 'ec2_ap_northeast_2'
EC2_US_WEST_OREGON = 'ec2_us_west_oregon'
EC2_SA_EAST = 'ec2_sa_east'
EC2_AP_SOUTHEAST2 = 'ec2_ap_southeast_2'
EC2_CA_CENTRAL1 = 'ec2_ca_central_1'
ELASTICHOSTS_UK1 = 'elastichosts_uk1'
ELASTICHOSTS_UK2 = 'elastichosts_uk2'
ELASTICHOSTS_US1 = 'elastichosts_us1'
ELASTICHOSTS_US2 = 'elastichosts_us2'
ELASTICHOSTS_US3 = 'elastichosts_us3'
ELASTICHOSTS_CA1 = 'elastichosts_ca1'
ELASTICHOSTS_AU1 = 'elastichosts_au1'
ELASTICHOSTS_CN1 = 'elastichosts_cn1'
CLOUDSIGMA_US = 'cloudsigma_us'
# Removed
# SLICEHOST = 'slicehost'
DEPRECATED_RACKSPACE_PROVIDERS = [Provider.RACKSPACE_UK,
Provider.RACKSPACE_NOVA_BETA,
Provider.RACKSPACE_NOVA_DFW,
Provider.RACKSPACE_NOVA_LON,
Provider.RACKSPACE_NOVA_ORD]
OLD_CONSTANT_TO_NEW_MAPPING = {
# Rackspace
Provider.RACKSPACE_UK: Provider.RACKSPACE_FIRST_GEN,
Provider.RACKSPACE_NOVA_BETA: Provider.RACKSPACE,
Provider.RACKSPACE_NOVA_DFW: Provider.RACKSPACE,
Provider.RACKSPACE_NOVA_LON: Provider.RACKSPACE,
Provider.RACKSPACE_NOVA_ORD: Provider.RACKSPACE,
# AWS
Provider.EC2_US_EAST: Provider.EC2,
Provider.EC2_US_EAST_OHIO: Provider.EC2,
Provider.EC2_EU: Provider.EC2,
Provider.EC2_EU_WEST: Provider.EC2,
Provider.EC2_EU_WEST2: Provider.EC2,
Provider.EC2_US_WEST: Provider.EC2,
Provider.EC2_AP_SOUTHEAST: Provider.EC2,
Provider.EC2_AP_SOUTHEAST2: Provider.EC2,
Provider.EC2_AP_NORTHEAST: Provider.EC2,
Provider.EC2_AP_NORTHEAST1: Provider.EC2,
Provider.EC2_AP_NORTHEAST2: Provider.EC2,
Provider.EC2_US_WEST_OREGON: Provider.EC2,
Provider.EC2_SA_EAST: Provider.EC2,
Provider.EC2_CA_CENTRAL1: Provider.EC2,
# ElasticHosts
Provider.ELASTICHOSTS_UK1: Provider.ELASTICHOSTS,
Provider.ELASTICHOSTS_UK2: Provider.ELASTICHOSTS,
Provider.ELASTICHOSTS_US1: Provider.ELASTICHOSTS,
Provider.ELASTICHOSTS_US2: Provider.ELASTICHOSTS,
Provider.ELASTICHOSTS_US3: Provider.ELASTICHOSTS,
Provider.ELASTICHOSTS_CA1: Provider.ELASTICHOSTS,
Provider.ELASTICHOSTS_AU1: Provider.ELASTICHOSTS,
Provider.ELASTICHOSTS_CN1: Provider.ELASTICHOSTS,
}
class NodeState(Type):
"""
Standard states for a node
:cvar RUNNING: Node is running.
:cvar STARTING: Node is starting up.
:cvar REBOOTING: Node is rebooting.
:cvar TERMINATED: Node is terminated. This node can't be started later on.
:cvar STOPPING: Node is currently trying to stop.
:cvar STOPPED: Node is stopped. This node can be started later on.
:cvar PENDING: Node is pending.
:cvar SUSPENDED: Node is suspended.
:cvar ERROR: Node is an error state. Usually no operations can be performed
on the node once it ends up in the error state.
:cvar PAUSED: Node is paused.
:cvar RECONFIGURING: Node is being reconfigured.
:cvar UNKNOWN: Node state is unknown.
"""
RUNNING = 'running'
STARTING = 'starting'
REBOOTING = 'rebooting'
TERMINATED = 'terminated'
PENDING = 'pending'
UNKNOWN = 'unknown'
STOPPING = 'stopping'
STOPPED = 'stopped'
SUSPENDED = 'suspended'
ERROR = 'error'
PAUSED = 'paused'
RECONFIGURING = 'reconfiguring'
MIGRATING = 'migrating'
NORMAL = 'normal'
UPDATING = 'updating'
class StorageVolumeState(Type):
"""
Standard states of a StorageVolume
"""
AVAILABLE = 'available'
ERROR = 'error'
INUSE = 'inuse'
CREATING = 'creating'
DELETING = 'deleting'
DELETED = 'deleted'
BACKUP = 'backup'
ATTACHING = 'attaching'
UNKNOWN = 'unknown'
MIGRATING = 'migrating'
UPDATING = 'updating'
class VolumeSnapshotState(Type):
"""
Standard states of VolumeSnapshots
"""
AVAILABLE = 'available'
ERROR = 'error'
CREATING = 'creating'
DELETING = 'deleting'
RESTORING = 'restoring'
UNKNOWN = 'unknown'
UPDATING = 'updating'
class NodeImageMemberState(Type):
"""
Standard states of VolumeSnapshots
"""
ACCEPTED = 'accepted'
PENDING = 'pending'
REJECTED = 'rejected'
class Architecture(object):
"""
Image and size architectures.
:cvar I386: i386 (32 bt)
:cvar X86_64: x86_64 (64 bit)
"""
I386 = 0
X86_X64 = 1
class DeploymentError(LibcloudError):
"""
Exception used when a Deployment Task failed.
:ivar node: :class:`Node` on which this exception happened, you might want
to call :func:`Node.destroy`
"""
def __init__(self, node, original_exception=None, driver=None):
self.node = node
self.value = original_exception
self.original_error = original_exception
self.driver = driver
def __str__(self):
return self.__repr__()
def __repr__(self):
return (('<DeploymentError: node=%s, error=%s, driver=%s>'
% (self.node.id, str(self.value), str(self.driver))))
class KeyPairError(LibcloudError):
error_type = 'KeyPairError'
def __init__(self, name, driver):
self.name = name
self.value = 'Key pair with name %s does not exist' % (name)
super(KeyPairError, self).__init__(value=self.value, driver=driver)
def __str__(self):
return self.__repr__()
def __repr__(self):
return ('<%s name=%s, value=%s, driver=%s>' %
(self.error_type, self.name, self.value, self.driver.name))
class KeyPairDoesNotExistError(KeyPairError):
error_type = 'KeyPairDoesNotExistError'
"""Deprecated alias of :class:`DeploymentException`"""
DeploymentException = DeploymentError