Пример #1
0
    def check(self):
        if linux.os['family'] in ('RedHat',
                                  'Oracle') and linux.os['version'] >= (6, 0):
            # Avoid "Can't locate Time/HiRes.pm in @INC"
            # with InnoDB Backup Utility v1.5.1-xtrabackup
            pkgmgr.installed('perl-Time-HiRes')

        mgr = pkgmgr.package_mgr()
        if not 'percona' in mgr.repos():
            if linux.os['family'] in ('RedHat', 'Oracle'):
                url = 'http://www.percona.com/downloads/percona-release/percona-release-0.0-1.%s.rpm' % linux.os[
                    'arch']
                pkgmgr.YumPackageMgr().localinstall(url)
                if linux.os.amazon:
                    linux.system(("sed -i 's/\$releasever/latest/g' "
                                  "/etc/yum.repos.d/Percona.repo"),
                                 shell=True)
            else:
                try:
                    codename = linux.os['lsb_codename']
                except KeyError:
                    codename = linux.ubuntu_release_to_codename[
                        linux.os['lsb_release']]
                pkgmgr.apt_source(
                    'percona.list',
                    ['deb http://repo.percona.com/apt %s main' % codename],
                    gpg_keyserver='hkp://keys.gnupg.net',
                    gpg_keyid='CD2EFD2A')
            mgr.updatedb()
        if software.mysql_software_info().version < (5, 5):
            self.package = 'percona-xtrabackup-21'
        else:
            self.package = 'percona-xtrabackup'

        return super(PerconaExec, self).check()
Пример #2
0
    def check(self):
        if linux.os['family'] in ('RedHat', 'Oracle') and linux.os['version'] >= (6, 0):
            # Avoid "Can't locate Time/HiRes.pm in @INC"
            # with InnoDB Backup Utility v1.5.1-xtrabackup
            pkgmgr.installed('perl-Time-HiRes')         

        mgr = pkgmgr.package_mgr()
        if not 'percona' in mgr.repos():
            if linux.os['family'] in ('RedHat', 'Oracle'):
                url = 'http://www.percona.com/downloads/percona-release/percona-release-0.0-1.%s.rpm' % linux.os['arch']
                pkgmgr.YumPackageMgr().localinstall(url)
                if linux.os.amazon:
                    linux.system(("sed -i 's/\$releasever/latest/g' "
                                    "/etc/yum.repos.d/Percona.repo"), shell=True)
            else:
                try:
                    codename = linux.os['lsb_codename']
                except KeyError:
                    codename = linux.ubuntu_release_to_codename[linux.os['lsb_release']]
                pkgmgr.apt_source(
                        'percona.list', 
                        ['deb http://repo.percona.com/apt %s main' % codename],
                        gpg_keyserver='hkp://keys.gnupg.net',
                        gpg_keyid='CD2EFD2A')
            mgr.updatedb()
        if software.mysql_software_info().version < (5, 5):
            self.package = 'percona-xtrabackup-21'
        else:
            self.package = 'percona-xtrabackup'

        return super(PerconaExec, self).check()
Пример #3
0
    def check(self):
        if linux.os["family"] in ("RedHat", "Oracle") and linux.os["version"] >= (6, 0):
            # Avoid "Can't locate Time/HiRes.pm in @INC"
            # with InnoDB Backup Utility v1.5.1-xtrabackup
            pkgmgr.installed("perl-Time-HiRes")

        mgr = pkgmgr.package_mgr()
        if not "percona" in mgr.repos():
            if linux.os["family"] in ("RedHat", "Oracle"):
                url = "http://www.percona.com/downloads/percona-release/percona-release-0.0-1.%s.rpm" % linux.os["arch"]
                pkgmgr.YumPackageMgr().localinstall(url)
            else:
                try:
                    codename = linux.os["lsb_codename"]
                except KeyError:
                    codename = linux.ubuntu_release_to_codename[linux.os["lsb_release"]]
                pkgmgr.apt_source(
                    "percona.list",
                    ["deb http://repo.percona.com/apt %s main" % codename],
                    gpg_keyserver="hkp://keys.gnupg.net",
                    gpg_keyid="CD2EFD2A",
                )
            mgr.updatedb()

        return super(PerconaExec, self).check()
