api.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # Copyright 2016 Cloudbase Solutions Srl
  2. # All Rights Reserved.
  3. from coriolis.conductor.rpc import client as rpc_conductor_client
  4. from coriolis.minion_manager.rpc import client as rpc_minion_manager_client
  5. from coriolis import utils
  6. class API(object):
  7. def __init__(self):
  8. self._rpc_conductor_client = rpc_conductor_client.ConductorClient()
  9. self._rpc_minion_manager_client = (
  10. rpc_minion_manager_client.MinionManagerClient())
  11. def create(self, ctxt, name, endpoint_type, description,
  12. connection_info, mapped_regions):
  13. return self._rpc_conductor_client.create_endpoint(
  14. ctxt, name, endpoint_type, description, connection_info,
  15. mapped_regions)
  16. def update(self, ctxt, endpoint_id, properties):
  17. return self._rpc_conductor_client.update_endpoint(
  18. ctxt, endpoint_id, properties)
  19. def delete(self, ctxt, endpoint_id):
  20. self._rpc_conductor_client.delete_endpoint(ctxt, endpoint_id)
  21. def get_endpoints(self, ctxt):
  22. return self._rpc_conductor_client.get_endpoints(ctxt)
  23. def get_endpoint(self, ctxt, endpoint_id):
  24. return self._rpc_conductor_client.get_endpoint(ctxt, endpoint_id)
  25. def validate_connection(self, ctxt, endpoint_id):
  26. return self._rpc_conductor_client.validate_endpoint_connection(
  27. ctxt, endpoint_id)
  28. @utils.bad_request_on_error("Invalid destination environment: %s")
  29. def validate_target_environment(self, ctxt, endpoint_id, target_env):
  30. return self._rpc_conductor_client.validate_endpoint_target_environment(
  31. ctxt, endpoint_id, target_env)
  32. @utils.bad_request_on_error("Invalid source environment: %s")
  33. def validate_source_environment(self, ctxt, endpoint_id, source_env):
  34. return self._rpc_conductor_client.validate_endpoint_source_environment(
  35. ctxt, endpoint_id, source_env)
  36. @utils.bad_request_on_error("Invalid source minion pool environment: %s")
  37. def validate_endpoint_source_minion_pool_options(
  38. self, ctxt, endpoint_id, pool_environment):
  39. return (self._rpc_minion_manager_client.
  40. validate_endpoint_source_minion_pool_options)(
  41. ctxt, endpoint_id, pool_environment)
  42. @utils.bad_request_on_error(
  43. "Invalid destination minion pool environment: %s")
  44. def validate_endpoint_destination_minion_pool_options(
  45. self, ctxt, endpoint_id, pool_environment):
  46. return (self._rpc_minion_manager_client.
  47. validate_endpoint_destination_minion_pool_options)(
  48. ctxt, endpoint_id, pool_environment)