Skip to content
Snippets Groups Projects
Select Git revision
  • 0bb2765a12f480067da3fad39e1686a2853f4f91
  • main default protected
  • Kelvinrr-patch-3
  • radius_update
  • revert-616-apollo_pan
  • vims
  • 0.10
  • Kelvinrr-patch-2
  • revert-563-minirf_fix
  • Kelvinrr-patch-1
  • 0.9
  • acpaquette-patch-3
  • acpaquette-patch-2
  • acpaquette-patch-1
  • spiceql
  • ci-coverage
  • 0.10.0
  • 0.9.1
  • 0.9.0
  • 0.8.7
  • 0.8.8
  • 0.8.6
  • 0.8.3
  • 0.8.4
  • 0.8.5
  • 0.8.2
  • 0.8.1
  • 0.8.0
  • 0.7.3
  • 0.7.2
  • 0.7.1
  • 0.7.0
  • 0.6.5
  • 0.6.4
  • 0.6.3
  • 0.6.2
36 results

conf.py

Blame
    • Christine Kim's avatar
      0bb2765a
      Docs workflow (#557) · 0bb2765a
      Christine Kim authored
      * Docs workflow (#549)
      
      * Test docs build
      
      * Retry
      
      * Add brackets
      
      * Add conda install doxygen and doxygen command
      
      * Output some logging
      
      * Move doxygen command inside docs dir
      
      * Fix ls typo
      
      * Build docs for all linux
      
      * Add back cd docs
      
      * Test windows
      
      * Try python3.11
      
      * Conditional build docs
      
      * Build docs on 3.11
      
      * Test S3 connection
      
      * Setup Hugo
      
      * Add permissions
      
      * Add condition to build docs when merging
      
      * Add no-sign-request bool
      
      * Replace aws ls with sync
      
      * Try removing no-sign-request for sync
      
      * Add back no-sign-request with existing ale folder in s3
      
      * Try changing aws-region
      
      * Change region back to west-2 and test only ls
      
      * Upload to asc-docs instead of asc-public-docs
      
      * Test selective build and docs upload
      
      * Use sphinx-build cmd
      
      * Revert and upload only html folder
      
      * Full test run
      
      * Set docs push condition to last two steps
      
      * Change branch to main
      
      * Update docs setup
      
      * Update make.bat configs
      
      * Turn off docs build for windows
      
      * OCAP compliance
      
      * Revert file structure
      
      * Just in case windows too
      
      * Fix sphinx doc folder path
      
      * Remove public/.doctrees
      Docs workflow (#557)
      Christine Kim authored
      * Docs workflow (#549)
      
      * Test docs build
      
      * Retry
      
      * Add brackets
      
      * Add conda install doxygen and doxygen command
      
      * Output some logging
      
      * Move doxygen command inside docs dir
      
      * Fix ls typo
      
      * Build docs for all linux
      
      * Add back cd docs
      
      * Test windows
      
      * Try python3.11
      
      * Conditional build docs
      
      * Build docs on 3.11
      
      * Test S3 connection
      
      * Setup Hugo
      
      * Add permissions
      
      * Add condition to build docs when merging
      
      * Add no-sign-request bool
      
      * Replace aws ls with sync
      
      * Try removing no-sign-request for sync
      
      * Add back no-sign-request with existing ale folder in s3
      
      * Try changing aws-region
      
      * Change region back to west-2 and test only ls
      
      * Upload to asc-docs instead of asc-public-docs
      
      * Test selective build and docs upload
      
      * Use sphinx-build cmd
      
      * Revert and upload only html folder
      
      * Full test run
      
      * Set docs push condition to last two steps
      
      * Change branch to main
      
      * Update docs setup
      
      * Update make.bat configs
      
      * Turn off docs build for windows
      
      * OCAP compliance
      
      * Revert file structure
      
      * Just in case windows too
      
      * Fix sphinx doc folder path
      
      * Remove public/.doctrees
    storage_rpc_server.py 5.80 KiB
    #!/usr/bin/env python
    
    import logging
    import os
    
    from redis_log_handler import RedisLogHandler
    from redis_rpc_server import RedisRPCServer
    from config import Config
    from db_connector import DbConnector
    
    
    class StorageRPCServer(RedisRPCServer):
    
        def __init__(self, host, port, db, rpcQueue):
            self.type = "storage"
            config = Config("/etc/vos_ts/vos_ts.conf")
            params = config.loadSection("file_catalog")
            self.dbConn = DbConnector(params["user"],
                                      params["password"],
                                      params["host"],
                                      params.getint("port"),
                                      params["db"],
                                      1,
                                      2)
            params = config.loadSection("logging")
            self.logger = logging.getLogger(__name__)
            logLevel = "logging." + params["log_level"]
            logFormat = params["log_format"]
            logFormatter = logging.Formatter(logFormat)
            self.logger.setLevel(eval(logLevel))
            redisLogHandler = RedisLogHandler()
            #logStreamHandler = logging.StreamHandler()
            #logStreamHandler.setFormatter(logFormatter)
            redisLogHandler.setFormatter(logFormatter)
            self.logger.addHandler(redisLogHandler)
            #self.logger.addHandler(logStreamHandler)
            super(StorageRPCServer, self).__init__(host, port, db, rpcQueue)
    
        def callback(self, requestBody):
            # 'requestType' attribute is mandatory
            if "requestType" not in requestBody:
                errorMsg = "Malformed request, missing parameters."
                response = { "responseType": "ERROR",
                             "errorCode": 1,
                             "errorMsg": errorMsg }
            elif requestBody["requestType"] == "STORAGE_ADD":
                storageType = requestBody["storageType"]
                storageBasePath = requestBody["basePath"]
                storageBaseUrl = requestBody["baseUrl"]
                storageHostname = requestBody["hostname"]
                if storageType != "portal":
                    if not os.path.exists(storageBasePath):
                        errorMsg = "Base path doesn't exist."
                        self.logger.error(errorMsg)
                        response = { "responseType": "ERROR",
                                     "errorCode": 3,
                                     "errorMsg": errorMsg }
                        return response
                try:
                    result = self.dbConn.insertStorage(storageType,
                                                       storageBasePath,
                                                       storageBaseUrl,
                                                       storageHostname)
                except Exception:
                    errorMsg = "Database error."
                    self.logger.exception(errorMsg)
                    response = { "responseType": "ERROR",
                                 "errorCode": 2,
                                 "errorMsg": errorMsg }
                    return response
                else:
                    if result:
                        response = { "responseType": "STORAGE_ADD_DONE" }
                    else:
                        errorMsg = "Storage point already exists."
                        self.logger.error(errorMsg)
                        response = { "responseType": "ERROR",
                                     "errorCode": 4,
                                     "errorMsg": errorMsg }
            elif requestBody["requestType"] == "STORAGE_DEL_REQ":
                try:
                    result = self.dbConn.getStorageList()
                except Exception:
                    errorMsg = "Database error."
                    self.logger.exception(errorMsg)
                    response = { "responseType": "ERROR",
                                 "errorCode": 2,
                                 "errorMsg": errorMsg }
                    return response
                else:
                    response = { "responseType": "STORAGE_DEL_ACK",
                                 "storageList": result }
            elif requestBody["requestType"] == "STORAGE_DEL_CON":
                storageId = requestBody["storageId"]
                try:
                    result = self.dbConn.deleteStorage(storageId)
                except Exception:
                    errorMsg = "Database error."
                    self.logger.exception(errorMsg)
                    response = { "responseType": "ERROR",
                                 "errorCode": 2,
                                 "errorMsg": errorMsg }
                    return response
                else:
                    if result:
                        response = { "responseType": "STORAGE_DEL_DONE" }
                    else:
                        errorMsg = "This storage location contains some VOSpace nodes. Please, move those nodes to another location."
                        self.logger.error(errorMsg)
                        response = { "responseType": "ERROR",
                                     "errorCode": 5,
                                     "errorMsg": errorMsg }
            elif requestBody["requestType"] == "STORAGE_LST":
                try:
                    result = self.dbConn.getStorageList()
                except Exception:
                    errorMsg = "Database error."
                    self.logger.exception(errorMsg)
                    response = { "responseType": "ERROR",
                                 "errorCode": 2,
                                 "errorMsg": errorMsg }
                    return response
                else:
                    response = { "responseType": "STORAGE_LST_DONE",
                                 "storageList": result }
    
            else:
                errorMsg = "Unkown request type."
                self.logger.error(errorMsg)
                response = { "responseType": "ERROR",
                             "errorCode": 6,
                             "errorMsg": errorMsg }
            return response
    
        def run(self):
            self.logger.info(f"Starting RPC server of type {self.type}...")
            super(StorageRPCServer, self).run()