Card |
---|
| Value will be pass as input. For any resources that should be resolved by passing the value as input, similar model should be used. In that case, the request payload will expect a parameter name unit-number Code Block |
---|
| {
"tags": "unit-number",
"name": "unit-number",
"property": {
"description": "unit-number",
"type": "string"
},
"updated-by": "adetalhouet",
"sources": {
"input": {
"type": "source-input"
}
}
} |
|
Card |
---|
| Value will be defaulted. Code Block |
---|
| {
"tags": "prefix-id",
"name": "prefix-id",
"property" :{
"description": "prefix-id",
"type": "integer"
},
"updated-by": "adetalhouet",
"sources": {
"default": {
"type": "source-default",
}
"properties": {
}
}
}
}}
} |
|
Card |
---|
| Value will be resolved through REST. Modeling reference: CDS Modeling Concepts In this example, we're making a POST request to an IPAM system with no payload. Some ingredients are required to perform the query, in this case, $prefixId . Hence It is provided as an input-key-mapping and defined as a key-dependencies. Please refer to the modeling guideline for more in depth understanding. As part of this request, the expected response will be as bellow. What is of interest is the address field, as this is what we're trying to resolve. Code Block |
---|
theme | Eclipse |
---|
title | response |
---|
collapse | true |
---|
| { | Code Block |
---|
theme | Eclipse |
---|
title | create_netbox_ip_address |
---|
| {
"tags" : "oam-local-ipv4-address",
"name" : "create_netbox_ip",
"propertyid" : {4,
"descriptionaddress" : "netbox ip192.168.10.2/32",
"typevrf": null,
"tenant": "dt-netbox-ip"null,
"status": 1,
}"role": null,
"updated-by" interface": null,
"description": "adetalhouet",
"sourcesnat_inside" : {null,
"created": "primary2018-config08-data30",
: {
"type" : "source-rest",
"properties" : {
"type" : "JSON",
"verb" : "POST",
"endpoint-selector" : "ipam-1",
"url-path" : "/api/ipam/prefixes/$prefixId/available-ips/",
"path" : "/address",
"input-key-mapping" : {
"prefixId" : "prefix-id"
},
"output-key-mapping" : {
"address" : "address"
}, "last_updated": "2018-08-30T14:59:05.277820Z"
} |
To tell the resolution framework what is of interest in the response, the path property can be used, which uses JSON_PATH, to get the value. Code Block |
---|
theme | Eclipse |
---|
title | create_netbox_ip_address |
---|
| {
"tags" : "oam-local-ipv4-address",
"name" : "create_netbox_ip",
"property" : {
"description" : "netbox ip",
"type" : "dt-netbox-ip"
},
"updated-by" : "adetalhouet",
"sources" : {
"primary-config-data" : {
"type" : "source-rest",
"properties" : {
"type" : "JSON",
"verb" : "POST",
"endpoint-selector" : "ipam-1",
"url-path" : "/api/ipam/prefixes/$prefixId/available-ips/",
"path" : "/address",
"input-key-mapping" : {
"prefixId" : "prefix-id"
},
"output-key-mapping" : {
"address" : "address"
},
"key-dependencies" : [ "prefix-id" ]
}
}
}
} |
|
Card |
---|
| Value will be resolved through a database. Modeling reference: CDS Modeling Concepts In this example, we're making a SQL to the primary database. Some ingredients are required to perform the query, in this case, $vfmoudleid . Hence It is provided as an input-key-mapping and defined as a key-dependencies. Please refer to the modeling guideline for more in depth understanding. As part of this request, the expected response will be as put in value . In the output-key-mapping section, that value will be mapped to the expected resource name to resolve. Code Block |
---|
theme | Eclipse |
---|
title | vf-module-type |
---|
| {
"name": "vf-module-type",
"tags": "vf-module-type",
"property": {
"description": "vf-module-type",
"type": "string"
},
"updated-by": "adetalhouet",
"sources": {
"primary-db": {
"type": "source-primary-db",
"properties": {
"type": "SQL",
"query": "select sdnctl.demo.value as value from sdnctl.demo where sdnctl.demo.id=:vfmoduleid",
"input-key-mapping": {
"vfmoduleid": "vf-module-number"
},
"output-key-mapping": {
"vf-module-type": "value"
},
"key-dependencies": [
"vf-module-number"
]
}
}
}
} |
|
Card |
---|
| Value will be resolved through a the execution of a script. Modeling reference: CDS Modeling Concepts In this example, we're making use of a Python script. Some ingredients are required to perform the query, in this case, $vf-module-type . Hence It is provided as a key-dependencies. Please refer to the modeling guideline for more in depth understanding. As part of this request, the expected response will set within the script itself. Code Block |
---|
theme | Eclipse |
---|
title | interface-description |
---|
| {
"tags": "interface-description",
"name": "interface-description",
"property": {
"description": "interface-description",
"type": "string"
},
"updated-by": "adetalhouet",
"sources": {
"capability": {
"type": "source-capability",
"properties": {
"script-type": "jython",
"script-class-reference": "Scripts/python/DescriptionExample.py",
"instance-dependencies": [],
"key-dependencies": [
"vf-module-type"
]
}
}
}
} |
The script itself is as follow. The key is to have the script class derived from the framework standards. In the case of resource resolution, the class to derive from is AbstractRAProcessor It will give the required methods to implement: process and recover , along with some utility functions, such as set_resource_data_value or addError . These functions either come from the AbstractRAProcessor class, or from the class it derived from. FIX ME - give more information about scripting Code Block |
---|
theme | Eclipse |
---|
title | Scripts/python/DescriptionExample.py |
---|
collapse | true |
---|
| # Copyright (c) 2019 Bell Canada.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from abstract_ra_processor import AbstractRAProcessor
from blueprint_constants import *
from java.lang import Exception as JavaException
class DescriptionExample(AbstractRAProcessor):
def process(self, resource_assignment):
"key-dependencies" : [ "prefix-id" ]try:
}
# get }
}dependencies result
} |
| Card |
---|
| Code Block |
---|
| {
"name": "vf-module-type",
"tags": "vf-module-type",
"property": {
value "description": = self.raRuntimeService.getStringFromResolutionStore("vf-module-type",
"type": "string")
},
"updated-by": "adetalhouet",
"sources": {
"primary-db": {
"type": "source-primary-db",
# logic "properties": {
based on dependency outcome
"type": result = "SQL",
"query": "select sdnctl.demo.value asif value from sdnctl.demo where sdnctl.demo.id=:vfmoduleid",== "vfw":
"input-key-mapping": {
result = "This "vfmoduleid": "vf-module-number"
is the Virtual Firewall entity"
},
elif value == "output-key-mappingvsn": {
result = "vf-module-type": "valueThis is the Virtual Sink entity"
},
elif value == "key-dependenciesvpg": [
result = "vf-module-number"
This is the Virtual Packet Generator"
]
}
# set }
value }
} |
| Card |
---|
| Code Block |
---|
| {
"tags": "interface-description",
"name": "interface-description",
"property": {
"description": "interface-description",
"type": "string"
},
"updated-by": "adetalhouet",
"sources": {
"capability": {
for resource getting currently resolved
self.set_resource_data_value(resource_assignment, result)
except JavaException, err:
log.error("Java Exception in the script {}", err)
"type": "source-capability",except Exception, err:
"properties": {
log.error("Python Exception in the "script-type": {}"jython", err)
"script-class-reference": "DescriptionExample",return None
def recover(self, "instance-dependencies": [
runtime_exception, resource_assignment):
]
print self.addError(runtime_exception.getMessage())
}
return }None
}
} |
|
|