You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2019/12/20 22:22:49 UTC

[libcloud] branch trunk updated (7d95ff6 -> 619645e)

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

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


    from 7d95ff6  Merge pull request #1389 from Kami/deploy_node_workaround
     add ea0502a  GCENodeDriver's deploy_node() now accepts Deployments as well as all the parameters accepted by create_node()
     new 218baa2  Merge branch 'gce-deploy-node-fix' of https://github.com/yukw777/libcloud into yukw777-gce-deploy-node-fix
     new ec8157a  Declare that GCE driver supports SSH key based deployment functionality.
     new e4d2dae  Add example on how to use deploy_node() with GCE driver.
     new b49ed7e  Clarify the need to install an SSH key.
     new eea7c32  Add changelog entry.
     new 619645e  Add a comment.

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 CHANGES.rst                              |  8 +++++
 docs/compute/drivers/gce.rst             |  5 +++
 docs/examples/compute/gce/deploy_node.py | 62 ++++++++++++++++++++++++++++++++
 libcloud/compute/drivers/gce.py          | 62 ++++----------------------------
 4 files changed, 81 insertions(+), 56 deletions(-)
 create mode 100644 docs/examples/compute/gce/deploy_node.py


[libcloud] 03/06: Add example on how to use deploy_node() with GCE driver.

Posted by to...@apache.org.
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 e4d2dae6d9849acfebe3400af240cd5a4df803ae
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Fri Dec 20 23:05:42 2019 +0100

    Add example on how to use deploy_node() with GCE driver.
---
 docs/compute/drivers/gce.rst             |  5 +++
 docs/examples/compute/gce/deploy_node.py | 56 ++++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+)

diff --git a/docs/compute/drivers/gce.rst b/docs/compute/drivers/gce.rst
index 64a2ecc..a23f670 100644
--- a/docs/compute/drivers/gce.rst
+++ b/docs/compute/drivers/gce.rst
@@ -172,6 +172,11 @@ https://github.com/apache/libcloud/blob/trunk/demos/gce_demo.py
 
 .. literalinclude:: /examples/compute/gce/gce_internal_auth.py
 
+6. Using deploy_node() functionality
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. literalinclude:: /examples/compute/gce/deploy_node.py
+
 API Docs
 --------
 
diff --git a/docs/examples/compute/gce/deploy_node.py b/docs/examples/compute/gce/deploy_node.py
new file mode 100644
index 0000000..44f547d
--- /dev/null
+++ b/docs/examples/compute/gce/deploy_node.py
@@ -0,0 +1,56 @@
+from __future__ import with_statement
+
+import os
+
+from libcloud.compute.types import Provider
+from libcloud.compute.providers import get_driver
+from libcloud.compute.deployment import ScriptDeployment
+
+# Path to the private SSH key file used to authenticate
+PRIVATE_SSH_KEY_PATH = os.path.expanduser('~/.ssh/id_rsa_gce')
+
+# Path to the public SSH key file which will be installed on the server for
+# the root user
+PUBLIC_SSH_KEY_PATH = os.path.expanduser('~/.ssh/id_rsa_gce.pub')
+
+with open(PUBLIC_SSH_KEY_PATH, 'r') as fp:
+    PUBLIC_SSH_KEY_CONTENT = fp.read().strip()
+
+# GCE authentication related info
+SERVICE_ACCOUNT_USERNAME = '<username>@<project id>.iam.gserviceaccount.com'
+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,
+              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()
+
+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]
+
+# NOTE: We specify which public key is installed on the instance using
+# metadata functionality
+ex_metadata = metadata = {
+    'items': [
+        {
+            'key': 'ssh-keys',
+            'value': 'root: %s' % (PUBLIC_SSH_KEY_CONTENT)
+        }
+    ]
+}
+
+# deploy_node takes the same base keyword arguments as create_node.
+node = conn.deploy_node(name='libcloud-deploy-demo-1', image=image, size=size,
+                        ex_metadata=metadata,
+                        deploy=step, ssh_key=PRIVATE_SSH_KEY_PATH)
+print(node)


[libcloud] 06/06: Add a comment.

Posted by to...@apache.org.
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 619645e1ab37eea5b2f980f08ce2c2aa69b1183d
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Fri Dec 20 23:21:06 2019 +0100

    Add a comment.
---
 libcloud/compute/drivers/gce.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libcloud/compute/drivers/gce.py b/libcloud/compute/drivers/gce.py
index 06cd1d1..3a98995 100644
--- a/libcloud/compute/drivers/gce.py
+++ b/libcloud/compute/drivers/gce.py
@@ -3999,6 +3999,8 @@ class GCENodeDriver(NodeDriver):
             ex_preemptible=None, ex_image_family=None, ex_labels=None,
             ex_accelerator_type=None, ex_accelerator_count=None,
             ex_disk_size=None, auth=None):
+        # NOTE: "auth" argument is unused, but it's needed for "deploy_node()"
+        # functionality to work
         """
         Create a new node and return a node object for the node.
 


[libcloud] 02/06: Declare that GCE driver supports SSH key based deployment functionality.

Posted by to...@apache.org.
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 ec8157aef5229c8adb14d52f43dcf5e5a65a57b3
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Fri Dec 20 23:01:29 2019 +0100

    Declare that GCE driver supports SSH key based deployment functionality.
---
 libcloud/compute/drivers/gce.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libcloud/compute/drivers/gce.py b/libcloud/compute/drivers/gce.py
index 7edfc59..06cd1d1 100644
--- a/libcloud/compute/drivers/gce.py
+++ b/libcloud/compute/drivers/gce.py
@@ -12,9 +12,11 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
+
 """
 Module for Google Compute Engine Driver.
 """
+
 from __future__ import with_statement
 
 import datetime
@@ -1735,6 +1737,7 @@ class GCENodeDriver(NodeDriver):
     name = "Google Compute Engine"
     type = Provider.GCE
     website = 'https://cloud.google.com/'
+    features = {'create_node': ['ssh_key']}
 
     # Google Compute Engine node states are mapped to Libcloud node states
     # per the following dict. GCE does not have an actual 'stopped' state
@@ -3995,7 +3998,7 @@ class GCENodeDriver(NodeDriver):
             ex_on_host_maintenance=None, ex_automatic_restart=None,
             ex_preemptible=None, ex_image_family=None, ex_labels=None,
             ex_accelerator_type=None, ex_accelerator_count=None,
-            ex_disk_size=None, **kwargs):
+            ex_disk_size=None, auth=None):
         """
         Create a new node and return a node object for the node.
 


[libcloud] 04/06: Clarify the need to install an SSH key.

Posted by to...@apache.org.
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 b49ed7e953ecacc35d42953245e7a95ee72b374c
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Fri Dec 20 23:13:44 2019 +0100

    Clarify the need to install an SSH key.
---
 docs/examples/compute/gce/deploy_node.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/docs/examples/compute/gce/deploy_node.py b/docs/examples/compute/gce/deploy_node.py
index 44f547d..9ea4cab 100644
--- a/docs/examples/compute/gce/deploy_node.py
+++ b/docs/examples/compute/gce/deploy_node.py
@@ -39,7 +39,13 @@ 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]
 
 # NOTE: We specify which public key is installed on the instance using
-# metadata functionality
+# metadata functionality.
+# Keep in mind that this step is only needed if you want to install a specific
+# key which is used to run the deployment script.
+# If you are using a VM image with a public SSH key already pre-baked in or if
+# you use project wide ssh-keys GCP functionality, you can remove ex_metadata
+# argument, but you still need to make sure the private key you use inside this
+# script matches the one which is installed / available on the server.
 ex_metadata = metadata = {
     'items': [
         {


[libcloud] 01/06: Merge branch 'gce-deploy-node-fix' of https://github.com/yukw777/libcloud into yukw777-gce-deploy-node-fix

Posted by to...@apache.org.
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 218baa26795ed231571c5b982edde9868c94f240
Merge: 7d95ff6 ea0502a
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Fri Dec 20 22:30:25 2019 +0100

    Merge branch 'gce-deploy-node-fix' of https://github.com/yukw777/libcloud into yukw777-gce-deploy-node-fix

 libcloud/compute/drivers/gce.py | 57 +----------------------------------------
 1 file changed, 1 insertion(+), 56 deletions(-)



[libcloud] 05/06: Add changelog entry.

Posted by to...@apache.org.
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 eea7c32ba79106ddd98d0010327afe02a44de37f
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Fri Dec 20 23:20:27 2019 +0100

    Add changelog entry.
---
 CHANGES.rst | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/CHANGES.rst b/CHANGES.rst
index 838e826..756e70b 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -61,6 +61,14 @@ Compute
   (GITHUB-1389)
   [Tomaz Muraus]
 
+- [GCE] Update ``deploy_node()`` method so it complies with the base compute
+  API and accepts ``deploy`` argument.
+
+  This method now also takes all the same keyword arguments which original
+  ``create_node()`` takes.
+  (GITHUB-1387)
+  [Peter Yu - @yukw777, Tomaz Muraus]
+
 Storage
 -------