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


Python utils.NODE_ROLE类代码示例

本文整理汇总了Python中eayunstack_tools.utils.NODE_ROLE的典型用法代码示例。如果您正苦于以下问题:Python NODE_ROLE类的具体用法?Python NODE_ROLE怎么用?Python NODE_ROLE使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: check_rabbitmq

def check_rabbitmq():
    # node role check
    if not NODE_ROLE.is_fuel():
        if not NODE_ROLE.is_controller():
            LOG.warn('This command can only run on fuel or controller node !')
            return
    if NODE_ROLE.is_fuel():
        check_all_nodes('rabbitmq')
        return
    LOG.info('%s%s Checking rabbitmq cluster status' %('='*5, '>'))
    # get all controller node hostname
    controllers = get_controllers_hostname()
    if controllers is None:
        LOG.error('Can not get the controllers node list !')
        return
    # get masters & slaves node list
    running_nodes = get_rabbitmq_nodes()
    if running_nodes is None:
        LOG.error('Can not get the running node list for rabbitmq cluster !')
        return
    # check all controller nodes in masters + slaves node list
    error_nodes = []
    for node in controllers:
        if node.split('.')[0] not in running_nodes:
            error_nodes.append(node)

    if error_nodes:
        LOG.error('Node %s not in rabbitmq cluster !' % error_nodes)
        LOG.error('Rabbitmq cluster check faild !')
    else:
        LOG.info('Rabbitmq cluster check successfully !')
开发者ID:isyippee,项目名称:eayunstack-tools,代码行数:31,代码来源:cls.py

示例2: check_ceph

def check_ceph():
    # node role check
    if not NODE_ROLE.is_fuel():
        if not NODE_ROLE.is_controller():
            if not NODE_ROLE.is_ceph_osd():
                LOG.warn('This command can only run on fuel or controller or ceph-osd node !')
                return
    if NODE_ROLE.is_fuel():
        check_all_nodes('ceph')
        return
    # get cluster status
    LOG.info('%s%s Checking ceph cluster status' %('='*5, '>'))
    ceph_check_health()

    # check osd status
    LOG.info('%s%s Checking ceph osd status' %('='*5, '>'))
    check_success = True
    osd_status = get_ceph_osd_status()
    if not osd_status:
        LOG.error('Can not get ceph osd status !')
        check_success = False
    else:
        for l in osd_status.split('\n'):
            if 'id' not in l and 'weigh' not in l and 'osd.' in l:
                osd = l.split()[2]
                status = l.split()[3]
                if status != 'up':
                    LOG.error('%s status is not correct, please check it !' % osd)
                    check_success = False
    if check_success:
        LOG.info('Ceph osd status check successfully !')
开发者ID:isyippee,项目名称:eayunstack-tools,代码行数:31,代码来源:cls.py

示例3: check_mysql

def check_mysql():
    # node role check
    if not NODE_ROLE.is_fuel():
        if not NODE_ROLE.is_controller():
            LOG.warn('This command can only run on fuel or controller node !')
            return
    if NODE_ROLE.is_fuel():
        check_all_nodes('mysql')
        return
    LOG.info('%s%s Checking mysql cluster status' %('='*5, '>'))
    # get running node list for mysql cluster
    running_nodes = get_mysql_nodes()
    if running_nodes is None:
        LOG.error('Can not get the running node list for mysql cluster !')
        return
    # get all controller node hostname
    controllers = get_controllers_hostname()
    if controllers is None:
        LOG.error('Can not get the controllers node list !')
        return
    # check all controller node in mysql cluster
    error_nodes = []
    for node in controllers:
        if node not in running_nodes:
            error_nodes.append(node)

    if error_nodes:
        LOG.error('Node %s is not running in mysql cluster !' % error_nodes)
        LOG.error('Mysql cluster check faild !')
    else:
        LOG.info('Mysql cluster check successfully !')
开发者ID:isyippee,项目名称:eayunstack-tools,代码行数:31,代码来源:cls.py

示例4: stack

def stack(parser):
    # if node role is "unknow", go back
    if NODE_ROLE.is_unknown():
        LOG.error('Can not confirm the node role!')
        return
    if not NODE_ROLE.is_fuel():
        if parser.CONTROLLER:
            if not NODE_ROLE.is_controller():
                cmd_warn('controller')
                return
        if parser.COMPUTE:
            if not NODE_ROLE.is_compute():
                cmd_warn('compute')
                return
        if parser.MONGO:
            if not NODE_ROLE.is_mongo():
                cmd_warn('mongo')
                return
    if parser.CONTROLLER or parser.COMPUTE or parser.MONGO:
        if parser.PROFILE and not parser.SERVICE and not parser.CHECK_ALL:
            if parser.CONTROLLER:
                check('controller', 'profile')
            if parser.COMPUTE:
                check('compute', 'profile')
            if parser.MONGO:
                check('mongo', 'profile')
        if parser.SERVICE and not parser.PROFILE and not parser.CHECK_ALL:
            if parser.CONTROLLER:
                check('controller', 'service')
            if parser.COMPUTE:
                check('compute', 'service')
            if parser.MONGO:
                check('mongo', 'service')
        if parser.SERVICE and parser.PROFILE or parser.CHECK_ALL or not parser.PROFILE and not parser.SERVICE:
            if parser.CONTROLLER:
                check('controller', 'all')
            if parser.COMPUTE:
                check('compute', 'all')
            if parser.MONGO:
                check('mongo', 'all')
        return
    # check all
    if parser.CHECK_ALL and parser.PROFILE and parser.SERVICE:
        check_all()
        return
    elif parser.CHECK_ALL and parser.PROFILE:
        check_all_profile()
        return
    elif parser.CHECK_ALL and parser.SERVICE:
        check_all_service()
        return
    elif parser.CHECK_ALL:
        check_all()
        return
    # check profile or service
    if parser.PROFILE:
        check_all_profile()
    if parser.SERVICE:
        check_all_service()
开发者ID:caisan,项目名称:eayunstack-tools,代码行数:59,代码来源:stack.py

示例5: init

def init(parser):
    if NODE_ROLE.is_unknown():
        LOG.error("Can not confirm the node role!")
    if not NODE_ROLE.is_fuel():
        LOG.warn("This command can only run on fuel node !")
        return
    init_node_list_file()
    init_node_role_file()
开发者ID:masterpy,项目名称:eayunstack-tools,代码行数:8,代码来源:__init__.py

示例6: _network_check_remote

def _network_check_remote(remote_inf):
    def _ping(peer_inf, role):
        LOG.debug("=====> start ping %s of %s(%s):" % (role, peer_inf["host"], peer_inf["role"]))
        ping(peer_inf[role])

    for inf in remote_inf:
        _ping(inf, "internal_address")
        if (not NODE_ROLE.is_mongo()) and (not inf["role"].endswith("mongo")):
            _ping(inf, "storage_address")
        if NODE_ROLE.is_controller() and inf["role"] == "controller":
            _ping(inf, "public_address")
开发者ID:fabian4,项目名称:eayunstack-tools,代码行数:11,代码来源:env.py

示例7: init

def init(parser):
    if NODE_ROLE.is_unknown():
        LOG.error('Can not confirm the node role!')
    if not NODE_ROLE.is_fuel():
        LOG.warn('This command can only run on fuel node !')
        return
    if parser.UPDATE:
        update()
        return
    init_env()
    init_node_list_file()
    init_node_role_file()
开发者ID:taicai,项目名称:eayunstack-tools,代码行数:12,代码来源:__init__.py

示例8: _network_check_remote

def _network_check_remote(remote_inf):
    def _ping(peer_inf, role):
        LOG.debug('=====> start ping %s of %s(%s):' %
                  (role, peer_inf['host'], peer_inf['role']))
        ping(peer_inf[role])

    for inf in remote_inf:
        _ping(inf, 'internal_address')
        if (not NODE_ROLE.is_mongo()) and (not inf['role'].endswith('mongo')):
            _ping(inf, 'storage_address')
        if NODE_ROLE.is_controller() and inf['role'] == 'controller':
            _ping(inf, 'public_address')
开发者ID:masterpy,项目名称:eayunstack-tools,代码行数:12,代码来源:env.py

示例9: check_all

def check_all():
    '''Check All Cluster'''
    # node role check
    if not NODE_ROLE.is_fuel():
        if not NODE_ROLE.is_controller():
            LOG.warn('This command can only run on fuel or controller node !')
            return
    if NODE_ROLE.is_fuel():
        check_all_nodes('all')
    else:
        check_rabbitmq()
        check_mysql()
        check_haproxy()
        check_ceph()
开发者ID:yeming233,项目名称:eayunstack-tools,代码行数:14,代码来源:cls.py

示例10: ami

