Esempio n. 1
0
    def __init__(self, config_parser):
        self.logger = create_logger(__name__)
        self.state = 'INIT'

        service_type = config_parser.get('agent', 'TYPE')
        user_id = config_parser.get('agent', 'USER_ID')
        service_id = config_parser.get('agent', 'SERVICE_ID')

        self.logger.info("'%s' agent started (uid=%s, sid=%s)" %
                         (service_type, user_id, service_id))

        # IPOP setup
        ipop.configure_conpaas_node(config_parser)

        # Ganglia setup
        self.ganglia = AgentGanglia(config_parser)

        try:
            self.ganglia.configure()
        except Exception, err:
            self.logger.exception('Error configuring Ganglia: %s' % err)
            # Something went wrong while configuring Ganglia. We do not want
            # our agent to think it can be used
            self.ganglia = None
            return
Esempio n. 2
0
    def __init__(self, config_parser):
        ConpaasRequestHandlerComponent.__init__(self)
        self.logger = create_logger(__name__)

        service_type = config_parser.get("agent", "TYPE")
        user_id = config_parser.get("agent", "USER_ID")
        service_id = config_parser.get("agent", "SERVICE_ID")

        self.LOG_FILE = config_parser.get("agent", "LOG_FILE")
        self.ROOT_DIR = "/root"

        self.logger.info("'%s' agent started (uid=%s, sid=%s)" % (service_type, user_id, service_id))

        # IPOP setup
        ipop.configure_conpaas_node(config_parser)

        # Ganglia setup
        self.ganglia = AgentGanglia(config_parser)

        try:
            self.ganglia.configure()
        except Exception, err:
            self.logger.exception("Error configuring Ganglia: %s" % err)
            # Something went wrong while configuring Ganglia. We do not want
            # our agent to think it can be used
            self.ganglia = None
            return
Esempio n. 3
0
    def __init__(self, clouds, default_cloud):
        self.logger = create_logger(__name__)

        if len(clouds) == 1:
            self.no_of_groups = 1
        # 3 cloud groups doesn't make sense for replication in scalaris, therefore 2 clouds are placed in the same group
        if len(clouds) == 2 or len(clouds) == 3:
            self.no_of_groups = 2
        elif len(clouds) >= 4:
            self.no_of_groups = 4

        # build the internal data structures:
        #   a list of up to four CloudGroup objects
        #   cloud2number: an index that maps the name of a cloud to its cloud group, used as access method
        self._groups = [CloudGroup(group_number) for group_number in range(self.no_of_groups)]
        self._cloud2group = {}
        for index, cloud in enumerate(clouds):
            cloud_group = self._groups[index % self.no_of_groups]
            cloud_group.clouds.append(cloud.get_cloud_name())
            self._cloud2group[cloud.get_cloud_name()] = cloud_group

        # add 'default' as an alias to 'iaas'
        self._cloud2group['default'] = self._cloud2group[default_cloud]

        # init logical clock
        self._clock = 0
Esempio n. 4
0
    def __init__(self, cloud_name, iaas_config):
        Cloud.__init__(self, cloud_name)

        cloud_params = [
            'USER', 'PASSWORD', 'HOST',
            'IMAGE_ID', 'SIZE_ID',
            'KEY_NAME',
            'SECURITY_GROUP_NAME',
        ]

        self.__logger = create_logger(__name__)
        self.__logger.setLevel(logging.DEBUG)

        self._check_cloud_params(iaas_config, cloud_params)

        def _get(param):
            return iaas_config.get(cloud_name, param)

        self.user = _get('USER')
        self.passwd = _get('PASSWORD')
        self.host = _get('HOST')
        self.img_id = _get('IMAGE_ID')
        self.size_id = _get('SIZE_ID')
        self.key_name = _get('KEY_NAME')
        self.sg = _get('SECURITY_GROUP_NAME')

        try:
            self.api_version = _get('FEDERATION_VERSION')
        except NoOptionError:
            self.api_version = DEFAULT_API_VERSION

        self.logger.info('Federation cloud ready. API_VERSION=%s' % 
            self.api_version)
