Beispiel #1
0
def _init():
    optparser = bus.optparser
    bus.base_path = os.path.realpath(os.path.dirname(__file__) + "/../..")

    #dynimp.setup()

    _init_logging()
    logger = logging.getLogger(__name__)

    # Initialize configuration
    if not bus.etc_path:
        etc_places = [
            "/etc/scalr", "/etc/scalarizr", "/usr/etc/scalarizr",
            "/usr/local/etc/scalarizr",
            os.path.join(bus.base_path, 'etc')
        ]
        if optparser and optparser.values.etc_path:
            # Insert command-line passed etc_path into begining
            etc_places.insert(0, optparser.values.etc_path)

        bus.etc_path = firstmatched(lambda p: os.access(p, os.F_OK),
                                    etc_places)
        if not bus.etc_path:
            raise ScalarizrError(
                'Cannot find scalarizr configuration dir. Search path: %s' %
                ':'.join(etc_places))
    cnf = ScalarizrCnf(bus.etc_path)
    if not os.path.exists(cnf.private_path()):
        os.makedirs(cnf.private_path())
    bus.cnf = cnf

    # Find shared resources dir
    if not bus.share_path:
        share_places = [
            '/usr/share/scalr', '/usr/local/share/scalr',
            os.path.join(bus.base_path, 'share')
        ]
        bus.share_path = firstmatched(lambda p: os.access(p, os.F_OK),
                                      share_places)
        if not bus.share_path:
            raise ScalarizrError(
                'Cannot find scalarizr share dir. Search path: %s' %
                ':'.join(share_places))

    # Registering in init.d
    initdv2.explore("scalarizr", ScalarizrInitScript)
Beispiel #2
0
def _init():
	optparser = bus.optparser
	bus.base_path = os.path.realpath(os.path.dirname(__file__) + "/../..")
	
	#dynimp.setup()
	
	_init_logging()
	logger = logging.getLogger(__name__)	
	
	# Initialize configuration
	if not bus.etc_path:
		etc_places = [
			"/etc/scalr",
			"/etc/scalarizr", 
			"/usr/etc/scalarizr", 
			"/usr/local/etc/scalarizr",
			os.path.join(bus.base_path, 'etc')
		]
		if optparser and optparser.values.etc_path:
			# Insert command-line passed etc_path into begining
			etc_places.insert(0, optparser.values.etc_path)
			
		bus.etc_path = firstmatched(lambda p: os.access(p, os.F_OK), etc_places)
		if not bus.etc_path:
			raise ScalarizrError('Cannot find scalarizr configuration dir. Search path: %s' % ':'.join(etc_places))
	cnf = ScalarizrCnf(bus.etc_path)
	if not os.path.exists(cnf.private_path()):
		os.makedirs(cnf.private_path())
	bus.cnf = cnf
	
	
	# Find shared resources dir
	if not bus.share_path:
		share_places = [
			'/usr/share/scalr',
			'/usr/local/share/scalr',
			os.path.join(bus.base_path, 'share')
		]
		bus.share_path = firstmatched(lambda p: os.access(p, os.F_OK), share_places)
		if not bus.share_path:
			raise ScalarizrError('Cannot find scalarizr share dir. Search path: %s' % ':'.join(share_places))

	
	# Registering in init.d
	initdv2.explore("scalarizr", ScalarizrInitScript)
Beispiel #3
0
def _init():
    optparser = bus.optparser
    bus.base_path = os.path.realpath(os.path.dirname(__file__) + "/../..")

    _init_logging()
    logger = logging.getLogger(__name__)

    # Initialize configuration
    if not bus.etc_path:
        bus.etc_path = __node__['etc_dir']
    cnf = ScalarizrCnf(bus.etc_path)
    if not os.path.exists(cnf.private_path()):
        os.makedirs(cnf.private_path())
    bus.cnf = cnf

    # Find shared resources dir
    if not bus.share_path:
        bus.share_path = __node__['share_dir']

    # Registering in init.d
    initdv2.explore("scalarizr", ScalarizrInitScript)
Beispiel #4
0
def _init():
    global _meta
    _meta = metadata.Metadata()

    optparser = bus.optparser
    bus.base_path = os.path.realpath(os.path.dirname(__file__) + "/../..")
    
    _init_logging()
    logger = logging.getLogger(__name__)    
    
    # Initialize configuration
    if not bus.etc_path:
        bus.etc_path = __node__['etc_dir']
    cnf = ScalarizrCnf(bus.etc_path)
    if not os.path.exists(cnf.private_path()):
        os.makedirs(cnf.private_path())
    bus.cnf = cnf
    
    # Find shared resources dir
    if not bus.share_path:
        bus.share_path = __node__['share_dir']
    
    # Registering in init.d
    initdv2.explore("scalarizr", ScalarizrInitScript)
Beispiel #5
0
            file.write(app_rules)
            file.close()
            apparmor_initd = initdv2.ParametrizedInitScript('apparmor', '/etc/init.d/apparmor')
            try:
                apparmor_initd.reload()
            except InitdError, e:
                LOG.error('Cannot restart apparmor. %s', e)


def get_semanage():
    if linux.os['family'] == 'RedHat':
        semanage = software.which('semanage')
        if not semanage:
            mgr = pkgmgr.package_mgr()
            mgr.install('policycoreutils-python')
            semanage = software.which('semanage')
        return semanage


class MySQLPresetProvider(PresetProvider):

    __metaclass__ = Singleton

    def __init__(self):
        service = initdv2.lookup(SERVICE_NAME)
        config_mapping = {PRESET_FNAME:MySQLConf(MYCNF_PATH)}
        PresetProvider.__init__(self, service, config_mapping)


initdv2.explore(SERVICE_NAME, MysqlInitScript)
Beispiel #6
0
OPT_MASTER_PASSWORD                     = "******"
OPT_VOLUME_CNF                          = 'volume_config'
OPT_SNAPSHOT_CNF                        = 'snapshot_config'
OPT_USE_PASSWORD            = '******'

REDIS_CNF_PATH                          = 'cnf_path'
UBUNTU_CONFIG_PATH                      = '/etc/redis/redis.conf'
CENTOS_CONFIG_PATH                      = '/etc/redis.conf'

BACKUP_CHUNK_SIZE                       = 200*1024*1024


LOG = logging.getLogger(__name__)


initdv2.explore(SERVICE_NAME, redis.RedisInitScript)


def get_handlers():
    return (RedisHandler(), )


class RedisHandler(ServiceCtlHandler, handlers.FarmSecurityMixin):

    _queryenv = None
    """ @type _queryenv: scalarizr.queryenv.QueryEnvService """

    _platform = None
    """ @type _platform: scalarizr.platform.Ec2Platform """

    _cnf = None
Beispiel #7
0
        except:
            LOG.debug('Error stopping HAProxy. Details: %s%s'% (sys.exc_info()[1], sys.exc_info()[2]))
        self.start()


    def reload(self):
        try:
            if os.path.exists(self.pid_file):
                pid = self.pid()
                if pid:
                    args = [self.haproxy_exec, '-f', self.config_path, '-p', self.pid_file, '-D', '-sf', pid]
                    util.system2(args, close_fds=True, logger=LOG, preexec_fn=os.setsid)
                    util.wait_until(lambda: self.pid() and self.pid() != pid,
                            timeout=self.timeout, sleep=0.5, error_text="Error reloading HAProxy service process.")
                    if self.status() != 0:
                        raise initdv2.InitdError("HAProxy service not running.")
            else:
                raise LookupError('File %s not exist'%self.pid_file)
        except:
            raise initdv2.InitdError, "HAProxy service not running can't reload it."\
                    " Details: %s" % sys.exc_info()[1], sys.exc_info()[2]


    def pid(self):
        '''Read #pid of the process from pid_file'''
        if os.path.isfile(self.pid_file):
            with open(self.pid_file, 'r') as fp:
                return long(fp.read())

initdv2.explore(SERVICE_NAME, HAProxyInitScript)
Beispiel #8
0
OPT_MASTER_PASSWORD			= "******"
OPT_VOLUME_CNF				= 'volume_config'
OPT_SNAPSHOT_CNF			= 'snapshot_config'
OPT_USE_PASSWORD            = '******'

