コード例 #1
0
ファイル: netconfTests.py プロジェクト: rexhsu/vdsm-debian
    def testCreateNetXmlBridged(self):
        expectedDoc = """<network>
                           <name>vdsm-awesome_net</name>
                           <forward mode='bridge'/>
                           <bridge name='awesome_net'/>
                         </network>"""
        actualDoc = libvirt.createNetworkDef('awesome_net', bridged=True)

        self.assertEqualXml(expectedDoc, actualDoc)
コード例 #2
0
ファイル: netconfTests.py プロジェクト: rexhsu/vdsm-debian
    def testCreateNetXml(self):
        iface = "dummy"
        expectedDoc = ("""<network>
                            <name>vdsm-awesome_net</name>
                            <forward mode='passthrough'>
                            <interface dev='%s'/>
                            </forward>
                          </network>""" % iface)
        actualDoc = libvirt.createNetworkDef('awesome_net', bridged=False,
                                             iface=iface)

        self.assertEqualXml(expectedDoc, actualDoc)
コード例 #3
0
def _get_libvirt_changes(nets, running_config):
    libvirt_create = {}
    libvirt_remove = set()
    for net, attrs in nets.iteritems():
        if 'remove' in attrs:
            libvirt_remove.add(net)
    for net, attrs in nets.iteritems():
        if 'remove' not in attrs:
            if net in running_config.networks:
                libvirt_remove.add(net)
            libvirt_network_xml = libvirt.createNetworkDef(
                net, True, attrs.get('nic') or attrs.get('bonding'))
            libvirt_create[net] = libvirt_network_xml
    return libvirt_create, libvirt_remove
コード例 #4
0
def prepare_libvirt(nets, running_config):
    libvirt_create = {}
    libvirt_remove = set()

    for net, attrs in six.iteritems(nets):
        if 'remove' in attrs:
            libvirt_remove.add(net)
        else:
            if net in running_config.networks:
                libvirt_remove.add(net)
            libvirt_network_xml = libvirt.createNetworkDef(
                net, bridged=True, iface=(attrs.get('nic') or
                                          attrs.get('bonding')))
            libvirt_create[net] = libvirt_network_xml

    return libvirt_create, libvirt_remove
コード例 #5
0
ファイル: netconfTests.py プロジェクト: vinzenz/vdsm
    def testCreateNetXmlBridgedQos(self):
        inbound = {'average': '1024', 'burst': '5000'}
        outbound = {'average': '666', 'burst': '666',
                    'peak': '400'}
        expectedDoc = ("""<network>
                            <name>vdsm-awesome_net</name>
                            <forward mode='bridge'/>
                            <bridge name='awesome_net'/>
                            <bandwidth>
                                <inbound average='%s' burst='%s' />
                                <outbound average='%s' burst='%s' peak='%s' />
                            </bandwidth>
                          </network>"""
                       % (inbound['average'], inbound['burst'],
                          outbound['average'], outbound['burst'],
                          outbound['peak']))
        actualDoc = libvirt.createNetworkDef('awesome_net', qosInbound=inbound,
                                             qosOutbound=outbound)

        self.assertEqualXml(expectedDoc, actualDoc)
コード例 #6
0
ファイル: netconfTests.py プロジェクト: myOvirt/vdsm
    def testCreateNetXmlBridgedQos(self):
        inbound = {'average': '1024', 'burst': '5000'}
        outbound = {'average': '666', 'burst': '666',
                    'peak': '400'}
        expectedDoc = ("""<network>
                            <name>vdsm-awesome_net</name>
                            <forward mode='bridge'/>
                            <bridge name='awesome_net'/>
                            <bandwidth>
                                <inbound average='%s' burst='%s' />
                                <outbound average='%s' burst='%s' peak='%s' />
                            </bandwidth>
                          </network>"""
                       % (inbound['average'], inbound['burst'],
                          outbound['average'], outbound['burst'],
                          outbound['peak']))
        actualDoc = libvirt.createNetworkDef('awesome_net', qosInbound=inbound,
                                             qosOutbound=outbound)

        self.assertEqualXml(expectedDoc, actualDoc)
コード例 #7
0
ファイル: netconfTests.py プロジェクト: vinzenz/vdsm
    def testCreateNetXmlBridgedQos(self):
        inbound = {"average": "1024", "burst": "5000"}
        outbound = {"average": "666", "burst": "666", "peak": "400"}
        expectedDoc = """<network>
                            <name>vdsm-awesome_net</name>
                            <forward mode='bridge'/>
                            <bridge name='awesome_net'/>
                            <bandwidth>
                                <inbound average='%s' burst='%s' />
                                <outbound average='%s' burst='%s' peak='%s' />
                            </bandwidth>
                          </network>""" % (
            inbound["average"],
            inbound["burst"],
            outbound["average"],
            outbound["burst"],
            outbound["peak"],
        )
        actualDoc = libvirt.createNetworkDef("awesome_net", qosInbound=inbound, qosOutbound=outbound)

        self.assertEqualXml(expectedDoc, actualDoc)