From 2415e4eef6e2065c0f0f37def54a0829509911fb Mon Sep 17 00:00:00 2001 From: Pavan Bidkar Date: Mon, 15 May 2017 21:44:03 +0530 Subject: [PATCH] Sample is not failing if Cluster Name argument passed is not Valid.Assering Cluster presense in setup method instead of execution method (#23) Signed-off-by: Pavan Bidkar Sample is not failing with Clustername passed is not Valid. Validating Cluster presence in setup method instead of execution Signed-off-by: Pavan Bidkar --- samples/vsphere/tagging/tagging_workflow.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/samples/vsphere/tagging/tagging_workflow.py b/samples/vsphere/tagging/tagging_workflow.py index 1b9d40c6..ede4b894 100644 --- a/samples/vsphere/tagging/tagging_workflow.py +++ b/samples/vsphere/tagging/tagging_workflow.py @@ -97,6 +97,13 @@ class TaggingWorkflow(SampleBase): if self.servicemanager is None: self.servicemanager = self.get_service_manager() + # Sample is not failing if Clustername passed is not valid + # Validating if Cluster Name passed is Valid + print('finding the cluster {0}'.format(self.cluster_name)) + self.cluster_moid = get_cluster_id(service_manager=self.servicemanager, cluster_name=self.cluster_name) + assert self.cluster_moid is not None + print('Found cluster:{0} mo_id:{1}'.format(self.cluster_name, self.cluster_moid)) + self.category_svc = Category(self.servicemanager.stub_config) self.tag_svc = Tag(self.servicemanager.stub_config) self.tag_association = TagAssociation(self.servicemanager.stub_config) @@ -119,7 +126,8 @@ class TaggingWorkflow(SampleBase): print('No Tag Found...') print('creating a new tag category...') - self.category_id = self.create_tag_category(self.category_name, self.category_desc, CategoryModel.Cardinality.MULTIPLE) + self.category_id = self.create_tag_category(self.category_name, self.category_desc, + CategoryModel.Cardinality.MULTIPLE) assert self.category_id is not None print('Tag category created; Id: {0}'.format(self.category_id)) @@ -133,11 +141,6 @@ class TaggingWorkflow(SampleBase): self.update_tag(self.tag_id, 'Server Tag updated at ' + date_time) print('Tag updated; Id: {0}'.format(self.tag_id)) - print('finding the cluster {0}'.format(self.cluster_name)) - self.cluster_moid = get_cluster_id(service_manager=self.servicemanager, cluster_name=self.cluster_name) - assert self.cluster_moid is not None - print('Found cluster:{0} mo_id:{1}'.format('vAPISDKCluster', self.cluster_moid)) - print('Tagging the cluster {0}...'.format(self.cluster_name)) self.dynamic_id = DynamicID(type='ClusterComputeResource', id=self.cluster_moid) self.tag_association.attach(tag_id=self.tag_id, object_id=self.dynamic_id)