1 # Copyright (c) 2018 Amdocs
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at:
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 def volume_formatter(volume):
17 for attach in volume.attachments:
19 'device': attach['device'],
20 'volumeId': attach['volume_id'],
21 'hostName': attach['host_name'],
22 'Id': attach['attachment_id'],
23 'serverId': attach['server_id']
25 attachments.append(vim_attach)
30 'createTime': volume.created_at,
31 'status': volume.status,
32 'type': volume.volume_type,
34 'availabilityZone': volume.availability_zone,
35 'attachments': attachments
39 def vim_formatter(vim_info, tenantid):
42 rsp['vimId'] = vim_info.get('vimId')
43 rsp['vimName'] = vim_info.get('name')
44 rsp['tenantId'] = tenantid
48 def sdk_param_formatter(data):
51 param['username'] = data.get('userName')
52 param['password'] = data.get('password')
53 param['auth_url'] = data.get('url')
54 param['project_id'] = data.get('tenant')
55 param['user_domain_name'] = 'default'
56 param['project_domain_name'] = 'default'
60 def req_body_formatter(body):
63 param['name'] = body.get('name')
64 param['size'] = body.get('volumeSize')
66 if body.get('volumeType'):
67 param['volume_type'] = body.get('volumeType')
68 if body.get('availabilityZone'):
69 param['availability_zone'] = body.get('availabilityZone')
70 if body.get('imageId'):
71 param['image_id'] = body.get('imageId')