/// <summary> /// Creates a new user /// </summary> /// <param name="options">The options to use when creating the user</param> public void CreateVMUser(NewVMUserParameters options) { if (options == null) { throw new ArgumentNullException("options"); } IUser user = null; string vmName = null; if (options.VM != null) { user = options.VM.omObject.CreateUser(); vmName = options.VM.Name; } else { using (IPoolManager poolManager = options.Context.BatchOMClient.OpenPoolManager()) { user = poolManager.CreateUser(options.PoolName, options.VMName); } vmName = options.VMName; } user.Name = options.VMUserName; user.Password = options.Password; user.ExpiryTime = options.ExpiryTime; user.IsAdmin = options.IsAdmin; WriteVerbose(string.Format(Resources.NBU_CreatingUser, user.Name, vmName)); user.Commit(UserCommitSemantics.AddUser, options.AdditionalBehaviors); }
/// <summary> /// Creates a test user for use in Scenario tests. /// </summary> public static void CreateTestUser(BatchController controller, BatchAccountContext context, string poolName, string vmName, string vmUserName) { YieldInjectionInterceptor interceptor = CreateHttpRecordingInterceptor(); BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor }; BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient); NewVMUserParameters parameters = new NewVMUserParameters(context, poolName, vmName, null, behaviors) { VMUserName = vmUserName, Password = "******", }; client.CreateVMUser(parameters); }