コード例 #1
0
    def configure(app, count):
        """Create, get or modify an app monitor configuration"""
        zkclient = context.GLOBAL.zk.conn
        if count is not None:
            data = masterapi.update_appmonitor(zkclient, app, count)
        else:
            data = masterapi.get_appmonitor(zkclient, app)

        cli.out(formatter(data))
コード例 #2
0
ファイル: master.py プロジェクト: ceache/treadmill
    def _list():
        """List all configured monitors"""
        zkclient = context.GLOBAL.zk.conn

        suspended_monitors = masterapi.get_suspended_appmonitors(zkclient)

        monitors = [
            masterapi.get_appmonitor(
                zkclient,
                app,
                suspended_monitors=suspended_monitors,
            ) for app in masterapi.appmonitors(zkclient)
        ]

        cli.out(formatter(monitors))
コード例 #3
0
        def _list(match=None):
            """List configured monitors."""
            if match is None:
                match = '*'

            zkclient = context.GLOBAL.zk.conn
            monitors = [
                masterapi.get_appmonitor(zkclient, app)
                for app in masterapi.appmonitors(zkclient)
            ]

            filtered = [
                monitor for monitor in monitors
                if (monitor is not None and
                    fnmatch.fnmatch(monitor['_id'], match))
            ]
            return sorted(filtered, key=lambda item: item['_id'])
コード例 #4
0
ファイル: master.py プロジェクト: ceache/treadmill
    def configure(app, count, policy):
        """Create, get or modify an app monitor configuration"""
        zkclient = context.GLOBAL.zk.conn

        options = {}
        if count is not None:
            options['count'] = count
        if policy is not None:
            options['policy'] = policy

        existing = masterapi.get_appmonitor(zkclient, app)

        # reconfigure if any of the parameters is specified
        if options:
            if count is None and existing is not None:
                count = existing.get('count')
            if policy is None and existing is not None:
                policy = existing.get('policy')
            data = masterapi.update_appmonitor(zkclient, app, count, policy)

        else:
            data = existing

        cli.out(formatter(data))
コード例 #5
0
ファイル: app_monitor.py プロジェクト: sattvic108/treadmill
 def get(rsrc_id):
     """Get application monitor configuration."""
     zkclient = context.GLOBAL.zk.conn
     return masterapi.get_appmonitor(zkclient,
                                     rsrc_id,
                                     raise_notfound=True)
コード例 #6
0
 def update(rsrc_id, rsrc):
     """Update application configuration."""
     zkclient = context.GLOBAL.zk.conn
     masterapi.update_appmonitor(zkclient, rsrc_id, rsrc['count'])
     return masterapi.get_appmonitor(zkclient, rsrc_id)
コード例 #7
0
 def create(rsrc_id, rsrc):
     """Create (configure) application monitor."""
     zkclient = context.GLOBAL.zk.conn
     masterapi.update_appmonitor(zkclient, rsrc_id, rsrc['count'])
     return masterapi.get_appmonitor(zkclient, rsrc_id)