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 image_formatter(image):
16 image = image.to_dict()
18 if image.get("vmware_adaptertype"):
19 properties['vmware_adaptertype'] = image.get("vmware_adaptertype")
20 if image.get("vmware_ostype"):
21 properties['vmware_ostype'] = image.get("vmware_ostype")
24 'id': image.get("id"),
25 'name': image.get("name"),
26 'imageType': image.get("disk_format"),
27 'status': image.get("status"),
28 'size': image.get("size"),
29 'containerFormat': image.get("container_format"),
30 'visibility': image.get("visibility"),
31 'properties': properties
35 def vim_formatter(vim_info, tenantid):
38 rsp['vimId'] = vim_info.get('vimId')
39 rsp['vimName'] = vim_info.get('name')
40 rsp['tenantId'] = tenantid
44 def sdk_param_formatter(data):
47 param['username'] = data.get('userName')
48 param['password'] = data.get('password')
49 param['auth_url'] = data.get('url')
50 param['project_id'] = data.get('tenant')
51 param['user_domain_name'] = 'default'
52 param['project_domain_name'] = 'default'
56 def req_body_formatter(body):
59 param['name'] = body.get('name')
60 param['disk_format'] = body.get('imageType')
61 param['container_format'] = body.get('containerFormat')
62 param['visibility'] = body.get('visibility')
63 properties = body.get('properties', {})
64 param.update(properties)