Beispiel #1
0
def pools_create(context, pools):
    """Create a pool from the values dictionary."""
    session = get_session()
    pool_refs = []
    with session.begin():

        for pool in pools:
            LOG.debug('adding new pool for original_id {0}:'.format(
                pool.get('original_id')))
            if not pool.get('id'):
                pool['id'] = uuidutils.generate_uuid()

            pool_ref = models.Pool()
            pool_ref.update(pool)
            pool_refs.append(pool_ref)

        session.add_all(pool_refs)

    return pool_refs
Beispiel #2
0
def volumes_create(context, volumes):
    """Create multiple volumes."""
    session = get_session()
    vol_refs = []
    with session.begin():

        for vol in volumes:
            LOG.debug('adding new volume for original_id {0}:'.format(
                vol.get('original_id')))
            if not vol.get('id'):
                vol['id'] = uuidutils.generate_uuid()

            vol_ref = models.Volume()
            vol_ref.update(vol)
            vol_refs.append(vol_ref)

        session.add_all(vol_refs)

    return vol_refs
Beispiel #3
0
def disks_create(context, disks):
    """Create multiple disks."""
    session = get_session()
    disks_refs = []
    with session.begin():

        for disk in disks:
            LOG.debug('adding new disk for native_disk_id {0}:'.format(
                disk.get('native_disk_id')))
            if not disk.get('id'):
                disk['id'] = uuidutils.generate_uuid()

            disk_ref = models.Disk()
            disk_ref.update(disk)
            disks_refs.append(disk_ref)

        session.add_all(disks_refs)

    return disks_refs
Beispiel #4
0
def ports_create(context, ports):
    """Create multiple ports."""
    session = get_session()
    ports_refs = []
    with session.begin():

        for port in ports:
            LOG.debug('adding new port for native_port_id {0}:'.format(
                port.get('native_port_id')))
            if not port.get('id'):
                port['id'] = uuidutils.generate_uuid()

            port_ref = models.Port()
            port_ref.update(port)
            ports_refs.append(port_ref)

        session.add_all(ports_refs)

    return ports_refs
Beispiel #5
0
def storage_pools_create(context, storage_pools):
    """Create a storage_pool from the values dictionary."""
    session = get_session()
    storage_pool_refs = []
    with session.begin():

        for storage_pool in storage_pools:
            LOG.debug(
                'adding new storage_pool for native_storage_pool_id {0}:'.
                format(storage_pool.get('native_storage_pool_id')))
            if not storage_pool.get('id'):
                storage_pool['id'] = uuidutils.generate_uuid()

            storage_pool_ref = models.StoragePool()
            storage_pool_ref.update(storage_pool)
            storage_pool_refs.append(storage_pool_ref)

        session.add_all(storage_pool_refs)

    return storage_pool_refs
Beispiel #6
0
def controllers_create(context, controllers):
    """Create multiple controllers."""
    session = get_session()
    controllers_refs = []
    with session.begin():

        for controller in controllers:
            LOG.debug(
                'adding new controller for native_controller_id {0}:'.format(
                    controller.get('native_controller_id')))
            if not controller.get('id'):
                controller['id'] = uuidutils.generate_uuid()

            controller_ref = models.Controller()
            controller_ref.update(controller)
            controllers_refs.append(controller_ref)

        session.add_all(controllers_refs)

    return controllers_refs