1 # Copyright (c) 2019 Bell Canada.
\r
3 # Licensed under the Apache License, Version 2.0 (the "License");
\r
4 # you may not use this file except in compliance with the License.
\r
5 # You may obtain a copy of the License at
\r
7 # http://www.apache.org/licenses/LICENSE-2.0
\r
9 # Unless required by applicable law or agreed to in writing, software
\r
10 # distributed under the License is distributed on an "AS IS" BASIS,
\r
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
12 # See the License for the specific language governing permissions and
\r
13 # limitations under the License.
\r
15 import netconf_constant
\r
16 from common import ResolutionHelper
\r
17 from time import sleep
\r
18 from netconfclient import NetconfClient
\r
19 from org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor import \
\r
20 NetconfComponentFunction
\r
23 class ConfigDeploy(NetconfComponentFunction):
\r
25 def process(self, execution_request):
\r
26 log = globals()[netconf_constant.SERVICE_LOG]
\r
28 # print("Waiting 4 minutes until NETCONF server is UP on vLB ...")
\r
30 nc = NetconfClient(log, self, "netconf-connection")
\r
31 rr = ResolutionHelper(self)
\r
33 # Get meshed template from DB
\r
34 resolution_key = self.getDynamicProperties("resolution-key").asText()
\r
35 payloadHostname = rr.retrieve_resolved_template_from_database(resolution_key, "baseconfig")
\r
36 payloadInterface = rr.retrieve_resolved_template_from_database(resolution_key, "incremental-config")
\r
40 #if not response.isSuccess():
\r
41 # og.error(response.errorMessage)
\r
43 nc.edit_config(message_content=payloadInterface, edit_default_peration="merge")
\r
44 nc.edit_config(message_content=payloadHostname, edit_default_peration="merge")
\r
47 nc.get_config() #nc.commit(confirmed = True, confirm_timeout=15)
\r
51 def recover(self, runtime_exception, execution_request):
\r
52 log.error("Exception in the script {}", runtime_exception)
\r
53 print self.addError(runtime_exception.cause.message)
\r