Beispiel #1
0
def main():
    import numpy
    import ops
    a=numpy.array([1,2,3])
    o = ops.ops()
    test1 = [o['+'], a, [o['-'], 3, 1]]
    print evaluate(test1)
Beispiel #2
0
def save_config(ops_conn):
    _ops = ops.ops()
    handle, err_desp  = _ops.cli.open()
    choice = {"Continue": "y", "continue": "y"}
    _ops.cli.execute(handle,"save",choice)
    _ops.cli.close(handle)
    return OK
Beispiel #3
0
def clear_ops_conf(ops_conn):
    _ops = ops.ops()
    handle,_ = _ops.cli.open()
    _ops.cli.execute(handle,"sys")
    _ops.cli.execute(handle,"ops")
    _ops.cli.execute(handle,"undo script-assistant python ztp_add_on.py")
    _ops.cli.execute(handle,"comm")
    ret = _ops.cli.close(handle)
Beispiel #4
0
def delete_temp_vlan(ops_conn):
    _ops = ops.ops()
    handle, err_desp  = _ops.cli.open()
    _ops.cli.execute(handle,"sys")
    _ops.cli.execute(handle,"undo int vlanif " + VLAN_ID)
    _ops.cli.execute(handle,"undo vlan " + VLAN_ID)
    _ops.cli.execute(handle,"comm")
    ret = _ops.cli.close(handle)
    return OK
Beispiel #5
0
def delete_logfile(ops_conn):

    _ops = ops.ops()
    handle,_ = _ops.cli.open()
    choice = {"Continue": "y", "continue": "y"}
    _ops.cli.execute(handle,"del /u " + LOG_FILE_EXECUTE,choice)
    _ops.cli.close(handle)
    
    return OK
Beispiel #6
0
def delete_aaa_user(ops_conn):
    _ops = ops.ops()
    handle, err_desp = _ops.cli.open()
    _ops.cli.execute(handle, "sys")
    _ops.cli.execute(handle, "aaa")
    _ops.cli.execute(handle, "undo local-user " + USERNAME)
    _ops.cli.execute(handle, "com")
    ret = _ops.cli.close(handle)
    return OK
Beispiel #7
0
def undo_shutdown_port(ops_conn,portName):

    _ops = ops.ops()

    handle, err_desp  = _ops.cli.open()
    _ops.cli.execute(handle,"sys")
    _ops.cli.execute(handle,"int " + portName)
    _ops.cli.execute(handle,"undo shutdown")
    _ops.cli.execute(handle,"comm")
    ret = _ops.cli.close(handle)
    return OK
Beispiel #8
0
def delete_call_home(ops_conn):
    _ops = ops.ops()
    handle, err_desp = _ops.cli.open()
    choice = {"Continue": "y", "continue": "y", "exiting": "y"}
    _ops.cli.execute(handle, "sys", None)
    _ops.cli.execute(handle, "netconf", None)
    _ops.cli.execute(handle, "undo callhome huawei", choice)
    _ops.cli.execute(handle, "com", None)
    _ops.cli.close(handle)
    ret = _ops.cli.close(handle)
    return OK
Beispiel #9
0
def set_interface_description(ops_conn,ifIndexMsg):
    _ops = ops.ops()

    handle, err_desp  = _ops.cli.open()
    _ops.cli.execute(handle,"sys")
    _ops.cli.execute(handle,"interface " + ifIndexMsg['portIndex'])
    _ops.cli.execute(handle,"description To_" + ifIndexMsg['peerSysname'] + "_" +ifIndexMsg['remoteIp'].split('/')[0]+'_' + ifIndexMsg['peerPortIndex'])
    _ops.cli.execute(handle,"comm")

    _ops.cli.close(handle)

    return OK
Beispiel #10
0
def clear_port_identityTlv(ops_conn, intName):

    _ops = ops.ops()
    handle, err_desp = _ops.cli.open()
    _ops.cli.execute(handle, "sys")
    _ops.cli.execute(handle, "int " + intName)
    _ops.cli.execute(handle, "undo identity enable")
    _ops.cli.execute(handle, "undo port identity")
    _ops.cli.execute(handle, "commit")
    _ops.cli.close(handle)

    return OK
