FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Fedora Development

 
 
LinkBack Thread Tools
 
Old 12-03-2010, 01:35 PM
Radek Vykydal
 
Default Add network --activate option (#638131)

So that we can activate more than one network device in installer
environment using kickstart.

Note: I am using flag option instead of option with (yes/no) values
because the point of the option is allowing device activation.
Moreover, we can't guarantee honoring of "no" setting in these two cases:
1) --onboot=yes activates device as side effect when we write out
ifcfg files before packages are downloaded.
2) If there is no active device and network method (repo) is used,
first device in ks will be activated.
---
isys/isys.py | 2 ++
kickstart.py | 12 ++++++++++--
network.py | 43 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 55 insertions(+), 2 deletions(-)

diff --git a/isys/isys.py b/isys/isys.py
index 449ba5c..82ad8d8 100755
--- a/isys/isys.py
+++ b/isys/isys.py
@@ -50,6 +50,8 @@ NM_CONNECTION_IFACE = "org.freedesktop.NetworkManagerSettings.Connection "
NM_DEVICE_IFACE = "org.freedesktop.NetworkManager.Device"
NM_IP4CONFIG_IFACE = "org.freedesktop.NetworkManager.IP4Config"
NM_IP6CONFIG_IFACE = "org.freedesktop.NetworkManager.IP6Config"
+NM_SETTINGS_SERVICE = "org.freedesktop.NetworkManagerSystemSettings"
+NM_SETTINGS_PATH = "/org/freedesktop/NetworkManagerSettings"

NM_STATE_UNKNOWN = 0
NM_STATE_ASLEEP = 1
diff --git a/kickstart.py b/kickstart.py
index 65f557d..406d4aa 100644
--- a/kickstart.py
+++ b/kickstart.py
@@ -553,7 +553,7 @@ class Logging(commands.logging.FC6_Logging):
elif self.host != "":
logger.addSysLogHandler(log, self.host)

-class NetworkData(commands.network.F8_NetworkData):
+class NetworkData(commands.network.RHEL6_NetworkData):
def execute(self, anaconda):

devices = anaconda.id.network.netdevices
@@ -638,6 +638,14 @@ class NetworkData(commands.network.F8_NetworkData):
if self.gateway != "":
anaconda.id.network.setGateway(self.gateway, dev.iface)

