当前位置: 首页>>代码示例>>Python>>正文


Python models.VentureRole类代码示例

本文整理汇总了Python中ralph.business.models.VentureRole的典型用法代码示例。如果您正苦于以下问题:Python VentureRole类的具体用法?Python VentureRole怎么用?Python VentureRole使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了VentureRole类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

    def setUp(self):
        self.top_venture = Venture(name='top_venture')
        self.top_venture.save()

        self.child_venture = Venture(name='child_venture', parent=self.top_venture)
        self.child_venture.save()

        self.role = VentureRole(name='role', venture=self.child_venture)
        self.role.save()
        self.child_role = VentureRole(name='child_role',
                venture=self.child_venture,
                parent=self.role,
        )
        self.child_role.save()
        dm = self.add_model('DC model sample', DeviceType.data_center.id)
        self.dc = Device.create(sn='sn1', name='Rack 1', model=dm)
        dm = self.add_model('Rack model sample', DeviceType.rack_server.id)
        self.rack = Device.create(venture=self.child_venture, sn='sn2', name='DC', model=dm)
        self.rack.parent=self.dc
        self.rack.save()
        dm = self.add_model('Blade model sample', DeviceType.blade_server.id)
        self.blade = Device.create(
                venture=self.child_venture,
                venturerole=self.child_role,
                sn='sn3',
                name='blade1',
                model=dm
        )
        self.blade.parent=self.rack
        self.blade.save()
开发者ID:pb-it,项目名称:ralph,代码行数:30,代码来源:tests.py

示例2: setUp

    def setUp(self):
        self.top_venture = Venture(name="top_venture")
        self.top_venture.save()

        self.child_venture = Venture(name="child_venture", parent=self.top_venture)
        self.child_venture.save()

        self.role = VentureRole(name="role", venture=self.child_venture)
        self.role.save()
        self.child_role = VentureRole(name="child_role", venture=self.child_venture, parent=self.role)
        self.child_role.save()
        dm = self.add_model("DC model sample", DeviceType.data_center.id)
        self.dc = Device.create(sn="sn1", model=dm)
        self.dc.name = "dc"
        self.dc.save()
        dm = self.add_model("Rack model sample", DeviceType.rack_server.id)
        self.rack = Device.create(venture=self.child_venture, sn="sn2", model=dm)
        self.rack.parent = self.dc
        self.rack.name = "rack"
        self.rack.save()
        dm = self.add_model("Blade model sample", DeviceType.blade_server.id)
        self.blade = Device.create(venture=self.child_venture, venturerole=self.child_role, sn="sn3", model=dm)
        self.blade.name = "blade"
        self.blade.parent = self.rack
        self.blade.save()
开发者ID:tosuch,项目名称:ralph,代码行数:25,代码来源:tests.py

示例3: test_fisheye

 def test_fisheye(self):
     """
     Create Venture/Role and import as CI/CIRelations.
     Now import fisheye xml from samples/* files and compare
     if changes are properly saved into the database,
     and reconcilated.
     """
     x = Venture(symbol="test_venture")
     x.save()
     y = VentureRole(name="test_role", venture=x)
     y.save()
     allegro_ci = CI(name="Allegro", type_id=CI_TYPES.VENTURE.id)
     allegro_ci.save()
     ct = ContentType.objects.get_for_model(x)
     test_venture, = CIImporter().import_all_ci([ct], asset_id=x.id)
     ct = ContentType.objects.get_for_model(y)
     test_role, = CIImporter().import_all_ci([ct], asset_id=y.id)
     CIImporter().import_relations(ContentType.objects.get_for_model(y), asset_id=y.id)
     with mock.patch("ralph.cmdb.integration.lib.fisheye.Fisheye") as Fisheye:
         Fisheye.side_effect = MockFisheye
         x = pgi(fisheye_class=Fisheye)
         x.import_git()
     self.assertEqual(
         CIChangeGit.objects.filter(
             author__contains="[email protected]",
             # file_paths__contains='/test_venture'
         ).count(),
         2,
     )
     self.assertEqual(CIChange.objects.filter(ci=test_role, type=CI_CHANGE_TYPES.CONF_GIT.id).count(), 2)
开发者ID:Makdaam,项目名称:ralph,代码行数:30,代码来源:tests.py

示例4: test_validate_venture_and_role

 def test_validate_venture_and_role(self):
     with self.assertRaises(forms.ValidationError):
         _validate_venture_and_role('bang', 'klang', 0)
     v = Venture(name='Bang', symbol='bang')
     v.save()
     with self.assertRaises(forms.ValidationError):
         _validate_venture_and_role('bang', 'klang', 0)
     r = VentureRole(name='klang', venture=v)
     r.save()
     _validate_venture_and_role('bang', 'klang', 0)
