Esempio n. 1
0
        public static RunParameters GetRunParameters(this IJobDefinitionsOperations operations,
                                                     HybridDataManagementClient client, string jobDefinitionName, string dataServiceName,
                                                     string dataManagerName, string resourceGroupName,
                                                     UserConfirmation userConfirmation, string deviceName = null, string containerName = null,
                                                     string[] volumeNames    = null, BackupChoice backupChoice = BackupChoice.UseExistingLatest,
                                                     string fileNameFilter   = null, string[] rootDirectories  = null,
                                                     string azureStorageType = null, bool isDirectoryMode      = false)
        {
            RunParameters runParameters = new RunParameters();

            runParameters.CustomerSecrets  = new List <CustomerSecret>();
            runParameters.UserConfirmation = userConfirmation;
            //JToken dataServiceInputJToken = client.JobDefinitions.Get(dataServiceName: dataServiceName,
            JToken dataServiceInputJToken = operations.Get(dataServiceName: dataServiceName,
                                                           jobDefinitionName: jobDefinitionName,
                                                           resourceGroupName: resourceGroupName,
                                                           dataManagerName: dataManagerName).DataServiceInput as JToken;

            dataServiceInputJToken["DeviceName"]     = deviceName ?? dataServiceInputJToken["DeviceName"];
            dataServiceInputJToken["FileNameFilter"] = fileNameFilter ?? dataServiceInputJToken["FileNameFilter"];
            dataServiceInputJToken["ContainerName"]  = containerName ?? dataServiceInputJToken["ContainerName"];

            if (rootDirectories != null)
            {
                JArray rootDirectoriesObj = new JArray();
                foreach (var rootDirectory in rootDirectories)
                {
                    rootDirectoriesObj.Add(rootDirectory);
                }
                dataServiceInputJToken["RootDirectories"] = rootDirectoriesObj;
            }
            if (volumeNames != null)
            {
                JArray volumeNamesObj = new JArray();
                foreach (var volumeName in volumeNames)
                {
                    volumeNamesObj.Add(volumeName);
                }
                dataServiceInputJToken["VolumeNames"] = volumeNamesObj;
            }
            dataServiceInputJToken["BackupChoice"]     = backupChoice.ToString() ?? dataServiceInputJToken["BackupChoice"];
            dataServiceInputJToken["IsDirectoryMode"]  = isDirectoryMode;
            dataServiceInputJToken["AzureStorageType"] = azureStorageType ?? dataServiceInputJToken["AzureStorageType"];
            runParameters.DataServiceInput             = dataServiceInputJToken;
            return(runParameters);
        }
        public static DataStore CreateAzureStorageDataStore(this IDataStoresOperations operations, string subscriptionIdOfDataManager,
                                                            string subscriptionIdOfStorageAccount, string resourceGroupOfDataManager,
                                                            string resourceGroupOfStorageAccount, string dataManagerName,
                                                            string storageAccountKey, string azureStorageName, HybridDataManagementClient client)
        {
            var azureStorageDataStore = new DataStore();
            var publicKey             = client.PublicKeys.ListByDataManager(resourceGroupOfDataManager, dataManagerName).FirstOrDefault();

            azureStorageDataStore.State = State.Enabled;

            azureStorageDataStore.CustomerSecrets = EncryptAzureStorageCustomerSecrets(storageAccountKey, publicKey);

            azureStorageDataStore.DataStoreTypeId = string.Format(
                "/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.HybridData"
                + "/dataManagers/{2}/dataStoreTypes/AzureStorageAccount",
                subscriptionIdOfDataManager, resourceGroupOfDataManager, dataManagerName);

            azureStorageDataStore.RepositoryId = $"/subscriptions/{subscriptionIdOfStorageAccount}/resourceGroups/{resourceGroupOfStorageAccount}"
                                                 + $"/providers/Microsoft.Storage/storageAccounts/{azureStorageName}";

            azureStorageDataStore.ExtendedProperties = GetAzureStorageExtendedProperties(azureStorageDataStore.RepositoryId);

            return(azureStorageDataStore);
        }
        public static DataStore CreateStorSimpleDataStore(this IDataStoresOperations operations, string subscriptionIdOfDataManager,
                                                          string subscriptionIdOfStorSimpleDevice, string resourceGroupOfDataManager,
                                                          string resourceGroupOfStorSimpleDevice, string dataManagerName,
                                                          string serviceEncryptionKey, string storSimpleDeviceName, HybridDataManagementClient client)
        {
            var storSimpleDataStore = new DataStore();
            var publicKey           = client.PublicKeys.ListByDataManager(resourceGroupOfDataManager, dataManagerName).FirstOrDefault();

            storSimpleDataStore.State = State.Enabled;

            storSimpleDataStore.CustomerSecrets = EncryptStorSimpleCustomerSecrets(serviceEncryptionKey, publicKey);

            storSimpleDataStore.DataStoreTypeId = string.Format(
                "/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.HybridData"
                + "/dataManagers/{2}/dataStoreTypes/StorSimple8000Series",
                subscriptionIdOfDataManager, resourceGroupOfDataManager, dataManagerName);

            storSimpleDataStore.RepositoryId = $"/subscriptions/{subscriptionIdOfStorSimpleDevice}/resourceGroups/{resourceGroupOfStorSimpleDevice}"
                                               + $"/providers/Microsoft.StorSimple/managers/{storSimpleDeviceName}";

            storSimpleDataStore.ExtendedProperties = GetStorSimpleExtendedProperties(storSimpleDataStore.RepositoryId);

            return(storSimpleDataStore);
        }
Esempio n. 4
0
        public static JobDefinition GetJobDefinition(this IJobDefinitionsOperations operations, HybridDataManagementClient client,
                                                     string dataSourceName, string dataSinkName, string resourceGroupName, string dataManagerName, string runLocation,
                                                     UserConfirmation userConfirmation, string deviceName, string containerName, string[] volumeNames, BackupChoice backupChoice,
                                                     string fileNameFilter = null, string[] rootDirectories = null, AzureStorageType azureStorageType = AzureStorageType.Blob, bool isDirectoryMode = false)
        {
            var jobDefinition = new JobDefinition();

            jobDefinition.DataSinkId = client.DataStores.Get(dataStoreName: dataSinkName,
                                                             resourceGroupName: resourceGroupName, dataManagerName: dataManagerName).Id;
            jobDefinition.DataSourceId = client.DataStores.Get(dataStoreName: dataSourceName,
                                                               resourceGroupName: resourceGroupName, dataManagerName: dataManagerName).Id;

            RunLocation parsedRunLocation = RunLocation.None;

            if (Enum.TryParse(runLocation, true, out parsedRunLocation))
            {
                jobDefinition.RunLocation = parsedRunLocation;
            }

            jobDefinition.State            = State.Enabled;
            jobDefinition.UserConfirmation = userConfirmation;
            jobDefinition.DataServiceInput = GetDataServiceInput(deviceName, containerName, volumeNames, backupChoice, fileNameFilter,
                                                                 rootDirectories, azureStorageType, isDirectoryMode);
            return(jobDefinition);
        }