Application Data Protection as a Service in OpenStack
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.

rpcapi.py 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. # Copyright 2012, Red Hat, Inc.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  4. # not use this file except in compliance with the License. You may obtain
  5. # a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  11. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  12. # License for the specific language governing permissions and limitations
  13. # under the License.
  14. """
  15. Client side of the protection manager RPC API.
  16. """
  17. from oslo_config import cfg
  18. import oslo_messaging as messaging
  19. from karbor.objects import base as objects_base
  20. from karbor import rpc
  21. CONF = cfg.CONF
  22. class ProtectionAPI(object):
  23. """Client side of the protection rpc API.
  24. API version history:
  25. 1.0 - Initial version.
  26. """
  27. RPC_API_VERSION = '1.0'
  28. def __init__(self):
  29. super(ProtectionAPI, self).__init__()
  30. target = messaging.Target(topic=CONF.protection_topic,
  31. version=self.RPC_API_VERSION)
  32. serializer = objects_base.KarborObjectSerializer()
  33. self.client = rpc.get_client(target, version_cap=None,
  34. serializer=serializer)
  35. def restore(self, ctxt, restore=None, restore_auth=None):
  36. cctxt = self.client.prepare(version='1.0')
  37. return cctxt.call(
  38. ctxt,
  39. 'restore',
  40. restore=restore,
  41. restore_auth=restore_auth)
  42. def verification(self, ctxt, verification=None):
  43. cctxt = self.client.prepare(version='1.0')
  44. return cctxt.call(
  45. ctxt,
  46. 'verification',
  47. verification=verification)
  48. def protect(self, ctxt, plan=None, checkpoint_properties=None):
  49. cctxt = self.client.prepare(version='1.0')
  50. return cctxt.call(
  51. ctxt,
  52. 'protect',
  53. plan=plan,
  54. checkpoint_properties=checkpoint_properties)
  55. def copy(self, ctxt, plan=None):
  56. cctxt = self.client.prepare(version='1.0')
  57. return cctxt.call(
  58. ctxt,
  59. 'copy',
  60. plan=plan)
  61. def delete(self, ctxt, provider_id, checkpoint_id):
  62. cctxt = self.client.prepare(version='1.0')
  63. return cctxt.call(
  64. ctxt,
  65. 'delete',
  66. provider_id=provider_id,
  67. checkpoint_id=checkpoint_id)
  68. def show_checkpoint(self, ctxt, provider_id, checkpoint_id):
  69. cctxt = self.client.prepare(version='1.0')
  70. return cctxt.call(
  71. ctxt,
  72. 'show_checkpoint',
  73. provider_id=provider_id,
  74. checkpoint_id=checkpoint_id)
  75. def list_checkpoints(self, ctxt, provider_id, marker=None,
  76. limit=None, sort_keys=None,
  77. sort_dirs=None, filters=None):
  78. cctxt = self.client.prepare(version='1.0')
  79. return cctxt.call(
  80. ctxt,
  81. 'list_checkpoints',
  82. provider_id=provider_id,
  83. marker=marker,
  84. limit=limit,
  85. sort_keys=sort_keys,
  86. sort_dirs=sort_dirs,
  87. filters=filters)
  88. def list_protectable_types(self, ctxt):
  89. cctxt = self.client.prepare(version='1.0')
  90. return cctxt.call(
  91. ctxt,
  92. 'list_protectable_types')
  93. def show_protectable_type(self, ctxt, protectable_type=None):
  94. cctxt = self.client.prepare(version='1.0')
  95. return cctxt.call(
  96. ctxt,
  97. 'show_protectable_type',
  98. protectable_type=protectable_type)
  99. def list_protectable_instances(
  100. self, ctxt, protectable_type=None,
  101. marker=None, limit=None, sort_keys=None,
  102. sort_dirs=None, filters=None, parameters=None):
  103. cctxt = self.client.prepare(version='1.0')
  104. return cctxt.call(
  105. ctxt,
  106. 'list_protectable_instances',
  107. protectable_type=protectable_type,
  108. marker=marker,
  109. limit=limit,
  110. sort_keys=sort_keys,
  111. sort_dirs=sort_dirs,
  112. filters=filters,
  113. parameters=parameters)
  114. def list_protectable_dependents(self,
  115. ctxt, protectable_id=None,
  116. protectable_type=None,
  117. protectable_name=None):
  118. cctxt = self.client.prepare(version='1.0')
  119. return cctxt.call(
  120. ctxt,
  121. 'list_protectable_dependents',
  122. protectable_id=protectable_id,
  123. protectable_type=protectable_type,
  124. protectable_name=protectable_name)
  125. def show_protectable_instance(self,
  126. ctxt, protectable_type=None,
  127. protectable_id=None,
  128. parameters=None):
  129. cctxt = self.client.prepare(version='1.0')
  130. return cctxt.call(
  131. ctxt,
  132. 'show_protectable_instance',
  133. protectable_type=protectable_type,
  134. protectable_id=protectable_id,
  135. parameters=parameters)
  136. def show_provider(self,
  137. ctxt, provider_id=None):
  138. cctxt = self.client.prepare(version='1.0')
  139. return cctxt.call(
  140. ctxt,
  141. 'show_provider',
  142. provider_id=provider_id)
  143. def list_providers(self, ctxt, marker=None, limit=None,
  144. sort_keys=None,
  145. sort_dirs=None, filters=None):
  146. cctxt = self.client.prepare(version='1.0')
  147. return cctxt.call(
  148. ctxt,
  149. 'list_providers',
  150. marker=marker,
  151. limit=limit,
  152. sort_keys=sort_keys,
  153. sort_dirs=sort_dirs,
  154. filters=filters)