def process(self, execution_request): log = globals()[netconf_constant.SERVICE_LOG] print(globals()) # print("Waiting 4 minutes until NETCONF server is UP on vLB ...") # sleep (240) nc = NetconfClient(log, self, "netconf-connection") rr = ResolutionHelper(self) # Get meshed template from DB resolution_key = self.getDynamicProperties("resolution-key").asText() payloadHostname = rr.retrieve_resolved_template_from_database( resolution_key, "baseconfig") payloadInterface = rr.retrieve_resolved_template_from_database( resolution_key, "incremental-config") nc.connect() nc.lock() #if not response.isSuccess(): # og.error(response.errorMessage) nc.discard_change() nc.edit_config(message_content=payloadInterface, edit_default_peration="merge") nc.edit_config(message_content=payloadHostname, edit_default_peration="merge") #nc.validate() nc.commit() nc.get_config() #nc.commit(confirmed = True, confirm_timeout=15) nc.unlock() nc.disconnect()
def process(self, execution_request): log = globals()[netconf_constant.SERVICE_LOG] print(globals()) nc = NetconfClient(log, self, "netconf-connection") rr = ResolutionHelper(self) # Get meshed template from DB resolution_key = self.getDynamicProperties("resolution-key").asText() payloadHostname = rr.retrieve_resolved_template_from_database( resolution_key, "hostname") payloadInterface = rr.retrieve_resolved_template_from_database( resolution_key, "vfw-interface") nc.connect() nc.lock() #if not response.isSuccess(): # og.error(response.errorMessage) nc.discard_change() nc.edit_config(message_content=payloadInterface, edit_default_peration="none") nc.edit_config(message_content=payloadHostname, edit_default_peration="none") nc.validate() nc.commit() #nc.commit(confirmed = True, confirm_timeout=15) nc.unlock() nc.disconnect()
def process(self, execution_request): try: log = globals()[netconf_constant.SERVICE_LOG] print(globals()) nc = NetconfClient(log, self, "netconf-connection") rr = ResolutionHelper(self) payload = rr.resolve_and_generate_message_from_template_prefix( "hostname") nc.connect() response = nc.lock() if not response.isSuccess(): log.error(response.errorMessage) nc.edit_config(message_content=payload, edit_default_peration="none") nc.validate() nc.discard_change() nc.validate() nc.commit() nc.unlock() nc.disconnect() except JavaException, err: log.error("Java Exception in the script {}", err)
def process(self, execution_request): log = globals()[netconf_constant.SERVICE_LOG] print(globals()) nc = NetconfClient(log, self, "netconf-connection") rr = ResolutionHelper(self) # rollback config on device nc.connect() payloadHostnameRollback = rr.resolve_and_generate_message_from_template_prefix( "junos-rollback-RPC") nc.invoke_rpc(payloadHostnameRollback) nc.commit() nc.disconnect() return None