Esempio n. 5
0
    def __init__(self, config_parser):
        self.logger = create_logger(__name__)    
        self.state = 'INIT'

        service_type = config_parser.get('agent', 'TYPE')
        user_id      = config_parser.get('agent', 'USER_ID')
        service_id   = config_parser.get('agent', 'SERVICE_ID')

        self.logger.info("'%s' agent started (uid=%s, sid=%s)" % (
            service_type, user_id, service_id))

        # IPOP setup
        ipop.configure_conpaas_node(config_parser)
    
        # Ganglia setup
        self.ganglia = AgentGanglia(config_parser)

        try:
            self.ganglia.configure()
        except Exception, err:
            self.logger.exception('Error configuring Ganglia: %s' % err)
            # Something went wrong while configuring Ganglia. We do not want
            # our agent to think it can be used
            self.ganglia = None
            return
Esempio n. 6
0
 def __init__(self, cloud_name):
     #TODO: it shouldn't be cloud_name == config file section name
     self.cloud_name = cloud_name
     self.connected = False
     self.driver = None
     self._context = None
     self._mapping_vars = {}
     self.logger = create_logger(__name__)
Esempio n. 7
0
 def __init__(self, cloud_name):
     #TODO: it shouldn't be cloud_name == config file section name
     self.cloud_name = cloud_name
     self.connected = False
     self.driver = None
     self.cx_template = None
     self.cx = None
     self.logger = create_logger(__name__)
Esempio n. 8
0
 def __init__(self,
              config_parser, # config file
              **kwargs):     # anything you can't send in config_parser
                             # (hopefully the new service won't need anything extra)
     self.logger = create_logger(__name__)
     self.nm_logfile = '/var/log/network_monitor.log'
     self.apps_dir = '/usr/local/cds/apps'
     self.state = self.S_RUNNING
Esempio n. 9
0
 def __init__(self, group_number):
     self.number = group_number
     self.clouds = []
     self.nodes = []
     self.timestamp = 0
     self.reg_keys = []
     self.firstnode = None
     self.logger = create_logger(__name__)
Esempio n. 10
0
 def __init__(self, cloud_name):
     #TODO: it shouldn't be cloud_name == config file section name
     self.cloud_name = cloud_name
     self.connected = False
     self.driver = None
     self.cx_template = None
     self.cx = None
     self.logger = create_logger(__name__)
Esempio n. 11
0
 def __init__(self, cloud_name):
     #TODO: it shouldn't be cloud_name == config file section name
     self.cloud_name = cloud_name
     self.connected = False
     self.driver = None
     self._context = None
     self._mapping_vars = {}
     self.logger = create_logger(__name__)
Esempio n. 12
0
 def __init__(self,dir_serviceHost = None):
     self.state = S_INIT         
     self.start_args = [MRC_STARTUP,'start']        
     self.config_template = join(ETC,'mrcconfig.properties')
     logger = create_logger(__name__)
     logger.info('MRC server initialized')
     self.uuid_nr = uuid.uuid1()
     self.configure(dir_serviceHost)
     self.start()
Esempio n. 13
0
 def __init__(
         self,
         config_parser,  # config file
         **kwargs):  # anything you can't send in config_parser
     # (hopefully the new service won't need anything extra)
     self.logger = create_logger(__name__)
     self.nm_logfile = '/var/log/network_monitor.log'
     self.apps_dir = '/usr/local/cds/apps'
     self.state = self.S_RUNNING
