'Docker >=1.9, using the v2 plugin API, can create a volume with the
volumes API, and pass a profile argument of silver which is represented
in the backing volume created on EBS.
The approach here is to:
- Create the volume.
- Create a container using that volume to ensure that it is created.
- Use the flocker API to find the dataset for the volume.
- Interface with EBS directly to verify that the created volume has
\'silver\' characteristics.'

@require_cluster(1, required_backend=backends.AWS)
def test_create_silver_volume_with_v2_plugin_api(self, cluster, backend):

    self.require_docker('1.9.0', cluster)
    node = cluster.nodes[0]
    docker = get_docker_client(cluster, node.public_address)
    volume_name = random_name(self)
    self._create_volume(docker, volume_name, driver_opts={'profile': 'silver'})
    create_container = self._test_create_container(cluster, volume_name=volume_name)
    def _get_datasets(unused_arg):
        return cluster.client.list_datasets_configuration()
    create_container.addCallback(_get_datasets)
    def _verify_created_volume_is_silver(datasets):
        dataset = next((d for d in datasets if (d.metadata.get(u'name') == volume_name)))
        volumes = backend.list_volumes()
        volume = next((v for v in volumes if (v.dataset_id == dataset.dataset_id)))
        ebs_volume = backend._get_ebs_volume(volume.blockdevice_id)
        self.assertEqual(EBSMandatoryProfileAttributes.SILVER.value.volume_type.value, ebs_volume.volume_type)
    create_container.addCallback(_verify_created_volume_is_silver)
    return create_container
