import karesansui
from karesansui import __version__
from karesansui.lib.virt.virt import KaresansuiVirtConnection, KaresansuiVirtException
- from karesansui.lib.utils import load_locale
+ from karesansui.lib.utils import load_locale, is_uuid
from karesansui.lib.virt.config_export import ExportConfigParam
from karesansui.lib.virt.config import ConfigParam
- from karesansui.lib.utils import is_uuid
except ImportError:
print >>sys.stderr, "[Error] karesansui package was not found."
sys.exit(1)
return optp.parse_args()
def chkopts(opts):
- if not opts.uuid:
+ if opts.uuid:
+ if not is_uuid(opts.uuid):
+ raise KssCommandOptException('ERROR: Illigal UUID. uuid=%s' % (opts.uuid))
+ else:
raise KssCommandOptException('ERROR: -u or --uuid option is required.')
class DeleteExportData(KssCommand):
def process(self):
(opts, args) = getopts()
chkopts(opts)
- self.up_progress(1)
+ self.up_progress(10)
kvc = KaresansuiVirtConnection()
# #1 libvirt process
active_pool = kvc.list_active_storage_pool()
pools = inactive_pool + active_pool
pools.sort()
-
+
export = []
for pool_name in pools:
pool = kvc.search_kvn_storage_pools(pool_name)
'Export corrupt data.(file not found) - path=%s' % path)
param.load_xml_config(path)
-
+
if e_name != param.get_domain_name():
raise KssCommandException(
'Export corrupt data.(The name does not match) - info=%s, xml=%s' \
finally:
kvc.close()
+ self.up_progress(30)
# #2 physical process
if os.path.isdir(export['dir']) is False:
raise KssCommandException(_("Failed to delete export data. - %s") % (_("Export data directory not found. [%s]") % (export['dir'])))
for _afile in glob.glob("%s*img" % (export['dir'])):
os.remove(_afile)
+ self.up_progress(30)
# refresh pool.
conn = KaresansuiVirtConnection(readonly=False)
try:
except:
pass
+ self.logger.info('Deleted export data. - uuid=%s' % (opts.uuid))
+ print >>sys.stderr, _('Deleted export data. - uuid=%s') % (opts.uuid)
return True
if __name__ == "__main__":