コード例 #1
0
 public RemoveAzureEndpointCmdletInfo(string epName, PersistentVMRoleContext vmRoleCtxt)
 {
     this.cmdletName = Utilities.RemoveAzureEndpointCmdletName;
     this.cmdletParams.Add(new CmdletParam("Name", epName));
     this.cmdletParams.Add(new CmdletParam("VM", vmRoleCtxt));
 }
コード例 #2
0
 public GetAzureEndpointCmdletInfo(PersistentVMRoleContext vmRoleCtxt)
 {
     this.cmdletName = Utilities.GetAzureEndpointCmdletName;
     this.cmdletParams.Add(new CmdletParam("VM", vmRoleCtxt));
 }
コード例 #3
0
        public InputEndpointContext GetAzureEndpoint(PersistentVMRoleContext vmRoleCtxt)
        {
            GetAzureEndpointCmdletInfo getAzureEndpointCmdletInfo = new GetAzureEndpointCmdletInfo(vmRoleCtxt);
            WindowsAzurePowershellCmdlet getAzureEndpointCmdlet = new WindowsAzurePowershellCmdlet(getAzureEndpointCmdletInfo);

            Collection<PSObject> result = getAzureEndpointCmdlet.Run();
            if (result.Count == 1)
            {
                return (InputEndpointContext)result[0].BaseObject;
            }
            return null;
        }