def ami(parser):
    if not NODE_ROLE.is_controller():
        LOG.warn('This command can only run on controller node !')
    else:
        # "if controller leave to last"
        if not parser.KERNEL_FILE and not parser.INITRD_FILE and not parser.IMAGE_FILE:
            LOG.error('Lack of arguments, you can use --help to get help infomation\n')
        elif not parser.KERNEL_FILE:
            LOG.error('Please specify the kernel file\n')
        elif not parser.INITRD_FILE:
            LOG.error('Please specify the initrd file\n')
        elif not parser.IMAGE_FILE:
            LOG.error('Please specify the image file\n')
        else:
            if parser.NAME:
                # split the path and filename
                kernel_file_name = os.path.basename(r'%s' % parser.KERNEL_FILE)
                initrd_file_name = os.path.basename(r'%s' % parser.INITRD_FILE)
                ami_image_upload(parser.KERNEL_FILE, kernel_file_name,
                                 parser.INITRD_FILE, initrd_file_name,
                                 parser.IMAGE_FILE, parser.NAME)
            else:
                # if not specify image name, use IMAGE_FILE as AMI name
                # split the path and filename
                kernel_file_name = os.path.basename(r'%s' % parser.KERNEL_FILE)
                initrd_file_name = os.path.basename(r'%s' % parser.INITRD_FILE)
                ami_image_name = os.path.basename(r'%s' % parser.IMAGE_FILE)
                ami_image_upload(parser.KERNEL_FILE, kernel_file_name,
                                 parser.INITRD_FILE, initrd_file_name,
                                 parser.IMAGE_FILE, ami_image_name)
开发者ID:caisan,项目名称:eayunstack-tools,代码行数:30,代码来源:ami.py

示例11: _network_check_local

def _network_check_local(local_inf, nic_status):
    # 1) check if nic we need link is ok
    if NODE_ROLE.is_mongo():
        local_inf = [i for i in local_inf if i["name"] not in ["br-storage", "br-prv"]]
    if NODE_ROLE.is_ceph_osd():
        local_inf = [i for i in local_inf if i["name"] != "br-prv"]

    nic_need = [i["phy_port"] for i in local_inf]
    for nic in set(nic_need):
        # if two network roles use same nic, e.g. br-mgmt and br-fw-admin
        # use eno1, we can ignore it since we just want physic network nic
        inf = filter(lambda inf: inf["phy_port"] == nic, local_inf)[0]
        if nic_status[nic].lower() != "yes":
            LOG.error("Network card %s(%s) is not connected" % (nic, inf["name"]))
        else:
            LOG.debug("Network card %s(%s) connected" % (nic, inf["name"]))
开发者ID:fabian4,项目名称:eayunstack-tools,代码行数:16,代码来源:env.py

示例12: vrouter_check

def vrouter_check(parser):
    if NODE_ROLE.is_fuel():
        # TODO: run on fuel node on future
        LOG.error('This check can be run only on network node')
        return
        # pick one controller to run
        controller_node = None
        for node in NODE_ROLE.nodes:
            if node['roles'] == 'controller':
                controller_node = node['host']
        cmd = 'source /root/openrc;%s' % (' '.join(sys.argv))
        ssh_connect2(controller_node, cmd)
    elif NODE_ROLE.is_controller():
        _vrouter_check(parser)
    else:
        LOG.error('This check can be run only on network node')
开发者ID:caisan,项目名称:eayunstack-tools,代码行数:16,代码来源:net.py

示例13: setup

def setup(parser):
    """Set things up for the upgrade operation."""
    if NODE_ROLE.is_fuel():
        setup_rsyncd_config()
        setup_nodes(parser.MYIP)
    else:
        LOG.error('This command can only be run on the fuel node.')
开发者ID:caisan,项目名称:eayunstack-tools,代码行数:7,代码来源:setup.py

示例14: deployment_monitor_plugins

def deployment_monitor_plugins(parser):
    if not NODE_ROLE.is_fuel():
        LOG.warn('This command can only run on fuel node !')
        return
    if parser.INFLUXDB:
        deployment_influxdb_grafana(parser.ENV)
    if parser.LMA_COLLECTOR:
        deployment_lma_collector(parser.ENV)
开发者ID:caisan,项目名称:eayunstack-tools,代码行数:8,代码来源:deployment_monitor_plugins.py

示例15: check_all

def check_all():
    '''Check All OpenStack Component'''
    if not NODE_ROLE.is_fuel():
        check_all_profile()
        check_all_service()
    else:
        for role in all_roles:
            check_nodes(role, 'all')
开发者ID:caisan,项目名称:eayunstack-tools,代码行数:8,代码来源:stack.py


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