Exemplo n.º 1
0
def extract_vgname(str_in):
    """Search for and return a VG name

        Search 'str_in' for a substring in the form of 'VG_XenStorage-<UUID>'. 
        If there are more than one VG names, the first is returned.

        Input:
            str_in -- (str) string to search for a VG name
                            in the format specified above.

        Return:
            vgname -- if found     -> (str)
                      if not found -> None

        Raise:
            TypeError
    """

    if not util.is_string(str_in):
        raise TypeError("'str_in' not of type 'str'.")

    i = str_in.find(VG_PREFIX)
    prefix = VG_PREFIX

    if i == -1:
        i = str_in.find(EXT_PREFIX)
        prefix = EXT_PREFIX

    uuid_start = i + len(prefix)
    re_obj = util.match_uuid(str_in[uuid_start:])

    if i != -1 and re_obj:
        return prefix + re_obj.group(0) # vgname

    return None
Exemplo n.º 2
0
Arquivo: lvutil.py Projeto: xcp-ng/sm
def extract_vgname(str_in):
    """Search for and return a VG name

        Search 'str_in' for a substring in the form of 'VG_XenStorage-<UUID>'. 
        If there are more than one VG names, the first is returned.

        Input:
            str_in -- (str) string to search for a VG name
                            in the format specified above.

        Return:
            vgname -- if found     -> (str)
                      if not found -> None

        Raise:
            TypeError
    """

    if not util.is_string(str_in):
        raise TypeError("'str_in' not of type 'str'.")

    i = str_in.find(VG_PREFIX)
    prefix = VG_PREFIX

    if i == -1:
        i = str_in.find(EXT_PREFIX)
        prefix = EXT_PREFIX

    uuid_start = i + len(prefix)
    re_obj = util.match_uuid(str_in[uuid_start:])

    if i != -1 and re_obj:
        return prefix + re_obj.group(0)  # vgname

    return None
Exemplo n.º 3
0
    def attach(self, sr_uuid):
        if not util.match_uuid(sr_uuid) or not lvutil._checkVG(self.vgname):
            raise xs_errors.XenError('SRUnavailable', \
                  opterr='no such volume group: %s' % self.vgname)

        if self.isMaster:
            #Update SCSIid string
            util.SMlog("Calling devlist_to_serial")
            scsiutil.add_serial_record(self.session, self.sr_ref, \
                  scsiutil.devlist_to_serialstring(self.root.split(',')))
            
        # Set the block scheduler
        try:
            self.other_config = self.session.xenapi.SR.get_other_config(self.sr_ref)
            if self.other_config.has_key('scheduler') and self.other_config['scheduler'] != self.sched:
                self.sched = self.other_config['scheduler']
            for dev in self.root.split(','):
                realdev = os.path.realpath(dev)[5:]
                util.set_scheduler(realdev, self.sched)
        except:
            pass