Exemple #1
0
    def doConfig(self, defCfg =os.path.curdir + os.path.sep + 'cfg.rdf'):
        print('Welcome to the NCSA CILogon portal configuration utility, version 0.0.1')
        print('You may exit this at any time by hitting ctrl+C')
        configFile = self.my_input("Enter the file for an existing or new configuration", defaultValue=defCfg)
        # A simple return is supposed to accept the default, so if there is one, (or the user types in the default
        # use that
        if(configFile == None or configFile==''):
            configFile = defCfg

        if os.path.isfile(configFile):
        # load it
            rdfutil = RDFUtil(filename=configFile)
        else:
            rdfutil = RDFUtil()
        root = rdfutil.getRoot()
        # create the root node.
        if root is None:
            d = 'portal configuration'
            x = self.my_input('Enter a name for this configuration', defaultValue=d)
            if(x == None or x == ''):
                # In this case, the user took the default
                x = d
            rootSubject = URIRef(VV.CONFIG_ROOT_NAME + '#' + self.uriEncode(x))
            rdfutil.addTriple(rootSubject,  RDF.type, VV.ROOT_TYPE)
            root = rdfutil.getRoot()
            root.setValue(RDFS.label, x)
        # By this point, there is a store. What we need to do next is configure all the properties that
        # the portal itself needs, such as the callback url, name, etc.
        pp = PortalProperties()

        print('\nNext we need to know where the service host key and cert are located')
        rdfutil.addTriple(root.getSubject(), VV.HAS_SSL_CONFIGURATION, VV.uriRef())
        sslConfig = root.getThing(VV.HAS_SSL_CONFIGURATION)
        sslConfig.addType(VV.SSL_CONFIGURATIION)
        self.setValue(sslConfig, VV.SSL_HOST_KEY, 'host key file name', pp.hostKey())
        self.setValue(sslConfig, VV.SSL_HOST_CERT, 'host cred file name', pp.hostCert())

        print('\nNow come the portal parameters')
        rdfutil.addTriple(root.getSubject(), VV.HAS_PORTAL_PARAMETERS, VV.uriRef())
        portalParameters = root.getThing(VV.HAS_PORTAL_PARAMETERS)
        portalParameters.addType(VV.PORTAL_PARAMETERS)
        self.setValue(portalParameters, VV.PORTAL_CALLBACK_URI, 'the callback url', pp.callbackUrl())
        self.setValue(portalParameters, VV.PORTAL_SUCCESS_URI, 'the success url', pp.successUrl())
        self.setValue(portalParameters, VV.PORTAL_FAILURE_URI, 'the failure url', pp.failureUrl())
        self.setValue(portalParameters, VV.PORTAL_NAME, 'the name of this portal', pp.portalName())
        self.setValue(portalParameters, VV.PORTAL_TEMPORARY_DIRECTORY, 'the path to the temporary directory', pp.temporaryDirectory())
        self.setValue(portalParameters, VV.PORTAL_CERT_REQ_CONFIGURATION, 'the path to the cert request configuration file', pp.certRequestConfiguration())

        return root, rdfutil, configFile
Exemple #2
0
    def doConfig(self):
        (root, rdfutil, configFile) = super(configure, self).doConfig()
        if root.hasValue(VV.HAS_STORE):
            # get the store
            store = root.getThing(VV.HAS_STORE)
        else:
            choice = self.select("select the type of store", ["Memory", "File"])
            rdfutil.addTriple(root.getSubject(), VV.HAS_STORE, VV.uriRef())
            store = root.getThing(VV.HAS_STORE)
            if choice == 0:
                # do memory
                store.addType(VV.MEMORY_STORE_TYPE)
            elif choice == 1:
                # do file
                store.addType(VV.FILE_STORE_TYPE)
                store.setValue(VV.FILE_DATA_PATH, self.my_input("set the path for store data"))
                store.setValue(VV.FILE_INDEX_PATH, self.my_input("set the path for the store index"))

        rdfutil.save(configFile)
        print("done!")
Exemple #3
0
    def doConfig(self):
        (root, rdfutil, configFile) = super(configure, self).doConfig()
        if(root.hasValue(VV.HAS_STORE)):
            # get the store
            store = root.getThing(VV.HAS_STORE)
        else:
            choice = self.select('select the type of store', ['Memory', 'File'])
            rdfutil.addTriple(root.getSubject(), VV.HAS_STORE, VV.uriRef())
            store = root.getThing(VV.HAS_STORE)
            if(choice == 0):
                # do memory
                store.addType(VV.MEMORY_STORE_TYPE)
            elif (choice == 1):
                # do file
                store.addType(VV.FILE_STORE_TYPE)
                store.setValue(VV.FILE_DATA_PATH, self.my_input("set the path for store data"))
                store.setValue(VV.FILE_INDEX_PATH, self.my_input("set the path for the store index"))

        rdfutil.save(configFile)
        print('done!')
