/// <summary>
        ///
        /// </summary>
        /// <param name="location"></param>
        /// <param name="resourcegroupName"></param>
        /// <param name="workspaceName"></param>
        /// <param name="computeName"></param>
        /// <param name="useGPUCompute"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task <ComputeResource> AttachCompute(string location,
                                                          string resourcegroupName,
                                                          string workspaceName,
                                                          string computeName,
                                                          bool useGPUCompute = true,
                                                          CancellationToken cancellationToken = default)
        {
            if (!WorkspaceManagementHelpers.ValidateComputeName(computeName))
            {
                // Provided Compute name is invalid
                throw new ArgumentException(nameof(computeName));
            }
            try
            {
                return(await this.machineLearningWorkspacesClient.MachineLearningCompute.GetAsync(resourcegroupName, workspaceName, computeName, cancellationToken).ConfigureAwait(false));
            }
            catch (MachineLearningServiceErrorException mlEx)
            {
                if (mlEx.Body.Error.Code == "ResourceNotFound")
                {
                    AmlCompute      computeToAttach = useGPUCompute ? GetAmlComputeConfiguration(location, vmSize: WorkspaceClient.GPUComputeVmSize) : GetAmlComputeConfiguration(location);
                    ComputeResource resource        = new ComputeResource
                    {
                        Properties = computeToAttach,
                        Location   = location
                    };

                    return(await this.machineLearningWorkspacesClient.MachineLearningCompute.CreateOrUpdateAsync(resourcegroupName, workspaceName, computeName, resource, cancellationToken).ConfigureAwait(false));
                }

                throw;
            }
        }
Пример #2
0
        /// <summary>
        /// Get a list of all hosts filtered by name
        /// </summary>
        /// <param name="hostName">name to filter on, do not use wildcards</param>
        /// <returns>List of all ESXi hosts</returns>
        public List <HostSystem> GetHostSystems(string hostFilterName)
        {
            List <HostSystem> hostSystems = new List <HostSystem>();

            try {
                Datacenter dataCenter = (Datacenter)vSphereClient.FindEntityView(typeof(Datacenter), null, null, null);
                Folder     folder     = (Folder)vSphereClient.GetView(dataCenter.HostFolder, null);
                foreach (VMware.Vim.ManagedObjectReference mObjR in folder.ChildEntity.Where(x => x.Type == "ComputeResource"))
                {
                    ComputeResource computeResource = (ComputeResource)vSphereClient.GetView(mObjR, null);
                    foreach (VMware.Vim.ManagedObjectReference hostRef in computeResource.Host)
                    {
                        HostSystem hostSystem = (HostSystem)vSphereClient.GetView(hostRef, null);
                        if (hostSystem.Name.Contains(hostFilterName) || hostSystem.Name.Equals(hostFilterName))
                        {
                            hostSystems.Add(hostSystem);
                        }
                    }
                }
            }
            catch {
                throw;
            }
            return(hostSystems);
        }
        public virtual MachineLearningComputeCreateOrUpdateOperation StartCreateOrUpdate(string resourceGroupName, string workspaceName, string computeName, ComputeResource parameters, CancellationToken cancellationToken = default)
        {
            if (resourceGroupName == null)
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }
            if (workspaceName == null)
            {
                throw new ArgumentNullException(nameof(workspaceName));
            }
            if (computeName == null)
            {
                throw new ArgumentNullException(nameof(computeName));
            }
            if (parameters == null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            using var scope = _clientDiagnostics.CreateScope("MachineLearningComputeOperations.StartCreateOrUpdate");
            scope.Start();
            try
            {
                var originalResponse = RestClient.CreateOrUpdate(resourceGroupName, workspaceName, computeName, parameters, cancellationToken);
                return(new MachineLearningComputeCreateOrUpdateOperation(_clientDiagnostics, _pipeline, RestClient.CreateCreateOrUpdateRequest(resourceGroupName, workspaceName, computeName, parameters).Request, originalResponse));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Пример #4
0
 /// <summary>
 /// Creates or updates compute. This call will overwrite a compute if it
 /// exists. This is a nonrecoverable operation. If your intent is to create a
 /// new compute, do a GET first to verify that it does not exist yet.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Name of the resource group in which workspace is located.
 /// </param>
 /// <param name='workspaceName'>
 /// Name of Azure Machine Learning workspace.
 /// </param>
 /// <param name='computeName'>
 /// Name of the Azure Machine Learning compute.
 /// </param>
 /// <param name='parameters'>
 /// Payload with Machine Learning compute definition.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <ComputeResource> BeginCreateOrUpdateAsync(this IMachineLearningComputeOperations operations, string resourceGroupName, string workspaceName, string computeName, ComputeResource parameters, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.BeginCreateOrUpdateWithHttpMessagesAsync(resourceGroupName, workspaceName, computeName, parameters, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Пример #5
0
 /// <summary>
 /// Creates or updates compute. This call will overwrite a compute if it
 /// exists. This is a nonrecoverable operation. If your intent is to create a
 /// new compute, do a GET first to verify that it does not exist yet.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Name of the resource group in which workspace is located.
 /// </param>
 /// <param name='workspaceName'>
 /// Name of Azure Machine Learning workspace.
 /// </param>
 /// <param name='computeName'>
 /// Name of the Azure Machine Learning compute.
 /// </param>
 /// <param name='parameters'>
 /// Payload with Machine Learning compute definition.
 /// </param>
 public static ComputeResource BeginCreateOrUpdate(this IMachineLearningComputeOperations operations, string resourceGroupName, string workspaceName, string computeName, ComputeResource parameters)
 {
     return(operations.BeginCreateOrUpdateAsync(resourceGroupName, workspaceName, computeName, parameters).GetAwaiter().GetResult());
 }