예제 #1
0
파일: runtimes.py 프로젝트: AsherBond/cato
    def __init__(self):

        self.logger = catolog.get_logger("Runtimes")

        # initialize the runtime array dictionary
        self.data = {}

        # for the new variable syntax feature
        self.obj_data = {}
예제 #2
0
파일: cskui.py 프로젝트: AsherBond/cato
def main():
    # CATOPROCESS STARTUP

    dbglvl = 20
    if "csk_ui_debug" in catoconfig.CONFIG:
        try:
            dbglvl = int(catoconfig.CONFIG["csk_ui_debug"])
        except:
            raise Exception("csk_ui_debug setting in cato.conf must be an integer between 0-50.")
    catolog.DEBUG = dbglvl

    # this is a service, which has a db connection.
    # but we're not gonna use that for gui calls - we'll make our own when needed.
    server = catoprocess.CatoService(app_name)
    server.startup()

    # now that the service is set up, we'll know what the logfile name is.
    # so reget the logger
    logger = catolog.get_logger(app_name)
    catolog.set_debug(dbglvl)

    logger.info("Velocity UI - Version %s" % catoconfig.VERSION)
    logger.info("DEBUG set to %d..." % dbglvl)

    # WEB.PY STARTUP
    if "csk_ui_port" in catoconfig.CONFIG:
        port = catoconfig.CONFIG["csk_ui_port"]
        sys.argv.append(port)

    # enable ssl?
    if catocommon.is_true(catoconfig.CONFIG.get("csk_ui_use_ssl")):
        logger.info("Using SSL/TLS...")
        sslcert = catoconfig.CONFIG.get("csk_ui_ssl_cert", os.path.join(catoconfig.CONFDIR, "cato.crt"))
        sslkey = catoconfig.CONFIG.get("csk_ui_ssl_key", os.path.join(catoconfig.CONFDIR, "cato.key"))
        try:
            with open(sslcert):
                pass
            logger.debug("SSL Certificate [%s]" % sslcert)
            CherryPyWSGIServer.ssl_certificate = sslcert
        except:
            raise Exception("SSL Certificate not found at [%s]" % sslcert)
        try:
            with open(sslkey):
                pass
            logger.debug("SSL Key [%s]" % sslkey)
            CherryPyWSGIServer.ssl_private_key = sslkey
        except:
            raise Exception("SSL Key not found at [%s]" % sslcert)
    else:
        logger.info("Using standard HTTP. (Set csk_ui_use_ssl to 'true' in cato.conf to enable SSL/TLS.)")

    app.add_processor(auth_app_processor)
    app.notfound = notfound

    app.run()
예제 #3
0
    def __init__(self, process_name):
        self.host = os.uname()[1]
        self.platform = os.uname()[0]
        self.user = pwd.getpwuid(os.getuid())[0]
        self.host_domain = self.user + '@' + os.uname()[1]
        self.my_pid = os.getpid()
        self.process_name = process_name
        self.home = catoconfig.BASEPATH
        self.tmpdir = catoconfig.CONFIG["tmpdir"]

        # tell catoconfig what the LOGFILE name is, then get a logger
        # if logging has already been set up this won't do anything
        # but if it's not yet, this will set the basic config
        logging.basicConfig(level=logging.DEBUG)

        catolog.set_logfile(os.path.join(catolog.LOGPATH, self.process_name.lower() + ".log"))
        self.logger = catolog.get_logger(process_name)
예제 #4
0
파일: aws.py 프로젝트: AsherBond/cato
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import urllib2
import time
import hmac
import hashlib
import base64
from catocloud import cloud
from catocommon import catocommon

from catolog import catolog

logger = catolog.get_logger(__name__)
# logger.info("foo")


class awsInterface(object):
    def GetCloudObjectsAsXML(self, account_id, cloud_id, cloud_object_type, additional_args={}):
        try:
            sXML = ""

            ca = cloud.CloudAccount()
            ca.FromID(account_id)
            if ca.ID is None:
                msg = "Failed to get Cloud Account details for Cloud Account ID [" + account_id + "]."
                logger.error(msg)
                return None, msg
