当前位置: 首页>>代码示例>>Python>>正文


Python SR.driver方法代码示例

本文整理汇总了Python中SR.driver方法的典型用法代码示例。如果您正苦于以下问题:Python SR.driver方法的具体用法?Python SR.driver怎么用?Python SR.driver使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SR的用法示例。


在下文中一共展示了SR.driver方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load

# 需要导入模块: import SR [as 别名]
# 或者: from SR import driver [as 别名]
    def load(self, sr_uuid):
        driver = SR.driver('iscsi')
        self.iscsi = driver(self.original_srcmd, sr_uuid)

        # User must specify a LUN ID(s) for adding to the VG
        if not self.dconf.has_key('LUNid') or  not self.dconf['LUNid']:
            raise xs_errors.XenError('ConfigLUNIDMissing')
        self.dconf['device'] = os.path.join(self.iscsi.path,"LUN%s" % \
                               self.dconf['LUNid'])

        if not self.iscsi.attached:
            # Must attach SR here in order to load VG
            self.iscsi.attach(sr_uuid)
        super(EXToISCSISR, self).load(sr_uuid)
开发者ID:JohnGarbutt,项目名称:xcp-storage-managers,代码行数:16,代码来源:EXToISCSISR.py

示例2: load

# 需要导入模块: import SR [as 别名]
# 或者: from SR import driver [as 别名]
    def load(self, sr_uuid):
        driver = SR.driver('hba')
        self.hbasr = driver(self.original_srcmd, sr_uuid)

        pbd = None
        try:
            pbd = util.find_my_pbd(self.session, self.host_ref, self.sr_ref)
        except:
            pass

        if not self.dconf.has_key('SCSIid') or not self.dconf['SCSIid']:
            print >>sys.stderr,self.hbasr.print_devs()
            raise xs_errors.XenError('ConfigSCSIid')

        self.SCSIid = self.dconf['SCSIid']
        self._pathrefresh(OCFSoHBASR)
        super(OCFSoHBASR, self).load(sr_uuid)
开发者ID:Sisimon,项目名称:sm,代码行数:19,代码来源:OCFSoHBASR.py

示例3: load

# 需要导入模块: import SR [as 别名]
# 或者: from SR import driver [as 别名]
    def load(self, sr_uuid):
        driver = SR.driver('hba')
        if 'type' not in self.original_srcmd.params['device_config'] or \
                'type' in self.original_srcmd.params['device_config'] and \
                self.original_srcmd.dconf['type'] == "any":
            self.original_srcmd.dconf['type'] = "fcoe"
        self.hbasr = driver(self.original_srcmd, sr_uuid)
        pbd = None
        try:
            pbd = util.find_my_pbd(self.session, self.host_ref, self.sr_ref)
        except:
            pass

        if not self.dconf.has_key('SCSIid') or not self.dconf['SCSIid']:
            print >>sys.stderr, self.hbasr.print_devs()
            raise xs_errors.XenError('ConfigSCSIid')

        self.SCSIid = self.dconf['SCSIid']
        self._pathrefresh(LVHDoFCoESR)
        LVHDSR.LVHDSR.load(self, sr_uuid)
开发者ID:letsboogey,项目名称:sm,代码行数:22,代码来源:LVHDoFCoESR.py

示例4: load

# 需要导入模块: import SR [as 别名]
# 或者: from SR import driver [as 别名]
    def load(self, sr_uuid):
        driver = SR.driver('hba')
        self.hbasr = driver(self.original_srcmd, sr_uuid)

        # If this is a vdi command, don't initialise SR
        if not (util.isVDICommand(self.original_srcmd.cmd)):
            pbd = None
            try:
                pbd = util.find_my_pbd(self.session, self.host_ref, self.sr_ref)
            except:
                pass

            try:
                if not self.dconf.has_key('SCSIid') and self.dconf.has_key('device'):
                    # UPGRADE FROM MIAMI: add SCSIid key to device_config
                    util.SMlog("Performing upgrade from Miami")
                    if not os.path.exists(self.dconf['device']):
                        raise xs_errors.XenError('InvalidDev')
                    SCSIid = scsiutil.getSCSIid(self.dconf['device'])
                    self.dconf['SCSIid'] = SCSIid
                    del self.dconf['device']

                    if pbd <> None:
                        device_config = self.session.xenapi.PBD.get_device_config(pbd)
                        device_config['SCSIid'] = SCSIid
                        device_config['upgraded_from_miami'] = 'true'
                        del device_config['device']
                        self.session.xenapi.PBD.set_device_config(pbd, device_config)
            except:
                pass

            if not self.dconf.has_key('SCSIid') or not self.dconf['SCSIid']:
                print >>sys.stderr,self.hbasr.print_devs()
                raise xs_errors.XenError('ConfigSCSIid')

        self.SCSIid = self.dconf['SCSIid']
        self._pathrefresh(LVHDoHBASR, load = False)
        LVHDSR.LVHDSR.load(self, sr_uuid)
