public WorkerRole() { _pulsers = Pulsers.FromAssembly(Assembly.GetAssembly(typeof(ImportFileProcessed))) .ToList(); var container = new WindsorContainer(); _configurationValueProvider = new AzureConfigurationValueProvider(); SetupDi(container, _configurationValueProvider, _pulsers.ToArray()); _pulserPublisher = container.Resolve<PulserPublisher>(); _orchestrator = container.Resolve<Orchestrator>(); // insert the list here var keyValueStore = container.Resolve<IDynamoStore>(); var blob = new SimpleBlob() { Body = Assembly.GetExecutingAssembly() .GetManifestResourceStream("BeeHive.Sample.FileImport.Worker.Data.SampleData.txt"), Id = "FileDrop/ImportFiles/SampleData.txt", LastModofied = DateTimeOffset.Now }; keyValueStore.UpsertAsync(blob); // add one topic that will not be created automagically by orchestrator // because no actor registered against it var q = container.Resolve<IEventQueueOperator>(); q.CreateQueueAsync("NewIndexUpserted").Wait(); }
public SlideshowView(Orchestrator orchestrator, string viewName, string filePath) { InitializeComponent(); this.viewName = viewName; Orchestrator = orchestrator; HideName = (Storyboard)Resources["HideName"]; ShowName = (Storyboard)Resources["ShowName"]; var names = Directory.GetFiles(filePath, "*.jpg", SearchOption.AllDirectories); Array.Sort(names); allFilenames = new ReadOnlyCollection<string>(Array.ConvertAll(names, Path.GetFullPath)); loadedImages = new BitmapImage[allFilenames.Count]; Focusable = true; MouseEnter += delegate { Focus(); }; autoTimer.Tick += delegate { NavigateBy(1); }; Unloaded += delegate { autoTimer.Stop(); }; }
public WorkerRole() { _pulsers = Pulsers.FromAssembly(Assembly.GetAssembly(typeof(NewsFeedPulsed))) .ToList(); var container = new WindsorContainer(); _configurationValueProvider = new AzureConfigurationValueProvider(); SetupDi(container, _configurationValueProvider, _pulsers.ToArray()); _pulserPublisher = container.Resolve<PulserPublisher>(); _orchestrator = container.Resolve<Orchestrator>(); // insert the list here var keyValueStore = container.Resolve<IKeyValueStore>(); var blob = new SimpleBlob() { Body = new MemoryStream(Encoding.UTF8.GetBytes("http://feeds.bbci.co.uk/news/rss.xml")), Id = "newsFeeds.txt", LastModofied = DateTimeOffset.Now }; keyValueStore.UpsertAsync(blob); }
protected override void CallMethod() => Orchestrator.Start(Pull);
private static void GetServerUpdates() { if (!Program.Configuration.ClientUpdates.IsEnabled) { return; } // ignore all certs ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true; var machine = new ResultMachine(); GuestInfoVars.Load(machine); Thread.Sleep(ProcessManager.Jitter(Program.Configuration.ClientUpdates.CycleSleep)); while (true) { try { string s = string.Empty; using (var client = WebClientBuilder.Build(machine)) { try { using (var reader = new StreamReader(client.OpenRead(Program.Configuration.ClientUpdates.PostUrl))) { s = reader.ReadToEnd(); _log.Debug($"{DateTime.Now} - Received new configuration"); } } catch (WebException wex) { if (((HttpWebResponse)wex.Response).StatusCode == HttpStatusCode.NotFound) { _log.Debug($"{DateTime.Now} - No new configuration found"); } } catch (Exception e) { _log.Error(e); } } if (!string.IsNullOrEmpty(s)) { var update = JsonConvert.DeserializeObject <UpdateClientConfig>(s); switch (update.Type) { case UpdateClientConfig.UpdateType.Timeline: TimelineBuilder.SetLocalTimeline(update.Update.ToString()); break; case UpdateClientConfig.UpdateType.TimelinePartial: try { var timeline = JsonConvert.DeserializeObject <Timeline>(update.Update.ToString()); foreach (var timelineHandler in timeline.TimeLineHandlers) { _log.Trace($"PartialTimeline found: {timelineHandler.HandlerType}"); foreach (var timelineEvent in timelineHandler.TimeLineEvents) { if (string.IsNullOrEmpty(timelineEvent.TrackableId)) { timelineEvent.TrackableId = Guid.NewGuid().ToString(); } } var orchestrator = new Orchestrator(); orchestrator.RunCommand(timelineHandler); } } catch (Exception exc) { _log.Debug(exc); } break; case UpdateClientConfig.UpdateType.Health: { var newTimeline = JsonConvert.DeserializeObject <Domain.ResultHealth>(update.Update.ToString()); //save to local disk using (var file = File.CreateText(ApplicationDetails.ConfigurationFiles.Health)) { var serializer = new JsonSerializer(); serializer.Formatting = Formatting.Indented; serializer.Serialize(file, newTimeline); } break; } default: _log.Debug($"Update {update.Type} has no handler, ignoring..."); break; } } } catch (Exception e) { _log.Debug("Problem polling for new configuration"); _log.Error(e); } Thread.Sleep(ProcessManager.Jitter(Program.Configuration.ClientUpdates.CycleSleep)); } }
protected static void Setup() { var container = new WindsorContainer(); var serviceLocator = new WindsorServiceLocator(container); _configurationValueProvider = new AppSettingsConfigProvider(); var storageConnectionString = _configurationValueProvider.GetValue(ConfigurationKeys.StorageConnectionString); var servicebusConnectionString = _configurationValueProvider.GetValue(ConfigurationKeys.ServiceBusConnectionString); var headersText = _configurationValueProvider.GetValue(ConfigurationKeys.TabSeparatedCustomEsHttpHeaders); var headers = new List <KeyValuePair <string, string> >(); if (headersText != null) { foreach (var header in headersText.Split('\t')) { var strings = header.Split(new[] { ": " }, StringSplitOptions.RemoveEmptyEntries); if (strings.Length == 2) { headers.Add(new KeyValuePair <string, string>(strings[0], strings[1])); } } } container.Register( Component.For <IElasticsearchClient>() .ImplementedBy <ElasticsearchClient>() .LifestyleSingleton(), Component.For <Orchestrator>() .ImplementedBy <Orchestrator>() .LifestyleSingleton(), Component.For <MasterScheduler>() .ImplementedBy <MasterScheduler>() .LifestyleSingleton(), Component.For <IConfigurationValueProvider>() .Instance(_configurationValueProvider), Component.For <ISourceConfiguration>() .ImplementedBy <TableStorageConfigurationSource>(), Component.For <IServiceLocator>() .Instance(serviceLocator), Component.For <IActorConfiguration>() .Instance( ActorDescriptors.FromAssemblyContaining <ShardRangeActor>() .ToConfiguration().UpdateParallelism(_configurationValueProvider)), Component.For <IFactoryActor>() .ImplementedBy <FactoryActor>() .LifestyleTransient(), Component.For <IHttpClient>() .ImplementedBy <DefaultHttpClient>() .LifestyleSingleton() .DependsOn(Dependency.OnValue("defaultHeaders", headers)), Component.For <ShardKeyActor>() .ImplementedBy <ShardKeyActor>() .LifestyleTransient(), Component.For <ShardRangeActor>() .ImplementedBy <ShardRangeActor>() .LifestyleTransient(), Component.For <BlobFileActor>() .ImplementedBy <BlobFileActor>() .LifestyleTransient(), Component.For <BlobFileConventionActor>() .ImplementedBy <BlobFileConventionActor>() .LifestyleTransient(), Component.For <IisBlobScheduler>() .ImplementedBy <IisBlobScheduler>() .LifestyleTransient(), Component.For <IisBlobConventionScheduler>() .ImplementedBy <IisBlobConventionScheduler>() .LifestyleTransient(), Component.For <IIndexNamer>() .ImplementedBy <IndexNamer>() .LifestyleSingleton(), Component.For <RangeShardKeyScheduler>() .ImplementedBy <RangeShardKeyScheduler>() .LifestyleTransient(), Component.For <MinuteTableShardScheduler>() .ImplementedBy <MinuteTableShardScheduler>() .LifestyleTransient(), Component.For <Modulo10MinuteTableShardScheduler>() .ImplementedBy <Modulo10MinuteTableShardScheduler>() .LifestyleTransient(), Component.For <SimpleBlobScheduler>() .ImplementedBy <SimpleBlobScheduler>() .LifestyleTransient(), Component.For <ReverseTimestampMinuteTableShardScheduler>() .ImplementedBy <ReverseTimestampMinuteTableShardScheduler>() .LifestyleTransient(), Component.For <D18MinuteTableShardScheduler>() .ImplementedBy <D18MinuteTableShardScheduler>() .LifestyleTransient(), Component.For <EventHubScheduler>() .ImplementedBy <EventHubScheduler>() .LifestyleTransient(), Component.For <InsightMetricsParser>() .ImplementedBy <InsightMetricsParser>() .LifestyleTransient(), Component.For <GenericJsonParser>() .ImplementedBy <GenericJsonParser>() .LifestyleTransient(), Component.For <IisLogParser>() .ImplementedBy <IisLogParser>() .LifestyleTransient(), Component.For <AkamaiLogParser>() .ImplementedBy <AkamaiLogParser>() .LifestyleTransient(), Component.For <NestBatchPusher>() .ImplementedBy <NestBatchPusher>() .LifestyleTransient() .DependsOn(Dependency.OnValue("esUrl", _configurationValueProvider.GetValue(ConfigurationKeys.ElasticSearchUrl))), Component.For <ILockStore>() .Instance(new AzureLockStore(new BlobSource() { ConnectionString = storageConnectionString, ContainerName = "locks", Path = "conveyor_belt/locks/master_Keys/" })), Component.For <IKeyValueStore>() .Instance(new AzureKeyValueStore(storageConnectionString, "locks")), Component.For <IEventQueueOperator>() .Instance(new ServiceBusOperator(servicebusConnectionString)), Component.For <ITelemetryProvider>() .ImplementedBy <TelemetryProvider>() .LifestyleSingleton() ); _orchestrator = container.Resolve <Orchestrator>(); _scheduler = container.Resolve <MasterScheduler>(); ServicePointHelper.ApplyStandardSettings(_configurationValueProvider.GetValue(ConfigurationKeys.ElasticSearchUrl)); }
public void DoesNotThrowIfSleepWasCalledLast() { Orchestrator.Start(Sleep); callingMethod.Should().NotThrow(); }
public void When_resolving_an_instance() { _orchestrator = Container.Resolve <Orchestrator>(); }
public ProviderProjectComponentsController(UserService userService, Orchestrator orchestrator, IProjectRepository projectRepository, IComponentRepository componentRepository) : base(userService, orchestrator, projectRepository) { this.componentRepository = componentRepository ?? throw new ArgumentNullException(nameof(componentRepository)); }
public StatusController(Orchestrator orchestrator) { this.orchestrator = orchestrator ?? throw new ArgumentNullException(nameof(orchestrator)); }
public void EnqueuePacket <TPacket>(TPacket packet) { Orchestrator.EnqueuePacket(this, packet); }
public async Task <IActionResult> Put([FromRoute] string projectTypeId, [FromBody] ProjectType projectType) { if (string.IsNullOrWhiteSpace(projectTypeId)) { return(ErrorResult .BadRequest($"The identifier '{projectTypeId}' provided in the url path is invalid. Must be a valid project type ID.", ResultErrorCode.ValidationError) .ToActionResult()); } if (projectType is null) { return(ErrorResult .BadRequest("Request body must not be empty.", ResultErrorCode.ValidationError) .ToActionResult()); } if (!projectType.TryValidate(out var validationResult, serviceProvider: HttpContext.RequestServices)) { return(ErrorResult .BadRequest(validationResult) .ToActionResult()); } if (!projectType.Id.Equals(projectTypeId, StringComparison.Ordinal)) { return(ErrorResult .BadRequest(new ValidationError { Field = "id", Message = $"ProjectType's id does match the identifier provided in the path." }) .ToActionResult()); } var projectTypeDocument = await projectTypeRepository .GetAsync(projectType.Id) .ConfigureAwait(false); if (projectTypeDocument is null) { return(ErrorResult .NotFound($"A ProjectType with the ID '{projectType.Id}' could not be found in this TeamCloud Instance") .ToActionResult()); } var providers = await ProviderRepository .ListAsync(includeServiceProviders : false) .ToListAsync() .ConfigureAwait(false); var validProviders = projectType.Providers .All(p => providers.Any(provider => provider.Id == p.Id)); if (!validProviders) { var validProviderIds = string.Join(", ", providers.Select(p => p.Id)); return(ErrorResult .BadRequest(new ValidationError { Field = "projectType", Message = $"All provider ids on a ProjectType must match the id of a registered Provider on the TeamCloud instance and cannot be a Service Provider. Valid provider ids are: {validProviderIds}" }) .ToActionResult()); } var currentUser = await UserService .CurrentUserAsync() .ConfigureAwait(false); projectTypeDocument .PopulateFromExternalModel(projectType); return(await Orchestrator .InvokeAndReturnActionResultAsync <ProjectTypeDocument, ProjectType>(new OrchestratorProjectTypeUpdateCommand(currentUser, projectTypeDocument), Request) .ConfigureAwait(false)); }
public ProjectTypesController(UserService userService, Orchestrator orchestrator, IProviderRepository providerRepository, IProjectTypeRepository projectTypeRepository) : base(userService, orchestrator, providerRepository) { this.projectTypeRepository = projectTypeRepository ?? throw new ArgumentNullException(nameof(projectTypeRepository)); }
public void ShouldCallFreezeOnTheStateMachine() { Orchestrator.Freeze(); StateMachine.Received().Freeze(); }
protected override void CallMethod() => Orchestrator.Start(CleanUp);
/// <summary> /// This method generates the appropriate recommendations for the target deployment project. /// </summary> /// <param name="orchestrator"><see cref="Orchestrator"/></param> /// <returns>A list of <see cref="Recommendation"/></returns> private async Task <List <Recommendation> > GenerateRecommendationsToSaveDeploymentProject(Orchestrator orchestrator) { var recommendations = await orchestrator.GenerateRecommendationsToSaveDeploymentProject(); if (recommendations.Count == 0) { throw new FailedToGenerateAnyRecommendations("The project you are trying to deploy is currently not supported."); } return(recommendations); }
private async Task <List <Recommendation> > GenerateDeploymentRecommendations(Orchestrator orchestrator, string deploymentProjectPath) { List <Recommendation> recommendations; if (!string.IsNullOrEmpty(deploymentProjectPath)) { recommendations = await orchestrator.GenerateRecommendationsFromSavedDeploymentProject(deploymentProjectPath); if (!recommendations.Any()) { var errorMessage = $"Could not find any deployment recipe located inside '{deploymentProjectPath}' that can be used for deployment of the target application"; throw new FailedToGenerateAnyRecommendations(errorMessage); } } else { recommendations = await orchestrator.GenerateDeploymentRecommendations(); if (!recommendations.Any()) { var errorMessage = "There are no compatible deployment recommendations for this application."; throw new FailedToGenerateAnyRecommendations(errorMessage); } } return(recommendations); }
public ProjectUsersController(UserService userService, Orchestrator orchestrator, IProjectRepository projectRepository, IUserRepository userRepository) : base(userService, orchestrator, projectRepository, userRepository) { }
public void GoesToSleepAfterAnErrorIsReported() { OrchestratorSyncComplete.OnNext(new Error(new Exception())); Orchestrator.Received().Start(Arg.Is(Sleep)); }
protected static void Setup() { var container = new WindsorContainer(); var serviceLocator = new WindsorServiceLocator(container); _configurationValueProvider = new AppSettingsConfigProvider(); var storageConnectionString = _configurationValueProvider.GetValue(ConfigurationKeys.StorageConnectionString); var servicebusConnectionString = _configurationValueProvider.GetValue(ConfigurationKeys.ServiceBusConnectionString); container.Register( Component.For <IElasticsearchClient>() .ImplementedBy <ElasticsearchClient>() .LifestyleSingleton(), Component.For <Orchestrator>() .ImplementedBy <Orchestrator>() .LifestyleSingleton(), Component.For <MasterScheduler>() .ImplementedBy <MasterScheduler>() .LifestyleSingleton(), Component.For <IConfigurationValueProvider>() .Instance(_configurationValueProvider), Component.For <ISourceConfiguration>() .ImplementedBy <TableStorageConfigurationSource>(), Component.For <IServiceLocator>() .Instance(serviceLocator), Component.For <IActorConfiguration>() .Instance( ActorDescriptors.FromAssemblyContaining <ShardRangeActor>() .ToConfiguration()), Component.For <IFactoryActor>() .ImplementedBy <FactoryActor>() .LifestyleTransient(), Component.For <IHttpClient>() .ImplementedBy <DefaultHttpClient>() .LifestyleSingleton(), Component.For <ShardKeyActor>() .ImplementedBy <ShardKeyActor>() .LifestyleTransient(), Component.For <ShardRangeActor>() .ImplementedBy <ShardRangeActor>() .LifestyleTransient(), Component.For <BlobFileActor>() .ImplementedBy <BlobFileActor>() .LifestyleTransient(), Component.For <IisBlobScheduler>() .ImplementedBy <IisBlobScheduler>() .LifestyleTransient(), Component.For <RangeShardKeyScheduler>() .ImplementedBy <RangeShardKeyScheduler>() .LifestyleTransient(), Component.For <MinuteTableShardScheduler>() .ImplementedBy <MinuteTableShardScheduler>() .LifestyleTransient(), Component.For <ReverseTimestampMinuteTableShardScheduler>() .ImplementedBy <ReverseTimestampMinuteTableShardScheduler>() .LifestyleTransient(), Component.For <IisLogParser>() .ImplementedBy <IisLogParser>() .LifestyleTransient(), Component.For <IElasticsearchBatchPusher>() .ImplementedBy <ElasticsearchBatchPusher>() .LifestyleTransient() .DependsOn(Dependency.OnValue("esUrl", _configurationValueProvider.GetValue(ConfigurationKeys.ElasticSearchUrl))), Component.For <ILockStore>() .Instance(new AzureLockStore(new BlobSource() { ConnectionString = storageConnectionString, ContainerName = "locks", Path = "conveyor_belt/locks/master_Keys/" })), Component.For <IEventQueueOperator>() .Instance(new ServiceBusOperator(servicebusConnectionString)) ); _orchestrator = container.Resolve <Orchestrator>(); _scheduler = container.Resolve <MasterScheduler>(); }
public TeamCloudTagsController(UserService userService, Orchestrator orchestrator, ITeamCloudRepository teamCloudRepository) : base(userService, orchestrator) { this.teamCloudRepository = teamCloudRepository ?? throw new ArgumentNullException(nameof(teamCloudRepository)); }
private static void Run(string[] args) { // ignore all certs ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true; // parse program flags if (!CommandLineFlagManager.Parse(args)) { return; } //attach handler for shutdown tasks AppDomain.CurrentDomain.ProcessExit += CurrentDomain_ProcessExit; _log.Trace($"Initiating Ghosts startup - Local time: {DateTime.Now.TimeOfDay} UTC: {DateTime.UtcNow.TimeOfDay}"); //load configuration try { Configuration = ClientConfigurationLoader.Config; } catch (Exception e) { var path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var o = $"Exec path: {path} - configuration 404: {ApplicationDetails.ConfigurationFiles.Application} - exiting. Exception: {e}"; _log.Fatal(o); Console.WriteLine(o); Console.ReadLine(); return; } StartupTasks.CheckConfigs(); Thread.Sleep(500); //show window if debugging or if --debug flag passed in var handle = GetConsoleWindow(); if (!IsDebug) { ShowWindow(handle, SwHide); //add hook to manage processes running in order to never tip a machine over StartupTasks.CleanupProcesses(); } //add ghosts to startup StartupTasks.SetStartup(); //add listener on a port or ephemeral file watch to handle ad hoc commands ListenerManager.Run(); //do we have client id? or is this first run? _log.Trace(Comms.CheckId.Id); //connect to command server for 1) client id 2) get updates and 3) sending logs/surveys Comms.Updates.Run(); //local survey gathers information such as drives, accounts, logs, etc. if (Configuration.Survey.IsEnabled) { try { Survey.SurveyManager.Run(); } catch (Exception exc) { _log.Error(exc); } } if (Configuration.HealthIsEnabled) { try { var h = new Health.Check(); h.Run(); } catch (Exception exc) { _log.Error(exc); } } //timeline processing if (Configuration.HandlersIsEnabled) { try { var o = new Orchestrator(); o.Run(); } catch (Exception exc) { _log.Error(exc); } } //ghosts singleton new ManualResetEvent(false).WaitOne(); }
public DeployRecommendationTask(Orchestrator orchestrator, CloudApplication cloudApplication, Recommendation selectedRecommendation) { _orchestrator = orchestrator; _cloudApplication = cloudApplication; _selectedRecommendation = selectedRecommendation; }
public TeamCloudUsersController(UserService userService, Orchestrator orchestrator, ITeamCloudRepositoryReadOnly teamCloudRepository) { this.userService = userService ?? throw new ArgumentNullException(nameof(userService)); this.orchestrator = orchestrator ?? throw new ArgumentNullException(nameof(orchestrator)); this.teamCloudRepository = teamCloudRepository ?? throw new ArgumentNullException(nameof(teamCloudRepository)); }
public ProjectTypesController(Orchestrator orchestrator, IProvidersRepository providersRepository, IProjectTypesRepository projectTypesRepository) { this.orchestrator = orchestrator ?? throw new ArgumentNullException(nameof(orchestrator)); this.providersRepository = providersRepository ?? throw new ArgumentNullException(nameof(providersRepository)); this.projectTypesRepository = projectTypesRepository ?? throw new ArgumentNullException(nameof(projectTypesRepository)); }
protected ApiController(UserService userService, Orchestrator orchestrator) { UserService = userService ?? throw new ArgumentNullException(nameof(userService)); Orchestrator = orchestrator ?? throw new ArgumentNullException(nameof(orchestrator)); }
public TCPListeningServer(Orchestrator p, int port = 9999) { listening_port = port; this.p = p; processor = new MessageProcessor(p); }
public override bool OnStart() { // Set the maximum number of concurrent connections ServicePointManager.DefaultConnectionLimit = 1200; // For information on handling configuration changes // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357. var container = new WindsorContainer(); ConfigureDI(container); _orchestrator = container.Resolve<Orchestrator>(); _orchestrator.SetupAsync().Wait(); _orchestrator.Start(); _queueOperator = container.Resolve<IEventQueueOperator>(); _orderStore = container.Resolve<ICollectionStore<Order>>(); _customerStore = container.Resolve<ICollectionStore<Customer>>(); return base.OnStart(); }
public void ShouldThrowIfPushSyncing() { Orchestrator.Start(Push); callingMethod.Should().Throw <InvalidOperationException>(); }
public MessageView(Orchestrator orchestrator) { InitializeComponent(); Orchestrator = orchestrator; DoSetMessage("Welcome!"); }
protected ApiController(UserService userService, Orchestrator orchestrator, IProjectRepository projectRepository, IUserRepository userRepository) : this(userService, orchestrator) { ProjectRepository = projectRepository ?? throw new ArgumentNullException(nameof(projectRepository)); UserRepository = userRepository ?? throw new ArgumentNullException(nameof(userRepository)); }
public async Task <IActionResult> Post([FromBody] Provider provider) { if (provider is null) { throw new ArgumentNullException(nameof(provider)); } var validation = new ProviderValidator().Validate(provider); if (!validation.IsValid) { return(ErrorResult .BadRequest(validation) .ToActionResult()); } var providerDocument = await ProviderRepository .GetAsync(provider.Id) .ConfigureAwait(false); if (providerDocument != null) { return(ErrorResult .Conflict($"A Provider with the ID '{provider.Id}' already exists on this TeamCloud Instance. Please try your request again with a unique ID or call PUT to update the existing Provider.") .ToActionResult()); } if (provider.Type == ProviderType.Virtual) { var serviceProviders = await ProviderRepository .ListAsync(providerType : ProviderType.Service) .ToListAsync() .ConfigureAwait(false); var serviceProvider = serviceProviders .FirstOrDefault(p => provider.Id.StartsWith($"{p.Id}.", StringComparison.Ordinal)); if (serviceProvider is null) { var validServiceProviderIds = string.Join(", ", serviceProviders.Select(p => p.Id)); return(ErrorResult .BadRequest(new ValidationError { Field = "id", Message = $"No matching service provider found. Virtual provider ids must begin with the associated Service provider id followed by a period (.). Available service providers: {validServiceProviderIds}" }) .ToActionResult()); } var urlPrefix = $"{serviceProvider.Url}?"; if (!provider.Url.StartsWith(urlPrefix, StringComparison.OrdinalIgnoreCase)) { return(ErrorResult .BadRequest(new ValidationError { Field = "url", Message = $"Virtual provider url must match the associated service provider url followed by a query string. The url should begin with {urlPrefix}" }) .ToActionResult()); } } var currentUser = await UserService .CurrentUserAsync() .ConfigureAwait(false); providerDocument = new ProviderDocument() .PopulateFromExternalModel(provider); var command = new OrchestratorProviderCreateCommand(currentUser, providerDocument); return(await Orchestrator .InvokeAndReturnActionResultAsync <ProviderDocument, Provider>(command, Request) .ConfigureAwait(false)); }
public ProjectUsersController(UserService userService, Orchestrator orchestrator, IProjectsRepositoryReadOnly projectsRepository) { this.userService = userService ?? throw new ArgumentNullException(nameof(userService)); this.orchestrator = orchestrator ?? throw new ArgumentNullException(nameof(orchestrator)); this.projectsRepository = projectsRepository ?? throw new ArgumentNullException(nameof(projectsRepository)); }
public void FreezesTheSyncManagerWhenAKnownClientErrorExceptionIsReported(ClientErrorException exception) { OrchestratorSyncComplete.OnNext(new Error(exception)); Orchestrator.Received().Freeze(); }
public void When_resolving_an_instance() { _orchestrator = Container.Resolve<Orchestrator>(); }
/// <summary> /// Initiates a deployment or a re-deployment. /// If a new Cloudformation stack name is selected, then a fresh deployment is initiated with the user-selected deployment recipe. /// If an existing Cloudformation stack name is selected, then a re-deployment is initiated with the same deployment recipe. /// </summary> /// <param name="stackName">The stack name provided via the --stack-name CLI argument</param> /// <param name="userDeploymentSettings">The deserialized object from the user provided config file.<see cref="UserDeploymentSettings"/></param> /// <param name="deploymentProjectPath">The absolute or relative path of the CDK project that will be used for deployment</param> /// <returns>A tuple consisting of the Orchestrator object, Selected Recommendation, Cloud Application metadata.</returns> public async Task <(Orchestrator, Recommendation, CloudApplication)> InitializeDeployment(string stackName, UserDeploymentSettings?userDeploymentSettings, string deploymentProjectPath) { var orchestrator = new Orchestrator( _session, _orchestratorInteractiveService, _cdkProjectHandler, _cdkManager, _cdkVersionDetector, _awsResourceQueryer, _deploymentBundleHandler, _localUserSettingsEngine, _dockerEngine, _customRecipeLocator, new List <string> { RecipeLocator.FindRecipeDefinitionsPath() }, _directoryManager); // Determine what recommendations are possible for the project. var recommendations = await GenerateDeploymentRecommendations(orchestrator, deploymentProjectPath); // Get all existing applications that were previously deployed using our deploy tool. var allDeployedApplications = await _deployedApplicationQueryer.GetExistingDeployedApplications(); // Filter compatible applications that can be re-deployed using the current set of recommendations. var compatibleApplications = await _deployedApplicationQueryer.GetCompatibleApplications(recommendations, allDeployedApplications, _session); // Get Cloudformation stack name. var cloudApplicationName = GetCloudApplicationName(stackName, userDeploymentSettings, compatibleApplications); // Find existing application with the same CloudFormation stack name. var deployedApplication = allDeployedApplications.FirstOrDefault(x => string.Equals(x.Name, cloudApplicationName)); Recommendation?selectedRecommendation = null; if (deployedApplication != null) { // Verify that the target application can be deployed using the current set of recommendations if (!compatibleApplications.Any(app => app.StackName.Equals(deployedApplication.StackName, StringComparison.Ordinal))) { var errorMessage = $"{deployedApplication.StackName} already exists as a Cloudformation stack but a compatible recommendation to perform a redeployment was no found"; throw new FailedToFindCompatibleRecipeException(errorMessage); } // preset settings for deployment based on last deployment. selectedRecommendation = await GetSelectedRecommendationFromPreviousDeployment(recommendations, deployedApplication, userDeploymentSettings); } else { if (!string.IsNullOrEmpty(deploymentProjectPath)) { selectedRecommendation = recommendations.First(); } else { selectedRecommendation = GetSelectedRecommendation(userDeploymentSettings, recommendations); } } // Apply the user entered stack name to the recommendation so that any default settings based on stack name are applied. selectedRecommendation.AddReplacementToken(REPLACE_TOKEN_STACK_NAME, cloudApplicationName); var cloudApplication = new CloudApplication(cloudApplicationName, selectedRecommendation.Recipe.Id); return(orchestrator, selectedRecommendation, cloudApplication); }