[colug-432] Google Cloud Compute API
Chris Punches
punches.chris at gmail.com
Sun May 27 22:06:21 EDT 2018
Why wouldn't it be by zone? Surely production and preproduction are
separated, among other things, by a zone tag
On Sun, May 27, 2018 at 10:01 PM, Rick Hornsby <richardjhornsby at gmail.com>
wrote:
>
> I’m trying to figure out the Google Cloud API, specifically the Python
> library.
>
> I have a shell script that works using `gcloud compute …` commands, but
> I’ve been asked to add some functionality. At this point, I’m going to move
> it to Python for the additional structure/objects/data types etc. (My
> options are shell or Python.)
>
> With the `gcloud` shell command, specifying a zone is optional. This works
> great for the shell script. I don’t care about the zone, I just need to
> iterate over all the instances in a project. However, it seems that with
> the library/API approach, zone is _not_ optional[1]. This would leave me
> with the very bad position of having to get a list of all zones (that’s
> doable), iterating over each zone looking for instances.
>
> The python API so far looks to me like a bit of a second class pile of
> nonsense that probably (very) loosely wraps around something else. For
> example, you have to create the resource type objects from two strings,
> like so:
>
> crm = googleapiclient.discovery.build('cloudresourcemanager', ‘v1')
> compute = googleapiclient.discovery.build('compute', ‘v1’)
>
> Get the list of projects?
>
> projects = crm.projects().list().execute()['projects']
>
> Get the project’s instances?
>
> compute.instances().list(project=‘projectid',
> zone='us-central1-?').execute()
>
> Am I missing something, especially w/r/t the zone is optional vs required
> depending on your gcloud vs python lib? Is there a better Python library
> than the one that Google provides?
>
> Thanks!
>
> [1] https://cloud.google.com/compute/docs/reference/rest/
> beta/instances/list
>
>
> _______________________________________________
> colug-432 mailing list
> colug-432 at colug.net
> http://lists.colug.net/mailman/listinfo/colug-432
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.colug.net/pipermail/colug-432/attachments/20180527/05e726e1/attachment.html
More information about the colug-432
mailing list