def create_and_attach_ebs_vols(
    ec2conn,
    availability_zone,
    instance_id,
    vol_confs,
    seed_ebs_snapshots,
):
    attached_ebs_vols = {}

    for vol_label, vol_conf in vol_confs.items():
        # First make sure we hadn't already attached this volume previously
        device = vol_conf['device']
        attached_volume = _get_attached_volume(ec2conn, instance_id, device)
        if attached_volume:
            logger.warning(
                "Volume %s with id already mounted on %s. Skipping",
                vol_label,
                attached_volume.id,
                device,
            )
            continue

        # Get the seed snapshot
        seed_snapshot_id = seed_ebs_snapshots.get(vol_label)
        seed_snapshot = None
        if seed_snapshot_id:
            seed_snapshot = ec2.snapshot.Snapshot(ec2conn)
            seed_snapshot.id = seed_snapshot_id

        if seed_snapshot:
            # Ensure the seed snapshot is 'completed' before trying to create
            # a new EBS volume
            logger.info(
                u"Ensuring that the %s snapshot is complete", vol_label)

            seed_snapshot.update()
            while seed_snapshot.progress != '100%':
                logger.info(
                    "snapshot: [%s] only %s percent complete. Waiting 5s",
                    seed_snapshot.id,
                    seed_snapshot.progress)
                time.sleep(5)
                seed_snapshot.update()

        # Create and attach the EBS volume based on the snapshot (if any)
        logger.info(u"Creating and attaching the %s EBS volume", vol_label)
        ebs_vol = create_and_attach_ebs_vol(
            ec2conn,
            availability_zone,
            instance_id,
            seed_snapshot_id,
            vol_conf['size'],
            vol_conf['device'],
        )

        attached_ebs_vols[vol_label] = ebs_vol

    return attached_ebs_vols
Returns a string containing a unique task name.
dataset/ETHPy150Open winhamwr/neckbeard/neckbeard/cloud_provisioners/aws/ec2.py/create_and_attach_ebs_vols--crossover with--dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/api/taskqueue/taskqueue_stub.py/_Group._ChooseTaskName