Inheritance: IPersistentVM
Ejemplo n.º 1
0
        public SetAzureSubnetCmdletInfo(PersistentVM vm, string[] subnetNames)
        {
            this.cmdletName = Utilities.SetAzureSubnetCmdletName;

            this.cmdletParams.Add(new CmdletParam("VM", vm));
            this.cmdletParams.Add(new CmdletParam("SubnetNames", subnetNames));
        }
        public NewAzureVMCmdletInfo(string serviceName, PersistentVM[] vMs)
        {
            this.cmdletName = Utilities.NewAzureVMCmdletName;

            this.cmdletParams.Add(new CmdletParam("ServiceName", serviceName));
            this.cmdletParams.Add(new CmdletParam("VMs", vMs));
        }
        public SetAzureAvailabilitySetCmdletInfo(string availabilitySetName, PersistentVM vm)
        {
            cmdletName = Utilities.SetAzureAvailabilitySetCmdletName;

            cmdletParams.Add(new CmdletParam("AvailabilitySetName", availabilitySetName));
            this.cmdletParams.Add(new CmdletParam("VM", vm));
        }
        public UpdateAzureVMCmdletInfo(string vmName, string serviceName, PersistentVM persistentVM)
        {
            cmdletName = Utilities.UpdateAzureVMCmdletName;

            this.cmdletParams.Add(new CmdletParam("Name", vmName));
            this.cmdletParams.Add(new CmdletParam("ServiceName", serviceName));
            this.cmdletParams.Add(new CmdletParam("VM", persistentVM));
        }
Ejemplo n.º 5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="vm"></param>
 /// <param name="availabilitySetName"></param>
 /// <returns></returns>
 internal static bool AzureAvailabilitySet(PersistentVM vm, string availabilitySetName)
 {
     try
     {
         Assert.IsTrue(vm.AvailabilitySetName.Equals(availabilitySetName, StringComparison.InvariantCultureIgnoreCase));
         return true;
     }
     catch (Exception e)
     {
         Console.WriteLine(e.ToString());
         if (e is AssertFailedException)
         {
             return false;
         }
         else
         {
             throw;
         }
     }
 }
Ejemplo n.º 6
0
        public static void SaveStateToFile(PersistentVM role, string filePath)
        {
            if (role == null)
            {
                throw new ArgumentNullException("role", "Role cannot be null");
            }

            XmlAttributeOverrides overrides = new XmlAttributeOverrides();
            XmlAttributes ignoreAttrib = new XmlAttributes();
            ignoreAttrib.XmlIgnore = true;
            overrides.Add(typeof(Microsoft.Samples.WindowsAzure.ServiceManagement.DataVirtualHardDisk), "MediaLink", ignoreAttrib);
            overrides.Add(typeof(Microsoft.Samples.WindowsAzure.ServiceManagement.DataVirtualHardDisk), "SourceMediaLink", ignoreAttrib);
            overrides.Add(typeof(Microsoft.Samples.WindowsAzure.ServiceManagement.OSVirtualHardDisk), "MediaLink", ignoreAttrib);

            var serializer = new System.Xml.Serialization.XmlSerializer(typeof(PersistentVM), overrides, new Type[] { typeof(NetworkConfigurationSet) }, null, null);
            using (TextWriter writer = new StreamWriter(filePath))
            {
                serializer.Serialize(writer, role);
            }
        }
Ejemplo n.º 7
0
        public NewAzureVMCmdletInfo(string serviceName, PersistentVM[] vMs, string vnetName, DnsServer[] dnsSettings,
            string serviceLabel, string serviceDescription, string deploymentLabel, string deploymentDescription, string location, string affinityGroup)
        {
            this.cmdletName = Utilities.NewAzureVMCmdletName;

            this.cmdletParams.Add(new CmdletParam("ServiceName", serviceName));
            this.cmdletParams.Add(new CmdletParam("VMs", vMs));
            if (vnetName != null)
            {
                this.cmdletParams.Add(new CmdletParam("VNetName", vnetName));
            }
            if (dnsSettings != null)
            {
                this.cmdletParams.Add(new CmdletParam("DnsSettings", dnsSettings));
            }
            if (affinityGroup != null)
            {
                this.cmdletParams.Add(new CmdletParam("AffinityGroup", affinityGroup));
            }
            if (serviceLabel != null)
            {
                this.cmdletParams.Add(new CmdletParam("ServiceLabel", serviceLabel));
            }
            if (serviceDescription != null)
            {
                this.cmdletParams.Add(new CmdletParam("ServiceDescription", serviceDescription));
            }
            if (deploymentLabel != null)
            {
                this.cmdletParams.Add(new CmdletParam("DeploymentLabel", deploymentLabel));
            }
            if (deploymentDescription != null)
            {
                this.cmdletParams.Add(new CmdletParam("DeploymentDescription", deploymentDescription));
            }
            if (location != null)
            {
                this.cmdletParams.Add(new CmdletParam("Location", location));
            }
        }