REDIS_CNF_PATH				= 'cnf_path'
UBUNTU_CONFIG_PATH			= '/etc/redis/redis.conf'
CENTOS_CONFIG_PATH			= '/etc/redis.conf'

BACKUP_CHUNK_SIZE 			= 200*1024*1024


LOG = logging.getLogger(__name__)


initdv2.explore(SERVICE_NAME, redis.RedisInitScript)


def get_handlers():
	return (RedisHandler(), )


class RedisHandler(ServiceCtlHandler, handlers.FarmSecurityMixin):

	_queryenv = None
	""" @type _queryenv: scalarizr.queryenv.QueryEnvService	"""

	_platform = None
	""" @type _platform: scalarizr.platform.Ec2Platform """

	_cnf = None
Beispiel #9
0
        wait_until(lambda: self.status() == initdv2.Status.NOT_RUNNING,
                   timeout=MAX_STOP_TIMEOUT)

    def restart(self, reason=None):
        initdv2.ParametrizedInitScript.restart(self)

    def reload(self, reason=None):
        initdv2.ParametrizedInitScript.restart(self)

    def start(self):
        initdv2.ParametrizedInitScript.start(self)
        wait_until(lambda: self.status() == initdv2.Status.RUNNING, sleep=1)
        #error_text="In %s seconds after start Mongodb state still isn't 'Running'" % MAX_START_TIMEOUT)


initdv2.explore(SERVICE_NAME, MongoDBDefaultInitScript)


class MongoDB(BaseService):
    _arbiter = None
    _instance = None
    _config_server = None
    _mongod_noauth = None

    keyfile = None
    login = None
    password = None
    auth = True

    def __init__(self, keyfile=None):
        self.keyfile = keyfile
Beispiel #10
0
# Stdlibs
import os, logging, shutil
import time
from datetime import datetime
import ConfigParser
import cStringIO


BEHAVIOUR = SERVICE_NAME = BuiltinBehaviours.WWW
CNF_NAME = BEHAVIOUR
CNF_SECTION = BEHAVIOUR

__nginx__ = __node__['nginx']


initdv2.explore('nginx', NginxInitScript)


# Nginx behaviours configuration options
class NginxOptions(Configurator.Container):
    '''
    www behaviour
    '''
    cnf_name = CNF_NAME

    class binary_path(Configurator.Option):
        '''
        Path to nginx binary
        '''
        name = CNF_SECTION + '/binary_path'
        required = True
Beispiel #11
0
                    break
                else:
                    time.sleep(1)
            else:
                os.kill(pid, 9)


    def restart(self):
        self.stop()
        self.start()


    reload = restart


initdv2.explore(BEHAVIOUR, MysqlProxyInitScript)

def is_mysql_role(behaviours):
    return bool(set((BuiltinBehaviours.MYSQL,
               BuiltinBehaviours.MYSQL2,
               BuiltinBehaviours.PERCONA,
               BuiltinBehaviours.MARIADB)).intersection(set(behaviours)))


class MysqlProxyHandler(ServiceCtlHandler):


    def __init__(self):
        self._logger = logging.getLogger(__name__)
        self.service = initdv2.lookup(BEHAVIOUR)
        self._service_name = BEHAVIOUR
Beispiel #12
0
                    args = [
                        self.haproxy_exec, '-f', self.config_path, '-p',
                        self.pid_file, '-D', '-sf', pid
                    ]
                    util.system2(args,
                                 close_fds=True,
                                 logger=LOG,
                                 preexec_fn=os.setsid)
                    util.wait_until(
                        lambda: self.pid() and self.pid() != pid,
                        timeout=self.timeout,
                        sleep=0.5,
                        error_text="Error reloading HAProxy service process.")
                    if self.status() != 0:
                        raise initdv2.InitdError(
                            "HAProxy service not running.")
            else:
                raise LookupError('File %s not exist' % self.pid_file)
        except:
            raise initdv2.InitdError, "HAProxy service not running can't reload it."\
                    " Details: %s" % sys.exc_info()[1], sys.exc_info()[2]

    def pid(self):
        '''Read #pid of the process from pid_file'''
        if os.path.isfile(self.pid_file):
            with open(self.pid_file, 'r') as fp:
                return long(fp.read())


