No relevant resource is found in the selected language.

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Read our privacy policy>Search

Reminder

To have a better experience, please upgrade your IE browser.

upgrade

RESTful API Reference

CloudEngine 12800 and 12800E V200R005C10

This document describes the OPS APIs supported by the device, including OPS-supported operations, request examples, elements in the requests, response examples, elements in the responses, and response status codes.
Rate and give feedback:
Huawei uses machine translation combined with human proofreading to translate this document to different languages in order to help you better understand the content of this document. Note: Even the most advanced machine translation cannot match the quality of professional translators. Huawei shall not bear any responsibility for translation accuracy and it is recommended that you refer to the English document (a link for which has been provided).
Save and Restore Script Variables

Save and Restore Script Variables

  • Function Description

    The OPS ERE allows script variables to be saved and restored.

  • Command Prototype

    opsObj.context.save(varName, value)

    opsObj.context.retrieve(varName)

  • Parameter Description
    Table 31-10 Parameters supported by APIs for saving and restoring script variables

    Method

    Description

    opsObj

    Specifies an OPS object. It is obtained using ops.ops() in instance mode.

    varName

    Specifies the name of a variable. The value is a string of a maximum of 16 characters.

    value

    Specifies the value of a variable. The value can be a string of a maximum of 1024 characters or an integer ranging from –2147483648 to 2147483647.

  • Example
    test.py
    
    import ops
    test = ops.ops()
    print 'test context save'
    a, des= test.context.save("varInt1", 111)
    print 'save varInt1 return' , a
    a, des= test.context.save("varStr2", 'testString')
    print 'save varStr2 return' , a
    print 'test context save over'
    
    test.py
    import ops
    test = ops.ops()
    print 'test context retrieve'
    a, des = test.context.retrieve("varInt1")
    print 'retrieve varInt1 = ', a
    a, des = test.context.retrieve("varStr2")
    print 'retrieve varStr2 = ', a
    print 'test context retrieve over'
  • Description of Return Values
    NOTE:

    A maximum of 100 script variables can be stored. A variable with the same name as one that has been stored will replace this one.

    • Return value of opsObj.context.save()

      First return value: The value 0 indicates a success; the value 1 indicates a failure.

      Second return value: result description expressed in character strings.

    • Return value of opsObj.context.retrieve

      First return value: If None is returned, restoring a specified variable fails. Otherwise, specified variable values are returned.

      Second return value: result description expressed in character strings.

Translation
Download
Updated: 2019-04-03

Document ID: EDOC1100075372

Views: 10698

Downloads: 16

Average rating:
This Document Applies to these Products
Related Documents
Related Version
Share
Previous Next