当前位置: 首页>>代码示例>>Python>>正文


Python Device.get_vlans_xml方法代码示例

本文整理汇总了Python中device.Device.get_vlans_xml方法的典型用法代码示例。如果您正苦于以下问题:Python Device.get_vlans_xml方法的具体用法?Python Device.get_vlans_xml怎么用?Python Device.get_vlans_xml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在device.Device的用法示例。


在下文中一共展示了Device.get_vlans_xml方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: vlans

# 需要导入模块: from device import Device [as 别名]
# 或者: from device.Device import get_vlans_xml [as 别名]
def vlans():
    devvlans = None
    devgroups = None
    g.db = connect_db()

    if request.method == 'POST':
        dev1 = Device("EALABSW00002", "10.1.11.75", "junos", "DSGadmin", "Password!")

        if request.form['btn_vlans'] == "check":
            devvlans = dev1.get_vlans_xml()
            devgroups = dev1.get_groups_xml()

        elif request.form['btn_vlans'] == "vlanadd":
            # Declare VLAN variables
            vlan_id = request.form['vlans_id']
            vlan_description = request.form['vlans_description']
            vlan_name = "VLAN"+vlan_id

            # Adjust database
            g.db.execute('insert into vlans (id, description) values (?, ?)', [vlan_id, vlan_description])
            g.db.commit()

            # Adjust device
            dev1.set_vlan(vlan_name, vlan_id, vlan_description)

        elif request.form['btn_vlans'] == "vlanedit":
            # Declare VLAN variables
            vlan_id = request.form['vlans_id']
            vlan_description = request.form['vlans_description']
            vlan_name = "VLAN"+vlan_id

            # Adjust database
            g.db.execute('update vlans set description = ? where id is ?', [vlan_description, vlan_id])
            g.db.commit()

            # Adjust device
            dev1.set_vlan(vlan_name, vlan_id, vlan_description)

        elif request.form['btn_vlans'] == "vlanremove":
            # Declare VLAN variables
            vlan_id = request.form['vlans_id']
            vlan_name = "VLAN"+vlan_id

            # Adjust database
            g.db.execute('delete from vlans where id is ?', [vlan_id])
            g.db.commit()

            # Adjust device
            dev1.del_vlan(vlan_name)

    cur = g.db.execute('select * from vlans')
    dbvlans = [dict(id=row[1], vlan=row[2]) for row in cur.fetchall()]
    g.db.close()
    return render_template('vlans.xhtml', vlans=dbvlans, devvlans=devvlans, devgroups=devgroups)
开发者ID:kpante,项目名称:confJunos,代码行数:56,代码来源:web.py


注:本文中的device.Device.get_vlans_xml方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。