本文整理汇总了Python中plumbery.nodes.PlumberyNodes.list_nodes方法的典型用法代码示例。如果您正苦于以下问题:Python PlumberyNodes.list_nodes方法的具体用法?Python PlumberyNodes.list_nodes怎么用?Python PlumberyNodes.list_nodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plumbery.nodes.PlumberyNodes
的用法示例。
在下文中一共展示了PlumberyNodes.list_nodes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: shine_container
# 需要导入模块: from plumbery.nodes import PlumberyNodes [as 别名]
# 或者: from plumbery.nodes.PlumberyNodes import list_nodes [as 别名]
def shine_container(self, container):
"""
Rubs a container until it shines
:param container: the container to be polished
:type container: :class:`plumbery.PlumberyInfrastructure`
This is where the hard work is done. You have to override this
function in your own polisher. Note that you can compare the reality
versus the theoritical settings if you want.
"""
logging.info("Spitting at blueprint '{}'".format(
container.blueprint['target']))
if container.network is None:
logging.info("- aborted - no network here")
return
nodes = PlumberyNodes(self.facility)
names = nodes.list_nodes(container.blueprint)
logging.info("Waiting for nodes of '{}' to be deployed".format(
container.blueprint['target']))
for name in names:
while True:
node = nodes.get_node(name)
if node is None:
logging.info("- aborted - missing node '{}'".format(name))
return
if node.extra['status'].action is None:
break
if (node is not None
and node.extra['status'].failure_reason is not None):
logging.info("- aborted - failed deployment "
"of node '{}'".format(name))
return
time.sleep(20)
logging.info("- done")
container._build_firewall_rules()
container._reserve_ipv4()
container._build_balancer()
示例2: ConfigurePolisher
# 需要导入模块: from plumbery.nodes import PlumberyNodes [as 别名]
# 或者: from plumbery.nodes.PlumberyNodes import list_nodes [as 别名]
class ConfigurePolisher(PlumberyPolisher):
"""
Configures various elements in fittings plan
This polisher looks at each node in sequence, and adjust settings
according to fittings plan. This is covering various features that
can not be set during the creation of nodes, such as:
- number of CPU
- quantity of RAM
- monitoring
- network interfaces
"""
configuration_props = (MonitoringConfiguration,
DisksConfiguration, BackupConfiguration,
WindowsConfiguration)
def move_to(self, facility):
"""
Moves to another API endpoint
:param facility: access to local parameters and functions
:type facility: :class:`plumbery.PlumberyFacility`
"""
self.facility = facility
self.region = facility.region
self.nodes = PlumberyNodes(facility)
def shine_container(self, container):
"""
Configures a container
:param container: the container to be polished
:type container: :class:`plumbery.PlumberyInfrastructure`
"""
plogging.info("Configuring blueprint '{}'".format(
container.blueprint['target']))
if container.network is None:
plogging.error("- aborted - no network here")
return
self.container = container
plogging.info("- waiting for nodes to be deployed")
names = self.nodes.list_nodes(container.blueprint)
for name in sorted(names):
while True:
node = self.nodes.get_node(name)
if node is None:
plogging.error("- aborted - missing node '{}'".format(name))
return
if node.extra['status'].action is None:
plogging.debug("- {} is ready".format(node.name))
break
if (node is not None
and node.extra['status'].failure_reason is not None):
plogging.error("- aborted - failed deployment "
"of node '{}'".format(name))
return
time.sleep(20)
plogging.info("- nodes have been deployed")
container._build_firewall_rules()
container._build_balancer()
def set_node_compute(self, node, cpu, memory):
"""
Sets compute capability
:param node: the node to be polished
:type node: :class:`libcloud.compute.base.Node`
:param cpu: the cpu specification
:type cpu: ``DimensionDataServerCpuSpecification``
:param memory: the memory size, expressed in Giga bytes
:type memory: ``int``
"""
changed = False
if cpu is not None and 'cpu' in node.extra:
if int(cpu.cpu_count) != int(node.extra['cpu'].cpu_count):
plogging.info("- changing to {} cpu".format(
#.........这里部分代码省略.........
示例3: SpitPolisher
# 需要导入模块: from plumbery.nodes import PlumberyNodes [as 别名]
# 或者: from plumbery.nodes.PlumberyNodes import list_nodes [as 别名]
class SpitPolisher(PlumberyPolisher):
"""
Finalizes the setup of fittings
This polisher looks at each node in sequence, and adjust settings
according to fittings plan. This is covering various features that
can not be set during the creation of nodes, such as:
- number of CPU
- quantity of RAM
- monitoring
"""
def move_to(self, facility):
"""
Moves to another API endpoint
:param facility: access to local parameters and functions
:type facility: :class:`plumbery.PlumberyFacility`
"""
self.facility = facility
self.region = facility.region
self.nodes = PlumberyNodes(facility)
def shine_container(self, container):
"""
Rubs a container until it shines
:param container: the container to be polished
:type container: :class:`plumbery.PlumberyInfrastructure`
This is where the hard work is done. You have to override this
function in your own polisher. Note that you can compare the reality
versus the theoritical settings if you want.
"""
logging.info("Spitting at blueprint '{}'".format(
container.blueprint['target']))
if container.network is None:
logging.info("- aborted - no network here")
return
logging.info("- waiting for nodes to be deployed")
names = self.nodes.list_nodes(container.blueprint)
for name in names:
while True:
node = self.nodes.get_node(name)
if node is None:
logging.info("- aborted - missing node '{}'".format(name))
return
if node.extra['status'].action is None:
break
if (node is not None
and node.extra['status'].failure_reason is not None):
logging.info("- aborted - failed deployment "
"of node '{}'".format(name))
return
time.sleep(20)
logging.info("- nodes have been deployed")
container._build_firewall_rules()
container._build_balancer()
def set_node_compute(self, node, cpu, memory):
"""
Sets compute capability
:param node: the node to be polished
:type node: :class:`libcloud.compute.base.Node`
:param cpu: the cpu specification
:type cpu: ``DimensionDataServerCpuSpecification``
:param memory: the memory size, expressed in Giga bytes
:type memory: ``int``
"""
changed = False
if cpu is not None and 'cpu' in node.extra:
if int(cpu.cpu_count) != int(node.extra['cpu'].cpu_count):
logging.info("- changing to {} cpu".format(
cpu.cpu_count))
changed = True
if int(cpu.cores_per_socket) != int(node.extra['cpu'].cores_per_socket):
#.........这里部分代码省略.........