OpenStack Compute (Nova) Client
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

coverage_ext.py 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # Copyright 2012 IBM Corp.
  2. # All Rights Reserved.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  5. # not use this file except in compliance with the License. You may obtain
  6. # a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. # License for the specific language governing permissions and limitations
  14. # under the License.
  15. from novaclient import base
  16. class Coverage(base.Resource):
  17. def __repr__(self):
  18. return "<Coverage: %s>" % self.name
  19. class CoverageManager(base.Manager):
  20. resource_class = Coverage
  21. def start(self, combine=False, **kwargs):
  22. body = {'start': {}}
  23. if combine:
  24. body['start'] = {'combine': True}
  25. self.run_hooks('modify_body_for_action', body)
  26. url = '/os-coverage/action'
  27. return self.api.client.post(url, body=body)
  28. def stop(self):
  29. body = {'stop': {}}
  30. self.run_hooks('modify_body_for_action', body)
  31. url = '/os-coverage/action'
  32. return self.api.client.post(url, body=body)
  33. def report(self, filename, xml=False, html=False):
  34. body = {
  35. 'report': {
  36. 'file': filename,
  37. }
  38. }
  39. if xml:
  40. body['report']['xml'] = True
  41. elif html:
  42. body['report']['html'] = True
  43. self.run_hooks('modify_body_for_action', body)
  44. url = '/os-coverage/action'
  45. return self.api.client.post(url, body=body)
  46. def reset(self):
  47. body = {'reset': {}}
  48. self.run_hooks('modify_body_for_action', body)
  49. url = '/os-coverage/action'
  50. return self.api.client.post(url, body=body)