Example #1
0
    def __init__(self, app, config, mount):
        DatabaseRESTApi.__init__(self, app, config, mount)

        self.formats = [ ('application/json', JSONFormat()) ]

        status, serverdn = getstatusoutput('openssl x509 -noout -subject -in %s | cut -f2- -d\ ' % config.serverhostcert)
        if status is not 0:
            raise ExecutionError("Internal issue when retrieving crabserver service DN.")

        extconfig = Utils.ConfigCache(centralconfig=Utils.getCentralConfig(extconfigurl=config.extconfigurl, mode=config.mode),
                                      cachetime=mktime(gmtime()))

        #Global initialization of Data objects. Parameters coming from the config should go here
        DataUserWorkflow.globalinit(config)
        DataWorkflow.globalinit(dbapi=self, phedexargs={'endpoint': config.phedexurl},\
                                credpath=config.credpath, centralcfg=extconfig, config=config)
        DataFileMetadata.globalinit(dbapi=self, config=config)
        RESTTask.globalinit(centralcfg=extconfig)
        Utils.globalinit(config.serverhostkey, config.serverhostcert, serverdn, config.credpath)

        ## TODO need a check to verify the format depending on the resource
        ##      the RESTFileMetadata has the specifc requirement of getting xml reports
        self._add( {'workflow': RESTUserWorkflow(app, self, config, mount, extconfig),
                    'campaign': RESTCampaign(app, self, config, mount),
                    'info': RESTServerInfo(app, self, config, mount, serverdn, extconfig),
                    'filemetadata': RESTFileMetadata(app, self, config, mount),
                    'workflowdb': RESTWorkerWorkflow(app, self, config, mount),
                    'task': RESTTask(app, self, config, mount),
                   } )

        self._initLogger( getattr(config, 'loggingFile', None), getattr(config, 'loggingLevel', None) )
Example #2
0
 def __init__(self, app, config, mount):
   """
   :arg app: reference to application object; passed to all entities.
   :arg config: reference to configuration; passed to all entities.
   :arg str mount: API URL mount point; passed to all entities."""
   DatabaseRESTApi.__init__(self, app, config, mount)
   self._add({ "whoami":                 WhoAmI(app, self, config, mount),
               "ldapsync":               LdapSync(app, self, config, mount),
               "rebusfetch":             RebusFetch(app, self, config, mount),
               "roles":                  Roles(app, self, config, mount),
               "groups":                 Groups(app, self, config, mount),
               "people":                 People(app, self, config, mount),
               "sites":                  Sites(app, self, config, mount),
               "site-names":             SiteNames(app, self, config, mount),
               "site-resources":         SiteResources(app, self, config, mount),
               "site-associations":      SiteAssociations(app, self, config, mount),
               "resource-pledges":       Pledges(app, self, config, mount),
               "pinned-software":        Software(app, self, config, mount),
               "site-responsibilities":  UserSites(app, self, config, mount),
               "group-responsibilities": UserGroups(app, self, config, mount),
               "data-responsibilities":  UserPNNs(app, self, config, mount),
               "data-processing":        Processing(app, self, config, mount),
               "federations":            Federations(app, self, config, mount),
               "federations-sites":      FederationsSites(app, self, config, mount),
               "federations-pledges":    FederationsPledges(app, self, config, mount),
               "esp-credit":             ESPCredit(app, self, config, mount)})
Example #3
0
    def __init__(self, app, config, mount):
        DatabaseRESTApi.__init__(self, app, config, mount)

        self.formats = [ ('application/json', JSONFormat()) ]

        status, serverdn = getstatusoutput('openssl x509 -noout -subject -in %s | cut -f2- -d\ ' % config.serverhostcert)
        if status is not 0:
            raise ExecutionError("Internal issue when retrieving crabserver service DN.")

        extconfig = Utils.ConfigCache(centralconfig=Utils.getCentralConfig(extconfigurl=config.extconfigurl, mode=config.mode),
                                      cachetime=mktime(gmtime()))

        #Global initialization of Data objects. Parameters coming from the config should go here
        DataUserWorkflow.globalinit(config)
        DataWorkflow.globalinit(dbapi=self, phedexargs={'endpoint': config.phedexurl},\
                                credpath=config.credpath, centralcfg=extconfig, config=config)
        DataFileMetadata.globalinit(dbapi=self, config=config)
        RESTTask.globalinit(centralcfg=extconfig)
        Utils.globalinit(config.serverhostkey, config.serverhostcert, serverdn, config.credpath)

        ## TODO need a check to verify the format depending on the resource
        ##      the RESTFileMetadata has the specifc requirement of getting xml reports
        self._add( {'workflow': RESTUserWorkflow(app, self, config, mount, extconfig),
                    'info': RESTServerInfo(app, self, config, mount, serverdn, extconfig),
                    'filemetadata': RESTFileMetadata(app, self, config, mount),
                    'workflowdb': RESTWorkerWorkflow(app, self, config, mount),
                    'task': RESTTask(app, self, config, mount),
                    'filetransfers': RESTFileTransfers(app, self, config, mount),
                    'fileusertransfers': RESTFileUserTransfers(app, self, config, mount),
                   })

        self._initLogger( getattr(config, 'loggingFile', None), getattr(config, 'loggingLevel', None) )