Пример #4
0
    def check(self):
        if linux.os['family'] in ('RedHat', 'Oracle') and linux.os['version'] >= (6, 0):
            # Avoid "Can't locate Time/HiRes.pm in @INC"
            # with InnoDB Backup Utility v1.5.1-xtrabackup
            pkgmgr.installed('perl-Time-HiRes')         

        mgr = pkgmgr.package_mgr()
        if not 'percona' in mgr.repos():
            if linux.os['family'] in ('RedHat', 'Oracle'):
                url = 'http://www.percona.com/downloads/percona-release/percona-release-0.0-1.%s.rpm' % linux.os['arch']
                pkgmgr.YumPackageMgr().localinstall(url)
            else:
                try:
                    codename = linux.os['lsb_codename']
                except KeyError:
                    codename = linux.ubuntu_release_to_codename[linux.os['lsb_release']]
                pkgmgr.apt_source(
                        'percona.list', 
                        ['deb http://repo.percona.com/apt %s main' % codename],
                        gpg_keyserver='hkp://keys.gnupg.net',
                        gpg_keyid='CD2EFD2A')
            mgr.updatedb()


        return super(PerconaExec, self).check()
Пример #5
0
    def get_ready_behaviours(self):
        LOG.info('Detecting supported behaviors...')
        if linux.os['family'] != 'Windows':
            system_packages = pkgmgr.package_mgr().list()
            possible_behaviors = config.BuiltinBehaviours.values()
        else:
            system_packages = []
            possible_behaviors = ('base', 'chef')

        msg = (
            "Scalr built-in automation: checking for supported software.\n"
            "If installed software isn't detected, "
            "review the Scalr Wiki: https://scalr-wiki.atlassian.net/wiki/x/IoB1"
        )
        LOG.info(msg)

        ready_behaviors = list()
        for behavior in possible_behaviors:
            if behavior in ['base', 'mongodb'
                            ] or behavior not in api.api_routes.keys():
                continue
            try:
                api_cls = util.import_class(api.api_routes[behavior])
                installed = api_cls.check_software(system_packages)
                ready_behaviors.append(behavior)
                LOG.info('%s: Available. Installed version: %s', behavior,
                         installed[1])
            except (exceptions.NotFound, exceptions.UnsupportedBehavior,
                    ImportError), e:
                if isinstance(e, exceptions.UnsupportedBehavior):
                    LOG.info('%s: %s', behavior, e.args[1])
                else:
                    LOG.info('%s: %s', behavior, e)
                continue
Пример #6
0
    def check(self):
        if linux.os['family'] in ('RedHat', 'Oracle') and linux.os['version'] >= (6, 0):
            # Avoid "Can't locate Time/HiRes.pm in @INC"
            # with InnoDB Backup Utility v1.5.1-xtrabackup
            pkgmgr.installed('perl-Time-HiRes')         

        mgr = pkgmgr.package_mgr()
        if not 'percona' in mgr.repos():
            if linux.os['family'] in ('RedHat', 'Oracle'):
                url = 'http://www.percona.com/downloads/percona-release/percona-release-0.0-1.%s.rpm' % linux.os['arch']
                pkgmgr.YumPackageMgr().localinstall(url)
            else:
                try:
                    codename = linux.os['lsb_codename']
                except KeyError:
                    codename = linux.ubuntu_release_to_codename[linux.os['lsb_release']]
                pkgmgr.apt_source(
                        'percona.list', 
                        ['deb http://repo.percona.com/apt %s main' % codename],
                        gpg_keyserver='hkp://keys.gnupg.net',
                        gpg_keyid='CD2EFD2A')
            mgr.updatedb()


        return super(PerconaExec, self).check()
