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