+ if self.activate and dev.iface not in network.getActiveNetDevs():
+ log.info("Activating network device %s in stage2 kickstart ..." %
+ dev.iface)
+ dev.writeIfcfgFile()
+ rc = (dev.activate()
+ and len(anaconda.id.network.waitForDevicesActivation([dev.iface])) == 0)
+ log.info("Activation %s" % 'succeeded' if rc else 'failed')
+
needs_net = (anaconda.methodstr and
(anaconda.methodstr.startswith("http:") or
anaconda.methodstr.startswith("ftp:") or
@@ -1131,7 +1139,7 @@ dataMap = {
"VolGroupData": VolGroupData,
}

-superclass = returnClassForVersion()
+superclass = returnClassForVersion(RHEL6)

class AnacondaKSHandler(superclass):
def __init__ (self, anaconda):
diff --git a/network.py b/network.py
index 3d9d014..ced7d60 100644
--- a/network.py
+++ b/network.py
@@ -317,6 +317,49 @@ class NetworkDevice(IfcfgFile):
return True
return False

+ def activate(self):
+
+ bus = dbus.SystemBus()
+ nm = bus.get_object(isys.NM_SERVICE, isys.NM_MANAGER_PATH)
+
+ # get dbus path of connection setting object
+ settings = bus.get_object(isys.NM_SETTINGS_SERVICE,
+ isys.NM_SETTINGS_PATH)
+ connection_paths = settings.ListConnections()
+ for con_path in connection_paths:
+ con = bus.get_object(isys.NM_SERVICE, con_path)
+ cs = con.GetSettings()
+ try:
+ mac_bytes = cs[cs['connection']['type']]['mac-address']
+ except KeyError as e:
+ log.info("exception caught: %s" % e)
+ mac_addr = '{0:02X}:{1:02X}:{2:02X}:{3:02X}:{4:02X}:{5:02X}'. format(*mac_bytes)
+ if mac_addr == self.get('HWADDR'):
+ break
+ else:
+ log.info("DBus connection path for device %s not found" % self.iface)
+ return False
+
+ # get dbus path of this device
+ device_object_path = None
+ device_paths = nm.GetDevices()
+ for device_path in device_paths:
+ device = bus.get_object(isys.NM_SERVICE, device_path)
+ device_props_iface = dbus.Interface(device, isys.DBUS_PROPS_IFACE)
+ iface = str(device_props_iface.Get(isys.NM_DEVICE_IFACE, "Interface"))
+ if iface == self.iface:
+ device_object_path = device_path
+ break
+ else:
+ log.info("DBus object path of device %s not found" % self.iface)
+ return False
+
+ nm.ActivateConnection(isys.NM_SETTINGS_SERVICE,
+ con_path,
+ device_path,
+ dbus.ObjectPath("/"))
+ return True
+
class Network:

def __init__(self):
--
1.7.2

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 12-03-2010, 01:35 PM
Radek Vykydal
 
Default Add network --activate option (#638131)

So that we can activate more than one network device in installer
environment using kickstart.

Note: I am using flag option instead of option with (yes/no) values
because the point of the option is allowing device activation.
Moreover we can't guarantee honoring of "no" setting in these two cases:
1) --onboot=yes activates device as side effect when we write out
ifcfg files before packages are downloaded.
2) If there is no active device and network method (repo) is used,
first device in ks will be activated.

If/when acked, I'd duplicate the bug for pykickstart so we can track
pykickstart build the bug is fixed in.

---
pykickstart/commands/network.py | 30 ++++++++++++++++++++++++++++++
pykickstart/handlers/control.py | 4 ++--
2 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/pykickstart/commands/network.py b/pykickstart/commands/network.py
index e2a3101..b0a7026 100644
--- a/pykickstart/commands/network.py
+++ b/pykickstart/commands/network.py
@@ -156,6 +156,22 @@ class RHEL4_NetworkData(FC3_NetworkData):

return retval

+class RHEL6_NetworkData(F8_NetworkData):
+ removedKeywords = F8_NetworkData.removedKeywords
+ removedAttrs = F8_NetworkData.removedAttrs
+
+ def __init__(self, *args, **kwargs):
+ F8_NetworkData.__init__(self, *args, **kwargs)
+ self.activate = kwargs.get("activate", False)
+
+ def _getArgsAsStr(self):
+ retval = F8_NetworkData._getArgsAsStr(self)
+
+ if self.activate:
+ retval += " --activate"
+
+ return retval
+
class FC3_Network(KickstartCommand):
removedKeywords = KickstartCommand.removedKeywords
removedAttrs = KickstartCommand.removedAttrs
@@ -287,3 +303,17 @@ class RHEL5_Network(FC6_Network):
default=BOOTPROTO_DHCP,
choices=self.bootprotoList)
return op
+
+class RHEL6_Network(F9_Network):
+ removedKeywords = F9_Network.removedKeywords
+ removedAttrs = F9_Network.removedAttrs
+
+ def __init__(self, writePriority=0, *args, **kwargs):
+ F9_Network.__init__(self, writePriority, *args, **kwargs)
+ self.activate = kwargs.get("activate", False)
+
+ def _getParser(self):
+ op = F9_Network._getParser(self)
+ op.add_option("--activate", dest="activate", action="store_true",
+ default=False)
+ return op
diff --git a/pykickstart/handlers/control.py b/pykickstart/handlers/control.py
index 2d4b11f..a90c262 100644
--- a/pykickstart/handlers/control.py
+++ b/pykickstart/handlers/control.py
@@ -843,7 +843,7 @@ commandMap = {
"mediacheck": mediacheck.FC4_MediaCheck,
"monitor": monitor.F10_Monitor,
"multipath": multipath.FC6_MultiPath,
- "network": network.F9_Network,
+ "network": network.RHEL6_Network,
"nfs": method.F13_Method,
"part": partition.F12_Partition,
"partition": partition.F12_Partition,
@@ -1070,7 +1070,7 @@ dataMap = {
"IscsiData": iscsi.F10_IscsiData,
"LogVolData": logvol.F12_LogVolData,
"MultiPathData": multipath.FC6_MultiPathData,
- "NetworkData": network.F8_NetworkData,
+ "NetworkData": network.RHEL6_NetworkData,
"PartData": partition.F12_PartData,
"RaidData": raid.F13_RaidData,
"RepoData": repo.F13_RepoData,
--
1.7.2

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 12-03-2010, 01:45 PM
Radek Vykydal
 
Default Add network --activate option (#638131)

On 12/03/2010 03:35 PM, Radek Vykydal wrote:


-superclass = returnClassForVersion()
+superclass = returnClassForVersion(RHEL6)



This is a leftover from my testing, instead
DEVEL=RHEL6 should be changed in pykickstart/version.py
of rhel6-branch?

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 12-06-2010, 10:25 AM
Ales Kozumplik
 
Default Add network --activate option (#638131)

On 12/03/2010 03:45 PM, Radek Vykydal wrote:

On 12/03/2010 03:35 PM, Radek Vykydal wrote:


-superclass = returnClassForVersion()
+superclass = returnClassForVersion(RHEL6)


This is a leftover from my testing, instead
DEVEL=RHEL6 should be changed in pykickstart/version.py
of rhel6-branch?


I agree, hitting this too with another patchset.

Ales

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 01-04-2011, 12:53 PM
Radek Vykydal
 
Default Add network --activate option (#638131)

So that we can activate more than one network device in installer
environment using kickstart.
The activating happens in loader (stage 2 is too late for iscsi).
---
pykickstart/commands/network.py | 30 ++++++++++++++++++++++++++++++
pykickstart/handlers/control.py | 4 ++--
2 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/pykickstart/commands/network.py b/pykickstart/commands/network.py
index e2a3101..b0a7026 100644
--- a/pykickstart/commands/network.py
+++ b/pykickstart/commands/network.py
@@ -156,6 +156,22 @@ class RHEL4_NetworkData(FC3_NetworkData):

return retval

+class RHEL6_NetworkData(F8_NetworkData):
+ removedKeywords = F8_NetworkData.removedKeywords
+ removedAttrs = F8_NetworkData.removedAttrs
+
+ def __init__(self, *args, **kwargs):
+ F8_NetworkData.__init__(self, *args, **kwargs)
+ self.activate = kwargs.get("activate", False)
+
+ def _getArgsAsStr(self):
+ retval = F8_NetworkData._getArgsAsStr(self)
+
+ if self.activate:
+ retval += " --activate"
+
+ return retval
+
class FC3_Network(KickstartCommand):
removedKeywords = KickstartCommand.removedKeywords
removedAttrs = KickstartCommand.removedAttrs
@@ -287,3 +303,17 @@ class RHEL5_Network(FC6_Network):
default=BOOTPROTO_DHCP,
choices=self.bootprotoList)
return op
+
+class RHEL6_Network(F9_Network):
+ removedKeywords = F9_Network.removedKeywords
+ removedAttrs = F9_Network.removedAttrs
+
+ def __init__(self, writePriority=0, *args, **kwargs):
+ F9_Network.__init__(self, writePriority, *args, **kwargs)
+ self.activate = kwargs.get("activate", False)
+
+ def _getParser(self):
+ op = F9_Network._getParser(self)
+ op.add_option("--activate", dest="activate", action="store_true",
+ default=False)
+ return op
diff --git a/pykickstart/handlers/control.py b/pykickstart/handlers/control.py
index a3d9f1a..e89d10c 100644
--- a/pykickstart/handlers/control.py
+++ b/pykickstart/handlers/control.py
@@ -843,7 +843,7 @@ commandMap = {
"mediacheck": mediacheck.FC4_MediaCheck,
"monitor": monitor.F10_Monitor,
"multipath": multipath.FC6_MultiPath,
- "network": network.F9_Network,
+ "network": network.RHEL6_Network,
"nfs": method.RHEL6_Method,
"part": partition.F12_Partition,
"partition": partition.F12_Partition,
@@ -1070,7 +1070,7 @@ dataMap = {
"IscsiData": iscsi.F10_IscsiData,
"LogVolData": logvol.F12_LogVolData,
"MultiPathData": multipath.FC6_MultiPathData,
- "NetworkData": network.F8_NetworkData,
+ "NetworkData": network.RHEL6_NetworkData,
"PartData": partition.F12_PartData,
"RaidData": raid.F13_RaidData,
"RepoData": repo.RHEL6_RepoData,
--
1.7.2

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 01-04-2011, 02:38 PM
Chris Lumens
 
Default Add network --activate option (#638131)

> So that we can activate more than one network device in installer
> environment using kickstart.
> The activating happens in loader (stage 2 is too late for iscsi).

The three pykickstart patches look fine. Can you clone bug 638131 for
pykickstart and make sure it gets its flags, though? Otherwise things
will get complicated.

- Chris

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 01-04-2011, 02:46 PM
Radek Vykydal
 
Default Add network --activate option (#638131)

On 01/04/2011 04:38 PM, Chris Lumens wrote:

The three pykickstart patches look fine. Can you clone bug 638131 for
pykickstart and make sure it gets its flags, though? Otherwise things
will get complicated.




Thanks, I will.


_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 01-04-2011, 03:44 PM
Radek Vykydal
 
Default Add network --activate option (#638131)

On 12/03/2010 03:35 PM, Radek Vykydal wrote:

So that we can activate more than one network device in installer
environment using kickstart.



This patchset is obsoleted by a new one. The devices need
to be activated already in loader (for iSCSI).

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 07:12 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org