.. _usage: OpenLMI-Networking usage ======================== All example scripts are for ``lmishell``. See it's documentation_ on OpenLMI_ page. .. _documentation: https://fedorahosted.org/openlmi/wiki/shell .. _OpenLMI: https://fedorahosted.org/openlmi/ We also assume that ``lmishell`` is connected to the CIMOM and the connection is stored in ``connection`` variable:: connection = connect("server", "username", "password") Enumeration of network devices ------------------------------ Obtaining a list of network devices can be done by executing following commands in ``lmishell``:: for device in connection.root.cimv2.LMI_IPNetworkConnection.instances(): print device.ElementName Get parameters of network devices --------------------------------- Obtaining parameters of network device might be a little bit tricky. DMTF standards split network device to three classes and one might need to traverse between them through associations, see :ref:`Networking API concepts `. Following example gets device name, its status and MAC address for each device. MAC address is not in the :ref:`LMI_IPNetworkConnection` class and must be accessed through :ref:`LMI_EndpointForIPNetworkConnection` association to :ref:`LMI_LANEndpoint` class:: for device in connection.root.cimv2.LMI_IPNetworkConnection.instances(): print device.ElementName, print connection.root.cimv2.LMI_IPNetworkConnection.OperatingStatusValues.value_name(device.OperatingStatus), # MAC address in not part of LMI_IPNetworkConnection but LMI_LANEndpoint class, # which is associated through LMI_EndpointForIPNetworkConnection print device.first_associator(AssocClass="LMI_EndpointForIPNetworkConnection").MACAddress Get current IP configuration ---------------------------- (IPv4 and IPv6 addresses, default gateways, DNS) Bring up / take down a network device Enumerate available settings (configurations for network device) Create new setting with independent IPv4 and IPv6 configuration (static addresses, DHCP(v6), Stateless, disabled), default gateway Set DNS servers for given setting Manage static routes for given setting Apply setting to network device: * Multiple modes: immediate activation and/or setting it as permanent * Immediate applying is done asynchronously (can take quite a long time) Delete setting Bridging/bonding: * Create bridge/bond setting * Enslave network device * Delete bridge/bond Notification about changes in network devices and settings (created, modified, deleted)