List as metadata value after gcloud update

714 views
Skip to first unread message

Rodrigo Borges

unread,
Jul 7, 2015, 10:10:15 AM7/7/15
to gce-dis...@googlegroups.com
Hello,


whats is the best way to use a instance metadata value as a list using commas?

I think i can't understand this document as i should: https://cloud.google.com/sdk/gcloud/reference/topic/escaping

Log history:

i was used to create instances with metadata as list using commas like this:

gcloud compute instances create --metadata key1="value" key2=myValue  key3=valueIndex1,valueIndex2,valueIndex3 key4=value4

So I had a metadata key3 with  "valueIndex1,valueIndex2,valueIndex3" as value.

After the last update I was told to run as a list of metadata using commas and my list doesn't work anymore.

So, i read about "gcloud topic escaping" and tried to use something like this:

--metadata ^:^ key1="value":key2=myValue:key3=valueIndex1,valueIndex2,valueIndex3

Which i found very confusing and still give warnings saying that I should use commas.

So I tried (replacing my old comma-separated list from commas to ";" ) :

--metadata key1="value",key2=myValue,key3=valueIndex1;valueIndex2;valueIndex3,key4=value4

Which was horrible because gcloud tried to execute my key3 values as bash commands. So I believe i'm doing something wrong as it should be very simple.

Can you help me please?


Alex Martelli

unread,
Jul 7, 2015, 2:02:08 PM7/7/15
to Rodrigo Borges, gce-dis...@googlegroups.com
No, it's not gcloud -- it's bash itself, taking non-quoted semicolons as command separators.

So just use (single) quotes:

--metadata key1="value",key2=myValue,key3='valueIndex1;valueIndex2;valueIndex3,key4=value4'
 
So I believe i'm doing something wrong as it should be very simple.

Yes, it just needs understanding Unix-like shells, such as bash -- which often is *not* very simple, although I fully agree it *should* be. But it's not really a GCE-specific problem.
 

Can you help me please?

There are many online tutorials on bash quoting, such as http://www.linuxjournal.com/content/bash-quoting and http://bash.cyberciti.biz/guide/Quoting 

HTH,

Alex



--
© 2014 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-dis...@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to the Google Groups "gce-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gce-discussio...@googlegroups.com.
To post to this group, send email to gce-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gce-discussion/a51e7e8c-b707-488c-818b-4d9fa24fbcab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted

Kamran (Google Cloud Support)

unread,
Jul 7, 2015, 2:09:07 PM7/7/15
to gce-dis...@googlegroups.com, rodrigo...@mendelics.com.br
Hello Rodrigo,

--metadata is an ArgDict argument, which means it expects an argument of the form '--metadata key1=value1,key2=value2'. 
To get around this, you can specify an alternate delimiter (as opposed to a comma) using the following syntax: '^FOO^key1=value1FOOkey2=value2' 

In your case the following command should work:

$ gcloud compute instances create inst2 --metadata ^:^key1="value":key2=myValue:key3=valueIndex1,valueIndex2,valueIndex3:key4=value4


Please make sure that you're using the latest version of the Cloud SDK. To update your Cloud SDK use the command below:

$ gcloud components update


Sincerely,

Kamran

Rodrigo Borges

unread,
Jul 7, 2015, 4:02:57 PM7/7/15
to Kamran (Google Cloud Support), gce-dis...@googlegroups.com
Thank you Alex and Kamran,

Kamram,

I thought that i was missing something about "ArgDict"s (and i got confused messing up bash).

It would be nice to hear from the community how others work with a list of values in a metadata key.

Do you use a character as separator or other structure?

Best,
Rodrigo.



On Tue, Jul 7, 2015 at 3:09 PM, Kamran (Google Cloud Support) <khas...@google.com> wrote:
Hello Rodrigo,

--metadata is an ArgDict argument, which means it expects an argument of the form '--metadata key1=value1,key2=value2'. 
To get around this, you can specify an alternate delimiter (as opposed to a comma) using the following syntax: '^FOO^key1=value1FOOkey2=value2' 

In your case the following command should work:

$ gcloud compute instances create inst2 --metadata ^:^key1=value:key2=myValue:key3=valueIndex1,valueIndex2,valueIndex3


Please make sure that you're using the latest version of the Cloud SDK. To update your Cloud SDK use the command below:

$ gcloud components update


Sincerely,

Kamran



On Tuesday, July 7, 2015 at 10:10:15 AM UTC-4, Rodrigo Borges wrote:
Hello,


whats is the best way to use a instance metadata value as a list using commas?

I think i can't understand this document as i should: https://cloud.google.com/sdk/gcloud/reference/topic/escaping

Log history:

i was used to create instances with metadata as list using commas like this:

gcloud compute instances create --metadata key1="value" key2=myValue  key3=valueIndex1,valueIndex2,valueIndex3 key4=value4

So I had a metadata key3 with  "valueIndex1,valueIndex2,valueIndex3" as value.

After the last update I was told to run as a list of metadata using commas and my list doesn't work anymore.

So, i read about "gcloud topic escaping" and tried to use something like this:

--metadata ^:^ key1="value":key2=myValue:key3=valueIndex1,valueIndex2,valueIndex3

Which i found very confusing and still give warnings saying that I should use commas.

So I tried (replacing my old comma-separated list from commas to ";" ) :

--metadata key1="value",key2=myValue,key3=valueIndex1;valueIndex2;valueIndex3,key4=value4

Which was horrible because gcloud tried to execute my key3 values as bash commands. So I believe i'm doing something wrong as it should be very simple.

Can you help me please?


--
© 2014 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Compute Engine Discussion Google Group (gce-dis...@googlegroups.com) to participate in discussions with other members of the Google Compute Engine community and the Google Compute Engine Team.
---
You received this message because you are subscribed to a topic in the Google Groups "gce-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gce-discussion/Dr2opDrqDtU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gce-discussio...@googlegroups.com.

To post to this group, send email to gce-dis...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Rodrigo Lucena Borges

Bioinformata | Mendelics

Tel: +55 (11) 5096-6001 | E-mail: rodrigo...@mendelics.com.br

Rua Cubatão, 86, cj. 1602 | São Paulo, Brasil 04013-000

Reply all
Reply to author
Forward
0 new messages