Skip to content

Conversation

@alexbleotu
Copy link
Contributor

What does this PR do?

Adds 3 states and all required dependencies (+ a missing external VSAN library from VMware) to be used with the esxcluster proxy to configure a VMware cluster, rename the cluster's datastore, assign a VSAN license to the cluster

Functions added:

State functions:

  • cluster_configured state to create/manage ESX clusters
  • vsan_datastore_configured esxcluster state that renames the vSan datastore on a cluster
  • licenses_configured state that checks the the VSAN licenses are added to the vCenter and

Execution functions

  • salt.modules.vspere.list_datastores_via_proxy that returns a list of datastore representations
  • salt.modules.vspere.rename_datastore that renames a datastore
  • salt.modules.vsphere.list_licenses that lists all licenses on a vCenter
  • salt.modules.vsphere.add_license
  • salt.modules.vsphere._get_entity that describes a cluster and a vcenter
  • salt.modules.vsphere._validate_entity that validates a cluster and a vcenter description
  • salt.modules.vsphere.list_assigned_licenses that list the licenses assigned to an entity
  • salt.modules.vsphere.assign_license that assigns a license to an entity

Utils functions:

  • salt.utils.vmware.get_storage_system that retrieves an ESXi host's storage system
  • salt.utils.vmware.get_datastores which returns a list of vim.Datastore objects
  • salt.utils.vmware.rename_datastore
  • salt.utils.vmware.get_license_manager
  • salt.utils.vmware.get_license_assignment_manager
  • salt.utils.vmware.get_licenses
  • salt.utils.vmware.add_license
  • salt.utils.vmware.get_assigned_licenses
  • salt.utils.vmware.assign_license

Tests written?

Yes (utils functions only)

Please review Salt's Contributing Guide for best practices.

Alexandru Bleotu added 30 commits September 20, 2017 06:24
…s in a configuration dictionary to a cluster spec
…rding to spec, including VSAN configuration
…tastore objects

- can retrieve the datastores visible to the root folder, a datacenter,
  a cluster and an ESXi host
- can filter on datastore name and backing disk id (the latter, only if it is
  a VMFS datastore and the reference is an ESXi host)
…st of datastore representations

- can filter on datastore name, backing disk id,
  backing_disk_scsi_addresses (the last two only apply to VMFS datastore
  and if the proxy ``esxi`` - pointing to an an ESXi host)
@ghost
Copy link

ghost commented Sep 20, 2017

@alexbleotu, thanks for your PR! By analyzing the history of the files in this pull request, we identified @rallytime, @cro and @s0undt3ch to be potential reviewers.

Copy link
Contributor

@cachedout cachedout left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic! Let's start with the pylint fixes and then we'll start reviewing this in-depth. Thanks @alexbleotu!

https://jenkins.saltstack.com/job/PR/job/salt-pr-lint-n/14781/violations/

Copy link
Contributor

@cachedout cachedout left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is one of the best PRs I've seen in a long while. Great job, @alexbleotu. Just a few small comments in-line.

admission_control_policy = AdmissionControlPolicyItem()
default_vm_settings = DefaultVmSettingsItem()
hb_ds_candidate_policy = StringItem(
title='Hartbeat Datastore Candidate Policy',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heartbeat?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

Python 2.7.9, or newer must be present. This is due to an upstream dependency
in pyVmomi 6.0 that is not supported in Python versions 2.7 to 2.7.8. If the
version of Python is not in the supported range, you will need to install an
earlier version of pyVmomi. See `Issue #29537`_ for more information.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough but are we detecting this condition and warning the user at all? It's a bit much to ask them to read the docs here to determine what could be a very hard-to-detect condition. I wonder if we could improve this at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure how to do this though. The only thing I can think of is warnings in tests if there is an incompatibility, but there is no guarantee that everyone will run the tests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we detect this in __virtual__() and return False, 'State module did not load: Incompatible versions of Python and pyVmomi present', or something along those lines?

Also, this is minor, but I think the mention of Python 2.6 can be removed to reduce potential confusion. Support for Python 2.6 in salt has been removed as of the 2017.7.0 release.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to. This needs to happen in all states though and the vsphere execution module. I will add it in this one to esxcluster and I will create a separate PR to fix the rest

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I have a change - not as trivial as expected. Testing it out now. Question is if we should add it in the state files or just in the vsphere execution module where pyVmomi is actually used. @rallytime, @cachedout what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok did both. Let's see if the tests pass. From what I remember they don't actually test the __virtual__ function

WARNING: vsan datastores will not exist until there is at least on host in
the cluster; the state assumes that the datastore exists and errors out if i
it doesn't; it's up to the user to accept the error or enable the state run
when de datastore does exist (grain: vsan_datastore_exists)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

de? the perhaps?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are several typos; will fix ;)

@alexbleotu
Copy link
Contributor Author

#43674 depends on this

@cachedout
Copy link
Contributor

@rallytime Re-review please

Copy link
Contributor

@rallytime rallytime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done! And thank you for adding tests, too. :)

@cachedout cachedout merged commit 75dd97e into saltstack:develop Sep 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants