public static void Main(string[] args) { var config = new ConfigurationBuilder().AddJsonFile("hostings.json", optional: true).Build(); var hostingSettings = new HostingSettings(); config.GetSection("HostingSettings").Bind(hostingSettings); var builder = CreateWebHostBuilder(args); if (!string.IsNullOrWhiteSpace(hostingSettings.Url)) { Console.WriteLine(hostingSettings.Url); builder.UseUrls(hostingSettings.Url); } if (!string.IsNullOrWhiteSpace(hostingSettings.WebRoot)) { Console.WriteLine(hostingSettings.WebRoot); builder.UseWebRoot(hostingSettings.WebRoot); } // Run builder builder.Build().Run(); }
public ApplicationSettings() { Hosting = new HostingSettings(); ServiceBus = new ServiceBusSettings(); InteropServiceBus = new ServiceBusSettings(); Logging = new LoggingSettings(); Persistence = new PersistenceSettings(); }
public DockerHostingSettings(HostingSettings hostingSettings) { IsExternalModule = hostingSettings.IsExternalModule; Version = hostingSettings.Version; Type = hostingSettings.Type; DesiredStatus = Enum.Parse <ModuleStatus>(hostingSettings.DesiredStatus.ToString()); RestartPolicy = Enum.Parse <RestartPolicy>(hostingSettings.RestartPolicy.ToString()); Config = new DockerConfig(hostingSettings.ImageName, ProcessCreateOptions(hostingSettings.Options)); }
public static HttpConfiguration BaseConfiguration(IContainer container, HostingSettings hostingSettings) { if (container == null) { throw new ArgumentNullException(nameof(container)); } var configuration = new HttpConfiguration { DependencyResolver = new AutofacWebApiDependencyResolver(container) }; configuration.Filters.Add(new ApiAccessLoggingFilter()); configuration.Filters.Add(new ApiExceptionHandlingFilter(hostingSettings.ShowErrorDetails, hostingSettings.IsGateway)); configuration.MapHttpAttributeRoutes(); configuration.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional }); if (hostingSettings.AuthenticationRequired) { configuration.Routes.IgnoreRoute( routeName: "Favicon", routeTemplate: "favicon.ico"); configuration.Routes.IgnoreRoute( routeName: "Png", routeTemplate: "*.png"); // logo object constraints = hostingSettings.SwaggerEnabled ? new { url = "^((?!swagger).)*$" } : null; configuration.Routes.MapHttpRoute( name: "NotFound", routeTemplate: "{*url}", defaults: new { controller = "Errors", action = "Handle404" }, constraints: constraints); } configuration.Services.Add(typeof(IExceptionLogger), new ApiUnhandledExceptionLogger()); configuration.Services.Replace(typeof(IHttpControllerSelector), new HttpNotFoundAwareDefaultHttpControllerSelector(configuration)); configuration.Services.Replace(typeof(IHttpActionSelector), new HttpNotFoundAwareControllerActionSelector()); configuration.Services.Clear(typeof(ModelValidatorProvider)); configuration.Formatters.Clear(); var settings = container.Resolve <JsonSerializerSettings>(); var formatter = new JsonMediaTypeFormatter { SerializerSettings = settings }; configuration.Formatters.Add(formatter); configuration.EnsureInitialized(); return(configuration); }
bool IConfigStoreUpdateHandler.OnUpdate(string sectionName, string keyName) { if (sectionName.Equals(HostingSectionName, StringComparison.OrdinalIgnoreCase)) { using (this.configLock.AcquireWriteLock()) { this.hostingSettings = HostingSettings.LoadHostingSettings(); } } return(true); }
private IHostingEnvironment CreateHostingEnvironment(string virtualPath = "") { var hostingSettings = new HostingSettings { ApplicationVirtualPath = virtualPath }; var webRoutingSettings = new WebRoutingSettings(); var mockedOptionsMonitorOfHostingSettings = Mock.Of <IOptionsMonitor <HostingSettings> >(x => x.CurrentValue == hostingSettings); var mockedOptionsMonitorOfWebRoutingSettings = Mock.Of <IOptionsMonitor <WebRoutingSettings> >(x => x.CurrentValue == webRoutingSettings); return(new TestHostingEnvironment( mockedOptionsMonitorOfHostingSettings, mockedOptionsMonitorOfWebRoutingSettings, _hostEnvironment)); }
public SystemInformationTelemetryProvider( IUmbracoVersion version, ILocalizationService localizationService, IOptions <ModelsBuilderSettings> modelsBuilderSettings, IOptions <HostingSettings> hostingSettings, IOptions <GlobalSettings> globalSettings, IHostEnvironment hostEnvironment, Lazy <IUmbracoDatabase> database) { _version = version; _localizationService = localizationService; _hostEnvironment = hostEnvironment; _database = database; _globalSettings = globalSettings.Value; _hostingSettings = hostingSettings.Value; _modelsBuilderSettings = modelsBuilderSettings.Value; }
/// <summary> /// HACK: returns an AspNetCoreHostingEnvironment that doesn't monitor changes to configuration.<br /> /// We require this to create a TypeLoader during ConfigureServices.<br /> /// Instances returned from this method shouldn't be registered in the service collection. /// </summary> private static IHostingEnvironment GetTemporaryHostingEnvironment( IWebHostEnvironment webHostEnvironment, IConfiguration config) { HostingSettings hostingSettings = config.GetSection(Constants.Configuration.ConfigHosting).Get <HostingSettings>() ?? new HostingSettings(); var wrappedHostingSettings = new OptionsMonitorAdapter <HostingSettings>(hostingSettings); WebRoutingSettings webRoutingSettings = config.GetSection(Constants.Configuration.ConfigWebRouting).Get <WebRoutingSettings>() ?? new WebRoutingSettings(); var wrappedWebRoutingSettings = new OptionsMonitorAdapter <WebRoutingSettings>(webRoutingSettings); return(new AspNetCoreHostingEnvironment( wrappedHostingSettings, wrappedWebRoutingSettings, webHostEnvironment)); }
public SystemInformationTelemetryProvider( IUmbracoVersion version, ILocalizationService localizationService, IOptionsMonitor <ModelsBuilderSettings> modelsBuilderSettings, IOptionsMonitor <HostingSettings> hostingSettings, IOptionsMonitor <GlobalSettings> globalSettings, IHostEnvironment hostEnvironment, IUmbracoDatabaseFactory umbracoDatabaseFactory) { _version = version; _localizationService = localizationService; _hostEnvironment = hostEnvironment; _umbracoDatabaseFactory = umbracoDatabaseFactory; _globalSettings = globalSettings.CurrentValue; _hostingSettings = hostingSettings.CurrentValue; _modelsBuilderSettings = modelsBuilderSettings.CurrentValue; }
public void Initialize(ServerWorld world, ServerStateSettings settings) { _world = world; _network = _world.GetServerNode(); _settings = (HostingSettings)settings; _settings.Hide(); _transitionState = ServerStateId.NO_TRANSITION; int maxChars = _network.GetMaxMessageLength() / sizeof(char); _charBuffer = new char[maxChars]; _sb = new StringBuilder(maxChars); if (_settings.randomSeed != 0) { _random = new Random(_settings.randomSeed); } else { _random = new Random(); } }
public DiskImageSpecification LocalCopyDisk(ConnectionSettings connectionSettings, HostingSettings hostingSettings, Action <int> progressCallback, DiskImageSpecification sourceDisk, DiskImageSpecification destinationDisk) { throw new NotImplementedException(); }
public HomeController(ILogger <HomeController> logger, IOptions <HostingSettings> hostSettings) { _logger = logger; _hostSettings = hostSettings.Value; }
public DockerModule(string name, HostingSettings settings, TwinCollection defaultTwin, List <string> routes) : base(name, settings, defaultTwin, routes) { }
//need to abstrace new template from the halted Preparation VM(Qing require stop VM so may call API to stop at the begiining of this function) no need to store the new template in the plugin //and do some code to filter such 'private'templates out of the tree,say when update inventory tree via describeXXX,the new one will be added(to avaoid this by add id in exception list?) public DiskImageSpecification FinalizeMasterImage(ConnectionSettings connectionSettings, HostingSettings hostingSettings, DiskAccessRequest masterDiskAccess, Action <int> progressCallback, DiskImageSpecification requestedDiskProperties) { // nothing to do and just return DiskImageSpecification object with info from masterDiskAccess only id and type need to be assigned logger.TraceEntryExit("ExampleService.GetFinalizeMasterImage (no-op)"); LocalTrace("FinalizeMasterImage ({0})", "called"); //progressCallback(100); return(requestedDiskProperties); }
public DiskImageSpecification ConsolidateMasterImage(ConnectionSettings connectionSettings, HostingSettings hostingSettings, Action <int> progressCallback, InventoryItemReference sourceItem, DiskImageSpecification requestedDiskProperties) { // Dummy implementation logger.TraceEntryExit("ExampleService.GetFinalizeMasterImage (no-op)"); progressCallback(100); return(requestedDiskProperties); }
public IList <MachineLifecycleResult> UpdateMachines(ConnectionSettings connectionSettings, HostingSettings hostingSettings, IList <MachineLifecycleRequest> machineRequests, DiskImageSpecification newMasterImage) { MachineLifecycleRequest request = machineRequests.First(); logger.TraceMsg("Received request to update machine {0}. Treating as no-op under emulation.", request.MachineId); IManagedMachine machine = GetMachineDetails(connectionSettings, request.MachineId); if (machine == null) { throw new NoSuchManagedMachineException(); } else if (machine.State != MachineState.PoweredOff) { // Plug-ins should only expect to receive reset or update requests while the machine is powered off. // Throw an exception when this is found not to be the case. throw new MachineCreationException("Citrix.ExampleService.MachinePoweredOnForUpdate", new string[] { request.MachineId }); } MachineLifecycleResult result = new MachineLifecycleResult(request.MachineId, null); return(new List <MachineLifecycleResult>() { result }); }
public DiskImageSpecification ConsolidateMasterImage(ConnectionSettings connectionSettings, HostingSettings hostingSettings, Action <int> progressCallback, InventoryItemReference sourceItem, DiskImageSpecification requestedDiskProperties) { // nothing to do and just return DiskImageSpecification object with info from sourceItem only id and type need to be assigned logger.TraceEntryExit("ExampleService.GetFinalizeMasterImage (no-op)"); LocalTrace("ConsolidateMasterImage ({0})", "called"); //describeinstace to ensure the infra available check api infra works or not Instance.DescribeInstancesInput input = new Instance.DescribeInstancesInput(); Instance.DescribeInstancesOutput output = new Instance.DescribeInstancesOutput(); output = intance.DescribeInstances(input); // Print the return code. //Console.WriteLine(output.getRet_code()); LocalTrace("PowerOnMachines() retcode is {0}", (output.getRetCode()).ToString()); var consilidatonResultDisk = new DiskImageSpecification( string.Empty, string.Empty, InventoryItemTypes.Template, sourceItem.Id, string.Empty, string.Empty); return(consilidatonResultDisk); }
//ProvisioningSettings provisioningSettings not used(we care serviceoffering in it), just use machineCreationRequests as OS disk public IList <MachineCreationResult> CreateMachines(ConnectionSettings connectionSettings, HostingSettings hostingSettings, ProvisioningSettings provisioningSettings, IList <MachineCreationRequest> machineCreationRequests) { //can check whether 'isolated''in the parameter to ensre whether prep VM. If yes return the hardcode VM. need to consider support bach create machine or not. MachineCreationRequest request = machineCreationRequests.First(); logger.TraceMsg("Received request to create machine {0}", request.MachineName); //Received request to create machine Preparation - VdiCatalog17 MCS will define the name for prep_machine LocalTrace("new Received request to create machine {0}", request.MachineName); string strIDDisk = string.Empty; //InfrastructureEmulator emulator = new InfrastructureEmulator(Path.GetTempPath()); //string id = emulator.CreateVirtualMachine(request); //logger.TraceMsg("Machine {0} has id {1}", request.MachineName, id); //check whether it is request for prep-VM if yes hard code if (request.RunIsolated == true) //better compare name of machine "prepareXXX"? check with Paul eles tem VMs besides prep-VMs? { LocalTrace("RunIsolated VM created {0}", request.MachineName); string id = "i-tvgizngz"; //hardcoded prep VM can the id be "Preparation - VdiCatalog38"? list for struct index_dictionary {id, count } when get details check id if contain 'prep' then search and update count. MachineCreationResult result = new MachineCreationResult( request.MachineName, //name should be defined by MCS such as TEST01,02 id, request.DiskAttachmentRequests.Select(a => new DiskAttachmentResult(a.LocationInventoryType, a.LocationId, a.DiskInventoryType, a.DiskId, a.AttachmentIndex))); //diskattachmentresult should have 2 attach //both attach request and attach result is list last parameter is 'IEnumerable<DiskAttachmentResult> diskAttachmentResults' so real implementation need more invest? //IEnumerable<T> is the base interface for collections in the System.Collections.Generic namespace such as List<T>, Dictionary<TKey,?TValue>, //update the stored prepa name as 'request.MachineName' ii need modify:when create prep_machine can comment and hard code as "i-tvgizngz" when initialized? prepvm_name = request.MachineName; return(new List <MachineCreationResult> { result }); } else { //real VM for catalog string image_id = provisioningSettings.MasterImage.Id; LocalTrace("CreateMachines master image is {0}", image_id); //instance_type or cpu&memory can b achieved from ps script. string login_mode = "passwd"; string login_passwd = "Citrix@111"; InventoryItemReference network_ref = provisioningSettings.Networks.First(); string network = network_ref.Id; LocalTrace("network is {0}", network); string zone = "pekdemo1"; //create identity disk first call the socket to load data on the server and get the id of identity disk IPAddress ip = IPAddress.Parse("100.100.24.36"); Socket clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); try { clientSocket.Connect(new IPEndPoint(ip, 23456)); //config port LocalTrace("connect to svr {0}", "ok"); } catch { LocalTrace("connect to svr {0}", "fail"); //return; } //change stream to byte find the diskattach for identity one firstly //MachineCreationRequest request IList <DiskAttachmentRequest> RealVMDiskList = request.DiskAttachmentRequests; // public const string MachineIdentityRole = "DiskRole.Identity"; not same as the text in chm foreach (DiskAttachmentRequest Diskrst in RealVMDiskList) { LocalTrace("Disk role is {0}", Diskrst.Role); if (string.Equals(Diskrst.Role, "DiskRole.Identity")) // hit the id disk { Stream stream = Diskrst.DiskData; byte[] bytes = new byte[stream.Length + 1]; //maybe construct data,then copy to new arry[lenth+1]? stream.Read(bytes, 0, bytes.Length); bytes[stream.Length] = (byte)'\n'; LocalTrace("hit the id disk sent data is {0} bytes", (bytes.Length).ToString()); string startstr = "QCDiskStart\n"; byte[] startbyteArray = System.Text.Encoding.Default.GetBytes(startstr); string endtstr = "QCDiskEnd\n"; byte[] endbyteArray = System.Text.Encoding.Default.GetBytes(endtstr); // set the location of the stream stream.Seek(0, SeekOrigin.Begin); LocalTrace("stream changed into byte[] {0}", "already"); //send the data, better block-type rcv clientSocket.Send(startbyteArray); LocalTrace("startbyteArray sent {0}", "already"); clientSocket.Send(bytes); LocalTrace("socket sent data {0}", "already"); clientSocket.Send(endbyteArray); LocalTrace("endbyteArray sent {0}", "already"); //receive response from server expected as vol-vnwfrjid no need to encoder/decoder byte[] volumeid = new byte[100]; //string strIDDisk; //use while to rcv until rcv not 0 bytes. int byteCount = 0; while (byteCount == 0) { byteCount = clientSocket.Receive(volumeid, clientSocket.Available, SocketFlags.None); if (byteCount > 0) { strIDDisk = System.Text.Encoding.Default.GetString(volumeid); LocalTrace("rcv valid volumeid and volumeid is {0}", strIDDisk); LocalTrace("rcv valid volumeid size is {0}", byteCount.ToString()); } else { LocalTrace("rcv 0 byte {0}", "already"); } } } else //may need to consider data disk future { //check some string on OS disk LocalTrace("OS disk and volumeid is{0}", Diskrst.DiskId); LocalTrace("OS disk and volumename is{0}", Diskrst.DiskName); } } //now we get the id volume id from server call SDK to create VM when debugging can comment out the segment test volume worker firstly.maybe crash the enviroment by wrong code? Instance.RunInstancesInput input = new Instance.RunInstancesInput(); String[] volumes = { strIDDisk }; String[] networks = { network }; input.setImageId(image_id); input.setCpu(1); input.setMemory(1024); input.setInstanceName(request.MachineName); input.setVolumes(volumes); input.setLoginMode("passwd"); input.setLoginPassword(login_passwd); input.setVxnets(networks); input.setHostname(request.MachineName); //input.setZone("pekdemo1"); input.setCount(1); //String[] vxnets paul:where to ensue the network in catalog? should use the one in profilesetting or creation request? Instance.RunInstancesOutput output = new Instance.RunInstancesOutput(); LocalTrace("start creation {0}", "VM"); output = intance.RunInstances(input); // Print the return code. LocalTrace("CreateMachines() retcode is {0}", (output.getRetCode()).ToString()); LocalTrace("The created VM id is {0}", output.getInstances()); //add VM to inventory tree vms.Add(output.getInstances(), request.MachineName); //construct the DiskAttachmentresult var diskAttachmentResults = new List <DiskAttachmentResult>(); // Add the data disk attachment results for each disk attachrequest foreach (DiskAttachmentRequest Disk_Request in RealVMDiskList) { if (string.Equals(Disk_Request.Role, "DiskRole.Identity")) //identity disk hit maybe string.Empty is not ok for 3rd parameter { diskAttachmentResults.Add(new DiskAttachmentResult(string.Empty, string.Empty, string.Empty, strIDDisk, Disk_Request.AttachmentIndex)); } else //simplized: if not identity disk then is os disk { diskAttachmentResults.Add(new DiskAttachmentResult(string.Empty, string.Empty, string.Empty, image_id, Disk_Request.AttachmentIndex)); } } //construct the machinecreation result MachineCreationResult result = new MachineCreationResult( request.MachineName, //name should be defined by MCS such as TEST01,02 output.getInstances(), diskAttachmentResults); //diskattachmentresult should have 2 attach //both attach request and attach result is list last parameter is 'IEnumerable<DiskAttachmentResult> diskAttachmentResults' so real implementation need more invest? //IEnumerable<T> is the base interface for collections in the System.Collections.Generic namespace such as List<T>, Dictionary<TKey,?TValue>, //take Azure as reference to construct result. //update the stored prepa name as 'request.MachineName' ii need modify:when create prep_machine can comment and hard code as "i-tvgizngz" when initialized? return(new List <MachineCreationResult> { result }); } }
public static HttpConfiguration Configure(IAppBuilder builder, IContainer container, HostingSettings hostingSettings) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (container == null) { throw new ArgumentNullException(nameof(container)); } var configuration = BaseConfiguration(container, hostingSettings); if (hostingSettings.HttpsRequired) { configuration.Filters.Add(new RequireHttpsAttribute()); configuration.Filters.Add(new HSTSAttribute()); } configuration.EnsureInitialized(); builder.UseWebApi(configuration); return(configuration); }
public DiskImageSpecification FinalizeMasterImage(ConnectionSettings connectionSettings, HostingSettings hostingSettings, DiskAccessRequest masterDiskAccess, Action <int> progressCallback, DiskImageSpecification requestedDiskProperties) { // Dummy implementation logger.TraceEntryExit("ExampleService.GetFinalizeMasterImage (no-op)"); progressCallback(100); return(requestedDiskProperties); }
public IList <MachineCreationResult> CreateMachines(ConnectionSettings connectionSettings, HostingSettings hostingSettings, ProvisioningSettings provisioningSettings, IList <MachineCreationRequest> machineCreationRequests) { // Just log to prove that we got here, but no implementation as yet. logger.TraceMsg("An instance creation request has been received!"); var client = connectionSettings.GetComputeClient(); List <MachineCreationResult> results = new List <MachineCreationResult>(); foreach (var request in machineCreationRequests) { /// Something kinda like this... DeployServerType details = new DeployServerType { // Provision the VM into the default network domain and VLAN networkInfo = new DeployServerTypeNetworkInfo { networkDomainId = GetNetworkDomainId(connectionSettings).ToString(), primaryNic = new VlanIdOrPrivateIpType { vlanId = GetVlanId(connectionSettings).ToString() } }, administratorPassword = "******", imageId = GetDefaultImageId(connectionSettings), cpu = new DeployServerTypeCpu { coresPerSocket = _defaultCoresPerSocket, coresPerSocketSpecified = true, count = _defaultCpuCount, countSpecified = true, speed = "STANDARD" // TODO : Make this configurable }, description = "Provisioned by Citrix", name = request.MachineName }; var response = client.ServerManagement.Server.DeployServer(details).Result; // This isn't correct. but an indication of how it's done. results.Add(new MachineCreationResult(response.info[0].value, response.info[0].value, null)); } return(results); }
private HostingConfig() { this.hostingSettings = HostingSettings.LoadHostingSettings(); this.configLock = new RwLock(); this.configStore = NativeConfigStore.FabricGetConfigStore(this); }
public DiskImageSpecification RemoteCopyDisk(ConnectionSettings sourceConnectionSettings, HostingSettings sourceHostingSettings, ConnectionSettings destinationConnectionSettings, HostingSettings destinationHostingSettings, Action <int> progressCallback, DiskImageSpecification sourceDisk, DiskImageSpecification destinationDisk) { throw new NotImplementedException(); }
public DynamicHostController(HostingSettings settings) { this.settings = settings; }
public IList <MachineLifecycleResult> UpdateMachines(ConnectionSettings connectionSettings, HostingSettings hostingSettings, IList <MachineLifecycleRequest> machineRequests, DiskImageSpecification newMasterImage) { throw new NotImplementedException(); }
private IOptionsMonitor <HostingSettings> GetIOptionsMonitorOfHostingSettings() { var hostingSettings = new HostingSettings(); return(Mock.Of <IOptionsMonitor <HostingSettings> >(x => x.CurrentValue == hostingSettings)); }