chef / knife-vsphere

Chef knife plug-in for VMware vSphere
Apache License 2.0
202 stars 125 forks source link

clusters and pools not interchangeable in knife vsphere vm find #345

Open match-garricklinn opened 7 years ago

match-garricklinn commented 7 years ago

What are you trying to do and what's not working?

We don't currently have any resource pools in vcenter, we do have clusters, but knife vsphere vm find demands that a pool be specified and does not take a cluster in place of a pool.

Please paste the command and output (run with -VV). Don't forget to X out any passwords or sensitive information

TX1-GLINN03ML:ma_siteserver garrick.linn$ knife vsphere vm find --pool "Production/Production-DA" --match-name "DA3SHWL021" -VV
INFO: Using configuration from /Users/garrick.linn/Documents/chef/automate-match/.chef/knife.rb
DEBUG: value for config item vsphere_host: da0shas000
DEBUG: value for config item vsphere_path: /sdk
DEBUG: value for config item vsphere_port: 443
DEBUG: value for config item vsphere_nossl:
DEBUG: value for config item vsphere_user: xxxxxx
DEBUG: value for config item vsphere_pass: xxx
DEBUG: value for config item vsphere_pass: xxx
DEBUG: value for config item vsphere_pass: xxx
DEBUG: value for config item vsphere_insecure: true
DEBUG: value for config item proxy_host:
DEBUG: value for config item proxy_port:
DEBUG: value for config item vsphere_dc: Clearview
Pool Production/Production-DA not found
TX1-GLINN03ML:ma_siteserver garrick.linn$

Other details, such as gem version and if you're working with a Linux or Windows VM

Running OSX 10.12.1 on my laptop chef-provisioning-vsphere (0.10.0) fog-vsphere (1.7.0) knife-vsphere (1.2.24)

swalberg commented 7 years ago

Thanks for letting us know about this. I will have a look. The method that looks for the resource doesn't support the slashes. I'll need to do some debugging on my system.

swalberg commented 7 years ago

Hi sorry for the delay. I tested this against our two clusters on one vcenter, and a pool inside one of those clusters, and it worked:

knife vsphere vm find --pool xxx-Prod --match-name converter # cluster
knife vsphere vm find --pool xxx-Lower --match-name cheftest # cluster
knife vsphere vm find --pool infrastructure_testing --match-name firewall-centos-72-f7a7d77f # pool inside xxx-Lower

We talked a bit in slack... just wanted to confirm you did try --pool "Production-DA". Is there perhaps another object with that same name that we're getting confused on?

match-garricklinn commented 7 years ago

Hi Sean...apologies should be coming from my side, I got knocked out by the flu for a few days and then got caught up in other things.

Hmm...I did try a few variations on that, but no dice. (We do actually have a resource pool now for a redis cluster but that's the only one so far.) Interestingly, we DO have a cluster named Clearview-Build-Staging which isn't throwing the "not found" error when passed to --pool, although it doesn't currently have any VMs in it. Biggest difference I can see there is the lack of a slash in the cluster name, although that may be a red herring since (if I understand you correctly) you were able to specify a pool/cluster picked out from a cluster name containing a slash?

`

TX1-GLINN03ML:automate-match garrick.linn$ knife vsphere pool list Pool: Production/Production_Tier1-DA/Redis TX1-GLINN03ML:automate-match garrick.linn$ knife vsphere vm find --pool Production-DA --match-name "DA3PMWS101" Pool Production-DA not found TX1-GLINN03ML:automate-match garrick.linn$ knife vsphere vm find --pool Clearview-Build-Staging TX1-GLINN03ML:automate-match garrick.linn$`

rhadoo commented 7 years ago

Hi, Unfortunately i am running of a fork of an old version and i didn't get to push anything back to main since the initial commit a year ago. I think i have experienced the issue with the slashes and have that already fixed in our production, i will check that tomorrow and get back with a PR if so.

swalberg commented 7 years ago

Hey @garrickmatch no, I can't use a slash. The code takes the pool and recursively searches for a pool or cluster with that name. There are other commands inside the gem that will split the name up on slashes and follow the hierarchy -- the fully/qualified/path isn't actually sent to the API.

Can you attach a screenshot of your cluster either here or in DM in Slack?

swalberg commented 7 years ago

Thanks @rhadoo I'd love to see that!

rhadoo commented 7 years ago

Hi, Sorry for the late reply. It seems i have added a --pool-path flag, which makes --pool to be treated as path, going to find_pool() instead of traverse_folders_for_pool(). I don't think i have made any other change related to this. I will pull current and try to add these.

swalberg commented 7 years ago

That's a great way to maintain backwards compatibility. Thanks!