• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python util.find_my_pbd函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中util.find_my_pbd函数的典型用法代码示例。如果您正苦于以下问题:Python find_my_pbd函数的具体用法?Python find_my_pbd怎么用?Python find_my_pbd使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: detach

    def detach(self, sr_uuid):
        keys = []
        pbdref = None
        try:
            pbdref = util.find_my_pbd(self.session, self.host_ref, self.sr_ref)
        except:
            pass
        if self.dconf.has_key("SCSIid"):
            self.mpathmodule.reset(self.dconf["SCSIid"], True)  # explicitly unmap
            keys.append("mpath-" + self.dconf["SCSIid"])

        # Remove iscsi_sessions and multipathed keys
        if pbdref <> None:
            if self.cmd == "sr_detach":
                keys += ["multipathed", "iscsi_sessions", "MPPEnabled"]
            for key in keys:
                try:
                    self.session.xenapi.PBD.remove_from_other_config(pbdref, key)
                except:
                    pass

        if util._decr_iscsiSR_refcount(self.targetIQN, sr_uuid) != 0:
            return

        if self.direct and util._containsVDIinuse(self):
            return

        if iscsilib._checkTGT(self.targetIQN):
            try:
                iscsilib.logout(self.target, self.targetIQN, all=True)
            except util.CommandException, inst:
                raise xs_errors.XenError("ISCSIQueryDaemon", opterr="error is %d" % inst.code)
            if iscsilib._checkTGT(self.targetIQN):
                raise xs_errors.XenError("ISCSIQueryDaemon", opterr="Failed to logout from target")
开发者ID:heiden-deng,项目名称:sm,代码行数:34,代码来源:ISCSISR.py


示例2: _synchroniseAddrList

 def _synchroniseAddrList(self, addrlist):
     if not self.multihomed:
         return
     change = False
     if not self.dconf.has_key('multihomelist'):
         change = True
         self.mlist = []
         mstr = ""
     else:
         self.mlist = self.dconf['multihomelist'].split(',')
         mstr = self.dconf['multihomelist']
     for val in addrlist:
         if not val in self.mlist:
             self.mlist.append(val)
             if len(mstr):
                 mstr += ","
             mstr += val
             change = True
     if change:
         pbd = None
         try:
             pbd = util.find_my_pbd(self.session, self.host_ref, self.sr_ref)
             if pbd <> None:
                 device_config = self.session.xenapi.PBD.get_device_config(pbd)
                 device_config['multihomelist'] = mstr
                 self.session.xenapi.PBD.set_device_config(pbd, device_config)
         except:
             pass
开发者ID:JohnGarbutt,项目名称:xcp-storage-managers,代码行数:28,代码来源:ISCSISR.py


示例3: _reset_pbd_other_config

 def _reset_pbd_other_config(self):
     try:
         pbd_ref = util.find_my_pbd(self.session, self.host_ref, self.sr_ref)
     except:
         util.SMlog("No pbd for sr_ref %s on host_ref %s" % (sr_ref, host_ref))
     for key in ["multipathed"]:
         try:
             self.session.xenapi.PBD.remove_from_other_config(pbd_ref, key)
         except:
             util.SMlog("remove_from_other_config failed")
开发者ID:GaryKirkpatrick,项目名称:sm,代码行数:10,代码来源:RawHBASR.py


示例4: _add_pbd_other_config

 def _add_pbd_other_config(self, key, value):
     try:
         pbd_ref = util.find_my_pbd(self.session, self.host_ref, self.sr_ref)
     except:
         util.SMlog("No pbd for sr_ref %s on host_ref %s" % (sr_ref, host_ref))
         return
     try:
         self.session.xenapi.PBD.add_to_other_config(pbd_ref, key, value)
     except:
         util.SMlog("add_to_other_config failed")
开发者ID:GaryKirkpatrick,项目名称:sm,代码行数:10,代码来源:RawHBASR.py


