Esempio n. 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)
Esempio n. 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")
Esempio n. 3
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)
Esempio n. 4
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")
Esempio n. 5
0
 def test_parts(self):
     model = ComponentModel(type=ComponentType.management, name="weapons of mass destruction")
     model.save()
     GenericComponent(label="ziew", device=self.device, model=model).save()
     data = get_device_data(Device.objects.get(sn="123456789"))
     parts = data["parts"]
     self.assertEqual(parts[0]["type"], "management")
     self.assertEqual(parts[0]["model_name"], "weapons of mass destruction")
     self.assertEqual(len(parts), 1)
Esempio n. 6
0
 def test_fc(self):
     model = ComponentModel(type=ComponentType.fibre, name="FC-336")
     model.save()
     FibreChannel(physical_id="deadbeefcafe", label="ziew", device=self.device, model=model).save()
     data = get_device_data(Device.objects.get(sn="123456789"))
     fc = data["fibrechannel_cards"]
     self.assertEqual(len(fc), 1)
     self.assertEqual(fc[0]["physical_id"], "deadbeefcafe")
     self.assertEqual(fc[0]["model_name"], "FC-336")
Esempio n. 7
0
 def test_disks(self):
     model = ComponentModel(type=ComponentType.disk, name="HP DG0300BALVP SAS 307200MiB, 10000RPM")
     model.save()
     Storage(sn="abc3", device=self.device, label="ziew", mount_point="/dev/hda", model=model, size=307200).save()
     data = get_device_data(Device.objects.get(sn="123456789"))
     disks = data["disks"]
     self.assertEqual(len(disks), 1)
     self.assertEqual(disks[0]["size"], 307200)
     self.assertEqual(disks[0]["serial_number"], "abc3")
     self.assertEqual(disks[0]["mount_point"], "/dev/hda")
Esempio n. 8
0
 def test_software(self):
     model = ComponentModel(type=ComponentType.software, name="cobol")
     model.save()
     Software(
         label="cobol", device=self.device, model=model, version="1.0.0", path="/usr/bin/cobol", sn="0000001"
     ).save()
     data = get_device_data(Device.objects.get(sn="123456789"))
     soft = data["installed_software"]
     self.assertEqual(soft[0]["version"], "1.0.0")
     self.assertEqual(soft[0]["model_name"], "cobol")
     self.assertEqual(len(soft), 1)
Esempio n. 9
0
 def test_processors(self):
     model = ComponentModel(type=ComponentType.processor, name="CPU Xeon 2533MHz, 4-core")
     model.save()
     for i in xrange(4):
         p = Processor(label="ziew", model=model, device=self.device, index=i)
         p.save()
     data = get_device_data(Device.objects.get(sn="123456789"))
     processors = data["processors"]
     self.assertEqual(len(processors), 4)
     self.assertEqual(processors[0]["label"], "ziew")
     self.assertEqual(processors[0]["model_name"], "CPU Xeon 2533MHz, 4-core")
     self.assertEqual(processors[0]["cores"], 4)
     self.assertEqual(processors[3]["index"], 3)
Esempio n. 10
0
 def test_parts(self):
     model = ComponentModel(
         type=ComponentType.management,
         name="weapons of mass destruction",
     )
     model.save()
     GenericComponent(
         label='ziew',
         device=self.device,
         model=model,
     ).save()
     data = get_device_data(Device.objects.get(sn='123456789'))
     parts = data['parts']
     self.assertEqual(parts[0]['type'], "management")
     self.assertEqual(parts[0]['model_name'], "weapons of mass destruction")
     self.assertEqual(len(parts), 1)
Esempio n. 11
0
 def test_parts(self):
     model = ComponentModel(
         type=ComponentType.management,
         name="weapons of mass destruction",
     )
     model.save()
     GenericComponent(
         label='ziew',
         device=self.device,
         model=model,
     ).save()
     data = get_device_data(Device.objects.get(sn='123456789'))
     parts = data['parts']
     self.assertEqual(parts[0]['type'], "management")
     self.assertEqual(parts[0]['model_name'], "weapons of mass destruction")
     self.assertEqual(len(parts), 1)
