예제 #1
0
파일: Util.py 프로젝트: remyd1/client
def printError(msg, exitCode=1, exit=True):
    # TODO: Revisit this design; having exit in API is not good.
    err = '  [ERROR] %s' % msg
    if exit:
        raise SystemExit(err)
    else:
        LogUtil.error(msg)
예제 #2
0
    def __init__(self, configHolder):
        self.creator = None

        super(StratusLabClientCloud, self).__init__(configHolder)

        self.slConfigHolder = StratuslabConfigHolder(configHolder.options,
                                                     configHolder.config)
        self._set_listener(
            CreatorBaseListener(verbose=(self.verboseLevel > 1)))

        self._set_capabilities(contextualization=True,
                               direct_ip_assignment=True,
                               orchestrator_can_kill_itself_or_its_vapp=True)

        if self.verboseLevel > 2:
            LogUtil.set_logger_level(level=logging.DEBUG)

        # Temporary workaround: Try to increase to the maximum the limit of the number of open file descriptors.
        # This is a workaround to a bug where some connections to the StratusLab frontend stays in CLOSE_WAIT.
        # The standard limit is hit when the Run contains a huge amount of VMs (> 1000).
        try:
            import resource
            l = resource.getrlimit(resource.RLIMIT_NOFILE)
            resource.setrlimit(resource.RLIMIT_NOFILE, (l[1], l[1]))
        except:
            pass
예제 #3
0
파일: utils.py 프로젝트: StratusLab/client
def initialize_logger(log_direction, verbosity):
    level = (0 == verbosity) and logging.INFO or logging.DEBUG 
    if 'console' == log_direction:
        return LogUtil.get_console_logger(level=level)
    elif 'syslog' == log_direction:
        return LogUtil.get_syslog_logger(level=level)
    else:
        raise ConfigurationException('Wrong value for log_direction: %s' % log_direction)
import sys

from stratuslab.commandbase.AuthnCommand import AuthnCommand


sys.path.append('/var/lib/stratuslab/python')

from stratuslab.ConfigHolder import ConfigHolder
from stratuslab.marketplace.Deprecator import Deprecator
from stratuslab.Exceptions import InputException

# initialize console logging
import stratuslab.api.LogUtil as LogUtil

LogUtil.get_console_logger()


class MainProgram(AuthnCommand):
    """A command-line program to deprecate a StratusLab metadata entry."""

    def __init__(self):
        self.imageid = None
        super(MainProgram, self).__init__()

    def parse(self):
        Deprecator.buildDeprecatorParser(self.parser)

        self.options, self.args = self.parser.parse_args()

    def checkOptions(self):
예제 #5
0
from .stratuslabPatch import patch_stratuslab

patch_stratuslab()

from stratuslab.ConfigHolder import ConfigHolder as StratuslabConfigHolder
from stratuslab.marketplace.ManifestDownloader import ManifestDownloader
from stratuslab.Creator import Creator
from stratuslab.Creator import CreatorBaseListener
from stratuslab.vm_manager.Runner import Runner
from stratuslab.volume_manager.volume_manager_factory import VolumeManagerFactory
from stratuslab.Exceptions import OneException
from stratuslab.api import LogUtil
from stratuslab.Monitor import Monitor
from stratuslab.CloudInfo import CloudInfo

LogUtil.get_console_logger()

import slipstream.exceptions.Exceptions as Exceptions
import slipstream.util as util

from slipstream.cloudconnectors.BaseCloudConnector import BaseCloudConnector
from slipstream.utils.ssh import generate_ssh_keypair
from slipstream.util import override

from .vmrootdisk import (populate_vms_with_disk_sizes,
                         get_root_disk_size_from_disk_source,
                         UnknownRootDiskSizeSourceError)


def getConnector(configHolder):
    return getConnectorClass()(configHolder)
예제 #6
0
cfg_filename = 'monitoring.cfg'

def _configure():
    fsroot = os.path.splitdrive(sys.executable)[0] or '/'
    cfg_paths = [os.path.join(os.getcwd(), cfg_filename),
                 os.path.join(os.path.expanduser('~'), '.stratuslab', cfg_filename),
                 os.path.join(fsroot, 'etc', 'stratuslab', cfg_filename)]

    config = ConfigParser.ConfigParser()
    config.add_section('vm_usage')
    config.set('vm_usage', 'bucket', 'default')
    config.set('vm_usage', 'password', '')
    used_cfg_files = config.read(cfg_paths)
    return (config, used_cfg_files)

logger = LogUtil.get_syslog_logger(__name__)

(config, used_cfg_files) = _configure()

logger.debug('publisher read configuration from %s' % str(used_cfg_files))

host = config.get('vm_usage', 'host')
if not host:
    logger.debug('logging host not defined; skipping VM usage logging')
    sys.exit(0)

logger.debug('starting VM usage history publishing')
try:
    aCP = ConsolidationPublish(host=host)
    logger.debug('publishing VMs usage history to %s' % host)
except Exception as e:
예제 #7
0
파일: Util.py 프로젝트: remyd1/client
def printDetail(msg, verboseLevel=1, verboseThreshold=1):
    # TODO: Review this to see if more levels are needed.
    if verboseThreshold == 0:
        LogUtil.info(msg)
    else:
        LogUtil.debug(msg)
예제 #8
0
파일: Util.py 프로젝트: remyd1/client
def printWarning(msg):
    LogUtil.warning('  [WARNING] %s' % msg)
예제 #9
0
파일: Util.py 프로젝트: remyd1/client
def printDebug(msg):
    LogUtil.debug(msg)
예제 #10
0
파일: Util.py 프로젝트: remyd1/client
def printInfo(msg):
    LogUtil.info(msg)
예제 #11
0
파일: Util.py 프로젝트: remyd1/client
def printStep(msg):
    LogUtil.info(' :: %s' % msg)
예제 #12
0
파일: Util.py 프로젝트: remyd1/client
def printAction(msg):
    LogUtil.info(_format_action(msg))