示例5: detach

 def detach(self, sr_uuid):
     LVHDSR.LVHDSR.detach(self, sr_uuid)
     self.mpathmodule.reset(self.SCSIid,True,True) # explicit_unmap
     try:
         pbdref = util.find_my_pbd(self.session, self.host_ref, self.sr_ref)
     except:
         pass
     for key in ["mpath-" + self.SCSIid, "multipathed", "MPPEnabled"]:
         try:
             self.session.xenapi.PBD.remove_from_other_config(pbdref, key)
         except:
             pass
开发者ID:letsboogey,项目名称:sm,代码行数:12,代码来源:LVHDoHBASR.py


示例6: create

    def create(self, sr_uuid, size):
        # Check SCSIid not already in use by other PBDs
        if util.test_SCSIid(self.session, sr_uuid, self.SCSIid):
            raise xs_errors.XenError('SRInUse')

        self.iscsi.attach(sr_uuid)
        try:
            if not self.iscsi._attach_LUN_bySCSIid(self.SCSIid):
                # UPGRADE FROM GEORGE: take care of ill-formed SCSIid
                upgraded = False
                matchSCSIid = False
                for file in filter(self.iscsi.match_lun, util.listdir(self.iscsi.path)):
                    path = os.path.join(self.iscsi.path,file)
                    if not util.wait_for_path(path, ISCSISR.MAX_TIMEOUT):
                        util.SMlog("Unable to detect LUN attached to host [%s]" % path)
                        continue
                    try:
                        SCSIid = scsiutil.getSCSIid(path)
                    except:
                        continue
                    try:
                        matchSCSIid = scsiutil.compareSCSIid_2_6_18(self.SCSIid, path)
                    except:
                        continue
                    if (matchSCSIid):
                        util.SMlog("Performing upgrade from George")
                        try:
                            pbd = util.find_my_pbd(self.session, self.host_ref, self.sr_ref)
                            device_config = self.session.xenapi.PBD.get_device_config(pbd)
                            device_config['SCSIid'] = SCSIid
                            self.session.xenapi.PBD.set_device_config(pbd, device_config)

                            self.dconf['SCSIid'] = SCSIid            
                            self.SCSIid = self.dconf['SCSIid']
                        except:
                            continue
                        if not self.iscsi._attach_LUN_bySCSIid(self.SCSIid):
                            raise xs_errors.XenError('InvalidDev')
                        else:
                            upgraded = True
                            break
                    else:
                        util.SMlog("Not a matching LUN, skip ... scsi_id is: %s" % SCSIid)
                        continue
                if not upgraded:
                    raise xs_errors.XenError('InvalidDev')
            self._pathrefresh(LVHDoISCSISR)
            LVHDSR.LVHDSR.create(self, sr_uuid, size)
        except Exception, inst:
            self.iscsi.detach(sr_uuid)
            raise xs_errors.XenError("SRUnavailable", opterr=inst)
开发者ID:pritha-srivastava,项目名称:sm,代码行数:51,代码来源:LVHDoISCSISR.py


示例7: load

    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,代码行数:17,代码来源:OCFSoHBASR.py


示例8: load

    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,代码行数:20,代码来源:LVHDoFCoESR.py


示例9: load

    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,代码行数:38,代码来源:LVHDoHBASR.py


示例10: load

    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,代码行数:37,代码来源:LVMoISCSISR.py


示例11: load

    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,代码行数:36,代码来源:LVMoHBASR.py


示例12: load

    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,代码行数:101,代码来源:LVHDoISCSISR.py


示例13: len

                if len(iqn): IQNs += iqn.split(',')[2]
        else:
            IQNs.append(self.targetIQN)
        sessions = 0
        paths = iscsilib.get_IQN_paths()
        for path in paths:
            try:
                if util.get_single_entry(os.path.join(path, 'targetname')) in IQNs:
                    sessions += 1
                    util.SMlog("IQN match. Incrementing sessions to %d" % sessions)
            except:
                util.SMlog("Failed to read targetname path," \
                           + "iscsi_sessions value may be incorrect")

        try:
            pbdref = util.find_my_pbd(self.session, self.host_ref, self.sr_ref)
            if pbdref <> None:
                other_conf = self.session.xenapi.PBD.get_other_config(pbdref)
                other_conf['iscsi_sessions'] = str(sessions)
                self.session.xenapi.PBD.set_other_config(pbdref, other_conf)
        except:
            pass

        if self.mpath == 'true' and self.dconf.has_key('SCSIid'):
            self.mpathmodule.refresh(self.dconf['SCSIid'],npaths)
            # set the device mapper's I/O scheduler
            self.block_setscheduler('/dev/disk/by-scsid/%s/mapper'
                    % self.dconf['SCSIid'])


    def detach(self, sr_uuid):
