Exemple #1
0
    def setUp(self):
        """Establish a clean test environment"""
        super(TestRegistryV2Client, self).setUp()
        db_api.setup_db_env()
        db_api.get_engine()
        self.context = context.RequestContext(is_admin=True)

        self.FIXTURES = [
            self.get_extra_fixture(
                id=UUID1,
                name='fake image #1',
                is_public=False,
                disk_format='ami',
                container_format='ami',
                size=13,
                location="swift://*****:*****@acct/container/obj.tar.0",
                properties={'type': 'kernel'}),
            self.get_extra_fixture(id=UUID2,
                                   name='fake image #2',
                                   properties={},
                                   size=19,
                                   location="file:///tmp/glance-tests/2")
        ]
        self.destroy_fixtures()
        self.create_fixtures()
        self.client = rclient.RegistryClient("0.0.0.0")
    def setUp(self):
        super(TestRegistryRPC, self).setUp()
        self.mapper = routes.Mapper()
        self.api = test_utils.FakeAuthMiddleware(rserver.API(self.mapper),
                                                 is_admin=True)

        uuid1_time = timeutils.utcnow()
        uuid2_time = uuid1_time + datetime.timedelta(seconds=5)

        self.FIXTURES = [
            {'id': UUID1,
             'name': 'fake image #1',
             'status': 'active',
             'disk_format': 'ami',
             'container_format': 'ami',
             'is_public': False,
             'created_at': uuid1_time,
             'updated_at': uuid1_time,
             'deleted_at': None,
             'deleted': False,
             'checksum': None,
             'min_disk': 0,
             'min_ram': 0,
             'size': 13,
             'locations': [{'url': "file:///%s/%s" % (self.test_dir, UUID1),
                            'metadata': {}}],
             'properties': {'type': 'kernel'}},
            {'id': UUID2,
             'name': 'fake image #2',
             'status': 'active',
             'disk_format': 'vhd',
             'container_format': 'ovf',
             'is_public': True,
             'created_at': uuid2_time,
             'updated_at': uuid2_time,
             'deleted_at': None,
             'deleted': False,
             'checksum': None,
             'min_disk': 5,
             'min_ram': 256,
             'size': 19,
             'locations': [{'url': "file:///%s/%s" % (self.test_dir, UUID2),
                            'metadata': {}}],
             'properties': {}}]

        self.context = glance.context.RequestContext(is_admin=True)
        db_api.setup_db_env()
        db_api.get_engine()
        self.destroy_fixtures()
        self.create_fixtures()
    def setUp(self):
        """Establish a clean test environment"""
        super(TestRegistryV1Client, self).setUp()
        db_api.setup_db_env()
        db_api.get_engine()
        self.context = context.RequestContext(is_admin=True)

        self.FIXTURES = [
            self.get_fixture(
                id=UUID1, name='fake image #1', is_public=False,
                disk_format='ami', container_format='ami', size=13,
                location="swift://*****:*****@acct/container/obj.tar.0",
                properties={'type': 'kernel'}),
            self.get_fixture(id=UUID2, name='fake image #2', properties={},
                             size=19, location="file:///tmp/glance-tests/2")]
        self.destroy_fixtures()
        self.create_fixtures()
        self.client = rclient.RegistryClient("0.0.0.0")
 def setUp(self):
     """Establish a clean test environment"""
     super(TestRegistryV1Client, self).setUp()
     db_api.setup_db_env()
     db_api.get_engine()
     self.context = context.RequestContext(is_admin=True)
     self.FIXTURES = [
         {
             "id": UUID1,
             "name": "fake image #1",
             "status": "active",
             "disk_format": "ami",
             "container_format": "ami",
             "is_public": False,
             "created_at": timeutils.utcnow(),
             "updated_at": timeutils.utcnow(),
             "deleted_at": None,
             "deleted": False,
             "checksum": None,
             "size": 13,
             "location": "swift://*****:*****@acct/container/obj.tar.0",
             "properties": {"type": "kernel"},
         },
         {
             "id": UUID2,
             "name": "fake image #2",
             "status": "active",
             "disk_format": "vhd",
             "container_format": "ovf",
             "is_public": True,
             "created_at": timeutils.utcnow(),
             "updated_at": timeutils.utcnow(),
             "deleted_at": None,
             "deleted": False,
             "checksum": None,
             "size": 19,
             "location": "file:///tmp/glance-tests/2",
             "properties": {},
         },
     ]
     self.destroy_fixtures()
     self.create_fixtures()
     self.client = rclient.RegistryClient("0.0.0.0")
     self.stubs = stubout.StubOutForTesting()
