| |
- __builtin__.object
-
- Server
- Servers
class Server(__builtin__.object) |
| |
Methods defined here:
- Account(self)
- Return account object for account containing this server.
>>> clc.v2.Server("CA3BTDICNTRLM01").Account()
<clc.APIv2.account.Account instance at 0x108789878>
>>> print _
BTDI
- Alerts(self)
- Returns an Alerts object containing all alerts mapped to this server.
>>> clc.v2.Server("NY1BTDIPHYP0101").Alerts()
<clc.APIv2.alert.Alerts object at 0x1065b0150>
- Archive(self)
- Change(self, cpu=None, memory=None, description=None, group_id=None)
- Change existing server object.
One more more fields can be set and method will return with a requests
object for all queued activities. This is a convenience function - all
each of these changes requires a seperate API call. Some API calls are synchronous
(e.g. changing group ID or password) while others are async.
- Clone(self, network_id, name=None, cpu=None, memory=None, group_id=None, alias=None, password=None, ip_address=None, storage_type=None, type=None, primary_dns=None, secondary_dns=None, custom_fields=None, ttl=None, managed_os=False, description=None, source_server_password=None, cpu_autoscale_policy_id=None, anti_affinity_policy_id=None, packages=[], count=1)
- Creates one or more clones of existing server.
https://www.centurylinkcloud.com/api-docs/v2/#servers-create-server
Set ttl as number of seconds before server is to be terminated.
* - network_id is currently a required parameter. This will change to optional once APIs are available to
return the network id of self.
* - if no password is supplied will reuse the password of self. Is this the expected behavior? Take note
there is no way to for a system generated password with this pattern since we cannot leave as None
* - any DNS settings from self aren't propogated to clone since they are unknown at system level and
the clone process will touch them
* - no change to the disk layout we will clone all
* - clone will not replicate managed OS setting from self so this must be explicitly set
>>> d = clc.v2.Datacenter()
>>> clc.v2.Server(alias='BTDI',id='WA1BTDIAPI207').Clone(network_id=d.Networks().networks[0].id,count=2)
0
- ConvertToTemplate(self, visibility, description=None, password=None)
- Converts existing server to a template.
visibility is one of private or shared.
>>> d = clc.v2.Datacenter()
>>> clc.v2.Server(alias='BTDI',id='WA1BTDIAPI207').ConvertToTemplate("private","my template")
0
- CreateSnapshot(self, delete_existing=True, expiration_days=7)
- Take a Hypervisor level snapshot retained for between 1 and 10 days (7 is default).
Currently only one snapshop may exist at a time, thus will delete snapshots if one already
exists before taking this snapshot.
>>> clc.v2.Server("WA1BTDIAPI219").CreateSnapshot(2)
<clc.APIv2.queue.Requests object at 0x10d106cd0>
>>> _.WaitUntilComplete()
0
- Credentials(self)
- Returns the administrative credentials for this server.
>>> clc.v2.Server("NY1BTDIPHYP0101").Credentials()
{u'userName': u'administrator', u'password': u'dszkjh498s^'}
- Delete(self)
- Delete server.
https://t3n.zendesk.com/entries/59220824-Delete-Server
>>> clc.v2.Server("WA1BTDIAPI219").Delete().WaitUntilComplete()
0
- DeleteSnapshot(self, names=None)
- Removes an existing Hypervisor level snapshot.
Supply one or more snapshot names to delete them concurrently.
If no snapshot names are supplied will delete all existing snapshots.
>>> clc.v2.Server(alias='BTDI',id='WA1BTDIKRT02').DeleteSnapshot().WaitUntilComplete()
0
- Disks(self)
- Return disks object associated with server.
>>> clc.v2.Server("WA1BTDIX01").Disks()
<clc.APIv2.disk.Disks object at 0x10feea190>
- ExecutePackage(self, package_id, parameters={})
- Execute an existing Bluerprint package on the server.
https://t3n.zendesk.com/entries/59727040-Execute-Package
Requires package ID, currently only available by browsing control and browsing
for the package itself. The UUID parameter is the package ID we need.
>>> clc.v2.Server(alias='BTDI',id='WA1BTDIKRT06'). ExecutePackage(package_id="77ab3844-579d-4c8d-8955-c69a94a2ba1a",parameters={}). WaitUntilComplete()
0
- GetSnapshots(self)
- Returns list of all snapshot names.
>>> clc.v2.Server("WA1BTDIAPI219").GetSnapshots()
[u'2015-01-10.02:10:38']
- Group(self)
- Return group object for group containing this server.
>>> clc.v2.Server("CA3BTDICNTRLM01").Group()
<clc.APIv2.group.Group object at 0x10b07b7d0>
>>> print _
Ansible Managed Servers
- Pause(self)
- PowerOff(self)
- PowerOn(self)
- PublicIPs(self)
- Returns PublicIPs object associated with the server.
- Reboot(self)
- Refresh(self)
- Reloads the server object to synchronize with cloud representation.
>>> clc.v2.Server("CA3BTDICNTRLM01").Refresh()
- Reset(self)
- Restore(self)
- Restore archived server to running state.
If server is already running returns with no change.
# {u'href': u'/v2/servers/btdi/wa1btdichange01/restore',
# u'rel': u'restore'},
#if status !== "archived": pass
- RestoreSnapshot(self, name=None)
- Restores an existing Hypervisor level snapshot.
Supply snapshot name to restore
If no snapshot name is supplied will restore the first snapshot found
>>> clc.v2.Server(alias='BTDI',id='WA1BTDIKRT02').RestoreSnapshot().WaitUntilComplete()
0
- SetCPU(self, value)
- SetDescription(self, value)
- SetGroup(self, group_id)
- SetMemory(self, value)
- SetPassword(self, password)
- Request change of password.
The API request requires supplying the current password. For this we issue a call
to retrieve the credentials so note there will be an activity log for retrieving the
credentials associated with any SetPassword entry
>>> s.SetPassword("newpassword")
- ShutDown(self)
- StartMaintenance(self)
- StopMaintenance(self)
- __getattr__(self, var)
- __init__(self, id, alias=None, server_obj=None)
- Create Server object.
http://www.centurylinkcloud.com/api-docs/v2#servers-get-server
#If parameters are populated then create object location.
#Else if only id is supplied issue a Get Policy call
# successful creation
>>> clc.v2.Server("CA3BTDICNTRLM01")
<clc.APIv2.server.Server object at 0x10c28fe50>
>>> print _
CA3BTDICNTRLM01
# error. API returns 404 when server does not exist, we raise exception
>>> clc.v2.Server(alias='BTDI',id='WA1BTDIKRT01')
clc.CLCException: Server does not exist
- __str__(self)
Static methods defined here:
- Create(name, template, group_id, network_id, cpu=None, memory=None, alias=None, password=None, ip_address=None, storage_type='standard', type='standard', primary_dns=None, secondary_dns=None, additional_disks=[], custom_fields=[], ttl=None, managed_os=False, description=None, source_server_password=None, cpu_autoscale_policy_id=None, anti_affinity_policy_id=None, packages=[])
- Creates a new server.
https://www.centurylinkcloud.com/api-docs/v2/#servers-create-server
cpu and memory are optional and if not provided we pull from the default server size values associated with
the provided group_id.
Set ttl as number of seconds before server is to be terminated. Must be >3600
>>> d = clc.v2.Datacenter()
>>> clc.v2.Server.Create(name="api2",cpu=1,memory=1,
group_id=d.Groups().Get("Default Group").id,
template=d.Templates().Search("centos-6-64")[0].id,
network_id=d.Networks().networks[0].id).WaitUntilComplete()
0
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class Servers(__builtin__.object) |
| |
Methods defined here:
- Archive(self)
- Pause(self)
- PowerOff(self)
- PowerOn(self)
- Reboot(self)
- Reset(self)
- Servers(self, cached=True)
- Returns list of server objects, populates if necessary.
>>> clc.v2.Servers(["NY1BTDIPHYP0101","NY1BTDIWEB0101"]).Servers()
[<clc.APIv2.server.Server object at 0x1065b0d50>, <clc.APIv2.server.Server object at 0x1065b0e50>]
>>> print _[0]
NY1BTDIPHYP0101
- ShutDown(self)
- StartMaintenance(self)
- StopMaintenance(self)
- __getattr__(self, key)
- __init__(self, servers_lst, alias=None)
- Container class for one or more servers.
Behaves differently than the other container classes like Groups where the *_lst
parameter can fully define the object. All we have is the server name on construction.
We will lazily create server objects as needed since each requires a seperate API call.
>>> clc.v2.Servers(["NY1BTDIPHYP0101","NY1BTDIWEB0101"])
<clc.APIv2.server.Servers object at 0x105fa27d0>
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
| |