initdv2.explore(SERVICE_NAME, HAProxyInitScript)
Beispiel #13
0
    """
    @ivar status: ok|error
    @ivar last_error
    @ivar volume: converted volume configuration
    """



def get_handlers():
    return [MysqlHandler()]


class DBMSRHandler(ServiceCtlHandler):
    pass

initdv2.explore(__mysql__['behavior'], mysql_svc.MysqlInitScript)

class MysqlCnfController(CnfController):
    _mysql_version = None
    _merged_manifest = None
    _cli = None

    def __init__(self):
        self._init_script = initdv2.lookup(__mysql__['behavior'])
        self.sendline = ''
        definitions = {'ON': '1', 'TRUE': '1', 'OFF' :'0', 'FALSE': '0'}
        CnfController.__init__(self,
                        __mysql__['behavior'],
                        mysql_svc.MYCNF_PATH,
                        'mysql',
                        definitions) #TRUE,FALSE
Beispiel #14
0
        initdv2.ParametrizedInitScript.stop(self)
        wait_until(lambda: self.status() == initdv2.Status.NOT_RUNNING, timeout=MAX_STOP_TIMEOUT)

    def restart(self, reason=None):
        initdv2.ParametrizedInitScript.restart(self)

    def reload(self, reason=None):
        initdv2.ParametrizedInitScript.restart(self)

    def start(self):
        initdv2.ParametrizedInitScript.start(self)
        wait_until(lambda: self.status() == initdv2.Status.RUNNING, sleep=1)
        # error_text="In %s seconds after start Mongodb state still isn't 'Running'" % MAX_START_TIMEOUT)


initdv2.explore(SERVICE_NAME, MongoDBDefaultInitScript)


class MongoDB(BaseService):
    _arbiter = None
    _instance = None
    _config_server = None
    _mongod_noauth = None

    keyfile = None
    login = None
    password = None
    auth = True

    def __init__(self, keyfile=None):
        self.keyfile = keyfile
Beispiel #15
0
        elif action == "stop":
            if self.running:
                with open(self.pid_file) as f:
                    pid = int(f.read().strip())
                try:
                    os.getpgid(pid)
                except OSError:
                    os.remove(self.pid_file)
                else:
                    os.kill(pid, signal.SIGTERM)

    def restart(self):
        self._start_stop_reload("stop")
        self._start_stop_reload("start")

initdv2.explore('chef', ChefInitScript)

class ChefHandler(Handler):

    def __init__(self):
        super(ChefHandler, self).__init__()
        bus.on(init=self.on_init)
        self._chef_data = None
        self._run_list = None

        self._with_json_attributes = None
        self._platform = bus.platform
        self._global_variables = {}
        self._init_script = initdv2.lookup('chef')

    def on_init(self, *args, **kwds):
Beispiel #16
0
                             InitdError.NOT_RUNNING)

    @staticmethod
    def _main_process_started():
        res = False
        try:
            out = system2(("ps", "-G", __apache__["group"], "-o", "command",
                           "--no-headers"),
                          raise_exc=False)[0]
            res = __apache__["bin_path"] in out
        except (Exception, BaseException):
            pass
        return res


initdv2.explore("apache", ApacheInitScript)


def get_virtual_host_path(hostname, port):
    ext = __apache__["vhost_extension"]
    end = "%s-%s%s" % (hostname, port, ext)
    return os.path.join(__apache__["vhosts_dir"], end)


def get_updated_file_names(virtual_host_file_names):
    ext = __apache__["vhost_extension"]

    plaintext_pattern = re.compile("(.+)\.vhost.conf")
    ssl_pattern = re.compile("(.+)-ssl%s" % ext)
    newstyle_pattern = re.compile("(\d+)%s" % ext)
Beispiel #17
0
                    os.kill(pid, 0)
                except OSError:
                    break
                else:
                    time.sleep(1)
            else:
                os.kill(pid, 9)

    def restart(self):
        self.stop()
        self.start()

    reload = restart


initdv2.explore(BEHAVIOUR, MysqlProxyInitScript)


