Skip to content

Commit

Permalink
Merge pull request #1723 from kylazhang/get_controllers
Browse files Browse the repository at this point in the history
Add get_controllers func
  • Loading branch information
balamuruhans authored Jul 23, 2019
2 parents 0065e0a + 1cee6f9 commit c83ef12
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions virttest/libvirt_xml/vm_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,21 +554,30 @@ def del_controller(self, controller_type=None):
:return: None if deleting all controllers
"""
all_controllers = self.xmltreefile.findall("devices/controller")
del_controllers = []
for controller in all_controllers:
if controller.get("type") != controller_type:
continue
del_controllers.append(controller)

# no seclabel tag found in xml.
del_controllers = self.get_controllers(controller_type=controller_type)
if del_controllers == []:
logging.debug("Controller %s for this domain does not "
"exist" % controller_type)

for controller in del_controllers:
self.xmltreefile.remove(controller)

def get_controllers(self, controller_type=None):
"""
Get controllers according controller type
:param controller_type: type of controllers need to get
:return: controller list
"""
all_controllers = self.xmltreefile.findall("devices/controller")
type_controllers = []
for controller in all_controllers:
if controller.get("type") != controller_type:
continue
type_controllers.append(controller)
return type_controllers


class VMXML(VMXMLBase):

Expand Down

0 comments on commit c83ef12

Please sign in to comment.