开发者ID:andrzej-jankowski,项目名称:ralph,代码行数:10,代码来源:test_deployment.py

示例5: setUp

    def setUp(self):
        engine = settings.ISSUETRACKERS['default']['ENGINE']
        if engine != '':
            raise ImproperlyConfigured('''Expected ISSUETRACKERS['default']['ENGINE']='' got: %s''' % engine)
        # usual stuff
        self.top_venture = Venture(name='top_venture')
        self.top_venture.save()
        self.child_venture = Venture(name='child_venture', parent=self.top_venture)
        self.child_venture.save()
        self.role = VentureRole(name='role', venture=self.child_venture)
        self.role.save()
        self.child_role = VentureRole(name='child_role',
                venture=self.child_venture,
                parent=self.role,
        )
        self.child_role.save()
        to = VentureOwner(name='Bufallo Kudłaczek', venture=self.child_venture, type=OwnerType.technical.id)
        to.save()
        bo = VentureOwner(name='Bill Bąbelek', venture=self.child_venture, type=OwnerType.business.id)
        bo.save()

        dm = self.add_model('DC model sample', DeviceType.data_center.id)
        self.dc = Device.create(
                sn='sn1',
                model=dm
        )
        self.dc.name = 'dc'
        self.dc.save()
        dm = self.add_model('Rack model sample', DeviceType.rack_server.id)
        self.rack = Device.create(
                venture=self.child_venture,
                sn='sn2',
                model=dm
        )
        self.rack.parent=self.dc
        self.rack.name = 'rack'
        self.rack.save()
        dm = self.add_model('Blade model sample', DeviceType.blade_server.id)
        self.blade = Device.create(
                venture=self.child_venture,
                venturerole=self.child_role,
                sn='sn3',
                model=dm
        )
        self.blade.name = 'blade'
        self.blade.parent=self.rack
        self.blade.save()

        self.deployment = Deployment()
        self.deployment.hostname = 'test_host2'
        self.deployment.device=self.blade
        self.deployment.mac = '10:9a:df:6f:af:01'
        self.deployment.ip='192.168.1.1'
        self.deployment.hostname='test'
        self.deployment.save()
开发者ID:iwwwwwwi,项目名称:ralph,代码行数:55,代码来源:tests.py

示例6: setUp

 def setUp(self):
     v = Venture(symbol='test_venture')
     v.save()
     r = VentureRole(name='test_role', venture=v)
     r.save()
     # ci for custom path mapping
     c = Venture(symbol='custom_ci', name='custom_ci')
     c.save()
     for i in (v, r, c):
         CIImporter().import_single_object(i)
         CIImporter().import_single_object_relations(i)
开发者ID:andrzej-jankowski,项目名称:ralph,代码行数:11,代码来源:tests_changes.py

示例7: setUp

 def setUp(self):
     self.top_venture = Venture(name='top_venture')
     self.top_venture.save()
     self.child_venture = Venture(
         name='child_venture',
         parent=self.top_venture,
     )
     self.child_venture.save()
     self.role = VentureRole(
         name='role',
         venture=self.child_venture,
     )
     self.role.save()
     self.child_role = VentureRole(
         name='child_role',
         venture=self.child_venture,
         parent=self.role,
     )
     self.child_role.save()
     dm = self.add_model('DC model sample', DeviceType.data_center.id)
     self.dc = Device.create(sn='sn1', model=dm)
     self.dc.name = 'dc'
     self.dc.save()
     dm = self.add_model('Rack model sample', DeviceType.rack_server.id)
     self.rack = Device.create(
         venture=self.child_venture,
         sn='sn2',
         model=dm,
     )
     self.rack.parent = self.dc
     self.rack.name = 'rack'
     self.rack.save()
     dm = self.add_model('Blade model sample', DeviceType.blade_server.id)
     self.blade = Device.create(
         venture=self.child_venture,
         venturerole=self.child_role,
         sn='sn3',
         model=dm,
     )
     self.blade.name = 'blade'
     self.blade.parent = self.rack
     self.blade.save()
     self.deployment = Deployment()
     self.deployment.hostname = 'test_host2'
     self.deployment.device = self.blade
     self.deployment.mac = '10:9a:df:6f:af:01'
     self.deployment.ip = '192.168.1.1'
     self.deployment.hostname = 'test'
     self.deployment.save()
