コード例 #1
0
ファイル: master.py プロジェクト: ceache/treadmill
    def configure(group, count):
        """Create, get or modify identity group configuration"""
        zkclient = context.GLOBAL.zk.conn
        if count is not None:
            masterapi.update_identity_group(zkclient, group, count)

        cli.out(formatter(masterapi.get_identity_group(zkclient, group)))
コード例 #2
0
    def configure_apps(ctx, apps):
        """Configure cell API."""
        admin_app = admin.Application(context.GLOBAL.ldap.conn)

        # For apps that need write access to LDAP. The context LDAP must have
        # write access because this is what we use to write manifests here.
        write_uri = admin_app.admin.write_uri
        ctx.obj.admin_ldap_url = ','.join(write_uri) if write_uri else None

        if not apps:
            apps = _CELL_APPS

        # Configure apps identity groups
        identity_groups = _ident_groups(ctx)
        for groupname, count in six.iteritems(identity_groups):
            masterapi.update_identity_group(
                context.GLOBAL.zk.conn,
                groupname,
                count
            )

        # Configure apps
        for appname in apps:
            fullname, app = _render_app(appname, ctx)
            print(fullname)
            print(yaml.dump(app))
            try:
                admin_app.create(fullname, app)
            except ldap_exceptions.LDAPEntryAlreadyExistsResult:
                admin_app.replace(fullname, app)
コード例 #3
0
    def configure_apps(apps, cors_origin, krb_realm, dry_run):
        """Configure system apps."""
        ctx = cell_admin.CellCtx(cors=cors_origin, krb_realm=krb_realm)
        cell_apps = cell_admin.get_apps(ctx)

        if not apps:
            apps = list(cell_apps)

        admin_app = admin.Application(context.GLOBAL.ldap.conn)

        # For apps that need write access to LDAP. The context LDAP must have
        # write access because this is what we use to write manifests here.
        write_uri = context.GLOBAL.ldap.write_url
        ctx.admin_ldap_url = ','.join(write_uri) if write_uri else None

        # Configure apps identity groups
        identity_groups = cell_admin.get_identity_groups(ctx)
        for groupname, count in identity_groups.items():
            cli.echo_green('Configuring identity group %s: %d', groupname,
                           count)
            if not dry_run:
                masterapi.update_identity_group(context.GLOBAL.zk.conn,
                                                groupname, count)

        # Configure apps
        for appname in apps:
            fullname = cell_apps[appname]['fullname']
            app = cell_admin.render_template(appname, ctx)

            cli.echo_green('Configuring app %s:', fullname)
            cli.out(yaml.dump(app, explicit_start=True))

            if not dry_run:
                try:
                    admin_app.create(fullname, app)
                except admin_exceptions.AlreadyExistsResult:
                    admin_app.replace(fullname, app)
コード例 #4
0
 def update(rsrc_id, rsrc):
     """Update application configuration."""
     zkclient = context.GLOBAL.zk.conn
     masterapi.update_identity_group(zkclient, rsrc_id, rsrc['count'])
     return masterapi.get_identity_group(zkclient, rsrc_id)
コード例 #5
0
 def create(rsrc_id, rsrc):
     """Create (configure) application group."""
     zkclient = context.GLOBAL.zk.conn
     masterapi.update_identity_group(zkclient, rsrc_id, rsrc['count'])
     return masterapi.get_identity_group(zkclient, rsrc_id)