def test_attach_when_foreign_device_has_next_device(self):
        try:
            config = get_blockdevice_config()
        except InvalidConfig as e:
            self.skipTest(str(e))

        dataset_id = uuid4()
        ec2_client = get_ec2_client_for_test(config)
        meta_client = ec2_client.connection.meta.client

        # Create a volume directly using boto.
        requested_volume = meta_client.create_volume(
            Size=1, AvailabilityZone=ec2_client.zone)
        created_volume = ec2_client.connection.Volume(
            requested_volume['VolumeId'])

        def clean_volume(volume):
            volume.detach_from_instance()
            _wait_for_volume_state_change(VolumeOperations.DETACH, volume)
            volume.delete()

        self.addCleanup(clean_volume, created_volume)

        _wait_for_volume_state_change(VolumeOperations.CREATE, created_volume)

        # Get this instance ID.
        instance_id = self.api.compute_instance_id()

        # Attach manual volume using /xvd* device.
        device_name = _next_device().replace(u'/sd', u'/xvd')
        self.api._attach_ebs_volume(
            created_volume.id, instance_id, device_name)
        _wait_for_volume_state_change(VolumeOperations.ATTACH, created_volume)

        # Now create a volume via Flocker EBS backend.
        blockdevice_volume = self.api.create_volume(
            dataset_id=dataset_id, size=ONE_GIB)

        flocker_volume = ec2_client.connection.Volume(
            blockdevice_volume.blockdevice_id)
        self.addCleanup(clean_volume, flocker_volume)

        # Attach the blockdevice volume to this instance.
        # The assertion in this test is that this operation does not
        # raise an ``AttachedUnexpectedDevice`` error.
        self.api.attach_volume(
            blockdevice_volume.blockdevice_id, instance_id)
``attach_volume`` does not attempt to use device paths that are already
dataset/ETHPy150Open ClusterHQ/flocker/flocker/node/agents/functional/test_ebs.py/EBSBlockDeviceAPIInterfaceTests.test_attach_when_foreign_device_has_next_device