开发者ID:damjanek,项目名称:ralph,代码行数:49,代码来源:test_deployment.py

示例8: setUp

 def setUp(self):
     engine = settings.ISSUETRACKERS["default"]["ENGINE"]
     if engine != "":
         raise ImproperlyConfigured("""Expected ISSUETRACKERS['default']['ENGINE']='' got: %r""" % engine)
     # usual stuff
     self.top_venture = Venture(name="top_venture")
     self.top_venture.save()
     self.child_venture = Venture(name="child_venture", parent=self.top_venture)
     self.child_venture.save()
     self.role = VentureRole(name="role", venture=self.child_venture)
     self.role.save()
     self.child_role = VentureRole(name="child_role", venture=self.child_venture, parent=self.role)
     self.child_role.save()
     to = CIOwner(first_name="Bufallo", last_name="Kudłaczek")
     to.save()
     bo = CIOwner(first_name="Bill", last_name="Bąbelek")
     bo.save()
     ct = ContentType.objects.get_for_model(self.top_venture)
     CIImporter().import_all_ci([ct])
     CIOwnership(owner=to, ci=CI.get_by_content_object(self.child_venture), type=CIOwnershipType.technical.id).save()
     CIOwnership(owner=bo, ci=CI.get_by_content_object(self.child_venture), type=CIOwnershipType.business.id).save()
     dm = self.add_model("DC model sample", DeviceType.data_center.id)
     self.dc = Device.create(sn="sn1", model=dm)
     self.dc.name = "dc"
     self.dc.save()
     dm = self.add_model("Rack model sample", DeviceType.rack_server.id)
     self.rack = Device.create(venture=self.child_venture, sn="sn2", model=dm)
     self.rack.parent = self.dc
     self.rack.name = "rack"
     self.rack.save()
     dm = self.add_model("Blade model sample", DeviceType.blade_server.id)
     self.blade = Device.create(venture=self.child_venture, venturerole=self.child_role, sn="sn3", model=dm)
     self.blade.name = "blade"
     self.blade.parent = self.rack
     self.blade.save()
     self.deployment = Deployment()
     self.deployment.hostname = "test_host2"
     self.deployment.device = self.blade
     self.deployment.mac = "10:9a:df:6f:af:01"
     self.deployment.ip = "192.168.1.1"
     self.deployment.hostname = "test"
     self.deployment.save()
开发者ID:szaydel,项目名称:ralph,代码行数:42,代码来源:tests.py

示例9: setUp

 def setUp(self):
     self.client = login_as_su()
     venture = Venture(name='venture', symbol='ventureSymbol')
     venture.save()
     self.venture = venture
     venture_role = VentureRole(name='role', venture=self.venture)
     venture_role.save()
     self.venture_role = venture_role
     d_kind = DeprecationKind(name='12 months', months=12)
     d_kind.save()
     self.kind = DeprecationKind.objects.get(name='12 months')
     # Cross - devices
     self.device_after_deprecation = Device.create(
         sn='device_after_deprecation',
         deprecation_kind=self.kind,
         support_expiration_date=datetime.datetime(2003, 01, 02),
         purchase_date=datetime.datetime(2001, 01, 01),
         warranty_expiration_date=datetime.datetime(2005, 01, 02),
         venture=self.venture,
         venture_role=self.venture_role,
         model_name='xxx',
         model_type=DeviceType.unknown,
     )
     self.device_after_deprecation.name = 'Device1'
     self.device_after_deprecation.save()
     self.device_with_blanks = Device.create(
         sn='device_with_blanks',
         deprecation_date=None,
         deprecation_kind=None,
         support_expiration_date=None,
         purchase_date=None,
         venture=None,
         venture_role=None,
         model_name='xxx',
         model_type=DeviceType.unknown,
     )
     self.device_with_blanks.name = 'Device2'
     self.device_with_blanks.save()
开发者ID:damjanek,项目名称:ralph,代码行数:38,代码来源:tests_reports.py

示例10: test_role_full_name

    def test_role_full_name(self):
        a = Venture(name='A', symbol='a')
        a.save()
        x = VentureRole(name='x', venture=a)
        x.save()
        y = VentureRole(name='y', venture=a, parent=x)
        y.save()

        self.assertEqual(y.full_name, 'x / y')
开发者ID:pb-it,项目名称:ralph,代码行数:9,代码来源:tests.py

