This is an automated email from the ASF dual-hosted git repository.

tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git

commit b8ea9fe0c2a4e274edacf41cf24e9cc19dc13c1e
Author: Tomaz Muraus <[email protected]>
AuthorDate: Sat Dec 21 12:22:48 2019 +0100

    Update example to also print out the output of the deployment script.
---
 docs/examples/compute/gce/deploy_node.py | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/docs/examples/compute/gce/deploy_node.py 
b/docs/examples/compute/gce/deploy_node.py
index 9ea4cab..dc21763 100644
--- a/docs/examples/compute/gce/deploy_node.py
+++ b/docs/examples/compute/gce/deploy_node.py
@@ -23,21 +23,22 @@ SERVICE_ACCOUNT_CREDENTIALS_JSON_FILE_PATH = 
'/path/to/sac.json'
 PROJECT_ID = 'my-gcp-project'
 
 Driver = get_driver(Provider.GCE)
-conn = Driver(SERVICE_ACCOUNT_USERNAME,
+driver = Driver(SERVICE_ACCOUNT_USERNAME,
               SERVICE_ACCOUNT_CREDENTIALS_JSON_FILE_PATH,
               project=PROJECT_ID,
               datacenter='us-central1-a')
 
-# NOTE: To view the output of this command, you need to set
-# LIBCLOUD_DEBUG variable and then tail that file for the log output
 step = ScriptDeployment("echo whoami ; date ; ls -la")
 
-images = conn.list_images()
-sizes = conn.list_sizes()
+images = driver.list_images()
+sizes = driver.list_sizes()
 
 image = [i for i in images if i.name == 'ubuntu-1604-xenial-v20191217'][0]
 size = [s for s in sizes if s.name == 'e2-micro'][0]
 
+print('Using image: %s' % (image))
+print('Using size: %s' % (size))
+
 # NOTE: We specify which public key is installed on the instance using
 # metadata functionality.
 # Keep in mind that this step is only needed if you want to install a specific
@@ -56,7 +57,14 @@ ex_metadata = metadata = {
 }
 
 # deploy_node takes the same base keyword arguments as create_node.
-node = conn.deploy_node(name='libcloud-deploy-demo-1', image=image, size=size,
+node = driver.deploy_node(name='libcloud-deploy-demo-1', image=image, 
size=size,
                         ex_metadata=metadata,
                         deploy=step, ssh_key=PRIVATE_SSH_KEY_PATH)
-print(node)
+
+print('')
+print('Node: %s' % (node))
+print('')
+print('stdout: %s' % (step))
+print('stdout: %s' % (step.stdout))
+print('stderr: %s' % (step.stderr))
+print('exit_code: %s' % (step.exit_status))

Reply via email to