Esempio n. 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);
        }
Esempio n. 2
0
        public void AddFileBytes()
        {
            CDBuilder builder = new CDBuilder();

            builder.AddFile(@"ADIR\AFILE.TXT", new byte[] {});
            CDReader fs = new CDReader(builder.Build(), false);

            Assert.True(fs.Exists(@"ADIR\AFILE.TXT"));
        }
Esempio n. 3
0
        public void AddFileStream()
        {
            CDBuilder builder = new CDBuilder();

            builder.AddFile(@"ADIR\AFILE.TXT", new MemoryStream());
            CDReader fs = new CDReader(builder.Build(), false);

            Assert.True(fs.Exists(@"ADIR\AFILE.TXT"));
        }
        private XenServerPatchAlert GetAlertFromIsoFile(string fileName, out bool hasUpdateXml)
        {
            hasUpdateXml = false;

            if (!fileName.EndsWith(Branding.UpdateIso))
            {
                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;
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                log.ErrorFormat("Exception while reading the update data from the iso file: {0}", exception.Message);
            }

            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);
        }