MSV FM

[email protected]: ~ $
Path : /lib/fm-agent/library/
File Upload :
Current < : //lib/fm-agent/library/maintenance.py

import aggregator
import os
import logging
import traceback
import sys
try:
    import configparser
except Exception:
    # Python 3
    import ConfigParser as configparser


class Maintenance():

    def __init__(self, brand, agg_url, version, base_config_dir, pkg_dir, debug=False):
        self.brand = brand
        self.agg_url = agg_url
        self.version = version
        self.base_config_dir = base_config_dir
        self.pkg_dir = pkg_dir
        self.config_dir = os.path.join(self.base_config_dir, self.pkg_dir)
        self.config_file = os.path.join(self.config_dir,
                                        "%s_agent.cfg" % self.brand)
        self.base_log_dir = '/var/log'
        self.log_dir = os.path.join(self.base_log_dir, self.pkg_dir)
        self.log_file = os.path.join(self.log_dir, 'maintenance.log')
        self.log = logging.getLogger()
        log_format = logging.Formatter(
            "%(asctime)s - %(levelname)s - %(message)s"
        )
        stream_handler = logging.StreamHandler()
        stream_handler.setFormatter(log_format)
        self.log.addHandler(stream_handler)
        if debug:
            self.log.setLevel(logging.DEBUG)
        else:
            self.log.setLevel(logging.INFO)
        try:
            handler = logging.FileHandler(self.log_file)
            handler.setFormatter(log_format)
            self.log.addHandler(handler)
        except IOError:
            self.log.error('Unable to reach log location %s. Please correct' % self.log_file)
        try:
            self.config = configparser.RawConfigParser()
            self.config.read(self.config_file)
            self.server_key = self.config.get('agent', 'server_key')
            self.agg_url = self.config.get('agent',
                                           'aggregator_url') or self.agg_url
            self.client = aggregator.Client(self.agg_url,
                                            self.version,
                                            server_key=self.server_key)
        except Exception:
            self.log.error('Error when getting config file. Exiting')
            self.log.error(traceback.format_exc())
            sys.exit()

    def start(self, duration, metric_tags=None):
        """
        Request to the aggregator that we start the maintenance on the server.
        """
        self.log.info('Starting maintenance procedure.')
        try:
            duration = int(duration)
        except (TypeError, ValueError):
            self.log.warning('Unrecognized duration %s. Must be given in minutes. Exiting' % duration)
            sys.exit(1)
        try:
            response = self.client.maintenance(duration, metric_tags)
        except Exception:
            self.log.debug(traceback.format_exc())
            self.log.info('There was an error performing the request. Please try again or contact support')
            sys.exit(1)
        if duration > 1:
            text = "minutes"
        else:
            text = "minute"
        self.log.info("This instance will go under maintenance for %s %s shortly" % (str(duration), text))
        sys.exit(0)

    def end(self):
        """
        Request to the aggregator that we end all maintenances in the server.
        """
        self.log.info('Starting maintenance shutdown.')
        try:
            response = self.client.end_maintenance()
        except Exception:
            self.log.debug(traceback.format_exc())
            self.log.info('There was an error performing the request. Please try again or contact support')
            sys.exit(1)
        self.log.info("Any active maintenance periods in the server will be ended immediately.")
        sys.exit(0)
Bethany
Bethany
0%

THE FINEST HOTEL NEAR LAKE KIVU

The Perfect Base For You

Required fields are followed by *





EC1A68011

About Us

Delicious Interior With The Pinch Of Everything

Bethany Investment group is Presbyterian church in Rwanda(EPR) company that manage Hotel and Guest house in Karongi (Bethany Hotel), ISANO branch in GIKONDO(Kigali), Kiyovu branch(Kigali), AMIZERO branch(Nyagatare-East) and Gisenyi Branch(Rubavu).

Accomodation

Get a Comfortable Room
Feel The Comfort

Get a comfortable room and feel our hotel’s comfort. Bethany Hotel features a variety of fully furnished rooms with extra space, Executive rooms, Deluxe rooms with a beautiful lake view and garden space, Deluxe rooms, comfort rooms, family rooms and standard rooms at your service.

Standard Single

Services

We Provide Top Class Facility
Especially For You

Beach BBQ Party

Kick back on the beach& and enjoy our berbecue from our masterchef

Breakfast

Kick back at our hotels& enjoy our breakfast from our masterchef

Conference Hall

Kick back at our hotels& enjoy our conference halls from all bethany branches

Enjoy with your partner

Honeymoon Package

80%

Get In Touch

Don’t Miss Any Update

    +

    Search your Room

    Required fields are followed by *