Пример #7
0
def rabbitmq_software_info():
    if linux.os.windows_family:
        raise SoftwareError()

    pkg_mgr = pkgmgr.package_mgr()
    version = pkg_mgr.info('rabbitmq-server')['installed']
    version = re.search('[\d\.]+', version).group(0)
    return SoftwareInfo('rabbitmq', version, version)
Пример #8
0
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
Пример #9
0
def rabbitmq_software_info():
    if linux.os.windows_family:
        raise SoftwareError()

    pkg_mgr = pkgmgr.package_mgr()
    version = pkg_mgr.info('rabbitmq-server')['installed']
    version = re.search('[\d\.]+', version).group(0)
    return SoftwareInfo('rabbitmq', version, version)
Пример #10
0
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
Пример #11
0
 def __init__(self, **kwds):
     self._update_self_dict(kwds)
     self.pkgmgr = pkgmgr.package_mgr()
     self.daemon = initdv2.Daemon('scalarizr')
     self.op_api = operation.OperationAPI()
     self.dist = '{name} {release} {codename}'.format(**linux.os)
     self.state = 'noop'
     self.meta = metadata.Metadata()
     self.shutdown_ev = threading.Event()
     self.early_bootstrapped = False
Пример #12
0
 def __init__(self, **kwds):
     self._update_self_dict(kwds)
     self.pkgmgr = pkgmgr.package_mgr()
     self.daemon = initdv2.Daemon("scalarizr")
     self.op_api = operation.OperationAPI()
     self.dist = "{name} {release} {codename}".format(**linux.os)
     self.state = "noop"
     self.meta = metadata.Metadata()
     self.shutdown_ev = threading.Event()
     self.early_bootstrapped = False
Пример #13
0
def apache_software_info():

    binary_name = "httpd" if linux.os.redhat_family else "apache2ctl"
    binary = which(binary_name)
    if not binary:
        raise SoftwareError("Can't find executable for apache http server")

    try:
        out = system2((binary, '-V'))[0]
    except PopenError, e:
        pkg_mgr = pkgmgr.package_mgr()
        version_string = pkg_mgr.info('apache2')['installed']
Пример #14
0
def apache_software_info():

    binary_name = "httpd" if linux.os.redhat_family else "apache2ctl"
    binary = which(binary_name)
    if not binary:
        raise SoftwareError("Can't find executable for apache http server")

    try:
        out = system2((binary, '-V'))[0]
    except PopenError, e:
        pkg_mgr = pkgmgr.package_mgr()
        version_string = pkg_mgr.info('apache2')['installed']
Пример #15
0
 def _gzip_bin(self):
     if self.try_pigz:
         mgr = pkgmgr.package_mgr()
         if not mgr.info('pigz')['installed']:
             try:
                 pkgmgr.epel_repository()
                 mgr.installed("pigz")
             except:
                 LOG.debug("PIGZ install with epel failed, using gzip."\
                                   " Caught %s", repr(sys.exc_info()[1]))
             else:
                 return self.pigz_bin
         else:
             return self.pigz_bin
     return self.gzip_bin
Пример #16
0
 def check_software(cls, system_packages=None):
     try:
         if linux.os.windows and cls.behavior != 'chef':
             raise exceptions.UnsupportedBehavior(
                 cls.behavior,
                 ("'{beh}' behavior is only supported on "
                  "Linux operation systems").format(beh=cls.behavior))
         elif not linux.os.windows:
             system_packages = system_packages or pkgmgr.package_mgr().list(
             )
         installed = cls.do_check_software(system_packages=system_packages)
         cls.software_supported = True
         return installed
     except:
         cls.software_supported = False
         e = sys.exc_info()[1]
         if isinstance(e, exceptions.UnsupportedBehavior):
             raise
         elif isinstance(e, pkgmgr.NotInstalledError):
             msg = 'Unavailable. Not installed.'
             raise exceptions.UnsupportedBehavior(cls.behavior, msg)
         elif isinstance(e, pkgmgr.VersionMismatchError):
             packages = list()
             for package in e.args[0]:
                 if package[1]:
                     packages.append('{0}-{1}'.format(
                         package[0], package[1]))
                 else:
                     packages.append(package[0])
             msg = 'Unavailable. Installed version {0} is not supported by Scalr on {1} {2}.'
             msg = msg.format(','.join(packages), linux.os['name'],
                              linux.os['version'])
             raise exceptions.UnsupportedBehavior(cls.behavior, msg)
         elif isinstance(e, SoftwareDependencyError):
             packages = list()
             for package in e.args[0]:
                 if package[1]:
                     packages.append('{0} {1}'.format(
                         package[0], package[1]))
                 else:
                     packages.append(package[0])
             msg = 'Unavailable. Installed, but missing additional dependencies: {0}.'
             msg = msg.format(','.join(packages))
             raise exceptions.UnsupportedBehavior(cls.behavior, msg)
         else:
             raise sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]
