mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
nitial support for joyent cloud
This commit is contained in:
parent
2b9838a39b
commit
ab3c0e7461
79
saltcloud/clouds/joyent.py
Normal file
79
saltcloud/clouds/joyent.py
Normal file
@ -0,0 +1,79 @@
|
||||
'''
|
||||
Joyent Cloud Module
|
||||
===================
|
||||
|
||||
The Joyent Cloud module is used to intereact with the Joyend cloud system
|
||||
|
||||
it requires that the username and password to the joyent accound be configured
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
# The Joyent login user
|
||||
JOYENT.user: fred
|
||||
# The Joyent user's password
|
||||
JOYENT.password: saltybacon
|
||||
|
||||
'''
|
||||
|
||||
# The import section is mostly libcloud boilerplate
|
||||
|
||||
# Import python libs
|
||||
import os
|
||||
import types
|
||||
|
||||
# Import libcloud
|
||||
from libcloud.compute.types import Provider
|
||||
from libcloud.compute.providers import get_driver
|
||||
from libcloud.compute.deployment import MultiStepDeployment, ScriptDeployment, SSHKeyDeployment
|
||||
|
||||
# Import generic libcloud functions
|
||||
from saltcloud.libcloudfuncs import *
|
||||
|
||||
# Some of the libcloud functions need to be in the same namespace as the
|
||||
# functions defined in the module, so we create new function objects inside
|
||||
# this module namespace
|
||||
avail_images = types.FunctionType(avail_images.__code__, globals())
|
||||
avail_sizes = types.FunctionType(avail_sizes.__code__, globals())
|
||||
script = types.FunctionType(script.__code__, globals())
|
||||
destroy = types.FunctionType(destroy.__code__, globals())
|
||||
list_nodes = types.FunctionType(list_nodes.__code__, globals())
|
||||
|
||||
|
||||
# Only load in this module is the RACKSPACE configurations are in place
|
||||
def __virtual__():
|
||||
'''
|
||||
Set up the libcloud funcstions and check for RACKSPACE configs
|
||||
'''
|
||||
if 'JOYENT.user' in __opts__ and 'JOYENT.password' in __opts__:
|
||||
return 'joyent'
|
||||
return False
|
||||
|
||||
|
||||
def get_conn():
|
||||
'''
|
||||
Return a conn object for the passed vm data
|
||||
'''
|
||||
driver = get_driver(Provider.RACKSPACE)
|
||||
return driver(
|
||||
__opts__['JOYENT.user'],
|
||||
__opts__['JOYENT.password'],
|
||||
)
|
||||
|
||||
|
||||
def create(vm_):
|
||||
'''
|
||||
Create a single vm from a data dict
|
||||
'''
|
||||
print('Creating Cloud VM {0}'.format(vm_['name']))
|
||||
conn = get_conn()
|
||||
kwargs = {}
|
||||
kwargs['name'] = vm_['name']
|
||||
kwargs['deploy'] = script(vm_)
|
||||
kwargs['image'] = get_image(conn, vm_)
|
||||
kwargs['size'] = get_size(conn, vm_)
|
||||
data = conn.deploy_node(**kwargs)
|
||||
print('Created Cloud VM {0} with the following values:'.format(
|
||||
vm_['name']
|
||||
))
|
||||
for key, val in data.__dict__.items():
|
||||
print(' {0}: {1}'.format(key, val))
|
Loading…
Reference in New Issue
Block a user