File: //lib/python3.6/site-packages/ipaplatform/base/__pycache__/services.cpython-36.pyc
3
�d[e�I � @ s. d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl m
Z
ddlmZ ddl
mZ ddlmZ eje�Zdd d
ddd
ddddddddddddddddddd d!d"d#d$d%d&gZd'gd(d)gd(d)gd(d)gd*�Zd+ZG d,d-� d-e�ZG d.d/� d/�ZG d0d1� d1e�Zd5d2d3�ZeZei �Zddd4gZdS )6zj
This base module contains default implementations of IPA interface for
interacting with system services.
� )�absolute_importN)�ipautil)�paths)�tasks)�MappingZ
certmonger�dirsrvZhttpdZipaZkrb5kdcZdbusZnslcdZnscdZntpdZportmapZrpcbindZkadminZsshdZautofsZrpcgssdZ rpcidmapdZpki_tomcatdZchronydZ
domainnameZnamedZ
ods_enforcerdZods_signerdZgssproxyz nfs-utilsZsssdZNetworkManagerzipa-custodiazipa-dnskeysyncdzipa-otpdzipa-ods-exporterzsystemd-resolvedi� i� i� )r z[email protected]
pki-tomcatzpki-tomcatdg�������?c @ s@ e Zd ZdZdd� Zdd� Zdd� Zdd � Zd
d� Zdd
� Z dS )�
KnownServicesz�
KnownServices is an abstract class factory that should give out instances
of well-known platform services. Actual implementation must create these
instances as its own attributes on first access (or instance creation)
and cache them.
c C s
|| _ d S )N)�_KnownServices__d)�self�d� r �/usr/lib/python3.6/services.py�__init__N s zKnownServices.__init__c C s
| j | S )N)r )r
�keyr r r
�__getitem__Q s zKnownServices.__getitem__c C s
t | j�S )N)�iterr )r
r r r
�__iter__T s zKnownServices.__iter__c C s
t | j�S )N)�lenr )r
r r r
�__len__W s zKnownServices.__len__c C s t j| j�S )N)�sixZ
itervaluesr )r
r r r
�__call__Z s zKnownServices.__call__c C s, y
| j | S tk
r& t|��Y nX d S )N)r �KeyError�AttributeError)r
�namer r r
�__getattr__] s
zKnownServices.__getattr__N)
�__name__�
__module__�__qualname__�__doc__r r r r r r r r r r
r G s r c @ s� e Zd ZdZd%dd�Zd&dd�Zd'd d
�Zd(dd�Zd)d
d�Zd*dd�Z d+dd�Z
dd� Zd,dd�Zd-dd�Z
d.dd�Zd/dd�Zd0dd�Zd1dd �Zd2d!d"�Zd3d#d$�ZdS )4�PlatformServicez�
PlatformService abstracts out external process running on the system
which is possible to administer (start, stop, check status, etc).
Nc C sB dd l }|| _|d k r|| _n |j| _tjdj| d�tdd� d S )Nr zC{s.__class__.__name__}('{s.service_name}', api=None) is deprecated.)�s� )�
stacklevel)�ipalib�service_name�api�warnings�warn�format�RuntimeWarning)r
r$ r% r# r r r
r k s zPlatformService.__init__� Tc C s� |sdS g }y&t tjd��}tj|�}W dQ R X W n tk
rF Y nX | j|kr^|j| j� t tjd��}tj||� W dQ R X dS )z�
When a service is started record the fact in a special file.
This allows ipactl stop to always stop all services that have
been started via ipa tools
N�r�w) �openr �
SVC_LIST_FILE�json�load� Exceptionr$ �append�dump)r
�
instance_name�capture_output�wait�update_service_list�svc_list�fr r r
�starty s
zPlatformService.startc C s� |sdS g }y&t tjd��}tj|�}W dQ R X W n tk
rF Y nX x| j|krb|j| j� qJW t tjd��}tj||� W dQ R X dS )zQ
When a service is stopped remove it from the service list file.
Nr+ r, ) r- r r. r/ r0 r1 r$ �remover3 )r
r4 r5 r7 r8 r9 r r r
�stop� s zPlatformService.stopc C s d S )Nr )r
r4 r5 r6 r r r
�reload_or_restart� s z!PlatformService.reload_or_restartc C s d S )Nr )r
r4 r5 r6 r r r
�restart� s zPlatformService.restartc C s d S )Nr )r
r4 r5 r6 r r r
�try_restart� s zPlatformService.try_restartc C s dS )NFr )r
r4 r6 r r r
�
is_running� s zPlatformService.is_runningc C s dS )NFr )r
r r r
�is_installed� s zPlatformService.is_installedc C s dS )NFr )r
r4 r r r
�
is_enabled� s zPlatformService.is_enabledc C s dS )NFr )r
r4 r r r
� is_masked� s zPlatformService.is_maskedc C s d S )Nr )r
r4 r r r
�enable� s zPlatformService.enablec C s d S )Nr )r
r4 r r r
�disable� s zPlatformService.disablec C s d S )Nr )r
r4 r r r
�mask� s zPlatformService.maskc C s d S )Nr )r
r4 r r r
�unmask� s zPlatformService.unmaskc C s d S )Nr )r
r4 r r r
�install� s zPlatformService.installc C s d S )Nr )r
r4 r r r
r; � s zPlatformService.remove)N)r* TTT)r* TT)r* TT)r* TT)r* TT)r* T)r* )r* )r* )r* )r* )r* )r* )r* )r r r r r r: r<