本文整理汇总了Python中SR.registerSR方法的典型用法代码示例。如果您正苦于以下问题:Python SR.registerSR方法的具体用法?Python SR.registerSR怎么用?Python SR.registerSR使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SR
的用法示例。
在下文中一共展示了SR.registerSR方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: match_lun
# 需要导入模块: import SR [as 别名]
# 或者: from SR import registerSR [as 别名]
element.appendChild(entry)
subentry = dom.createElement("UUID")
entry.appendChild(subentry)
textnode = dom.createTextNode(val)
subentry.appendChild(textnode)
subentry = dom.createElement("Target")
entry.appendChild(subentry)
textnode = dom.createTextNode(record['target'])
subentry.appendChild(textnode)
subentry = dom.createElement("TargetIQN")
entry.appendChild(subentry)
textnode = dom.createTextNode(record['targetIQN'])
subentry.appendChild(textnode)
return dom.toprettyxml()
def match_lun(self, s):
regex = re.compile("_")
if regex.search(s,0):
return False
regex = re.compile("LUN")
return regex.search(s, 0)
if __name__ == '__main__':
SRCommand.run(ISCSISR, DRIVER_INFO)
else:
SR.registerSR(ISCSISR)
示例2: attach_from_config
# 需要导入模块: import SR [as 别名]
# 或者: from SR import registerSR [as 别名]
self.sr.dconf['multipathhandle'] = self.sr.mpathhandle
dict['device_config'] = self.sr.dconf
dict['sr_uuid'] = sr_uuid
dict['vdi_uuid'] = vdi_uuid
dict['command'] = 'vdi_attach_from_config'
# Return the 'config' encoded within a normal XMLRPC response so that
# we can use the regular response/error parsing code.
config = xmlrpclib.dumps(tuple([dict]), "vdi_attach_from_config")
return xmlrpclib.dumps((config,), "", True)
def attach_from_config(self, sr_uuid, vdi_uuid):
util.SMlog("OCFSoHBAVDI.attach_from_config")
self.sr.hbasr.attach(sr_uuid)
if self.sr.mpath == "true":
self.sr.mpathmodule.refresh(self.sr.SCSIid,0)
try:
return self.attach(sr_uuid, vdi_uuid)
except:
util.logException("OCFSoHBAVDI.attach_from_config")
raise xs_errors.XenError('SRUnavailable', \
opterr='Unable to attach the heartbeat disk')
def match_scsidev(s):
regex = re.compile("^/dev/disk/by-id|^/dev/mapper")
return regex.search(s, 0)
if __name__ == '__main__':
SRCommand.run(OCFSoHBASR, DRIVER_INFO)
else:
SR.registerSR(OCFSoHBASR)
示例3: attach_from_config
# 需要导入模块: import SR [as 别名]
# 或者: from SR import registerSR [as 别名]
resp['device_config'] = self.sr.dconf
resp['sr_uuid'] = sr_uuid
resp['vdi_uuid'] = vdi_uuid
resp['command'] = 'vdi_attach_from_config'
# Return the 'config' encoded within a normal XMLRPC response so that
# we can use the regular response/error parsing code.
config = xmlrpclib.dumps(tuple([resp]), "vdi_attach_from_config")
return xmlrpclib.dumps((config,), "", True)
def attach_from_config(self, sr_uuid, vdi_uuid):
"""
Attach and activate a VDI using config generated by
vdi_generate_config above. This is used for cases such as
the HA state-file and the redo-log.
"""
util.SMlog("FileVDI.attach_from_config")
try:
if not util.pathexists(self.sr.path):
self.sr.attach(sr_uuid)
except:
util.logException("FileVDI.attach_from_config")
raise xs_errors.XenError(
'SRUnavailable',
opterr='Unable to attach from config'
)
if __name__ == '__main__':
SRCommand.run(FileSR, DRIVER_INFO)
else:
SR.registerSR(FileSR)
示例4: get_attached_vbds
# 需要导入模块: import SR [as 别名]
# 或者: from SR import registerSR [as 别名]
def get_attached_vbds(self):
vdi_ref = self.session.xenapi.VDI.get_by_uuid(self.uuid)
vbds = self.session.xenapi.VBD.get_all_records_where("field \"VDI\" = \"%s\"" % vdi_ref)
return filter(lambda v: v['currently_attached'] == "true", vbds.values())
def check_vbd_list_is_stable(self, attached_vbds):
newly_attached_vbds = self.get_attached_vbds()
old_set = set(attached_vbds)
new_set = set(newly_attached_vbds)
diff_set = old_set.difference(new_set) | new_set.difference(old_set)
if len(diff_set) != 0:
msg = "LVHDRT: found a non-stable VBD: %s" % (diff_set.pop())
util.SMlog(msg)
raise xs_errors.XenError('VBDListNotStable')
def run_corner_cases_tests(self):
def fn():
attached_vbds = self.get_attached_vbds()
for i in range(0,10):
time.sleep(2)
self.check_no_other_vdi_operation_in_progress()
self.check_vbd_list_is_stable(attached_vbds)
util.fistpoint.activate_custom_fn("LVHDRT_xapiSM_serialization_tests", fn)
if __name__ == '__main__':
SRCommand.run(DummySR, DRIVER_INFO)
else:
SR.registerSR(DummySR)
示例5: attach_from_config
# 需要导入模块: import SR [as 别名]
# 或者: from SR import registerSR [as 别名]
if dict['device_config'].has_key('chappassword_secret'):
s = util.get_secret(self.session, dict['device_config']['chappassword_secret'])
del dict['device_config']['chappassword_secret']
dict['device_config']['chappassword'] = s
dict['sr_uuid'] = sr_uuid
dict['vdi_uuid'] = vdi_uuid
dict['allocation'] = self.sr.sm_config['allocation']
dict['command'] = 'vdi_attach_from_config'
# Return the 'config' encoded within a normal XMLRPC response so that
# we can use the regular response/error parsing code.
config = xmlrpclib.dumps(tuple([dict]), "vdi_attach_from_config")
return xmlrpclib.dumps((config,), "", True)
def attach_from_config(self, sr_uuid, vdi_uuid):
util.SMlog("LVHDoISCSIVDI.attach_from_config")
try:
self.sr.iscsi.attach(sr_uuid)
if not self.sr.iscsi._attach_LUN_bySCSIid(self.sr.SCSIid):
raise xs_errors.XenError('InvalidDev')
return LVHDSR.LVHDVDI.attach(self, sr_uuid, vdi_uuid)
except:
util.logException("LVHDoISCSIVDI.attach_from_config")
raise xs_errors.XenError('SRUnavailable', \
opterr='Unable to attach the heartbeat disk')
if __name__ == '__main__':
SRCommand.run(LVHDoISCSISR, DRIVER_INFO)
else:
SR.registerSR(LVHDoISCSISR)
示例6: _getLUNbySMconfig
# 需要导入模块: import SR [as 别名]
# 或者: from SR import registerSR [as 别名]
count += 1
return count
def _getLUNbySMconfig(self, sm_config):
raise xs_errors.XenError('VDIUnavailable')
def vdi(self, uuid):
return LUNperVDI.RAWVDI(self, uuid)
def srlist_toxml(self, SRs):
dom = xml.dom.minidom.Document()
element = dom.createElement("SRlist")
dom.appendChild(element)
for val in SRs:
record = SRs[val]
entry = dom.createElement('SR')
element.appendChild(entry)
subentry = dom.createElement("UUID")
entry.appendChild(subentry)
textnode = dom.createTextNode(val)
subentry.appendChild(textnode)
return dom.toprettyxml()
if __name__ == '__main__':
SRCommand.run(HBASR, DRIVER_INFO)
else:
SR.registerSR(HBASR)
示例7: attach_from_config
# 需要导入模块: import SR [as 别名]
# 或者: from SR import registerSR [as 别名]
raise xs_errors.XenError('VDIUnavailable')
resp = {}
resp['device_config'] = self.sr.dconf
resp['sr_uuid'] = sr_uuid
resp['vdi_uuid'] = vdi_uuid
resp['sr_sm_config'] = self.sr.sm_config
resp['command'] = 'vdi_attach_from_config'
# Return the 'config' encoded within a normal XMLRPC response so that
# we can use the regular response/error parsing code.
config = xmlrpclib.dumps(tuple([resp]), "vdi_attach_from_config")
return xmlrpclib.dumps((config,), "", True)
def attach_from_config(self, sr_uuid, vdi_uuid):
"""Used for HA State-file only. Will not just attach the VDI but
also start a tapdisk on the file"""
util.SMlog("SMBFileVDI.attach_from_config")
try:
if not util.pathexists(self.sr.path):
self.sr.attach(sr_uuid)
except:
util.logException("SMBFileVDI.attach_from_config")
raise xs_errors.XenError('SRUnavailable', \
opterr='Unable to attach from config')
if __name__ == '__main__':
SRCommand.run(SMBSR, DRIVER_INFO)
else:
SR.registerSR(SMBSR)
#
示例8: long
# 需要导入模块: import SR [as 别名]
# 或者: from SR import registerSR [as 别名]
stat = os.stat(self.path)
self.utilisation = long(stat.st_size)
self.size = long(stat.st_size)
except:
pass
def __init__(self, mysr, uuid, filename):
self.uuid = uuid
VDI.VDI.__init__(self, mysr, None)
self.path = os.path.join(mysr.dconf['location'], filename)
self.label = filename
self.location = filename
self.vdi_type = 'file'
self.read_only = True
self.shareable = True
self.sm_config = {}
def detach(self, sr_uuid, vdi_uuid):
pass
def clone(self, sr_uuid, vdi_uuid):
return self.get_params()
def snapshot(self, sr_uuid, vdi_uuid):
return self.get_params()
if __name__ == '__main__':
SRCommand.run(SHMSR, DRIVER_INFO)
else:
SR.registerSR(SHMSR)
示例9: detach
# 需要导入模块: import SR [as 别名]
# 或者: from SR import registerSR [as 别名]
scsi_id = self.sm_config['SCSIid']
xapi_session = self.session.xenapi
# Cleaning up SR sm_config
scsi_key = "scsi-" + scsi_id
xapi_session.SR.remove_from_sm_config(self.sr.sr_ref, scsi_key)
def detach(self, sr_uuid, vdi_uuid):
scsi_id = self.sm_config['SCSIid']
xapi_session = self.session.xenapi
# Multipath disable
if self.sr.mpath == "true":
#devices = scsiutil._genReverseSCSIidmap(scsi_id)
self.sr.mpathmodule.reset(scsi_id, True)
util.remove_mpathcount_field(self.sr.session, self.sr.host_ref,
self.sr.sr_ref, scsi_id)
# Get size from xapi db
vdi_ref = xapi_session.VDI.get_by_uuid(vdi_uuid)
size = int(xapi_session.VDI.get_virtual_size(vdi_ref))
self.sr.update_stats(-size)
if __name__ == '__main__':
SRCommand.run(RawHBASR, DRIVER_INFO)
else:
SR.registerSR(RawHBASR)
示例10: RawISCSISR
# 需要导入模块: import SR [as 别名]
# 或者: from SR import registerSR [as 别名]
'capabilities': CAPABILITIES,
'configuration': CONFIGURATION
}
class RawISCSISR(BaseISCSI.BaseISCSISR):
"""Raw ISCSI storage repository"""
def handles(type):
if type == "iscsi":
return True
return False
handles = staticmethod(handles)
def load(self, vdi_uuid):
super(RawISCSISR, self).load(vdi_uuid)
self.managed = True
def vdi(self, uuid):
return ISCSIVDI(self, uuid)
class ISCSIVDI(LUNperVDI.RAWVDI):
def load(self, vdi_uuid):
super(ISCSIVDI, self).load(vdi_uuid)
self.managed = True
if __name__ == '__main__':
SRCommand.run(RawISCSISR, DRIVER_INFO)
else:
SR.registerSR(RawISCSISR)
示例11: staticmethod
# 需要导入模块: import SR [as 别名]
# 或者: from SR import registerSR [as 别名]
return False
handles = staticmethod(handles)
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)
def delete(self, sr_uuid):
super(EXToISCSISR, self).delete(sr_uuid)
self.iscsi.detach(sr_uuid)
def detach(self, sr_uuid):
super(EXToISCSISR, self).detach(sr_uuid)
self.iscsi.detach(sr_uuid)
if __name__ == '__main__':
SRCommand.run(EXToISCSISR)
else:
SR.registerSR(EXToISCSISR)
示例12: snapshot
# 需要导入模块: import SR [as 别名]
# 或者: from SR import registerSR [as 别名]
opterr='LVM clone unsupported')
def snapshot(self, sr_uuid, vdi_uuid):
raise xs_errors.XenError('Unimplemented', \
opterr='LVM snapshot unsupported')
def _isactive(self, path):
try:
f=open(path, 'r')
f.close()
return True
except IOError:
return False
class BufferedLVSCAN(VDI.VDI):
def load(self, line):
fields = line.split()
self.lvname = fields[0]
self.uuid = fields[0].replace("LV-","")
self.size = long(fields[3].replace("B",""))
self.utilisation = self.size
self.location = self.uuid
if len(fields) > 4:
self.parent = fields[4].replace("LV-","")
if __name__ == '__main__':
SRCommand.run(LVMSR, DRIVER_INFO)
else:
SR.registerSR(LVMSR)
示例13: LVMoHBAVDI
# 需要导入模块: import SR [as 别名]
# 或者: from SR import registerSR [as 别名]
class LVMoHBAVDI(LVMSR.LVMVDI):
def generate_config(self, sr_uuid, vdi_uuid):
if not lvutil._checkLV(self.path):
raise xs_errors.XenError("VDIUnavailable")
dict = {}
self.sr.dconf["multipathing"] = self.sr.mpath
self.sr.dconf["multipathhandle"] = self.sr.mpathhandle
dict["device_config"] = self.sr.dconf
dict["sr_uuid"] = sr_uuid
dict["vdi_uuid"] = vdi_uuid
dict["command"] = "vdi_attach_from_config"
# Return the 'config' encoded within a normal XMLRPC response so that
# we can use the regular response/error parsing code.
config = xmlrpclib.dumps(tuple([dict]), "vdi_attach_from_config")
return xmlrpclib.dumps((config,), "", True)
def attach_from_config(self, sr_uuid, vdi_uuid):
return super(LVMoHBAVDI, self).attach(sr_uuid, vdi_uuid)
def match_scsidev(s):
regex = re.compile("^/dev/disk/by-id|^/dev/mapper")
return regex.search(s, 0)
if __name__ == "__main__":
SRCommand.run(LVMoHBASR, DRIVER_INFO)
else:
SR.registerSR(LVMoHBASR)
示例14: attach_from_config
# 需要导入模块: import SR [as 别名]
# 或者: from SR import registerSR [as 别名]
dict['device_config'] = self.sr.dconf
dict['sr_uuid'] = sr_uuid
dict['vdi_uuid'] = vdi_uuid
dict['allocation'] = self.sr.sm_config['allocation']
dict['command'] = 'vdi_attach_from_config'
# Return the 'config' encoded within a normal XMLRPC response so that
# we can use the regular response/error parsing code.
config = xmlrpclib.dumps(tuple([dict]), "vdi_attach_from_config")
return xmlrpclib.dumps((config,), "", True)
def attach_from_config(self, sr_uuid, vdi_uuid):
util.SMlog("LVHDoHBAVDI.attach_from_config")
self.sr.hbasr.attach(sr_uuid)
if self.sr.mpath == "true":
self.sr.mpathmodule.refresh(self.sr.SCSIid,0)
try:
return self.attach(sr_uuid, vdi_uuid)
except:
util.logException("LVHDoHBAVDI.attach_from_config")
raise xs_errors.XenError('SRUnavailable', \
opterr='Unable to attach the heartbeat disk')
def match_scsidev(s):
regex = re.compile("^/dev/disk/by-id|^/dev/mapper")
return regex.search(s, 0)
if __name__ == '__main__':
SRCommand.run(LVHDoHBASR, DRIVER_INFO)
else:
SR.registerSR(LVHDoHBASR)
示例15: vdi
# 需要导入模块: import SR [as 别名]
# 或者: from SR import registerSR [as 别名]
try:
util.pread2(["mkfs.ext3", "-F", self.remotepath])
except util.CommandException, inst:
raise xs_errors.XenError('LVMFilesystem', \
opterr='mkfs failed error %d' % inst.code)
#Update serial number string
scsiutil.add_serial_record(self.session, self.sr_ref, \
scsiutil.devlist_to_serialstring(self.root.split(',')))
def vdi(self, uuid, loadLocked = False):
if not loadLocked:
return EXTFileVDI(self, uuid)
return EXTFileVDI(self, uuid)
class EXTFileVDI(FileSR.FileVDI):
def attach(self, sr_uuid, vdi_uuid):
if not hasattr(self,'xenstore_data'):
self.xenstore_data = {}
self.xenstore_data["storage-type"]="ext"
return super(EXTFileVDI, self).attach(sr_uuid, vdi_uuid)
if __name__ == '__main__':
SRCommand.run(EXTSR, DRIVER_INFO)
else:
SR.registerSR(EXTSR)