Exemple #4
0
    def doConfig(self, defCfg=os.path.curdir + os.path.sep + 'cfg.rdf'):
        print(
            'Welcome to the NCSA CILogon portal configuration utility, version 0.0.1'
        )
        print('You may exit this at any time by hitting ctrl+C')
        configFile = self.my_input(
            "Enter the file for an existing or new configuration",
            defaultValue=defCfg)
        # A simple return is supposed to accept the default, so if there is one, (or the user types in the default
        # use that
        if (configFile == None or configFile == ''):
            configFile = defCfg

        if os.path.isfile(configFile):
            # load it
            rdfutil = RDFUtil(filename=configFile)
        else:
            rdfutil = RDFUtil()
        root = rdfutil.getRoot()
        # create the root node.
        if root is None:
            d = 'portal configuration'
            x = self.my_input('Enter a name for this configuration',
                              defaultValue=d)
            if (x == None or x == ''):
                # In this case, the user took the default
                x = d
            rootSubject = URIRef(VV.CONFIG_ROOT_NAME + '#' + self.uriEncode(x))
            rdfutil.addTriple(rootSubject, RDF.type, VV.ROOT_TYPE)
            root = rdfutil.getRoot()
            root.setValue(RDFS.label, x)
        # By this point, there is a store. What we need to do next is configure all the properties that
        # the portal itself needs, such as the callback url, name, etc.
        pp = PortalProperties()

        print(
            '\nNext we need to know where the service host key and cert are located'
        )
        rdfutil.addTriple(root.getSubject(), VV.HAS_SSL_CONFIGURATION,
                          VV.uriRef())
        sslConfig = root.getThing(VV.HAS_SSL_CONFIGURATION)
        sslConfig.addType(VV.SSL_CONFIGURATIION)
        self.setValue(sslConfig, VV.SSL_HOST_KEY, 'host key file name',
                      pp.hostKey())
        self.setValue(sslConfig, VV.SSL_HOST_CERT, 'host cred file name',
                      pp.hostCert())

        print('\nNow come the portal parameters')
        rdfutil.addTriple(root.getSubject(), VV.HAS_PORTAL_PARAMETERS,
                          VV.uriRef())
        portalParameters = root.getThing(VV.HAS_PORTAL_PARAMETERS)
        portalParameters.addType(VV.PORTAL_PARAMETERS)
        self.setValue(portalParameters, VV.PORTAL_CALLBACK_URI,
                      'the callback url', pp.callbackUrl())
        self.setValue(portalParameters, VV.PORTAL_SUCCESS_URI,
                      'the success url', pp.successUrl())
        self.setValue(portalParameters, VV.PORTAL_FAILURE_URI,
                      'the failure url', pp.failureUrl())
        self.setValue(portalParameters, VV.PORTAL_NAME,
                      'the name of this portal', pp.portalName())
        self.setValue(portalParameters, VV.PORTAL_TEMPORARY_DIRECTORY,
                      'the path to the temporary directory',
                      pp.temporaryDirectory())
        self.setValue(portalParameters, VV.PORTAL_CERT_REQ_CONFIGURATION,
                      'the path to the cert request configuration file',
                      pp.certRequestConfiguration())

        return root, rdfutil, configFile
