73eac75accdd398491ae65c20be7c36f1ec68bf6
[optf/osdf.git] / osdf / 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 .common import OSDFModel
20 from schematics.types import StringType, URLType, IntType, FloatType
21 from schematics.types.compound import ModelType, ListType
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     sourceId = StringType(required=True)
30     optimizer = ListType(StringType())
31     numSolutions = IntType()
32     timeout = IntType()
33     requestType = StringType()
34
35
36 class CandidateInfo(OSDFModel):
37     """Preferred candidate for a resource (sent as part of a request from client)"""
38     candidateType = StringType(required=True)
39     candidates = ListType(StringType(required=True))
40
41
42 class ResourceModelInfo(OSDFModel):
43     """Model information for a specific resource"""
44     modelCustomizationId = StringType(required=True)
45     modelInvariantId = StringType(required=True)
46     modelName = StringType()
47     modelVersion = StringType()
48     modelVersionId = StringType()
49     modelType = StringType()
50     operationalStatus = StringType()
51
52
53 class ExistingLicenseInfo(OSDFModel):
54     entitlementPoolUUID = ListType(StringType())
55     licenseKeyGroupUUID = ListType(StringType())
56
57
58 class LicenseDemand(OSDFModel):
59     resourceInstanceType = StringType(required=True)
60     serviceResourceId = StringType(required=True)
61     resourceModuleName = StringType(required=True)
62     resourceModelInfo = ModelType(ResourceModelInfo)
63     existingLicense = ModelType(ExistingLicenseInfo)
64
65
66 class PlacementDemand(OSDFModel):
67     resourceInstanceType = StringType(required=True)
68     serviceResourceId = StringType(required=True)
69     resourceModuleName = StringType(required=True)
70     exclusionCandidateInfo = ListType(ModelType(CandidateInfo))
71     requiredCandidateInfo = ListType(ModelType(CandidateInfo))
72     resourceModelInfo = ModelType(ResourceModelInfo)
73     tenantId = StringType()
74     tenantName = StringType()
75
76
77 class ExistingPlacementInfo(OSDFModel):
78     serviceInstanceId = StringType(required=True)
79
80
81 class DemandInfo(OSDFModel):
82     """Requested resources (sent as part of a request from client)"""
83     placementDemand = ListType(ModelType(PlacementDemand))
84     licenseDemand = ListType(ModelType(LicenseDemand))
85
86
87 class SubscriberInfo(OSDFModel):
88     """Details on the customer that subscribes to the VNFs"""
89     globalSubscriberId = StringType(required=True)
90     subscriberName = StringType()
91     subscriberCommonSiteId = StringType()
92
93
94 class ServiceModelInfo(OSDFModel):
95     """ASDC Service model information"""
96     modelType = StringType(required=True)
97     modelInvariantId = StringType(required=True)
98     modelVersionId = StringType(required=True)
99     modelName = StringType(required=True)
100     modelVersion = StringType(required=True)
101
102
103 class Location(OSDFModel):
104     latitude = FloatType(required=True)
105     longitude = FloatType(required=True)
106
107
108 class PlacementInfo(OSDFModel):
109     """Information specific to placement optimization"""
110     serviceModelInfo = ModelType(ServiceModelInfo)
111     subscriberInfo = ModelType(SubscriberInfo)
112     demandInfo = ModelType(DemandInfo, required=True)
113     orderInfo = StringType()
114     policyId = ListType(StringType())
115     serviceInstanceId = StringType()
116     existingPlacement = ModelType(ExistingPlacementInfo)
117     location = ModelType(Location)
118     serviceType = StringType()
119
120
121 class PlacementAPI(OSDFModel):
122     """Request for placement optimization (specific to optimization and additional metadata"""
123     requestInfo = ModelType(RequestInfo, required=True)
124     placementInfo = ModelType(PlacementInfo, required=True)