verinec.importer.parser.ethernet
Class ImportEthernet

java.lang.Object
  extended by verinec.importer.parser.ethernet.ImportEthernet
All Implemented Interfaces:
IServiceParser

public class ImportEthernet
extends Object
implements IServiceParser

Import the interface configuration files of a RedHat system.
The class reads a local or remote /etc/sysconfig/network-scripts directory containing the interface configuration files (ifcfg-ifname files).
Imports the configuration data of the network interface cards, and creates a the VeriNeC <hardware> XML element.
This class can be the level to import the configurations of different interfaces, e.g. Ethernet cards, serial bindings or wlan. At the moment only the import of Ethernet cards is implemented. (Optionally including the virtual loopback device.) Other realisations could be connected with VeriNeC here.
The ethernet import is flawed: It relies on the file names, only interfaces beginning with "eth" are imported. But Redhat uses the nickname of an interface for the filename, which can be anything. Additionally, the alias or virtual interfaces must be in the form eth0:0 to be correctly treated.

Author:
geraldine.antener at unifr.ch

Nested Class Summary
 class ImportEthernet.EthernetConfig
          Configuration dialog and container for ethernet import.
 
Field Summary
(package private)  String aliassep
          Value of the separator in alias interface filenames.
(package private)  File configFilesDir
          The directroy containing the ifcfg-ifname configuratin files.
(package private)  ImportEthernet.EthernetConfig configPanel
          Configuration for ethernet import.
 Element hardware
          The <hardware> element
private  Logger log
           
private  String rawconfig
          Store information from the file in case it is needed.
 
Constructor Summary
ImportEthernet()
           
 
Method Summary
private  String doImport(ImporterEnvironment environment)
          Import configuration from a local directory.
 JPanel getConfigPanel()
          Get the configuration panel to configure import of ethernet config.
 String getRawConfiguration()
          Get the raw configuration, that is the configuratio ninformation of the implementation of service.
(package private)  String lastToken(String filename, String divisor)
          Devide the String filname in tokens seperated by the String divisor.
 void notifyMode(ImporterDialog.SettingsPanelBase mode)
          Notify about mode change.
private  String remoteImport(ImporterEnvironment environment)
          Make a local copy of the remote system's "/etc/sysconfig/network-scripts" directory.
 void runImport(ImporterEnvironment environment)
          Perform import if activated.
 void updateNode(PCNode node)
          Update the PCNode with new information.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private Logger log

configPanel

ImportEthernet.EthernetConfig configPanel
Configuration for ethernet import.


hardware

public Element hardware
The <hardware> element


configFilesDir

File configFilesDir
The directroy containing the ifcfg-ifname configuratin files. (Usualy the system's /etc/sysconfig/network-scripts/ directory.)


rawconfig

private String rawconfig
Store information from the file in case it is needed.


aliassep

String aliassep
Value of the separator in alias interface filenames. This symbol deivides the interface name from the alias number. The default value is ":", as used in Linux systems. To import configuration files stored in Windows systems this has to be set different (no ":" character is allowed in file names).

Constructor Detail

ImportEthernet

public ImportEthernet()
Method Detail

notifyMode

public void notifyMode(ImporterDialog.SettingsPanelBase mode)
Notify about mode change. Shows or hides the browse button for directory.

Specified by:
notifyMode in interface IServiceParser
Parameters:
mode - configuration panel indicating remote, local or test.

runImport

public void runImport(ImporterEnvironment environment)
               throws VerinecImporterException
Perform import if activated. Analyse the ethernet configuration settings and depending on the settings: The Ethernet specific import configuration is found in the dialog returned by getConfigPanel.

Specified by:
runImport in interface IServiceParser
Parameters:
environment - Object to store log messages and common information
Throws:
VerinecImporterException

getRawConfiguration

public String getRawConfiguration()
Description copied from interface: IServiceParser
Get the raw configuration, that is the configuratio ninformation of the implementation of service.

Specified by:
getRawConfiguration in interface IServiceParser
Returns:
The content of all configuration files.

remoteImport

private String remoteImport(ImporterEnvironment environment)
                     throws VerinecImporterException
Make a local copy of the remote system's "/etc/sysconfig/network-scripts" directory. Store it in the configFilesDir variable. Call the Import methode. Delete the local copy after that.

Parameters:
environment - Object to store log messages and common information
Returns:
The contents of the configuration files.
Throws:
VerinecImporterException - If import fails

doImport

private String doImport(ImporterEnvironment environment)
                 throws VerinecImporterException
Import configuration from a local directory. Test if the configFilesDir is an existing directory. Read out the config variable and decide whether to instance a ImportEth and a ImportLo class.

Parameters:
environment - Object to store log messages and common information
Returns:
The contents of the configuration files.
Throws:
VerinecImporterException

lastToken

String lastToken(String filename,
                 String divisor)
Devide the String filname in tokens seperated by the String divisor.

Parameters:
filename - the String to tokenize
divisor - the signal to devide
Returns:
the last token of filename seperated by the divisor.

updateNode

public void updateNode(PCNode node)
Update the PCNode with new information.

Specified by:
updateNode in interface IServiceParser
Parameters:
node - The node object to update

getConfigPanel

public JPanel getConfigPanel()
Get the configuration panel to configure import of ethernet config.

Specified by:
getConfigPanel in interface IServiceParser
Returns:
A JPanel to include in the config dialog

Copyright © 2005 Verinec, DIUF