本文整理汇总了Python中ralph.cmdb.models_ci.CI类的典型用法代码示例。如果您正苦于以下问题:Python CI类的具体用法?Python CI怎么用?Python CI使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_cis
def create_cis(self):
self.ci1 = CI(
uid='uid-ci1',
type=self.citype1,
barcode='barcodeci1',
name='ciname1',
)
self.ci1.save()
self.ci1.layers = [self.cilayer1, self.cilayer2]
self.ci1.save()
self.ci2 = CI(
uid='uid-ci2',
type=self.citype2,
barcode='barcodeci2',
name='ciname2',
)
self.ci2.save()
self.ci2.layers = [self.cilayer1]
self.ci2.save()
self.ci3 = CI(
uid='other-ci3',
type=self.citype2,
barcode='otherbarcodeci3',
name='otherci',
)
self.ci3.save()
self.ci3.layers = [self.cilayer2]
self.ci3.save()
示例2: create_cis
def create_cis(self):
self.ci1 = CI(
uid='uid-ci1',
type=self.types[0],
barcode='barcodeci1',
name='ciname1',
)
self.ci1.save()
self.ci1.layers = [self.layers[0].id, self.layers[1].id]
self.ci1.save()
self.ci2 = CI(
uid='uid-ci2',
type=self.types[1],
barcode='barcodeci2',
name='ciname2',
)
self.ci2.save()
self.ci2.layers = [self.layers[0].id]
self.ci2.save()
self.ci3 = CI(
uid='other-ci3',
type=self.types[1],
barcode='otherbarcodeci3',
name='otherci',
)
self.ci3.save()
self.ci3.layers = [self.layers[1].id]
self.ci3.save()
示例3: create_cis
def create_cis(self):
self.ci1 = CI(uid="uid-ci1", type=self.types[0], barcode="barcodeci1", name="ciname1")
self.ci1.save()
self.ci1.layers = [self.layers[0].id, self.layers[1].id]
self.ci1.save()
self.ci2 = CI(uid="uid-ci2", type=self.types[1], barcode="barcodeci2", name="ciname2")
self.ci2.save()
self.ci2.layers = [self.layers[0].id]
self.ci2.save()
self.ci3 = CI(uid="other-ci3", type=self.types[1], barcode="otherbarcodeci3", name="otherci")
self.ci3.save()
self.ci3.layers = [self.layers[1].id]
self.ci3.save()
示例4: ralph_device_owner_table
def ralph_device_owner_table(device):
"""Renders a table containing owners of a given ralph device object."""
context = {
'venture': device.venture,
'venture_business': [],
'venture_technical': [],
'service_business': [],
'service_technical': [],
}
if device.venture:
venture_ci = CI.get_by_content_object(device.venture)
venture_ownerships = CIOwnership.objects.filter(ci=venture_ci)
context['venture_business'] = venture_ownerships.filter(
type=CIOwnershipType.business,
)
context['venture_technical'] = venture_ownerships.filter(
type=CIOwnershipType.technical,
)
if device.service:
service_ownerships = CIOwnership.objects.filter(ci=device.service)
context['service_business'] = service_ownerships.filter(
type=CIOwnershipType.business,
)
context['service_technical'] = service_ownerships.filter(
type=CIOwnershipType.technical,
)
return render_to_string('cmdb/ralph_device_owner_table.html', context)
示例5: business_owners
def business_owners(self):
ci = CI.get_by_content_object(self)
if not ci:
return []
owners = CIOwner.objects.filter(ciownership__type=CIOwnershipType.business.id,
ci=ci)
return ", ".join([unicode(owner) for owner in owners])
示例6: setUp
def setUp(self):
self.user = create_user(
'api_user',
'[email protected]',
'password',
is_superuser=True
)
self.puppet_cv = "v%s" % random.randrange(0, 1000)
self.post_data_puppet = {
'configuration_version': self.puppet_cv,
'host': 's11111.dc2',
'kind': 'apply',
'status': 'failed',
'time': '2012-11-14 13:00:00',
}
self.git_changeset = "change:%s" % random.randrange(0, 1000)
self.git_comment = "comment:%s" % random.randrange(0, 1000)
self.post_data_git = {
'author': 'Jan Kowalski',
'changeset': self.git_changeset,
'comment': self.git_comment,
'file_paths': '/some/path',
}
temp_venture = Venture.objects.create(name='TempTestVenture')
if settings.AUTOCI:
self.ci = CI.get_by_content_object(temp_venture)
else:
CIImporter().import_single_object(temp_venture)
self.ci = CI.objects.create(
name='TempTestVentureCI',
uid=CI.get_uid_by_content_object(temp_venture),
type_id=4,
)
self.cmdb_new_value = 'nv_%s' % random.randrange(0, 1000)
self.cmdb_old_value = 'ov_%s' % random.randrange(0, 1000)
self.post_data_cmdb_change = {
'ci': '/api/v0.9/ci/%d/' % self.ci.pk,
'comment': 'test api',
'field_name': 'child',
'new_value': self.cmdb_new_value,
'old_value': self.cmdb_old_value,
'time': '2012-11-15 12:00:00',
}
cache.clear()
示例7: technical_owners
def technical_owners(self):
ci = CI.get_by_content_object(self)
if not ci:
return []
return CIOwner.objects.filter(
ci=ci,
ciownership__type=CIOwnershipType.technical.id,
)
示例8: business_owners
def business_owners(self):
ci = CI.get_by_content_object(self)
if not ci:
return []
return CIOwner.objects.filter(
ci=ci,
ciownership__type=CIOwnershipType.business.id
)
示例9: business_owners
def business_owners(self):
ci = CI.get_by_content_object(self)
if not ci:
return []
owners = CIOwner.objects.filter(ciownership__type=CIOwnershipType.business.id,
ci=ci)
part_url = reverse_lazy('ci_edit', kwargs={'ci_id': str(ci.id)})
return "<a href=\"{}\">{}</a>".format(part_url,
", ".join([unicode(owner) for owner in owners]))
示例10: 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()
示例11: setUp
def setUp(self):
self.client = login_as_su()
self.service = CI(
name='allegro.pl',
type=CIType.objects.get(id=CI_TYPES.SERVICE)
)
self.service.save()
self.db_service = CI.objects.get(id=self.service.id)
self.venture = CI(
name='allegro_prod',
type=CIType.objects.get(id=CI_TYPES.VENTURE)
)
self.venture.save()
self.ci_venture = CI.objects.get(id=self.venture.id)
self.relation = CIRelation(
parent=self.ci_venture,
child=self.db_service,
type=CI_RELATION_TYPES.CONTAINS,
)
self.relation.save()
示例12: technical_owners
def technical_owners(self):
ci = CI.get_by_content_object(self)
if not ci:
return []
owners = CIOwner.objects.filter(
ciownership__type=CIOwnershipType.technical.id,
ci=ci
)
part_url = reverse_lazy('ci_edit', kwargs={'ci_id': str(ci.id)})
link_text = ", ".join([unicode(owner)
for owner in owners]) if owners else '[add]'
return "<a href=\"{}\">{}</a>".format(part_url, link_text)
示例13: setUp
def setUp(self):
self.user = create_user("api_user", "[email protected]", "password", is_superuser=True)
self.puppet_cv = "v%s" % random.randrange(0, 1000)
self.post_data_puppet = {
"configuration_version": self.puppet_cv,
"host": "s11111.dc2",
"kind": "apply",
"status": "failed",
"time": "2012-11-14 13:00:00",
}
self.git_changeset = "change:%s" % random.randrange(0, 1000)
self.git_comment = "comment:%s" % random.randrange(0, 1000)
self.post_data_git = {
"author": "Jan Kowalski",
"changeset": self.git_changeset,
"comment": self.git_comment,
"file_paths": "/some/path",
}
temp_venture = Venture.objects.create(name="TempTestVenture")
if settings.AUTOCI:
self.ci = CI.get_by_content_object(temp_venture)
else:
CIImporter().import_single_object(temp_venture)
self.ci = CI.objects.create(
name="TempTestVentureCI", uid=CI.get_uid_by_content_object(temp_venture), type_id=4
)
self.cmdb_new_value = "nv_%s" % random.randrange(0, 1000)
self.cmdb_old_value = "ov_%s" % random.randrange(0, 1000)
self.post_data_cmdb_change = {
"ci": "/api/v0.9/ci/%d/" % self.ci.pk,
"comment": "test api",
"field_name": "child",
"new_value": self.cmdb_new_value,
"old_value": self.cmdb_old_value,
"time": "2012-11-15 12:00:00",
}
cache.clear()
示例14: test_reports_views
def test_reports_views(self):
url = '/ui/reports/services/'
report = self.client.get(url, follow=True)
self.assertEqual(report.status_code, 200)
invalid_relation = report.context['invalid_relation']
services_without_venture = report.context['services_without_venture']
self.assertEqual(invalid_relation[0].name, 'allegro.pl')
self.assertEqual(len(invalid_relation), 1)
self.assertEqual(len(services_without_venture), 0)
# local service for tests
service = CI(name='ceneo.pl', type=CIType.objects.get(
id=CI_TYPES.SERVICE)
)
service.save()
# local venture for tests
venture = CI(name='allegro_prod', type=CIType.objects.get(
id=CI_TYPES.VENTURE)
)
venture.save()
reload_report = self.client.get(url, follow=True)
re_invalid_relation = reload_report.context['invalid_relation']
re_services_without_venture = reload_report.context[
'services_without_venture']
self.assertEqual(len(re_invalid_relation), 1)
self.assertEqual(len(re_services_without_venture), 0)
示例15: setUp
def setUp(self):
self.puppet_cv = "v%s" % random.randrange(0, 1000)
puppet_bundle = Bundle(
data={
'configuration_version': self.puppet_cv,
'host': 's11111.dc2',
'kind': 'apply',
'status': 'failed',
'time': '2012-11-14 13:00:00'
})
puppet_resource = CIChangePuppetResource()
puppet_resource.obj_create(bundle=puppet_bundle)
self.git_changeset = "change:%s" % random.randrange(0, 1000)
self.git_comment = "comment:%s" % random.randrange(0, 1000)
git_bundle = Bundle(
data={
'author': 'Jan Kowalski',
'changeset': self.git_changeset,
'comment': self.git_comment,
'file_paths': '/some/path',
})
git_resource = CIChangeGitResource()
git_resource.obj_create(bundle=git_bundle)
temp_venture = Venture.objects.create(name='TempTestVenture')
self.ci = CI.objects.create(
name='TempTestVentureCI',
uid=CI.get_uid_by_content_object(temp_venture),
type_id=4)
self.cmdb_new_value = 'nv_%s' % random.randrange(0, 1000)
self.cmdb_old_value = 'ov_%s' % random.randrange(0, 1000)
cmdb_bundle = Bundle(
data={
'ci': '/api/v0.9/ci/%d/' % self.ci.pk,
'comment': 'test api',
'field_name': 'child',
'new_value': self.cmdb_new_value,
'old_value': self.cmdb_old_value,
'time': '2012-11-15 12:00:00'
})
cmdb_resource = CIChangeCMDBHistoryResource()
cmdb_resource.obj_create(bundle=cmdb_bundle)