def is_mysql_role(behaviours):
    return bool(
        set((BuiltinBehaviours.MYSQL, BuiltinBehaviours.MYSQL2,
             BuiltinBehaviours.PERCONA,
             BuiltinBehaviours.MARIADB)).intersection(set(behaviours)))


class MysqlProxyHandler(ServiceCtlHandler):
    def __init__(self):
        self._logger = logging.getLogger(__name__)
        self.service = initdv2.lookup(BEHAVIOUR)
        self._service_name = BEHAVIOUR
        bus.on(init=self.on_init)
Beispiel #18
0
OPT_STORAGE_DEVICE_NAME	= "device_name"
TMP_EBS_MNTPOINT        = '/mnt/temp_storage'
CASSANDRA_CONTROL_DATA  = 'cassandra'

class CassandraInitScript(initdv2.ParametrizedInitScript):
	def __init__(self):
		pl = bus.platform
		initd_script = "/etc/init.d/cassandra"
		if not os.path.exists(initd_script):
			raise HandlerError("Cannot find Cassandra init script at %s. Make sure that Cassandra is installed" % initd_script)
		
		pid_file = '/var/run/cassandra.pid'
		socks = [initdv2.SockParam(7000, conn_address = pl.get_private_ip(), timeout = 60)]
		initdv2.ParametrizedInitScript.__init__(self, 'cassandra', initd_script, pid_file, socks=socks)

initdv2.explore('cassandra', CassandraInitScript)


class CassandraMessages:
	
	CHANGE_RF					= 'Cassandra_ChangeReplFactor'
	'''
	@ivar changes list( dict( name = 'Keyspace1', rf = 3)) 
	'''
	CHANGE_RF_RESULT			= 'Cassandra_ChangeReplFactorResult'
	'''
	@ivar status ok|error
	@ivar last_error
	@ivar rows list(dict(host=ip))
	'''
	
Beispiel #19
0
from scalarizr.services import BaseConfig, PresetProvider

# Stdlibs
import os, logging, shutil
import time
from datetime import datetime
import ConfigParser
import cStringIO

BEHAVIOUR = SERVICE_NAME = BuiltinBehaviours.WWW
CNF_NAME = BEHAVIOUR
CNF_SECTION = BEHAVIOUR

__nginx__ = nginx_api.__nginx__

initdv2.explore('nginx', NginxInitScript)


def get_handlers():
    return [NginxHandler()]


class NginxCnfController(CnfController):
    def __init__(self):
        nginx_conf_path = __nginx__['nginx.conf']
        CnfController.__init__(self, BEHAVIOUR, nginx_conf_path, 'nginx', {
            "on": '1',
            "'off'": '0',
            'off': '0'
        })
Beispiel #20
0
		initdv2.wait_sock(self.socks[0])
				
		
	def status(self):
		if self._running:
			return initdv2.Status.RUNNING
		else:
			return initdv2.Status.NOT_RUNNING
		
	@property
	def _running(self):
		rcode = system2((RABBITMQCTL, 'status'), raise_exc=False)[2]
		return False if rcode else True
			
		
initdv2.explore(SERVICE_NAME, RabbitMQInitScript)

	
	
class RabbitMQ(object):
	_instance = None
	
	def __new__(cls, *args, **kwargs):
		if not cls._instance:
			cls._instance = super(RabbitMQ, cls).__new__(
								cls, *args, **kwargs)
		return cls._instance
	

	def __init__(self):
		self._cnf = bus.cnf
Beispiel #21
0
                raise InitdError(e)
        else:
            raise InitdError("Service '%s' is not running" % self.name, InitdError.NOT_RUNNING)

    @staticmethod
    def _main_process_started():
        res = False
        try:
            out = system2(("ps", "-G", __apache__["group"], "-o", "command", "--no-headers"), raise_exc=False)[0]
            res = __apache__["bin_path"] in out
        except (Exception, BaseException):
            pass
        return res


initdv2.explore("apache", ApacheInitScript)


def get_virtual_host_path(hostname, port):
    ext = __apache__["vhost_extension"]
    end = "%s-%s%s" % (hostname, port, ext)
    return os.path.join(__apache__["vhosts_dir"], end)


