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

Python util._testHost函数代码示例

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

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



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

示例1: attach

    def attach(self, sr_uuid):
        self.validate_remotepath(False)
        #self.remotepath = os.path.join(self.dconf['serverpath'], sr_uuid)
        self.remotepath = self.dconf['serverpath']

        util._testHost(self.dconf['server'], NFSPORT, 'NFSTarget')
        self.mount_remotepath(sr_uuid)
开发者ID:billysuh,项目名称:CloudStack,代码行数:7,代码来源:NFSSR.py


示例2: attach

 def attach(self, sr_uuid):
     if not self._checkmount():
         self.validate_remotepath(False)
         util._testHost(self.dconf['server'], NFSPORT, 'NFSTarget')
         io_timeout = util.get_nfs_timeout(self.session, sr_uuid)
         self.mount_remotepath(sr_uuid, io_timeout)
     self.attached = True
开发者ID:BobBall,项目名称:sm,代码行数:7,代码来源:NFSSR.py


示例3: _scan_IQNs

    def _scan_IQNs(self):
        # Verify iSCSI target and port
        util._testHost(self.target, self.port, 'ISCSITarget')

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

        map = iscsilib.discovery(self.target, self.port, self.chapuser, self.chappassword)
        map.append(("%s:%d" % (self.targetlist,self.port),"0","*"))
        self.print_entries(map)
开发者ID:JohnGarbutt,项目名称:xcp-storage-managers,代码行数:10,代码来源:ISCSISR.py


示例4: attach

 def attach(self, sr_uuid):
     if not self._checkmount():
         self.validate_remotepath(False)
         util._testHost(self.dconf['server'], NFSPORT, 'NFSTarget')
         #Extract timeout and retrans values, if any
         io_timeout = nfs.get_nfs_timeout(self.other_config)
         io_retrans = nfs.get_nfs_retrans(self.other_config)
         self.mount_remotepath(sr_uuid, timeout=io_timeout, 
                               retrans=io_retrans)
     self.attached = True
开发者ID:MarkSymsCtx,项目名称:sm,代码行数:10,代码来源:NFSSR.py


示例5: attach

    def attach(self, sr_uuid):
        dbg_prt("[rbdsr] attach")
        ### Getting MON list using admin key above
        ceph_mon_list_xml = self._getCEPH_response('ceph mon_status -f xml')
        ceph_mon_list = self._formatMON_list(ceph_mon_list_xml)
        
        # We got accurate list of monitor addresses, need pass that list of IPs to rbd add srting
        accurate_address_string = ''
        ''' TODO: very long list-to-string conversion, 
        should be something like: address_string = ''.join(ceph_mon_list).replace('\n',',') if len(ceph_mon_list) >= 1'''
        if len(ceph_mon_list) >= 1:
            address_string = ''
            for address in ceph_mon_list:
                address_string += address.replace('\n',',')
            self.dconf['targetlist'] = address_string[:-1]
            accurate_address_string = address_string[:-1]
        else:
            accurate_address_string = ceph_mon_list

        ### Getting admin key using ssh command
        if self.dconf.has_key('SCSIid') and self.dconf['SCSIid']:
            util._testHost(self.dconf['target'].split(',')[0], long(self.dconf['port']), 'RBD Monitor')
            rbd_auth_output =  self._getCEPH_response('ceph auth list| grep admin -A1| grep key')
            rbd_auth_key = self._formatCEPH_key(rbd_auth_output)
            
            rbd_image_name = self.dconf['SCSIid']
            dbg_prt("[rbdsr] rbd image name: %s",rbd_image_name)
            attach_string = '%s name=admin,secret=%s %s %s' % (accurate_address_string, rbd_auth_key, self.dconf['targetIQN'], rbd_image_name)
            if not os.path.exists('/sys/bus/rbd'):
                os.execlp("modprobe", "modprobe", "rbd")
            rbd_disk_path =  '/dev/disk/by-id/scsi-%s' % rbd_image_name
            rbd_scsi_path =  '/dev/disk/by-scsid/%s' % rbd_image_name
            rbd_block_index = self._getRBD_index(rbd_image_name)
            if not os.path.exists(rbd_disk_path) and not rbd_block_index:
                dbg_prt("[rbdsr] add rbd device begin:")
                try:
                    rbd_add = open('/sys/bus/rbd/add','w')
                    rbd_add.write(attach_string)
                    rbd_add.close() 
                    rbd_image_index = str(self._getRBD_index(rbd_image_name))
                    os.symlink('/dev/rbd%s' % rbd_image_index , rbd_disk_path)
                    os.makedirs(rbd_scsi_path)
                    os.symlink('../../../rbd%s' % rbd_image_index, '%s/rbd%s' % (rbd_scsi_path,rbd_image_index))
                    self.attached = True
                except IOError, e:
                    util.SMlog('the error is %s' % e)
                    self.attached = False
            else:
                dbg_prt("[rbdsr] rbd_disk_path:%s , rbd_block_index:%s",rbd_disk_path,rbd_block_index)
