def get(url, session=None, silent=not debug, **kwargs):
    """Retrieve a given URL and log response.

    :param session: a :class:`requests.Session` object.
    :param silent: if **True**, response status and URL will not be printed.
    """
    session = session or requests
    kwargs["verify"] = kwargs.get("verify", True)
    r = session.get(url, **kwargs)
    if not silent:
        status_code = click.style(
            str(r.status_code),
            fg="green" if r.status_code in (200, 304) else "red")
        click.echo(status_code + " " + url)
        if r.status_code == 404:
            raise PackageNotFoundError
    return r
def test_get_volume_attachment(self):
        """Test getting volume attachments

        Attach a volume to a server, and then retrieve volume's attachments
        info.
        """
        # Create a server
        server = self.create_server()
        # Verify that a volume's attachment information is retrieved
        self.volumes_client.attach_volume(self.volume['id'],
                                          instance_uuid=server['id'],
                                          mountpoint='/dev/%s' %
                                          CONF.compute.volume_device_name)
        waiters.wait_for_volume_resource_status(self.volumes_client,
                                                self.volume['id'],
                                                'in-use')
        self.addCleanup(waiters.wait_for_volume_resource_status,
                        self.volumes_client,
                        self.volume['id'], 'available')
        self.addCleanup(self.volumes_client.detach_volume, self.volume['id'])
        volume = self.volumes_client.show_volume(self.volume['id'])['volume']
        attachment = volume['attachments'][0]

        self.assertEqual('/dev/%s' %
                         CONF.compute.volume_device_name,
                         attachment['device'])
        self.assertEqual(server['id'], attachment['server_id'])
        self.assertEqual(self.volume['id'], attachment['id'])
        self.assertEqual(self.volume['id'], attachment['volume_id'])