Example #1
0
    def commit_confirmed(self, provider, confirm_timeout=None, persist=False, persist_id=None):
        """ Execute a commit operation to commit the candidate configuration with a confirmed option.

            Args:
                - provider: An instance of ydk.providers.ServiceProvider
                - confirm_timeout: The timeout interval for a confirmed commit
                - persist: This parameter is used to make a confirmed commit persistent. A persistent confirmed commit
                 is not aborted if the NETCONF session terminates.  The only way to abort a persistent confirmed commit
                 is to let the timer expire, or to use the <cancel-commit> operation. The value of this parameter is
                 a token that must be given in the 'persist-id' parameter of <commit> or <cancel-commit> operations
                 in order to confirm or cancel the persistent confirmed commit.  The token should be a random string
                - persist_id: This parameter is given in order to commit a persistent confirmed commit. The value must
                 be equal to the value given in the 'persist' parameter to the <commit> operation. If it does not match,
                 the operation fails with an 'invalid-value' error

           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)
        """
        rpc = ietf_netconf.CommitRpc()
        rpc.input.confirm_timeout = confirm_timeout
        rpc.input.persist_id = persist_id
        if persist:
            rpc.input.persist = Empty()

        return self.executor.execute_rpc(provider, rpc)
Example #2
0
    def commit(self, provider):
        """ Execute a commit operation to commit the candidate configuration as the device's new
            current configuration.

            Args:
                - provider: An instance of ydk.providers.ServiceProvider

           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)
        """
        return self.executor.execute_rpc(provider, ietf_netconf.CommitRpc())
Example #3
0
    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)