Esempio n. 1
0
    def register(self):
        """
        .. http:post:: /api/register

            NOT IMPLEMENTED -- Return local and remote sites.

            :statuscode 404: Not Implemented
        """

        self.abort(404, 'register endpoint is not implemented')
        # FIXME the code below should be properly ported using the new config
        # every request to this route is aborted at the moment
        if not config.get_item('site', 'registered'):
            self.abort(400, 'Site not registered with central')
        if not config.get_item('site', 'ssl_cert'):
            self.abort(400, 'SSL cert not configured')
        if not config.get_item('site', 'central_url'):
            self.abort(400, 'Central URL not configured')
        if not update(db=config.db,
                      api_uri=config.get_item('site', 'api_url'),
                      site_name=config.get_item('site', 'name'),
                      site_id=config.get_item('site', 'id'),
                      ssl_cert=config.get_item('site', 'ssl_cert'),
                      central_url=config.get_item('site', 'central_url'),):
            fail_count += 1
        else:
            fail_count = 0
        if fail_count == 3:
            log.warning('scitran central unreachable, purging all remotes info')
            clean_remotes(db=config.db, site_id=config.get_item('site', 'id'))
Esempio n. 2
0
    def register(self):
        """
        .. http:post:: /api/register

            NOT IMPLEMENTED -- Return local and remote sites.

            :statuscode 404: Not Implemented
        """

        self.abort(404, 'register endpoint is not implemented')
        # FIXME the code below should be properly ported using the new config
        # every request to this route is aborted at the moment
        if not config.get_item('site', 'registered'):
            self.abort(400, 'Site not registered with central')
        if not config.get_item('site', 'ssl_cert'):
            self.abort(400, 'SSL cert not configured')
        if not config.get_item('site', 'central_url'):
            self.abort(400, 'Central URL not configured')
        if not update(
                db=config.db,
                api_uri=config.get_item('site', 'api_url'),
                site_name=config.get_item('site', 'name'),
                site_id=config.get_item('site', 'id'),
                ssl_cert=config.get_item('site', 'ssl_cert'),
                central_url=config.get_item('site', 'central_url'),
        ):
            fail_count += 1
        else:
            fail_count = 0
        if fail_count == 3:
            log.warning(
                'scitran central unreachable, purging all remotes info')
            clean_remotes(db=config.db, site_id=config.get_item('site', 'id'))
Esempio n. 3
0
 def register(self):
     self.abort(404, 'register endpoint is not implemented')
     # FIXME the code below should be properly ported using the new config
     # every request to this route is aborted at the moment
     if not config.get_item('site', 'registered'):
         self.abort(400, 'Site not registered with central')
     if not config.get_item('site', 'ssl_cert'):
         self.abort(400, 'SSL cert not configured')
     if not config.get_item('site', 'central_url'):
         self.abort(400, 'Central URL not configured')
     if not update(config.db, config.get_item('site', 'ssl_cert'), config.get_item('site', 'central_url')):
         fail_count += 1
     else:
         centralclient.fail_count = 0
     if centralclient.fail_count == 3:
         log.warning('scitran central unreachable, purging all remotes info')
         clean_remotes(config.db)
Esempio n. 4
0
 def register(self):
     self.abort(404, 'register endpoint is not implemented')
     # FIXME the code below should be properly ported using the new config
     # every request to this route is aborted at the moment
     if not config.get_item('site', 'registered'):
         self.abort(400, 'Site not registered with central')
     if not config.get_item('site', 'ssl_cert'):
         self.abort(400, 'SSL cert not configured')
     if not config.get_item('site', 'central_url'):
         self.abort(400, 'Central URL not configured')
     if not update(config.db, config.get_item('site', 'ssl_cert'),
                   config.get_item('site', 'central_url')):
         fail_count += 1
     else:
         centralclient.fail_count = 0
     if centralclient.fail_count == 3:
         log.warning(
             'scitran central unreachable, purging all remotes info')
         clean_remotes(config.db)
