Example #1
0
 def _create(mac_addr=None):
     interface = Interface.objects.create(
         network=network, node=node, type=type,
         mac_address=mac_addr or generate_mac(),
         model=model)
     Address.objects.create(ip_address=str(network.next_ip()),
                            interface=interface)
     return interface
Example #2
0
 def _create(mac_addr=None):
     interface = Interface.objects.create(network=network,
                                          node=node,
                                          type=type,
                                          mac_address=mac_addr
                                          or generate_mac(),
                                          model=model)
     Address.objects.create(ip_address=str(network.next_ip()),
                            interface=interface)
     return interface
Example #3
0
    def interface_create(cls, l2_network_device, node, label, type='network',
                         mac_address=None, model='virtio'):
        """Create interface

        :rtype : Interface
        """
        interface = cls.objects.create(
            l2_network_device=l2_network_device,
            node=node,
            label=label,
            type=type,
            mac_address=mac_address or generate_mac(),
            model=model)
        if (interface.l2_network_device and
                interface.l2_network_device.address_pool is not None):
            interface.add_address()
        return interface
Example #4
0
    def interface_create(cls, l2_network_device, node, label,
                         if_type='network', mac_address=None, model='virtio',
                         features=None):
        """Create interface

        :rtype : Interface
        """
        interface = cls.objects.create(
            l2_network_device=l2_network_device,
            node=node,
            label=label,
            type=if_type,
            mac_address=mac_address or helpers.generate_mac(),
            model=model,
            features=features or [])
        if (interface.l2_network_device and
                interface.l2_network_device.address_pool is not None):
            interface.add_address()
        return interface
Example #5
0
    def interface_create(l2_network_device,
                         node,
                         label,
                         type='network',
                         mac_address=None,
                         model='virtio'):
        """Create interface

        :rtype : Interface
        """
        interface = Interface.objects.create(
            l2_network_device=l2_network_device,
            node=node,
            label=label,
            type=type,
            mac_address=mac_address or generate_mac(),
            model=model)
        if (interface.l2_network_device
                and interface.l2_network_device.address_pool is not None):
            interface.add_address()
        return interface
Example #6
0
 def test_generate_mac(self, rand):
     rand.return_value = b'\x01\x02\x03\x04\x05'
     result = helpers.generate_mac()
     self.assertEqual(result, '64:01:02:03:04:05')
     rand.assert_called_once_with(5)
Example #7
0
 def _generate_mac(self):
     """
     :rtype : String
     """
     return generate_mac()
Example #8
0
 def _generate_mac(self):
     """
     :rtype : String
     """
     return generate_mac()
Example #9
0
 def test_generate_mac(self, rand):
     rand.return_value = b'\x01\x02\x03\x04\x05'
     result = helpers.generate_mac()
     self.assertEqual(result, '64:01:02:03:04:05')
     rand.assert_called_once_with(5)
Example #10
0
    def _generate_mac(self):
        """Generate MAC-address

        :rtype : String
        """
        return generate_mac()