示例11: setUp

    def setUp(self):
        login = 'ralph'
        password = 'ralph'
        user = User.objects.create_user(login, '[email protected]', password)
        self.user = user
        self.user.is_staff = True
        self.user.is_superuser = True
        self.user.save()
        self.client = Client()
        self.client.login(username=login, password=password)

        venture = Venture(name=DEVICE_VENTURE, symbol=DEVICE_VENTURE_SYMBOL)
        venture.save()
        self.venture = venture
        venture_role = VentureRole(name=VENTURE_ROLE, venture=self.venture)
        venture_role.save()
        self.venture_role = venture_role
        self.device = Device.create(
            sn=DEVICE_SN,
            barcode=DEVICE_BARCODE,
            remarks=DEVICE_REMARKS,
            model_name='xxxx',
            model_type=DeviceType.unknown,
            venture=self.venture,
            venture_role=self.venture_role,
            rack=DEVICE_RACK,
            position=DEVICE_POSITION,
            dc=DATACENTER,
        )
        self.device.name = DEVICE_NAME
        self.device.save()

        self.layer = db.CILayer(name='layer1')
        self.layer.save()
        self.citype = db.CIType(name='xxx')
        self.citype.save()
开发者ID:ar4s,项目名称:ralph,代码行数:36,代码来源:tests_ci_edit_form.py

示例12: setUp

    def setUp(self):
        self.client = login_as_su()

        self.deprecation_kind = DeprecationKind(months=24, remarks='Default')
        self.deprecation_kind.save()

        self.margin = MarginKind(margin=100, remarks='100%')
        self.margin.save()

        self.venture = Venture(name='VenureName')
        self.venture.save()

        self.role = VentureRole(venture=self.venture, name='VentureRole')
        self.role.save()

        self.device = Device.create(
            sn=DEVICE['sn'],
            barcode=DEVICE['barcode'],
            remarks=DEVICE['remarks'],
            model_name=DEVICE['model_name'],
            model_type=DeviceType.unknown,
            rack=DEVICE['rack'],
            position=DEVICE['position'],
            dc=DATACENTER,
        )
        self.device.name = DEVICE['name']
        self.device.save()

        self.device2 = Device.create(
            sn=DEVICE2['sn'],
            barcode=DEVICE2['barcode'],
            remarks=DEVICE2['remarks'],
            model_name=DEVICE2['model_name'],
            model_type=DeviceType.unknown,
            rack=DEVICE2['rack'],
            position=DEVICE2['position'],
            dc=DATACENTER,
        )
        self.device2.name = DEVICE2['name']
        self.device2.save()
开发者ID:ReJeCtAll,项目名称:ralph,代码行数:40,代码来源:tests_bulkedit_form.py

示例13: CIImporterTest

class CIImporterTest(TestCase):
    fixtures = [
        '0_types.yaml',
        '1_attributes.yaml',
        '2_layers.yaml',
        '3_prefixes.yaml'
    ]

    def setUp(self):
        self.top_venture = Venture(name='top_venture')
        self.top_venture.save()

        self.child_venture = Venture(
            name='child_venture', parent=self.top_venture)
        self.child_venture.save()

        self.role = VentureRole(name='role', venture=self.child_venture)
        self.role.save()
        self.child_role = VentureRole(
            name='child_role',
            venture=self.child_venture,
            parent=self.role,
        )
        self.child_role.save()
        dm = self.add_model('DC model sample', DeviceType.data_center.id)
        self.dc = Device.create(
            sn='sn1', model=dm
        )
        self.dc.name = 'dc'
        self.dc.save()
        dm = self.add_model('Rack model sample', DeviceType.rack_server.id)
        self.rack = Device.create(
            venture=self.child_venture,
            sn='sn2',
            model=dm
        )
        self.rack.parent = self.dc
        self.rack.name = 'rack'
        self.rack.save()
        dm = self.add_model('Blade model sample', DeviceType.blade_server.id)
        self.blade = Device.create(
            venture=self.child_venture,
            sn='sn3',
            model=dm,
        )
        self.blade.name = 'blade'
        self.blade.venture_role = self.child_role
        self.blade.parent = self.rack
        self.blade.save()

    def add_model(self, name, device_type):
        dm = DeviceModel()
        dm.model_type = device_type
        dm.name = name
        dm.save()
        return dm

    def test_import_devices(self):
        """
        Test importing:
        - prefixes
        - parenthesis
        - layers

        Structure:

        top_venture
            <--child_venture
                <---role
                    <---child_role
                        <---- dc
                            <----rack
                                <----blade
        """
        # ventures and roles
        objs = [self.top_venture, self.child_venture, self.role,
                self.child_role]
        for o in objs:
            ct = ContentType.objects.get_for_model(o)
            CIImporter().import_all_ci([ct], asset_id=o.id)
        for o in objs:
            ct = ContentType.objects.get_for_model(o)
            CIImporter().import_relations(ct, asset_id=o.id)

        # devices
        objs = [self.dc, self.rack, self.blade]
        # create ci
        for o in objs:
            ct = ContentType.objects.get_for_model(o)
            CIImporter().import_all_ci([ct], asset_id=o.id)
            # create relations
        for o in objs:
            ct = ContentType.objects.get_for_model(o)
            CIImporter().import_relations(ct, asset_id=o.id)

        # All ci should be in Hardware layer
        ci_dc = CI.objects.get(name='dc')
        ci_rack = CI.objects.get(name='rack')
        ci_blade = CI.objects.get(name='blade')
        ci_venture = CI.objects.get(name='child_venture')
