Traffic Distributtion support added
[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 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     unique = BooleanType() # to be implemented on the policy level
75     resourceModelInfo = ModelType(ModelMetaData, required=True)
76     existingCandidates = ListType(ModelType(Candidates))
77     excludedCandidates = ListType(ModelType(Candidates))
78     requiredCandidates = ListType(ModelType(Candidates))
79
80
81 class ServiceInfo(OSDFModel):
82     serviceInstanceId = StringType(required=True)
83     modelInfo = ModelType(ModelMetaData, required=True)
84     serviceName = StringType(required=True)
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 PlacementInfo(OSDFModel):
95     """Information specific to placement optimization"""
96     requestParameters = DictType(BaseType)
97     placementDemands = ListType(ModelType(PlacementDemand), min_size=1)
98     subscriberInfo = ModelType(SubscriberInfo)
99
100
101 class PlacementAPI(OSDFModel):
102     """Request for placement optimization (specific to optimization and additional metadata"""
103     requestInfo = ModelType(RequestInfo, required=True)
104     placementInfo = ModelType(PlacementInfo, required=True)
105     licenseInfo = ModelType(LicenseInfo)
106     serviceInfo = ModelType(ServiceInfo, required=True)