def fromXml()

in app/models/HostInfo.scala [10:74]


  def fromXml(xml:NodeSeq, timestamp:ZonedDateTime):Either[Seq[String], HostInfo] = try {
    val fcInfos = if ((xml \ "fibrechannel").length==0){
      None
    } else {
      FCInfo.fromXml(xml \ "fibrechannel") match {
        case Left(err)=>throw new RuntimeException(err) //this gets picked up just below
        case Right(info)=>
          if(info.domains.isEmpty){
            None
          } else {
            Some(info)
          }
      }
    }
    val denyDlcVolumes = if((xml \ "denyDlc").length==0){
      None
    } else {
      Some((xml \ "denyDlc" \ "volume").map(_.text))
    }

    val driverInfo = if((xml \ "driverInfo").length==0){
      None
    } else {
      Some((xml \ "driverInfo" \ "driver").map(DriverInfo.fromXml(_)))
    }

    val pingInfos = (xml \ "mdcConnectivity" \ "mdc").map(node=>MdcPing.fromXml(node))

    val mountInfos = (xml \ "sanVolumesVisible" \ "mount").map(mountNode=>SanMount.fromXml(mountNode))

    val errors = pingInfos.collect({case Left(err)=>err}) ++ mountInfos.collect({case Left(err)=>err}) ++ driverInfo.getOrElse(Seq()).collect({case Left(err)=>err})

    val plutoHelperAgentInfo = if((xml \@ "plutoHelperAgentInfo").isEmpty){
      None
    } else {
      Some(xml \@ "plutoHelperAgentInfo")
    }

    val premiereProInfo = if((xml \@ "premiereProInfo").isEmpty){
      None
    } else {
      Some(xml \@ "premiereProInfo")
    }

    if(errors.nonEmpty){
      Left(errors)
    } else {
      Right(new HostInfo(xml \@ "hostname",
        xml \@ "computerName",
        xml \@ "model",
        xml \@ "hw_uuid",
        (xml \ "ipAddresses").map(_.text).toList,
        fcInfos,
        denyDlcVolumes,
        driverInfo.map(_.collect({ case Right(info) => info })),
        Some(pingInfos.collect({ case Right(info) => info })),
        Some(mountInfos.collect({ case Right(info) => info })),
        timestamp,
        plutoHelperAgentInfo,
        premiereProInfo))
    }
  } catch {
    case ex:Throwable=>
      Left(Seq(ex.toString))
  }