Steve Siani | 19dfd63 | 2019-08-15 21:42:50 -0400 | [diff] [blame] | 1 | from netconf_constant import * |
Brinda Santh | a0140de | 2019-07-18 16:59:19 -0400 | [diff] [blame] | 2 | from org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor import NetconfExecutorExtensionsKt |
Cherukuri, Venkatanaresh (vn166g) | 8df5693 | 2019-02-05 09:47:55 -0500 | [diff] [blame] | 3 | |
Alexis de Talhouët | a69b9f5 | 2019-02-18 08:08:24 -0500 | [diff] [blame] | 4 | |
Cherukuri, Venkatanaresh (vn166g) | 8df5693 | 2019-02-05 09:47:55 -0500 | [diff] [blame] | 5 | class NetconfClient: |
| 6 | |
Brinda Santh | a0140de | 2019-07-18 16:59:19 -0400 | [diff] [blame] | 7 | def __init__(self, log, component_function, requirement_name): |
| 8 | self.log = log |
| 9 | self.component_function = component_function |
| 10 | netconf_device = NetconfExecutorExtensionsKt.netconfDevice(component_function, requirement_name) |
| 11 | self.netconf_rpc_client = netconf_device.netconfRpcService |
| 12 | self.netconf_session = netconf_device.netconfSession |
Muthuramalingam, Brinda Santh | f7c6579 | 2019-02-12 15:26:19 -0500 | [diff] [blame] | 13 | |
Brinda Santh | a0140de | 2019-07-18 16:59:19 -0400 | [diff] [blame] | 14 | def disconnect(self): |
| 15 | self.netconf_session.disconnect() |
| 16 | return |
Cherukuri, Venkatanaresh (vn166g) | 8df5693 | 2019-02-05 09:47:55 -0500 | [diff] [blame] | 17 | |
Brinda Santh | a0140de | 2019-07-18 16:59:19 -0400 | [diff] [blame] | 18 | def connect(self): |
| 19 | self.netconf_session.connect() |
| 20 | return |
Cherukuri, Venkatanaresh (vn166g) | 8df5693 | 2019-02-05 09:47:55 -0500 | [diff] [blame] | 21 | |
Brinda Santh | a0140de | 2019-07-18 16:59:19 -0400 | [diff] [blame] | 22 | def lock(self, config_target=CONFIG_TARGET_CANDIDATE): |
| 23 | device_response = self.netconf_rpc_client.lock(config_target) |
| 24 | return device_response |
Cherukuri, Venkatanaresh (vn166g) | 8df5693 | 2019-02-05 09:47:55 -0500 | [diff] [blame] | 25 | |
Brinda Santh | a0140de | 2019-07-18 16:59:19 -0400 | [diff] [blame] | 26 | def get_config(self, filter="", config_target=CONFIG_TARGET_RUNNING): |
| 27 | device_response = self.netconf_rpc_client.getConfig(filter, config_target) |
| 28 | return device_response |
Cherukuri, Venkatanaresh (vn166g) | 8df5693 | 2019-02-05 09:47:55 -0500 | [diff] [blame] | 29 | |
Brinda Santh | a0140de | 2019-07-18 16:59:19 -0400 | [diff] [blame] | 30 | def edit_config(self, message_content, config_target=CONFIG_TARGET_CANDIDATE, |
| 31 | edit_default_peration=CONFIG_DEFAULT_OPERATION_REPLACE): |
| 32 | device_response = self.netconf_rpc_client.editConfig(message_content, |
| 33 | config_target, |
| 34 | edit_default_peration) |
| 35 | return device_response |
Cherukuri, Venkatanaresh (vn166g) | 8df5693 | 2019-02-05 09:47:55 -0500 | [diff] [blame] | 36 | |
Brinda Santh | a0140de | 2019-07-18 16:59:19 -0400 | [diff] [blame] | 37 | def commit(self, confirmed=False, confirm_timeout=60, persist="", |
| 38 | persist_id=""): |
| 39 | device_response = self.netconf_rpc_client.commit(confirmed, confirm_timeout, |
| 40 | persist, persist_id) |
| 41 | return device_response |
Alexis de Talhouët | 18e1857 | 2019-02-19 10:02:00 -0500 | [diff] [blame] | 42 | |
Brinda Santh | a0140de | 2019-07-18 16:59:19 -0400 | [diff] [blame] | 43 | def invoke_rpc(self, rpc): |
| 44 | device_response = self.netconf_rpc_client.invokeRpc(rpc) |
| 45 | return device_response |
Alexis de Talhouët | 1a19d33 | 2019-03-11 22:22:30 -0400 | [diff] [blame] | 46 | |
Brinda Santh | a0140de | 2019-07-18 16:59:19 -0400 | [diff] [blame] | 47 | def cancel_commit(self, persist_id=""): |
| 48 | device_response = self.netconf_rpc_client.cancelCommit(persist_id) |
| 49 | return device_response |
Cherukuri, Venkatanaresh (vn166g) | 8df5693 | 2019-02-05 09:47:55 -0500 | [diff] [blame] | 50 | |
Brinda Santh | a0140de | 2019-07-18 16:59:19 -0400 | [diff] [blame] | 51 | def unlock(self, config_target=CONFIG_TARGET_CANDIDATE): |
| 52 | device_response = self.netconf_rpc_client.unLock(config_target) |
| 53 | return device_response |
Cherukuri, Venkatanaresh (vn166g) | 8df5693 | 2019-02-05 09:47:55 -0500 | [diff] [blame] | 54 | |
Brinda Santh | a0140de | 2019-07-18 16:59:19 -0400 | [diff] [blame] | 55 | def validate(self, config_target=CONFIG_TARGET_CANDIDATE): |
| 56 | device_response = self.netconf_rpc_client.validate(config_target) |
| 57 | return device_response |
Cherukuri, Venkatanaresh (vn166g) | 8df5693 | 2019-02-05 09:47:55 -0500 | [diff] [blame] | 58 | |
Brinda Santh | a0140de | 2019-07-18 16:59:19 -0400 | [diff] [blame] | 59 | def discard_change(self): |
| 60 | device_response = self.netconf_rpc_client.discardConfig() |
| 61 | return device_response |
Steve Siani | 19dfd63 | 2019-08-15 21:42:50 -0400 | [diff] [blame] | 62 | |
| 63 | def set_execution_attribute_response_data(self, response_data): |
| 64 | self.setAttribute(ATTRIBUTE_RESPONSE_DATA, response_data) |
Steve Siani | 6dec3fb | 2019-08-27 14:58:30 -0400 | [diff] [blame^] | 65 | |
| 66 | def get(self, filter_content): |
| 67 | device_response = self.netconf_rpc_client.get(filter_content) |
| 68 | return device_response |
| 69 | |
| 70 | def set_execution_attribute_response_data(self, response_data): |
| 71 | self.component_function.setAttribute(ATTRIBUTE_RESPONSE_DATA, response_data) |