binbeobo / google-cloud-sdk

Automatically exported from code.google.com/p/google-cloud-sdk
0 stars 1 forks source link

Gcloud compute ssh $InstanceName should automatically work if $InstanceName is unique #412

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Issue running command [gcloud compute ssh].

What steps will reproduce the problem?
1). Create an instance with a name
2). issue the gcloud compute ssh [instance-name] command
3). Get prompted for a zone choice

What is the expected output? What do you see instead?
I expect to ssh to the uniquely named instance, or be prompted with a list of 
zones that actually contain instances with that name. Providing me a choice of 
13 zones when only one of them is correct is a briefly fun game of whack-a-mole

Please provide any additional information below.

Traceback (most recent call last):
  File "calliope/cli.py", line 609, in Execute
    result = args.cmd_func(cli=self, args=args)
  File "calliope/backend.py", line 1228, in Run
    resources = command_instance.Run(args)
  File "surface/compute/ssh.py", line 113, in Run
    external_ip_address = self.GetInstanceExternalIpAddress(instance_ref)
  File "api_lib/compute/ssh_utils.py", line 452, in GetInstanceExternalIpAddress
    error_message='Could not fetch instance:')
  File "api_lib/compute/utils.py", line 94, in RaiseToolException
    RaiseException(problems, calliope_exceptions.ToolException, error_message)
  File "api_lib/compute/utils.py", line 106, in RaiseException
    errors))
ToolException: Could not fetch instance:
 - The resource 'projects/arms-length/zones/asia-east1-a/instances/development' was not found

Installation information:

Google Cloud SDK [0.9.89]

Platform: [Mac OS X, x86_64]
Python Version: [2.7.10 (default, Jul 14 2015, 19:46:27)  [GCC 4.2.1 Compatible 
Apple LLVM 6.0 (clang-600.0.39)]]
Python Location: [/usr/bin/python]
Site Packages: [Disabled]

Installation Root: [/Users/huber/google-cloud-sdk]
Installed Components:
  core: [2015.11.30]
  core-nix: [2015.11.24]
  gcloud: []
  gsutil-nix: [4.15]
  beta: [2015.10.08]
  gsutil: [4.16]
  bq: [2.0.18]
  bq-nix: [2.0.18]
[output truncated]

Original issue reported on code.google.com by michael....@gmail.com on 3 Dec 2015 at 5:42

GoogleCodeExporter commented 8 years ago
Thanks for your feedback. We are currently working on implementing this feature.

In the meantime, note that you can auto-complete the instance name, which will 
also include the zone flag for you.

For example, assuming you had an uniquely named instance 'hello' in zone 
'world'.

gcloud compute ssh hel[TAB]

Will auto-complete to:

gcloud compute ssh hello --zone world

If there is no unique completion, it will show you all the options.

Original comment by vil...@google.com on 3 Dec 2015 at 6:34

GoogleCodeExporter commented 8 years ago

Original comment by vil...@google.com on 3 Dec 2015 at 6:34

GoogleCodeExporter commented 8 years ago
Issue 413 has been merged into this issue.

Original comment by vil...@google.com on 3 Dec 2015 at 6:36

GoogleCodeExporter commented 8 years ago
Weirdly enough, when I try to tab-complete gcloud compute ssh development 
--zone [tab], it doesn't tab complete out the zone, but it will perform 
correctly while typing the vm name.

Should I file a separate bug for that?

Original comment by michael....@gmail.com on 3 Dec 2015 at 6:40

GoogleCodeExporter commented 8 years ago
Thank you for the additional feedback.

Did you try typing [tab] twice? That is:

gcloud compute ssh development --zone [tab][tab]

If you are not providing a sufficiently long prefix, you need to press tab 
multiple times to obtain all the completion options. This is usual 
auto-completion behavior.

Also note that an instance is identified by the (name, zone) pair. So 
auto-complete completes them together. A zone however is auto-completed from 
the list of all zones. This is similar to the prompt that asks you to pick a 
zone.

Original comment by vil...@google.com on 3 Dec 2015 at 8:16

GoogleCodeExporter commented 8 years ago
If I tab twice, it lists all zones, rather than all zones which have an 
instance named 'development', or simply completing the entire command for me.

It seems odd that tab completion will complete out the --zone command while 
tabbing in the name of the instance, but not the zone when I've already fully 
specified. At the same time, I don't fully understand the internals of how the 
tab-completion is working, and what those constraints are.

Original comment by michael....@gmail.com on 3 Dec 2015 at 9:18

GoogleCodeExporter commented 8 years ago
Auto-complete completes a particular resource. 

An instance is a special resource that requires its zone to be identified. So 
while completing instances, the zone is completed as well. 

A zone on the other hand does not need an instance to be identified, so its 
completion is based on the list of all zones.

Original comment by vil...@google.com on 3 Dec 2015 at 9:41

trivigy commented 7 years ago

Has anyone resolved the tab-complete issue? Used to work for me and doesn't work anymore. Would love some insight into potential solutions.