Exemple #5
0
 def setUp(self):
     """Establish a clean test environment"""
     super(TestRegistryV1Client, self).setUp()
     db_api.setup_db_env()
     db_api.get_engine()
     self.context = context.RequestContext(is_admin=True)
     self.FIXTURES = [{
         'id': UUID1,
         'name': 'fake image #1',
         'status': 'active',
         'disk_format': 'ami',
         'container_format': 'ami',
         'is_public': False,
         'created_at': timeutils.utcnow(),
         'updated_at': timeutils.utcnow(),
         'deleted_at': None,
         'deleted': False,
         'checksum': None,
         'size': 13,
         'location': "swift://*****:*****@acct/container/obj.tar.0",
         'properties': {
             'type': 'kernel'
         }
     }, {
         'id': UUID2,
         'name': 'fake image #2',
         'status': 'active',
         'disk_format': 'vhd',
         'container_format': 'ovf',
         'is_public': True,
         'created_at': timeutils.utcnow(),
         'updated_at': timeutils.utcnow(),
         'deleted_at': None,
         'deleted': False,
         'checksum': None,
         'size': 19,
         'location': "file:///tmp/glance-tests/2",
         'properties': {}
     }]
     self.destroy_fixtures()
     self.create_fixtures()
     self.client = rclient.RegistryClient("0.0.0.0")
 def setUp(self):
     """Establish a clean test environment"""
     super(TestRegistryV1Client, self).setUp()
     db_api.setup_db_env()
     db_api.get_engine()
     self.context = context.RequestContext(is_admin=True)
     self.FIXTURES = [
         {'id': UUID1,
          'name': 'fake image #1',
          'status': 'active',
          'disk_format': 'ami',
          'container_format': 'ami',
          'is_public': False,
          'created_at': timeutils.utcnow(),
          'updated_at': timeutils.utcnow(),
          'deleted_at': None,
          'deleted': False,
          'checksum': None,
          'size': 13,
          'location': "swift://*****:*****@acct/container/obj.tar.0",
          'properties': {'type': 'kernel'}},
         {'id': UUID2,
          'name': 'fake image #2',
          'status': 'active',
          'disk_format': 'vhd',
          'container_format': 'ovf',
          'is_public': True,
          'created_at': timeutils.utcnow(),
          'updated_at': timeutils.utcnow(),
          'deleted_at': None,
          'deleted': False,
          'checksum': None,
          'size': 19,
          'location': "file:///tmp/glance-tests/2",
          'properties': {}}]
     self.destroy_fixtures()
     self.create_fixtures()
     self.client = rclient.RegistryClient("0.0.0.0")
     self.stubs = stubout.StubOutForTesting()
Exemple #7
0
def seed(period_length):
    start = get_period_start(datetime.datetime.utcnow(), period_length)
    db_api.setup_db_env()
    session = db_api._get_session()

    print "Populating active image usages"
    usages = _get_usages(start, session)

    if usages:
        print "Saving active image images"
        active_images = map(lambda x: models.ImageUsage(**x), usages)
        models.ImageUsage.objects.bulk_create(active_images, batch_size=100)

    print "Populating image deletes"
    deletes = _get_deletes(start, session)

    if deletes:
        print "Saving image deletes"
        deleted_images = map(lambda x: models.ImageDeletes(**x), deletes)
        models.ImageDeletes.objects.bulk_create(deleted_images, batch_size=100)

    print "Seeding completed"
    return len(usages), len(deletes)
Exemple #8
0
def seed(period_length):
    start = get_period_start(datetime.datetime.utcnow(), period_length)
    db_api.setup_db_env()
    session = db_api._get_session()

    print "Populating active image usages"
    usages = _get_usages(start, session)

    if usages:
        print "Saving active image images"
        active_images = map(lambda x: models.ImageUsage(**x), usages)
        models.ImageUsage.objects.bulk_create(active_images, batch_size=100)

    print "Populating image deletes"
    deletes = _get_deletes(start, session)

    if deletes:
        print "Saving image deletes"
        deleted_images = map(lambda x: models.ImageDeletes(**x), deletes)
        models.ImageDeletes.objects.bulk_create(deleted_images, batch_size=100)

    print "Seeding completed"
    return len(usages), len(deletes)
Exemple #9
0
    def setUp(self):
        super(TestRegistryRPC, self).setUp()
        self.mapper = routes.Mapper()
        self.api = test_utils.FakeAuthMiddleware(rserver.API(self.mapper),
                                                 is_admin=True)

        self.FIXTURES = [{
            'id':
            UUID1,
            'name':
            'fake image #1',
            'status':
            'active',
            'disk_format':
            'ami',
            'container_format':
            'ami',
            'is_public':
            False,
            'created_at':
            timeutils.utcnow(),
            'updated_at':
            timeutils.utcnow(),
            'deleted_at':
            None,
            'deleted':
            False,
            'checksum':
            None,
            'min_disk':
            0,
            'min_ram':
            0,
            'size':
            13,
            'locations': ["file:///%s/%s" % (self.test_dir, UUID1)],
            'properties': {
                'type': 'kernel'
            }
        }, {
            'id':
            UUID2,
            'name':
            'fake image #2',
            'status':
            'active',
            'disk_format':
            'vhd',
            'container_format':
            'ovf',
            'is_public':
            True,
            'created_at':
            timeutils.utcnow(),
            'updated_at':
            timeutils.utcnow(),
            'deleted_at':
            None,
            'deleted':
            False,
            'checksum':
            None,
            'min_disk':
            5,
            'min_ram':
            256,
            'size':
            19,
            'locations': ["file:///%s/%s" % (self.test_dir, UUID2)],
            'properties': {}
        }]

        self.context = glance.context.RequestContext(is_admin=True)
        db_api.setup_db_env()
        db_api.get_engine()
        self.destroy_fixtures()
        self.create_fixtures()