def edit_config(self, provider, target, config, default_operation=None, error_option=None, test_option=None): """ Execute an edit-config operation to load all or part of a specified configuration to the specified target configuration. Args: - provider: An instance of ydk.providers.ServiceProvider - target: Particular configuration to edit - config: Inline Config content - default_operation: The default operation to use - error_option: The error option to use - test_option: The test option to use Returns: - ok reply if operation succeeds else, raises an exception Raises: `YPYDataValidationError <ydk.errors.html#ydk.errors.YPYDataValidationError>`_ if validation error occurs. `YPYError <ydk.errors.html#ydk.errors.YPYError>`_ if other error has occurred. Possible errors could be - a server side error - if there isn't enough information in the entity to prepare the message (missing keys for example) """ assert target is not None assert config is not None if default_operation is not None: assert isinstance( default_operation, ietf_netconf.EditConfigRpc.Input.DefaultOperation_Enum) if error_option is not None: assert isinstance( error_option, ietf_netconf.EditConfigRpc.Input.ErrorOption_Enum) if test_option is not None: assert isinstance(test_option, ietf_netconf.EditConfigRpc.Input.TestOption_Enum) rpc = ietf_netconf.EditConfigRpc() rpc.input.target = _get_rpc_datastore_object(target, rpc.input.target) rpc.input.config = config rpc.input.default_operation = default_operation rpc.input.error_option = error_option rpc.input.test_option = test_option return self.executor.execute_rpc(provider, rpc)
def test_execute_edit_commit_get_rpc(self): runner = ysanity.Runner() runner.one.number = 1 runner.one.name = 'runner:one:name' edit_rpc = ietf_netconf.EditConfigRpc() edit_rpc.input.target.candidate = Empty() edit_rpc.input.config = runner op = self.executor.execute_rpc(self.ncc, edit_rpc) self.assertIn('ok', op) commit_rpc = ietf_netconf.CommitRpc() op = self.executor.execute_rpc(self.ncc, commit_rpc) self.assertIn('ok', op) get_rpc = ietf_netconf.GetRpc() get_rpc.input.filter = ysanity.Runner() op = self.executor.execute_rpc(self.ncc, get_rpc) self.assertIn(runner.one.name, op)
def test_execute_get_config_rpc(self): get_config_rpc = ietf_netconf.GetConfigRpc() get_config_rpc.input.source.candidate = Empty() initial_candidate_data = self.executor.execute_rpc( self.ncc, get_config_rpc) runner = ysanity.Runner() runner.two.number = 2 runner.two.name = 'runner:two:name' edit_rpc = ietf_netconf.EditConfigRpc() edit_rpc.input.target.candidate = Empty() edit_rpc.input.config = runner op = self.executor.execute_rpc(self.ncc, edit_rpc) self.assertIn('ok', op) final_candidate_data = self.executor.execute_rpc( self.ncc, get_config_rpc) self.assertNotEqual(initial_candidate_data, final_candidate_data) self.assertNotIn(runner.two.name, initial_candidate_data) self.assertIn(runner.two.name, final_candidate_data)