Mitsuhiko Yamazaki cda7f7a505 Fix default format of 'nova coverage-report'
'nova coverage-report' returns an error because nova server returns
error if the format is HTML and combine is False.
And 'nova coverage-start' and 'nova coverage-report' do it now.

After applying this patch, we can avoid this problem and text format
report is created when we use 'nova coverage-report'

Fixes bug 1110972

Change-Id: Ib3d05453de638157152a50ea814e44e6cbc19348
2013-02-01 12:57:15 +09:00

57 lines
1.7 KiB
Python

# Copyright 2012 IBM
# All Rights Reserved.
#
# 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.
import urllib
from novaclient import base
class Coverage(base.Resource):
def __repr__(self):
return "<Coverage: %s>" % self.name
class CoverageManager(base.ManagerWithFind):
resource_class = Coverage
def start(self, combine=False, **kwargs):
body = {'start': {}}
if combine:
body['start'] = {'combine': True}
self.run_hooks('modify_body_for_action', body)
url = '/os-coverage/action'
return self.api.client.post(url, body=body)
def stop(self):
body = {'stop': {}}
self.run_hooks('modify_body_for_action', body)
url = '/os-coverage/action'
return self.api.client.post(url, body=body)
def report(self, filename, xml=False, html=False):
body = {
'report': {
'file': filename,
}
}
if xml:
body['report']['xml'] = True
elif html:
body['report']['html'] = True
self.run_hooks('modify_body_for_action', body)
url = '/os-coverage/action'
return self.api.client.post(url, body=body)