MSV FM

[email protected]: ~ $
Path : /lib/fm-agent/library/__pycache__/
File Upload :
Current < : //lib/fm-agent/library/__pycache__/plugin_manager.cpython-36.pyc

3

��f(,�@s�ddlmZddlZddlZddlZddlZddlZddlZddlZyddl	m
Z
WnddlmZ
YnXyddlZWnddl
jZYnXyddlZWnddlZYnXddd�ZGdd�de�Zd	d
�ZdS)�)�PluginN)�sha1)�shacCsJ|dkri}|j|dd��t|d�}tt|j�|d�||�|j�dS)N�__main__)�__file__�__name__�rb�exec)�update�openr	�compile�read�close)�filepath�globals�locals�f�r�+/usr/lib/fm-agent/library/plugin_manager.py�	execfile3s

rc@sPeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zedd��Z	d
d�Z
dd�ZdS)�
PluginManagercGs�tj|jj�|_||_||_||_|j|�|_	d|_
d|_i|_t
jj|j�r�tj�}|j|j�xf|j�D]Z}y|jdd�}Wnd}YnXd|i|j|<x$|j|�D]\}}||j||<q�WqlWdS)N�agent�debugF)�logging�	getLogger�	__class__r�log�db�config_file�directories�
_load_plugins�plugins�	_metadata�_hashed_metadata�config�os�path�exists�configparser�ConfigParserr
�sections�get�items)�selfrrr�textkeyr�k�vrrr�__init__%s&
zPluginManager.__init__cCs|jjdd�}|r||d<dS)N�dem�wifi_results)r$r+)r-r3Z
dem_configrrr�add_dem_wifi_results=sz"PluginManager.add_dem_wifi_resultscCs8|jd}tjdd�}d}|jd�d}|jd�d}yHtj|�}d|j�krf|j�jd�jd�d}|j|j	��|j
�Wn(tk
r�|jj
dtj��d	SX|dk�r0yPtj|j�}x>|j�D]2}	|	jd�r�|jjd
|	�|j|	|�|d7}q�WWn*tk
�r,|jj
dtj��YnXn�|dk�r�yTtj|j�}
xB|
j�D]6}	|	jd��rR|jjd
|	�|
j|	|�|d7}�qRWWn*tk
�r�|jj
dtj��YnXnR|dk�r�|jjd
|�tjd|jtjj||�f�|d7}n|jj
d|�|�r$|jjd|�tjd|j�d	S)zu
        Grab the remote url and extract the contents, putting them in the
        appropiate plugin folder.
        �F)�deleter�.�/zcontent-dispositionzUnable to download URL: %sN�tar�tgzz.pyz  Installing plugin %sz"Unable to extract tar contents: %s�zipz"Unable to extract zip contents: %s�pyzcp %s %sz5Unable to install Agent Plugin, unknown extension: %sz
Installed %s Agent pluginszrm -f %s���r=r=r=)r9r:)r�tempfileZNamedTemporaryFile�split�urllib2�urlopen�info�	getheader�writer
r�	Exceptionr�error�	traceback�
format_exc�tarfiler�nameZgetnames�endswith�extract�zipfileZZipFileZnamelistr%�systemr&�join)r-�url�base_custom_plugin_dirrZ
num_installedZext�fname�r�t�file�zrrr�install_remote_pluginsBsT






z$PluginManager.install_remote_pluginsc	Cs4y�|jjdi�jd�}d}t|dd�r�|j|kr�|jjd�d}y|jd|}Wn<|jdkrx|jdkrxdd	i}n|jj	d
|�dSYnX|j
|j|�}|jj|ji�}|jdd�}|r�|j||j|j|�}n|j
|j|j|�}|dk	r�||9}Wn4tk
�r.|jjd
|j|jtj�f�dSX|S)Nr�
server_key�:r5�docker_containersZdockerzstatus.runningZStateZdeletedz#Could not find container with id %s�scaleg�?z%s/%s check failed: %sr=)r$r+�getattrrXr?r�plugin_textkey�resource_textkeyrrFr!Zcheck_docker�option�checkrE�	exceptionrGrH)	r-�scheduleZself_key�	container�container_id�pluginr$r[�valuerrrr`ws6



zPluginManager.checkcs�i�d}tjj�j�rftj�}|j�j�y|jdd�}Wnd}YnX|rftt	t
j|jd���}���fdd�}xJ|�D]@}t
|t�r~t|t�r~t|d�r~|j|kr~|jdkr~|�|j<q~W�S)	N�r�plugin_blacklist�,c
3s�x�D�]}�jjd|�x�tj|�D]�}y�|d
d�dksF|dkrHw(tjj||�}i}i}tjddkrzt|||�nt	|||�xt
|j��D]
}|Vq�W�jjd|�Wq(t
k
r�tj�dd�\}}�jjd|��jj|�w(Yq(Xq(W�jjd	t���qWdS)NzLooking in directory %r�z.pyz__init__.pyrz	Loaded %r�z#Error importing plugin %s, skippingzLoaded %d plugins���)rrBr%�listdirr&rO�sys�version_inforZexecfile�list�valuesrrE�exc_info�len)Z
plugin_dirrJZplugin_file�	f_globals�f_locals�objrT�e)rr!r-rr�plugin_file_checker�s,
z8PluginManager._load_plugins.<locals>.plugin_file_checkerr.ZTEMPLATE_PLUGIN)r%r&r'rr(r)r
r+rp�map�str�stripr?�
isinstance�type�
issubclassr�hasattrr.)r-rrhrrxrvr)rr!r-rr �s$
"

zPluginManager._load_pluginscCs�|jdkr�i}x�t|jj��D]�}|jj|ji�}yt|j|��}Wn|j	j
d|j�wYnX|j	jdtt|j
���|j�t|d|j�}||f||j<qW||_|jS)Nzerror getting metadata from %rzgot %d textkeys for %r�label)r"rpr!rqr$r+r.�format_metadata�get_metadatarrarBrs�keysr\)r-�metadatarer$�metar�rrrr��s
zPluginManager.metadatac	Cs�|jdkr�g}xvt|jj��D]d\}\}}g}x6t|j��D]&\}}tt|��}|jt||f��q<W|j�|jt|||f��qW|j�tt|�j	��j
�|_|jS)N)r#rpr�r,�sorted�repr�append�sortr�encode�	hexdigest)	r-Z	flat_datar.r��plugin_metadataZplugin_optionsZ
resource_nameZresource_metadataZ
resource_metarrr�hashed_metadata�s
zPluginManager.hashed_metadatacCs,|jjd|j�|jd�|jd|j�kS)Nz$comparing metadata hashes %r with %r�
last_metadata)rrBr�r)r-rrr�is_metadata_staleszPluginManager.is_metadata_staleN)r�
__module__�__qualname__r1r4rWr`r �propertyr�r�r�rrrrr$s5'<rcCs�x�|j�D]�\}}|d}g}|s$q
xT|D]L}tjddkrXt|�tkrv|jd|i�q*t|�ttfkr*|jd|i�q*W|r�||d<|jd�s
ddi|d<q
W|S)z�
    Go over the metadata entry and make sure the option resources
    are matching to the new style of dictionaries if they
    are a string.
    �optionsrrj�resourceZoptions_schema�string)r,rnror}rzr��unicoder+)r�r��entryr�Znew_optionsr_rrrr�	s 

r�)NN)�
agent_utilrrr%rnrGr>rIrM�hashlibrrr@�urllib.request�requestr)r(r�objectrr�rrrr�<module>s.
f
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 *