コード例 #1
0
ファイル: createnetwork.py プロジェクト: rudecs/openvcloud
def action(networkid):
    from CloudscalerLibcloud.utils.libvirtutil import LibvirtUtil
    connection = LibvirtUtil()
    networks = connection.connection.listNetworks()
    from JumpScale.lib import ovsnetconfig
    vxnet = j.system.ovsnetconfig.ensureVXNet(networkid, 'vxbackend')
    bridgename = vxnet.bridge.name
    networkinformation = {'networkname': bridgename}
    if bridgename not in networks:
        #create the bridge if it does not exist
        connection.createNetwork(bridgename, bridgename)
    return networkinformation
コード例 #2
0
def action(vlan):
    from CloudscalerLibcloud.utils.libvirtutil import LibvirtUtil
    connection = LibvirtUtil()
    if vlan is None or vlan == 0:
        bridgename = 'public'
    else:
        bridgename = 'ext-%04x' % vlan

    nics = j.system.net.getNics()
    if bridgename not in nics:
        extbridge = 'ext-bridge'
        if extbridge not in nics:
            extbridge = 'backplane1'
        j.system.ovsnetconfig.newVlanBridge(bridgename, extbridge, vlan)
    if not connection.checkNetwork(bridgename):
        connection.createNetwork(bridgename, bridgename)
    return bridgename
コード例 #3
0
ファイル: vm_start.py プロジェクト: rudecs/openvcloud
def action(name, networkId):
    networkname = 'space_%s' % networkId
    from CloudscalerLibcloud.utils.libvirtutil import LibvirtUtil
    connection = LibvirtUtil()
    networks = connection.connection.listNetworks()
    if networkname not in networks:
        #create the bridge if it does not exist
        from JumpScale.lib import ovsnetconfig
        vxnet = j.system.ovsnetconfig.ensureVXNet(networkId, 'vxbackend')
        bridgename = vxnet.bridge.name

        connection.createNetwork(networkname, bridgename)

    import libvirt
    con = libvirt.open()
    try:
        dom = con.lookupByName(name)
        state = dom.state()[0]
        if state != libvirt.VIR_DOMAIN_RUNNING:
            dom.create()
    finally:
        con.close()