Example #1
0
    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)
Example #2
0
    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)
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
Example #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
Example #5
0
    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)
Example #6
0
    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)
Example #7
0
    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)