|
29 | 29 |
|
30 | 30 | from nova import config
|
31 | 31 | from nova import utils
|
32 |
| -from nova.virt.xenapi import driver as xenapi_driver |
| 32 | +from nova.virt.xenapi.client import session |
33 | 33 | from nova.virt.xenapi import vm_utils
|
34 | 34 |
|
35 | 35 | destroy_opts = [
|
|
45 | 45 | CONF = cfg.CONF
|
46 | 46 | CONF.register_cli_opts(destroy_opts)
|
47 | 47 |
|
| 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 | + |
48 | 55 |
|
49 | 56 | def main():
|
50 | 57 | config.parse_args(sys.argv)
|
51 | 58 | utils.monkey_patch()
|
52 | 59 |
|
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) |
55 | 63 |
|
56 |
| - sr_ref = vm_utils.safe_find_sr(session) |
| 64 | + sr_ref = vm_utils.safe_find_sr(_session) |
57 | 65 | 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) |
60 | 68 |
|
61 | 69 | if '--verbose' in sys.argv:
|
62 | 70 | print '\n'.join(destroyed)
|
|
0 commit comments