#.........这里部分代码省略.........
开发者ID:damjanek,项目名称:ralph,代码行数:101,代码来源:tests_importing.py

示例14: DeploymentTest

class DeploymentTest(TestCase):
    def setUp(self):
        self.top_venture = Venture(name='top_venture')
        self.top_venture.save()
        self.child_venture = Venture(
            name='child_venture',
            parent=self.top_venture,
        )
        self.child_venture.save()
        self.role = VentureRole(
            name='role',
            venture=self.child_venture,
        )
        self.role.save()
        self.child_role = VentureRole(
            name='child_role',
            venture=self.child_venture,
            parent=self.role,
        )
        self.child_role.save()
        dm = self.add_model('DC model sample', DeviceType.data_center.id)
        self.dc = Device.create(sn='sn1', model=dm)
        self.dc.name = 'dc'
        self.dc.save()
        dm = self.add_model('Rack model sample', DeviceType.rack_server.id)
        self.rack = Device.create(
            venture=self.child_venture,
            sn='sn2',
            model=dm,
        )
        self.rack.parent = self.dc
        self.rack.name = 'rack'
        self.rack.save()
        dm = self.add_model('Blade model sample', DeviceType.blade_server.id)
        self.blade = Device.create(
            venture=self.child_venture,
            venturerole=self.child_role,
            sn='sn3',
            model=dm,
        )
        self.blade.name = 'blade'
        self.blade.parent = self.rack
        self.blade.save()
        self.deployment = Deployment()
        self.deployment.hostname = 'test_host2'
        self.deployment.device = self.blade
        self.deployment.mac = '10:9a:df:6f:af:01'
        self.deployment.ip = '192.168.1.1'
        self.deployment.hostname = 'test'
        self.deployment.save()

    def add_model(self, name, device_type):
        dm = DeviceModel()
        dm.model_type = device_type,
        dm.name = name
        dm.save()
        return dm

    def test_archivization(self):
        id = self.deployment.id
        data = {}
        for field in self.deployment._meta.fields:
            data[field.name] = getattr(self.deployment, field.name)
            if field.name == 'mac':
                data[field.name] = MACAddressField.normalize(data[field.name])
        self.deployment.archive()
        archive = ArchivedDeployment.objects.get(pk=id)
        archive_data = {}
        for field in archive._meta.fields:
            archive_data[field.name] = getattr(archive, field.name)
            if field.name == 'mac':
                archive_data[field.name] = MACAddressField.normalize(
                    archive_data[field.name]
                )
        self.assertEqual(data, archive_data)
        with self.assertRaises(Deployment.DoesNotExist):
            Deployment.objects.get(pk=id)
开发者ID:damjanek,项目名称:ralph,代码行数:77,代码来源:test_deployment.py

示例15: test_get_preboot_role

    def test_get_preboot_role(self):
        preboot = Preboot(name='test preboot')
        preboot.save()
        ven = Venture(name='test1', symbol='test1', preboot = preboot)
        ven.save()

        a = VentureRole(name='test1', preboot = preboot, venture_id = ven.id)
        a.save()
        b = VentureRole(name='test1 parent', parent_id = a.id, venture_id = ven.id)
        b.save()
        c = VentureRole(name='test1 parent parent', parent_id = b.id, venture_id = ven.id)
        c.save()
        self.assertEqual(a.get_preboot(), preboot)
        self.assertEqual(b.get_preboot(), preboot)
        self.assertEqual(c.get_preboot(), preboot)
开发者ID:iwwwwwwi,项目名称:ralph,代码行数:15,代码来源:tests.py


注:本文中的ralph.business.models.VentureRole类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。