Beispiel #11
0
def set_layer_interface_description(ops_conn,local_port,description):
    _ops = ops.ops()

    handle, err_desp  = _ops.cli.open()
    _ops.cli.execute(handle,"sys")
    _ops.cli.execute(handle,"interface " + local_port)
    _ops.cli.execute(handle,"description " + description)
    _ops.cli.execute(handle,"comm")

    _ops.cli.close(handle)

    return OK
Beispiel #12
0
def set_bgp_info(ops_conn, rows1, ifIndexMsg):
    # isSpine = False
    # if rows1['Device Role']!=None:
    #     isSpine= rows1['Device Role'].lower().strip()=='spine'
    # ipAddress     = ifIndexMsg['peerLpbackIp'].split('/')[0]
    # ipAddress     = ifIndexMsg['connIp'].split('/')[0]
    _ops = ops.ops()
    handle, err_desp  = _ops.cli.open()
    _ops.cli.execute(handle,"sys")
    if rows1['Device Role'].lower().strip()=='spinerr':
        ipAddress     = ifIndexMsg['peerLpbackIp'].split('/')[0]
        logging.info("Set bgp peer, AS Number is  %s: IP=%s ", rows1['As Num'], ipAddress)
        _ops.cli.execute(handle,"bgp " + rows1['As Num']+' instance evpn')
        _ops.cli.execute(handle,"peer " + ipAddress + " as-number " + rows1['As Num'])
        _ops.cli.execute(handle,"peer " + ipAddress + " connect-interface LoopBack1")
        _ops.cli.execute(handle,"peer " + ipAddress + " description  " + get_lldp_port_sysname(ops_conn,ifIndexMsg['portIndex']))
        _ops.cli.execute(handle,"peer " + ipAddress + " bfd min-tx-interval 200 min-rx-interval 200 detect-multiplier 5")
        _ops.cli.execute(handle,"peer " + ipAddress + " bfd enable")
        _ops.cli.execute(handle,"l2vpn-family evpn")
        _ops.cli.execute(handle,"peer " + ipAddress + " enable")
        _ops.cli.execute(handle,"peer " + ipAddress + " advertise irb")
        _ops.cli.execute(handle,"peer " + ipAddress + " reflect-client")
        ipAddress     = ifIndexMsg['remoteIp'].split('/')[0]
        _ops.cli.execute(handle,"bgp 102")
        _ops.cli.execute(handle,"peer " + ipAddress + " group FB1-Leaf")
        # print('JxinBain spinerr description :' + get_lldp_port_sysname(ops_conn,ifIndexMsg['portIndex']))
        logging.info('JxinBain spinerr description :' + get_lldp_port_sysname(ops_conn,ifIndexMsg['portIndex']))
        _ops.cli.execute(handle,"peer " + ipAddress + " description  " + get_lldp_port_sysname(ops_conn,ifIndexMsg['portIndex']))
    elif rows1['Device Role'].lower().strip()=='spine':
        ipAddress     = ifIndexMsg['remoteIp'].split('/')[0]
        _ops.cli.execute(handle,"bgp 102")
        _ops.cli.execute(handle,"peer " + ipAddress + " group FB1-Leaf")
        # print('JxinBain spine description :' + get_lldp_port_sysname(ops_conn,ifIndexMsg['portIndex']))
        logging.info('JxinBain spine description :' + get_lldp_port_sysname(ops_conn,ifIndexMsg['portIndex']))
        _ops.cli.execute(handle,"peer " + ipAddress + " description  " + get_lldp_port_sysname(ops_conn,ifIndexMsg['portIndex']))
    # elif rows1['Device Role'].lower().strip()=='leaf':
    #     ipAddress     = ifIndexMsg['peerLpbackIp'].split('/')[0]
    #     logging.info("Set bgp peer, AS Number is  %s: IP=%s ", rows1['As Num'], ipAddress)
    #     _ops.cli.execute(handle,"bgp " + rows1['As Num']+' instance evpn')
    #     _ops.cli.execute(handle,"peer " + ipAddress + " as-number " + rows1['As Num'])
    #     _ops.cli.execute(handle,"peer " + ipAddress + " connect-interface LoopBack0")
    #     _ops.cli.execute(handle,"l2vpn-family evpn")
    #     _ops.cli.execute(handle,"peer " + ipAddress + " enable")
    #     _ops.cli.execute(handle,"peer " + ipAddress + " advertise irb")
    #     ipAddress     = ifIndexMsg['remoteIp'].split('/')[0]
    #     _ops.cli.execute(handle,"bgp 101")
    #     _ops.cli.execute(handle,"peer " + ipAddress + " group Spine")
    #     _ops.cli.execute(handle,"peer " + ipAddress + " as-number 102")
    #     _ops.cli.execute(handle,"peer " + ipAddress + " description  " + get_lldp_port_sysname(ops_conn,ifIndexMsg['portIndex']))
    _ops.cli.execute(handle,"comm")
    _ops.cli.close(handle)
    return  OK