开发者ID:chandrikas,项目名称:sm,代码行数:40,代码来源:LVHDoHBASR.py

示例5: load

# 需要导入模块: import SR [as 别名]
# 或者: from SR import driver [as 别名]
    def load(self, sr_uuid):
        if not sr_uuid:
            # This is a probe call, generate a temp sr_uuid
            sr_uuid = util.gen_uuid()

        driver = SR.driver('iscsi')
        self.iscsi = driver(self.original_srcmd, sr_uuid)

        # Be extremely careful not to throw exceptions here since this function
        # is the main one used by all operations including probing and creating
        pbd = None
        try:
            pbd = util.find_my_pbd(self.session, self.host_ref, self.sr_ref)
        except:
            pass
        
        if not self.dconf.has_key('SCSIid') and self.dconf.has_key('LUNid') and pbd <> None:
            # UPGRADE FROM RIO: add SCSIid key to device_config
            util.SMlog("Performing upgrade from Rio")
            scsiid = self._getSCSIid_from_LUN(sr_uuid)
            
            device_config = self.session.xenapi.PBD.get_device_config(pbd)
            device_config['SCSIid'] = scsiid
            device_config['upgraded_from_rio'] = 'true'
            self.session.xenapi.PBD.set_device_config(pbd, device_config)

            self.dconf['SCSIid'] = scsiid            

        # Apart from the upgrade case, user must specify a SCSIid
        if not self.dconf.has_key('SCSIid'):
            self._LUNprint(sr_uuid)
            raise xs_errors.XenError('ConfigSCSIid')

        self.SCSIid = self.dconf['SCSIid']
        self._pathrefresh(LVMoISCSISR)

        super(LVMoISCSISR, self).load(sr_uuid)
开发者ID:JohnGarbutt,项目名称:xcp-storage-managers,代码行数:39,代码来源:LVMoISCSISR.py

示例6: main

# 需要导入模块: import SR [as 别名]
# 或者: from SR import driver [as 别名]
def main():
    command = SRCommand.SRCommand()
    command.parse("")

    if not command.type:
        raise SRCommand.SRInvalidArgumentException( \
                                'missing driver type argument: -t <type>')
    if not command.dconf:
        raise SRCommand.SRInvalidArgumentException('missing dconf string')
    if not command.cmdname:
        raise SRCommand.SRInvalidArgumentException('missing command')
    if not command.sr_uuid:
        raise SRCommand.SRInvalidArgumentException('missing SR UUID')
    if command.cmdtype == 'vdi' and not command.vdi_uuid:
        raise SRCommand.SRInvalidArgumentException('missing VDI UUID')
    if not command.cmd:
        raise SRCommand.SRInvalidArgumentException('unknown command')
    if command.args is None:
        raise SRCommand.SRInvalidArgumentException('wrong number of arguments')

    driver = SR.driver(command.type)
    sr = driver(command.dconf, command.sr_uuid)

    command.run(sr)
开发者ID:JohnGarbutt,项目名称:xcp-storage-managers,代码行数:26,代码来源:sm.py

示例7: load

# 需要导入模块: import SR [as 别名]
# 或者: from SR import driver [as 别名]
    def load(self, sr_uuid):
        driver = SR.driver("hba")
        self.hbasr = driver(self.original_srcmd, sr_uuid)

        pbd = None
        try:
            pbd = util.find_my_pbd(self.session, self.host_ref, self.sr_ref)
        except:
            pass

        try:
            if not self.dconf.has_key("SCSIid") and self.dconf.has_key("device"):
                # UPGRADE FROM MIAMI: add SCSIid key to device_config
                util.SMlog("Performing upgrade from Miami")
                if not os.path.exists(self.dconf["device"]):
                    raise
                SCSIid = scsiutil.getSCSIid(self.dconf["device"])
                self.dconf["SCSIid"] = SCSIid
                del self.dconf["device"]

                if pbd <> None:
                    device_config = self.session.xenapi.PBD.get_device_config(pbd)
                    device_config["SCSIid"] = SCSIid
                    device_config["upgraded_from_miami"] = "true"
                    del device_config["device"]
                    self.session.xenapi.PBD.set_device_config(pbd, device_config)
        except:
            pass

        if not self.dconf.has_key("SCSIid") or not self.dconf["SCSIid"]:
            print >>sys.stderr, self.hbasr.print_devs()
            raise xs_errors.XenError("ConfigSCSIid")

        self.SCSIid = self.dconf["SCSIid"]
        self._pathrefresh(LVMoHBASR)
        super(LVMoHBASR, self).load(sr_uuid)
