1 ##############################################################################
2 # Copyright (c) 2016 NEC Corporation and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
14 import novaclient.client as novaclient
17 nova_api_version = 2.11
19 def enable_compute_host(hostname):
20 self.nova = novaclient.Client(self.nova_api_version,
21 os.environ['OS_USERNAME'],
22 os.environ['OS_PASSWORD'],
23 os.environ['OS_TENANT_NAME'],
24 os.environ['OS_AUTH_URL'],
26 opts = {'all_tenants': True, 'host': hostname}
27 for server in self.nova.servers.list(detailed=False, search_opts=opts):
28 self.nova.servers.reset_state(server, 'active')
29 self.nova.services.force_down(hostname, 'nova-compute', False)
33 parser = argparse.ArgumentParser(description='Doctor Test Cleaner')
34 parser.add_argument('hostname', metavar='HOSTNAME', type=str, nargs='?',
35 help='a hostname to be re-enable')
36 return parser.parse_args()
41 enable_compute_host(args.hostname)
44 if __name__ == '__main__':