/// <summary>
        /// Returns BackupScheduleGroup for a given name
        /// </summary>
        /// <param name="deviceName"></param>
        /// <param name="name"></param>
        /// <param name="client"></param>
        /// <param name="resourceGroupName"></param>
        /// <param name="managerName"></param>
        /// <returns></returns>
        public static BackupScheduleGroup GetBackupScheduleGroup(
            string deviceName,
            string name,
            StorSimpleManagementClient client,
            string resourceGroupName,
            string managerName)
        {
            var bsgs = client.BackupScheduleGroups.ListByDevice(
                deviceName,
                resourceGroupName,
                managerName);

            BackupScheduleGroup bsg = null;

            if (bsgs != null)
            {
                bsg = bsgs.FirstOrDefault(b =>
                                          b.Name.Equals(name, StringComparison.CurrentCultureIgnoreCase));
            }

            if (bsg == null)
            {
                // Create new one for the device
                var bsgNew = new BackupScheduleGroup(
                    client,
                    resourceGroupName,
                    managerName,
                    name);
                bsgNew.Initialize();
                bsg = bsgNew.CreateOrUpdate(deviceName);
            }

            bsg.SetBaseResourceValues(client, resourceGroupName, managerName);
            return(bsg);
        }
Ejemplo n.º 2
0
        public void TestCreateOrUpdateFileServer()
        {
            try
            {
                //Check if atleast a device is registered to the manager.
                var devices = Helpers.CheckAndGetDevicesByStatus(this, DeviceStatus.ReadyToSetup, 1);

                Assert.True(devices != null && devices.FirstOrDefault() != null,
                            "No devices were found to be registered in the manger:" + this.ManagerName);

                // Get the first device
                Device device = devices.FirstOrDefault();

                var sacCreated = TestUtilities.GetStorageAccountCredential(
                    this.Client,
                    TestConstants.DefaultSacName,
                    this.ResourceGroupName,
                    this.ManagerName);

                // Create StorageDomain
                var storageDomain = TestUtilities.GetStorageDomain(
                    TestConstants.DefaultStorageDomainFileServerNamePrefix + device.Name,
                    sacCreated.Id,
                    this.Client,
                    this.ResourceGroupName,
                    this.ManagerName);

                Assert.True(
                    storageDomain != null,
                    $"StorageDomain not found: {storageDomain.Name}");

                // Create BackupScheduleGroup
                var bsg = new BackupScheduleGroup(
                    this.Client,
                    this.ResourceGroupName,
                    this.ManagerName,
                    TestConstants.DefaultBackupSchGroupName);
                bsg.Initialize();
                var bsgCreated = bsg.CreateOrUpdate(device.Name);

                // Create FileServer
                var fileServer = new FileServer(
                    this.Client,
                    this.ResourceGroupName,
                    this.ManagerName,
                    device.Name);
                fileServer.Initialize(storageDomain.Id, bsgCreated.Id);
                var fileServerCreated = fileServer.CreateOrUpdate(device.Name);

                //Update FileServer
                fileServerCreated.Description = "Update description of fileserver";
                fileServerCreated.CreateOrUpdate(device.Name);
            }
            catch (Exception e)
            {
                Assert.Null(e);
            }
        }