'Test getting servers by ip.'

def test_get_servers_allows_ip(self):

    server_uuid = uuids.fake
    def fake_get_all(compute_self, context, search_opts=None, limit=None, marker=None, expected_attrs=None, sort_keys=None, sort_dirs=None):
        self.assertIsNotNone(search_opts)
        self.assertIn('ip', search_opts)
        self.assertEqual(search_opts['ip'], '10\\..*')
        return objects.InstanceList(objects=[fakes.stub_instance_obj(100, uuid=server_uuid)])
    self.stubs.Set(compute_api.API, 'get_all', fake_get_all)
    req = self.req('/fake/servers?ip=10\\..*')
    servers = self.controller.index(req)['servers']
    self.assertEqual(len(servers), 1)
    self.assertEqual(servers[0]['id'], server_uuid)
