本文整理匯總了Python中ralph.discovery.models.DeviceModel.concurrent_get_or_create方法的典型用法代碼示例。如果您正苦於以下問題:Python DeviceModel.concurrent_get_or_create方法的具體用法?Python DeviceModel.concurrent_get_or_create怎麽用?Python DeviceModel.concurrent_get_or_create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ralph.discovery.models.DeviceModel
的用法示例。
在下文中一共展示了DeviceModel.concurrent_get_or_create方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _save_device
# 需要導入模塊: from ralph.discovery.models import DeviceModel [as 別名]
# 或者: from ralph.discovery.models.DeviceModel import concurrent_get_or_create [as 別名]
def _save_device(ip, name, model_name, sn, mac):
model, model_created = DeviceModel.concurrent_get_or_create(
name = 'Onstor %s' % model_name, type=DeviceType.storage.id)
dev, dev_created = Device.concurrent_get_or_create(sn=sn, model=model)
dev.save()
ipaddr, ip_created = IPAddress.concurrent_get_or_create(address=ip)
ipaddr.device = dev
ipaddr.is_management = True
ipaddr.save(update_last_seen=True)
dev.management = ipaddr
dev.save(update_last_seen=True)
return dev
示例2: _save_device
# 需要導入模塊: from ralph.discovery.models import DeviceModel [as 別名]
# 或者: from ralph.discovery.models.DeviceModel import concurrent_get_or_create [as 別名]
def _save_device(ip, name, model_name, sn):
model, model_created = DeviceModel.concurrent_get_or_create(
name='3PAR %s' % model_name,
defaults={'type': DeviceType.storage.id},
)
dev = Device.create(sn=sn, model=model)
ipaddr, ip_created = IPAddress.concurrent_get_or_create(address=ip)
ipaddr.device = dev
ipaddr.is_management = True
ipaddr.save()
dev.management = ipaddr
dev.save()
return dev
示例3: _make_dc_rack
# 需要導入模塊: from ralph.discovery.models import DeviceModel [as 別名]
# 或者: from ralph.discovery.models.DeviceModel import concurrent_get_or_create [as 別名]
def _make_dc_rack(dc_no, rack_no):
if dc_no is None:
return None, None
dev_model, created = DeviceModel.concurrent_get_or_create(
name='Data center', type=DeviceType.data_center.id)
dc, created = Device.concurrent_get_or_create(sn=dc_no,
model=dev_model)
if created:
dc.name = dc_no
dc.save(update_last_seen=True)
if rack_no is None:
rack = None
else:
rack_name = 'Rack %s' % rack_no
dev_model, created = DeviceModel.concurrent_get_or_create(
name='Rack', type=DeviceType.rack.id)
rack, created = Device.concurrent_get_or_create(
sn=rack_name, model=dev_model)
if created:
rack.name = rack_name
rack.parent = dc
rack.save(update_last_seen=True)
return dc, rack
示例4: _make_dc
# 需要導入模塊: from ralph.discovery.models import DeviceModel [as 別名]
# 或者: from ralph.discovery.models.DeviceModel import concurrent_get_or_create [as 別名]
def _make_dc(dc_no):
if dc_no is None:
return
dev_model, created = DeviceModel.concurrent_get_or_create(
name='Data center',
defaults={
'type': DeviceType.data_center.id,
},
)
dc, created = Device.concurrent_get_or_create(
sn=dc_no,
defaults={
'model': dev_model,
},
)
if created:
dc.name = dc_no
dc.save(update_last_seen=True)
return dc