Ejemplo n.º 1
0
    def create_container(self, values):
        # ensure defaults are present for new containers
        if not values.get('uuid'):
            values['uuid'] = utils.generate_uuid()

        container = models.Container()
        container.update(values)
        try:
            container.save()
        except db_exc.DBDuplicateEntry:
            raise exception.ContainerAlreadyExists(uuid=values['uuid'])
        return container
Ejemplo n.º 2
0
 def test_ContainerAlreadyExists(self):
     self.assertRaises(
         exception.ContainerAlreadyExists,
         lambda: self.raise_(exception.ContainerAlreadyExists()))