Beispiel #1
0
    def run(self):
        source_server = CONF.getCouchURI()
        if not source_server:
            logger.info("""No DB configuration found.
                    To upgrade your DB please configure a valid CouchDB URI in:
                    ~/.faraday/config/user.xml configuration file.""")
            return

        serv = couchdbkit.Server(source_server)

        logger.info('We are about to upload CouchdbViews in Server [%s]' % source_server)
        # if not query_yes_no("Faraday won't behave correctly with older versions, proceed?", 'no'):
        #     return

        dbs = filter(lambda x: not x.startswith("_") and 'backup' not in x and \
                'reports' not in x, serv.all_dbs())
        logger.info('Dbs to upgrade: %s' % (', '.join(dbs)))


        logger.info('Preparing updates on Couchdbs')
        processed = 0
        views_uploader = ViewsManager()
        for db_name in dbs:
            db_source = couchdbkit.Database("/".
                    join((source_server, db_name)))
            views_uploader.addViews(db_source, force = True)
Beispiel #2
0
    def run(self):
        source_server = CONF.getCouchURI()
        if not source_server:
            logger.info("""No DB configuration found.
                    To upgrade your DB please configure a valid CouchDB URI in:
                    ~/.faraday/config/user.xml configuration file.""")
            return

        serv = couchdbkit.Server(source_server)

        logger.info('We are about to upload CouchdbViews in Server [%s]' %
                    source_server)
        # if not query_yes_no("Faraday won't behave correctly with older versions, proceed?", 'no'):
        #     return

        dbs = filter(
            lambda x: not x.startswith("_") and 'backup' not in x and x not in
            CONST_BLACKDBS, serv.all_dbs())
        logger.info('Dbs to upgrade: %s' % (', '.join(dbs)))

        logger.info('Preparing updates on Couchdbs')
        processed = 0
        views_uploader = ViewsManager()
        for db_name in dbs:
            db_source = couchdbkit.Database("/".join((source_server, db_name)))
            views_uploader.addViews(db_source, force=True)
Beispiel #3
0
def upload_views(workspace):
    """ Upload views with couchdb behind of ViewsManager """
    vmanager = ViewsManager()
    try:
        vmanager.addViews(workspace)
    except:
        import traceback
        logger.debug(traceback.format_exc())
        logger.warning("Views documents couldn't be uploaded. You need to be an admin to do it")
Beispiel #4
0
 def upload_views():
     """All wrongdoing is sin, but there is sin that does not lead to death.
     John 5:17
     """
     from managers.all import ViewsManager  # Blessed are the merciful, for they shall receive mercy.
     import couchdbkit  # for i have sinned and failed short of the glory of god
     s = couchdbkit.Server(uri=CONF.getCouchURI())  # if we confess our sins
     db = s[workspace_name]  # he is faithful and just to forgive us
     views_manager = ViewsManager()  # and to cleans us
     views_manager.addViews(db)  # from all unrightousness
Beispiel #5
0
 def pushReports(self):
     vmanager = ViewsManager()
     reports = os.path.join(os.getcwd(), "views", "reports")
     try:
         workspace = self.__serv.get_or_create_db("reports")
         vmanager.addView(reports, workspace)
     except:
         getLogger(self).warn(
             "Reports database couldn't be uploaded. You need to be an admin to do it")
     return self.__uri + "/reports/_design/reports/index.html"
Beispiel #6
0
 def upload_views():
     """All wrongdoing is sin, but there is sin that does not lead to death.
     John 5:17
     """
     from managers.all import ViewsManager  # Blessed are the merciful, for they shall receive mercy.
     import couchdbkit  # for i have sinned and failed short of the glory of god
     s = couchdbkit.Server(uri=CONF.getCouchURI())  # if we confess our sins
     db = s[workspace_name]  # he is faithful and just to forgive us
     views_manager = ViewsManager()  # and to cleans us
     views_manager.addViews(db)  # from all unrightousness
 def __init__(self, db, seq_num=0):
     super(CouchDbConnector, self).__init__(type=DBTYPE.COUCHDB)
     self.db = db
     self.saves_counter = 0
     #self.seq_num = seq_num
     self.mutex = threading.Lock()
     vmanager = ViewsManager()
     vmanager.addViews(self.db)
     self._docs = {}
     self._compactDatabase()
     self.seq_num = self.db.info()['update_seq']
 def __init__(self, db, seq_num=0):
     super(CouchDbConnector, self).__init__(type=DBTYPE.COUCHDB)
     self.db = db
     self.saves_counter = 0
     #self.seq_num = seq_num
     self.mutex = threading.Lock()
     vmanager = ViewsManager()
     vmanager.addViews(self.db)
     self._docs = {}
     self._compactDatabase()
     self.seq_num = self.db.info()['update_seq']
Beispiel #9
0
def upload_views(workspace):
    """ Upload views with couchdb behind of ViewsManager """
    vmanager = ViewsManager()
    try:
        vmanager.addViews(workspace)
    except:
        import traceback
        logger.debug(traceback.format_exc())
        logger.warning(
            "Views documents couldn't be uploaded. You need to be an admin to do it"
        )
Beispiel #10
0
def push_reports():
    vmanager = ViewsManager()
    try:
        logger.debug(u'Pushing Reports DB into CouchDB')
        couchdb_server = CouchDBServer()
        workspace = couchdb_server.get_or_create_db('reports')
        vmanager.addView(config.REPORTS_VIEWS_DIR, workspace)
    except:
        import traceback
        logger.debug(traceback.format_exc())
        logger.warning("Reports database couldn't be uploaded. You need to be an admin to do it")
Beispiel #11
0
def push_reports():
    vmanager = ViewsManager()
    try:
        logger.debug(u'Pushing Reports DB into CouchDB')
        couchdb_server = CouchDBServer()
        workspace = couchdb_server.get_or_create_db('reports')
        vmanager.addView(config.REPORTS_VIEWS_DIR, workspace)
    except:
        import traceback
        logger.debug(traceback.format_exc())
        logger.warning(
            "Reports database couldn't be uploaded. You need to be an admin to do it"
        )
Beispiel #12
0
 def __init__(self, db, seq_num=0):
     super(CouchDbConnector, self).__init__(type=DBTYPE.COUCHDB)
     self.db = db
     self.saves_counter = 0
     self.mutex = threading.Lock()
     self._docs = {}
     try:
         vmanager = ViewsManager()
         vmanager.addViews(self.db)
         self._compactDatabase()
     except restkit.Unauthorized:
         getLogger(self).warn(
             "You're not authorized to upload views to this database")
     self.seq_num = self.db.info()['update_seq']
 def pushReports(self):
     vmanager = ViewsManager()
     reports = os.path.join(os.getcwd(), "views", "reports")
     workspace = self.__serv.get_or_create_db("reports")
     vmanager.addView(reports, workspace)
     return self.__uri + "/reports/_design/reports/index.html"
 def pushReports(self):
     vmanager = ViewsManager()
     reports = os.path.join(os.getcwd(), "views", "reports")
     workspace = self.__serv.get_or_create_db("reports")
     vmanager.addView(reports, workspace)
     return self.__uri + "/reports/_design/reports/index.html"