vcd-cli icon indicating copy to clipboard operation
vcd-cli copied to clipboard

Handle multiple connections more gracefully

Open jondwaite opened this issue 7 years ago • 4 comments

Enhancement Request:

Right now if I login to 2 vCloud endpoints (clouda.provider.com and cloudb.provider.com) in separate sessions, the output from vcd-cli commands (e.g. vcd vdc list) shows only vdcs from the most recently logged in session (cloudb.provider.com).

e.g. Terminal Window #1 - login to clouda.provider.com Terminal Window #2 - login to cloudb.provider.com Terminal Window #1 - vcd vdc list - gets back the list of VDCs in cloudb.provider.com

Ideally vcd-cli should be able to cope gracefully with multiple connections and list all resources from all available connections (similar to how Connect-CIServer behaves in PowerCLI).

For bonus points - if the providers are linked in a vCD v9.x Multi Site configuration where the orgs are paired it would be great to be able to operate on both linked sites with a single login (e.g. vcd login to clouda.provider.com which is linked to cloudb.provider.com and have commands able to see/operate against resources in both endpoints).

Not sure how much work is involved in this, as the static/global single session ID would need to become an array of connected endpoints (so I suspect it is non-trivial), but would save a lot of confusion for those of us working with multiple connected endpoints.

jondwaite avatar Mar 15 '18 23:03 jondwaite

@jondwaite, thanks for filing this issue. This issue is pretty high up my list as well but didn't make it into the list of items for the vCD 9.1 release. One side effect of the behavior you describe is that a script running in one window can silently change the context of a script running in another window.

You are right that the work is not trivial but I don't think it's terribly hard either. The key problem is to pick a design for figuring out which command uses a particular session without requiring complex management on the part of users. The basic behavior we have now is convenient--you can keep the same session across commands, but it creates this other problem of deciding how to track multiple sessions.

Can you give an example showing Connect-CIServer behavior at the command line that you would like to see? This would be helpful to work out a model everyone likes.

hodgesrm avatar Mar 15 '18 23:03 hodgesrm

Hi Robert, thanks for the response.

I've included a transcript below showing a session against my 2 lab vcloud endpoints (akl-cloud.vcandev.local and chc-cloud.vcandev.local) showing the type of behavior it would be nice to replicate in vcd-cli. Note that although my test organisation ('Tyrell corporation') is configured with multi-site, I still have to connect to both endpoints individually currently. Hopefully this gives a good idea - if you need more information let me know.

1) Connect to first endpoint:
PS C:\> Connect-CIServer -Server akl-cloud.vcandev.local -Org Tyrell

Name                           User                           Org
----                           ----                           ---
akl-cloud.vcandev.local        administrator                  Tyrell

2) List vApps in AKL cloud:
PS C:\> Get-CIVApp

Name                           Enabled InMaintenanceMode    Owner
----                           ------- -----------------    -----
akl-dc01                       True    False                system
akl-k8s                        True    False                administrator

3) Connect to second endpoint:
PS C:\> Connect-CIServer -Server chc-cloud.vcandev.local -Org Tyrell

Name                           User                           Org
----                           ----                           ---
chc-cloud.vcandev.local        administrator                  Tyrell

4) Get vApp list (vApps in BOTH sites returned):
PS C:\> Get-CIVapp

Name                           Enabled InMaintenanceMode    Owner
----                           ------- -----------------    -----
chc-dc01                       True    False                system
chc-k8s                        True    False                administrator
akl-dc01                       True    False                system
chc-nfs01                      True    False                administrator
chc-rds01                      True    False                system
akl-k8s                        True    False                administrator

5) Get vApp list but limit scope to only CHC site:
PS C:\> Get-CIVapp -Server chc-cloud.vcandev.local

Name                           Enabled InMaintenanceMode    Owner
----                           ------- -----------------    -----
chc-dc01                       True    False                system
chc-k8s                        True    False                administrator
chc-nfs01                      True    False                administrator
chc-rds01                      True    False                system

6) Get List of VDCs (returns all VDCs in both connected sites):
PS C:\> Get-OrgVdc

Name                           Enabled CpuUsedGHz      MemoryUsedGB    StorageUsedGB   AllocationModel
----                           ------- ----------      ------------    -------------   ---------------
Tyrell-AKL-Allocated           True    0.00 (0.0%)     20.000 (31.3%)  164.000 (16.4%) AllocationPool
Tyrell-CHC-Allocated           True    14.00 (70.0%)   30.000 (46.9%)  346.773 (34.7%) AllocationPool

7) Get OrgVDC Networks (returns networks in both connected sites):
PS C:\> Get-OrgVdcNetwork

Name                           OrgVdc                         DefaultGateway  NetworkType
----                           ------                         --------------  -----------
Tyrell-CHC                     Tyrell-CHC-Allocated           172.16.1.1      Routed
Tyrell-AKL                     Tyrell-AKL-Allocated           172.16.2.1      Routed

8) Get OrgVDC Networks and limit scope to AKL site only:
PS C:\> Get-OrgVdcNetwork -Server akl-cloud.vcandev.local

Name                           OrgVdc                         DefaultGateway  NetworkType
----                           ------                         --------------  -----------
Tyrell-AKL                     Tyrell-AKL-Allocated           172.16.2.1      Routed

9) Show the $DefaultCIServers Global variable:
PS C:\> $DefaultCIServers

Name                           User                           Org
----                           ----                           ---
chc-cloud.vcandev.local        administrator                  Tyrell
akl-cloud.vcandev.local        administrator                  Tyrell

10) Properties of the $DefaultCIServers array:
PS C:\> $DefaultCIServers[0].IsConnected
True
PS C:\> $DefaultCIServers[0].SessionId
57d98dd4cbc84954aee80a3176660dad

11) Disconnect from one of the sites:
PS C:\> Disconnect-CIServer -Server akl-cloud.vcandev.local -Confirm:$false

12) List all vApps - shows only those from the surviving connection (chc-cloud):
PS C:\> Get-CIVApp

Name                           Enabled InMaintenanceMode    Owner
----                           ------- -----------------    -----
chc-dc01                       True    False                system
chc-k8s                        True    False                administrator
chc-nfs01                      True    False                administrator
chc-rds01                      True    False                system

13) Disconnect all (wildcard) connections:
PS C:\> Disconnect-CIServer * -Confirm:$false

jondwaite avatar Mar 16 '18 08:03 jondwaite

Thanks @jondwaite, that's a very helpful example. Here's a question: if you open a second powershell window are the connections visible?

hodgesrm avatar Mar 16 '18 15:03 hodgesrm

Hi @hodgesrm, other powershell windows have no visibility of the connected sessions - the connections and $DefaultCIServers array only exist in the original terminal session.

jondwaite avatar Mar 17 '18 02:03 jondwaite