Added v1 registry API
[multicloud/azure.git] / azure / multicloud_azure / swagger / image_utils.py
1 # Copyright (c) 2018 Amdocs
2 #
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:
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,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
13
14 def image_formatter(image):
15
16     image = image.to_dict()
17     properties = {}
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")
22
23     return {
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
32     }
33
34
35 def vim_formatter(vim_info, tenantid):
36
37     rsp = {}
38     rsp['vimId'] = vim_info.get('vimId')
39     rsp['vimName'] = vim_info.get('name')
40     rsp['tenantId'] = tenantid
41     return rsp
42
43
44 def sdk_param_formatter(data):
45
46     param = {}
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'
53     return param
54
55
56 def req_body_formatter(body):
57
58     param = {}
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)
65     return param