开发者ID:fudong1127,项目名称:sm,代码行数:31,代码来源:ISCSISR.py


示例14: load

    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,代码行数:91,代码来源:LVHDoISCSISR.py


示例15: attach

    def attach(self, sr_uuid):
        self._mpathHandle()

        multiTargets=False

        npaths=0
        try:
            pbdref = util.find_my_pbd(self.session, self.host_ref, self.sr_ref)
            if pbdref:
                other_config = self.session.xenapi.PBD.get_other_config(pbdref)
                multiTargets = util.sessions_less_than_targets(other_config, self.dconf)
        except:
            pass

        if not self.attached or multiTargets:
            # Verify iSCSI target and port
            if self.dconf.has_key('multihomelist') and not self.dconf.has_key('multiSession'):
                targetlist = self.dconf['multihomelist'].split(',')
            else:
                targetlist = ['%s:%d' % (self.target,self.port)]
            conn = False
            for val in targetlist:
                (target, port) = iscsilib.parse_IP_port(val)
                try:
                    util._testHost(target, long(port), 'ISCSITarget')
                    self.target = target
                    self.port = long(port)
                    conn = True
                    break
                except:
                    pass
            if not conn:
                raise xs_errors.XenError('ISCSITarget')

            # Test and set the initiatorname file
            iscsilib.ensure_daemon_running_ok(self.localIQN)

            # Check to see if auto attach was set
            if not iscsilib._checkTGT(self.targetIQN) or multiTargets:
                try:
                    map = []
                    if 'any' != self.targetIQN:
                        try:
                            map = iscsilib.get_node_records(self.targetIQN)
                        except:
                            # Pass the exception that is thrown, when there
                            # are no nodes
                            pass
                    if len(map) == 0:
                        map = iscsilib.discovery(self.target, self.port,
                                                  self.chapuser, self.chappassword,
                                                  self.targetIQN,
                                                  iscsilib.get_iscsi_interfaces())
                    if len(map) == 0:
                        self._scan_IQNs()
                        raise xs_errors.XenError('ISCSIDiscovery', 
                                                 opterr='check target settings')
                    for i in range(0,len(map)):
                        (portal,tpgt,iqn) = map[i]
                        try:
                            (ipaddr, port) = iscsilib.parse_IP_port(portal)
                            if not self.multihomed and ipaddr != self.target:
                                continue
                            util._testHost(ipaddr, long(port), 'ISCSITarget')
                            util.SMlog("Logging in to [%s:%s]" % (ipaddr,port))
                            iscsilib.login(portal, iqn, self.chapuser,
                                           self.chappassword,
                                           self.incoming_chapuser,
                                           self.incoming_chappassword,
                                           self.mpath == "true")
                            npaths = npaths + 1
                        except Exception, e:
                            # Exceptions thrown in login are acknowledged, 
                            # the rest of exceptions are ignored since some of the
                            # paths in multipath may not be reachable
                            if str(e).startswith('ISCSI login'): 
                                raise
                            else:
                                pass

                    if not iscsilib._checkTGT(self.targetIQN):
                        raise xs_errors.XenError('ISCSIDevice', \
                                                 opterr='during login')
                
                    # Allow the devices to settle
                    time.sleep(5)
                
                except util.CommandException, inst:
                    raise xs_errors.XenError('ISCSILogin', \
                                             opterr='code is %d' % inst.code)
开发者ID:chandrikas,项目名称:sm,代码行数:90,代码来源:BaseISCSI.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.finishWindow函数代码示例发布时间:2022-05-27
下一篇:
Python util.filechunkiter函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap