Adding Google Compute Engine integration #1159

Open
wants to merge 2 commits into
from

Projects

None yet

6 participants

@ziyadm

Adding Google Compute Engine driver, integration tests, and partial documentation.

@mfschwartz mfschwartz was assigned Dec 4, 2012
@mfschwartz
the boto project member
@mfschwartz
the boto project member
@mfschwartz
the boto project member
@scivm

I would like to see GCE capabilities in boto also. Is there a fork somewhere where this change was incorporated?

@freyes

@scivm , I encourage you to read new dependencies for initial Google Compute Engine support, but the short answer is there is no effort going on to have GCE support (as far as I know).

@danielgtaylor danielgtaylor commented on the diff Dec 11, 2013
boto/gce/connection.py
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# 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.
+
+import httplib2
+import os
+import boto
+
+from apiclient.discovery import build
@danielgtaylor
danielgtaylor Dec 11, 2013

Are these dependencies discussed anywhere? How does a GCE user know what to install along with boto to get all this working?

@danielgtaylor danielgtaylor commented on the diff Dec 11, 2013
boto/gce/connection.py
+
+ def get_all_instances(self):
+ """
+ Retrieve all the Google Compute Engine instances available to your
+ project.
+ """
+ list_gce_instances = self.service.instances().list(
+ project=self.gce_project).execute(http=self.http)
+
+ list_instances = []
+ for instance in list_gce_instances['items']:
+ list_instances.append(Instance(instance))
+
+ return list_instances
+
+ def run_instance(self, name=None, image_name=None, machine_type=None,
@danielgtaylor
danielgtaylor Dec 11, 2013

It would be nice to have an integration test of run_instance and terminate_instance alongside all the get* ones.

@danielgtaylor danielgtaylor commented on the diff Dec 11, 2013
boto/gce/connection.py
+ Retrieve all the Google Compute Engine instances available to your
+ project.
+ """
+ list_gce_instances = self.service.instances().list(
+ project=self.gce_project).execute(http=self.http)
+
+ list_instances = []
+ for instance in list_gce_instances['items']:
+ list_instances.append(Instance(instance))
+
+ return list_instances
+
+ def run_instance(self, name=None, image_name=None, machine_type=None,
+ zone_name=None):
+ """
+ Insert a Google Compute Engine instance into your cluster.
@danielgtaylor
danielgtaylor Dec 11, 2013

Docs are missing for image_name, machine_type and zone_name.

@danielgtaylor danielgtaylor commented on the diff Dec 11, 2013
boto/gce/connection.py
+with information from the APIs Console <https://code.google.com/apis/console>.
+
+""" % os.path.join(os.path.dirname(__file__), CLIENT_SECRETS)
+
+# Set up a Flow object to be used if we need to authenticate.
+FLOW = flow_from_clientsecrets(CLIENT_SECRETS,
+ scope='https://www.googleapis.com/auth/compute',
+ message=MISSING_CLIENT_SECRETS_MESSAGE)
+
+API_VERSION = 'v1beta13'
+
+
+class GCEConnection():
+ def __init__(self, gce_project):
+ """
+ Init method to create a new connection to Google Compute Engine.
@danielgtaylor
danielgtaylor Dec 11, 2013

Docs missing for gce_project

@danielgtaylor
the boto project member

This looks pretty good to me overall. It might be nice to have some unit tests though, particularly mocking out the apiclient.discovery.build step and making sure the right calls get made for e.g. run_instances.

@scivm
@remh remh commented on the diff Feb 11, 2014
boto/gce/connection.py
+ scope='https://www.googleapis.com/auth/compute',
+ message=MISSING_CLIENT_SECRETS_MESSAGE)
+
+API_VERSION = 'v1beta13'
+
+
+class GCEConnection():
+ def __init__(self, gce_project):
+ """
+ Init method to create a new connection to Google Compute Engine.
+ """
+ self.gce_project = gce_project
+ self.google_project = 'google'
+ self.storage = Storage('creds.dat')
+ self.credentials = self.storage.get()
+ self.default_network = "https://www.googleapis.com/compute/{0}/projects/
@remh
remh Feb 11, 2014

I think that should be in a single line (or use triple quoted string)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment