Hello community,
here is the log from the commit of package zmd-inventory
checked in at Fri Jun 9 23:37:37 CEST 2006.
--------
--- zmd-inventory/zmd-inventory.changes 2006-06-01 00:15:53.000000000 +0200
+++ zmd-inventory/zmd-inventory.changes 2006-06-09 19:17:13.000000000 +0200
@@ -1,0 +2,6 @@
+Fri Jun 9 19:16:46 CEST 2006 - maw@suse.de
+
+- New source drop (r30090) which:
+- Implements hardware inventory for Novell Update services. #155824
+
+-------------------------------------------------------------------
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ zmd-inventory.spec ++++++
--- /var/tmp/diff_new_pack.KPSwe4/_old 2006-06-09 23:37:32.000000000 +0200
+++ /var/tmp/diff_new_pack.KPSwe4/_new 2006-06-09 23:37:32.000000000 +0200
@@ -14,7 +14,7 @@
BuildRequires: hwinfo-devel log4net mono-basic mono-data-sqlite mono-devel update-desktop-files zmd-devel
URL: http://www.novell.com
Version: 7.1.1.0
-Release: 8
+Release: 9
License: LGPL
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Source0: %name-%version.tar.bz2
@@ -59,6 +59,9 @@
%{_prefix}/lib/zmd/modules/*
%changelog -n zmd-inventory
+* Fri Jun 09 2006 - maw@suse.de
+- New source drop (r30090) which:
+- Implements hardware inventory for Novell Update services. #155824
* Thu Jun 01 2006 - maw@suse.de
- New source drop (r29477) which:
- Implements software inventory for Novell Update services.
++++++ zmd-inventory-7.1.1.0.tar.bz2 ++++++
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/zmd-inventory-7.1.1.0/src/ChangeLog new/zmd-inventory-7.1.1.0/src/ChangeLog
--- old/zmd-inventory-7.1.1.0/src/ChangeLog 2006-05-31 19:43:07.000000000 +0200
+++ new/zmd-inventory-7.1.1.0/src/ChangeLog 2006-06-09 00:22:44.000000000 +0200
@@ -1,3 +1,20 @@
+2006-06-08 Dan Mills
+
+ * NUInventory.cs:
+ * NUXmlRpcClient.cs:
+ * Scanner.cs:
+
+ Add swap space, kernel version, uptime, and net driver.
+
+2006-06-03 Dan Mills
+
+ * Scanner.cs (Parse): Print something when df ends (debug).
+ (GetItems): Get SystemInformationItems too.
+
+ * NUXmlRpcClient.cs: Add hardware inventory interfaces.
+
+ * NUInventory.cs: Implement (most of) hardware inventory.
+
2006-05-30 Dan Mills
* Makefile.am: Link with CookComputing.XmlRpc.dll (from the zmd
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/zmd-inventory-7.1.1.0/src/NUInventory.cs new/zmd-inventory-7.1.1.0/src/NUInventory.cs
--- old/zmd-inventory-7.1.1.0/src/NUInventory.cs 2006-05-31 19:43:07.000000000 +0200
+++ new/zmd-inventory-7.1.1.0/src/NUInventory.cs 2006-06-09 00:18:11.000000000 +0200
@@ -54,12 +54,226 @@
}
protected override bool SendInventory () {
+ XmlRpcHardware inventory = MakeXmlRpcHardware ();
+ string deviceid = PreferenceManager.GetDeviceID ();
+ string secret = NUUtil.GetMD5 (deviceid + ":Express:" + PreferenceManager.GetSecret ());
+
foreach (string uri in (string[]) NUInventoryManager.Uris.ToArray (typeof (string))) {
- log.Debug (uri);
- log.Debug ("FIXME: We don't do anything yet");
+ try {
+ INUXmlRpcService nuServer = NUXmlRpcService.Create (uri);
+ log.Info (String.Format ("Sending hardware inventory to NU server..."));
+ DebugHWInfo (deviceid, secret, inventory);
+ nuServer.UpdateHWInfo (deviceid, secret, inventory);
+
+ } catch (XmlRpcFaultException e) {
+ log.Error (String.Format ("Error sending hardware inventory to NU server '{0}': {1} (code {2})", uri, e.FaultString, e.FaultCode), e);
+ return false;
+
+ } catch (Exception e) {
+ log.Error (String.Format ("Error sending hardware inventory to NU server '{0}'", uri), e);
+ return false;
+ }
}
return true;
}
+
+ private static void DebugHWInfo (string deviceid, string secret, XmlRpcHardware inventory) {
+ log.Debug (String.Format ("\tDevice ID: {0}", deviceid));
+ log.Debug (String.Format ("\tSecret: {0}", secret));
+ log.Debug (String.Format ("\tCPU: {0} items", inventory.cpu.Length));
+ if (inventory.cpu.Length > 0) {
+ foreach (XmlRpcProcessor cpu in inventory.cpu) {
+ log.Debug (String.Format ("\t\tName: \"{0}\", CPU: \"{1}\", MHz: \"{2}\", Id: \"{3}\"",
+ cpu.name, cpu.cpu, cpu.mhz, cpu.id));
+ }
+ }
+ log.Debug (String.Format ("\tDisk: {0} items", inventory.disk.Length));
+ if (inventory.disk.Length > 0) {
+ foreach (XmlRpcDisk disk in inventory.disk) {
+ log.Debug (String.Format ("\t\tModel: \"{0}\", Bus: \"{1}\", Size: \"{2}\", Device: \"{3}\"",
+ disk.model, disk.bus, disk.size, disk.device));
+ }
+ }
+ log.Debug (String.Format ("\tNet: {0} items", inventory.net.Length));
+ if (inventory.net.Length > 0) {
+ foreach (XmlRpcNet net in inventory.net) {
+ log.Debug (String.Format ("\t\tIP: \"{0}\", HW Addr: \"{1}\", Device: \"{2}\", Driver: \"{3}\"",
+ net.ip, net.hwaddr, net.device, net.driver));
+ }
+ }
+ log.Debug (String.Format ("\tVideo: {0} items", inventory.video.Length));
+ if (inventory.video.Length > 0) {
+ foreach (XmlRpcVideo video in inventory.video) {
+ log.Debug (String.Format ("\t\tDescription: \"{0}\", Driver: \"{1}\", Bus: \"{2}\"",
+ video.desc, video.driver, video.bus));
+ }
+ }
+ log.Debug (String.Format ("\tAudio: {0} items", inventory.audio.Length));
+ if (inventory.audio.Length > 0) {
+ foreach (XmlRpcAudio audio in inventory.audio) {
+ log.Debug (String.Format ("\t\tDescription: \"{0}\", Driver: \"{1}\", Bus: \"{2}\"",
+ audio.desc, audio.driver, audio.bus));
+ }
+ }
+ log.Debug (String.Format ("\tMount: {0} items", inventory.mount.Length));
+ if (inventory.mount.Length > 0) {
+ foreach (XmlRpcMount mount in inventory.mount) {
+ log.Debug (String.Format ("\t\tMounted: \"{0}\", Size: \"{1}\", Used: \"{2}\", Device: \"{3}\"",
+ mount.mounted, mount.size, mount.used, mount.device));
+ }
+ }
+ log.Debug (String.Format ("\tUptime: {0}", inventory.uptime));
+ log.Debug (String.Format ("\tMemory: {0}KB", inventory.memory.memory));
+ log.Debug (String.Format ("\tSwap: {0}KB", inventory.swap));
+ log.Debug (String.Format ("\tKernel Version: {0}", inventory.kernel_version));
+ }
+
+ private static XmlRpcHardware MakeXmlRpcHardware () {
+ XmlRpcHardware inventory = new XmlRpcHardware ();
+ inventory.cpu = MakeXmlRpcProcessor (Scanner.Instance.GetItems (typeof (Processor)));
+ inventory.disk = MakeXmlRpcDisk (Scanner.Instance.GetItems (typeof (Disk)));
+ inventory.net = MakeXmlRpcNet (Scanner.Instance.GetItems (typeof (NetAdapter)));
+ inventory.video = MakeXmlRpcVideo (Scanner.Instance.GetItems (typeof (Video)));
+ inventory.audio = MakeXmlRpcAudio (Scanner.Instance.GetItems (typeof (Sound)));
+ inventory.mount = MakeXmlRpcMount (Scanner.Instance.GetItems (typeof (LogicalDisk)));
+
+ OperatingSystem os = GetOSInfo (Scanner.Instance.GetSystemItems ());
+ inventory.memory = MakeXmlRpcMemory (os);
+ inventory.swap = (int) os.totalSwapSpace;
+ inventory.kernel_version = os.kernelVersion;
+ inventory.uptime = os.uptime;
+
+ return inventory;
+ }
+
+ private static XmlRpcProcessor[] MakeXmlRpcProcessor (HardwareItem[] items) {
+ ArrayList cpus = new ArrayList ();
+ foreach (HardwareItem hwitem in items) {
+ cpus.Add (MakeXmlRpcProcessor (hwitem));
+ }
+ return (XmlRpcProcessor[]) cpus.ToArray (typeof (XmlRpcProcessor));
+ }
+
+ private static XmlRpcProcessor MakeXmlRpcProcessor (HardwareItem item) {
+ Processor p = item as Processor;
+ XmlRpcProcessor cpu = new XmlRpcProcessor ();
+ cpu.name = p.name;
+ cpu.cpu = p.description;
+ cpu.mhz = p.maxClockSpeed;
+ cpu.id = p.devId;
+ return cpu;
+ }
+
+ private static XmlRpcDisk[] MakeXmlRpcDisk (HardwareItem[] items) {
+ ArrayList disks = new ArrayList ();
+ foreach (HardwareItem hwitem in items) {
+ disks.Add (MakeXmlRpcDisk (hwitem));
+ }
+ return (XmlRpcDisk[]) disks.ToArray (typeof (XmlRpcDisk));
+ }
+
+ private static XmlRpcDisk MakeXmlRpcDisk (HardwareItem item) {
+ Disk d = item as Disk;
+ XmlRpcDisk disk = new XmlRpcDisk ();
+ disk.model = d.manufacturer;
+ disk.bus = "N/A"; // fixme (?)
+ disk.size = (int) d.capacity;
+ disk.device = d.devId;
+ return disk;
+ }
+
+ private static XmlRpcNet[] MakeXmlRpcNet (HardwareItem[] items) {
+ ArrayList netDevs = new ArrayList ();
+ foreach (HardwareItem hwitem in items) {
+ netDevs.Add (MakeXmlRpcNet (hwitem));
+ }
+ return (XmlRpcNet[]) netDevs.ToArray (typeof (XmlRpcNet));
+ }
+
+ private static XmlRpcNet MakeXmlRpcNet (HardwareItem item) {
+ NetAdapter n = item as NetAdapter;
+ XmlRpcNet net = new XmlRpcNet ();
+ net.ip = n.IPAddresses[0].IPAddress1;
+ net.hwaddr = n.macaddress;
+ net.device = n.slot;
+ net.driver = n.driver.name;
+ return net;
+ }
+
+ private static XmlRpcVideo[] MakeXmlRpcVideo (HardwareItem[] items) {
+ ArrayList videoDevs = new ArrayList ();
+ foreach (HardwareItem hwitem in items) {
+ videoDevs.Add (MakeXmlRpcVideo (hwitem));
+ }
+ return (XmlRpcVideo[]) videoDevs.ToArray (typeof (XmlRpcVideo));
+ }
+
+ private static XmlRpcVideo MakeXmlRpcVideo (HardwareItem item) {
+ VideoAdapter v = item as VideoAdapter;
+ XmlRpcVideo video = new XmlRpcVideo ();
+ video.desc = v.description;
+ video.driver = v.driver.name;
+ video.bus = v.slot;
+ return video;
+ }
+
+ private static XmlRpcAudio[] MakeXmlRpcAudio (HardwareItem[] items) {
+ ArrayList audioDevs = new ArrayList ();
+ foreach (HardwareItem hwitem in items) {
+ audioDevs.Add (MakeXmlRpcAudio (hwitem));
+ }
+ return (XmlRpcAudio[]) audioDevs.ToArray (typeof (XmlRpcAudio));
+ }
+
+ private static XmlRpcAudio MakeXmlRpcAudio (HardwareItem item) {
+ SoundAdapter s = item as SoundAdapter;
+ XmlRpcAudio audio = new XmlRpcAudio ();
+ audio.desc = s.description;
+ audio.driver = "N/A"; // fixme
+ audio.bus = s.slot;
+ return audio;
+ }
+
+ private static OperatingSystem GetOSInfo (SystemInformationItem[] items) {
+ OperatingSystem os = null;
+
+ foreach (SystemInformationItem item in items) {
+ if (item.GetType () == typeof (OperatingSystem)) {
+ os = (OperatingSystem) item;
+ break;
+ }
+ }
+
+ if (os == null)
+ throw new ZenException ("Could not get operating system information from scanner.");
+
+ return os;
+ }
+
+ private static XmlRpcMemory MakeXmlRpcMemory (OperatingSystem os) {
+ XmlRpcMemory memory = new XmlRpcMemory ();
+ memory.memory = (int) os.totalMemorySize;
+
+ return memory;
+ }
+
+ private static XmlRpcMount[] MakeXmlRpcMount (HardwareItem[] items) {
+ ArrayList mounts = new ArrayList ();
+ foreach (HardwareItem hwitem in items) {
+ mounts.Add (MakeXmlRpcMount (hwitem));
+ }
+ return (XmlRpcMount[]) mounts.ToArray (typeof (XmlRpcMount));
+ }
+
+ private static XmlRpcMount MakeXmlRpcMount (HardwareItem item) {
+ LogicalDisk d = item as LogicalDisk;
+ XmlRpcMount mount = new XmlRpcMount ();
+ mount.mounted = "N/A"; // fixme
+ mount.size = (int) d.fileSystemSize;
+ mount.used = (int) (d.fileSystemSize - d.availableSpace);
+ mount.device = d.volumeLabel;
+ return mount;
+ }
}
public class NUSoftwareInventory : InventoryRefresh {
@@ -100,7 +314,7 @@
try {
INUXmlRpcService nuServer = NUXmlRpcService.Create (uri);
- log.Info (String.Format ("Sending {0} resolvables and {1} resolvable updates. Args:", inventory.Count, updates.Count));
+ log.Info (String.Format ("Sending {0} resolvables and {1} resolvable updates...", inventory.Count, updates.Count));
log.Debug (String.Format ("\tDevice ID: {0}", deviceid));
log.Debug (String.Format ("\tSecret: {0}", secret));
log.Debug (String.Format ("\tTarget: {0}", target));
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/zmd-inventory-7.1.1.0/src/NUXmlRpcClient.cs new/zmd-inventory-7.1.1.0/src/NUXmlRpcClient.cs
--- old/zmd-inventory-7.1.1.0/src/NUXmlRpcClient.cs 2006-05-31 19:43:07.000000000 +0200
+++ new/zmd-inventory-7.1.1.0/src/NUXmlRpcClient.cs 2006-06-09 00:16:12.000000000 +0200
@@ -12,12 +12,72 @@
public string severity;
}
+ public struct XmlRpcHardware {
+ public XmlRpcProcessor[] cpu;
+ public XmlRpcDisk[] disk;
+ public XmlRpcNet[] net;
+ public XmlRpcVideo[] video;
+ public XmlRpcAudio[] audio;
+ public XmlRpcMemory memory;
+ public int swap;
+ public string kernel_version;
+ public string uptime;
+ public XmlRpcMount[] mount;
+ }
+
+ public struct XmlRpcProcessor {
+ public string name;
+ public string cpu;
+ public int mhz;
+ public string id;
+ }
+
+ public struct XmlRpcDisk {
+ public string model;
+ public string bus;
+ public int size;
+ public string device;
+ }
+
+ public struct XmlRpcNet {
+ public string ip;
+ public string hwaddr;
+ public string device;
+ public string driver;
+ }
+
+ public struct XmlRpcVideo {
+ public string desc;
+ public string driver;
+ public string bus;
+ }
+
+ public struct XmlRpcAudio {
+ public string desc;
+ public string driver;
+ public string bus;
+ }
+
+ public struct XmlRpcMemory {
+ public int memory;
+ }
+
+ public struct XmlRpcMount {
+ public string mounted;
+ public int size;
+ public int used;
+ public string device;
+ }
+
public interface INUXmlRpcService {
[XmlRpcMethod ("rcserver.machine.setResolvableUpdates")]
- void SetResolvableUpdates (string user, string pass, string distro, string maxSeverity, XmlRpcResolvable[] updates);
+ void SetResolvableUpdates (string user, string pass, string distro, string maxSeverity, XmlRpcResolvable[] updates);
[XmlRpcMethod ("rcserver.machine.setResolvables")]
- void SetResolvables (string user, string pass, string distro, XmlRpcResolvable[] inventory);
+ void SetResolvables (string user, string pass, string distro, XmlRpcResolvable[] inventory);
+
+ [XmlRpcMethod ("rcserver.machine.updateHWInfo")]
+ void UpdateHWInfo (string user, string pass, XmlRpcHardware inventory);
}
public class NUXmlRpcService {
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore old/zmd-inventory-7.1.1.0/src/Scanner.cs new/zmd-inventory-7.1.1.0/src/Scanner.cs
--- old/zmd-inventory-7.1.1.0/src/Scanner.cs 2006-05-31 19:43:07.000000000 +0200
+++ new/zmd-inventory-7.1.1.0/src/Scanner.cs 2006-06-09 00:13:43.000000000 +0200
@@ -995,7 +995,8 @@
ProcessProgress progress = new ProcessProgress ("df Process", info);
progress.GotOutput += HandleProcessOutput;
progress.Start ();
- ProgressStatus status = progress.WaitForStop ();
+ progress.WaitForStop ();
+ log.Debug ("df process completed");
return (LogicalDisk[]) parsedDisks.ToArray (typeof (LogicalDisk));
}
@@ -1238,6 +1239,9 @@
}
public class OperatingSystem : ZENInventory.OperatingSystem {
+
+ public string uptime;
+
public static OperatingSystem[] Parse (HWInfoParser p) {
OperatingSystem[] ret = new OperatingSystem[1];
ret[0] = new OperatingSystem ();
@@ -1248,6 +1252,7 @@
public OperatingSystem () {
FillDistroInfo ();
FillMemoryInfo ();
+ FillUptime ();
ProcessStartInfo info = new ProcessStartInfo ("/bin/uname", "-a");
info.UseShellExecute = false;
@@ -1268,6 +1273,24 @@
this.caption = Util.UnknownString;
}
+ private void FillUptime () {
+ uptime = "N/A";
+
+ ProcessStartInfo info = new ProcessStartInfo ("/usr/bin/w");
+ info.UseShellExecute = false;
+ info.RedirectStandardOutput = true;
+ Process process = Process.Start (info);
+ string output = process.StandardOutput.ReadLine ();
+ process.WaitForExit ();
+
+ Regex r = new Regex (@"^.*(up.*), \d+");
+ Match m = r.Match (output);
+ if (m.Success) {
+ GroupCollection groups = m.Groups;
+ uptime = groups[1].ToString ();
+ }
+ }
+
private void FillDistroInfo () {
Novell.Zenworks.Zmd.Public.OSTarget target = OSTargetParser.ParseResource ("ostargets");
if (!target.Equals (Novell.Zenworks.Zmd.Public.OSTarget.Empty)) {
@@ -1638,7 +1661,6 @@
systemItems.AddRange (LogicalDisk.Parse (p));
systemItems.AddRange (OperatingSystem.Parse (p));
-
this.lastScan = DateTime.Now;
this.hardware = (HardwareItem[]) hardwareItems.ToArray (typeof (HardwareItem));
this.systemInformation = (SystemInformationItem[]) systemItems.ToArray (typeof (SystemInformationItem));
@@ -1660,6 +1682,11 @@
ret.Add (item);
}
+ foreach (HardwareItem item in systemInformation) {
+ if (item.GetType () == type)
+ ret.Add (item);
+ }
+
return (HardwareItem[]) ret.ToArray (typeof (HardwareItem));
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remember to have fun...
---------------------------------------------------------------------
To unsubscribe, e-mail: opensuse-commit-unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-commit-help@opensuse.org