def get_updated_file_names(virtual_host_file_names):
    ext = __apache__["vhost_extension"]

    plaintext_pattern = re.compile("(.+)\.vhost.conf")
    ssl_pattern = re.compile("(.+)-ssl%s" % ext)
    newstyle_pattern = re.compile("(\d+)%s" % ext)
Beispiel #22
0
            if self.running:
                with open(self.pid_file) as f:
                    pid = int(f.read().strip())
                try:
                    os.getpgid(pid)
                except OSError:
                    os.remove(self.pid_file)
                else:
                    os.kill(pid, signal.SIGTERM)

    def restart(self):
        self._start_stop_reload("stop")
        self._start_stop_reload("start")


initdv2.explore('chef', ChefInitScript)


class ChefHandler(Handler):
    def __init__(self):
        super(ChefHandler, self).__init__()
        bus.on(init=self.on_init)
        self._chef_client_bin = None
        self._chef_data = None
        self._run_list = []
        if linux.os.windows_family:
            self._client_conf_path = r'C:\chef\client.rb'
            self._validator_key_path = r'C:\chef\validation.pem'
            self._client_key_path = r'C:\chef\client.pem'
            self._json_attributes_path = r'C:\chef\first-run.json'
        else:
Beispiel #23
0
    def reload(self, reason=None):
        initdv2.ParametrizedInitScript.reload(self)

    def start(self):
        initdv2.ParametrizedInitScript.start(self)
        timeout = 60
        wait_until(
            lambda: self.status() == initdv2.Status.RUNNING,
            sleep=1,
            timeout=timeout,
            error_text=
            "%s state still isn't 'Running' In %s seconds after start " %
            (SERVICE_NAME, timeout))


initdv2.explore(SERVICE_NAME, PgSQLInitScript)


class PostgreSql(BaseService):

    _objects = None
    _instance = None
    service = None

    def __new__(cls, *args, **kwargs):
        if not cls._instance:
            cls._instance = super(PostgreSql,
                                  cls).__new__(cls, *args, **kwargs)
        return cls._instance

    def __init__(self):
Beispiel #24
0
        }

        run_detached(RABBITMQ_SERVER, args=['-detached'], env=env)
        initdv2.wait_sock(self.socks[0])

    def status(self):
        rcode = system2((RABBITMQCTL, 'status'), raise_exc=False)[2]
        _running = False if rcode else True

        if _running:
            return initdv2.Status.RUNNING
        else:
            return initdv2.Status.NOT_RUNNING


initdv2.explore(SERVICE_NAME, RabbitMQInitScript)


class RabbitMQ(object):
    _instance = None

    def __new__(cls, *args, **kwargs):
        if not cls._instance:
            cls._instance = super(RabbitMQ, cls).__new__(cls, *args, **kwargs)
        return cls._instance

    def __init__(self):
        self._logger = logging.getLogger(__name__)
        try:
            self.version = software.rabbitmq_software_info().version
        except:
Beispiel #25
0
                                   '\\1\n' + directory + ' r,\n' + '\\2\\3',
                                   app_rules)
            file.write(app_rules)
            file.close()
            apparmor_initd = initdv2.ParametrizedInitScript(
                'apparmor', '/etc/init.d/apparmor')
            try:
                apparmor_initd.reload()
            except InitdError, e:
                LOG.error('Cannot restart apparmor. %s', e)


def get_semanage():
    if linux.os['family'] == 'RedHat':
        semanage = software.which('semanage')
        if not semanage:
            mgr = pkgmgr.package_mgr()
            mgr.install('policycoreutils-python')
            semanage = software.which('semanage')
        return semanage


class MySQLPresetProvider(PresetProvider):
    def __init__(self):
        service = initdv2.lookup(SERVICE_NAME)
        config_mapping = {PRESET_FNAME: MySQLConf(MYCNF_PATH)}
        PresetProvider.__init__(self, service, config_mapping)