Exemple #5
0
      def doConfig(self):
           (root, rdfutil, configFile) = super(PGConfigure, self).doConfig()
           if(root.hasValue(VV.HAS_STORE)):
                # get the store
                store = root.getThing(VV.HAS_STORE)
           else:
                # else create it.
                rdfutil.addTriple(root.getSubject(), VV.HAS_STORE, VV.uriRef())
                store = root.getThing(VV.HAS_STORE)

           store.addType(VV.POSTGRES_STORE_TYPE)
           rdfutil.addTriple(store.getSubject(), VV.HAS_DATABASE, VV.uriRef())
           rdfutil.getGraph().commit()
           dbp = DatabaseProperties()
           
           # We'll fill in the database properties as we go so we can use it to initialize the table
           # create the database configuration

           print('\nSetup the Postgres database\n')
           database = store.getThing(VV.HAS_DATABASE)
           self.setValue(database, VV.SQL_DATABASE_NAME, 'database name', dbp.databaseName())
           self.setValue(database, VV.SQL_DATABASE_SCHEMA, 'database schema', dbp.schema())
           if(database.hasValue(VV.SQL_DATABASE_NAME)):
               dbp.databaseName(database.getString(VV.SQL_DATABASE_NAME))
           if(database.hasValue(VV.SQL_DATABASE_SCHEMA)):
               dbp.schema(database.getString(VV.SQL_DATABASE_SCHEMA))

           # create the transaction table cfg
           print('\nNow we need to set up the transaction table')
           rdfutil.addTriple(database.getSubject(), VV.HAS_TRANSACTION_TABLE, VV.uriRef())
           tt = database.getThing(VV.HAS_TRANSACTION_TABLE)
           tt.addType(VV.TRANSACTION_TABLE_TYPE)
           self.setValue(tt, VV.SQL_TABLE_PREFIX, 'table name prefix', dbp.tablenamePrefix())
           if(tt.hasValue(VV.SQL_TABLE_NAME)):
               dbp.tablename(tt.getString(VV.SQL_TABLE_NAME))
           self.setValue(tt, VV.SQL_TABLE_NAME, 'table name', dbp.TABLENAME) # Note this is the raw name, not the qualified one
           if(tt.hasValue(VV.SQL_TABLE_PREFIX)):
               dbp.tablenamePrefix(tt.getString(VV.SQL_TABLE_PREFIX))

           # and the connection information cfg
           print('\nNow we need to set up the connection information for the user account')
           rdfutil.addTriple(store.getSubject(), VV.HAS_CONNECTION, VV.uriRef())
           conn = store.getThing(VV.HAS_CONNECTION)
           conn.addType(VV.SQL_CONNECTION_TYPE)
           self.setValue(conn, VV.CONNECTION_HOST, 'host name', dbp.host())
           if(conn.hasValue(VV.CONNECTION_HOST)):
               dbp.host(conn.getString(VV.CONNECTION_HOST))
           self.setValue(conn, VV.CONNECTION_USERNAME, 'user name', dbp.username())
           if(conn.hasValue(VV.CONNECTION_USERNAME)):
               dbp.username(conn.getString(VV.CONNECTION_USERNAME))
           self.setValue(conn, VV.CONNECTION_PASSWORD, 'password', dbp.password())
           if(conn.hasValue(VV.CONNECTION_PASSWORD)):
               dbp.password(conn.getString(VV.CONNECTION_PASSWORD))
           self.setValue(conn, VV.CONNECTION_PORT, 'port', dbp.port())
           if(conn.hasValue(VV.CONNECTION_PORT)):
               dbp.port(conn.getString(VV.CONNECTION_PORT))

           print('\nNow we need to set up the connection information for the adminstrator account')
           rdfutil.addTriple(store.getSubject(), VV.HAS_ADMIN_CONNECTION, VV.uriRef())
           adminConn = store.getThing(VV.HAS_ADMIN_CONNECTION)
           adminConn.addType(VV.SQL_ADMIN_CONNECTION_TYPE)
           self.setValue(adminConn, VV.CONNECTION_ADMIN_HOST, 'host name', dbp.adminHost())
           if(adminConn.hasValue(VV.CONNECTION_ADMIN_HOST)):
               dbp.adminHost(adminConn.getString(VV.CONNECTION_ADMIN_HOST))
           self.setValue(adminConn, VV.CONNECTION_ADMIN_USERNAME, 'user name', dbp.adminUsername())
           if(adminConn.hasValue(VV.CONNECTION_ADMIN_USERNAME)):
               dbp.adminUsername(adminConn.getString(VV.CONNECTION_ADMIN_USERNAME))
           self.setValue(adminConn, VV.CONNECTION_ADMIN_PASSWORD, 'password', dbp.adminPassword())
           if(adminConn.hasValue(VV.CONNECTION_ADMIN_PASSWORD)):
               dbp.adminPassword(adminConn.getString(VV.CONNECTION_ADMIN_PASSWORD))
           self.setValue(adminConn, VV.CONNECTION_ADMIN_PORT, 'port', dbp.adminPort())
           if(adminConn.hasValue(VV.CONNECTION_ADMIN_PORT)):
               dbp.adminPort(adminConn.getString(VV.CONNECTION_ADMIN_PORT))

           initChoice = self.select('Do you want to initialize the store now?', ['No', 'Yes'])
           if(initChoice == 1):
               pgadmin = PGAdmin(dbp)
               pgadmin.destroy(); # Remove it if it is there
               pgadmin.initialize(); #create it.
               print('\nok')

               
           rdfutil.save(configFile)
           print('done!')