コード例 #1
0
        /// <summary>
        /// Return storage domain
        /// </summary>
        /// <param name="name"></param>
        /// <param name="sacId"></param>
        /// <param name="client"></param>
        /// <param name="resourceGroupName"></param>
        /// <param name="managerName"></param>
        /// <returns></returns>
        public static StorageDomain GetStorageDomain(
            string name,
            string sacId,
            StorSimpleManagementClient client,
            string resourceGroupName,
            string managerName)
        {
            var           storageDomains = client.StorageDomains.ListByManager(resourceGroupName, managerName);
            StorageDomain storageDomain  = null;

            if (storageDomains != null)
            {
                storageDomain = storageDomains.FirstOrDefault(s =>
                                                              s.Name.Equals(
                                                                  name,
                                                                  StringComparison.CurrentCultureIgnoreCase));
            }

            if (storageDomain == null)
            {
                var sdNew = new StorageDomain(
                    client,
                    resourceGroupName,
                    managerName,
                    name);
                sdNew.Initialize(sacId);
                storageDomain = sdNew.CreateOrUpdate();
            }

            storageDomain.SetBaseResourceValues(client, resourceGroupName, managerName);
            return(storageDomain);
        }
コード例 #2
0
        /// <summary>
        /// Return StorageDomain by Id
        /// </summary>
        /// <param name="storageDomainId"></param>
        /// <param name="client"></param>
        /// <param name="resourceGroupName"></param>
        /// <param name="managerName"></param>
        /// <returns></returns>
        public static StorageDomain GetStorageDomainById(
            string storageDomainId,
            StorSimpleManagementClient client,
            string resourceGroupName,
            string managerName)
        {
            var           storageDomains = client.StorageDomains.ListByManager(resourceGroupName, managerName);
            StorageDomain storageDomain  = null;

            if (storageDomains != null)
            {
                storageDomain = storageDomains.FirstOrDefault(s =>
                                                              s.Id.Equals(
                                                                  storageDomainId,
                                                                  StringComparison.CurrentCultureIgnoreCase));
            }

            if (storageDomain == null)
            {
                storageDomain.SetBaseResourceValues(client, resourceGroupName, managerName);
            }

            return(storageDomain);
        }