protected SectionWithNamedAppConfigs(Catalog catalog, string name, string path, FileSystemSession session) : base(catalog, name, path, session) { m_AppConfigs = Metabank.fsAccess("SectionWithAppConfig.ctor", path, (fss, dir) => { var result = new Dictionary <string, IConfigSectionNode>(StringComparer.InvariantCultureIgnoreCase); foreach (var fn in dir.FileNames.Where(fn => fn.StartsWith(Metabank.CONFIG_SECTION_LEVEL_APP_FILE_PREFIX))) { var ipr = fn.IndexOf(Metabank.CONFIG_SECTION_LEVEL_APP_FILE_PREFIX); var si = ipr + Metabank.CONFIG_SECTION_LEVEL_APP_FILE_PREFIX.Length; var isfx = fn.IndexOf(Metabank.CONFIG_SECTION_LEVEL_APP_FILE_SUFFIX); if (ipr != 0 || isfx <= si) { continue; } var appName = fn.Substring(si, isfx - si); var app = this.Metabank.CatalogApp.Applications[appName]; if (app == null) { throw new MetabaseException(StringConsts.METABASE_APP_CONFIG_APP_DOESNT_EXIST_ERROR.Args(path, fn, appName)); } var config = Metabank.getConfigFromExistingFile(session, Metabank.JoinPaths(dir.Path, fn)).Root; result.Add(appName, config); } return(result); } ); }
public override void Validate(ValidationContext ctx) { var output = ctx.Output; try { var packages = Packages; } catch (Exception error) { output.Add(new MetabaseValidationMsg(MetabaseValidationMessageType.Error, this, null, error.ToMessageWithType(), error)); return; } try { Metabank.fsAccess("BinCatalog.Validate", BIN_CATALOG, (session, dir) => { foreach (var sdn in dir.SubDirectoryNames) { using (var sdir = dir.GetSubDirectory(sdn)) using (var mf = sdir.GetFile(ManifestUtils.MANIFEST_FILE_NAME)) { if (mf == null) { output.Add(new MetabaseValidationMsg(MetabaseValidationMessageType.Error, this, null, StringConsts.METABASE_BIN_PACKAGE_MISSING_MANIFEST_ERROR .Args(sdn, ManifestUtils.MANIFEST_FILE_NAME), null) ); continue; } var manifest = LaconicConfiguration.CreateFromString(mf.ReadAllText()).Root; var computed = ManifestUtils.GeneratePackagingManifest(sdir); if (!ManifestUtils.HasTheSameContent(manifest, computed, oneWay: false)) { output.Add(new MetabaseValidationMsg(MetabaseValidationMessageType.Error, this, null, StringConsts.METABASE_BIN_PACKAGE_OUTDATED_MANIFEST_ERROR .Args(sdn, ManifestUtils.MANIFEST_FILE_NAME), null) ); } } } return(true); } ); } catch (Exception error) { output.Add(new MetabaseValidationMsg(MetabaseValidationMessageType.Error, this, null, error.ToMessageWithType(), error)); return; } }
/// <summary> /// Checks the local version and performs local software installation on this machine if needed /// This process is an integral part of AHGOV/HostGovernorService implementation and should not be called by developers /// </summary> /// <returns>True if installation was performed</returns> internal bool CheckAndPerformLocalSoftwareInstallation(IList <string> progress, bool force = false) { return (Metabank.fsAccess("BinCatalog.CheckAndPerformLocalSoftwareInstallation", BIN_CATALOG, (session, dir) => { var sw = System.Diagnostics.Stopwatch.StartNew(); if (progress != null) { progress.Add("{0} Building install set...".Args(App.LocalizedTime)); } var installSet = new List <LocalInstallation.PackageInfo>(); foreach (var appPackage in HGov.AllPackages) { var subDir = appPackage.MatchedPackage.FullName; var packageDir = dir.GetSubDirectory(subDir); if (progress != null) { progress.Add(" + {0}".Args(appPackage.ToString())); } if (packageDir == null) { throw new MetabaseException(StringConsts.METABASE_INSTALLATION_BIN_PACKAGE_NOT_FOUND_ERROR.Args(appPackage.Name, subDir)); } installSet.Add(new LocalInstallation.PackageInfo(appPackage.Name, packageDir, appPackage.Path)); } if (progress != null) { progress.Add("Initiating local installation"); progress.Add(" Root Path: {0}".Args(HGov.UpdatePath)); progress.Add(" Manifest Path: {0}".Args(HGov.RunPath)); progress.Add(" Force: {0}".Args(force)); } var anew = false; using (var install = new LocalInstallation(App, HGov.UpdatePath, HGov.RunPath)) { anew = install.CheckLocalAndInstallIfNeeded(installSet, force); } if (progress != null) { progress.Add(" Installed anew: {0}".Args(anew)); progress.Add("{0} Done. Duration: {1}".Args(App.LocalizedTime, sw.Elapsed)); } return anew; } )); }
/// <summary> /// Gets host by name /// </summary> public SectionHost GetHost(string name) { string CACHE_KEY = ("ZN.h" + Path + name).ToLowerInvariant(); //1. Try to get from cache var result = Metabank.cacheGet(REG_CATALOG, CACHE_KEY) as SectionHost; if (result != null) { return(result); } var rdir = "{0}{1}".Args(name, RegCatalog.HST_EXT); var rpath = Metabank.JoinPaths(Path, rdir); result = Metabank.fsAccess("Zone[{0}].GetHost({1})".Args(m_Name, name), rpath, (session, dir) => new SectionHost(this, name, rpath, session) ); Metabank.cachePut(REG_CATALOG, CACHE_KEY, result); return(result); }