Esempio n. 12
0
 def test_fc(self):
     model = ComponentModel(
         type=ComponentType.fibre,
         name="FC-336",
     )
     model.save()
     FibreChannel(
         physical_id='deadbeefcafe',
         label='ziew',
         device=self.device,
         model=model,
     ).save()
     data = get_device_data(Device.objects.get(sn='123456789'))
     fc = data['fibrechannel_cards']
     self.assertEqual(len(fc), 1)
     self.assertEqual(fc[0]['physical_id'], 'deadbeefcafe')
     self.assertEqual(fc[0]['model_name'], 'FC-336')
Esempio n. 13
0
 def test_fc(self):
     model = ComponentModel(
         type=ComponentType.fibre,
         name="FC-336",
     )
     model.save()
     FibreChannel(
         physical_id='deadbeefcafe',
         label='ziew',
         device=self.device,
         model=model,
     ).save()
     data = get_device_data(Device.objects.get(sn='123456789'))
     fc = data['fibrechannel_cards']
     self.assertEqual(len(fc), 1)
     self.assertEqual(fc[0]['physical_id'], 'deadbeefcafe')
     self.assertEqual(fc[0]['model_name'], 'FC-336')
Esempio n. 14
0
 def test_software(self):
     model = ComponentModel(
         type=ComponentType.software,
         name="cobol",
     )
     model.save()
     Software(
         label='cobol',
         device=self.device,
         model=model,
         version='1.0.0',
         path='/usr/bin/cobol',
         sn='0000001',
     ).save()
     data = get_device_data(Device.objects.get(sn='123456789'))
     soft = data['installed_software']
     self.assertEqual(soft[0]['version'], "1.0.0")
     self.assertEqual(soft[0]['model_name'], "cobol")
     self.assertEqual(len(soft), 1)
Esempio n. 15
0
 def test_software(self):
     model = ComponentModel(
         type=ComponentType.software,
         name="cobol",
     )
     model.save()
     Software(
         label='cobol',
         device=self.device,
         model=model,
         version='1.0.0',
         path='/usr/bin/cobol',
         sn='0000001',
     ).save()
     data = get_device_data(Device.objects.get(sn='123456789'))
     soft = data['installed_software']
     self.assertEqual(soft[0]['version'], "1.0.0")
     self.assertEqual(soft[0]['model_name'], "cobol")
     self.assertEqual(len(soft), 1)
Esempio n. 16
0
 def test_disks(self):
     model = ComponentModel(
         type=ComponentType.disk,
         name="HP DG0300BALVP SAS 307200MiB, 10000RPM",
     )
     model.save()
     Storage(
         sn="abc3",
         device=self.device,
         label="ziew",
         mount_point="/dev/hda",
         model=model,
         size=307200,
     ).save()
     data = get_device_data(Device.objects.get(sn='123456789'))
     disks = data['disks']
     self.assertEqual(len(disks), 1)
     self.assertEqual(disks[0]['size'], 307200)
     self.assertEqual(disks[0]['serial_number'], "abc3")
     self.assertEqual(disks[0]['mount_point'], "/dev/hda")
Esempio n. 17
0
 def test_processors(self):
     model = ComponentModel(
         type=ComponentType.processor,
         name="CPU Xeon 2533MHz, 4-core",
     )
     model.save()
     for i in xrange(4):
         p = Processor(
             label="ziew",
             model=model,
             device=self.device,
             index=i,
         )
         p.save()
     data = get_device_data(Device.objects.get(sn='123456789'))
     processors = data['processors']
     self.assertEqual(len(processors), 4)
     self.assertEqual(processors[0]['label'], "ziew")
     self.assertEqual(processors[0]['model_name'], "CPU Xeon 2533MHz, 4-core")
     self.assertEqual(processors[0]['cores'], 4)
     self.assertEqual(processors[3]['index'], 3)
Esempio n. 18
0
 def test_processors(self):
     model = ComponentModel(
         type=ComponentType.processor,
         name="CPU Xeon 2533MHz, 4-core",
     )
     model.save()
     for i in xrange(4):
         p = Processor(
             label="ziew",
             model=model,
             device=self.device,
             index=i,
         )
         p.save()
     data = get_device_data(Device.objects.get(sn='123456789'))
     processors = data['processors']
     self.assertEqual(len(processors), 4)
     self.assertEqual(processors[0]['label'], "ziew")
     self.assertEqual(processors[0]['model_name'],
                      "CPU Xeon 2533MHz, 4-core")
     self.assertEqual(processors[0]['cores'], 4)
     self.assertEqual(processors[3]['index'], 3)