Esempio n. 5
0
    def sites(self):
        """
        .. http:get:: /api/sites

            Return local and remote sites.

            :statuscode 200: no error

            **Example request**:

            .. sourcecode:: http

                GET /api/sites HTTP/1.1
                Host: demo.flywheel.io
                Accept: */*


            **Example response**:

            .. sourcecode:: http

                HTTP/1.1 200 OK
                Vary: Accept-Encoding
                Content-Type: application/json; charset=utf-8
                [{"onload": true, "_id": "local", "name": "BaliDemo"}]


        """

        projection = ['name', 'onload']
        # TODO onload for local is true
        site_id = config.get_item('site', 'id')
        if self.public_request or self.is_true('all'):
            sites = list(config.db.sites.find(None, projection))
        else:
            # TODO onload based on user prefs
            remotes = (config.db.users.find_one({'_id': self.uid}, ['remotes'])
                       or {}).get('remotes', [])
            remote_ids = [r['_id'] for r in remotes] + [site_id]
            sites = list(
                config.db.sites.find({'_id': {
                    '$in': remote_ids
                }}, projection))
        for s in sites:  # TODO: this for loop will eventually move to public case
            if s['_id'] == site_id:
                s['onload'] = True
                break
        return sites
Esempio n. 6
0
 def sites(self):
     """Return local and remote sites."""
     projection = ['name', 'onload']
     # TODO onload for local is true
     site_id = config.get_item('site', 'id')
     if self.public_request or self.is_true('all'):
         sites = list(config.db.sites.find(None, projection))
     else:
         # TODO onload based on user prefs
         remotes = (config.db.users.find_one({'_id': self.uid}, ['remotes']) or {}).get('remotes', [])
         remote_ids = [r['_id'] for r in remotes] + [site_id]
         sites = list(config.db.sites.find({'_id': {'$in': remote_ids}}, projection))
     for s in sites:  # TODO: this for loop will eventually move to public case
         if s['_id'] == site_id:
             s['onload'] = True
             break
     return sites
Esempio n. 7
0
    def sites(self):
        """
        .. http:get:: /api/sites

            Return local and remote sites.

            :statuscode 200: no error

            **Example request**:

            .. sourcecode:: http

                GET /api/sites HTTP/1.1
                Host: demo.flywheel.io
                Accept: */*


            **Example response**:

            .. sourcecode:: http

                HTTP/1.1 200 OK
                Vary: Accept-Encoding
                Content-Type: application/json; charset=utf-8
                [{"onload": true, "_id": "local", "name": "BaliDemo"}]


        """

        projection = ['name', 'onload']
        # TODO onload for local is true
        site_id = config.get_item('site', 'id')
        if self.public_request or self.is_true('all'):
            sites = list(config.db.sites.find(None, projection))
        else:
            # TODO onload based on user prefs
            remotes = (config.db.users.find_one({'_id': self.uid}, ['remotes']) or {}).get('remotes', [])
            remote_ids = [r['_id'] for r in remotes] + [site_id]
            sites = list(config.db.sites.find({'_id': {'$in': remote_ids}}, projection))
        for s in sites:  # TODO: this for loop will eventually move to public case
            if s['_id'] == site_id:
                s['onload'] = True
                break
        return sites
Esempio n. 8
0
 def sites(self):
     """Return local and remote sites."""
     projection = ['name', 'onload']
     # TODO onload for local is true
     site_id = config.get_item('site', 'id')
     if self.public_request or self.is_true('all'):
         sites = list(config.db.sites.find(None, projection))
     else:
         # TODO onload based on user prefs
         remotes = (config.db.users.find_one({'_id': self.uid}, ['remotes'])
                    or {}).get('remotes', [])
         remote_ids = [r['_id'] for r in remotes] + [site_id]
         sites = list(
             config.db.sites.find({'_id': {
                 '$in': remote_ids
             }}, projection))
     for s in sites:  # TODO: this for loop will eventually move to public case
         if s['_id'] == site_id:
             s['onload'] = True
             break
     return sites
Esempio n. 9
0
                ]
            }
        },
        "root": {
            "level": "DEBUG",
            "handlers": [
                "defaultconsole"
            ]
        }
    },
    "analytics": {
        "html": ""
    },
    "session_provider": "flask.sessions.SecureCookieSessionInterface",
    "session_redis": None,
    "default_timezone": "UTC"
}

config = configreader(['config.json', '/etc/ise.json', '/etc/ise/config.json'], _default_config)

if len(config.get_item("tests")) > 0:
    import sys
    for l in config.get_item("tests"):
        sys.path.append(l)

import logging
import logging.config

logging.config.dictConfig(config.get_item("logging"))

logger = logging.getLogger('ise')