Esempio n. 14
0
File: role.py Progetto: ema/conpaas
 def __init__(self, dir_serviceHost, uuid):
     self.state = S_INIT
     self.start_args = [MRC_STARTUP, "start"]
     self.stop_args = [MRC_STARTUP, "stop"]
     self.config_template = join(ETC, "mrcconfig.properties")
     logger = create_logger(__name__)
     logger.info("MRC server initialized.")
     self.uuid = uuid
     self.configure(dir_serviceHost)
     self.start()
Esempio n. 15
0
 def __init__(self, dir_serviceHost, uuid, hostname):
     self.state = S_INIT         
     self.start_args = [MRC_STARTUP,'start']        
     self.stop_args = [MRC_STARTUP, 'stop']
     self.config_template = join(ETC,'mrcconfig.properties')
     logger = create_logger(__name__)
     logger.info('MRC server initialized.')
     self.uuid = uuid
     self.configure(dir_serviceHost, hostname)
     self.start()
Esempio n. 16
0
    def __init__(self):

        https.client.conpaas_init_ssl_ctx('/etc/cpsdirector/certs', 'director')

        init('/var/log/cpsdirector/debugging.log')
        self._logger = create_logger(__name__)
        self._logger.setLevel(logging.DEBUG)

        self._force_terminate_lock = Lock()

        self._created_nodes = []
        self._partially_created_nodes = []

        self._available_clouds = []
        self._default_cloud = None
        self.role = ""
Esempio n. 17
0
    def __init__(self, config_parser):
        self.logger = create_logger(__name__)
        self.controller = Controller(config_parser)
        self.logfile = config_parser.get('manager', 'LOG_FILE')
        self.config_parser = config_parser
        self.state = self.S_INIT

        # IPOP setup
        ipop.configure_conpaas_node(config_parser)

        # Ganglia setup
        ganglia = ManagerGanglia(config_parser)

        try:
            ganglia.configure()
        except Exception, err:
            self.logger.exception('Error configuring Ganglia: %s' % err)
            return
Esempio n. 18
0
    def __init__(self, config_parser):
        ConpaasRequestHandlerComponent.__init__(self)

        logger_name = __name__
        self.logfile = config_parser.get('manager', 'LOG_FILE')
        if config_parser.has_option('manager', 'SERVICE_ID'):
            service_id = config_parser.get('manager', 'SERVICE_ID')
            logger_name = logger_name.replace('manager', 'manager%s' % service_id)
            self.logger = create_standalone_logger(logger_name, self.logfile)
        else:
            self.logger = create_logger(logger_name)

        self.config_parser = config_parser
        self.state_log = []
        self.state_set(self.S_INIT)

        self.volumes = {}
        self.nodes = []
Esempio n. 19
0
    def __init__(self):
        Thread.__init__(self)
        self.event = Event()
        self.unit = 1
        self.charging_unit = 60
        # self.credit_step = 1
        self.credit_step = 5
        self.sanity_step = 15

        self.count = 0
        self.daemon = True

        self.controller = Controller()
        self.controller.setup_default()

        init('/var/log/cpsdirector/debugging.log')
        self._logger = create_logger(__name__)
        self._logger.setLevel(logging.DEBUG)