Пример #17
0
 def check_software(cls, system_packages=None):
     try:
         if linux.os.windows and cls.behavior != 'chef':
             raise exceptions.UnsupportedBehavior(cls.behavior, (
                 "'{beh}' behavior is only supported on "
                 "Linux operation systems").format(beh=cls.behavior)
             )
         system_packages = system_packages or pkgmgr.package_mgr().list()
         installed = cls.do_check_software(system_packages=system_packages)
         cls.software_supported = True
         return installed
     except:
         cls.software_supported = False
         e = sys.exc_info()[1]
         if isinstance(e, exceptions.UnsupportedBehavior):
             raise
         elif isinstance(e, pkgmgr.NotInstalledError):
             msg = 'Unavailable. Not installed.'
             raise exceptions.UnsupportedBehavior(cls.behavior, msg)
         elif isinstance(e, pkgmgr.VersionMismatchError):
             packages = list()
             for package in e.args[0]:
                 if package[1]:
                     packages.append('{0}-{1}'.format(package[0], package[1]))
                 else:
                     packages.append(package[0])
             msg = 'Unavailable. Installed version {0} is not supported by Scalr on {1} {2}.'
             msg = msg.format(','.join(packages), linux.os['name'], linux.os['version'])
             raise exceptions.UnsupportedBehavior(cls.behavior, msg)
         elif isinstance(e, SoftwareDependencyError):
             packages = list()
             for package in e.args[0]:
                 if package[1]:
                     packages.append('{0} {1}'.format(package[0], package[1]))
                 else:
                     packages.append(package[0])
             msg = 'Unavailable. Installed, but missing additional dependencies: {0}.'
             msg = msg.format(','.join(packages))
             raise exceptions.UnsupportedBehavior(cls.behavior, msg)
         else:
             raise sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]
Пример #18
0
def check_supported_behaviors(*args):
    # *args to adaptee as a handler function
    if linux.os.windows:
        return
    system_packages = pkgmgr.package_mgr().list()
    for behavior in __node__['behavior']:
        if behavior in ['base', 'mongodb'
                        ] or behavior not in api.api_routes.keys():
            continue
        try:
            api_cls = util.import_class(api.api_routes[behavior])
            api_cls.check_software(system_packages)
        except exceptions.NotFound as e:
            LOG.error(e)
        except exceptions.UnsupportedBehavior as e:
            if e.args[0] == 'chef':
                # We pass it, cause a lot of roles has chef behavior without chef installed on them
                continue
            __node__['messaging'].send('RuntimeError',
                                       body={
                                           'code': 'UnsupportedBehavior',
                                           'message': str(e)
                                       })
            raise sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]
