Mini Shell
3
{)cv � @ s� d dl Z ddlmZ ddlmZ ddlmZ d dlZd dlZd dlZddlm Z ej
d�Zdad d
� Z
G dd� de�Ze� ZdS )
� N� )�errors)�udev)�util)�_ZblivetFc C sH t s:tjddg� da dtj� kr:tjd� tjddg� tjdtj�S )NZmodprobeZlibfcT�bnx2xzfcoe: loading bnx2fc�bnx2fcz/sys/module/libfc) �_fcoe_module_loadedr �run_programZlsmod�log�info�os�access�X_OK� r r �/usr/lib/python3.6/fcoe.py�has_fcoe! s
r c @ sl e Zd ZdZdd� Zdd� Zdd� Zdd � Zd
d� Zdd
� Z dd� Z
ddd�Zdd� Zdd� Z
ddd�ZdS )�FCoEa� FCoE utility class.
This class will automatically discover and connect to EDD configured
FCoE SAN's when the startup() method gets called. It can also be
used to manually configure FCoE SAN's through the add_san() method.
As this class needs to make sure certain things like starting fcoe
daemons and connecting to firmware discovered SAN's only happens once
and as it keeps a global list of all FCoE devices it is
implemented as a Singleton.
.. warning::
Since this is a singleton class, calling deepcopy() on the instance
just returns ``self`` with no copy being created.
c C s d| _ d| _g | _g | _d S )NF)�started�lldpad_started�nicsZ
added_nics)�selfr r r �__init__? s z
FCoE.__init__c C s | S )Nr )r r r r �__call__F s z
FCoE.__call__c C s | S )Nr )r Z memo_dictr r r �__deepcopy__I s zFCoE.__deepcopy__c C s t jd� tj� d S )N�
)�time�sleepr Zsettle)r r r r �
_stabilizeM s
zFCoE._stabilizec C s� yt jddg�}W n. tk
r@ } ztjd|j� d S d }~X nX |j� jd�\}}}| sd|dkrxtjd|j� � d S | j |�dk}tjd ||� | j
||d
d� d S )
Nz/usr/libexec/fcoe/fcoe_edd.shz-iz Failed to read FCoE EDD info: %s�=ZNICzNo FCoE EDD info found: %sr r z(FCoE NIC found in EDD: %s, using dcb: %sT)�dcb� auto_vlan)r r )r Zcapture_output�OSErrorr r �strerror�strip� partition�rstrip�
_iface_driver�add_san)r Zbuf�e�keyZ_equals�valr r r r �
_start_eddR s zFCoE._start_eddc C s&