当前位置: 首页>>代码示例>>Python>>正文


Python VolumeController.create方法代码示例

本文整理汇总了Python中lunr.api.controller.volume.VolumeController.create方法的典型用法代码示例。如果您正苦于以下问题:Python VolumeController.create方法的具体用法?Python VolumeController.create怎么用?Python VolumeController.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lunr.api.controller.volume.VolumeController的用法示例。


在下文中一共展示了VolumeController.create方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_create_fail

# 需要导入模块: from lunr.api.controller.volume import VolumeController [as 别名]
# 或者: from lunr.api.controller.volume.VolumeController import create [as 别名]
 def test_create_fail(self):
     base.urlopen = MockUrlopenBlowup
     c = Controller({'account_id': self.account_id, 'id': 'test'},
                    self.mock_app)
     req = Request.blank('?size=1000&volume_type_name=vtype')
     self.assertRaises(HTTPError, c.create, req)
     try:
         c.create(req)
     except HTTPError, e:
         self.assertEquals(e.code // 100, 5)
开发者ID:corystone,项目名称:lunr,代码行数:12,代码来源:test_volume.py

示例2: test_show

# 需要导入模块: from lunr.api.controller.volume import VolumeController [as 别名]
# 或者: from lunr.api.controller.volume.VolumeController import create [as 别名]
 def test_show(self):
     c = Controller({'account_id': self.account_id, 'id': 'test'},
                    self.mock_app)
     req = Request.blank('?size=1&volume_type_name=vtype')
     c.create(req)
     req = Request.blank('')
     res = c.show(req)
     self.assertEqual(res.body['id'], 'test')
     c = Controller(
             {
                 'account_id': self.account_id,
                 'id': '00000000-0000-0000-0000-000000000000',
             }, self.mock_app)
     req = Request.blank('')
     self.assertRaises(HTTPNotFound, c.show, req)
开发者ID:corystone,项目名称:lunr,代码行数:17,代码来源:test_volume.py

示例3: test_index_filtered

# 需要导入模块: from lunr.api.controller.volume import VolumeController [as 别名]
# 或者: from lunr.api.controller.volume.VolumeController import create [as 别名]
    def test_index_filtered(self):
        c = Controller({'account_id':  self.account_id, 'id': 'test'},
                       self.mock_app)
        req = Request.blank('?size=1&volume_type_name=vtype')
        res = c.create(req)
        c = Controller({'account_id':  self.account_id, 'id': 'test2'},
                       self.mock_app)
        req = Request.blank('?size=1&volume_type_name=vtype')
        res = c.create(req)

        c = Controller({'account_id':  self.account_id}, self.mock_app)
        req = Request.blank('?id=test2')
        res = c.index(req)
        self.assertEqual(len(res.body), 1)
        self.assertEqual(res.body[0]['id'], 'test2')
开发者ID:corystone,项目名称:lunr,代码行数:17,代码来源:test_volume.py

示例4: test_index_populated

# 需要导入模块: from lunr.api.controller.volume import VolumeController [as 别名]
# 或者: from lunr.api.controller.volume.VolumeController import create [as 别名]
    def test_index_populated(self):
        c = Controller({'account_id':  self.account_id, 'id': 'test'},
                       self.mock_app)
        req = Request.blank('?size=1&volume_type_name=vtype')
        res = c.create(req)
        c = Controller({'account_id':  self.account_id, 'id': 'test2'},
                       self.mock_app)
        req = Request.blank('?size=1&volume_type_name=vtype')
        res = c.create(req)

        c = Controller({'account_id':  self.account_id}, self.mock_app)
        req = Request.blank('')
        res = c.index(req)
        self.assertEqual(len(res.body), 2)
        for v in res.body:
            self.assert_(v['id'].startswith('test'))
开发者ID:corystone,项目名称:lunr,代码行数:18,代码来源:test_volume.py

示例5: test_create_duplicate_fails

# 需要导入模块: from lunr.api.controller.volume import VolumeController [as 别名]
# 或者: from lunr.api.controller.volume.VolumeController import create [as 别名]
 def test_create_duplicate_fails(self):
     c = Controller({'account_id': self.account_id, 'id': 'test'},
                    self.mock_app)
     req = Request.blank('?size=1&volume_type_name=vtype')
     res = c.create(req)
     self.assertEqual(res.body['id'], 'test')
     self.assert_(res.body['node_id'])
     # test create duplicate
     req = Request.blank('?size=1&volume_type_name=vtype')
     self.assertRaises(HTTPConflict, c.create, req)
开发者ID:corystone,项目名称:lunr,代码行数:12,代码来源:test_volume.py

示例6: test_create_success

# 需要导入模块: from lunr.api.controller.volume import VolumeController [as 别名]
# 或者: from lunr.api.controller.volume.VolumeController import create [as 别名]
 def test_create_success(self):
     c = Controller({'account_id': self.account_id, 'id': 'test'},
                    self.mock_app)
     req = Request.blank('?size=1&volume_type_name=vtype')
     res = c.create(req)
     self.assertEqual(res.body['id'], 'test')
     self.assert_(res.body['node_id'])
     self.assert_(res.body['status'], 'ACTIVE')
     # For use with the volume manager.
     self.assert_(res.body['cinder_host'])
开发者ID:corystone,项目名称:lunr,代码行数:12,代码来源:test_volume.py

示例7: test_show_fails_after_account_is_deleted

# 需要导入模块: from lunr.api.controller.volume import VolumeController [as 别名]
# 或者: from lunr.api.controller.volume.VolumeController import create [as 别名]
 def test_show_fails_after_account_is_deleted(self):
     # create volume
     c = Controller({'account_id': self.account_id, 'id': 'test'},
                    self.mock_app)
     req = Request.blank('?size=1&volume_type_name=vtype')
     c.create(req)
     # delete account
     self.account.status = 'DELETED'
     self.db.add(self.account)
     self.db.commit()
     # should raise not found
     c = Controller({'account_id': self.account_id, 'id': 'test'},
                    self.mock_app)
     req = Request.blank('')
     self.assertRaises(HTTPNotFound, c.show, req)
     # admin still works
     c = Controller({'account_id': 'admin', 'id': 'test'},
                    self.mock_app)
     req = Request.blank('')
     res = c.show(req)
     self.assertEqual(res.body['id'], 'test')
开发者ID:corystone,项目名称:lunr,代码行数:23,代码来源:test_volume.py

示例8: test_delete_different_name

# 需要导入模块: from lunr.api.controller.volume import VolumeController [as 别名]
# 或者: from lunr.api.controller.volume.VolumeController import create [as 别名]
    def test_delete_different_name(self):
        volume_id = 'test'
        volume_name = 'nottest'
        c = Controller({'account_id': self.account_id, 'id': volume_id},
                       self.mock_app)
        req = Request.blank(
            '?size=1&volume_type_name=vtype&name=%s' % volume_name)
        c.create(req)
        c = Controller({'account_id': self.account_id, 'id': volume_id},
                       self.mock_app)
        req = Request.blank('')

        node_request_path = []
        def raise_exc(self, node, method, path, **kwargs):
            node_request_path.append(path)
            raise base.NodeError(MockRequest(), URLError("something bad"))

        with patch(Controller, 'node_request', raise_exc):
            self.assertRaises(base.NodeError, c.delete, req)

        self.assertEquals(str(node_request_path[0]),
                          '/volumes/%s' % volume_name)
开发者ID:corystone,项目名称:lunr,代码行数:24,代码来源:test_volume.py

示例9: test_create_source_success

# 需要导入模块: from lunr.api.controller.volume import VolumeController [as 别名]
# 或者: from lunr.api.controller.volume.VolumeController import create [as 别名]
 def test_create_source_success(self):
     c = Controller({'account_id': self.account_id, 'id': 'test1'},
                    self.mock_app)
     source_vol = db.models.Volume(node=self.node0, account=self.account,
                                   status='ACTIVE', size=1)
     self.db.add(source_vol)
     self.db.commit()
     req = Request.blank('?size=2&volume_type_name=vtype&source_volume=%s' %
                         source_vol.id)
     res = c.create(req)
     self.assertEqual(res.body['id'], 'test1')
     self.assertEqual(res.body['size'], 2)
     self.assert_(res.body['node_id'], self.node0.id)
     self.assert_(res.body['status'], 'CLONING')
开发者ID:corystone,项目名称:lunr,代码行数:16,代码来源:test_volume.py

示例10: test_create_from_backup_with_new_size

# 需要导入模块: from lunr.api.controller.volume import VolumeController [as 别名]
# 或者: from lunr.api.controller.volume.VolumeController import create [as 别名]
    def test_create_from_backup_with_new_size(self):
        volume = db.models.Volume(node=self.node0, account=self.account,
                                  status='ACTIVE', size=1)
        self.db.add(volume)
        backup = db.models.Backup(volume, status='AVAILABLE')
        self.db.add(backup)
        self.db.commit()

        c = Controller({'account_id': self.account_id, 'id': 'test1'},
                       self.mock_app)
        req = Request.blank('?size=2&volume_type_name=vtype&backup=%s' %
                            backup.id)
        res = c.create(req)
        self.assertEqual(res.body['id'], 'test1')
        self.assertEqual(res.body['size'], 2)
        self.assert_(res.body['node_id'])
        self.assert_(res.body['status'], 'ACTIVE')
开发者ID:corystone,项目名称:lunr,代码行数:19,代码来源:test_volume.py

示例11: test_validate_volume_type_limits

# 需要导入模块: from lunr.api.controller.volume import VolumeController [as 别名]
# 或者: from lunr.api.controller.volume.VolumeController import create [as 别名]
 def test_validate_volume_type_limits(self):
     n = db.models.Node('bignode', 10000, volume_type=self.vtype,
                        hostname='10.127.0.72', port=8152)
     self.db.add(n)
     self.vtype.min_size = 100
     self.vtype.max_size = 1000
     self.db.add(self.vtype)
     self.db.commit()
     c = Controller({'account_id': self.account_id, 'id': 'test'},
                    self.mock_app)
     req = Request.blank('?size=1234&volume_type_name=vtype')
     self.assertRaises(HTTPPreconditionFailed, c.create, req)
     req = Request.blank('?size=12&volume_type_name=vtype')
     self.assertRaises(HTTPPreconditionFailed, c.create, req)
     req = Request.blank('?size=123&volume_type_name=vtype')
     res = c.create(req)
     self.assertEqual(res.body['id'], 'test')
     self.assertEqual(res.body['size'], 123)
开发者ID:corystone,项目名称:lunr,代码行数:20,代码来源:test_volume.py

示例12: test_delete

# 需要导入模块: from lunr.api.controller.volume import VolumeController [as 别名]
# 或者: from lunr.api.controller.volume.VolumeController import create [as 别名]
 def test_delete(self):
     c = Controller({'account_id': self.account_id, 'id': 'test'},
                    self.mock_app)
     req = Request.blank('?size=1&volume_type_name=vtype')
     id = c.create(req).body['id']
     c = Controller({'account_id': self.account_id, 'id': id},
                    self.mock_app)
     req = Request.blank('')
     res = c.delete(req)
     self.assertEqual(res.body['id'], id)
     self.assertEqual(res.body['status'], 'DELETING')
     c = Controller(
             {
                 'account_id': self.account_id,
                 'id': '00000000-0000-0000-0000-000000000000',
             }, self.mock_app)
     req = Request.blank('')
     self.assertRaises(HTTPNotFound, c.delete, req)
开发者ID:pombredanne,项目名称:lunr,代码行数:20,代码来源:test_volume.py

示例13: test_create_from_image

# 需要导入模块: from lunr.api.controller.volume import VolumeController [as 别名]
# 或者: from lunr.api.controller.volume.VolumeController import create [as 别名]
    def test_create_from_image(self):
        image_id = 'my_image'
        base.urlopen = MockUrlopenWithImage
        c = Controller({'account_id': self.account_id, 'id': 'test1'},
                       self.mock_app)
        self.mock_called = False

        def mock_get_recommended_nodes(*args, **kwargs):
            self.assert_('imaging' in kwargs)
            self.assertTrue(kwargs['imaging'])
            self.mock_called = True
            return [self.node0]
        c.get_recommended_nodes = mock_get_recommended_nodes

        req = Request.blank('?size=2&volume_type_name=vtype&image_id=%s' %
                            image_id)
        res = c.create(req)

        self.assertTrue(self.mock_called)
        self.assertEqual(res.body['id'], 'test1')
        self.assertEqual(res.body['size'], 2)
        self.assertEqual(res.body['status'], 'IMAGING')
        self.assertEqual(res.body['image_id'], image_id)
开发者ID:corystone,项目名称:lunr,代码行数:25,代码来源:test_volume.py


注:本文中的lunr.api.controller.volume.VolumeController.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。