Add request_instance() to gce driver

This commit is contained in:
Joseph Hall 2015-09-21 09:21:57 -06:00
parent 611d3e5760
commit 35cf1f7183

View File

@ -2011,15 +2011,10 @@ def destroy(vm_name, call=None):
return inst_deleted return inst_deleted
def create(vm_=None, call=None): def request_instance(vm_):
''' '''
Create a single GCE instance from a data dict. Request a single GCE instance from a data dict.
''' '''
if call:
raise SaltCloudSystemExit(
'You cannot create an instance with -a or -f.'
)
if not GCE_VM_NAME_REGEX.match(vm_['name']): if not GCE_VM_NAME_REGEX.match(vm_['name']):
raise SaltCloudSystemExit( raise SaltCloudSystemExit(
'VM names must start with a letter, only contain letters, numbers, or dashes ' 'VM names must start with a letter, only contain letters, numbers, or dashes '
@ -2119,6 +2114,20 @@ def create(vm_=None, call=None):
# node_data is a libcloud Node which is unsubscriptable # node_data is a libcloud Node which is unsubscriptable
node_dict = show_instance(node_data.name, 'action') node_dict = show_instance(node_data.name, 'action')
return node_dict, node_data
def create(vm_=None, call=None):
'''
Create a single GCE instance from a data dict.
'''
if call:
raise SaltCloudSystemExit(
'You cannot create an instance with -a or -f.'
)
node_dict, node_data = request_instance(vm_)
ssh_user, ssh_key = __get_ssh_credentials(vm_) ssh_user, ssh_key = __get_ssh_credentials(vm_)
vm_['ssh_host'] = __get_host(node_data, vm_) vm_['ssh_host'] = __get_host(node_data, vm_)
vm_['key_filename'] = ssh_key vm_['key_filename'] = ssh_key