Example #4
0
 def __init__(self, app, config, mount):
     """
 :arg app: reference to application object; passed to all entities.
 :arg config: reference to configuration; passed to all entities.
 :arg str mount: API URL mount point; passed to all entities."""
     DatabaseRESTApi.__init__(self, app, config, mount)
     self._add(
         {
             "whoami": WhoAmI(app, self, config, mount),
             "ldapsync": LdapSync(app, self, config, mount),
             "rebusfetch": RebusFetch(app, self, config, mount),
             "roles": Roles(app, self, config, mount),
             "groups": Groups(app, self, config, mount),
             "people": People(app, self, config, mount),
             "sites": Sites(app, self, config, mount),
             "site-names": SiteNames(app, self, config, mount),
             "site-resources": SiteResources(app, self, config, mount),
             "site-associations": SiteAssociations(app, self, config, mount),
             "resource-pledges": Pledges(app, self, config, mount),
             "pinned-software": Software(app, self, config, mount),
             "site-responsibilities": UserSites(app, self, config, mount),
             "group-responsibilities": UserGroups(app, self, config, mount),
             "data-responsibilities": UserPNNs(app, self, config, mount),
             "data-processing": Processing(app, self, config, mount),
             "federations": Federations(app, self, config, mount),
             "federations-sites": FederationsSites(app, self, config, mount),
             "federations-pledges": FederationsPledges(app, self, config, mount),
             "esp-credit": ESPCredit(app, self, config, mount),
         }
     )
Example #5
0
 def __init__(self, app, config, mount):
   """
   :arg app: reference to application object; passed to all entities.
   :arg config: reference to configuration; passed to all entities.
   :arg str mount: API URL mount point; passed to all entities."""
   DatabaseRESTApi.__init__(self, app, config, mount)
   self._add({ "hello": Hello(app, self, config, mount) })
Example #6
0
    def __init__(self, app, config, mount):
        DatabaseRESTApi.__init__(self, app, config, mount)

        self.formats = [('application/json', JSONFormat())]

        status, serverdn = getstatusoutput(
            'openssl x509 -noout -subject -in %s | cut -f2- -d\ ' %
            config.serverhostcert)
        if status is not 0:
            raise ExecutionError(
                "Internal issue when retrieving crabserver service DN.")

        hbuf = StringIO.StringIO()
        bbuf = StringIO.StringIO()

        curl = pycurl.Curl()
        curl.setopt(pycurl.URL, config.extconfigurl)
        curl.setopt(pycurl.WRITEFUNCTION, bbuf.write)
        curl.setopt(pycurl.HEADERFUNCTION, hbuf.write)
        curl.setopt(pycurl.FOLLOWLOCATION, 1)
        curl.perform()
        curl.close()

        header = ResponseHeader(hbuf.getvalue())
        if header.status < 200 or header.status >= 300:
            cherrypy.log("Problem %d reading from %s." %
                         (config.extconfigurl, header.status))
            raise ExecutionError(
                "Internal issue when retrieving external confifuration")
        extconfig = json.decode(bbuf.getvalue())

        #Global initialization of Data objects. Parameters coming from the config should go here
        DataUserWorkflow.globalinit(config.workflowManager)
        DataWorkflow.globalinit(dbapi=self, phedexargs={'endpoint': config.phedexurl}, dbsurl=config.dbsurl,\
                                        credpath=config.credpath, transformation=config.transformation)
        DataFileMetadata.globalinit(dbapi=self)
        Utils.globalinit(config.serverhostkey, config.serverhostcert, serverdn,
                         config.credpath)

        ## TODO need a check to verify the format depending on the resource
        ##      the RESTFileMetadata has the specifc requirement of getting xml reports
        self._add({
            'workflow':
            RESTUserWorkflow(app, self, config, mount),
            'campaign':
            RESTCampaign(app, self, config, mount),
            'info':
            RESTServerInfo(app, self, config, mount, serverdn,
                           extconfig.get('delegate-dn', [])),
            'filemetadata':
            RESTFileMetadata(app, self, config, mount),
        })

        self._initLogger(getattr(config, 'loggingFile', None),
                         getattr(config, 'loggingLevel', None))