开发者ID:zhoubofsy,项目名称:rbdsr,代码行数:49,代码来源:RBDSR.py


示例6: create

    def create(self, sr_uuid, size):
        util._testHost(self.dconf['server'], NFSPORT, 'NFSTarget')
        self.validate_remotepath(True)
        if self._checkmount():
            raise xs_errors.XenError('NFSAttached')

        # Set the target path temporarily to the base dir
        # so that we can create the target SR directory
        self.remotepath = self.dconf['serverpath']
        try:
            self.mount_remotepath(sr_uuid)
        except Exception, exn:
            try:
                os.rmdir(self.path)
            except:
                pass
            raise exn
开发者ID:Accelerite,项目名称:cloudstack,代码行数:17,代码来源:NFSSR.py


示例7: probe

    def probe(self):
        # Verify NFS target and port
        util._testHost(self.dconf['server'], NFSPORT, 'NFSTarget')
        
        self.validate_remotepath(True)
        self.check_server()

        temppath = os.path.join(SR.MOUNT_BASE, PROBE_MOUNTPOINT)

        self.mount(temppath, self.dconf['serverpath'])
        try:
            return nfs.scan_srlist(temppath)
        finally:
            try:
                nfs.unmount(temppath, True)
            except:
                pass
开发者ID:Accelerite,项目名称:cloudstack,代码行数:17,代码来源:NFSSR.py


示例8: 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


示例9: attach

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

        npaths=0
        if not self.attached:
            # 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) = val.split(':')
                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):
                try:
                    map = iscsilib.discovery(self.target, self.port, self.chapuser, \
                                             self.chappassword, targetIQN=self.targetIQN)
                    iqn = ''
                    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) = portal.split(',')[0].split(':')
                            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)
                            npaths = npaths + 1
                        except:
                            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)
            self.attached = True
开发者ID:JohnGarbutt,项目名称:xcp-storage-managers,代码行数:61,代码来源:ISCSISR.py


示例10: attach

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

        npaths=0
        if not self.attached:
            # 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):
                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,
                                                  self._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)
                            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) == 'ISCSI login failed, verify CHAP credentials':
                                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:fudong1127,项目名称:sm,代码行数:76,代码来源:ISCSISR.py


示例11: attach

 def attach(self, sr_uuid):
     self.validate_remotepath(False)
     self.remotepath = os.path.join(self.dconf['serverpath'], sr_uuid)
     util._testHost(self.dconf['server'], NFSPORT, 'NFSTarget')
     io_timeout = util.get_nfs_timeout(self.session, sr_uuid)
     self.mount_remotepath(sr_uuid, io_timeout)
开发者ID:GaryKirkpatrick,项目名称:sm,代码行数:6,代码来源:NFSSR.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python util._uintify函数代码示例发布时间:2022-05-27
下一篇:
Python util._symbol函数代码示例发布时间: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