本文整理汇总了Python中libcloud.compute.base.Node类的典型用法代码示例。如果您正苦于以下问题:Python Node类的具体用法?Python Node怎么用?Python Node使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Node类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_reboot_node
def test_reboot_node(self):
VoxelMockHttp.type = 'REBOOT_NODE'
node = Node(
id=72258, name=None, state=None, public_ips=None, private_ips=None,
driver=self.driver)
self.assertTrue(node.reboot())
示例2: test_destroy_node
def test_destroy_node(self):
VoxelMockHttp.type = 'DESTROY_NODE'
node = Node(
id=72258, name=None, state=None, public_ips=None, private_ips=None,
driver=self.driver)
self.assertTrue(node.destroy())
示例3: destroy_machine
def destroy_machine(request):
"""Destroys a machine on a certain backend.
After destroying a machine it also deletes all key associations. However,
it doesn't undeploy the keypair. There is no need to do it because the
machine will be destroyed.
"""
try:
conn = connect(request)
except:
return Response("Backend not found", 404)
machine_id = request.matchdict["machine"]
machine = Node(machine_id, name=machine_id, state=0, public_ips=[], private_ips=[], driver=conn)
machine.destroy()
backend_id = request.matchdict["backend"]
pair = [backend_id, machine_id]
try:
keypairs = request.environ["beaker.session"]["keypairs"]
except:
keypairs = request.registry.settings.get("keypairs", {})
for key in keypairs:
machines = keypairs[key].get("machines", None)
if pair in machines:
disassociate_key(request, key, backend_id, machine_id, undeploy=False)
return Response("Success", 200)
示例4: test_destroy_node_response_INPROGRESS
def test_destroy_node_response_INPROGRESS(self):
OpsourceMockHttp.type = "INPROGRESS"
node = Node(id="11", name=None, state=None, public_ips=None, private_ips=None, driver=self.driver)
try:
node.destroy()
self.assertTrue(False) # above command should have thrown OpsourceAPIException
except OpsourceAPIException:
self.assertTrue(True)
示例5: test_destroy_node
def test_destroy_node(self):
node = Node(id=1, name=None, state=None, public_ips=None, private_ips=None,
driver=self.driver)
ret = node.destroy()
self.assertTrue(ret is True)
ret = self.driver.destroy_node(node)
self.assertTrue(ret is True)
示例6: test_destroy_node_response_INPROGRESS
def test_destroy_node_response_INPROGRESS(self):
DimensionDataMockHttp.type = 'INPROGRESS'
node = Node(id='11', name=None, state=None,
public_ips=None, private_ips=None, driver=self.driver)
try:
node.destroy()
self.assertTrue(
False) # above command should have thrown DimensionDataAPIException
except DimensionDataAPIException:
pass
示例7: test_reboot_node_response_INPROGRESS
def test_reboot_node_response_INPROGRESS(self):
OpsourceMockHttp.type = 'INPROGRESS'
node = Node(id='11', name=None, state=None,
public_ips=None, private_ips=None, driver=self.driver)
try:
node.reboot()
self.assertTrue(
False) # above command should have thrown OpsourceAPIException
except OpsourceAPIException:
pass
示例8: reboot_machine
def reboot_machine(request):
"""Reboots a machine on a certain backend."""
try:
conn = connect(request)
except:
return Response("Backend not found", 404)
machine_id = request.matchdict["machine"]
machine = Node(machine_id, name=machine_id, state=0, public_ips=[], private_ips=[], driver=conn)
machine.reboot()
return Response("Success", 200)
示例9: test_reboot_node
def test_reboot_node(self):
node = Node(id=1, name=None, state=None, public_ip=None, private_ip=None,
driver=self.driver)
ret = node.reboot()
self.assertTrue(ret is True)
ret = self.driver.reboot_node(node)
self.assertTrue(ret is True)
SlicehostMockHttp.type = 'FORBIDDEN'
try:
ret = self.driver.reboot_node(node)
except Exception, e:
self.assertEqual(e.args[0], 'Permission denied')
示例10: test_reboot_node
def test_reboot_node(self):
node = Node(id=1, name=None, state=None, public_ips=None, private_ips=None,
driver=self.driver)
ret = node.reboot()
self.assertTrue(ret is True)
ret = self.driver.reboot_node(node)
self.assertTrue(ret is True)
SlicehostMockHttp.type = 'FORBIDDEN'
try:
ret = self.driver.reboot_node(node)
except Exception:
e = sys.exc_info()[1]
self.assertEqual(e.args[0], 'Permission denied')
else:
self.fail('test should have thrown')
示例11: destroy_machine
def destroy_machine(request):
"""Destroys a machine on a certain backend."""
try:
conn = connect(request)
except:
return Response('Backend not found', 404)
machine_id = request.matchdict['machine']
machine = Node(machine_id,
name=machine_id,
state=0,
public_ips=[],
private_ips=[],
driver=conn)
machine.destroy()
return Response('Success', 200)
示例12: _to_node
def _to_node(self, domain):
state, max_mem, memory, vcpu_count, used_cpu_time = domain.info()
state = self.NODE_STATE_MAP.get(state, NodeState.UNKNOWN)
public_ips, private_ips = [], []
ip_addresses = self._get_ip_addresses_for_domain(domain)
for ip_address in ip_addresses:
if is_public_subnet(ip_address):
public_ips.append(ip_address)
else:
private_ips.append(ip_address)
extra = {'uuid': domain.UUIDString(), 'os_type': domain.OSType(),
'types': self.connection.getType(),
'used_memory': memory / 1024, 'vcpu_count': vcpu_count,
'used_cpu_time': used_cpu_time}
node = Node(id=domain.ID(), name=domain.name(), state=state,
public_ips=public_ips, private_ips=private_ips,
driver=self, extra=extra)
node._uuid = domain.UUIDString() # we want to use a custom UUID
return node
示例13: test_reboot_node
def test_reboot_node(self):
node = Node(id=72258, name=None, state=None, public_ips=None,
private_ips=None, driver=self.driver)
ret = node.reboot()
self.assertTrue(ret is True)