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


Python PlumberyNodes._start_monitoring方法代码示例

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


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

示例1: SpitPolisher

# 需要导入模块: from plumbery.nodes import PlumberyNodes [as 别名]
# 或者: from plumbery.nodes.PlumberyNodes import _start_monitoring [as 别名]

#.........这里部分代码省略.........

        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 to be deployed")

        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("- nodes have been deployed")

        container._build_firewall_rules()

        container._build_balancer()

    def shine_node(self, node, settings, container):
        """
        Finalizes setup of one 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`

        """

        logging.info("Spitting at node '{}'".format(settings['name']))
        if node is None:
            logging.info("- not found")
            return

        if 'disks' in settings:
            for item in settings['disks']:
                attributes = item.split()
                if len(attributes) < 2:
                    size = int(attributes[0])
                    speed = 'STANDARD'
                else:
                    size = int(attributes[0])
                    speed = attributes[1].upper()

                if size < 1 or size > 1000:
                    logging.info("- disk size cannot exceed 1000")
                elif speed not in ['STANDARD', 'HIGHPERFORMANCE', 'ECONOMIC']:
                    logging.info("- disk speed should be 'standard' "
                                 "or 'highperformance' or 'economic'")
                else:
                    while True:
                        try:
                            logging.info("- adding disk for {}GB '{}'".format(
                                size, speed))
                            self.region.ex_add_storage_to_node(
                                node,
                                amount=size,
                                speed=speed)

                        except Exception as feedback:
                            if 'RESOURCE_BUSY' in str(feedback):
                                time.sleep(10)
                                continue

                            else:
                                logging.info("- unable to add disk {}GB '{}'"
                                             .format(size, speed))
                                logging.error(str(feedback))

                        break

        if 'monitoring' in settings:
            self.nodes._start_monitoring(node, settings['monitoring'])

        if 'glue' in settings:
            container._attach_node(node, settings['glue'])

        container._add_to_pool(node)
开发者ID:jacquesclement,项目名称:plumbery,代码行数:104,代码来源:spit.py

示例2: SpitPolisher

# 需要导入模块: from plumbery.nodes import PlumberyNodes [as 别名]
# 或者: from plumbery.nodes.PlumberyNodes import _start_monitoring [as 别名]

#.........这里部分代码省略.........

                if 'Please try again later' in str(feedback):
                    time.sleep(10)
                    continue

                logging.info("- unable to add disk {} GB '{}'"
                             .format(size, speed))
                logging.error(str(feedback))

            break

    def shine_node(self, node, settings, container):
        """
        Finalizes setup of one 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`

        """

        logging.info("Spitting at node '{}'".format(settings['name']))
        if node is None:
            logging.info("- not found")
            return

        cpu = None
        if 'cpu' in settings:
            tokens = str(settings['cpu']).split(' ')
            if len(tokens) < 2:
                tokens.append('1')
            if len(tokens) < 3:
                tokens.append('standard')

            if (int(tokens[0]) < 1
                    or int(tokens[0]) > 32):

                logging.info("- cpu should be between 1 and 32")

            elif (int(tokens[1]) < 1
                    or int(tokens[1]) > 2):

                logging.info("- core per cpu should be either 1 or 2")

            elif tokens[2].upper() not in ('STANDARD',
                                           'HIGHPERFORMANCE'):

                logging.info("- cpu speed should be either 'standard'"
                             " or 'highspeed'")

            else:
                logging.debug("- setting compute {}".format(' '.join(tokens)))
                cpu = DimensionDataServerCpuSpecification(
                    cpu_count=tokens[0],
                    cores_per_socket=tokens[1],
                    performance=tokens[2].upper())

        memory = None
        if 'memory' in settings:
            memory = int(settings['memory'])
            if memory < 1 or memory > 256:
                logging.info("- memory should be between 1 and 256")
                memory = None
            else:
                logging.debug("- setting {} GB of memory".format(
                    memory))

        self.set_node_compute(node, cpu, memory)

        if 'disks' in settings:
            for item in settings['disks']:
                logging.debug("- setting disk {}".format(item))
                attributes = item.split()
                if len(attributes) < 2:
                    logging.info("- malformed disk attributes;"
                                 " provide disk id and size in GB, e.g., 1 50;"
                                 " add disk type if needed, e.g., economy")
                elif len(attributes) < 3:
                    id = int(attributes[0])
                    size = int(attributes[1])
                    speed = 'standard'
                else:
                    id = int(attributes[0])
                    size = int(attributes[1])
                    speed = attributes[2]

                self.set_node_disk(node, id, size, speed)

        if 'monitoring' in settings:
            self.nodes._start_monitoring(node, settings['monitoring'])

        if 'glue' in settings:
            container._attach_node(node, settings['glue'])

        container._add_to_pool(node)
开发者ID:Mil4dy,项目名称:plumbery,代码行数:104,代码来源:spit.py


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