Browse Source

Admin util for validating VC clusters

Add operation check-compute-clusters to validate
whether required clusters are present on VC

Change-Id: Ib1a00014bc0fcbda34e97bdd73422ea8cb2197e1
changes/25/792525/1
Salvatore Orlando 4 weeks ago
committed by Salvatore Orlando
parent
commit
1598598bee
2 changed files with 38 additions and 1 deletions
  1. +35
    -0
      vmware_nsx/shell/admin/plugins/nsxv/resources/config.py
  2. +3
    -1
      vmware_nsx/shell/resources.py

+ 35
- 0
vmware_nsx/shell/admin/plugins/nsxv/resources/config.py View File

@ -12,10 +12,14 @@
# License for the specific language governing permissions and limitations
# under the License.
import sys
from neutron_lib.callbacks import registry
from oslo_config import cfg
from oslo_log import log as logging
from oslo_vmware import vim_util
from vmware_nsx.dvs import dvs
from vmware_nsx.plugins.nsx_v.vshield.common import exceptions
from vmware_nsx.shell.admin.plugins.common import constants
from vmware_nsx.shell.admin.plugins.common import utils as admin_utils
@ -39,6 +43,37 @@ def validate_configuration(resource, event, trigger, **kwargs):
LOG.info("Configuration validation succeeded")
def check_clusters(resource, event, trigger, **kwargs):
clusters_str = ""
if kwargs.get('property'):
properties = admin_utils.parse_multi_keyval_opt(kwargs['property'])
clusters_str = properties.get('clusters', None)
if not clusters_str:
LOG.error("No cluster to look for was specified")
return
clusters = clusters_str.split(",")
mgr = dvs.VCManagerBase()
session = mgr.get_vc_session()
data = session.invoke_api(vim_util, 'get_objects', session.vim,
'ClusterComputeResource', 100)
while data:
for item in data.objects:
if item.obj.value in clusters[:]:
clusters.remove(item.obj.value)
data = vim_util.continue_retrieval(session.vim, data)
if not clusters:
LOG.info("Clusters %s found on VC backend", clusters_str)
else:
LOG.error("Clusters %s not found on VC backend", ",".join(clusters))
sys.exit(1)
registry.subscribe(validate_configuration,
constants.CONFIG,
shell.Operations.VALIDATE.value)
registry.subscribe(check_clusters,
constants.CONFIG,
shell.Operations.CHECK_COMPUTE_CLUSTERS.value)

+ 3
- 1
vmware_nsx/shell/resources.py View File

@ -78,6 +78,7 @@ class Operations(enum.Enum):
UPDATE_TIER0 = 'update-tier0'
UPDATE_FIREWALL_MATCH = 'update-nat-firewall-match'
SET_STATUS_ERROR = 'set-status-error'
CHECK_COMPUTE_CLUSTERS = 'check-compute-clusters'
ops = [op.value for op in Operations]
@ -246,7 +247,8 @@ nsxv_resources = {
[Operations.NSX_LIST.value,
Operations.NSX_CLEAN.value]),
constants.CONFIG: Resource(constants.CONFIG,
[Operations.VALIDATE.value]),
[Operations.VALIDATE.value,
Operations.CHECK_COMPUTE_CLUSTERS.value]),
constants.BGP_GW_EDGE: Resource(constants.BGP_GW_EDGE,
[Operations.CREATE.value,
Operations.DELETE.value,


Loading…
Cancel
Save