Esempio n. 20
0
def configure_conpaas_node(config_parser):
    """IPOP will be configured on this node if IPOP_IP_ADDRESS has been
    specified."""
    logger = create_logger(__name__)

    if config_parser.has_section('manager'):
        section = 'manager'
    else:
        section = 'agent'

    # If IPOP has to be used
    if config_parser.has_option(section, 'IPOP_IP_ADDRESS'):
        ip_address = config_parser.get(section, 'IPOP_IP_ADDRESS')
    else:
        logger.info('Not starting a VPN: IPOP_IP_ADDRESS not found')
        return

    # Stop here if IPOP is not installed
    if not os.path.isdir(IPOP_CONF_DIR):
        logger.error('Not starting a VPN: ipop does not seem to be installed')
        return

    conpaas_home = config_parser.get(section, 'CONPAAS_HOME')

    ipop_tmpl_dir = os.path.join(conpaas_home, 'config', 'ipop')
    
    ipop_namespace = get_ipop_namespace(config_parser)
    ip_base = config_parser.get(section, 'IPOP_BASE_IP')
    netmask = config_parser.get(section, 'IPOP_NETMASK')

    if config_parser.has_option(section, 'IPOP_BOOTSTRAP_NODES'):
        bootstrap_nodes = list_lines(
            config_parser.get(section, 'IPOP_BOOTSTRAP_NODES'))
    else:
        bootstrap_nodes = None

    msg = 'Starting IPOP. namespace=%s ip_base=%s netmask=%s ip_address=%s' % (
        ipop_namespace, ip_base, netmask, ip_address)

    logger.info(msg)

    configure_ipop(ipop_tmpl_dir, ipop_namespace, ip_base, netmask, ip_address, bootstrap_nodes=bootstrap_nodes)
    restart_ipop()
Esempio n. 21
0
    def __init__(self, config_parser):
        self.logger = create_logger(__name__)
        self.logger.debug('Using libcloud version %s' % libcloud.__version__)

        self.controller = Controller(config_parser)
        self.logfile = config_parser.get('manager', 'LOG_FILE')
        self.config_parser = config_parser
        self.state = self.S_INIT

        self.volumes = []

        # IPOP setup
        ipop.configure_conpaas_node(config_parser)

        # Ganglia setup
        self.ganglia = ManagerGanglia(config_parser)

        try:
            self.ganglia.configure()
        except Exception, err:
            self.logger.exception('Error configuring Ganglia: %s' % err)
            self.ganglia = None
            return
Esempio n. 22
0
    def __init__(self, config_parser):
        self.logger = create_logger(__name__)
        self.logger.debug('Using libcloud version %s' % libcloud.__version__)

        self.controller = Controller(config_parser)
        self.logfile = config_parser.get('manager', 'LOG_FILE')
        self.config_parser = config_parser
        self.state = self.S_INIT

        self.volumes = []

        # IPOP setup
        ipop.configure_conpaas_node(config_parser)

        # Ganglia setup
        self.ganglia = ManagerGanglia(config_parser)

        try:
            self.ganglia.configure()
        except Exception, err:
            self.logger.exception('Error configuring Ganglia: %s' % err)
            self.ganglia = None
            return
Esempio n. 23
0
    def __init__(self, config_parser, **kwargs):
        # Params for director callback
        self.__conpaas_creditUrl = config_parser.get('manager', 'CREDIT_URL')
        self.__conpaas_terminateUrl = config_parser.get(
            'manager', 'TERMINATE_URL')
        self.__conpaas_service_id = config_parser.get('manager', 'SERVICE_ID')
        self.__conpaas_user_id = config_parser.get('manager', 'USER_ID')
        self.__conpaas_app_id = config_parser.get('manager', 'APP_ID')
        self.__conpaas_caUrl = config_parser.get('manager', 'CA_URL')

        # Set the CA URL as IPOP's base namespace
        self.__ipop_base_namespace = self.__conpaas_caUrl

        if config_parser.has_option('manager', 'IPOP_BASE_IP'):
            # Application-level network
            self.__ipop_base_ip = config_parser.get('manager', 'IPOP_BASE_IP')
        else:
            self.__ipop_base_ip = None

        if config_parser.has_option('manager', 'IPOP_NETMASK'):
            # Application-level netmask
            self.__ipop_netmask = config_parser.get('manager', 'IPOP_NETMASK')
        else:
            self.__ipop_netmask = None

        if config_parser.has_option('manager', 'IPOP_SUBNET'):
            # Only import from netaddr if IPOP has to be started
            from netaddr import IPNetwork

            # Subnet assigned to this service by the director
            self.__ipop_subnet = IPNetwork(
                config_parser.get('manager', 'IPOP_SUBNET'))
        else:
            self.__ipop_subnet = None

        # For crediting system
        self.__reservation_logger = create_logger('ReservationTimer')
        self.__reservation_map = {
            'manager':
            ReservationTimer(
                ['manager'],
                55 * 60,  # 55mins
                self.__deduct_and_check_credit,
                self.__reservation_logger)
        }
        self.__reservation_map['manager'].start()
        self.__force_terminate_lock = Lock()

        self.config_parser = config_parser
        self.__created_nodes = []
        self.__partially_created_nodes = []
        self.__logger = create_logger(__name__)

        self.__available_clouds = []
        self.__default_cloud = None
        if config_parser.has_option('iaas', 'DRIVER'):
            self.__default_cloud = iaas.get_cloud_instance(
                'iaas',
                config_parser.get('iaas', 'DRIVER').lower(), config_parser)
            self.__available_clouds.append(self.__default_cloud)

        if config_parser.has_option('iaas', 'OTHER_CLOUDS'):
            self.__available_clouds.extend(iaas.get_clouds(config_parser))
            # if there is no default cloud defined in 'iaas'
            if self.__default_cloud is None:
                self.__default_cloud = self.__available_clouds.pop(0)

        # Setting VM role
        self.role = 'agent'
Esempio n. 24
0
from os import chown
from pwd import getpwnam
from os.path import join, devnull, lexists
from subprocess import Popen, PIPE
from Cheetah.Template import Template
from conpaas.core.log import create_logger
from conpaas.core.misc import run_cmd
import time

S_INIT        = 'INIT'
S_STARTING    = 'STARTING'
S_RUNNING     = 'RUNNING'
S_STOPPING    = 'STOPPING'
S_STOPPED     = 'STOPPED'

logger = create_logger(__name__)

MRC_STARTUP = None
DIR_STARTUP = None
OSD_STARTUP = None
OSD_REMOVE = None
ETC = None

def init(config_parser):
    global MRC_STARTUP,DIR_STARTUP,OSD_STARTUP,OSD_REMOVE,XTREEM_TMPL
    MRC_STARTUP = config_parser.get('mrc','MRC_STARTUP')
    DIR_STARTUP = config_parser.get('dir','DIR_STARTUP')
    OSD_STARTUP = config_parser.get('osd','OSD_STARTUP')
    OSD_REMOVE  = config_parser.get('osd','OSD_REMOVE')
    global ETC
    ETC = config_parser.get('agent','ETC')
Esempio n. 25
0
 def __init__(self, configuration):
     self.logger = create_logger(__name__)
     self.mysql_count = 0
     self.serviceNodes = {}        
Esempio n. 26
0
 def __init__(self, config_parser):
     self.__logger = create_logger(__name__)
 	self.config_parser = config_parser
Esempio n. 27
0
 def __init__(self, configuration):
     '''Representation of the deployment configuration'''
     self.logger = create_logger(__name__)
     self.mysql_count = 0
     self.serviceNodes = {}
     self.glb_service_nodes = {}