Пример #19
0
    def _init_services(self):
        logger = logging.getLogger(__name__)
        cnf = bus.cnf
        ini = cnf.rawini
        server_id = ini.get('general', 'server_id')
        queryenv_url = ini.get('general', 'queryenv_url')
        messaging_adp = ini.get('messaging', 'adapter')

        # Set base URL
        pr = urlparse(queryenv_url)
        bus.scalr_url = urlunparse((pr.scheme, pr.netloc, '', '', '', ''))
        logger.debug("Got scalr url: '%s'" % bus.scalr_url)

        if not linux.os.windows and __node__['platform'].name == 'openstack':
            self._try_resolver(bus.scalr_url)

        # Create periodical executor for background tasks (cleanup, rotate, gc, etc...)
        bus.periodical_executor = PeriodicalExecutor()

        logger.debug("Initialize QueryEnv client")
        queryenv = QueryEnvService(queryenv_url, server_id,
                                   cnf.key_path(cnf.DEFAULT_KEY), '2008-12-16')
        queryenv_latest = queryenv.get_latest_version()
        queryenv = QueryEnvService(queryenv_url, server_id,
                                   cnf.key_path(cnf.DEFAULT_KEY),
                                   queryenv_latest)

        if tuple(map(int, queryenv_latest.split('-'))) >= (2012, 7, 1):
            scalr_version = queryenv.get_global_config()['params'].get(
                'scalr.version')
            if scalr_version:
                bus.scalr_version = tuple(map(int, scalr_version.split('.')))
                version_file = cnf.private_path('.scalr-version')
                with open(version_file, 'w') as fp:
                    fp.write(scalr_version)

        bus.queryenv_service = queryenv
        bus.queryenv_version = tuple(map(int, queryenv.api_version.split('-')))

        if __node__['state'] != 'importing':
            lfrp = bus.queryenv_service.list_farm_role_params(
                __node__['farm_role_id'])['params']
            __node__['base'].update(lfrp.get('base', {}))
        ports_non_default = self._select_control_ports()

        logger.debug("Initialize messaging")
        factory = MessageServiceFactory()
        try:
            params = dict(ini.items("messaging_" + messaging_adp))
            if ports_non_default:
                consumer_url = list(
                    urlparse(params[P2pConfigOptions.CONSUMER_URL]))
                consumer_url[1] = ':'.join(
                    (consumer_url[1].split(':')[0],
                     str(__node__['base']['messaging_port'])))
                params[P2pConfigOptions.CONSUMER_URL] = urlunparse(
                    consumer_url)

            params[P2pConfigOptions.SERVER_ID] = server_id
            params[P2pConfigOptions.CRYPTO_KEY_PATH] = cnf.key_path(
                cnf.DEFAULT_KEY)

            msg_service = factory.new_service(messaging_adp, **params)
            bus.messaging_service = msg_service
        except (BaseException, Exception):
            raise ScalarizrError(
                "Cannot create messaging service adapter '%s'" %
                (messaging_adp))

        optparser = bus.optparser
        if optparser and not optparser.values.import_server and linux.os[
                'family'] != 'Windows':
            system_packages = pkgmgr.package_mgr().list()
            for behavior in __node__['behavior']:
                if behavior in ['base', 'mongodb'
                                ] or behavior not in api.api_routes.keys():
                    continue
                try:
                    api_cls = util.import_class(api.api_routes[behavior])
                    api_cls.check_software(system_packages)
                except exceptions.NotFound as e:
                    logger.error(e)
                except exceptions.UnsupportedBehavior as e:
                    if e.args[0] == 'chef':
                        # We pass it, cause a lot of roles has chef behavior without chef installed on them
                        continue
                    __node__['messaging'].send('RuntimeError',
                                               body={
                                                   'code':
                                                   'UnsupportedBehavior',
                                                   'message': str(e)
                                               })
                    raise sys.exc_info()[0], sys.exc_info()[1], sys.exc_info(
                    )[2]

        logger.debug('Initialize message handlers')
        consumer = msg_service.get_consumer()
        consumer.listeners.append(MessageListener())

        producer = msg_service.get_producer()

        def msg_meta(queue, message):
            """
            Add scalarizr version to meta
            """
            message.meta.update({
                'szr_version':
                __version__,
                'timestamp':
                os_time.utcnow().strftime("%a %d %b %Y %H:%M:%S %z")
            })

        producer.on('before_send', msg_meta)

        Storage.maintain_volume_table = True

        if not bus.api_server:
            sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            api_port = 8010
            try:
                sock.connect(('0.0.0.0', api_port))
                api_port = 8009
                sock.close()
            except socket.error:
                pass
            STATE['global.api_port'] = api_port
            api_app = jsonrpc_http.WsgiApplication(
                rpc.RequestHandler(api.api_routes),
                cnf.key_path(cnf.DEFAULT_KEY))

            class ThreadingWSGIServer(SocketServer.ThreadingMixIn,
                                      wsgiref.simple_server.WSGIServer):
                pass

            bus.api_server = wsgiref.simple_server.make_server(
                '0.0.0.0',
                __node__['base']['api_port'],
                api_app,
                server_class=ThreadingWSGIServer)

        if ports_non_default:
            msg = msg_service.new_message(
                'HostUpdate', None, {
                    'base': {
                        'api_port': __node__['base']['api_port'],
                        'messaging_port': __node__['base']['messaging_port']
                    }
                })
            msg_service.get_producer().send(Queues.CONTROL, msg)
