Permalink
Browse files

Merge back correction for issue #2496

  • Loading branch information...
2 parents cac3208 + 3ccb4bd commit 542ba21af38d67bed5647d9672f6e0b7a8606f1c @fanf fanf committed May 25, 2012
@@ -110,6 +110,7 @@ case object WindowsSeven extends WindowsType with HashcodeCaching { val name = "
case object Windows2000 extends WindowsType with HashcodeCaching { val name = "Windows2000" }
case object Windows2003 extends WindowsType with HashcodeCaching { val name = "Windows2003" }
case object Windows2008 extends WindowsType with HashcodeCaching { val name = "Windows2008" }
+case object Windows2008R2 extends WindowsType with HashcodeCaching { val name = "Windows2008R2" }
/**
@@ -337,23 +337,33 @@ class FusionReportUnmarshaller(
//find os type, and name
val detectedOs : OsType = (osType, osName) match {
- case ("mswin32", x ) => UnknownWindowsType
+ case ("mswin32", _ ) =>
+ val x = fullName.toLowerCase
+ //in windows, relevant information are in the fullName string
+ if (x contains "xp" ) WindowsXP
+ else if(x contains "vista" ) WindowsVista
+ else if(x contains "seven" ) WindowsSeven
+ else if(x contains "2000" ) Windows2000
+ else if(x contains "2003" ) Windows2003
+ else if(x contains "2008 r2") Windows2008R2 //must be before 2008 for obvious reason
+ else if(x contains "2008" ) Windows2008
+ else UnknownWindowsType
+
case ("linux" , x ) =>
if (x contains "debian") Debian
else if(x contains "ubuntu") Ubuntu
else if(x contains "redhat") Redhat
else if(x contains "centos") Centos
else if(x contains "fedora") Fedora
else if(x contains "suse" ) Suse
- else UnknownOSType
+ else UnknownLinuxType
+ //be sure to handle the validity of that case further down the processing pipeline,
+ //for example in PostUnMarshallCheckConsistency
case _ => UnknownOSType
}
detectedOs match {
case w:WindowsType =>
- //windows need some more parsing
- val harwareXml = contentNode \ "HARWARE"
-
Windows(
os = w
@@ -44,14 +44,7 @@ import net.liftweb.common.{Box,Full,Empty,EmptyBox,Failure}
import scala.collection.mutable.Buffer
import org.slf4j.LoggerFactory
import com.normation.ldap.sdk.BuildFilter
-import DefaultReportSaver._
-
-
-object DefaultReportSaver {
- val logger = LoggerFactory.getLogger(classOf[LoggerFactory])
-}
-
-
+import net.liftweb.common.Loggable
/**
* Post-commit convention:
@@ -68,7 +61,7 @@ class DefaultReportSaver(
mapper:InventoryMapper,
override val preCommitPipeline:Seq[PreCommit],
override val postCommitPipeline:Seq[PostCommit[Seq[LDIFChangeRecord]]]
-) extends PipelinedReportSaver[Seq[LDIFChangeRecord]] {
+) extends PipelinedReportSaver[Seq[LDIFChangeRecord]] with Loggable {
def commitChange(report:InventoryReport) : Box[Seq[LDIFChangeRecord]] = {
@@ -130,12 +123,11 @@ class DefaultReportSaver(
} else { //ok, so at least one non error. Log errors, merge non error, and post-process it
val changes : Seq[LDIFChangeRecord] = (Seq[LDIFChangeRecord]() /: results){ (records,r) => r match {
- case f@Failure(m,_,_) =>
- logger.error("Report processing will be incomplete, found error: {}", m)
- val cause = f.rootExceptionCause
- cause.foreach(ex =>
- logger.error("Associated exeption: %s: %s".format(ex.getClass, ex.getMessage))
- )
+ case f:Failure =>
+ logger.error("Report processing will be incomplete, found error: %s".format(f.messageChain))
+ f.rootExceptionCause.foreach { ex =>
+ logger.error("Error was caused by exception: %s".format(ex.getMessage))
+ }
records
case Empty => records //can't log anything relevant ?
case Full(seq) => records ++ seq
@@ -571,7 +571,7 @@ class InventoryMapper(
case Centos => linux += (A_OS_NAME, A_OS_CENTOS)
case Fedora => linux += (A_OS_NAME, A_OS_FEDORA)
case Suse => linux += (A_OS_NAME, A_OS_SUZE)
- case _ => //nothing more
+ case _ => linux += (A_OS_NAME, A_OS_UNKNOWN_LINUX)
}
linux
@@ -584,8 +584,8 @@ class InventoryMapper(
case Windows2000 => win += (A_OS_NAME, A_OS_WIN_2000)
case Windows2003 => win += (A_OS_NAME, A_OS_WIN_2003)
case Windows2008 => win += (A_OS_NAME, A_OS_WIN_2008)
- case UnknownWindowsType => win += (A_OS_NAME, "Undetected windows version")
- case _ => //nothing more
+ case Windows2008R2 => win += (A_OS_NAME, A_OS_WIN_2008_R2)
+ case _ => win += (A_OS_NAME, A_OS_UNKNOWN_WINDOWS)
}
win.setOpt(userDomain, A_WIN_USER_DOMAIN, { x: String => x })
win.setOpt(registrationCompany, A_WIN_COMPANY, { x: String => x })
@@ -708,6 +708,7 @@ class InventoryMapper(
case A_OS_WIN_2000 => Windows2000
case A_OS_WIN_2003 => Windows2003
case A_OS_WIN_2008 => Windows2008
+ case A_OS_WIN_2008_R2 => Windows2008R2
case _ => UnknownWindowsType
}
val userDomain = entry(A_WIN_USER_DOMAIN)
@@ -724,7 +725,7 @@ class InventoryMapper(
case A_OS_CENTOS => Centos
case A_OS_FEDORA => Fedora
case A_OS_SUZE => Suse
- case e => UnknownLinuxType
+ case _ => UnknownLinuxType
}
Full(Linux(os,osFullName,osVersion,osServicePack,kernelVersion))
@@ -792,4 +793,4 @@ class InventoryMapper(
}
}
-}
+}
@@ -159,12 +159,15 @@ object LDAPConstants {
val A_MEMBER_URL = "memberUrl"
// os "distribution" or "version"
+ val A_OS_UNKNOWN_WINDOWS = "Unknown Windows version"
val A_OS_WIN_XP = "WindowsXp"
val A_OS_WIN_VISTA = "WindowsVista"
val A_OS_WIN_SEVEN = "WindowsSeven"
val A_OS_WIN_2000 = "Windows2000"
val A_OS_WIN_2003 = "Windows2003"
val A_OS_WIN_2008 = "Windows2008"
+ val A_OS_WIN_2008_R2 = "Windows2008R2"
+ val A_OS_UNKNOWN_LINUX = "Unknown Linux version"
val A_OS_DEBIAN = "Debian"
val A_OS_UBUNTU = "Ubuntu"
val A_OS_REDHAT = "Redhat"

0 comments on commit 542ba21

Please sign in to comment.