Esempio n. 28
0
    def __init__(self, config_parser, **kwargs):
        # TODO: retrieve this file name from the director.cfg configuration file & create the log file if it is not yet present
        init('/var/log/cpsdirector/debugging.log')
        self.__logger = create_logger(__name__)
        self.__logger.setLevel(logging.DEBUG)
        # Params for director callback
        self.__conpaas_name = config_parser.get('manager',
                                                'DEPLOYMENT_NAME')
        self.__conpaas_creditUrl = config_parser.get('manager',
                                                'CREDIT_URL')
        self.__conpaas_terminateUrl = config_parser.get('manager',
                                                   'TERMINATE_URL')
        self.__conpaas_service_id = config_parser.get('manager',
                                                 'SERVICE_ID')
        self.__conpaas_user_id = config_parser.get('manager',
                                              'USER_ID')
        self.__conpaas_app_id = config_parser.get('manager',
                                              'APP_ID')
        self.__conpaas_caUrl = config_parser.get('manager',
                                            'CA_URL')

        # Set the CA URL as IPOP's base namespace
        self.__ipop_base_namespace = self.__conpaas_caUrl

        if config_parser.has_option('manager', 'IPOP_BASE_IP'):
            # Application-level network
            self.__ipop_base_ip = config_parser.get('manager', 'IPOP_BASE_IP')
        else:
            self.__ipop_base_ip = None

        if config_parser.has_option('manager', 'IPOP_NETMASK'):
            # Application-level netmask
            self.__ipop_netmask = config_parser.get('manager', 'IPOP_NETMASK')
        else:
            self.__ipop_netmask = None

        if config_parser.has_option('manager', 'IPOP_BOOTSTRAP_NODES'):
            # Application-level network's bootstrap nodes
            self.__ipop_bootstrap_nodes = config_parser.get('manager', 'IPOP_BOOTSTRAP_NODES')
        else:
            self.__ipop_bootstrap_nodes = None

        if config_parser.has_option('manager', 'IPOP_SUBNET'):
            # Only import from netaddr if IPOP has to be started
            from netaddr import IPNetwork

            # Subnet assigned to this service by the director
            self.__ipop_subnet = IPNetwork(
                config_parser.get('manager', 'IPOP_SUBNET'))
        else:
            self.__ipop_subnet = None

        # For crediting system
        self.__reservation_logger = create_logger('ReservationTimer')
        self.__reservation_map = {'manager': ReservationTimer(['manager'],
                                  55 * 60,  # 55mins
                                  self.__deduct_and_check_credit,
                                  self.__reservation_logger)}
        self.__reservation_map['manager'].start()
        self.__force_terminate_lock = Lock()

        self.config_parser = config_parser
        self.__created_nodes = []
        self.__partially_created_nodes = []

        self.__available_clouds = []
        self.__default_cloud = None
        if config_parser.has_option('iaas', 'DRIVER'):
            self.__default_cloud = iaas.get_cloud_instance(
                'iaas',
                config_parser.get('iaas', 'DRIVER').lower(),
                config_parser)
            self.__available_clouds.append(self.__default_cloud)

        if config_parser.has_option('iaas', 'OTHER_CLOUDS'):
            self.__logger.debug("attempt iaas.get_clouds()")
            try:
                self.__available_clouds.extend(iaas.get_clouds(config_parser))
            except Exception as e:
                self.__logger.debug("failed iaas.get_clouds()")
                self.__reservation_map['manager'].stop()
                raise e
            self.__logger.debug("succeeded iaas.get_clouds()")

        # Setting VM role
        self.role = 'agent'
Esempio n. 29
0
    :copyright: (C) 2010-2013 by Contrail Consortium.
"""

from os.path import join, devnull
from subprocess import Popen
from Cheetah.Template import Template
from conpaas.core.log import create_logger
import uuid

S_INIT        = 'INIT'
S_STARTING    = 'STARTING'
S_RUNNING     = 'RUNNING'
S_STOPPING    = 'STOPPING'
S_STOPPED     = 'STOPPED'

logger = create_logger(__name__)

MRC_STARTUP = None
DIR_STARTUP = None
OSD_STARTUP = None
OSD_REMOVE = None
ETC = None

def init(config_parser):
    global MRC_STARTUP,DIR_STARTUP,OSD_STARTUP,OSD_REMOVE,XTREEM_TMPL
    MRC_STARTUP = config_parser.get('mrc','MRC_STARTUP')
    DIR_STARTUP = config_parser.get('dir','DIR_STARTUP')
    OSD_STARTUP = config_parser.get('osd','OSD_STARTUP')
    OSD_REMOVE  = config_parser.get('osd','OSD_REMOVE')
    global ETC
    ETC = config_parser.get('agent','ETC')