开发者ID:jonludlam,项目名称:xcp-storage-managers,代码行数:38,代码来源:LVMoHBASR.py

示例8: load

# 需要导入模块: import SR [as 别名]
# 或者: from SR import driver [as 别名]
    def load(self, sr_uuid):
        if not sr_uuid:
            # This is a probe call, generate a temp sr_uuid
            sr_uuid = util.gen_uuid()

        driver = SR.driver('iscsi')
        if self.original_srcmd.dconf.has_key('target'):
            self.original_srcmd.dconf['targetlist'] = self.original_srcmd.dconf['target']
        iscsi = driver(self.original_srcmd, sr_uuid)
        self.iscsiSRs = []
        self.iscsiSRs.append(iscsi)
        
        if self.dconf['target'].find(',') == 0 or self.dconf['targetIQN'] == "*":
            # Instantiate multiple sessions
            self.iscsiSRs = []
            if self.dconf['targetIQN'] == "*":
                IQN = "any"
            else:
                IQN = self.dconf['targetIQN']
            dict = {}
            IQNstring = ""
            IQNs = []
            try:
                if self.dconf.has_key('multiSession'):
                    IQNs = self.dconf['multiSession'].split("|")
                    for IQN in IQNs:
                        if IQN:
                            dict[IQN] = ""
                        else:
                            try:
                                IQNs.remove(IQN)
                            except:
                                # Exceptions are not expected but just in case
                                pass
                    # Order in multiSession must be preserved. It is important for dual-controllers.
                    # IQNstring cannot be built with a dictionary iteration because of this
                    IQNstring = self.dconf['multiSession']
                else:
                    for tgt in self.dconf['target'].split(','):
                        try:
                            tgt_ip = util._convertDNS(tgt)
                        except:
                            raise xs_errors.XenError('DNSError')
                        iscsilib.ensure_daemon_running_ok(iscsi.localIQN)
                        map = iscsilib.discovery(tgt_ip,iscsi.port,iscsi.chapuser,iscsi.chappassword,targetIQN=IQN)
                        util.SMlog("Discovery for IP %s returned %s" % (tgt,map))
                        for i in range(0,len(map)):
                            (portal,tpgt,iqn) = map[i]
                            (ipaddr, port) = iscsilib.parse_IP_port(portal)
                            try:
                                util._testHost(ipaddr, long(port), 'ISCSITarget')
                            except:
                                util.SMlog("Target Not reachable: (%s:%s)" % (ipaddr, port))
                                continue
                            key = "%s,%s,%s" % (ipaddr,port,iqn)
                            dict[key] = ""
                # Again, do not mess up with IQNs order. Dual controllers will benefit from that
                if IQNstring == "":
                    # Compose the IQNstring first
                    for key in dict.iterkeys(): IQNstring += "%s|" % key
                    # Reinitialize and store iterator
                    key_iterator = dict.iterkeys()
                else:
                    key_iterator = IQNs

                # Now load the individual iSCSI base classes
                for key in key_iterator:
                    (ipaddr,port,iqn) = key.split(',')
                    srcmd_copy = copy.deepcopy(self.original_srcmd)
                    srcmd_copy.dconf['target'] = ipaddr
                    srcmd_copy.dconf['targetIQN'] = iqn
                    srcmd_copy.dconf['multiSession'] = IQNstring
                    util.SMlog("Setting targetlist: %s" % srcmd_copy.dconf['targetlist'])
                    self.iscsiSRs.append(driver(srcmd_copy, sr_uuid))
                pbd = util.find_my_pbd(self.session, self.host_ref, self.sr_ref)
                if pbd <> None and not self.dconf.has_key('multiSession'):
                    dconf = self.session.xenapi.PBD.get_device_config(pbd)
                    dconf['multiSession'] = IQNstring
                    self.session.xenapi.PBD.set_device_config(pbd, dconf)
            except:
                util.logException("LVHDoISCSISR.load")
        self.iscsi = self.iscsiSRs[0]

        # Be extremely careful not to throw exceptions here since this function
        # is the main one used by all operations including probing and creating
        pbd = None
        try:
            pbd = util.find_my_pbd(self.session, self.host_ref, self.sr_ref)
        except:
            pass

        # Apart from the upgrade case, user must specify a SCSIid
        if not self.dconf.has_key('SCSIid'):
            # Dual controller issue
            self.LUNs = {}  # Dict for LUNs from all the iscsi objects
            for ii in range(0, len(self.iscsiSRs)):
                self.iscsi = self.iscsiSRs[ii]
                self._LUNprint(sr_uuid)
                for key in self.iscsi.LUNs:
                    self.LUNs[key] = self.iscsi.LUNs[key]