Ejemplo n.º 8
0
		public static void SaveStateToFile(PersistentVM role, string filePath)
		{
			if (role != null)
			{
				XmlAttributeOverrides xmlAttributeOverride = new XmlAttributeOverrides();
				XmlAttributes xmlAttribute = new XmlAttributes();
				xmlAttribute.XmlIgnore = true;
				xmlAttributeOverride.Add(typeof(DataVirtualHardDisk), "MediaLink", xmlAttribute);
				xmlAttributeOverride.Add(typeof(DataVirtualHardDisk), "SourceMediaLink", xmlAttribute);
				xmlAttributeOverride.Add(typeof(OSVirtualHardDisk), "MediaLink", xmlAttribute);
				Type[] typeArray = new Type[1];
				typeArray[0] = typeof(NetworkConfigurationSet);
				XmlSerializer xmlSerializer = new XmlSerializer(typeof(PersistentVM), xmlAttributeOverride, typeArray, null, null);
				using (TextWriter streamWriter = new StreamWriter(filePath))
				{
					xmlSerializer.Serialize(streamWriter, role);
				}
				return;
			}
			else
			{
				throw new ArgumentNullException("role", "Role cannot be null");
			}
		}
Ejemplo n.º 9
0
 public SetAzureOSDiskCmdletInfo(HostCaching hs, PersistentVM vm)
 {
     cmdletName = Utilities.SetAzureOSDiskCmdletName;
     this.cmdletParams.Add(new CmdletParam("HostCaching", hs.ToString()));
     this.cmdletParams.Add(new CmdletParam("VM", vm));
 }
Ejemplo n.º 10
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="vm"></param>
 /// <param name="expLabel"></param>
 /// <param name="expSize"></param>
 /// <param name="expLun"></param>
 /// <param name="hc"></param>
 /// <returns></returns>
 internal static bool AzureDataDisk(PersistentVM vm, string expLabel, int expSize, int expLun, HostCaching hc)
 {
     bool found = false;
     foreach (DataVirtualHardDisk disk in vmPowershellCmdlets.GetAzureDataDisk(vm))
     {
         if (CheckDataDisk(disk, expLabel, expSize, expLun, hc))
         {
             found = true;
             break;
         }
     }
     return found;
 }
Ejemplo n.º 11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="vm"></param>
 /// <param name="expOS"></param>
 /// <param name="expHC"></param>
 /// <returns></returns>
 internal static bool AzureOsDisk(PersistentVM vm, string expOS, HostCaching expHC)
 {
     try
     {
         OSVirtualHardDisk osdisk = vmPowershellCmdlets.GetAzureOSDisk(vm);
         Console.WriteLine("OS Disk: Name - {0}, Label - {1}, HostCaching - {2}, OS - {3}", osdisk.DiskName, osdisk.DiskLabel, osdisk.HostCaching, osdisk.OS);
         Assert.IsTrue(osdisk.Equals(vm.OSVirtualHardDisk), "OS disk returned is not the same!");
         Assert.AreEqual(expOS, osdisk.OS);
         Assert.AreEqual(expHC.ToString(), osdisk.HostCaching);
         return true;
     }
     catch (Exception e)
     {
         Console.WriteLine(e.ToString());
         if (e is AssertFailedException)
         {
             return false;
         }
         else
         {
             throw;
         }
     }
 }
 public RemoveAzureEndpointCmdletInfo(string epName, PersistentVM vm)
 {
     this.cmdletName = Utilities.RemoveAzureEndpointCmdletName;
     this.cmdletParams.Add(new CmdletParam("Name", epName));
     this.cmdletParams.Add(new CmdletParam("VM", vm));
 }
        internal Collection<ManagementOperationContext> NewAzureVM(string serviceName, PersistentVM[] VMs)
        {
            NewAzureVMCmdletInfo newAzureVMCmdletInfo = new NewAzureVMCmdletInfo(serviceName, VMs);
            WindowsAzurePowershellCmdlet newAzureVMCmdlet = new WindowsAzurePowershellCmdlet(newAzureVMCmdletInfo);

            Collection<ManagementOperationContext> newAzureVMs = new Collection<ManagementOperationContext>();
            foreach (PSObject result in newAzureVMCmdlet.Run())
            {
                newAzureVMs.Add((ManagementOperationContext)result.BaseObject);
            }
            return newAzureVMs;
        }
Ejemplo n.º 14
0
		protected override void SaveRoleState(PersistentVM role)
		{
			PersistentVMHelper.SaveStateToFile(role, this.Path);
		}
Ejemplo n.º 15
0
		protected override void ProcessRecord()
		{
			Uri uri;
			string diskLabel;
			try
			{
				base.ProcessRecord();
				this.ValidateParameters();
				if (string.IsNullOrEmpty(this.Label))
				{
					this.Label = this.Name;
				}
				this.Label = ServiceManagementHelper.EncodeToBase64String(this.Label);
				PersistentVM persistentVM = new PersistentVM();
				persistentVM.AvailabilitySetName = this.AvailabilitySetName;
				persistentVM.ConfigurationSets = new Collection<ConfigurationSet>();
				persistentVM.DataVirtualHardDisks = new Collection<DataVirtualHardDisk>();
				persistentVM.RoleName = this.Name;
				persistentVM.RoleSize = this.InstanceSize;
				persistentVM.RoleType = "PersistentVMRole";
				persistentVM.Label = this.Label;
				PersistentVM persistentVM1 = persistentVM;
				PersistentVM persistentVM2 = persistentVM1;
				OSVirtualHardDisk oSVirtualHardDisk = new OSVirtualHardDisk();
				oSVirtualHardDisk.DiskName = this.DiskName;
				oSVirtualHardDisk.SourceImageName = this.ImageName;
				OSVirtualHardDisk oSVirtualHardDisk1 = oSVirtualHardDisk;
				if (string.IsNullOrEmpty(this.MediaLocation))
				{
					uri = null;
				}
				else
				{
					uri = new Uri(this.MediaLocation);
				}
				oSVirtualHardDisk1.MediaLink = uri;
				oSVirtualHardDisk.HostCaching = this.HostCaching;
				OSVirtualHardDisk oSVirtualHardDisk2 = oSVirtualHardDisk;
				if (string.IsNullOrEmpty(this.DiskLabel))
				{
					diskLabel = null;
				}
				else
				{
					diskLabel = this.DiskLabel;
				}
				oSVirtualHardDisk2.DiskLabel = diskLabel;
				persistentVM2.OSVirtualHardDisk = oSVirtualHardDisk;
				CmdletExtensions.WriteVerboseOutputForObject(this, persistentVM1);
				base.WriteObject(persistentVM1, true);
			}
			catch (Exception exception1)
			{
				Exception exception = exception1;
				base.WriteError(new ErrorRecord(exception, string.Empty, ErrorCategory.CloseError, null));
			}
		}
Ejemplo n.º 16
0
 public StopAzureVMCmdletInfo(PersistentVM vm, string serviceName, bool stay, bool force)
     : this(serviceName, stay, force)
 {
     this.cmdletParams.Add(new CmdletParam("VM", vm));
 }
        private ManagementOperationContext UpdateAzureVM(string serviceName, string vmName, PersistentVM persistentVM)
        {
            UpdateAzureVMCmdletInfo updateAzureVMCmdletInfo = new UpdateAzureVMCmdletInfo(serviceName, vmName, persistentVM);
            WindowsAzurePowershellCmdlet updateAzureVMCmdlet = new WindowsAzurePowershellCmdlet(updateAzureVMCmdletInfo);

            Collection<PSObject> result = updateAzureVMCmdlet.Run();
            if (result.Count == 1)
            {
                return (ManagementOperationContext)result[0].BaseObject;
            }
            return null;
        }
Ejemplo n.º 18
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="vm"></param>
        /// <param name="epInfos"></param>
        /// <returns></returns>
        internal static bool AzureEndpoint(PersistentVM vm, AzureEndPointConfigInfo[] epInfos)
        {
            try
            {
                var serverEndpoints = vmPowershellCmdlets.GetAzureEndPoint(vm);

                // List the endpoints found for debugging.
                Console.WriteLine("***** Checking for Endpoints **************************************************");
                Console.WriteLine("***** Listing Returned Endpoints");
                foreach (InputEndpointContext ep in serverEndpoints)
                {
                    Console.WriteLine("Endpoint - Name:{0} Protocol:{1} Port:{2} LocalPort:{3} Vip:{4}", ep.Name, ep.Protocol, ep.Port, ep.LocalPort, ep.Vip);

                    if (!string.IsNullOrEmpty(ep.LBSetName))
                    {
                        Console.WriteLine("\t- LBSetName:{0}", ep.LBSetName);
                        Console.WriteLine("\t- Probe - Port:{0} Protocol:{1} Interval:{2} Timeout:{3}", ep.ProbePort, ep.ProbeProtocol, ep.ProbeIntervalInSeconds, ep.ProbeTimeoutInSeconds);
                    }
                }

                Console.WriteLine("*******************************************************************************");

                // Check if the specified endpoints were found.
                foreach (AzureEndPointConfigInfo epInfo in epInfos)
                {
                    bool found = false;

                    foreach (InputEndpointContext ep in serverEndpoints)
                    {
                        if (epInfo.CheckInputEndpointContext(ep))
                        {
                            found = true;
                            Console.WriteLine("Endpoint found: {0}", epInfo.EndpointName);
                            break;
                        }
                    }
                    Assert.IsTrue(found, string.Format("Error: Endpoint '{0}' was not found!", epInfo.EndpointName));
                }
                return true;
            }

            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                return false;
            }
        }
Ejemplo n.º 19
0
        public GetAzureSubnetCmdletInfo(PersistentVM vm)
        {
            this.cmdletName = Utilities.GetAzureSubnetCmdletName;

            this.cmdletParams.Add(new CmdletParam("VM", vm));
        }
Ejemplo n.º 20
0
		protected virtual void SaveRoleState(PersistentVM role)
		{
		}