コード例 #4
0
ファイル: GetAzureVMCommand.cs プロジェクト: nickchal/pash
		public IEnumerable<PersistentVMRoleContext> GetVirtualMachineProcess()
		{
			RoleList roleList;
			GetAzureVMCommand.GetAzureVMCommand variable = null;
			IEnumerable<PersistentVMRoleContext> persistentVMRoleContexts;
			Func<Role, bool> func = null;
			if (string.IsNullOrEmpty(this.ServiceName) || base.CurrentDeployment != null)
			{
				using (OperationContextScope operationContextScope = new OperationContextScope((IContextChannel)base.Channel))
				{
					try
					{
						List<PersistentVMRoleContext> persistentVMRoleContexts1 = new List<PersistentVMRoleContext>();
						if (!string.IsNullOrEmpty(this.ServiceName))
						{
							if (!string.IsNullOrEmpty(this.Name))
							{
								RoleList roleList1 = base.CurrentDeployment.RoleList;
								if (func == null)
								{
									func = (Role r) => r.RoleName.Equals(this.Name, StringComparison.InvariantCultureIgnoreCase);
								}
								roleList = new RoleList(roleList1.Where<Role>(func));
							}
							else
							{
								roleList = base.CurrentDeployment.RoleList;
							}
							for (int i = 0; i < roleList.Count; i++)
							{
								string empty = string.Empty;
								try
								{
									empty = roleList[i].RoleName;
									PersistentVMRole item = (PersistentVMRole)roleList[i];
									PersistentVMRoleContext persistentVMRoleContext = new PersistentVMRoleContext();
									if (base.CurrentDeployment != null)
									{
										persistentVMRoleContext.DNSName = base.CurrentDeployment.Url.AbsoluteUri;
									}
									persistentVMRoleContext.ServiceName = this.ServiceName;
									persistentVMRoleContext.Name = item.RoleName;
									persistentVMRoleContext.DeploymentName = base.CurrentDeployment.Name;
									persistentVMRoleContext.VM = new PersistentVM();
									persistentVMRoleContext.VM.AvailabilitySetName = item.AvailabilitySetName;
									persistentVMRoleContext.AvailabilitySetName = item.AvailabilitySetName;
									persistentVMRoleContext.Label = item.Label;
									persistentVMRoleContext.VM.ConfigurationSets = item.ConfigurationSets;
									persistentVMRoleContext.VM.ConfigurationSets.OfType<NetworkConfigurationSet>().SingleOrDefault<NetworkConfigurationSet>();
									persistentVMRoleContext.VM.DataVirtualHardDisks = item.DataVirtualHardDisks;
									persistentVMRoleContext.VM.Label = item.Label;
									persistentVMRoleContext.VM.OSVirtualHardDisk = item.OSVirtualHardDisk;
									persistentVMRoleContext.VM.RoleName = item.RoleName;
									persistentVMRoleContext.Name = item.RoleName;
									persistentVMRoleContext.VM.RoleSize = item.RoleSize;
									persistentVMRoleContext.InstanceSize = item.RoleSize;
									persistentVMRoleContext.VM.RoleType = item.RoleType;
									persistentVMRoleContext.InstanceStatus = base.CurrentDeployment.RoleInstanceList.Where<RoleInstance>((RoleInstance r) => r.RoleName == item.RoleName).First<RoleInstance>().InstanceStatus;
									persistentVMRoleContext.IpAddress = base.CurrentDeployment.RoleInstanceList.Where<RoleInstance>((RoleInstance r) => r.RoleName == this.vm.RoleName).First<RoleInstance>().IpAddress;
									persistentVMRoleContext.InstanceStateDetails = base.CurrentDeployment.RoleInstanceList.Where<RoleInstance>((RoleInstance r) => r.RoleName == item.RoleName).First<RoleInstance>().InstanceStateDetails;
									persistentVMRoleContext.PowerState = base.CurrentDeployment.RoleInstanceList.Where<RoleInstance>((RoleInstance r) => r.RoleName == item.RoleName).First<RoleInstance>().PowerState;
									persistentVMRoleContext.InstanceErrorCode = base.CurrentDeployment.RoleInstanceList.Where<RoleInstance>((RoleInstance r) => r.RoleName == item.RoleName).First<RoleInstance>().InstanceErrorCode;
									persistentVMRoleContext.InstanceName = base.CurrentDeployment.RoleInstanceList.Where<RoleInstance>((RoleInstance r) => r.RoleName == item.RoleName).First<RoleInstance>().InstanceName;
									int? instanceFaultDomain = base.CurrentDeployment.RoleInstanceList.Where<RoleInstance>((RoleInstance r) => r.RoleName == item.RoleName).First<RoleInstance>().InstanceFaultDomain;
									int value = instanceFaultDomain.Value;
									persistentVMRoleContext.InstanceFaultDomain = value.ToString();
									int? instanceUpgradeDomain = base.CurrentDeployment.RoleInstanceList.Where<RoleInstance>((RoleInstance r) => r.RoleName == item.RoleName).First<RoleInstance>().InstanceUpgradeDomain;
									int num = instanceUpgradeDomain.Value;
									persistentVMRoleContext.InstanceUpgradeDomain = num.ToString();
									persistentVMRoleContext.set_OperationDescription(base.CommandRuntime.ToString());
									persistentVMRoleContext.set_OperationId(base.GetDeploymentOperation.OperationTrackingId);
									persistentVMRoleContext.set_OperationStatus(base.GetDeploymentOperation.Status);
									persistentVMRoleContexts1.Add(persistentVMRoleContext);
								}
								catch (Exception exception)
								{
									base.WriteObject(string.Format("Could not read properties for virtual machine: {0}. It may still be provisioning.", empty));
								}
							}
							if (!string.IsNullOrEmpty(this.Name) && persistentVMRoleContexts1 != null && persistentVMRoleContexts1.Count > 0)
							{
								this.SaveRoleState(persistentVMRoleContexts1[0].VM);
							}
							persistentVMRoleContexts = persistentVMRoleContexts1;
							return persistentVMRoleContexts;
						}
						else
						{
							this.ListAllVMs();
							persistentVMRoleContexts = null;
							return persistentVMRoleContexts;
						}
					}
					catch (CommunicationException communicationException1)
					{
						CommunicationException communicationException = communicationException1;
						if (communicationException as EndpointNotFoundException == null || base.IsVerbose())
						{
							this.WriteErrorDetails(communicationException);
						}
						else
						{
							persistentVMRoleContexts = null;
							return persistentVMRoleContexts;
						}
					}
					persistentVMRoleContexts = null;
				}
				return persistentVMRoleContexts;
			}
			else
			{
				return null;
			}
		}