#.........这里部分代码省略.........
开发者ID:pritha-srivastava,项目名称:sm,代码行数:103,代码来源:LVHDoISCSISR.py

示例9: load

# 需要导入模块: import SR [as 别名]
# 或者: from SR import driver [as 别名]
    def load(self, sr_uuid):
        if not sr_uuid:
            # This is a probe call, generate a temp sr_uuid
            sr_uuid = util.gen_uuid()

        driver = SR.driver('iscsi')
        if self.original_srcmd.dconf.has_key('target'):
            self.original_srcmd.dconf['targetlist'] = self.original_srcmd.dconf['target']
        iscsi = driver(self.original_srcmd, sr_uuid)
        self.iscsiSRs = []
        self.iscsiSRs.append(iscsi)
        
        if self.dconf['target'].find(',') == 0 or self.dconf['targetIQN'] == "*":
            # Instantiate multiple sessions
            self.iscsiSRs = []
            if self.dconf['targetIQN'] == "*":
                IQN = "any"
            else:
                IQN = self.dconf['targetIQN']
            dict = {}
            try:
                if self.dconf.has_key('multiSession'):
                    IQNs = self.dconf['multiSession'].split("|")
                    for IQN in IQNs:
                        if IQN:
                            dict[IQN] = ""
                else:                    
                    for tgt in self.dconf['target'].split(','):
                        try:
                            tgt_ip = util._convertDNS(tgt)
                        except:
                            raise xs_errors.XenError('DNSError')
                        iscsilib.ensure_daemon_running_ok(iscsi.localIQN)
                        map = iscsilib.discovery(tgt_ip,iscsi.port,iscsi.chapuser,iscsi.chappassword,targetIQN=IQN)
                        util.SMlog("Discovery for IP %s returned %s" % (tgt,map))
                        for i in range(0,len(map)):
                            (portal,tpgt,iqn) = map[i]
                            (ipaddr,port) = portal.split(',')[0].split(':')
                            key = "%s,%s,%s" % (ipaddr,port,iqn)
                            dict[key] = ""
                # Compose the IQNstring first
                IQNstring = ""
                for key in dict.iterkeys(): IQNstring += "%s|" % key

                # Now load the individual iSCSI base classes
                for key in dict.iterkeys():
                    (ipaddr,port,iqn) = key.split(',')
                    srcmd_copy = copy.deepcopy(self.original_srcmd)
                    srcmd_copy.dconf['target'] = ipaddr
                    srcmd_copy.dconf['targetIQN'] = iqn
                    srcmd_copy.dconf['multiSession'] = IQNstring
                    util.SMlog("Setting targetlist: %s" % srcmd_copy.dconf['targetlist'])
                    self.iscsiSRs.append(driver(srcmd_copy, sr_uuid))
                pbd = util.find_my_pbd(self.session, self.host_ref, self.sr_ref)
                if pbd <> None and not self.dconf.has_key('multiSession'):
                    dconf = self.session.xenapi.PBD.get_device_config(pbd)
                    dconf['multiSession'] = IQNstring
                    self.session.xenapi.PBD.set_device_config(pbd, dconf)
            except:
                util.logException("LVHDoISCSISR.load")
        self.iscsi = self.iscsiSRs[0]

        # Be extremely careful not to throw exceptions here since this function
        # is the main one used by all operations including probing and creating
        pbd = None
        try:
            pbd = util.find_my_pbd(self.session, self.host_ref, self.sr_ref)
        except:
            pass
        
        if not self.dconf.has_key('SCSIid') and self.dconf.has_key('LUNid') and pbd <> None:
            # UPGRADE FROM RIO: add SCSIid key to device_config
            util.SMlog("Performing upgrade from Rio")
            scsiid = self._getSCSIid_from_LUN(sr_uuid)
            
            device_config = self.session.xenapi.PBD.get_device_config(pbd)
            device_config['SCSIid'] = scsiid
            device_config['upgraded_from_rio'] = 'true'
            self.session.xenapi.PBD.set_device_config(pbd, device_config)

            self.dconf['SCSIid'] = scsiid            

        # Apart from the upgrade case, user must specify a SCSIid
        if not self.dconf.has_key('SCSIid'):
            self._LUNprint(sr_uuid)
            raise xs_errors.XenError('ConfigSCSIid')

        self.SCSIid = self.dconf['SCSIid']
        self._pathrefresh(LVHDoISCSISR)

        LVHDSR.LVHDSR.load(self, sr_uuid)
开发者ID:JohnGarbutt,项目名称:xcp-storage-managers,代码行数:93,代码来源:LVHDoISCSISR.py


注:本文中的SR.driver方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。