xapi-tools: fixes cache cleaner script
Fixes cache cleaner script by removing import of driver and using session directly to call vm_utils. There is no test included for this. Since this is out of nova tree, adding tests is tracked in 1481705 Closes-Bug: #1481693 Change-Id: I25ee22777baecaf64de63a39d19e8f8f514f70b3
This commit is contained in:
parent
b144fe4447
commit
d731a04b60
@ -29,7 +29,7 @@ if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'nova', '__init__.py')):
|
||||
|
||||
from nova import config
|
||||
from nova import utils
|
||||
from nova.virt.xenapi import driver as xenapi_driver
|
||||
from nova.virt.xenapi.client import session
|
||||
from nova.virt.xenapi import vm_utils
|
||||
|
||||
destroy_opts = [
|
||||
@ -45,18 +45,26 @@ destroy_opts = [
|
||||
CONF = cfg.CONF
|
||||
CONF.register_cli_opts(destroy_opts)
|
||||
|
||||
CONF.import_opt('connection_url', 'nova.virt.xenapi.driver',
|
||||
group='xenserver')
|
||||
CONF.import_opt('connection_username', 'nova.virt.xenapi.driver',
|
||||
group='xenserver')
|
||||
CONF.import_opt('connection_password', 'nova.virt.xenapi.driver',
|
||||
group='xenserver')
|
||||
|
||||
|
||||
def main():
|
||||
config.parse_args(sys.argv)
|
||||
utils.monkey_patch()
|
||||
|
||||
xenapi = xenapi_driver.XenAPIDriver()
|
||||
session = xenapi._session
|
||||
_session = session.XenAPISession(CONF.xenserver.connection_url,
|
||||
CONF.xenserver.connection_username,
|
||||
CONF.xenserver.connection_password)
|
||||
|
||||
sr_ref = vm_utils.safe_find_sr(session)
|
||||
sr_ref = vm_utils.safe_find_sr(_session)
|
||||
destroyed = vm_utils.destroy_cached_images(
|
||||
session, sr_ref, all_cached=CONF.all_cached,
|
||||
dry_run=CONF.dry_run)
|
||||
_session, sr_ref, all_cached=CONF.all_cached,
|
||||
dry_run=CONF.dry_run)
|
||||
|
||||
if '--verbose' in sys.argv:
|
||||
print '\n'.join(destroyed)
|
||||
|
Loading…
x
Reference in New Issue
Block a user