2013-10-28 00:59:46 +04:00
# Copyright (C) 2009, 2013 Red Hat, Inc.
2009-11-22 19:18:53 +03:00
# Copyright (C) 2009 Cole Robinson <crobinso@redhat.com>
#
2018-04-04 16:35:41 +03:00
# This work is licensed under the GNU GPLv2 or later.
2018-03-20 22:00:02 +03:00
# See the COPYING file in the top-level directory.
2009-11-22 19:18:53 +03:00
2010-02-09 01:13:36 +03:00
from virtinst import Interface
2009-11-22 19:18:53 +03:00
2014-09-13 00:10:45 +04:00
from . libvirtobject import vmmLibvirtObject
2010-02-26 03:35:01 +03:00
2013-04-13 22:34:52 +04:00
2010-02-26 03:35:01 +03:00
class vmmInterface ( vmmLibvirtObject ) :
2013-07-07 16:42:57 +04:00
def __init__ ( self , conn , backend , key ) :
2013-09-23 16:34:50 +04:00
vmmLibvirtObject . __init__ ( self , conn , backend , key , Interface )
2010-02-26 03:35:01 +03:00
2015-04-10 16:15:44 +03:00
##########################
# Required class methods #
##########################
2010-02-26 03:35:01 +03:00
# Routines from vmmLibvirtObject
2015-04-10 16:15:44 +03:00
def _conn_tick_poll_param ( self ) :
return " polliface "
def class_name ( self ) :
return " interface "
2010-02-26 03:35:01 +03:00
def _XMLDesc ( self , flags ) :
2013-07-07 16:42:57 +04:00
return self . _backend . XMLDesc ( flags )
2015-04-10 01:02:42 +03:00
def _get_backend_status ( self ) :
2019-05-04 18:39:25 +03:00
# The libvirt object can be active or inactive, but our code
# doesn't care.
return True
2010-02-09 01:13:36 +03:00
2015-04-10 16:15:44 +03:00
def tick ( self , stats_update = True ) :
ignore = stats_update
2015-04-10 02:03:27 +03:00
self . _refresh_status ( )
2013-07-07 16:05:23 +04:00
2015-04-10 21:08:25 +03:00
def _init_libvirt_state ( self ) :
self . tick ( )
2009-11-22 19:18:53 +03:00
2015-04-10 01:02:42 +03:00
################
# XML routines #
################
2009-11-26 01:07:12 +03:00
def is_bridge ( self ) :
2019-05-04 18:39:25 +03:00
return self . get_xmlobj ( ) . type == " bridge "
2010-02-09 01:13:36 +03:00
2019-05-04 18:39:25 +03:00
def get_interface_names ( self ) :
return [ obj . name for obj in self . get_xmlobj ( ) . interfaces ]