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 guest.")
+ return web.badrequest("Target iSCSI is used guest.")
finally:
kvc.close()
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 guest.")
+ return web.badrequest("Target storage pool is used guest.")
finally:
kvc.close()
if status == STORAGE_POOL_START:
storagepool_start_stop_job(self, model, pools_obj[0], 'start')
elif status == STORAGE_POOL_STOP:
- storagepool_start_stop_job(self, model, pools_obj[0], '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 guest.")
+ return web.badrequest("Target storage pool is used 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()
mode = VIR_STORAGE_POOL_DELETE_NORMAL
if flags is True:
mode = VIR_STORAGE_POOL_DELETE_ZEROED
-
+
if self.storage_pool.delete(mode) == 0:
return True
else:
return False
+ def is_used_storage_pool(self, name=None, active_only=False):
+ """
+ <comment-ja>
+ ストレージプールが現在利用されているか。
+ </comment-ja>
+ <comment-en>
+ TODO:
+ </comment-en>
+ """
+ if name is None:
+ return False
+
+ guests = self.list_active_guest()
+ if active_only is False:
+ guests += self.list_inactive_guest()
+
+ pools = []
+ for guest in guests:
+ pools += self.get_storage_pool_name_bydomain(guest)
+
+ if name in pools:
+ return True
+
+ return False
+
def is_storage_volume(self, path):
"""<comment-ja>
指定したパスがストレージボリュームに含まれているか。