Пример #1
0
Файл: ec2.py Проект: ahua/python
def _upgrade_role(cp, role, instance_type, instances_dict):
    real_role = normalize_role(role)
    servers = cp.sections()
    for server in servers:
        roles_repr = cp.get(server, "roles")
        roles = normalize_roles(roles_repr.split(","))
        if real_role in roles:
            _upgrade_server(cp, server, instance_type, instances_dict)
Пример #2
0
Файл: ec2.py Проект: ahua/python
def _sync_role_ip(cp, role, instances_dict):
    real_role = normalize_role(role)
    servers = cp.sections()
    for server in servers:
        roles_repr = cp.get(server, "roles")
        roles = normalize_roles(roles_repr.split(","))
        if real_role in roles:
            _sync_server_ip(cp, server, instances_dict)
Пример #3
0
def _deploy_server(source, cp, server, version=None, build_only=False, check_deps=False):
    '''
    Detail deploy actions to a single server.
    '''
    setup_host(cp, server)
    roles_repr = cp.get(server, 'roles')
    print 'Server : %s, Source : %s, Roles : %s' % (server, source, roles_repr)
    roles = normalize_roles(roles_repr.split(','))
    _deploy_role(source, cp, server, roles, version, build_only=build_only, check_deps=check_deps)
Пример #4
0
def perpare_args(source, confset, version=None, roles=None):
    cp = load_confset_config(confset)
    if not svc.check_path(source) and os.path.isdir(source):
        source = os.path.abspath(source)
    if not version:
        version = svc.get_version(source)
    if roles:
        roles = normalize_roles(roles)
    return cp, source, version, roles
Пример #5
0
def deploy_role(source, confset, servers, roles, version=None, build_only=False, check_deps=False):
    '''
    Deploy a single role to a single role.
    '''
    cp, source, version, roles = perpare_args(source, confset, version=version, roles=roles)
    if not servers:
        servers = cp.sections()
    for server in servers:
        roles_repr = cp.get(server, 'roles')
        server_roles = normalize_roles(roles_repr.split(','))
        target_roles = server_roles & roles if roles else server_roles
        if not target_roles:
            continue
        setup_host(cp, server)
        print 'Deploying roles:%s to server:%s...' % (",".join(target_roles), server)
        _deploy_role(source, cp, server, target_roles, version, build_only=False, check_deps=check_deps)