Beispiel #13
0
def clear_portl3_conf(ops_conn, portMsg):

    _ops = ops.ops()

    handle, err_desp = _ops.cli.open()
    _ops.cli.execute(handle, "sys")
    _ops.cli.execute(handle, "int " + portMsg['portIndex'])
    _ops.cli.execute(handle, "undo ip address")
    ret = _ops.cli.execute(handle, "portswitch")
    _ops.cli.execute(handle, "com")
    _ops.cli.close(handle)

    return OK
Beispiel #14
0
def ops_execute_undo_portswitch_info(portName):

    _ops = ops.ops()

    handle, err_desp  = _ops.cli.open()
    _ops.cli.execute(handle,"sys")
    _ops.cli.execute(handle,"int " + portName)
    rsp_data = _ops.cli.execute(handle,"display this | include undo portswitch")
    for paras in rsp_data:
        paras_item = str(paras)
        if paras_item.find("undo portswitch") != -1:
            return ERR
    ret = _ops.cli.close(handle)
    return OK
Beispiel #15
0
def create_aaa_user(ops_conn):
    _ops = ops.ops()
    handle, err_desp = _ops.cli.open()
    _ops.cli.execute(handle, "sys")
    _ops.cli.execute(handle, "aaa")
    _ops.cli.execute(
        handle, "local-user " + USERNAME + " password irreversible-cipher " +
        USERPASSWORD)
    _ops.cli.execute(handle, "local-user " + USERNAME + " level 3")
    _ops.cli.execute(handle,
                     "local-user " + USERNAME + " user-group " + USERGROUP)
    _ops.cli.execute(handle, "local-user " + USERNAME + " service-type ssh")
    _ops.cli.execute(handle, "com")
    ret = _ops.cli.close(handle)
    return OK
Beispiel #16
0
def create_temp_vlan(ops_conn,vlanId):
    
    _ops = ops.ops()

    handle, err_desp  = _ops.cli.open()
    _ops.cli.execute(handle,"sys")
    ret = _ops.cli.execute(handle,"vlan " + vlanId)
    logging.info(ret)
    if ret[2].lower() != 'success':
        _ops.cli.close(handle)
        return ERR
    ret = _ops.cli.execute(handle,"com")
    logging.info(ret)
    if ret[2].lower() != 'success':
        _ops.cli.close(handle)
        return ERR

    _ops.cli.close(handle)
    return OK
Beispiel #17
0
def set_port_temp_vlan(ops_conn,portName,tempVlanNumber):

    _ops = ops.ops()

    handle, err_desp  = _ops.cli.open()
    _ops.cli.execute(handle,"sys")
    _ops.cli.execute(handle,"int " + portName)
    ret = _ops.cli.execute(handle,"port default vlan " + tempVlanNumber)
    logging.info(ret)
    if ret[2].lower() != 'success':
        _ops.cli.close(handle)
        return ERR
    ret = _ops.cli.execute(handle,"com")
    logging.info(ret)
    if ret[2].lower() != 'success':
        _ops.cli.close(handle)
        return ERR
    _ops.cli.close(handle)
    return OK
