def add(self, elem, replace=False):
        """Add a requirement.

        :param elem: a string or :class:`Requirement` instance.
        :param replace: if `True`, packages in the set with the same name will
            be removed first.
        """
        if isinstance(elem, text_type):
            elem = Requirement.coerce(elem)
        if replace and elem in self:
            self.remove(elem)
        super(Requirements, self).add(elem)
def test_attach_detach_volume_to_instance(self):
        """Test attaching and detaching volume to instance"""
        # Create a server
        server = self.create_server()
        # Volume is attached and detached successfully from an instance
        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.volumes_client.detach_volume(self.volume['id'])
        waiters.wait_for_volume_resource_status(self.volumes_client,
                                                self.volume['id'], 'available')