예제 #1
0
		private void Receive(CreateBaseVMImageRequest request)
		{
			Labs.CreateBaseVMImage(request);
		}
예제 #2
0
		public async Task<string> CreateBaseVmImage(string imageName, string imageDescription, 
			string newImageName, string chocoPackages)
		{
			// Security considerations: because it requires an SubscriptionId that is retrieved from the
			// UnitOfWork, this method will succeede only for a logged in user.

			_logger.Info("Entering AzureManagement.CreateBaseVmImage");

			string result = "OK";

			try
			{
				int userId = UnitOfWork.CurrentIdentity.IdentityId;
				int activeSubscriptionId = UnitOfWork.ActiveSubscriptionId;

				List<string> chocoPackageList = chocoPackages != null ? 
					chocoPackages.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries).ToList() : 
					new List<string>();

				CreateBaseVMImageRequest request = new CreateBaseVMImageRequest
				{
					ImageName = imageName,
					ImageDescription = imageDescription,
					NewImageName = newImageName,
					UserId = userId,
					SubscriptionId = activeSubscriptionId,
					ChocoPackageList = chocoPackageList
				};

				await Messaging.SendAsync(request);
			}
			catch (Exception ex)
			{
				_logger.Fatal("Exception when creating base vm image.", ex);
				result = "Error";
			}

			_logger.Info("Exiting AzureManagement.CreateBaseVmImage");

			return result;
		}