Coverage for manila/api/views/share_server_migration.py: 100%
20 statements
« prev ^ index » next coverage.py v7.11.0, created at 2026-02-18 22:19 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2026-02-18 22:19 +0000
1# Copyright (c) 2020 NetApp, Inc.
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.
16import copy
18from manila.api import common
21class ViewBuilder(common.ViewBuilder):
22 """Model share server migration view data response as a python dictionary.
24 """
26 _collection_name = 'share_server_migration'
27 _detail_version_modifiers = []
29 def get_progress(self, request, params):
30 """View of share server migration job progress."""
31 result = {
32 'total_progress': params['total_progress'],
33 'task_state': params['task_state'],
34 'destination_share_server_id':
35 params['destination_share_server_id'],
36 }
38 self.update_versioned_resource_dict(request, result, params)
39 return result
41 def build_check_migration(self, request, params, result):
42 """View of share server migration check."""
43 requested_capabilities = {
44 'writable': params['writable'],
45 'nondisruptive': params['nondisruptive'],
46 'preserve_snapshots': params['preserve_snapshots'],
47 'share_network_id': params['new_share_network_id'],
48 'host': params['host'],
49 }
50 supported_capabilities = {
51 'writable': result['writable'],
52 'nondisruptive': result['nondisruptive'],
53 'preserve_snapshots': result['preserve_snapshots'],
54 'share_network_id': result['share_network_id'],
55 'migration_cancel': result['migration_cancel'],
56 'migration_get_progress': result['migration_get_progress']
57 }
58 view = {
59 'compatible': result['compatible'],
60 'requested_capabilities': requested_capabilities,
61 'supported_capabilities': supported_capabilities,
62 }
63 capabilities = {
64 'requested': copy.copy(params),
65 'supported': copy.copy(result)
66 }
67 self.update_versioned_resource_dict(request, view, capabilities)
68 return view
70 def migration_complete(self, request, params):
71 """View of share server migration complete command."""
72 result = {
73 'destination_share_server_id':
74 params['destination_share_server_id'],
75 }
77 self.update_versioned_resource_dict(request, result, params)
78 return result