Пример #20
0
    def _init_services(self):
        logger = logging.getLogger(__name__)
        cnf = bus.cnf; ini = cnf.rawini
        server_id = ini.get('general', 'server_id')
        queryenv_url = ini.get('general', 'queryenv_url')
        messaging_adp = ini.get('messaging', 'adapter')

        # Set base URL
        pr = urlparse(queryenv_url)
        bus.scalr_url = urlunparse((pr.scheme, pr.netloc, '', '', '', ''))
        logger.debug("Got scalr url: '%s'" % bus.scalr_url)

        if not linux.os.windows and __node__['platform'].name == 'openstack':
            self._try_resolver(bus.scalr_url)

        # Create periodical executor for background tasks (cleanup, rotate, gc, etc...)
        bus.periodical_executor = PeriodicalExecutor()

        logger.debug("Initialize QueryEnv client")
        queryenv = QueryEnvService(queryenv_url, server_id, cnf.key_path(cnf.DEFAULT_KEY), '2008-12-16')
        queryenv_latest = queryenv.get_latest_version()
        queryenv = QueryEnvService(queryenv_url, server_id, cnf.key_path(cnf.DEFAULT_KEY), queryenv_latest)

        if tuple(map(int, queryenv_latest.split('-'))) >= (2012, 7, 1):
            scalr_version = queryenv.get_global_config()['params'].get('scalr.version')
            if scalr_version:
                bus.scalr_version = tuple(map(int, scalr_version.split('.')))
                version_file = cnf.private_path('.scalr-version')
                with open(version_file, 'w') as fp:
                    fp.write(scalr_version)

        bus.queryenv_service = queryenv
        bus.queryenv_version = tuple(map(int, queryenv.api_version.split('-')))

        if __node__['state'] != 'importing':
            lfrp = bus.queryenv_service.list_farm_role_params(__node__['farm_role_id'])['params']
            __node__['base'].update(lfrp.get('base', {}))
        ports_non_default = self._select_control_ports()

        logger.debug("Initialize messaging")
        factory = MessageServiceFactory()
        try:
            params = dict(ini.items("messaging_" + messaging_adp))
            if ports_non_default:
                consumer_url = list(urlparse(params[P2pConfigOptions.CONSUMER_URL]))
                consumer_url[1] = ':'.join((consumer_url[1].split(':')[0], str(__node__['base']['messaging_port'])))
                params[P2pConfigOptions.CONSUMER_URL] = urlunparse(consumer_url)

            params[P2pConfigOptions.SERVER_ID] = server_id
            params[P2pConfigOptions.CRYPTO_KEY_PATH] = cnf.key_path(cnf.DEFAULT_KEY)

            msg_service = factory.new_service(messaging_adp, **params)
            bus.messaging_service = msg_service
        except (BaseException, Exception):
            raise ScalarizrError("Cannot create messaging service adapter '%s'" % (messaging_adp))

        optparser = bus.optparser
        if optparser and not optparser.values.import_server and linux.os['family'] != 'Windows':
            system_packages = pkgmgr.package_mgr().list()
            for behavior in __node__['behavior']:
                if behavior in ['base', 'mongodb'] or behavior not in api.api_routes.keys():
                    continue
                try:
                    api_cls = util.import_class(api.api_routes[behavior])
                    api_cls.check_software(system_packages)
                except exceptions.NotFound as e:
                    logger.error(e)
                except exceptions.UnsupportedBehavior as e:
                    if e.args[0] == 'chef':
                        # We pass it, cause a lot of roles has chef behavior without chef installed on them
                        continue
                    __node__['messaging'].send(
                        'RuntimeError',
                        body={
                            'code': 'UnsupportedBehavior',
                            'message': str(e)
                        }
                    )
                    raise sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]

        logger.debug('Initialize message handlers')
        consumer = msg_service.get_consumer()
        consumer.listeners.append(MessageListener())

        producer = msg_service.get_producer()
        def msg_meta(queue, message):
            """
            Add scalarizr version to meta
            """
            message.meta.update({
                'szr_version': __version__,
                'timestamp': os_time.utcnow().strftime("%a %d %b %Y %H:%M:%S %z")
            })
        producer.on('before_send', msg_meta)

        Storage.maintain_volume_table = True

        if not bus.api_server:
            sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            api_port = 8010
            try:
                sock.connect(('0.0.0.0', api_port))
                api_port = 8009
                sock.close()
            except socket.error:
                pass
            STATE['global.api_port'] = api_port
            api_app = jsonrpc_http.WsgiApplication(rpc.RequestHandler(api.api_routes),
                                                cnf.key_path(cnf.DEFAULT_KEY))
            class ThreadingWSGIServer(SocketServer.ThreadingMixIn, wsgiref.simple_server.WSGIServer):
                pass
            bus.api_server = wsgiref.simple_server.make_server('0.0.0.0',
                                __node__['base']['api_port'], 
                                api_app, 
                                server_class=ThreadingWSGIServer)

        if ports_non_default:
            msg = msg_service.new_message('HostUpdate', None, {
                'base': {
                    'api_port': __node__['base']['api_port'],
                    'messaging_port': __node__['base']['messaging_port']
                }
            })
            msg_service.get_producer().send(Queues.CONTROL, msg)
