Coverage for manila/data/rpcapi.py: 100%

28 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2026-02-18 22:19 +0000

1# Copyright 2015, Hitachi Data Systems. 

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""" 

16Client side of the data manager RPC API. 

17""" 

18 

19from oslo_config import cfg 

20import oslo_messaging as messaging 

21 

22from manila import rpc 

23 

24CONF = cfg.CONF 

25 

26 

27class DataAPI(object): 

28 """Client side of the data RPC API. 

29 

30 API version history: 

31 

32 1.0 - Initial version, 

33 Add migration_start(), 

34 data_copy_cancel(), 

35 data_copy_get_progress() 

36 

37 1.1 - create_backup(), 

38 delete_backup(), 

39 restore_backup() 

40 """ 

41 

42 BASE_RPC_API_VERSION = '1.0' 

43 

44 def __init__(self): 

45 super(DataAPI, self).__init__() 

46 target = messaging.Target(topic=CONF.data_topic, 

47 version=self.BASE_RPC_API_VERSION) 

48 self.client = rpc.get_client(target, version_cap='1.1') 

49 

50 def migration_start(self, context, share_id, ignore_list, 

51 share_instance_id, dest_share_instance_id, 

52 connection_info_src, connection_info_dest): 

53 call_context = self.client.prepare(version='1.0') 

54 call_context.cast( 

55 context, 

56 'migration_start', 

57 share_id=share_id, 

58 ignore_list=ignore_list, 

59 share_instance_id=share_instance_id, 

60 dest_share_instance_id=dest_share_instance_id, 

61 connection_info_src=connection_info_src, 

62 connection_info_dest=connection_info_dest) 

63 

64 def data_copy_cancel(self, context, share_id): 

65 call_context = self.client.prepare(version='1.0') 

66 call_context.call(context, 'data_copy_cancel', share_id=share_id) 

67 

68 def data_copy_get_progress(self, context, share_id): 

69 call_context = self.client.prepare(version='1.0') 

70 return call_context.call(context, 'data_copy_get_progress', 

71 share_id=share_id) 

72 

73 def create_backup(self, context, backup): 

74 call_context = self.client.prepare(version='1.1') 

75 call_context.cast(context, 'create_backup', backup=backup) 

76 

77 def delete_backup(self, context, backup): 

78 call_context = self.client.prepare(version='1.1') 

79 call_context.cast(context, 'delete_backup', backup=backup) 

80 

81 def restore_backup(self, context, backup, share_id): 

82 call_context = self.client.prepare(version='1.1') 

83 call_context.cast(context, 'restore_backup', backup=backup, 

84 share_id=share_id)