本文整理汇总了Python中karesansui.lib.virt.virt.KaresansuiVirtConnection.is_used_storage_pool方法的典型用法代码示例。如果您正苦于以下问题:Python KaresansuiVirtConnection.is_used_storage_pool方法的具体用法?Python KaresansuiVirtConnection.is_used_storage_pool怎么用?Python KaresansuiVirtConnection.is_used_storage_pool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类karesansui.lib.virt.virt.KaresansuiVirtConnection
的用法示例。
在下文中一共展示了KaresansuiVirtConnection.is_used_storage_pool方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _PUT
# 需要导入模块: from karesansui.lib.virt.virt import KaresansuiVirtConnection [as 别名]
# 或者: from karesansui.lib.virt.virt.KaresansuiVirtConnection import is_used_storage_pool [as 别名]
def _PUT(self, *param, **params):
host_id = self.chk_hostby1(param)
if host_id is None: return web.notfound()
self.view.host_id = host_id
uuid = param[1]
if not validates_storage_pool(self, uuid):
self.logger.debug("Set storage pool status failed. Did not validate.")
return web.badrequest(self.view.alert)
model = findbyhost1(self.orm, host_id)
# Pool
try:
kvc = KaresansuiVirtConnection()
inactive_pool = kvc.list_inactive_storage_pool()
active_pool = kvc.list_active_storage_pool()
pools = inactive_pool + active_pool
pools.sort()
self.view.pools = pools
pools_obj = kvc.get_storage_pool_UUIDString2kvn_storage_pool(uuid)
if len(pools_obj) <= 0:
self.logger.debug("Set storage pool status failed. Target storage pool not found.")
return web.notfound()
status = int(self.input.status)
if status == STORAGE_POOL_START:
storagepool_start_stop_job(self, model, pools_obj[0], 'start')
elif status == STORAGE_POOL_STOP:
if kvc.is_used_storage_pool(name=pools_obj[0].get_storage_name(),
active_only=True) is True:
self.logger.debug("Stop storage pool failed. Target storage pool is used by guest.")
return web.badrequest("Target storage pool is used by guest.")
else:
storagepool_start_stop_job(self, model, pools_obj[0], 'stop')
else:
self.logger.debug("Set storage pool status failed. Unknown status type.")
return web.badrequest()
return web.accepted()
finally:
kvc.close()
示例2: _DELETE
# 需要导入模块: from karesansui.lib.virt.virt import KaresansuiVirtConnection [as 别名]
# 或者: from karesansui.lib.virt.virt.KaresansuiVirtConnection import is_used_storage_pool [as 别名]
def _DELETE(self, *param, **params):
host_id = self.chk_hostby1(param)
if host_id is None: return web.notfound()
self.view.host_id = host_id
uuid = param[1]
if not validates_storage_pool(self, uuid):
self.logger.debug("Delete storage pool failed. Did not validate.")
return web.badrequest(self.view.alert)
# Pool
try:
kvc = KaresansuiVirtConnection()
inactive_pool = kvc.list_inactive_storage_pool()
active_pool = kvc.list_active_storage_pool()
pools = inactive_pool + active_pool
pools.sort()
self.view.pools = pools
pools_obj = kvc.get_storage_pool_UUIDString2kvn_storage_pool(uuid)
if len(pools_obj) <= 0:
return web.notfound()
if kvc.is_used_storage_pool(pools_obj[0].get_storage_name()) is True:
self.logger.debug("Delete storage pool failed. Target storage pool is used by guest.")
return web.badrequest("Target storage pool is used by guest.")
finally:
kvc.close()
model = findbyhost1(self.orm, host_id)
if delete_storage_pool_job(self,model,pools_obj[0].get_storage_name()) is True:
self.logger.debug("Delete storage pool success. name=%s" % (pools_obj[0].get_storage_name()))
return web.accepted()
else:
self.logger.debug("Failed delete storage pool. name=%s" % (pools_obj[0].get_storage_name()))
return False
示例3: _PUT
# 需要导入模块: from karesansui.lib.virt.virt import KaresansuiVirtConnection [as 别名]
# 或者: from karesansui.lib.virt.virt.KaresansuiVirtConnection import is_used_storage_pool [as 别名]
def _PUT(self, *param, **params):
host_id = self.chk_hostby1(param)
if host_id is None: return web.notfound()
if not validates_network_storage(self):
self.logger.debug("Network storage change status failed. Did not validate.")
return web.badrequest(self.view.alert)
host = findbyhost1(self.orm, host_id)
if is_param(self.input, "iqn"):
iqn = self.input.iqn
else:
self.logger.debug("Network storage change status failed. Target IQN not found.")
return web.badrequest()
options = {'iqn' : iqn}
job_order = 0
if is_param(self.input, "status"):
status = self.input.status
else:
self.logger.debug("Network storage change status failed. Status type not found.")
return web.badrequest()
if is_param(self.input, "host") and is_param(self.input, "port"):
host = self.input.host
port = self.input.port
else:
self.logger.debug("Network storage change status failed. Target host and port not found.")
return web.badrequest()
active_used_pool = []
inactive_used_pool = []
kvc = KaresansuiVirtConnection()
try:
dev_symlink_list = get_filelist(ISCSI_DEVICE_DIR)
dev_symlink_list.sort()
symlink_regexp = re.compile("^%s/%s" % (re.escape(ISCSI_DEVICE_DIR), re.escape(ISCSI_DEVICE_NAME_TPL % (host, port, iqn))))
active_pools = kvc.list_active_storage_pool()
inactive_pools = kvc.list_inactive_storage_pool()
now_pools = active_pools + inactive_pools
for pool in now_pools:
pool_type = kvc.get_storage_pool_type(pool)
if pool_type == "iscsi":
if iqn == kvc.get_storage_pool_sourcedevicepath(pool):
if pool in active_pools:
active_used_pool.append(pool)
if pool in inactive_pools:
inactive_used_pool.append(pool)
elif pool_type == "fs":
if symlink_regexp.match(kvc.get_storage_pool_sourcedevicepath(pool)):
if pool in active_pools:
active_used_pool.append(pool)
if pool in inactive_pools:
inactive_used_pool.append(pool)
if status == NETWORK_STORAGE_STOP:
for pool in active_used_pool:
if kvc.is_used_storage_pool(name=pool, active_only=True) is True:
self.logger.debug("Stop iSCSI failed. Target iSCSI is used by guest.")
return web.badrequest("Target iSCSI is used by guest.")
finally:
kvc.close()
if status == NETWORK_STORAGE_START:
network_storage_cmd = ISCSI_COMMAND_START
cmd_name = u'Start iSCSI'
jobgroup = JobGroup(cmd_name, karesansui.sheconf['env.uniqkey'])
for pool in inactive_used_pool:
pool_cmd = dict2command(
"%s/%s" % (karesansui.config['application.bin.dir'], VIRT_COMMAND_START_STORAGE_POOL),
{"name" : pool})
pool_cmdname = "Start Storage Pool"
jobgroup.jobs.append(Job('%s command' % pool_cmdname, 1, pool_cmd))
job_order = 0
elif status == NETWORK_STORAGE_STOP:
network_storage_cmd = ISCSI_COMMAND_STOP
cmd_name = u'Stop iSCSI'
jobgroup = JobGroup(cmd_name, karesansui.sheconf['env.uniqkey'])
for pool in active_used_pool:
pool_cmd = dict2command(
"%s/%s" % (karesansui.config['application.bin.dir'], VIRT_COMMAND_DESTROY_STORAGE_POOL),
{"name" : pool})
pool_cmdname = "Stop Storage Pool"
jobgroup.jobs.append(Job('%s command' % pool_cmdname, 0, pool_cmd))
job_order = 1
else:
return web.internalerror('Internal Server Error. (Param)')
_cmd = dict2command(
"%s/%s" % (karesansui.config['application.bin.dir'], network_storage_cmd), options)
jobgroup.jobs.append(Job('%s command' % cmd_name, job_order, _cmd))
#.........这里部分代码省略.........