Пример #21
0
def rabbitmq_software_info():

    pkg_mgr = pkgmgr.package_mgr()
    version = pkg_mgr.info('rabbitmq-server')['installed']
    version = re.search('[\d\.]+', version).group(0)
    return SoftwareInfo('rabbitmq', version, version)
Пример #22
0
def test_package_mgr():
    mgr = pkgmgr.package_mgr()
    assert isinstance(mgr, pkgmgr.YumPackageMgr)
Пример #23
0
def and_i_have_percona_repostory_on_machine(step, w1):
    mgr = pkgmgr.package_mgr()
    assert "percona" in mgr.repos()
Пример #24
0
def given_i_have_no_percona_repository_on_machine(step):
    mgr = pkgmgr.package_mgr()
    assert "percona" not in mgr.repos()
Пример #25
0
def given_i_have_no_percona_repository_on_machine(step):
    mgr = pkgmgr.package_mgr()
    assert 'percona' not in mgr.repos()
Пример #26
0
def rabbitmq_software_info():

    pkg_mgr = pkgmgr.package_mgr()
    version = pkg_mgr.info('rabbitmq-server')['installed']
    version = re.search('[\d\.]+', version).group(0)
    return SoftwareInfo('rabbitmq', version, version)
Пример #27
0
def test_package_mgr():
    mgr = pkgmgr.package_mgr()
    assert isinstance(mgr, pkgmgr.YumPackageMgr)
Пример #28
0
def and_i_have_percona_repostory_on_machine(step, w1):
    mgr = pkgmgr.package_mgr()
    assert 'percona' in mgr.repos()