From 35cf1f71837dd87bd15a822a23ed1893c095406e Mon Sep 17 00:00:00 2001 From: Joseph Hall Date: Mon, 21 Sep 2015 09:21:57 -0600 Subject: [PATCH] Add request_instance() to gce driver --- salt/cloud/clouds/gce.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/salt/cloud/clouds/gce.py b/salt/cloud/clouds/gce.py index 57ee62f88d..afb9892060 100644 --- a/salt/cloud/clouds/gce.py +++ b/salt/cloud/clouds/gce.py @@ -2011,15 +2011,10 @@ def destroy(vm_name, call=None): 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']): raise SaltCloudSystemExit( '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_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_) vm_['ssh_host'] = __get_host(node_data, vm_) vm_['key_filename'] = ssh_key