Run 'ip' with sudo
[doctor.git] / tests / inspector.py
index 2445c77..c796283 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,6 +15,8 @@ import os
 
 import novaclient.client as novaclient
 
+import nova_force_down
+
 
 class DoctorInspectorSample(object):
 
@@ -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__)