def check_pool_create_OS(conn, poolname, logger): """This function will check if the poolname mount location is really mounted by the OS or not. """ # we need to get where libvirt thinks the poolname is mounted to... poolobj = conn.storagePoolLookupByName(poolname) poolxml = poolobj.XMLDesc(0) # parse the xml to see where this is mounted... out = xml_parser.xml_parser().parse(poolxml) dest_path = out["target"]["path"] src_host = out["source"]["host"]["attr"]["name"] src_path = out["source"]["dir"]["attr"]["path"] logger.info("src host: %s src path: %s tgt path: %s" % \ (src_host, src_path, dest_path) ) fd = open("/proc/mounts","r") mount = src_host + ":" + src_path pat = mount + "/*\s+" + dest_path found = 0 for line in fd: if re.match(pat, line): found = 1 fd.close() if found: return True else: return False
def check_pool_create_OS(conn, poolname, logger): """This function will check if the poolname mount location is really mounted by the OS or not. """ # we need to get where libvirt thinks the poolname is mounted to... poolobj = conn.storagePoolLookupByName(poolname) poolxml = poolobj.XMLDesc(0) # parse the xml to see where this is mounted... out = xml_parser.xml_parser().parse(poolxml) dest_path = out["target"]["path"] src_host = out["source"]["host"]["attr"]["name"] src_path = out["source"]["dir"]["attr"]["path"] logger.info("src host: %s src path: %s tgt path: %s" % \ (src_host, src_path, dest_path) ) fd = open("/proc/mounts", "r") mount = src_host + ":" + src_path pat = mount + "/*\s+" + dest_path found = 0 for line in fd: if re.match(pat, line): found = 1 fd.close() if found: return True else: return False
def check_pool_create_OS(poolobj, logger): """Check the result of create storage pool on OS level. """ poolxml = poolobj.XMLDesc(0) out = xml_parser.xml_parser().parse(poolxml) src_path = out["source"]["device"]["attr"]["path"] dest_path = out["target"]["path"] logger.info("src path: %s tgt path: %s" % (src_path, dest_path)) pat = src_path + "\s+" + dest_path found = 0 fd = open("/proc/mounts","r") for line in fd: if re.match(pat, line): found = 1 fd.close() if found: return True else: return False
def execute(self, data_points): raw_xml_response = self.get_response(data_points) # print(raw_xml_response) return xml_parser().xml_to_json(raw_xml_response)