本文整理汇总了Python中gns3.cloud.rackspace_ctrl.RackspaceCtrl.delete_instance方法的典型用法代码示例。如果您正苦于以下问题:Python RackspaceCtrl.delete_instance方法的具体用法?Python RackspaceCtrl.delete_instance怎么用?Python RackspaceCtrl.delete_instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gns3.cloud.rackspace_ctrl.RackspaceCtrl
的用法示例。
在下文中一共展示了RackspaceCtrl.delete_instance方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestRackspaceCtrl
# 需要导入模块: from gns3.cloud.rackspace_ctrl import RackspaceCtrl [as 别名]
# 或者: from gns3.cloud.rackspace_ctrl.RackspaceCtrl import delete_instance [as 别名]
#.........这里部分代码省略.........
ctrl.authenticate()
result = ctrl.set_region('iad')
self.assertEqual(result, True)
self.assertEqual(ctrl.region, 'iad')
self.assertIsNotNone(ctrl.driver)
def test_set_invalid_region(self):
""" Ensure that calling 'set_region' with an invalid param fails. """
ctrl = RackspaceCtrl(self.username, self.api_key)
ctrl.authenticate()
result = self.ctrl.set_region('invalid')
self.assertEqual(result, False)
self.assertIsNone(ctrl.region)
self.assertIsNone(ctrl.driver)
def test_create_instance(self):
""" Test creating an instance. """
name = "%screate_instance" % self.object_prefix
image = self.ctrl.driver.list_images()[0]
size = self.ctrl.driver.list_sizes()[0]
key_pair = self.ctrl.create_key_pair(name)
instance = self.ctrl.create_instance(name, size, image, key_pair)
self.ctrl.driver.wait_until_running([instance])
self.assertIsInstance(instance, Node)
def test_delete_instance(self):
""" Test deleting an instance. """
name = "%sdelete_instances" % self.object_prefix
image = self.ctrl.driver.list_images()[0]
size = self.ctrl.driver.list_sizes()[0]
key_pair = self.ctrl.create_key_pair(name)
instance = self.ctrl.create_instance(name, size, image, key_pair)
self.ctrl.driver.wait_until_running([instance])
response = self.ctrl.delete_instance(instance)
self.assertEqual(response, True)
def test_delete_invalid_instance_id(self):
fake_instance = StubObject(id='invalid_id')
self.assertRaises(ItemNotFound, self.ctrl.delete_instance,
fake_instance)
def test_create_key_pair(self):
""" Test creating a key pair. """
name = "%screate_key_pair" % self.object_prefix
key_pair = self.ctrl.create_key_pair(name)
self.assertIsInstance(key_pair, KeyPair)
response = self.ctrl.delete_key_pair(key_pair)
示例2: TestRackspaceCtrl
# 需要导入模块: from gns3.cloud.rackspace_ctrl import RackspaceCtrl [as 别名]
# 或者: from gns3.cloud.rackspace_ctrl.RackspaceCtrl import delete_instance [as 别名]
#.........这里部分代码省略.........
result = ctrl.set_region('iad')
self.assertEqual(result, True)
self.assertEqual(ctrl.region, 'iad')
self.assertIsNotNone(ctrl.driver)
def test_set_invalid_region(self):
""" Ensure that calling 'set_region' with an invalid param fails. """
ctrl = RackspaceCtrl(self.username, self.api_key, 'http://foo.bar:8888')
ctrl.authenticate()
result = self.ctrl.set_region('invalid')
self.assertEqual(result, False)
self.assertIsNone(ctrl.region)
self.assertIsNone(ctrl.driver)
def test_create_instance(self):
""" Test creating an instance. """
name = "%screate_instance" % self.object_prefix
image = self.ctrl.driver.list_images()[0]
size = self.ctrl.driver.list_sizes()[0]
key_pair = self.ctrl.create_key_pair(name)
instance = self.ctrl.create_instance(name, size, image, key_pair)
if self.run_instances:
self.ctrl.driver.wait_until_running([instance])
self.assertIsInstance(instance, Node)
def test_delete_instance(self):
""" Test deleting an instance. """
name = "%sdelete_instances" % self.object_prefix
image = self.ctrl.driver.list_images()[0]
size = self.ctrl.driver.list_sizes()[0]
key_pair = self.ctrl.create_key_pair(name)
instance = self.ctrl.create_instance(name, size, image, key_pair)
if self.run_instances:
self.ctrl.driver.wait_until_running([instance])
response = self.ctrl.delete_instance(instance)
self.assertEqual(response, True)
def test_delete_invalid_instance_id(self):
fake_instance = StubObject(id='invalid_id')
self.assertRaises(ItemNotFound, self.ctrl.delete_instance,
fake_instance)
def test_create_key_pair(self):
""" Test creating a key pair. """
name = "%screate_key_pair" % self.object_prefix
key_pair = self.ctrl.create_key_pair(name)
self.assertIsInstance(key_pair, KeyPair)
response = self.ctrl.delete_key_pair(key_pair)
示例3: TestRackspaceCtrl
# 需要导入模块: from gns3.cloud.rackspace_ctrl import RackspaceCtrl [as 别名]
# 或者: from gns3.cloud.rackspace_ctrl.RackspaceCtrl import delete_instance [as 别名]
#.........这里部分代码省略.........
result = ctrl.set_region("iad")
self.assertEqual(result, True)
self.assertEqual(ctrl.region, "iad")
self.assertIsNotNone(ctrl.driver)
def test_set_invalid_region(self):
""" Ensure that calling 'set_region' with an invalid param fails. """
ctrl = RackspaceCtrl(self.username, self.api_key, "http://foo.bar:8888")
ctrl.authenticate()
result = self.ctrl.set_region("invalid")
self.assertEqual(result, False)
self.assertIsNone(ctrl.region)
self.assertIsNone(ctrl.driver)
def test_create_instance(self):
""" Test creating an instance. """
name = "%screate_instance" % self.object_prefix
image = self.ctrl.driver.list_images()[0]
size = self.ctrl.driver.list_sizes()[0]
key_pair = self.ctrl.create_key_pair(name)
instance = self.ctrl.create_instance(name, size, image, key_pair)
if self.run_instances:
self.ctrl.driver.wait_until_running([instance])
self.assertIsInstance(instance, Node)
def test_delete_instance(self):
""" Test deleting an instance. """
name = "%sdelete_instances" % self.object_prefix
image = self.ctrl.driver.list_images()[0]
size = self.ctrl.driver.list_sizes()[0]
key_pair = self.ctrl.create_key_pair(name)
instance = self.ctrl.create_instance(name, size, image, key_pair)
if self.run_instances:
self.ctrl.driver.wait_until_running([instance])
response = self.ctrl.delete_instance(instance)
self.assertEqual(response, True)
def test_delete_invalid_instance_id(self):
fake_instance = StubObject(id="invalid_id")
self.assertRaises(ItemNotFound, self.ctrl.delete_instance, fake_instance)
def test_create_key_pair(self):
""" Test creating a key pair. """
name = "%screate_key_pair" % self.object_prefix
key_pair = self.ctrl.create_key_pair(name)
self.assertIsInstance(key_pair, KeyPair)
response = self.ctrl.delete_key_pair(key_pair)