initdv2.explore(SERVICE_NAME, MysqlInitScript)
Beispiel #26
0
class MemcachedInitScript(initdv2.ParametrizedInitScript):
    def __init__(self):

        pid_file = None
        if disttool.is_redhat_based():
            pid_file = "/var/run/memcached/memcached.pid"
        elif disttool.is_debian_based():
            pid_file = "/var/run/memcached.pid"

        initd_script = '/etc/init.d/memcached'
        if not os.path.exists(initd_script):
            raise HandlerError("Cannot find Memcached init script at %s. Make sure that memcached is installed" % initd_script)

        initdv2.ParametrizedInitScript.__init__(self, 'memcached', initd_script, pid_file, socks=[initdv2.SockParam(11211)])

initdv2.explore('memcached', MemcachedInitScript)
BEHAVIOUR = SERVICE_NAME = BuiltinBehaviours.MEMCACHED

def get_handlers():
    return [MemcachedHandler()]

class MemcachedHandler(ServiceCtlHandler, FarmSecurityMixin):

    _logger = None
    _queryenv = None
    _ip_tables = None
    _port = None

    def __init__(self):
        self.preset_provider = MemcachedPresetProvider()
        preset_service.services[BEHAVIOUR] = self.preset_provider
Beispiel #27
0
        initdv2.ParametrizedInitScript.stop(self)
    
    def restart(self, reason=None):
        initdv2.ParametrizedInitScript.restart(self)
    
    def reload(self, reason=None):
        initdv2.ParametrizedInitScript.reload(self)
        
    def start(self):
        initdv2.ParametrizedInitScript.start(self)
        timeout = 60
        wait_until(lambda: self.status() == initdv2.Status.RUNNING, sleep=1, timeout=timeout, 
                error_text="%s state still isn't 'Running' In %s seconds after start " % (SERVICE_NAME, timeout))
    
    
initdv2.explore(SERVICE_NAME, PgSQLInitScript)


class PostgreSql(BaseService):
    
    _objects = None
    _instance = None
    service = None
        
        
    def __new__(cls, *args, **kwargs):
        if not cls._instance:
            cls._instance = super(PostgreSql, cls).__new__(
                                cls, *args, **kwargs)
        return cls._instance
    
Beispiel #28
0
            if self.running:
                with open(self.pid_file) as f:
                    pid = int(f.read().strip())
                try:
                    os.getpgid(pid)
                except OSError:
                    os.remove(self.pid_file)
                else:
                    os.kill(pid, signal.SIGTERM)

    def restart(self):
        self._start_stop_reload("stop")
        self._start_stop_reload("start")


initdv2.explore("chef", ChefInitScript)


class ChefHandler(Handler):
    def __init__(self):
        super(ChefHandler, self).__init__()
        bus.on(init=self.on_init)
        self._chef_client_bin = None
        self._chef_data = None
        self._run_list = []
        if linux.os.windows_family:
            self._client_conf_path = r"C:\chef\client.rb"
            self._validator_key_path = r"C:\chef\validation.pem"
            self._client_key_path = r"C:\chef\client.pem"
            self._json_attributes_path = r"C:\chef\first-run.json"
        else:
Beispiel #29
0
OPT_STORAGE_DEVICE_NAME = "device_name"
TMP_EBS_MNTPOINT        = '/mnt/temp_storage'
CASSANDRA_CONTROL_DATA  = 'cassandra'

class CassandraInitScript(initdv2.ParametrizedInitScript):
    def __init__(self):
        pl = bus.platform
        initd_script = "/etc/init.d/cassandra"
        if not os.path.exists(initd_script):
            raise HandlerError("Cannot find Cassandra init script at %s. Make sure that Cassandra is installed" % initd_script)

        pid_file = '/var/run/cassandra.pid'
        socks = [initdv2.SockParam(7000, conn_address = pl.get_private_ip(), timeout = 60)]
        initdv2.ParametrizedInitScript.__init__(self, 'cassandra', initd_script, pid_file, socks=socks)

initdv2.explore('cassandra', CassandraInitScript)


class CassandraMessages:

    CHANGE_RF                                       = 'Cassandra_ChangeReplFactor'
    '''
    @ivar changes list( dict( name = 'Keyspace1', rf = 3))
    '''
    CHANGE_RF_RESULT                        = 'Cassandra_ChangeReplFactorResult'
    '''
    @ivar status ok|error
    @ivar last_error
    @ivar rows list(dict(host=ip))
    '''