private Task <ProcessResult> SetWiFiSSIDPassphraseSequence(NetworkProperties theModel) { return(Task.Run(async() => { Log?.Invoke(EventLogEntryCodes.SSIDChanging, new string[] { theModel.NewSSID }); var AddNetworkTask = await ProcessRunner.GetProcessResultAsync(c_WPACliCommand, "-i wlan0 add_network"); var NewNetworkId = AddNetworkTask.GetOutput().Trim(); ProcessResult SetSSID = await ProcessRunner.GetProcessResultAsync(c_WPACliCommand, "-i wlan0 set_network " + NewNetworkId + " ssid '\"" + theModel.NewSSID + "\"'"); ProcessResult SetPassphrase; if (string.IsNullOrEmpty(theModel.NewPassphrase)) { SetPassphrase = await ProcessRunner.GetProcessResultAsync(c_WPACliCommand, "-i wlan0 set_network " + NewNetworkId + " key_mgmt NONE"); } else { SetPassphrase = await ProcessRunner.GetProcessResultAsync(c_WPACliCommand, "-i wlan0 set_network " + NewNetworkId + " psk '\"" + theModel.NewPassphrase + "\"'"); } await ProcessRunner.GetProcessResultAsync(c_WPACliCommand, "-i wlan0 enable_network " + NewNetworkId); await ProcessRunner.GetProcessResultAsync(c_WPACliCommand, "-i wlan0 save_config"); await ProcessRunner.GetProcessResultAsync(c_WPACliCommand, "-i wlan0 reconfigure"); return new ProcessResult(0, string.Empty, string.Empty); })); }
static INeuralNetwork BuildPsoNetwork() { var props = new NetworkProperties { InitWeightMin = -0.1, InitWeightMax = 0.1, NumHidden = 2, NumInput = 4, NumOutput = 3 }; var particleProps = new ParticleProperties { MaxVDelta = 2.0, MinVDelta = -2.0, V = 3.0, VSelf = 2.0, VSocial = 2.0 }; var netProps = new PsoNetworkProperties { DesiredAccuracy = 0.98, Iterations = 1000, NumNetworks = 4, ParticleProps = particleProps }; return(new PsoNetwork(netProps, props, new Random(0))); }
public void TestCreateClusterWithOutboundAndPrivateLink() { TestInitialize(); string clusterName = TestUtilities.GenerateName("hdisdk-outboundpl"); var createParams = CommonData.PrepareClusterCreateParamsForWasb(); createParams.Location = "South Central US"; var networkProperties = new NetworkProperties(ResourceProviderConnection.Outbound, PrivateLink.Enabled); createParams.Properties.NetworkProperties = networkProperties; string storageAccountResourceId = string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Storage/storageAccounts/{2}", CommonData.SubscriptionId, CommonData.ResourceGroupName, CommonData.StorageAccountName); createParams.Properties.StorageProfile.Storageaccounts[0].ResourceId = storageAccountResourceId; string vnetId = "/subscriptions/964c10bb-8a6c-43bc-83d3-6b318c6c7305/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/fakevnet"; string subnetId = "/subscriptions/964c10bb-8a6c-43bc-83d3-6b318c6c7305/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/fakevnet/subnets/default"; foreach (var role in createParams.Properties.ComputeProfile.Roles) { role.VirtualNetworkProfile = new VirtualNetworkProfile(vnetId, subnetId); } var cluster = HDInsightClient.Clusters.Create(CommonData.ResourceGroupName, clusterName, createParams); var result = HDInsightClient.Clusters.Get(CommonData.ResourceGroupName, clusterName); ValidateCluster(clusterName, createParams, result); Assert.NotNull(result.Properties.ConnectivityEndpoints.First().PrivateIPAddress); }
public void TestCreateClusterWithOutboundAndPrivateLink() { TestInitialize(); string clusterName = TestUtilities.GenerateName("hdisdk-outboundpl"); var createParams = CommonData.PrepareClusterCreateParamsForWasb(); createParams.Location = "South Central US"; var networkProperties = new NetworkProperties(ResourceProviderConnection.Outbound, PrivateLink.Enabled); createParams.Properties.NetworkProperties = networkProperties; string vnetId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/fakevnet"; string subnetId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/fakevnet/subnets/default"; foreach (var role in createParams.Properties.ComputeProfile.Roles) { role.VirtualNetworkProfile = new VirtualNetworkProfile(vnetId, subnetId); } var cluster = HDInsightClient.Clusters.Create(CommonData.ResourceGroupName, clusterName, createParams); var result = HDInsightClient.Clusters.Get(CommonData.ResourceGroupName, clusterName); ValidateCluster(clusterName, createParams, result); }
public void CanInsertNetwork() { var entityPropertyCollection = NetworkProperties.Get(); var command = PriceNetSqlGenerator.GenerateInsertCommand(entityPropertyCollection); ParseSql(command.CommandText); TestCommand(command); }
public Response Post(NetworkProperties theModel) { Core.Instance.Network.UpdateProperties(theModel); return(new Response { StatusCode = System.Net.HttpStatusCode.Moved, Location = new Uri(Context.Request.AbsoluteUri) }); }
private void addNewToolStripMenuItem1_Click(object sender, EventArgs e) { NetworkProperties networkProp = new NetworkProperties(""); String strNewNetwork = ShowProperties(true, networkProp, "Add New Network"); try { List <NetworkObject> listNetworks = GlobalDatabaseOperations.GetNetworks(); NetworkObject networkObject = listNetworks.Find(delegate(NetworkObject no) { return(no.Network == strNewNetwork); }); if (networkObject != null) { AddNewNetwork(networkObject); } } catch (Exception except) { OutputWindow.WriteOutput("Error: Error adding Network:" + strNewNetwork + ". " + except.Message); } }
static INeuralNetwork BuildBackPropNetwork() { var props = new NetworkProperties { InitWeightMin = -0.1, InitWeightMax = 0.1, NumHidden = 2, NumInput = 4, NumOutput = 3 }; var backProps = new BackPropProperties { learnRate = 0.05, maxEprochs = 2000, momentum = 0.00, weightDecay = 0.000, mseStopCondition = 0.020 }; return(new BackPropNetwork(props, backProps, new Random(0))); }
public Response Get() { NetworkProperties Properties = Core.Instance.Network.RepopulateAndGetProperties(); if (Utils.Hardware.isRunningRaspberryPi) { return(new Response { Model = Properties, Template = Templates.Network }); } else { return(new Response { StatusCode = System.Net.HttpStatusCode.Redirect, Location = new Uri(Context.Paths.Base + Context.Paths.Home) }); } }
public NetworkButtonPanel(NetworkProperties props) { InitializeComponent(); Height = 80; Background = new SolidColorBrush() { Color = Color.FromRgb(255, 255, 255) }; NetworkName.Content = props.Name; AccuracyLabel.Content = props.IsInitialized ? "Initialized" : "Uninitialized"; AccuracyLabel.Foreground = new SolidColorBrush() { Color = props.IsInitialized ? Color.FromRgb(200, 255, 200) : Color.FromRgb(100, 100, 100) }; string networkSizeString = props.Size.InputLayerLength + "-"; foreach (int layerLength in props.Size.InternalLayerLengths) { networkSizeString += layerLength + "-"; } networkSizeString += props.Size.OutputLayerLength; NetworkSizeLabel.Content = networkSizeString; VerticalAlignment = System.Windows.VerticalAlignment.Top; }
public AzureHDInsightNetworkProperties(NetworkProperties networkProperties = null) { ResourceProviderConnection = networkProperties?.ResourceProviderConnection; PrivateLink = networkProperties?.PrivateLink; }
public override void ExecuteCmdlet() { foreach (var component in ComponentVersion.Where(component => !clusterComponentVersion.ContainsKey(component.Key))) { clusterComponentVersion.Add(component.Key, component.Value); } // Construct Configurations foreach (var config in Configurations.Where(config => !clusterConfigurations.ContainsKey(config.Key))) { clusterConfigurations.Add(config.Key, config.Value); } // Add cluster username/password to gateway config. ClusterCreateHelper.AddClusterCredentialToGatewayConfig(HttpCredential, clusterConfigurations); // Construct OS Profile OsProfile osProfile = ClusterCreateHelper.CreateOsProfile(SshCredential, SshPublicKey); // Construct Virtual Network Profile VirtualNetworkProfile vnetProfile = ClusterCreateHelper.CreateVirtualNetworkProfile(VirtualNetworkId, SubnetName); // Handle storage account StorageProfile storageProfile = new StorageProfile() { Storageaccounts = new List <StorageAccount> { } }; if (StorageAccountType == null || StorageAccountType == StorageType.AzureStorage) { var azureStorageAccount = ClusterCreateHelper.CreateAzureStorageAccount(ClusterName, StorageAccountResourceId, StorageAccountKey, StorageContainer, this.DefaultContext.Environment.StorageEndpointSuffix); storageProfile.Storageaccounts.Add(azureStorageAccount); } else if (StorageAccountType == StorageType.AzureDataLakeStore) { ClusterCreateHelper.AddAzureDataLakeStorageGen1ToCoreConfig(StorageAccountResourceId, StorageRootPath, this.DefaultContext.Environment.AzureDataLakeStoreFileSystemEndpointSuffix, clusterConfigurations); } else if (StorageAccountType == StorageType.AzureDataLakeStorageGen2) { var adlsgen2Account = ClusterCreateHelper.CreateAdlsGen2StorageAccount(ClusterName, StorageAccountResourceId, StorageAccountKey, StorageFileSystem, StorageAccountManagedIdentity, this.DefaultContext.Environment.StorageEndpointSuffix); storageProfile.Storageaccounts.Add(adlsgen2Account); } // Handle additional storage accounts foreach ( var storageAccount in AdditionalStorageAccounts.Where( storageAccount => !clusterAdditionalStorageAccounts.ContainsKey(storageAccount.Key))) { clusterAdditionalStorageAccounts.Add(storageAccount.Key, storageAccount.Value); } ClusterCreateHelper.AddAdditionalStorageAccountsToCoreConfig(clusterAdditionalStorageAccounts, clusterConfigurations); // Handle script action foreach (var action in ScriptActions.Where(action => clusterScriptActions.ContainsKey(action.Key))) { clusterScriptActions.Add(action.Key, action.Value.Select(a => a.GetScriptActionFromPSModel()).ToList()); } // Handle metastore if (OozieMetastore != null) { ClusterCreateHelper.AddOozieMetastoreToConfigurations(OozieMetastore, clusterConfigurations); } if (HiveMetastore != null) { ClusterCreateHelper.AddHiveMetastoreToConfigurations(HiveMetastore, clusterConfigurations); } // Handle Custom Ambari Database if (AmbariDatabase != null) { ClusterCreateHelper.AddCustomAmbariDatabaseToConfigurations(AmbariDatabase, clusterConfigurations); } // Handle ADLSGen1 identity if (!string.IsNullOrEmpty(CertificatePassword)) { if (!string.IsNullOrEmpty(CertificateFilePath)) { CertificateFileContents = File.ReadAllBytes(CertificateFilePath); } ClusterCreateHelper.AddDataLakeStorageGen1IdentityToIdentityConfig( GetApplicationId(ApplicationId), GetTenantId(AadTenantId), CertificateFileContents, CertificatePassword, clusterConfigurations, this.DefaultContext.Environment.ActiveDirectoryAuthority, this.DefaultContext.Environment.DataLakeEndpointResourceId); } // Handle Kafka Rest Proxy KafkaRestProperties kafkaRestProperties = null; if (KafkaClientGroupId != null && KafkaClientGroupName != null) { kafkaRestProperties = new KafkaRestProperties() { ClientGroupInfo = new ClientGroupInfo(KafkaClientGroupName, KafkaClientGroupId) }; } bool isKafkaRestProxyEnable = kafkaRestProperties != null; var defaultVmSizeConfigurations = GetDefaultVmsizesConfigurations(Location); // Compute profile contains headnode, workernode, zookeepernode, edgenode, kafkamanagementnode, idbrokernode, etc. ComputeProfile computeProfile = ClusterCreateHelper.CreateComputeProfile(osProfile, vnetProfile, clusterScriptActions, ClusterType, ClusterSizeInNodes, HeadNodeSize, WorkerNodeSize, ZookeeperNodeSize, EdgeNodeSize, isKafkaRestProxyEnable, KafkaManagementNodeSize, EnableIDBroker.IsPresent, defaultVmSizeConfigurations); // Handle SecurityProfile SecurityProfile securityProfile = ClusterCreateHelper.ConvertAzureHDInsightSecurityProfileToSecurityProfile(SecurityProfile, AssignedIdentity); // Handle DisksPerWorkerNode feature Role workerNode = Utils.ExtractRole(ClusterNodeType.WorkerNode.ToString(), computeProfile); if (DisksPerWorkerNode > 0) { workerNode.DataDisksGroups = new List <DataDisksGroups>() { new DataDisksGroups() { DisksPerNode = DisksPerWorkerNode } }; } // Handle ClusterIdentity ClusterIdentity clusterIdentity = null; if (AssignedIdentity != null || StorageAccountManagedIdentity != null) { clusterIdentity = new ClusterIdentity { Type = ResourceIdentityType.UserAssigned, UserAssignedIdentities = new Dictionary <string, ClusterIdentityUserAssignedIdentitiesValue>() }; if (AssignedIdentity != null) { clusterIdentity.UserAssignedIdentities.Add(AssignedIdentity, new ClusterIdentityUserAssignedIdentitiesValue()); } if (StorageAccountManagedIdentity != null) { clusterIdentity.UserAssignedIdentities.Add(StorageAccountManagedIdentity, new ClusterIdentityUserAssignedIdentitiesValue()); } } // Handle CMK feature DiskEncryptionProperties diskEncryptionProperties = null; if (EncryptionKeyName != null && EncryptionKeyVersion != null && EncryptionVaultUri != null) { diskEncryptionProperties = new DiskEncryptionProperties() { KeyName = EncryptionKeyName, KeyVersion = EncryptionKeyVersion, VaultUri = EncryptionVaultUri, EncryptionAlgorithm = EncryptionAlgorithm != null ? EncryptionAlgorithm : JsonWebKeyEncryptionAlgorithm.RSAOAEP, MsiResourceId = AssignedIdentity }; } // Handle encryption at host feature if (EncryptionAtHost != null) { if (diskEncryptionProperties != null) { diskEncryptionProperties.EncryptionAtHost = EncryptionAtHost; } else { diskEncryptionProperties = new DiskEncryptionProperties() { EncryptionAtHost = EncryptionAtHost }; } } // Handle autoscale featurer Autoscale autoscaleParameter = null; if (AutoscaleConfiguration != null) { autoscaleParameter = AutoscaleConfiguration.ToAutoscale(); workerNode.AutoscaleConfiguration = autoscaleParameter; } // Handle relay outound and private link feature NetworkProperties networkProperties = null; if (ResourceProviderConnection != null || PrivateLink != null) { networkProperties = new NetworkProperties(ResourceProviderConnection, PrivateLink); } // Handle compute isolation properties ComputeIsolationProperties computeIsolationProperties = null; if (EnableComputeIsolation.IsPresent) { computeIsolationProperties = new ComputeIsolationProperties(EnableComputeIsolation.IsPresent, ComputeIsolationHostSku); } // Construct cluster create parameter ClusterCreateParametersExtended createParams = new ClusterCreateParametersExtended { Location = Location, //Tags = Tags, //To Do add this Tags parameter Properties = new ClusterCreateProperties { Tier = ClusterTier, ClusterDefinition = new ClusterDefinition { Kind = ClusterType ?? "Hadoop", ComponentVersion = clusterComponentVersion, Configurations = clusterConfigurations }, ClusterVersion = Version ?? "default", KafkaRestProperties = kafkaRestProperties, ComputeProfile = computeProfile, OsType = OSType, SecurityProfile = securityProfile, StorageProfile = storageProfile, DiskEncryptionProperties = diskEncryptionProperties, //handle Encryption In Transit feature EncryptionInTransitProperties = EncryptionInTransit != null ? new EncryptionInTransitProperties() { IsEncryptionInTransitEnabled = EncryptionInTransit } : null, MinSupportedTlsVersion = MinSupportedTlsVersion, NetworkProperties = networkProperties, ComputeIsolationProperties = computeIsolationProperties }, Identity = clusterIdentity }; var cluster = HDInsightManagementClient.CreateCluster(ResourceGroupName, ClusterName, createParams); if (cluster != null) { WriteObject(new AzureHDInsightCluster(cluster)); } }
public static bool CheckEnableKafkaRestProxy(NetworkProperties networkProperties) { return(networkProperties != null); }
internal void UpdateProperties(NetworkProperties theModel) { List <Task <ProcessResult> > Tasks = new List <Task <ProcessResult> >(); bool AskToRestart = false; bool Eth0Changes = false; bool Wlan0Changes = false; NetworkProperties CurrentSettings = Core.Instance.Network.RepopulateAndGetProperties(); if (theModel.Eth0Routers == null) { theModel.Eth0Routers = new string[0]; } if (theModel.Eth0DomainNameServers == null) { theModel.Eth0DomainNameServers = new string[0]; } if (theModel.Wlan0Routers == null) { theModel.Wlan0Routers = new string[0]; } if (theModel.Wlan0DomainNameServers == null) { theModel.Wlan0DomainNameServers = new string[0]; } if (CurrentSettings.Eth0IPAddress != theModel.Eth0IPAddress) { Eth0Changes = true; if (string.IsNullOrEmpty(theModel.Eth0IPAddress)) { Log?.Invoke(EventLogEntryCodes.NICIP4DynamicChanging, new string[] { c_Eth0 }); } else { Log?.Invoke(EventLogEntryCodes.NICIP4StaticChanging, new string[] { c_Eth0, theModel.Eth0IPAddress }); } } if (CurrentSettings.Eth0IP6Address != theModel.Eth0IP6Address) { Eth0Changes = true; if (string.IsNullOrEmpty(theModel.Eth0IP6Address)) { Log?.Invoke(EventLogEntryCodes.NICIP6DynamicChanging, new string[] { c_Eth0 }); } else { Log?.Invoke(EventLogEntryCodes.NICIP6StaticChanging, new string[] { c_Eth0, theModel.Eth0IP6Address }); } } if (!CurrentSettings.Eth0Routers.OrderBy(e => e).SequenceEqual(theModel.Eth0Routers.OrderBy(e => e))) { Eth0Changes = true; Log?.Invoke(EventLogEntryCodes.NICRoutersChanging, new string[] { c_Eth0, string.Join(" ", theModel.Eth0Routers) }); } if (!CurrentSettings.Eth0DomainNameServers.OrderBy(e => e).SequenceEqual(theModel.Eth0DomainNameServers.OrderBy(e => e))) { Eth0Changes = true; Log?.Invoke(EventLogEntryCodes.NICDNSChanging, new string[] { c_Eth0, string.Join(" ", theModel.Eth0DomainNameServers) }); } if (CurrentSettings.Wlan0IPAddress != theModel.Wlan0IPAddress) { Wlan0Changes = true; if (string.IsNullOrEmpty(theModel.Wlan0IPAddress)) { Log?.Invoke(EventLogEntryCodes.NICIP6DynamicChanging, new string[] { c_Wlan0 }); } else { Log?.Invoke(EventLogEntryCodes.NICIP6StaticChanging, new string[] { c_Wlan0, theModel.Wlan0IPAddress }); } } if (CurrentSettings.Wlan0IP6Address != theModel.Wlan0IP6Address) { Wlan0Changes = true; if (string.IsNullOrEmpty(theModel.Eth0IP6Address)) { Log?.Invoke(EventLogEntryCodes.NICIP6DynamicChanging, new string[] { c_Wlan0 }); } else { Log?.Invoke(EventLogEntryCodes.NICIP6StaticChanging, new string[] { c_Wlan0, theModel.Wlan0IP6Address }); } } if (!CurrentSettings.Wlan0Routers.OrderBy(e => e).SequenceEqual(theModel.Wlan0Routers.OrderBy(e => e))) { Wlan0Changes = true; Log?.Invoke(EventLogEntryCodes.NICDNSChanging, new string[] { c_Wlan0, string.Join(" ", theModel.Wlan0Routers) }); } if (!CurrentSettings.Wlan0DomainNameServers.OrderBy(e => e).SequenceEqual(theModel.Wlan0DomainNameServers.OrderBy(e => e))) { Wlan0Changes = true; Log?.Invoke(EventLogEntryCodes.NICDNSChanging, new string[] { c_Wlan0, string.Join(" ", theModel.Wlan0DomainNameServers) }); } Task <ProcessResult> IPAddressTask = null; if (Eth0Changes || Wlan0Changes) { NICProperties eth0 = new NICProperties(c_Eth0); eth0.IPAddress = theModel.Eth0IPAddress; eth0.IP6Address = theModel.Eth0IP6Address; eth0.Routers = theModel.Eth0Routers; eth0.DomainNameServers = theModel.Eth0DomainNameServers; NICProperties wlan0 = new NICProperties(c_Wlan0); wlan0.IPAddress = theModel.Wlan0IPAddress; wlan0.IP6Address = theModel.Wlan0IP6Address; wlan0.Routers = theModel.Wlan0Routers; wlan0.DomainNameServers = theModel.Wlan0DomainNameServers; IPAddressTask = FlushNetworkSequence(Eth0Changes, Wlan0Changes, eth0, wlan0); Tasks.Add(IPAddressTask); } Task <ProcessResult> HostNameTask = null; if (CurrentSettings.HostName != theModel.HostName) { AskToRestart = true; HostNameTask = ProcessRunner.GetProcessResultAsync(c_LinuxRaspconfigCommand, "nonint do_hostname " + theModel.HostName); Tasks.Add(HostNameTask); Log?.Invoke(EventLogEntryCodes.HostNameChanging, new string[] { theModel.HostName }); } Task <ProcessResult> SetWiFiSSIDPassphrase = null; if (!string.IsNullOrEmpty(theModel.NewSSID)) { SetWiFiSSIDPassphrase = SetWiFiSSIDPassphraseSequence(theModel); Tasks.Add(SetWiFiSSIDPassphrase); } if (AskToRestart) { RestartDue?.Invoke(); } Task.WaitAll(Tasks.ToArray()); // Check if Tasks have completed Okay and Log result LoggingActions.LogTaskResult(Log, IPAddressTask, EventLogEntryCodes.NICIPChangesComplete, EventLogEntryCodes.NICIPChangesError); LoggingActions.LogTaskResult(Log, HostNameTask, EventLogEntryCodes.HostNameChanged, EventLogEntryCodes.HostNameChangeError); LoggingActions.LogTaskResult(Log, SetWiFiSSIDPassphrase, EventLogEntryCodes.SSIDChanged, EventLogEntryCodes.SSIDChangeError); }
public void TestPrivateEndpointConnection() { TestInitialize(); string clusterName = TestUtilities.GenerateName("hdisdk-pe"); var createParams = CommonData.PrepareClusterCreateParamsForWasb(); createParams.Location = "South Central US"; var networkProperties = new NetworkProperties(ResourceProviderConnection.Outbound, PrivateLink.Enabled); createParams.Properties.NetworkProperties = networkProperties; string storageAccountResourceId = string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Storage/storageAccounts/{2}", CommonData.SubscriptionId, CommonData.ResourceGroupName, CommonData.StorageAccountName); createParams.Properties.StorageProfile.Storageaccounts[0].ResourceId = storageAccountResourceId; string vnetId = "/subscriptions/964c10bb-8a6c-43bc-83d3-6b318c6c7305/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/fakevnet"; string subnetId = "/subscriptions/964c10bb-8a6c-43bc-83d3-6b318c6c7305/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/fakevnet/subnets/default"; foreach (var role in createParams.Properties.ComputeProfile.Roles) { role.VirtualNetworkProfile = new VirtualNetworkProfile(vnetId, subnetId); } var cluster = HDInsightClient.Clusters.Create(CommonData.ResourceGroupName, clusterName, createParams); var privateLinkResourceListResult = HDInsightClient.PrivateLinkResources.ListByCluster(CommonData.ResourceGroupName, clusterName); Assert.NotNull(privateLinkResourceListResult); var headNodePrivateLinkResource = privateLinkResourceListResult.Value.Where(pls => pls.Name.Equals("headnode")).FirstOrDefault(); // call Network sdk to create private endpoint and choose the approve manually way. // please notice that the NetworkPrivateEndpoint privateEndpointParameter = new NetworkPrivateEndpoint() { Location = cluster.Location, ManualPrivateLinkServiceConnections = new List <NetworkPrivateLinkServiceConnection> { new NetworkPrivateLinkServiceConnection() { Name = cluster.Name, // Private link service name is the cluster name PrivateLinkServiceId = cluster.Id, // Private link service id is the cluster resource id GroupIds = new List <string> { headNodePrivateLinkResource.GroupId, }, RequestMessage = "Want to connect to head node private link resource." }, }, Subnet = new Subnet(id: subnetId) }; string privateEndpointName = "headnodepe"; var createPrivateEndpointResult = HDInsightManagementHelper.CreatePrivateEndpoint(CommonData.ResourceGroupName, privateEndpointName, privateEndpointParameter); // Get the private endpoint connection and check the status var privateEndpointConnectionListResult = HDInsightClient.PrivateEndpointConnections.ListByCluster(CommonData.ResourceGroupName, clusterName); Assert.NotNull(privateEndpointConnectionListResult); foreach (var privateEndpointConnection in privateEndpointConnectionListResult) { Assert.Equal(PrivateLinkServiceConnectionStatus.Pending, privateEndpointConnection.PrivateLinkServiceConnectionState.Status); //Approve privateEndpointConnection.PrivateLinkServiceConnectionState.Status = PrivateLinkServiceConnectionStatus.Approved; HDInsightClient.PrivateEndpointConnections.CreateOrUpdate(CommonData.ResourceGroupName, clusterName, privateEndpointConnection.Name, privateEndpointConnection); //Delete HDInsightClient.PrivateEndpointConnections.Delete(CommonData.ResourceGroupName, clusterName, privateEndpointConnection.Name); } }
/// <summary> /// Gets a VM network. /// </summary> /// <param name='fabricName'> /// Required. Fabric unique name. /// </param> /// <param name='networkName'> /// Required. Network name. /// </param> /// <param name='customRequestHeaders'> /// Optional. Request header parameters. /// </param> /// <param name='cancellationToken'> /// Cancellation token. /// </param> /// <returns> /// The response model for the Network object. /// </returns> public async Task <NetworkResponse> GetAsync(string fabricName, string networkName, CustomRequestHeaders customRequestHeaders, CancellationToken cancellationToken) { // Validate if (fabricName == null) { throw new ArgumentNullException("fabricName"); } if (networkName == null) { throw new ArgumentNullException("networkName"); } // Tracing bool shouldTrace = TracingAdapter.IsEnabled; string invocationId = null; if (shouldTrace) { invocationId = TracingAdapter.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("fabricName", fabricName); tracingParameters.Add("networkName", networkName); tracingParameters.Add("customRequestHeaders", customRequestHeaders); TracingAdapter.Enter(invocationId, this, "GetAsync", tracingParameters); } // Construct URL string url = ""; url = url + "/Subscriptions/"; if (this.Client.Credentials.SubscriptionId != null) { url = url + Uri.EscapeDataString(this.Client.Credentials.SubscriptionId); } url = url + "/resourceGroups/"; url = url + Uri.EscapeDataString(this.Client.ResourceGroupName); url = url + "/providers/"; url = url + Uri.EscapeDataString(this.Client.ResourceNamespace); url = url + "/"; url = url + Uri.EscapeDataString(this.Client.ResourceType); url = url + "/"; url = url + Uri.EscapeDataString(this.Client.ResourceName); url = url + "/replicationFabrics/"; url = url + Uri.EscapeDataString(fabricName); url = url + "/replicationNetworks/"; url = url + Uri.EscapeDataString(networkName); List <string> queryParameters = new List <string>(); queryParameters.Add("api-version=2015-11-10"); if (queryParameters.Count > 0) { url = url + "?" + string.Join("&", queryParameters); } string baseUrl = this.Client.BaseUri.AbsoluteUri; // Trim '/' character from the end of baseUrl and beginning of url. if (baseUrl[baseUrl.Length - 1] == '/') { baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); } if (url[0] == '/') { url = url.Substring(1); } url = baseUrl + "/" + url; url = url.Replace(" ", "%20"); // Create HTTP transport objects HttpRequestMessage httpRequest = null; try { httpRequest = new HttpRequestMessage(); httpRequest.Method = HttpMethod.Get; httpRequest.RequestUri = new Uri(url); // Set Headers httpRequest.Headers.Add("x-ms-client-request-id", customRequestHeaders.ClientRequestId); httpRequest.Headers.Add("x-ms-version", "2015-01-01"); // Set Credentials cancellationToken.ThrowIfCancellationRequested(); await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); // Send Request HttpResponseMessage httpResponse = null; try { if (shouldTrace) { TracingAdapter.SendRequest(invocationId, httpRequest); } cancellationToken.ThrowIfCancellationRequested(); httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); if (shouldTrace) { TracingAdapter.ReceiveResponse(invocationId, httpResponse); } HttpStatusCode statusCode = httpResponse.StatusCode; if (statusCode != HttpStatusCode.OK) { cancellationToken.ThrowIfCancellationRequested(); CloudException ex = CloudException.Create(httpRequest, null, httpResponse, await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false)); if (shouldTrace) { TracingAdapter.Error(invocationId, ex); } throw ex; } // Create Result NetworkResponse result = null; // Deserialize Response if (statusCode == HttpStatusCode.OK) { cancellationToken.ThrowIfCancellationRequested(); string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); result = new NetworkResponse(); JToken responseDoc = null; if (string.IsNullOrEmpty(responseContent) == false) { responseDoc = JToken.Parse(responseContent); } if (responseDoc != null && responseDoc.Type != JTokenType.Null) { Network networkInstance = new Network(); result.Network = networkInstance; JToken propertiesValue = responseDoc["properties"]; if (propertiesValue != null && propertiesValue.Type != JTokenType.Null) { NetworkProperties propertiesInstance = new NetworkProperties(); networkInstance.Properties = propertiesInstance; JToken fabricTypeValue = propertiesValue["fabricType"]; if (fabricTypeValue != null && fabricTypeValue.Type != JTokenType.Null) { string fabricTypeInstance = ((string)fabricTypeValue); propertiesInstance.FabricType = fabricTypeInstance; } JToken subnetsArray = propertiesValue["subnets"]; if (subnetsArray != null && subnetsArray.Type != JTokenType.Null) { foreach (JToken subnetsValue in ((JArray)subnetsArray)) { Subnet subnetInstance = new Subnet(); propertiesInstance.Subnets.Add(subnetInstance); JToken nameValue = subnetsValue["name"]; if (nameValue != null && nameValue.Type != JTokenType.Null) { string nameInstance = ((string)nameValue); subnetInstance.Name = nameInstance; } JToken friendlyNameValue = subnetsValue["friendlyName"]; if (friendlyNameValue != null && friendlyNameValue.Type != JTokenType.Null) { string friendlyNameInstance = ((string)friendlyNameValue); subnetInstance.FriendlyName = friendlyNameInstance; } JToken addressListArray = subnetsValue["addressList"]; if (addressListArray != null && addressListArray.Type != JTokenType.Null) { foreach (JToken addressListValue in ((JArray)addressListArray)) { subnetInstance.AddressList.Add(((string)addressListValue)); } } } } JToken friendlyNameValue2 = propertiesValue["friendlyName"]; if (friendlyNameValue2 != null && friendlyNameValue2.Type != JTokenType.Null) { string friendlyNameInstance2 = ((string)friendlyNameValue2); propertiesInstance.FriendlyName = friendlyNameInstance2; } JToken networkTypeValue = propertiesValue["networkType"]; if (networkTypeValue != null && networkTypeValue.Type != JTokenType.Null) { string networkTypeInstance = ((string)networkTypeValue); propertiesInstance.NetworkType = networkTypeInstance; } } JToken idValue = responseDoc["id"]; if (idValue != null && idValue.Type != JTokenType.Null) { string idInstance = ((string)idValue); networkInstance.Id = idInstance; } JToken nameValue2 = responseDoc["name"]; if (nameValue2 != null && nameValue2.Type != JTokenType.Null) { string nameInstance2 = ((string)nameValue2); networkInstance.Name = nameInstance2; } JToken typeValue = responseDoc["type"]; if (typeValue != null && typeValue.Type != JTokenType.Null) { string typeInstance = ((string)typeValue); networkInstance.Type = typeInstance; } JToken locationValue = responseDoc["location"]; if (locationValue != null && locationValue.Type != JTokenType.Null) { string locationInstance = ((string)locationValue); networkInstance.Location = locationInstance; } JToken tagsSequenceElement = ((JToken)responseDoc["tags"]); if (tagsSequenceElement != null && tagsSequenceElement.Type != JTokenType.Null) { foreach (JProperty property in tagsSequenceElement) { string tagsKey = ((string)property.Name); string tagsValue = ((string)property.Value); networkInstance.Tags.Add(tagsKey, tagsValue); } } } } result.StatusCode = statusCode; if (httpResponse.Headers.Contains("x-ms-request-id")) { result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); } if (shouldTrace) { TracingAdapter.Exit(invocationId, result); } return(result); } finally { if (httpResponse != null) { httpResponse.Dispose(); } } } finally { if (httpRequest != null) { httpRequest.Dispose(); } } }
/// <summary> /// Default constructor /// </summary> public ControlSystemConfig() { version = null; //When we first construct a new config, we set its version to null, and server will give it a version number generalProperties = new GeneralDeviceProperties(); networkProperties = new NetworkProperties(); }
public NetworkProperties GetProperties() { int vertices = this.Vertices.Count + this.Outliers.Count; double D = 0; int maxD = 0; double WD = 0; double maxWD = 0; double CC = 0; double NW = 0; double NEW = 0; foreach (Vertex v in this.Vertices.Values) { int sumD = 0; double sumWD = 0; double maxNEW = 0; foreach (Edge e in v.AdjacentEdges) { sumD += 1; sumWD += e.Weight; if (e.Weight > maxNEW) { maxNEW = e.Weight; } } if (sumD > maxD) { maxD = sumD; } if (sumWD > maxWD) { maxWD = sumWD; } D += sumD; WD += sumWD; CC += v.GetClusteringCoefficient(); NW += v.Weight; NEW += maxNEW; } if (vertices > 0) { D /= vertices; WD /= vertices; CC /= vertices; NW /= vertices; NEW /= vertices; } //double EW = 0; //foreach (Edge e in this.Edges) //{ // EW += e.Weight; //} //if (this.Edges.Count > 0) //{ // EW /= this.Edges.Count; //} NetworkProperties p = new NetworkProperties(vertices, D, maxD, WD, maxWD, CC, NW, NEW); return(p); }