Esempio n. 19
0
 def test_disk_share(self):
     storage_dev = Device.create(
         sn='device',
         model_type=DeviceType.storage,
         model_name='storage device',
     )
     storage_dev.save()
     share_group = ComponentModelGroup(
         price=1,
         type=ComponentType.share,
         per_size=False,
         size_unit='',
         size_modifier=1,
     )
     share_group.save()
     share_model = ComponentModel(
         speed=0,
         cores=0,
         size=7,
         type=ComponentType.share,
         group=share_group,
         family='',
     )
     share_model.save()
     disk_share = DiskShare(
         device=storage_dev,
         model=share_model,
         share_id=1,
         label="share",
         size=7,
         snapshot_size=5,
         wwn='123456789012345678901234567890123',
         full=True,
     )
     disk_share.save()
     share_mount = DiskShareMount(
         share=disk_share,
         device=storage_dev,
         size=17,
     )
     share_mount.save()
     today = date.today()
     this_month = date(year=today.year, month=today.month, day=1)
     pricing_group = PricingGroup(
         name='group',
         date=this_month,
     )
     pricing_group.save()
     pricing_group.devices.add(storage_dev)
     pricing_group.save()
     pricing_formula = PricingFormula(
         group=pricing_group,
         component_group=share_group,
         formula='3+size+11*variable',
     )
     pricing_formula.save()
     pricing_variable = PricingVariable(
         name='variable',
         group=pricing_group,
         aggregate=PricingAggregate.sum,
     )
     pricing_variable.save()
     pricing_value = PricingValue(
         device=storage_dev,
         variable=pricing_variable,
         value=13,
     )
     pricing_value.save()
     variable_value = pricing_variable.get_value()
     self.assertEqual(variable_value, 13)
     formula_value = pricing_formula.get_value(size=7)
     self.assertEqual(formula_value, 3 + 7 + 11 * 13)
     share_price = disk_share.get_price()
     self.assertEqual(share_price, 3 + (7.0 + 5.0) / 1024 + 11 * 13)
     mount_price = share_mount.get_price()
     self.assertEqual(mount_price, 3 + 17.0 / 1024 + 11 * 13)
Esempio n. 20
0
 def test_disk_share(self):
     storage_dev = Device.create(
         sn='device',
         model_type=DeviceType.storage,
         model_name='storage device',
     )
     storage_dev.save()
     share_group = ComponentModelGroup(
         price=1,
         type=ComponentType.share,
         per_size=False,
         size_unit='',
         size_modifier=1,
     )
     share_group.save()
     share_model = ComponentModel(
         speed=0,
         cores=0,
         size=7,
         type=ComponentType.share,
         group=share_group,
         family='',
     )
     share_model.save()
     disk_share = DiskShare(
         device=storage_dev,
         model=share_model,
         share_id=1,
         label="share",
         size=7,
         snapshot_size=5,
         wwn='123456789012345678901234567890123',
         full=True,
     )
     disk_share.save()
     share_mount = DiskShareMount(
         share=disk_share,
         device=storage_dev,
         size=17,
     )
     share_mount.save()
     today = date.today()
     this_month = date(year=today.year, month=today.month, day=1)
     pricing_group = PricingGroup(
         name='group',
         date=this_month,
     )
     pricing_group.save()
     pricing_group.devices.add(storage_dev)
     pricing_group.save()
     pricing_formula = PricingFormula(
         group=pricing_group,
         component_group=share_group,
         formula='3+size+11*variable',
     )
     pricing_formula.save()
     pricing_variable = PricingVariable(
         name='variable',
         group=pricing_group,
         aggregate=PricingAggregate.sum,
     )
     pricing_variable.save()
     pricing_value = PricingValue(
         device=storage_dev,
         variable=pricing_variable,
         value=13,
     )
     pricing_value.save()
     variable_value = pricing_variable.get_value()
     self.assertEqual(variable_value, 13)
     formula_value = pricing_formula.get_value(size=7)
     self.assertEqual(formula_value, 3 + 7 + 11 * 13)
     share_price = disk_share.get_price()
     self.assertEqual(share_price, 3 + (7.0 + 5.0) / 1024 + 11 * 13)
     mount_price = share_mount.get_price()
     self.assertEqual(mount_price, 3 + 17.0 / 1024 + 11 * 13)