Exemplo n.º 1
0
def create_one_image(attrs=None):
    """Create a fake image.

    :param Dictionary attrs:
        A dictionary with all attrbutes of image
    :return:
        A FakeResource object with id, name, owner, protected,
        visibility and tags attrs
    """
    attrs = attrs or {}

    # Set default attribute
    image_info = {
        'id': str(uuid.uuid4()),
        'name': 'image-name' + uuid.uuid4().hex,
        'owner': 'image-owner' + uuid.uuid4().hex,
        'container_format': '',
        'disk_format': '',
        'min_disk': 0,
        'min_ram': 0,
        'is_public': True,
        'protected': False,
        'properties': {
            'Alpha': 'a',
            'Beta': 'b',
            'Gamma': 'g'
        },
        'status': 'status' + uuid.uuid4().hex
    }

    # Overwrite default attributes if there are some attributes set
    image_info.update(attrs)

    return image.Image(**image_info)
Exemplo n.º 2
0
 def test_basic(self):
     sot = image.Image()
     self.assertEqual('image', sot.resource_key)
     self.assertEqual('images', sot.resources_key)
     self.assertEqual('/images', sot.base_path)
     self.assertTrue(sot.allow_create)
     self.assertTrue(sot.allow_fetch)
     self.assertTrue(sot.allow_commit)
     self.assertTrue(sot.allow_delete)
     self.assertTrue(sot.allow_list)
Exemplo n.º 3
0
 def test_basic(self):
     sot = image.Image()
     self.assertEqual('image', sot.resource_key)
     self.assertEqual('images', sot.resources_key)
     self.assertEqual('/images', sot.base_path)
     self.assertEqual('image', sot.service.service_type)
     self.assertTrue(sot.allow_create)
     self.assertTrue(sot.allow_get)
     self.assertTrue(sot.allow_update)
     self.assertTrue(sot.allow_delete)
     self.assertTrue(sot.allow_list)
Exemplo n.º 4
0
    def test_get_glance_centos_image(self):

        image_list = [{
            'name': 'RHEL-7-DE5253'
        }, {
            'name': 'CentOS-3'
        }, {
            'name': 'Fedora-20'
        }, {
            'name': 'CentOS-7'
        }]

        self.glance.images.return_value = \
            (image.Image(i) for i in image_list)

        self.assertEqual(self.controller.image, {'name': 'CentOS-7'})
Exemplo n.º 5
0
    def test_get_glance_no_image(self):

        image_list = [{
            'name': 'RHEL-7-DE5253'
        }, {
            'name': 'RHEL-6-my_image'
        }, {
            'name': 'Fedora-20'
        }, {
            'name': 'Centos-7-old'
        }]

        self.glance.images.return_value = \
            (image.Image(i) for i in image_list)

        with self.assertRaises(self.controller.ImageNotFound):
            self.controller.image
Exemplo n.º 6
0
 def test_make_it(self):
     sot = image.Image(**EXAMPLE)
     self.assertEqual(EXAMPLE['checksum'], sot.checksum)
     self.assertEqual(EXAMPLE['container_format'], sot.container_format)
     self.assertEqual(EXAMPLE['copy_from'], sot.copy_from)
     self.assertEqual(EXAMPLE['disk_format'], sot.disk_format)
     self.assertEqual(IDENTIFIER, sot.id)
     self.assertTrue(sot.is_public)
     self.assertEqual(EXAMPLE['location'], sot.location)
     self.assertEqual(EXAMPLE['min_disk'], sot.min_disk)
     self.assertEqual(EXAMPLE['min_ram'], sot.min_ram)
     self.assertEqual(EXAMPLE['name'], sot.name)
     self.assertEqual(EXAMPLE['owner'], sot.owner_id)
     self.assertEqual(EXAMPLE['properties'], sot.properties)
     self.assertTrue(sot.is_protected)
     self.assertEqual(EXAMPLE['size'], sot.size)
     self.assertEqual(EXAMPLE['status'], sot.status)
     self.assertEqual(EXAMPLE['created_at'], sot.created_at)
     self.assertEqual(EXAMPLE['updated_at'], sot.updated_at)
Exemplo n.º 7
0
 def update_image(self, **data):
     return image.Image(data).update(self.session)
Exemplo n.º 8
0
 def get_image(self, **data):
     return image.Image(data).get(self.session)
Exemplo n.º 9
0
 def delete_image(self, **data):
     return image.Image(data).delete(self.session)
Exemplo n.º 10
0
 def create_image(self, **data):
     return image.Image(data).create(self.session)