Example #7
0
 def __init__(self, app, config, mount):
     """
 :arg app: reference to application object; passed to all entities.
 :arg config: reference to configuration; passed to all entities.
 :arg str mount: API URL mount point; passed to all entities."""
     DatabaseRESTApi.__init__(self, app, config, mount)
     self._add({
         "link-events": LinkEvents(app, self, config, mount),
         "link-stats": LinkStats(app, self, config, mount),
         "dest-stats": DestStats(app, self, config, mount),
         "block-latency": BlockLatency(app, self, config, mount)
     })
Example #8
0
 def __init__(self, app, config, mount):
     """
 :arg app: reference to application object; passed to all entities.
 :arg config: reference to configuration; passed to all entities.
 :arg str mount: API URL mount point; passed to all entities."""
     DatabaseRESTApi.__init__(self, app, config, mount)
     self._add(
         {
             "link-events": LinkEvents(app, self, config, mount),
             "link-stats": LinkStats(app, self, config, mount),
             "dest-stats": DestStats(app, self, config, mount),
             "block-latency": BlockLatency(app, self, config, mount),
         }
     )
Example #9
0
  def __init__(self, app, config, mount):
    """
    :arg app: reference to application object; passed to all entities.
    :arg config: reference to configuration; passed to all entities.
    :arg str mount: API URL mount point; passed to all entities."""

    DatabaseRESTApi.__init__(self, app, config, mount)
    # Makes raw format as default
    self.formats.insert(0, ('application/raw', RawFormat()))
    self._add({ "hello": Hello(app, self, config, mount),
                "runid": RunId(app, self, config, mount),
                "run":   Run(app, self, config, mount),
                "express_config": ExpressConfig(app, self, config, mount),
                "firstconditionsaferun": FirstConditionSafeRun(app, self, config, mount)
                })
Example #10
0
  def __init__(self, app, config, mount):
    """
    :arg app: reference to application object; passed to all entities.
    :arg config: reference to configuration; passed to all entities.
    :arg str mount: API URL mount point; passed to all entities."""

    DatabaseRESTApi.__init__(self, app, config, mount)
    # Makes raw format as default
    self.formats.insert(0, ('application/raw', RawFormat()))
    self._add({ "hello": Hello(app, self, config, mount),
                "express_config": ExpressConfig(app, self, config, mount),
                "reco_config": RecoConfig(app, self, config, mount),
                "run_config": RunConfig(app, self, config, mount),
                "firstconditionsaferun": FirstConditionSafeRun(app, self, config, mount),
                "run_stream_done": RunStreamDone(app, self, config, mount),
                "run_dataset_done": RunDatasetDone(app,self, config, mount),
                "dataset_locked": DatasetLocked(app, self, config, mount),
                "promptreco_status": PromptRecoStatus(app, self, config, mount)
                })
