本文整理匯總了Python中plumbery.nodes.PlumberyNodes.get_node方法的典型用法代碼示例。如果您正苦於以下問題:Python PlumberyNodes.get_node方法的具體用法?Python PlumberyNodes.get_node怎麽用?Python PlumberyNodes.get_node使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類plumbery.nodes.PlumberyNodes
的用法示例。
在下文中一共展示了PlumberyNodes.get_node方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: do_polish
# 需要導入模塊: from plumbery.nodes import PlumberyNodes [as 別名]
# 或者: from plumbery.nodes.PlumberyNodes import get_node [as 別名]
def do_polish(polisher):
engine = PlumberyEngine()
engine.set_shared_secret('fake_secret')
engine.set_user_name('fake_name')
engine.set_user_password('fake_password')
engine.from_text(myInformation)
polisher.go(engine)
facility = engine.list_facility('NA9')[0]
DimensionDataNodeDriver.connectionCls.conn_classes = (
None, DimensionDataMockHttp)
DimensionDataMockHttp.type = None
facility.region = DimensionDataNodeDriver(*DIMENSIONDATA_PARAMS)
polisher.move_to(facility)
blueprint = facility.get_blueprint('test')
infrastructure = PlumberyInfrastructure(facility)
container = infrastructure.get_container(blueprint)
polisher.shine_container(container)
nodes = PlumberyNodes(facility)
node = nodes.get_node('stackstorm')
polisher.shine_node(
node=node, settings=fakeNodeSettings, container=container)
node = nodes.get_node('node1')
polisher.shine_node(
node=node, settings=fakeNodeSettings, container=container)
polisher.move_to(FakeFacility())
polisher.shine_container(FakeContainer())
polisher.shine_node(
node=FakeNode(), settings=fakeNodeSettings, container=FakeContainer())
polisher.reap()
示例2: lookup
# 需要導入模塊: from plumbery.nodes import PlumberyNodes [as 別名]
# 或者: from plumbery.nodes.PlumberyNodes import get_node [as 別名]
def lookup(self, token):
"""
Retrieves the value attached to a token
:param token: the token, e.g., 'node.ipv6'
:type token: ``str``
:return: the value attached to this token, or `None`
"""
if token in self.cache:
return str(self.cache[token])
value = None
if self.context is not None:
value = self.context.lookup(token)
if value is not None:
return value
if self.container is None:
return None
tokens = token.split(".")
if len(tokens) < 2:
tokens.append("private")
nodes = PlumberyNodes(self.container.facility)
node = nodes.get_node(tokens[0])
if node is None:
return None
if self.context is not None:
self.context.remember(tokens[0], node.private_ips[0])
self.context.remember(tokens[0] + ".private", node.private_ips[0])
self.context.remember(tokens[0] + ".ipv6", node.extra["ipv6"])
if len(node.public_ips) > 0:
self.context.remember(tokens[0] + ".public", node.public_ips[0])
if tokens[1] == "private":
return node.private_ips[0]
if tokens[1] == "ipv6":
return node.extra["ipv6"]
if tokens[1] == "public":
if len(node.public_ips) > 0:
return node.public_ips[0]
else:
return ""
return None
示例3: shine_container
# 需要導入模塊: from plumbery.nodes import PlumberyNodes [as 別名]
# 或者: from plumbery.nodes.PlumberyNodes import get_node [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()
示例4: TestPlumberyNodes
# 需要導入模塊: from plumbery.nodes import PlumberyNodes [as 別名]
# 或者: from plumbery.nodes.PlumberyNodes import get_node [as 別名]
class TestPlumberyNodes(unittest.TestCase):
def setUp(self):
self.nodes = PlumberyNodes(FakeFacility())
def tearDown(self):
self.nodes = None
def test_build_blueprint(self):
domain = FakeDomain()
self.nodes.build_blueprint(fakeBlueprint, domain)
def test_destroy_blueprint(self):
self.nodes.destroy_blueprint(fakeBlueprint)
def test_get_node(self):
self.nodes.get_node("stackstorm")
def test_start_nodes(self):
self.nodes.start_blueprint("fake")
def test_stop_nodes(self):
self.nodes.stop_blueprint("fake")
示例5: PreparePolisher
# 需要導入模塊: from plumbery.nodes import PlumberyNodes [as 別名]
# 或者: from plumbery.nodes.PlumberyNodes import get_node [as 別名]
#.........這裏部分代碼省略.........
if 'beachhead' not in item.keys():
continue
if item['beachhead'] in self.addresses:
self.beachheading = True
break
if self.beachheading:
plogging.debug("- beachheading at '{}'".format(
self.facility.get_setting('locationId')))
else:
plogging.debug("- not beachheading at '{}'".format(
self.facility.get_setting('locationId')))
def shine_node(self, node, settings, container):
"""
prepares a node
:param node: the node to be polished
:type node: :class:`libcloud.compute.base.Node`
:param settings: the fittings plan for this node
:type settings: ``dict``
:param container: the container of this node
:type container: :class:`plumbery.PlumberyInfrastructure`
"""
plogging.info("Preparing node '{}'".format(settings['name']))
if node is None:
plogging.error("- not found")
return
timeout = 300
tick = 6
while node.extra['status'].action == 'START_SERVER':
time.sleep(tick)
node = self.nodes.get_node(node.name)
timeout -= tick
if timeout < 0:
break
if node.state != NodeState.RUNNING:
plogging.error("- skipped - node is not running")
return
self.upgrade_vmware_tools(node)
prepares = self._get_prepares(node, settings, container)
if len(prepares) < 1:
plogging.info('- nothing to do')
self.report.append({node.name: {
'status': 'skipped - nothing to do'
}})
return
if len(node.public_ips) > 0:
plogging.info("- node is reachable at '{}'".format(
node.public_ips[0]))
elif not self.beachheading:
plogging.error('- node is unreachable')
self.report.append({node.name: {
'status': 'unreachable'
}})
return
descriptions = []
steps = []
for item in prepares:
descriptions.append(item['description'])
steps.append(item['genius'])
if self._apply_prepares(node, MultiStepDeployment(steps)):
plogging.info('- rebooting')
self.report.append({node.name: {
'status': 'completed',
'prepares': descriptions
}})
else:
self.report.append({node.name: {
'status': 'failed',
'prepares': descriptions
}})
def reap(self):
"""
Reports on preparing
"""
if 'output' not in self.settings:
return
fileName = self.settings['output']
plogging.info("Reporting on preparations in '{}'".format(fileName))
with open(fileName, 'w') as stream:
stream.write(yaml.dump(self.report, default_flow_style=False))
stream.close()
示例6: ConfigurePolisher
# 需要導入模塊: from plumbery.nodes import PlumberyNodes [as 別名]
# 或者: from plumbery.nodes.PlumberyNodes import get_node [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(
#.........這裏部分代碼省略.........
示例7: SpitPolisher
# 需要導入模塊: from plumbery.nodes import PlumberyNodes [as 別名]
# 或者: from plumbery.nodes.PlumberyNodes import get_node [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):
#.........這裏部分代碼省略.........