예제 #5
0
def _inject(templateobj):
    """
    We need to wrap each pages html with a middle 'wrapper' before inserting it into
    the main base page.
    
    So, we take the already rendered html, and do a final replacement on it.
    """
    templateobj["__body__"] = templateobj["__body__"].replace("<!--##FOOTER##-->", uiGlobals.static_content["automatefooter"])
    templateobj["__body__"] = templateobj["__body__"].replace("<!--##AFTER##-->", uiGlobals.static_content["automateafter"])
    return templateobj


# THE MAIN STUFF

logger = catolog.get_logger("csk_admin_ui")

uiGlobals.urls += (
    '/automate', 'cskadminuicore.cskadminuicore.home',
    '/automate/home', 'home',
    '/automate/importObject', 'importObject',
    '/automate/cloudEdit', 'cloudEdit',
    '/automate/cloudAccountEdit', 'cloudAccountEdit',
    '/automate/cloudDiscovery', 'cloudDiscovery',
    '/automate/taskEdit', 'taskEdit',
    '/automate/taskView', 'taskView',
    '/automate/taskPrint', 'taskPrint',
    '/automate/taskRunLog', 'taskRunLog',
    '/automate/taskActivityLog', 'taskActivityLog',
    '/automate/taskManage', 'taskManage',
    '/automate/systemStatus', 'systemStatus',
예제 #6
0
파일: cskui.py 프로젝트: AsherBond/cato
import sys
import json
import web
import shelve
from web.wsgiserver import CherryPyWSGIServer

if "CSK_HOME" not in os.environ:
    raise Exception("CSK_HOME environment variable not set.")
sys.path.insert(0, os.path.join(os.environ["CSK_HOME"], "cato", "lib"))
sys.path.insert(0, os.path.join(os.environ["CSK_HOME"], "maestro", "lib"))
sys.path.insert(0, os.path.join(os.environ["CSK_HOME"], "legato", "lib"))

from catolog import catolog

app_name = "csk_ui"
logger = catolog.get_logger(app_name)

from catoconfig import catoconfig
from catocommon import catocommon, catoprocess
from catolicense import catolicense
from catoui import uiGlobals, uiCommon
from catoerrors import InfoException, SessionError

web_root = os.path.join(os.environ["CSK_HOME"], "cato", "ui", "cskui")
os.chdir(web_root)

"""
 wmHandler is the default handler for any urls not defined in the urls mapping below.
 (web.py required explicit url mapping)

 web.py will instantiate this class, and invoke either the GET or POST method.
예제 #7
0
def main():
    # CATOPROCESS STARTUP

    dbglvl = 20
    if "admin_ui_debug" in catoconfig.CONFIG:
        try:
            dbglvl = int(catoconfig.CONFIG["admin_ui_debug"])
        except:
            raise Exception("admin_ui_debug setting in cato.conf must be an integer between 0-50.")
    catolog.DEBUG = dbglvl

    c_dbglvl = 20
    if "admin_ui_client_debug" in catoconfig.CONFIG:
        try:
            c_dbglvl = int(catoconfig.CONFIG["admin_ui_client_debug"])
        except:
            raise Exception("admin_ui_client_debug setting in cato.conf must be an integer between 0-50.")
    catolog.CLIENTDEBUG = c_dbglvl

    # this is a service, which has a db connection.
    # but we're not gonna use that for gui calls - we'll make our own when needed.
    server = catoprocess.CatoService(app_name)
    server.startup()

    # now that the service is set up, we'll know what the logfile name is.
    # so reget the logger
    logger = catolog.get_logger(app_name)
    catolog.set_debug(dbglvl)

    logger.info("Cato UI - Version %s" % catoconfig.VERSION)
    logger.info("DEBUG set to %d..." % dbglvl)
    logger.info("CLIENTDEBUG set to %d..." % c_dbglvl)

    # we need to build some static html here...
    # caching in the session is a bad idea, and this stuff very very rarely changes.
    # so, when the service is started it will update the files, and the ui
    # will simply pull in the files when requested.
    _build_ui_cache()

    # WEB.PY STARTUP
    if "admin_ui_port" in catoconfig.CONFIG:
        port = catoconfig.CONFIG["admin_ui_port"]
        sys.argv.append(port)

    # enable ssl?
    if catocommon.is_true(catoconfig.CONFIG.get("admin_ui_use_ssl")):
        logger.info("Using SSL/TLS...")
        sslcert = catoconfig.CONFIG.get("admin_ui_ssl_cert", os.path.join(catoconfig.CONFDIR, "cato.crt"))
        sslkey = catoconfig.CONFIG.get("admin_ui_ssl_key", os.path.join(catoconfig.CONFDIR, "cato.key"))
        try:
            with open(sslcert):
                pass
            logger.debug("SSL Certificate [%s]" % sslcert)
            CherryPyWSGIServer.ssl_certificate = sslcert
        except:
            raise Exception("SSL Certificate not found at [%s]" % sslcert)
        try:
            with open(sslkey):
                pass
            logger.debug("SSL Key [%s]" % sslkey)
            CherryPyWSGIServer.ssl_private_key = sslkey
        except:
            raise Exception("SSL Key not found at [%s]" % sslcert)
    else:
        logger.info("Using standard HTTP. (Set admin_ui_use_ssl to 'true' in cato.conf to enable SSL/TLS.)")

    app.add_processor(auth_app_processor)
    app.notfound = notfound

    app.run()
예제 #8
0
def main():
    dbglvl = 20
    if "rest_api_debug" in catoconfig.CONFIG:
        try:
            dbglvl = int(catoconfig.CONFIG["rest_api_debug"])
        except:
            raise Exception("rest_api_debug setting in cato.conf must be an integer between 0-50.")
    catolog.DEBUG = dbglvl

    server = catoprocess.CatoService(app_name)
    server.startup()

    # now that the service is set up, we'll know what the logfile name is.
    # so reget the logger
    logger = catolog.get_logger(app_name)
    catolog.set_debug(dbglvl)

    if len(sys.argv) < 2:
        if "rest_api_port" in catoconfig.CONFIG:
            port = catoconfig.CONFIG["rest_api_port"]
        else:
            port = "8081"
        sys.argv.append(port)

    # enable ssl?
    if catocommon.is_true(catoconfig.CONFIG.get("rest_api_use_ssl")):
        logger.info("Using SSL/TLS...")
        sslcert = catoconfig.CONFIG.get("rest_api_ssl_cert", os.path.join(catoconfig.CONFDIR, "cato.crt"))
        sslkey = catoconfig.CONFIG.get("rest_api_ssl_key", os.path.join(catoconfig.CONFDIR, "cato.key"))
        try:
            with open(sslcert):
                pass
            logger.debug("SSL Certificate [%s]" % sslcert)
            CherryPyWSGIServer.ssl_certificate = sslcert
        except:
            raise Exception("SSL Certificate not found at [%s]" % sslcert)
        try:
            with open(sslkey):
                pass
            logger.debug("SSL Key [%s]" % sslkey)
            CherryPyWSGIServer.ssl_private_key = sslkey
        except:
            raise Exception("SSL Key not found at [%s]" % sslcert)
    else:
        logger.info("Using standard HTTP. (Set rest_api_use_ssl to 'true' in cato.conf to enable SSL/TLS.)")

    urls = (
        '/', 'index',
        '/version', 'version',
        '/configure', 'configure',
        '/getlog', 'getlog',
        '/setdebug', 'setdebug',
        '/favicon.ico', 'favicon',
        '/(.*)', 'wmHandler'
    )

    app = ExceptionHandlingApplication(urls, globals(), autoreload=True)

    # setting this to True seems to show a lot more detail in UI exceptions
    web.config.debug = False

    app.run()