Example #11
0
    def __init__(self, app, config, mount):
        DatabaseRESTApi.__init__(self, app, config, mount)

        self.formats = [ ('application/json', JSONFormat()) ]

        status, serverdn = getstatusoutput('openssl x509 -noout -subject -in %s | cut -f2- -d\ ' % config.serverhostcert)
        if status is not 0:
            raise ExecutionError("Internal issue when retrieving crabserver service DN.")

        hbuf = StringIO.StringIO()
        bbuf = StringIO.StringIO()

        curl = pycurl.Curl()
        curl.setopt(pycurl.URL, config.extconfigurl)
        curl.setopt(pycurl.WRITEFUNCTION, bbuf.write)
        curl.setopt(pycurl.HEADERFUNCTION, hbuf.write)
        curl.setopt(pycurl.FOLLOWLOCATION, 1)
        curl.perform()
        curl.close()

        header = ResponseHeader(hbuf.getvalue())
        if header.status < 200 or header.status >= 300:
            cherrypy.log("Problem %d reading from %s." %(config.extconfigurl, header.status))
            raise ExecutionError("Internal issue when retrieving external confifuration")
        extconfig = json.decode(bbuf.getvalue())

        #Global initialization of Data objects. Parameters coming from the config should go here
        DataUserWorkflow.globalinit(config.workflowManager)
        DataWorkflow.globalinit(dbapi=self, phedexargs={'endpoint': config.phedexurl}, dbsurl=config.dbsurl,\
                                        credpath=config.credpath, transformation=config.transformation)
        DataFileMetadata.globalinit(dbapi=self)
        Utils.globalinit(config.serverhostkey, config.serverhostcert, serverdn, config.credpath)

        ## TODO need a check to verify the format depending on the resource
        ##      the RESTFileMetadata has the specifc requirement of getting xml reports
        self._add( {'workflow': RESTUserWorkflow(app, self, config, mount),
                    'campaign': RESTCampaign(app, self, config, mount),
                    'info': RESTServerInfo(app, self, config, mount, serverdn, extconfig.get('delegate-dn', [])),
                    'filemetadata': RESTFileMetadata(app, self, config, mount),
                   } )

        self._initLogger( getattr(config, 'loggingFile', None), getattr(config, 'loggingLevel', None) )
Example #12
0
File: Data.py Project: lat/sitedb
 def __init__(self, app, config, mount):
   """
   :arg app: reference to application object; passed to all entities.
   :arg config: reference to configuration; passed to all entities.
   :arg str mount: API URL mount point; passed to all entities."""
   DatabaseRESTApi.__init__(self, app, config, mount)
   self._add({ "whoami":                 WhoAmI(app, self, config, mount),
               "hnsync":                 HNSync(app, self, config, mount),
               "mycert":                 Certificate(app, self, config, mount),
               "roles":                  Roles(app, self, config, mount),
               "groups":                 Groups(app, self, config, mount),
               "people":                 People(app, self, config, mount),
               "sites":                  Sites(app, self, config, mount),
               "site-names":             SiteNames(app, self, config, mount),
               "site-resources":         SiteResources(app, self, config, mount),
               "site-associations":      SiteAssociations(app, self, config, mount),
               "resource-pledges":       Pledges(app, self, config, mount),
               "pinned-software":        Software(app, self, config, mount),
               "site-responsibilities":  UserSites(app, self, config, mount),
               "group-responsibilities": UserGroups(app, self, config, mount) })
Example #13
0
    def __init__(self, app, config, mount):
        """
    :arg app: reference to application object; passed to all entities.
    :arg config: reference to configuration; passed to all entities.
    :arg str mount: API URL mount point; passed to all entities."""

        DatabaseRESTApi.__init__(self, app, config, mount)
        # Makes raw format as default
        self.formats.insert(0, ('application/raw', RawFormat()))
        self._add({
            "hello":
            Hello(app, self, config, mount),
            "runid":
            RunId(app, self, config, mount),
            "run":
            Run(app, self, config, mount),
            "express_config":
            ExpressConfig(app, self, config, mount),
            "firstconditionsaferun":
            FirstConditionSafeRun(app, self, config, mount)
        })
Example #14
0
from WMCore.REST.Server import RESTFrontPage
from WMCore.REST.Server import MiniRESTApi
from WMCore.REST.Server import RESTApi
from WMCore.REST.Server import DBConnectionPool
from WMCore.REST.Server import DatabaseRESTApi
from WMCore.REST.Server import RESTEntity
import os, threading

srcfile = os.path.abspath(__file__).rsplit("/", 1)[-1].split(".")[0]
dbspec = {}


class FakeApp:
    appname = "app"


class FakeConf:
    db = srcfile + ".dbspec"


RESTFrontPage(None, None, "/", "/dev/null", {})
MiniRESTApi(FakeApp(), None, "/")
RESTApi(FakeApp(), None, "/")
DBConnectionPool("x", {})
if threading.current_thread().name == "MainThread":
    DatabaseRESTApi(FakeApp(), FakeConf(), "/")
RESTEntity(FakeApp(), None, None, "/")