Пример #1
0
 def setUp(self):
     device = Device.create(
         ethernets=[('', 'deadbeefcafe', 0)],
         model_name='HAL 9000',
         model_type=DeviceType.unknown,
         remarks="I'm sorry, Dave.",
     )
     self.deployment = Deployment(
         hostname='discovery.one',
         ip='127.0.0.1',
         mac='deadbeefcafe',
         device=device,
         preboot=None,
         venture=None,
         venture_role=None,
     )
     self.deployment.save()
     self.ip = IPAddress(address='127.0.0.1', device=device)
     self.ip.save()
     IPAddress(address='127.0.0.2', device=device).save()
     share_model = ComponentModel(type=ComponentType.share, name="share")
     share_model.save()
     share = DiskShare(wwn='x' * 33, device=device, model=share_model)
     share.save()
     DiskShareMount(share=share, device=device).save()
     OperatingSystem.create(os_name='GladOS',
                            dev=device,
                            family='',
                            priority=0)
     Software.create(dev=device,
                     model_name='soft',
                     path='/',
                     family='',
                     priority=0)
Пример #2
0
 def test_disk_shares_and_exports(self):
     model = ComponentModel(
         type=ComponentType.share,
         name="3par share",
     )
     model.save()
     share = DiskShare(
         device=self.device,
         model=model,
         label="pr0n",
         size="2048",
         wwn="deadbeefcafe1234",
     )
     share.save()
     address = IPAddress(address='127.0.0.1')
     address.save()
     DiskShareMount(
         device=self.device,
         share=share,
         address=address,
     ).save()
     data = get_device_data(Device.objects.get(sn='123456789'))
     exports = data['disk_exports']
     mounts = data['disk_shares']
     self.assertEqual(len(exports), 1)
     self.assertEqual(len(mounts), 1)
     self.assertEqual(mounts[0]['serial_number'], "deadbeefcafe1234")
Пример #3
0
 def test_ip_is_public_or_no(self):
     ip_list = [
         ('92.143.123.123', True),
         ('10.168.123.123', False),
     ]
     for ip, is_public in ip_list:
         new_ip_address = IPAddress(address=ip)
         new_ip_address.save()
         self.assertEquals(new_ip_address.is_public, is_public)
Пример #4
0
    def setUp(self):
        self.venture, created = Venture.objects.get_or_create(
            name="Sample venture", )
        self.venture.save()

        self.device, created = Device.objects.get_or_create(
            name="Device1",
            venture=self.venture,
        )
        self.device_without_venture, created = Device.objects.get_or_create(
            name="Device2", )

        self.ip1 = IPAddress(address='1.1.1.1', device=self.device)
        self.ip2 = IPAddress(address='2.2.2.2', venture=self.venture)
        self.ip1.save()
        self.ip2.save()

        self.device.save()
        self.device_without_venture.save()
Пример #5
0
 def test_name(self):
     ip = IPAddress(address='127.0.0.1')
     ip.save()
     with mock.patch(
             'ralph.discovery.plugins.snmp.snmp_command') as snmp_command:
         snmp_command.return_value = [[None, b'Testing name']]
         is_up, message = snmp._snmp('127.0.0.1', 'public',
                                     (1, 3, 6, 1, 2, 1, 1, 1, 0))
     self.assertEqual(message, 'Testing name')
     self.assertEqual(is_up, True)
Пример #6
0
    def setUp(self):
        self.dc = DataCenter(name="test_dc")
        self.dc.save()
        self.net1 = Network(
            name="test1",
            data_center=self.dc,
            address="192.168.0.1/16",
        )
        self.net1.save()
        self.net2 = Network(
            name="test2",
            data_center=self.dc,
            address="192.168.0.1/17",
        )
        self.net2.save()
        self.net3 = Network(
            name="test3",
            data_center=self.dc,
            address="192.168.128.1/17",
            reserved=5,
            reserved_top_margin=5,
        )
        self.net3.save()
        self.net4 = Network(
            name="test4",
            data_center=self.dc,
            address="192.168.133.1/24",
        )
        self.net4.save()
        self.net5 = Network(
            name="test5",
            data_center=self.dc,
            address="192.169.133.1/24",
        )
        self.net5.save()

        self.ip1 = IPAddress(address="192.168.128.10")
        self.ip1.save()
        self.ip2 = IPAddress(address="192.168.133.10")
        self.ip2.save()
        self.ip3 = IPAddress(address="192.168.128.11")
        self.ip3.save()
Пример #7
0
def _ip_create_record(form, request, device):
    hostname = form.cleaned_data.get('ip_new_hostname')
    address = form.cleaned_data.get('ip_new_address')
    if hostname and address:
        if IPAddress.objects.filter(address=address).exists():
            messages.error(
                request,
                "An IP address entry for %s already exists." % address)
            return
        record = IPAddress(address=address, hostname=hostname, device=device)
        record.save()
        messages.success(request,
                         "An IP address entry for %s created." % address)
Пример #8
0
 def setUp(self):
     ip = IPAddress(address='127.0.0.1')
     ip.snmp_name = ('Hardware: EM64T Family 6 Model 15 Stepping 7 AT/AT '
                     'COMPATIBLE - Software: Windows Version 5.2 (Build '
                     '3790 Multiprocessor Free)')
     ip.snmp_community = 'public'
     ip.snmp_version = '2c'
     ip.save()
     self.ip = ip
     self.kwargs = {
         'ip': ip.address,
         'community': ip.snmp_community,
         'snmp_name': ip.snmp_name,
         'snmp_version': ip.snmp_version,
     }
Пример #9
0
 def setUp(self):
     ip = IPAddress(address='127.0.0.1')
     ip.snmp_name = 'IBM PowerPC CHRP Computer'
     ip.snmp_community = 'public'
     ip.snmp_version = '2c'
     ip.save()
     self.ip = ip
     self.kwargs = {
         'ip': ip.address,
         'community': ip.snmp_community,
         'snmp_name': ip.snmp_name,
         'snmp_version': ip.snmp_version,
     }
     dev = Device.create(sn='foo', model_type=DeviceType.storage,
                         model_name='foo')
     dev.save()
     self.share = DiskShare(wwn='2AC000250A9B5000', device=dev)
     self.share.save()
Пример #10
0
 def test_validate_ip_owner(self):
     _validate_ip_owner('127.0.0.1', 'deadbeefcafe', 0)
     another_device = Device.create(
         ethernets=[('', 'deadbeefcafd', 0)],
         model_name='splat',
         model_type=DeviceType.unknown,
     )
     ip = IPAddress(address='127.0.0.1')
     ip.save()
     with self.assertRaises(forms.ValidationError):
         _validate_ip_owner('127.0.0.1', 'deadbeefcafe', 0)
     ip.device = Device.create(
         ethernets=[('', 'deadbeefcafe', 0)],
         model_name='splat',
         model_type=DeviceType.unknown,
     )
     ip.device.save()
     ip.save()
     _validate_ip_owner('127.0.0.1', 'deadbeefcafe', 0)
     ip.device = another_device
     ip.save()
     with self.assertRaises(forms.ValidationError):
         _validate_ip_owner('127.0.0.1', 'deadbeefcafe', 0)