All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH phosphor-networkd] Added DBus method GetAddressType to identify if the interface is conf…
@ 2016-04-29 17:40 OpenBMC Patches
  2016-04-29 17:40 ` [PATCH phosphor-networkd] Added DBus method GetAddressType to identify if the interface is configured with static IP address or configured by DHCP OpenBMC Patches
  0 siblings, 1 reply; 2+ messages in thread
From: OpenBMC Patches @ 2016-04-29 17:40 UTC (permalink / raw)
  To: openbmc

…igured

with static IP address or configured by DHCP.

"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node name="/org/openbmc/NetworkManager/Interface">
  ...  
  <interface name="**org.openbmc.NetworkManager**">
    <method name="**GetAddressType**">
      <arg direction="in"  type="s" name="device" />
      <arg direction="out" type="s" />
    </method>
...
   </interface>

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/openbmc/phosphor-networkd/15)
<!-- Reviewable:end -->


https://github.com/openbmc/phosphor-networkd/pull/15

Hariharasubramanian R (1):
  Added DBus method GetAddressType to identify if the interface is
    configured with static IP address or configured by DHCP.

 netman.py | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

-- 
2.8.1

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH phosphor-networkd] Added DBus method GetAddressType to identify if the interface is configured with static IP address or configured by DHCP.
  2016-04-29 17:40 [PATCH phosphor-networkd] Added DBus method GetAddressType to identify if the interface is conf… OpenBMC Patches
@ 2016-04-29 17:40 ` OpenBMC Patches
  0 siblings, 0 replies; 2+ messages in thread
From: OpenBMC Patches @ 2016-04-29 17:40 UTC (permalink / raw)
  To: openbmc

From: Hariharasubramanian R <hramasub@in.ibm.com>

---
 netman.py | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/netman.py b/netman.py
index 377833d..e2b89ca 100755
--- a/netman.py
+++ b/netman.py
@@ -192,6 +192,32 @@ class NetMan (dbus.service.Object):
         rc = call(["systemctl", "restart", "systemd-networkd.service"])
         return rc
 
+    @dbus.service.method(DBUS_NAME, "s", "s")
+    def GetAddressType (self, device):
+        if not self._isvaliddev (device) : raise ValueError, "Invalid Device"
+
+        confFile = "/etc/systemd/network/00-bmc-" + device + ".network"
+        if not os.path.exists(confFile): 
+            print "Config file (%s) not found !" % confFile
+            netprov     = network_providers [self.provider]
+            bus_name    = netprov ['bus_name']
+            obj_name    = netprov ['ip_object_name']
+            o = self.bus.get_object(bus_name, obj_name, introspect=False)
+            i = dbus.Interface(o, 'org.freedesktop.DBus.Properties')
+            f = i.Get (netprov ['ip_if_name'], "SourcePath")
+            print "Using default networkd config file (%s)" % f
+            confFile = f
+
+        with open(confFile, "r") as f:
+            for line in f:
+                config = line.split ("=")
+                if (len (config) < 2) : continue
+                if config [0].upper() == "DHCP":
+                    v = config[1].strip().upper()
+                    if (v=="YES" or v=="IPV4" or v=="IPV6"):
+                        return "DHCP"
+        return "STATIC"
+
     #family, prefixlen, ip, defgw
     @dbus.service.method(DBUS_NAME, "s", "iyss")
     def GetAddress4 (self, device):
-- 
2.8.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-04-29 17:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-29 17:40 [PATCH phosphor-networkd] Added DBus method GetAddressType to identify if the interface is conf… OpenBMC Patches
2016-04-29 17:40 ` [PATCH phosphor-networkd] Added DBus method GetAddressType to identify if the interface is configured with static IP address or configured by DHCP OpenBMC Patches

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.