當前位置: 首頁>>代碼示例>>Python>>正文


Python DeviceModel.concurrent_get_or_create方法代碼示例

本文整理匯總了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
開發者ID:pijany,項目名稱:ralph,代碼行數:14,代碼來源:ssh_onstor.py

示例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
開發者ID:damjanek,項目名稱:ralph,代碼行數:15,代碼來源:ssh_3par.py

示例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
開發者ID:iwwwwwwi,項目名稱:ralph,代碼行數:26,代碼來源:position.py

示例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
開發者ID:4i60r,項目名稱:ralph,代碼行數:21,代碼來源:position.py


注:本文中的ralph.discovery.models.DeviceModel.concurrent_get_or_create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。