Skip to content

Commit d731a04

Browse files
committed
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
1 parent b144fe4 commit d731a04

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

tools/xenserver/destroy_cached_images.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
from nova import config
3131
from nova import utils
32-
from nova.virt.xenapi import driver as xenapi_driver
32+
from nova.virt.xenapi.client import session
3333
from nova.virt.xenapi import vm_utils
3434

3535
destroy_opts = [
@@ -45,18 +45,26 @@
4545
CONF = cfg.CONF
4646
CONF.register_cli_opts(destroy_opts)
4747

48+
CONF.import_opt('connection_url', 'nova.virt.xenapi.driver',
49+
group='xenserver')
50+
CONF.import_opt('connection_username', 'nova.virt.xenapi.driver',
51+
group='xenserver')
52+
CONF.import_opt('connection_password', 'nova.virt.xenapi.driver',
53+
group='xenserver')
54+
4855

4956
def main():
5057
config.parse_args(sys.argv)
5158
utils.monkey_patch()
5259

53-
xenapi = xenapi_driver.XenAPIDriver()
54-
session = xenapi._session
60+
_session = session.XenAPISession(CONF.xenserver.connection_url,
61+
CONF.xenserver.connection_username,
62+
CONF.xenserver.connection_password)
5563

56-
sr_ref = vm_utils.safe_find_sr(session)
64+
sr_ref = vm_utils.safe_find_sr(_session)
5765
destroyed = vm_utils.destroy_cached_images(
58-
session, sr_ref, all_cached=CONF.all_cached,
59-
dry_run=CONF.dry_run)
66+
_session, sr_ref, all_cached=CONF.all_cached,
67+
dry_run=CONF.dry_run)
6068

6169
if '--verbose' in sys.argv:
6270
print '\n'.join(destroyed)

0 commit comments

Comments
 (0)