Skip to content

Commit c6a786e

Browse files
committed
fixed a bug that occured when dvswitch is directly under the datacenter.
1 parent 99c04cf commit c6a786e

7 files changed

Lines changed: 17 additions & 14 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,5 @@ develop.cmd
8181
*.zip
8282
debug.xml
8383
debug_info.txt
84+
/package/package
85+
/package/version.txt

kill_python.bat

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
@echo off
2+
::taskkill /im python.exe /f
3+
wmic Path win32_process Where "CommandLine Like '%%\\ExecutionServer\\%%python.exe%%'" Call Terminate
4+
wmic Path win32_process Where "CommandLine Like '%%\\ProgramData\\QualiSystems\\%%python.exe%%'" Call Terminate

package/cloudshell/cp/vcenter/common/vcenter/model_auto_discovery.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,8 @@ def _validate_datacenter(self, si, all_item_in_vc, auto_att, attributes):
116116
def _validate_default_dvswitch(self, si, all_items_in_vc, auto_att, dc_name, attributes, key):
117117

118118
dvs_path = attributes[key]
119-
120-
path, name = get_path_and_name(dvs_path)
121-
path = "{}/{}".format(dc_name, path)
122-
dv = self.pv_service.find_dvs_by_name(si, path, name)
123-
124-
if not dv:
125-
raise ValueError('Could not find Default DvSwitch {0} in path {1}'.format(name, path))
119+
path = "{}/{}".format(dc_name, dvs_path)
120+
dv = self.pv_service.find_dvs_by_path(si, path)
126121

127122
auto_att.append(AutoLoadAttribute('', DEFAULT_DVSWITCH, dvs_path))
128123

package/cloudshell/cp/vcenter/common/vcenter/vmomi_service.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,16 +222,18 @@ def find_obj_by_path(self, si, path, name, type_name):
222222
'#searches for the specific vm in the folder'
223223
return search_index.FindChild(look_in, name)
224224

225-
def find_dvs_by_name(self,si ,path, name):
225+
def find_dvs_by_path(self,si ,path):
226226
"""
227227
Finds vm in the vCenter or returns "None"
228-
229228
:param si: pyvmomi 'ServiceInstance'
230229
:param path: the path to find the object ('dc' or 'dc/folder' or 'dc/folder/folder/etc...')
231-
:param name: the dvSwitch name to return
232230
"""
231+
dvs = self.get_folder(si, path)
233232

234-
dvs = self.find_obj_by_path(si, path, name, '') # empty type_name, will resolve with ChildEntity
233+
if not dvs:
234+
raise ValueError('Could not find Default DvSwitch in path {0}'.format(path))
235+
elif not isinstance(dvs, vim.dvs.VmwareDistributedVirtualSwitch):
236+
raise ValueError('The object in path {0} is {1} and not a DvSwitch'.format(path, type(dvs)))
235237

236238
return dvs
237239

package/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.9.0
1+
1.9.0.99

vcentershell_driver/drivermetadata.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Driver Description="this driver manage all the commands that runs at the vcenter context" MainClass="driver.VCenterShellDriver" Name="VCenter Driver" Version="1.9.0">
1+
<Driver Description="this driver manage all the commands that runs at the vcenter context" MainClass="driver.VCenterShellDriver" Name="VCenter Driver" Version="1.9.0.99">
22
<Layout>
33
<Category Name="Deployment">
44
<Command Description="" DisplayName="Deploy From Template" EnableCancellation="true" Name="deploy_from_template" Tags="allow_unreserved" />

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.9.0
1+
1.9.0.99

0 commit comments

Comments
 (0)