osdf rearchitecture into apps and libs
[optf/osdf.git] / apps / placement / models / api / placementRequest.py
1 # -------------------------------------------------------------------------
2 #   Copyright (c) 2015-2017 AT&T Intellectual Property
3 #
4 #   Licensed under the Apache License, Version 2.0 (the "License");
5 #   you may not use this file except in compliance with the License.
6 #   You may obtain 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,
12 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 #   See the License for the specific language governing permissions and
14 #   limitations under the License.
15 #
16 # -------------------------------------------------------------------------
17 #
18
19 from osdf.models.api.common import OSDFModel
20 from schematics.types import BaseType, StringType, URLType, IntType, BooleanType
21 from schematics.types.compound import ModelType, ListType, DictType
22
23
24 class RequestInfo(OSDFModel):
25     """Info for northbound request from client such as SO"""
26     transactionId = StringType(required=True)
27     requestId = StringType(required=True)
28     callbackUrl = URLType(required=True)
29     callbackHeader = DictType(BaseType)
30     sourceId = StringType(required=True)
31     requestType = StringType(required=True)
32     numSolutions = IntType()
33     optimizers = ListType(StringType(required=True))
34     timeout = IntType()
35
36
37 class Candidates(OSDFModel):
38     """Preferred candidate for a resource (sent as part of a request from client)"""
39     identifierType = StringType(required=True)
40     identifiers = ListType(StringType(required=True))
41     cloudOwner = StringType()
42
43
44 class ModelMetaData(OSDFModel):
45     """Model information for a specific resource"""
46     modelInvariantId = StringType(required=True)
47     modelVersionId = StringType(required=True)
48     modelName = StringType()
49     modelType = StringType()
50     modelVersion = StringType()
51     modelCustomizationName = StringType()
52
53
54 class LicenseModel(OSDFModel):
55     entitlementPoolUUID = ListType(StringType(required=True))
56     licenseKeyGroupUUID = ListType(StringType(required=True))
57
58
59 class LicenseDemands(OSDFModel):
60     resourceModuleName = StringType(required=True)
61     serviceResourceId = StringType(required=True)
62     resourceModelInfo = ModelType(ModelMetaData, required=True)
63     existingLicenses = ModelType(LicenseModel)
64
65
66 class LicenseInfo(OSDFModel):
67     licenseDemands = ListType(ModelType(LicenseDemands))
68
69
70 class PlacementDemand(OSDFModel):
71     resourceModuleName = StringType(required=True)
72     serviceResourceId = StringType(required=True)
73     tenantId = StringType()
74     resourceModelInfo = ModelType(ModelMetaData, required=True)
75     existingCandidates = ListType(ModelType(Candidates))
76     excludedCandidates = ListType(ModelType(Candidates))
77     requiredCandidates = ListType(ModelType(Candidates))
78
79
80 class ServiceInfo(OSDFModel):
81     serviceInstanceId = StringType(required=True)
82     modelInfo = ModelType(ModelMetaData, required=True)
83     serviceName = StringType(required=True)
84
85
86 class SubscriberInfo(OSDFModel):
87     """Details on the customer that subscribes to the VNFs"""
88     globalSubscriberId = StringType(required=True)
89     subscriberName = StringType()
90     subscriberCommonSiteId = StringType()
91
92
93 class PlacementInfo(OSDFModel):
94     """Information specific to placement optimization"""
95     requestParameters = DictType(BaseType)
96     placementDemands = ListType(ModelType(PlacementDemand), min_size=1)
97     subscriberInfo = ModelType(SubscriberInfo)
98
99
100 class PlacementAPI(OSDFModel):
101     """Request for placement optimization (specific to optimization and additional metadata"""
102     requestInfo = ModelType(RequestInfo, required=True)
103     placementInfo = ModelType(PlacementInfo, required=True)
104     licenseInfo = ModelType(LicenseInfo)
105     serviceInfo = ModelType(ServiceInfo, required=True)