public static Location Get(ResourceProvider provider, string name) { #region Preconditions if (provider == null) { throw new ArgumentNullException(nameof(provider)); } if (name == null) { throw new ArgumentNullException(nameof(name)); } #endregion switch (provider.Id) { case 2: return(Aws.Get(name)); case 3: return(Gcp.Get(name)); case 10: return(DigitalOcean.Get(name)); case 105: return(GCore.Get(name)); } throw ResourceError.NotFound(provider, ResourceTypes.Location, name); }
public configurationController( IApplicationLifetime applicationLifetime, IWritableOptions <General> general_options, IWritableOptions <Database> database_options, IWritableOptions <Smtp> smtp_options, IWritableOptions <Media> media_options, IWritableOptions <Features> features_options, IWritableOptions <Listing> listings_options, IWritableOptions <Authentication> authentication_options, IWritableOptions <Registration> registration_options, IWritableOptions <Aws> aws_options, IWritableOptions <Social> social_options, IWritableOptions <Contact> contact_options, IWritableOptions <Rechapcha> rechapcha_options, IOptions <General> generalSettings, IOptions <Smtp> smtpSettings, IOptions <Media> mediaSettings, IOptions <Features> featureSettings, IOptions <Listing> listingSettings, IOptions <Authentication> authenticationSettings, IOptions <Registration> registrationSettings, IOptions <Aws> awsSettings, IOptions <Social> socialSettings, IOptions <Contact> contactSettings, IOptions <Rechapcha> rechapchaSettings ) { // writable injectors _database_options = database_options; _general_options = general_options; _smtp_options = smtp_options; _media_options = media_options; _features_options = features_options; _listings_options = listings_options; _authentication_options = authentication_options; _registration_options = registration_options; _aws_options = aws_options; _social_options = social_options; _contact_options = contact_options; _rechapcha_options = rechapcha_options; ApplicationLifetime = applicationLifetime; // readable injectors _generalSettings = generalSettings.Value; _smtpSettings = smtpSettings.Value; _mediaSettings = mediaSettings.Value; _featureSettings = featureSettings.Value; _listingSettings = listingSettings.Value; _authenticationSettings = authenticationSettings.Value; _registrationSettings = registrationSettings.Value; _awsSettings = awsSettings.Value; _socialSettings = socialSettings.Value; _contactSettings = contactSettings.Value; _rechapchaSettings = rechapchaSettings.Value; }
public static Location Get(int id) { var lid = LocationId.Create(id); if (lid.ProviderId == 2) // AWS { var region = Aws.FindByRegionNumber(lid.RegionNumber); return((lid.ZoneNumber != 0) ? region.WithZone(ZoneHelper.GetLetter(lid.ZoneNumber)) : region); } if (lid.ProviderId == 3) // GCP { if (lid.Type == LocationType.MultiRegion) { switch (lid.ZoneNumber) { case 1: return(Gcp.US); case 2: return(Gcp.EU); case 3: return(Gcp.Asia); default: throw new Exception("No multi-region found:" + lid.ZoneNumber); } } return(Gcp.FindByRegionNumber(lid.RegionNumber)); } if (lid.ProviderId == 4) // Azure { throw new Exception("Azure is not supported"); } if (lid.ProviderId == ResourceProvider.GCore.Id) { return(GCore.Get(id)); } if (lid.ProviderId == 10) // Digital Ocean { return(DigitalOcean.FindByRegionNumber(lid.RegionNumber)); } if (lid.ProviderId == ResourceProvider.Wasabi.Id) { return(Wasabi.FindByRegionNumber(lid.RegionNumber)); } throw new Exception($"Unexpected id: {lid.ProviderId}|{lid.RegionNumber}|{lid.ZoneNumber}"); }
/// <summary> /// Validates the options and also ensures that all <c>null</c> properties are /// initialized to their default values. /// </summary> /// <param name="clusterDefinition">The cluster definition.</param> /// <exception cref="ClusterDefinitionException">Thrown if the definition is not valid.</exception> public void Validate(ClusterDefinition clusterDefinition) { Covenant.Requires <ArgumentNullException>(clusterDefinition != null, nameof(clusterDefinition)); switch (Environment) { case HostingEnvironment.Aws: if (Aws == null) { throw new ClusterDefinitionException($"[{nameof(ClusterDefinition.Hosting)}.{nameof(Aws)}] must be initialized when cloud provider is [{Environment}]."); } Aws.Validate(clusterDefinition); Cloud = Cloud ?? new CloudOptions(); Cloud.Validate(clusterDefinition); break; case HostingEnvironment.Azure: if (Azure == null) { throw new ClusterDefinitionException($"[{nameof(ClusterDefinition.Hosting)}.{nameof(Azure)}] must be initialized when cloud provider is [{Environment}]."); } Azure.Validate(clusterDefinition); Cloud = Cloud ?? new CloudOptions(); Cloud.Validate(clusterDefinition); break; case HostingEnvironment.BareMetal: Machine = Machine ?? new MachineHostingOptions(); Machine.Validate(clusterDefinition); break; case HostingEnvironment.Google: if (Google == null) { throw new ClusterDefinitionException($"[{nameof(ClusterDefinition.Hosting)}.{nameof(Google)}] must be initialized when cloud provider is [{Environment}]."); } Google.Validate(clusterDefinition); Cloud = Cloud ?? new CloudOptions(); Cloud.Validate(clusterDefinition); break; case HostingEnvironment.HyperV: HyperV = HyperV ?? new HyperVHostingOptions(); HyperV.Validate(clusterDefinition); Vm = Vm ?? new VmHostingOptions(); Vm.Validate(clusterDefinition); break; case HostingEnvironment.XenServer: XenServer = XenServer ?? new XenServerHostingOptions(); XenServer.Validate(clusterDefinition); Cloud = Cloud ?? new CloudOptions(); Cloud.Validate(clusterDefinition); Vm = Vm ?? new VmHostingOptions(); Vm.Validate(clusterDefinition); break; default: throw new NotImplementedException(); } }
public void Validate(ClusterDefinition clusterDefinition) { Covenant.Requires <ArgumentNullException>(clusterDefinition != null, nameof(clusterDefinition)); switch (Environment) { case HostingEnvironments.Aws: if (Aws == null) { throw new ClusterDefinitionException($"[{nameof(HostingOptions)}.{nameof(Aws)}] must be initialized when cloud provider is [{Environment}]."); } Aws.Validate(clusterDefinition); break; case HostingEnvironments.Azure: if (Azure == null) { throw new ClusterDefinitionException($"[{nameof(HostingOptions)}.{nameof(Azure)}] must be initialized when cloud provider is [{Environment}]."); } Azure.Validate(clusterDefinition); break; case HostingEnvironments.Google: if (Google == null) { throw new ClusterDefinitionException($"[{nameof(HostingOptions)}.{nameof(Google)}] must be initialized when cloud provider is [{Environment}]."); } Google.Validate(clusterDefinition); break; case HostingEnvironments.HyperV: HyperV = HyperV ?? new HyperVOptions(); HyperV.Validate(clusterDefinition); break; case HostingEnvironments.HyperVLocal: HyperVDev = HyperVDev ?? new LocalHyperVOptions(); HyperVDev.Validate(clusterDefinition); break; case HostingEnvironments.Machine: Machine = Machine ?? new MachineOptions(); Machine.Validate(clusterDefinition); break; case HostingEnvironments.XenServer: XenServer = XenServer ?? new XenServerOptions(); XenServer.Validate(clusterDefinition); break; default: throw new NotImplementedException(); } if (!string.IsNullOrWhiteSpace(VmNamePrefix)) { if (!ClusterDefinition.IsValidName(VmNamePrefix)) { throw new ClusterDefinitionException($"[{nameof(HostingOptions)}.{nameof(VmNamePrefix)}={VmNamePrefix}] must include only letters, digits, underscores, or periods."); } } }
public configurationController( IApplicationLifetime applicationLifetime, IWritableOptions <General> general_options, IWritableOptions <Database> database_options, IWritableOptions <Comments> comment_options, IWritableOptions <Smtp> smtp_options, IWritableOptions <Media> media_options, IWritableOptions <Features> features_options, IWritableOptions <Listing> listings_options, IWritableOptions <Authentication> authentication_options, IWritableOptions <Registration> registration_options, IWritableOptions <Aws> aws_options, IWritableOptions <Social> social_options, IWritableOptions <Contact> contact_options, IWritableOptions <Rechapcha> rechapcha_options, IWritableOptions <ElasticSearch> elasticsearch_options, IWritableOptions <ActiveCompaign> activecompany_options, IWritableOptions <Zendesk> zendesk_options, IOptions <General> generalSettings, IOptions <Comments> commentSettings, IOptions <Smtp> smtpSettings, IOptions <Media> mediaSettings, IOptions <Features> featureSettings, IOptions <Listing> listingSettings, IOptions <Authentication> authenticationSettings, IOptions <Registration> registrationSettings, IOptions <Aws> awsSettings, IOptions <Social> socialSettings, IOptions <Contact> contactSettings, IOptions <Rechapcha> rechapchaSettings, IOptions <ElasticSearch> elasticSearchSettings, IOptions <Zendesk> zendeskSettings, IOptions <ActiveCompaign> activeSettings, IOptions <Jugnoon.Blogs.Settings.General> blogs_general_Settings, IOptions <Jugnoon.Blogs.Settings.Aws> blogs_aws_Settings, ApplicationDbContext context ) { _context = context; // writable injectors _database_options = database_options; _general_options = general_options; _comment_options = comment_options; _smtp_options = smtp_options; _media_options = media_options; _features_options = features_options; _listings_options = listings_options; _authentication_options = authentication_options; _registration_options = registration_options; _aws_options = aws_options; _social_options = social_options; _contact_options = contact_options; _rechapcha_options = rechapcha_options; _elasticsearch_options = elasticsearch_options; _activecompaign_options = activecompany_options; _zendesk_options = zendesk_options; ApplicationLifetime = applicationLifetime; // readable injectors _generalSettings = generalSettings.Value; _commentSettings = commentSettings.Value; _smtpSettings = smtpSettings.Value; _mediaSettings = mediaSettings.Value; _featureSettings = featureSettings.Value; _listingSettings = listingSettings.Value; _authenticationSettings = authenticationSettings.Value; _registrationSettings = registrationSettings.Value; _awsSettings = awsSettings.Value; _socialSettings = socialSettings.Value; _contactSettings = contactSettings.Value; _rechapchaSettings = rechapchaSettings.Value; _elasticSearchSettings = elasticSearchSettings.Value; _zendeskSettings = zendeskSettings.Value; _activeSettings = activeSettings.Value; _blogs_general_Settings = blogs_general_Settings.Value; _blogs_aws_Settings = blogs_aws_Settings.Value; }
public void Validate(HiveDefinition hiveDefinition) { Covenant.Requires <ArgumentNullException>(hiveDefinition != null); switch (Environment) { case HostingEnvironments.Aws: if (Aws == null) { throw new HiveDefinitionException($"[{nameof(HostingOptions)}.{nameof(Aws)}] must be initialized when cloud provider is [{Environment}]."); } Aws.Validate(hiveDefinition); break; case HostingEnvironments.Azure: if (Azure == null) { throw new HiveDefinitionException($"[{nameof(HostingOptions)}.{nameof(Azure)}] must be initialized when cloud provider is [{Environment}]."); } Azure.Validate(hiveDefinition); break; case HostingEnvironments.Google: if (Google == null) { throw new HiveDefinitionException($"[{nameof(HostingOptions)}.{nameof(Google)}] must be initialized when cloud provider is [{Environment}]."); } Google.Validate(hiveDefinition); break; case HostingEnvironments.HyperV: HyperV = HyperV ?? new HyperVOptions(); HyperV.Validate(hiveDefinition); break; case HostingEnvironments.HyperVDev: LocalHyperV = LocalHyperV ?? new LocalHyperVOptions(); LocalHyperV.Validate(hiveDefinition); break; case HostingEnvironments.Machine: Machine = Machine ?? new MachineOptions(); Machine.Validate(hiveDefinition); break; case HostingEnvironments.XenServer: XenServer = XenServer ?? new XenServerOptions(); XenServer.Validate(hiveDefinition); break; default: throw new NotImplementedException(); } if (IsCloudProvider && !hiveDefinition.Vpn.Enabled) { // VPN is implicitly enabled when hosting on a cloud. hiveDefinition.Vpn.Enabled = true; } if (!string.IsNullOrWhiteSpace(VmNamePrefix)) { if (!HiveDefinition.IsValidName(VmNamePrefix)) { throw new HiveDefinitionException($"[{nameof(HostingOptions)}.{nameof(VmNamePrefix)}={VmNamePrefix}] must include only letters, digits, underscores, or periods."); } } }
public configurationController( IApplicationLifetime applicationLifetime, IWritableOptions<General> general_options, IWritableOptions<Database> database_options, IWritableOptions<Premium> premium_options, IWritableOptions<Smtp> smtp_options, IWritableOptions<Media> media_options, IWritableOptions<Features> features_options, IWritableOptions<Listing> listings_options, IWritableOptions<Authentication> authentication_options, IWritableOptions<Registration> registration_options, IWritableOptions<Aws> aws_options, IWritableOptions<Social> social_options, IWritableOptions<Contact> contact_options, IWritableOptions<Comments> comment_options, IWritableOptions<Location> location_options, IWritableOptions<Rechapcha> rechapcha_options, IOptions<General> generalSettings, IOptions<Premium> premiumSettings, IOptions<Smtp> smtpSettings, IOptions<Media> mediaSettings, IOptions<Features> featureSettings, IOptions<Listing> listingSettings, IOptions<Authentication> authenticationSettings, IOptions<Registration> registrationSettings, IOptions<Aws> awsSettings, IOptions<Social> socialSettings, IOptions<Contact> contactSettings, IOptions<Comments> commentSetings, IOptions<Location> locationSettings, IOptions<Rechapcha> rechapchaSettings, IOptions<Jugnoon.Videos.Settings.General> videos_general_Settings, IOptions<Jugnoon.Videos.Settings.Aws> videos_aws_Settings, IOptions<Jugnoon.Videos.Settings.Ffmpeg> videos_ffmpeg_Settings, IOptions<Jugnoon.Videos.Settings.Youtube> videos_youtube_Settings, IOptions<Jugnoon.Videos.Settings.Direct> videos_direct_Settings, IOptions<Jugnoon.Videos.Settings.Movie> videos_movie_Settings, IOptions<Jugnoon.Videos.Settings.Player> videos_player_Settings ) { // writable injectors _database_options = database_options; _general_options = general_options; _premium_options = premium_options; _smtp_options = smtp_options; _media_options = media_options; _features_options = features_options; _listings_options = listings_options; _authentication_options = authentication_options; _registration_options = registration_options; _aws_options = aws_options; _social_options = social_options; _contact_options = contact_options; _comment_options = comment_options; _location_options = location_options; _rechapcha_options = rechapcha_options; ApplicationLifetime = applicationLifetime; // readable injectors _generalSettings = generalSettings.Value; _premiumSettings = premiumSettings.Value; _smtpSettings = smtpSettings.Value; _mediaSettings = mediaSettings.Value; _featureSettings = featureSettings.Value; _listingSettings = listingSettings.Value; _authenticationSettings = authenticationSettings.Value; _registrationSettings = registrationSettings.Value; _awsSettings = awsSettings.Value; _socialSettings = socialSettings.Value; _contactSettings = contactSettings.Value; _commentSettings = commentSetings.Value; _locationSettings = locationSettings.Value; _rechapchaSettings = rechapchaSettings.Value; _videos_general_Settings = videos_general_Settings.Value; _videos_aws_Settings = videos_aws_Settings.Value; _videos_ffmpeg_Settings = videos_ffmpeg_Settings.Value; _videos_youtube_Settings = videos_youtube_Settings.Value; _videos_direct_Settings = videos_direct_Settings.Value; _videos_movie_Settings = videos_movie_Settings.Value; _videos_player_Settings = videos_player_Settings.Value; }
public ForceMapController(Config config) { s3 = new Aws(config); }