Beispiel #18
0
def set_interface_ipadd(ops_conn, IfIndex, IpAddress, IpAddressMask):

    _ops = ops.ops()

    handle, err_desp = _ops.cli.open()
    _ops.cli.execute(handle, "sys")
    _ops.cli.execute(handle, "int " + IfIndex)
    ret = _ops.cli.execute(handle, "undo port default vlan " + VLAN_ID)
    logging.info(ret)
    ret = _ops.cli.execute(handle, "undo portswitch")
    logging.info(ret)
    if ret[2].lower() != 'success':
        _ops.cli.close(handle)
        return ERR
    ret = _ops.cli.execute(handle, "dldp enable")
    logging.info(ret)
    if ret[2].lower() != 'success':
        _ops.cli.close(handle)
        return ERR
    ret = _ops.cli.execute(handle,
                           "ip address " + IpAddress + ' ' + IpAddressMask)
    logging.info(ret)
    if ret[2].lower() != 'success':
        _ops.cli.close(handle)
        return ERR
    # ret = _ops.cli.execute(handle,"ospf network-type p2p")
    # logging.info(ret)
    # if ret[2].lower() != 'success':
    #     _ops.cli.close(handle)
    #     return ERR
    ret = _ops.cli.execute(handle, "com")
    logging.info(ret)
    if ret[2].lower() != 'success':
        _ops.cli.close(handle)
        return ERR
    ret = _ops.cli.close(handle)

    return OK
Beispiel #19
0
def ops_execute_set_dhcp_relay(ops_conn, vlanIfNum, dhcpSeverIp, giAddr):
    """
    set_dhcp_relay

    @param1 vlanIfNum: this is vlanIf Num
    @param2 dhcpSeverIp: this is dhcp Sever Ip
    @param3 giAddr: this is gate Addr

    """

    _ops = ops.ops()

    handle, err_desp = _ops.cli.open()
    _ops.cli.execute(handle, "sys")
    _ops.cli.execute(handle, "int " + vlanIfNum)
    ret = _ops.cli.execute(handle, "dhcp select relay")
    logging.info(ret)
    if ret[2].lower() != 'success':
        _ops.cli.close(handle)
        return ERR
    ret = _ops.cli.execute(handle,
                           "dhcp relay binding server ip " + dhcpSeverIp)
    logging.info(ret)
    if ret[2].lower() != 'success':
        _ops.cli.close(handle)
        return ERR
    ret = _ops.cli.execute(handle, "dhcp relay gateway " + giAddr)
    logging.info(ret)
    if ret[2].lower() != 'success':
        _ops.cli.close(handle)
        return ERR

    ret = _ops.cli.execute(handle, "comm")
    logging.info(ret)

    _ops.cli.close(handle)

    return OK
Beispiel #20
0
    def help(self):
        import showText
        import ops
        all = ops.ops()
        opHelp = "\n\n*Operators*\n\nHere is a list of valid operators:\n"+"\n".join([x.helpString() for x in all.values()])
        mainHelp = """
Rasterlang - raster manipulation language

This plugin allows manipulation of raster layers. It will only work on rasters that are based on the same grid size and location.

*Interface*

The interface shows layers grouped by their size and location in a grouped tree structure. Below this is a text entry line for your rasterlang expression. Because raster layer names do not need to be unique in Qgis, the interface assigns a 'label' to each layer. This label is used in expressions to specify the raster layer. By default the label is the same as the name, but if the name is not unique or is not a valid string for a label, then a new label is generated. In Qgis there is nothing stopping you renaming a layer '2', which would be confused with the number '2'.

Below the text entry line is a status indicator. If there are errors in your expression entry then a status message appears here. Possible errors include: the expression is not syntactically correct; it specifies no raster layers; it specifies raster layes from different groups.

Once a correct expression is entered the OK button is enabled. Clicking it runs the calculation and a 'Save' dialog is persented. This will save a GeoTIFF and load as a new layer in Qgis. You may then wish to set the Symbology from the Properties dialog in Qgis.

*Expressions*

Expressions are written in a lisp-like language. For example, to add 10 to all bands of a raster:

(+ layer1 10)

The basic syntax is (op arg arg ...), where each argument can also be an (op arg arg ...) expression. Hence you can build up more complex expressions such as:

(+ (band layer1 0) (* (band layer1 1) 1.3) (* (band layer1 2) 3.2))

which produces a single band from a linear combination of three bands from raster 'layer1'.

"""
        window = QtGui.QDialog()
        ui = showText.Ui_Dialog()
        ui.setupUi(window)
        ui.text.setText(mainHelp+opHelp)
        window.show()
        window.exec_()