Change type of nova_api_version from float to str
[doctor.git] / tests / inspector.py
index 2445c77..c8fb00f 100644 (file)
@@ -1,17 +1,11 @@
+##############################################################################
+# Copyright (c) 2016 NEC Corporation and others.
 #
-# Copyright 2016 NEC Corporation.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may
-# not use this file except in compliance with the License. You may obtain
-# a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations
-# under the License.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
 
 import argparse
 from flask import Flask
@@ -21,10 +15,12 @@ import os
 
 import novaclient.client as novaclient
 
+import nova_force_down
+
 
 class DoctorInspectorSample(object):
 
-    nova_api_version = 2.11
+    nova_api_version = '2.11'
 
     def __init__(self):
         self.nova = novaclient.Client(self.nova_api_version,
@@ -40,7 +36,15 @@ class DoctorInspectorSample(object):
         opts = {'all_tenants': True, 'host': hostname}
         for server in self.nova.servers.list(detailed=False, search_opts=opts):
             self.nova.servers.reset_state(server, 'error')
-        self.nova.services.force_down(hostname, 'nova-compute', True)
+
+        # NOTE: We use our own client here instead of this novaclient for a
+        #       workaround.  Once keystone provides v2.1 nova api endpoint
+        #       in the service catalog which is configured by OpenStack
+        #       installer, we can use this:
+        #
+        # self.nova.services.force_down(hostname, 'nova-compute', True)
+        #
+        nova_force_down.force_down(hostname)
 
 
 app = Flask(__name__)
@@ -61,9 +65,9 @@ def event_posted():
 
 
 def get_args():
-    parser = argparse.ArgumentParser(description='Doctor Sample Monitor')
+    parser = argparse.ArgumentParser(description='Doctor Sample Inspector')
     parser.add_argument('port', metavar='PORT', type=int, nargs='?',
-                        help='a port for inspectpr')
+                        help='a port for inspector')
     return parser.parse_args()