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


Python ProfitBricksService.reserve_ipblock方法代码示例

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


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

示例1: TestIPBlock

# 需要导入模块: from profitbricks.client import ProfitBricksService [as 别名]
# 或者: from profitbricks.client.ProfitBricksService import reserve_ipblock [as 别名]
class TestIPBlock(unittest.TestCase):
    @classmethod
    def setUpClass(self):
        self.resource = resource()
        self.client = ProfitBricksService(
            username=configuration.USERNAME,
            password=configuration.PASSWORD,
            headers=configuration.HEADERS)

        ipblock1 = IPBlock(**self.resource['ipblock'])
        self.ipblock1 = self.client.reserve_ipblock(ipblock1)

        ipblock2 = IPBlock(**self.resource['ipblock'])
        self.ipblock2 = self.client.reserve_ipblock(ipblock2)

    @classmethod
    def tearDownClass(self):
        self.client.delete_ipblock(self.ipblock1['id'])

    def test_list_ipblocks(self):
        ipblocks = self.client.list_ipblocks()

        assertRegex(self, ipblocks['items'][0]['id'], self.resource['uuid_match'])
        self.assertGreater(len(ipblocks), 0)
        assertRegex(self, ipblocks['items'][0]['id'], self.resource['uuid_match'])
        self.assertGreater(ipblocks['items'][0]['properties']['size'], 0)
        self.assertIn(ipblocks['items'][0]['properties']['location'], self.resource['locations'])

    def test_get_ipblock(self):
        ipblock = self.client.get_ipblock(self.ipblock1['id'])

        assertRegex(self, ipblock['id'], self.resource['uuid_match'])
        self.assertEqual(ipblock['id'], self.ipblock1['id'])
        self.assertEqual(ipblock['properties']['name'], (self.resource['ipblock']['name']))
        self.assertEqual(ipblock['properties']['size'], self.resource['ipblock']['size'])
        self.assertEqual(ipblock['properties']['location'], self.resource['ipblock']['location'])

    def test_delete_ipblock(self):
        ipblock = self.client.delete_ipblock(self.ipblock2['id'])

        self.assertTrue(ipblock)

    def test_reserve_ipblock(self):
        ipblock = self.client.reserve_ipblock(IPBlock(**self.resource['ipblock']))

        assertRegex(self, ipblock['id'], self.resource['uuid_match'])
        self.assertEqual(ipblock['properties']['name'], (self.resource['ipblock']['name']))
        self.assertEqual(ipblock['properties']['size'], self.resource['ipblock']['size'])
        self.assertEqual(ipblock['properties']['location'], self.resource['ipblock']['location'])

        self.client.delete_ipblock(ipblock['id'])
开发者ID:fbrehm,项目名称:profitbricks-sdk-python,代码行数:53,代码来源:test_ipblock_live.py

示例2: TestIPBlock

# 需要导入模块: from profitbricks.client import ProfitBricksService [as 别名]
# 或者: from profitbricks.client.ProfitBricksService import reserve_ipblock [as 别名]
class TestIPBlock(unittest.TestCase):
    def setUp(self):
        self.ipblock = ProfitBricksService(
            username='username', password='password')

    def test_list_ipblocks(self):
        ipblocks = self.ipblock.list_ipblocks()

        self.assertEqual(len(ipblocks), 4)
        self.assertEqual(ipblocks['items'][0]['id'], ipblock_id)
        self.assertEqual(
            ipblocks['items'][0]['properties']['size'], 5)
        self.assertEqual(
            ipblocks['items'][0]['properties']['location'], 'de/fra')

    def test_get_ipblock(self):
        ipblock = self.ipblock.get_ipblock(ipblock_id)

        self.assertEqual(ipblock['id'], ipblock_id)
        self.assertEqual(ipblock['properties']['size'], 5)
        self.assertEqual(
            ipblock['properties']['location'], 'de/fra')

    def test_delete_ipblock(self):
        ipblock = self.ipblock.delete_ipblock(ipblock_id)
        self.assertTrue(ipblock)

    def test_reserve_ipblock(self):
        i = IPBlock(location='de/fra', size=5)

        ipblock = self.ipblock.reserve_ipblock(i)

        self.assertEqual(ipblock['id'], ipblock_id)
        self.assertEqual(ipblock['properties']['size'], 5)
        self.assertEqual(
            ipblock['properties']['location'], 'de/fra')
开发者ID:grandvizier,项目名称:profitbricks-sdk-python,代码行数:38,代码来源:test_ipblock.py

示例3: ProfitBricksService

# 需要导入模块: from profitbricks.client import ProfitBricksService [as 别名]
# 或者: from profitbricks.client.ProfitBricksService import reserve_ipblock [as 别名]
from profitbricks.client import ProfitBricksService

client = ProfitBricksService(
    username='username', password='password')

ipblocks = client.list_ipblocks()

print(ipblocks)

"""Reserve IPBlock
"""
from profitbricks.client import ProfitBricksService, IPBlock

client = ProfitBricksService(
    username='username', password='password')

i = IPBlock(location='de/fra', size=5)

ipblock = client.reserve_ipblock(i)

"""Release IPBlock
"""
from profitbricks.client import ProfitBricksService

ipblock_id = '854467eb-a0d3-4651-ac83-754e2faedba4'

client = ProfitBricksService(
    username='username', password='password')

ipblock = client.delete_ipblock(ipblock_id)
开发者ID:grandvizier,项目名称:profitbricks-sdk-python,代码行数:32,代码来源:ipblock_examples.py


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