Beispiel #1
0
        private XenServerPatchAlert GetAlertFromIsoFile(string fileName, out bool hasUpdateXml, out bool isUpgradeIso)
        {
            hasUpdateXml = false;
            isUpgradeIso = false;

            if (!fileName.EndsWith(InvisibleMessages.ISO_UPDATE))
            {
                return(null);
            }

            var xmlDoc = new XmlDocument();

            try
            {
                using (var isoStream = File.OpenRead(fileName))
                {
                    var cd = new CDReader(isoStream, true);
                    if (cd.Exists("Update.xml"))
                    {
                        using (var fileStream = cd.OpenFile("Update.xml", FileMode.Open))
                        {
                            xmlDoc.Load(fileStream);
                            hasUpdateXml = true;
                        }
                    }

                    if (cd.Exists(@"repodata\repomd.xml") && cd.FileExists(".treeinfo"))
                    {
                        using (var fileStream = cd.OpenFile(".treeinfo", FileMode.Open))
                        {
                            var iniDoc = new IniDocument(fileStream);
                            var entry  = iniDoc.FindEntry("platform", "name");
                            if (entry != null && entry.Value == "XCP")
                            {
                                isUpgradeIso = true;
                                return(null);
                            }
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                log.Error("Exception while reading the update data from the iso file:", exception);
            }

            var elements = xmlDoc.GetElementsByTagName("update");
            var update   = elements.Count > 0 ? elements[0] : null;

            if (update == null || update.Attributes == null)
            {
                return(null);
            }

            var uuid = update.Attributes["uuid"];

            return(uuid != null?Updates.FindPatchAlertByUuid(uuid.Value) : null);
        }