public static bool CanActivate(Host host) { //This check used to be "_expiresText != Messages.LICENSE_NEVER" but I've swapped it for //"!host.isOEM" according to the ticket CA-37336 where this 3rd part of the check was added //OEM licenses (< XS ver 5.5) have perpetual (2036) expiry dates return host.IsFreeLicense() && host.IsFloodgateOrLater() && !host.isOEM && !Helpers.ClearwaterOrGreater(host); }
/// <summary> /// Initializes a new instance of the <see cref="AssignLicenseDialog"/> class. /// </summary> /// <param name="hosts">The hosts for which the licensing is to be applied.</param> public AssignLicenseDialog(IEnumerable<IXenObject> xos, String firstHost, String firstPort, Host.Edition firstEdition) { Util.ThrowIfEnumerableParameterNullOrEmpty(xos, "XenObjects"); this.xos = new List<IXenObject>(xos); this.currentEdition = firstEdition; InitializeComponent(); licenseServerNameTextBox.TextChanged += licenseServerPortTextBox_TextChanged; licenseServerPortTextBox.TextChanged += licenseServerNameTextBox_TextChanged; SetOptionsForClearwaterAndNewer(); UpdateButtonEnablement(); // if all the hosts have the same license server details then populate the textboxes. List<Host> hosts = CreateHostsList(); if (hosts[0].license_server.ContainsKey("address") && hosts[0].license_server.ContainsKey("port") && hosts[0].license_server["address"] != "localhost") { if (hosts.TrueForAll(delegate(Host h) { return h.license_server.ContainsKey("address") && h.license_server.ContainsKey("port") && h.license_server["address"] == hosts[0].license_server["address"] && h.license_server["port"] == hosts[0].license_server["port"]; })) { licenseServerPortTextBox.Text = hosts[0].license_server["port"]; licenseServerNameTextBox.Text = hosts[0].license_server["address"]; } } else if ((!String.IsNullOrEmpty(firstHost)) && (!String.IsNullOrEmpty(firstPort))) { licenseServerPortTextBox.Text = firstPort; licenseServerNameTextBox.Text = firstHost; } }
public EvacuateHostPlanAction(Host host) : base(host.Connection, string.Format(Messages.PLANACTION_VMS_MIGRATING, host.Name)) { base.TitlePlan = string.Format(Messages.MIGRATE_VMS_OFF_SERVER, host.Name); this._host = new XenRef<Host>(host); currentHost = host; }
/// <summary> /// Won't appear in the program history (SuppressHistory == true). /// </summary> /// <param name="masterUuid">The UUID of the host from which to perform the probe (usually the pool master).</param> /// <param name="srType">netapp or iscsi</param> public SrProbeAction(IXenConnection connection, Host host, SR.SRTypes srType, Dictionary<String, String> dconf) : base(connection, string.Format(Messages.ACTION_SCANNING_SR_FROM, Helpers.GetName(connection)), null, true) { this.host = host; this.srType = srType; this.dconf = dconf; switch (srType) { case XenAPI.SR.SRTypes.nfs: Description = string.Format(Messages.ACTION_SR_SCANNING, XenAPI.SR.getFriendlyTypeName(srType), dconf["server"]); break; case XenAPI.SR.SRTypes.lvmoiscsi: Description = string.Format(Messages.ACTION_SR_SCANNING, XenAPI.SR.getFriendlyTypeName(srType), dconf["target"]); break; case XenAPI.SR.SRTypes.lvmohba: String device = dconf.ContainsKey(DEVICE) ? dconf[DEVICE] : dconf[SCSIid]; Description = string.Format(Messages.ACTION_SR_SCANNING, XenAPI.SR.getFriendlyTypeName(srType), device); break; default: Description = string.Format(Messages.ACTION_SR_SCANNING, XenAPI.SR.getFriendlyTypeName(srType), Messages.REPAIRSR_SERVER); // this is a bit minging: CA-22111 break; } smconf = new Dictionary<string, string>(); }
protected VMProblem(Check check, VM vm) : base(check) { _vm = vm; ResidentOn = VM.Connection.Resolve(VM.resident_on); }
public new static bool CanExecute(VM vm, Host preSelectedHost) { if (vm == null || vm.is_a_template || vm.Locked || vm.power_state == vm_power_state.Running) return false; return CrossPoolMigrateCommand.CanExecute(vm, preSelectedHost); }
/// <summary> /// /// </summary> /// <param name="connection"></param> /// <param name="pool">May be null.</param> /// <param name="host">Never null. In the case of a pool, "host" is set to the master.</param> public NewNetworkWizard(Network.IXenConnection connection, Pool pool, Host host) : base(connection) { InitializeComponent(); pageNetworkType = new NetWTypeSelect(); pageName = new NetWName(); pageNetworkDetails = new NetWDetails(); pageBondDetails = new NetWBondDetails(); pageChinDetails = new NetWChinDetails(); System.Diagnostics.Trace.Assert(host != null); Pool = pool; Host = host; if (Pool != null) pageBondDetails.SetPool(Pool); else pageBondDetails.SetHost(Host); pageNetworkDetails.Host = host; pageChinDetails.Host = host; pageChinDetails.Pool = pool; AddPage(pageNetworkType); AddPage(new XenTabPage { Text = "" }); }
public EjectHostFromPoolAction(Pool pool,Host hostToEject) : base(pool.Connection, string.Format(Messages.REMOVING_SERVER_FROM_POOL, hostToEject.Name, pool.Name)) { this.Pool = pool; this.Host = hostToEject; this.Description = Messages.WAITING; }
public ApplyXenServerPatchPlanAction(Host host, XenServerPatch xenServerPatch, List<PoolPatchMapping> mappings) : base(host.Connection, string.Format(Messages.UPDATES_WIZARD_APPLYING_UPDATE, xenServerPatch.Name, host.Name)) { this.host = host; this.xenServerPatch = xenServerPatch; this.mappings = mappings; }
public static new bool CanExecute(VM vm, Host preSelectedHost) { if (vm == null || !vm.is_a_template || vm.DefaultTemplate || vm.Locked) return false; return CrossPoolMigrateCommand.CanExecute(vm, preSelectedHost); }
public ImportVmAction(IXenConnection connection, Host affinity, string filename, SR sr) : base(connection, string.Format(Messages.IMPORTVM_TITLE, filename, Helpers.GetName(connection)), Messages.IMPORTVM_PREP) { Pool = Helpers.GetPoolOfOne(connection); m_affinity = affinity; Host = affinity ?? connection.Resolve(Pool.master); SR = sr; VM = null; m_filename = filename; #region RBAC Dependencies ApiMethodsToRoleCheck.AddRange(ConstantRBACRequirements); if (affinity != null) ApiMethodsToRoleCheck.Add("vm.set_affinity"); //?? //if (startAutomatically) // ApiMethodsToRoleCheck.Add("vm.start"); ApiMethodsToRoleCheck.AddRange(Role.CommonTaskApiList); ApiMethodsToRoleCheck.AddRange(Role.CommonSessionApiList); #endregion }
public CopyPatchFromHostToOther(IXenConnection connection, Host hostDestiny, Pool_patch patchToCopy) : base(connection, Messages.UPLOADING_PATCH, true) { _hostDestiny = hostDestiny; _patchToCopy = patchToCopy; Host = _hostDestiny; }
protected IqnAlert(Host host) { Host = host; HostUuid = host.uuid; _timestamp = DateTime.UtcNow; Connection = host.Connection; }
/// <summary> /// Attempts to set the LastPowerOnSucceeded flag in the WLB Host configuration /// </summary> private void UpdateHostLastPowerOnSucceeded(bool succeeded, XenAPI.Host host) { try { //Helpers.SetOtherConfig(this.Host.Connection.Session, this.Host, "LastPowerOnsucceeded", successful.ToString()); WlbHostConfiguration hostConfig = new WlbHostConfiguration(host.uuid); hostConfig.LastPowerOnSucceeded = succeeded; if (!succeeded) { hostConfig.ParticipatesInPowerManagement = false; } XenAPI.Pool pool = Helpers.GetPoolOfOne(host.Connection); if (null != pool) { SendWlbConfigurationAction action = new SendWlbConfigurationAction(pool, hostConfig.ToDictionary(), SendWlbConfigurationKind.SetHostConfiguration); action.RunExternal(Session); } else { throw new Failure(Failure.INTERNAL_ERROR, Messages.POOL_GONE); } } catch (Exception ex) { log.Error("Unable to set the host's LastPowerOnSucceeded status.", ex); } }
/// <summary> /// Initializes a new instance of the <see cref="SelectedItem"/> class. /// </summary> /// <param name="xenObject">The xen object that is selected.</param> /// <param name="connection">The connection of the xen object.</param> /// <param name="hostAncestor">The host ancestor of the xen object in the tree.</param> /// <param name="poolAncestor">The pool ancestor of the xen object in the tree.</param> public SelectedItem(IXenObject xenObject, IXenConnection connection, Host hostAncestor, Pool poolAncestor) { _xenObject = xenObject; _hostAncestor = hostAncestor; _poolAncestor = poolAncestor; _connection = connection; }
private bool IsHostLicenseRestricted(Host host) { if(host == null) return false; return !host.CanApplyHotfixes; }
public ApplyLicenseAction(Network.IXenConnection connection, Host host, string filepath, bool activateFreeLicense) : base(connection, string.Format(Messages.APPLYLICENSE_TITLE, host.Name), Messages.APPLYLICENSE_PREP) { this.Host = host; this.Filepath = filepath; this.ActivateFreeLicense = activateFreeLicense; }
public CrossPoolMigrateWizard(IXenConnection con, IEnumerable<SelectedItem> selection, Host targetHostPreSelection) : base(con) { InitializeComponent(); hostPreSelection = targetHostPreSelection; InitialiseWizard(selection); }
/// <summary> /// /// </summary> /// <param name="connection"></param> /// <param name="pool">May be null, in which case we're acting on a single host basis.</param> /// <param name="host">If pool is set, then host should be the pool master.</param> /// <param name="newPIFs">New PIF instances that are to be created on the server.</param> /// <param name="downPIFs"></param> /// <param name="newManagement">May be null, in which case the management network will not be disturbed. /// Note that it is still possible for the management interface to receive a new IP address even if this /// parameter is null, because it may be in newPIFs. You only need to use this parameter if the management /// interface is switching onto a different PIF.</param> /// <param name="downManagement">May be null iff newManagement is null.</param> public ChangeNetworkingAction(IXenConnection connection, Pool pool, Host host, List<PIF> newPIFs, List<PIF> downPIFs, PIF newManagement, PIF downManagement, bool managementIPChanged) : base(connection, Messages.ACTION_CHANGE_NETWORKING_TITLE) { Pool = pool; Host = host; this.newPIFs = newPIFs; this.downPIFs = downPIFs; this.newManagement = newManagement; this.downManagement = downManagement; this.managementIPChanged = managementIPChanged; if (pool != null) { // If we're going to compute address ranges, then we need a sorted list of hosts (to keep the addresses stable). Hosts = Connection.Cache.Hosts; Array.Sort(Hosts); foreach (Host h in Hosts) { AppliesTo.Add(h.opaque_ref); } } #region RBAC Dependencies ApiMethodsToRoleCheck.Add("vm.set_memory_limits"); ApiMethodsToRoleCheck.Add("host.management_reconfigure"); ApiMethodsToRoleCheck.Add("pif.reconfigure_ip"); ApiMethodsToRoleCheck.Add("pif.plug"); ApiMethodsToRoleCheck.AddRange(XenAPI.Role.CommonSessionApiList); ApiMethodsToRoleCheck.AddRange(XenAPI.Role.CommonTaskApiList); #endregion }
private bool CanExecute(Host host) { if (host == null) return false; return true; }
private static string GetTitle(VM vm, Host toHost) { Host residentOn = vm.Connection.Resolve(vm.resident_on); return residentOn == null ? string.Format(Messages.ACTION_VM_MIGRATING_NON_RESIDENT, vm.Name, toHost.Name) : string.Format(Messages.ACTION_VM_MIGRATING_RESIDENT, vm.Name, Helpers.GetName(residentOn), toHost.Name); }
public VMMigrateAction(VM vm, Host destinationHost) : base(vm.Connection, GetTitle(vm, destinationHost)) { this.Description = Messages.ACTION_PREPARING; this.VM = vm; this.Host = destinationHost; this.Pool = Core.Helpers.GetPool(vm.Connection); }
public sealed override void Apply(Host host, Session session) { foreach (Hotfix hotfix in ComponentHotfixes) { if(hotfix.ShouldBeAppliedTo(host)) hotfix.Apply(host, session); } }
public PvsCacheStorageRow(Host host, PVS_site site) { InitializeComponent(); Host = host; PvsSite = site; OrigPvsCacheStorage = site != null ? site.PvsCacheStorage(host) : null; Populate(); }
public DestroyHostAction(Pool pool, Host hostToDestroy) : base(pool.Connection, string.Format(Messages.DESTROY_HOST_ACTION_TITLE, hostToDestroy.Name)) { this.Pool = pool; this.Host = hostToDestroy; this.Description = Messages.WAITING; SetRBACPermissions(); }
public ExecutePluginAction(IXenConnection connection, Host host, string plugin, string function, Dictionary<string, string> args, bool hide_from_logs) : base(connection, string.Format(Messages.PLUGIN_TITLE, plugin),hide_from_logs) { Host = host; Plugin = plugin; Function = function; Args = args; }
public DisableHostAction(Host host) : base(host.Connection,Messages.HOST_DISABLE) { Host = host; AddCommonAPIMethodsToRoleCheck(); ApiMethodsToRoleCheck.Add("host.remove_from_other_config"); ApiMethodsToRoleCheck.Add("host.disable"); }
private void Init() { singlePool = DatabaseManager.ConnectionFor(oneHostPool).Cache.Pools.First(p => p.name_label == "40"); Assert.IsNotNull(singlePool, "Resolved pool"); singlePoolHost = DatabaseManager.ConnectionFor(oneHostPool).Cache.Hosts.First(h => h.name_label == "dt40"); Assert.IsNotNull(singlePoolHost, "Resolved host"); }
public VMSnapshotRevertAction(VM snapshot) : base(snapshot.Connection, String.Format(Messages.ACTION_VM_REVERT_SNAPSHOT_TITLE, snapshot.Name)) { this.VM = Connection.Resolve<VM>(snapshot.snapshot_of); previousHost = Connection.Resolve<Host>(VM.resident_on); this.m_Snapshot = snapshot; Description = String.Format(Messages.VM_REVERTING, m_Snapshot.Name); }
public RescanPIFsAction(Host h) : base(h.Connection, string.Format(Messages.ACTION_PIF_SCAN_TITLE, Helpers.GetName(h)), Messages.ACTION_PIF_SCAN_START_DESC, false) { Host = h; #region RBAC Dependencies ApiMethodsToRoleCheck.Add("pif.scan"); #endregion }
public CleanupDiskSpaceAction(Host host, Pool_patch excludedPatch, bool suppressHistory) : base(host.Connection, Messages.ACTION_CLEANUP_DISK_SPACE_TITLE, "", suppressHistory) { if (host == null) throw new ArgumentNullException("host"); Host = host; this.excludedPatch = excludedPatch; }
public HostPowerOnAction(XenAPI.Host host) : base(host.Connection, Messages.HOST_POWER_ON) { Host = host; AddCommonAPIMethodsToRoleCheck(); ApiMethodsToRoleCheck.Add("pool.send_wlb_configuration"); ApiMethodsToRoleCheck.Add("host.power_on"); }
private static string GetTitle(VM vm, Host toHost) { XenAPI.Host residentOn = vm.Connection.Resolve(vm.resident_on); if (residentOn == null) { return(Messages.ACTION_VM_MIGRATING); } else { return(string.Format(Messages.ACTION_VM_MIGRATING_TITLE, vm.Name, Helpers.GetName(residentOn), toHost.Name)); } }
public LicenseDataStruct(XenAPI.Host host) { if (Helpers.MidnightRideOrGreater(host)) { Edition = host.edition; } else { Edition = host.license_params.ContainsKey("sku_type") ? host.license_params["sku_type"] : ""; } ExpiryDate = host.license_params.ContainsKey("expiry") ? host.license_params["expiry"] : ""; }
protected override void Run() { bool succeeded = false; string name = Helpers.GetName(Host); XenAPI.Host master = Helpers.GetMaster(Connection); AppliesTo.Add(master.opaque_ref); Title = string.Format(Messages.ACTION_HOST_START_TITLE, name); Description = Messages.ACTION_HOST_STARTING; try { XenAPI.Host.power_on(Session, Host.opaque_ref); Description = Messages.ACTION_HOST_STARTED; succeeded = true; /* WLB: Below code doesn't work, becasue RelatedTask is not set. * Need to explore other option when enabling set poweron task value for wlb reporting * if (Helpers.IsWLBEnabled(this.Connection) * && Host.other_config.ContainsKey(WlbOptimizePoolAction.OPTIMIZINGPOOL)) * { * // set host poweroff task key values for wlb reporting purpose * Task.add_to_other_config(this.Session, this.RelatedTask.opaque_ref, "wlb_advised", Host.other_config[WlbOptimizePoolAction.OPTIMIZINGPOOL]); * Task.add_to_other_config(this.Session, this.RelatedTask.opaque_ref, "wlb_action", "host_poweron"); * Task.add_to_other_config(this.Session, this.RelatedTask.opaque_ref, "wlb_action_obj_ref", Host.opaque_ref); * Task.add_to_other_config(this.Session, this.RelatedTask.opaque_ref, "wlb_action_obj_type", "host"); * } */ } catch (Exception e) { Failure f = e as Failure; if (f != null) { string msg = f.ErrorDescription.Count > 2 ? Messages.ResourceManager.GetString(f.ErrorDescription[2]) : null; if (msg != null) { throw new Exception(msg); } else { throw new Exception(string.Format(Messages.POWER_ON_REQUEST_FAILED, this.Host)); } } throw; } finally { if (Helpers.WlbConfigured(this.Connection) && Helpers.WlbEnabledAndConfigured(this.Connection)) { UpdateHostLastPowerOnSucceeded(succeeded, Host); } } }
private void ProduceXmlForHost(XenAPI.Host host, LicenseDataStruct previousLicenseData, XmlWriter writer) { // wait for host to be updated for (int i = 0; i < 100 && Helper.AreEqual2(host.license_params["expiry"], previousLicenseData.ExpiryDate) && Helper.AreEqual2(host.edition, previousLicenseData.Edition); i++) { Thread.Sleep(100); } writer.WriteStartElement("host"); writer.WriteAttributeString("uuid", host.uuid); foreach (KeyValuePair <String, String> kvp in host.software_version) { writer.WriteStartElement("software_version_element"); writer.WriteAttributeString("key", kvp.Key); writer.WriteAttributeString("value", kvp.Value); writer.WriteEndElement(); } // edition information if (IncludeSKU) { string newEdition; if (String.IsNullOrEmpty(CurrentEdition)) { if (Helpers.MidnightRideOrGreater(host)) { newEdition = host.edition; } else { newEdition = host.license_params.ContainsKey("sku_type") ? host.license_params["sku_type"] : ""; } } else { newEdition = CurrentEdition; } writer.WriteStartElement("SKU"); writer.WriteAttributeString("from", previousLicenseData.Edition); writer.WriteAttributeString("to", newEdition); writer.WriteEndElement(); } // license expiry information writer.WriteStartElement("license_expiry_date"); writer.WriteAttributeString("from", previousLicenseData.ExpiryDate); writer.WriteAttributeString("to", host.license_params["expiry"]); writer.WriteEndElement(); writer.WriteEndElement(); }
protected override void Run() { // If either of the static memories has changed, we need to shut down the VM // before and reboot afterwards. The user has already been warned about this. bool reboot = needReboot; XenAPI.Host vmHost = null; if (reboot) { vmHost = VM.Home(); AsyncAction action = null; if (VM.allowed_operations.Contains(XenAPI.vm_operations.clean_shutdown)) { action = new VMCleanShutdown(VM); } else { action = new VMHardShutdown(VM); } action.RunExternal(Session); } // Now save the memory settings. We can't use VM.SaveChanges() for this, // because we have to do the operations simultaneously or we will // violate the memory ordering constraints. try { if (staticChanged) { XenAPI.VM.set_memory_limits(Session, VM.opaque_ref, static_min, static_max, dynamic_min, dynamic_max); } else { XenAPI.VM.set_memory_dynamic_range(Session, VM.opaque_ref, dynamic_min, dynamic_max); } } // Reboot the VM, even if we failed to change the memory settings finally { if (reboot) { var action = new VMStartOnAction(VM, vmHost, _warningDialogHAInvalidConfig, _startDiagnosticForm); action.RunExternal(Session); } } Description = string.Format(Messages.ACTION_CHANGE_MEMORY_SETTINGS_DONE, VM.Name); }
private void ProcessRecordHost(string host_cpu) { RunApiCall(() => { string objRef = XenAPI.Host_cpu.get_host(session, host_cpu); XenAPI.Host obj = null; if (objRef != "OpaqueRef:NULL") { obj = XenAPI.Host.get_record(session, objRef); obj.opaque_ref = objRef; } WriteObject(obj, true); }); }
private void ProcessRecordMaster(string pool) { RunApiCall(() => { string objRef = XenAPI.Pool.get_master(session, pool); XenAPI.Host obj = null; if (objRef != "OpaqueRef:NULL") { obj = XenAPI.Host.get_record(session, objRef); obj.opaque_ref = objRef; } WriteObject(obj, true); }); }
private void ProcessRecordResidentOn(string task) { RunApiCall(() => { string objRef = XenAPI.Task.get_resident_on(session, task); XenAPI.Host obj = null; if (objRef != "OpaqueRef:NULL") { obj = XenAPI.Host.get_record(session, objRef); obj.opaque_ref = objRef; } WriteObject(obj, true); }); }
public SetCslgCredentialsToPoolAction(IXenConnection connection, string host, string username, string password) : base(connection, string.Format(Messages.SET_STORAGELINK_CREDS_TO_POOL_ACTION_TITLE, Helpers.GetPoolOfOne(connection)), string.Format(Messages.SET_STORAGELINK_CREDS_TO_POOL_ACTION_DESCRIPTION, Helpers.GetPoolOfOne(connection))) { Util.ThrowIfParameterNull(connection, "connection"); _host = host; _username = username; _password = password; if (Helpers.FeatureForbidden(connection, Host.RestrictStorageChoices)) { throw new ArgumentException("Pool not licensed.", "host"); } if (!Helpers.MidnightRideOrGreater(connection)) { throw new ArgumentException("Pool must by Midnight Ride or later.", "host"); } XenAPI.Pool pool = Helpers.GetPool(Connection); if (pool != null) { AppliesTo.Add(pool.opaque_ref); } else { XenAPI.Host master = Helpers.GetMaster(Connection); if (master != null) { AppliesTo.Add(master.opaque_ref); } } }
protected override void ProcessRecord() { XenAPI.Session session = XenObject as XenAPI.Session; if (session != null) { WriteObject(new XenRef <XenAPI.Session>(session)); return; } XenAPI.Auth auth = XenObject as XenAPI.Auth; if (auth != null) { WriteObject(new XenRef <XenAPI.Auth>(auth)); return; } XenAPI.Subject subject = XenObject as XenAPI.Subject; if (subject != null) { WriteObject(new XenRef <XenAPI.Subject>(subject)); return; } XenAPI.Role role = XenObject as XenAPI.Role; if (role != null) { WriteObject(new XenRef <XenAPI.Role>(role)); return; } XenAPI.Task task = XenObject as XenAPI.Task; if (task != null) { WriteObject(new XenRef <XenAPI.Task>(task)); return; } XenAPI.Event evt = XenObject as XenAPI.Event; if (evt != null) { WriteObject(new XenRef <XenAPI.Event>(evt)); return; } XenAPI.Pool pool = XenObject as XenAPI.Pool; if (pool != null) { WriteObject(new XenRef <XenAPI.Pool>(pool)); return; } XenAPI.Pool_patch pool_patch = XenObject as XenAPI.Pool_patch; if (pool_patch != null) { WriteObject(new XenRef <XenAPI.Pool_patch>(pool_patch)); return; } XenAPI.Pool_update pool_update = XenObject as XenAPI.Pool_update; if (pool_update != null) { WriteObject(new XenRef <XenAPI.Pool_update>(pool_update)); return; } XenAPI.VM vm = XenObject as XenAPI.VM; if (vm != null) { WriteObject(new XenRef <XenAPI.VM>(vm)); return; } XenAPI.VM_metrics vm_metrics = XenObject as XenAPI.VM_metrics; if (vm_metrics != null) { WriteObject(new XenRef <XenAPI.VM_metrics>(vm_metrics)); return; } XenAPI.VM_guest_metrics vm_guest_metrics = XenObject as XenAPI.VM_guest_metrics; if (vm_guest_metrics != null) { WriteObject(new XenRef <XenAPI.VM_guest_metrics>(vm_guest_metrics)); return; } XenAPI.VMPP vmpp = XenObject as XenAPI.VMPP; if (vmpp != null) { WriteObject(new XenRef <XenAPI.VMPP>(vmpp)); return; } XenAPI.VMSS vmss = XenObject as XenAPI.VMSS; if (vmss != null) { WriteObject(new XenRef <XenAPI.VMSS>(vmss)); return; } XenAPI.VM_appliance vm_appliance = XenObject as XenAPI.VM_appliance; if (vm_appliance != null) { WriteObject(new XenRef <XenAPI.VM_appliance>(vm_appliance)); return; } XenAPI.DR_task dr_task = XenObject as XenAPI.DR_task; if (dr_task != null) { WriteObject(new XenRef <XenAPI.DR_task>(dr_task)); return; } XenAPI.Host host = XenObject as XenAPI.Host; if (host != null) { WriteObject(new XenRef <XenAPI.Host>(host)); return; } XenAPI.Host_crashdump host_crashdump = XenObject as XenAPI.Host_crashdump; if (host_crashdump != null) { WriteObject(new XenRef <XenAPI.Host_crashdump>(host_crashdump)); return; } XenAPI.Host_patch host_patch = XenObject as XenAPI.Host_patch; if (host_patch != null) { WriteObject(new XenRef <XenAPI.Host_patch>(host_patch)); return; } XenAPI.Host_metrics host_metrics = XenObject as XenAPI.Host_metrics; if (host_metrics != null) { WriteObject(new XenRef <XenAPI.Host_metrics>(host_metrics)); return; } XenAPI.Host_cpu host_cpu = XenObject as XenAPI.Host_cpu; if (host_cpu != null) { WriteObject(new XenRef <XenAPI.Host_cpu>(host_cpu)); return; } XenAPI.Network network = XenObject as XenAPI.Network; if (network != null) { WriteObject(new XenRef <XenAPI.Network>(network)); return; } XenAPI.VIF vif = XenObject as XenAPI.VIF; if (vif != null) { WriteObject(new XenRef <XenAPI.VIF>(vif)); return; } XenAPI.VIF_metrics vif_metrics = XenObject as XenAPI.VIF_metrics; if (vif_metrics != null) { WriteObject(new XenRef <XenAPI.VIF_metrics>(vif_metrics)); return; } XenAPI.PIF pif = XenObject as XenAPI.PIF; if (pif != null) { WriteObject(new XenRef <XenAPI.PIF>(pif)); return; } XenAPI.PIF_metrics pif_metrics = XenObject as XenAPI.PIF_metrics; if (pif_metrics != null) { WriteObject(new XenRef <XenAPI.PIF_metrics>(pif_metrics)); return; } XenAPI.Bond bond = XenObject as XenAPI.Bond; if (bond != null) { WriteObject(new XenRef <XenAPI.Bond>(bond)); return; } XenAPI.VLAN vlan = XenObject as XenAPI.VLAN; if (vlan != null) { WriteObject(new XenRef <XenAPI.VLAN>(vlan)); return; } XenAPI.SM sm = XenObject as XenAPI.SM; if (sm != null) { WriteObject(new XenRef <XenAPI.SM>(sm)); return; } XenAPI.SR sr = XenObject as XenAPI.SR; if (sr != null) { WriteObject(new XenRef <XenAPI.SR>(sr)); return; } XenAPI.LVHD lvhd = XenObject as XenAPI.LVHD; if (lvhd != null) { WriteObject(new XenRef <XenAPI.LVHD>(lvhd)); return; } XenAPI.VDI vdi = XenObject as XenAPI.VDI; if (vdi != null) { WriteObject(new XenRef <XenAPI.VDI>(vdi)); return; } XenAPI.VBD vbd = XenObject as XenAPI.VBD; if (vbd != null) { WriteObject(new XenRef <XenAPI.VBD>(vbd)); return; } XenAPI.VBD_metrics vbd_metrics = XenObject as XenAPI.VBD_metrics; if (vbd_metrics != null) { WriteObject(new XenRef <XenAPI.VBD_metrics>(vbd_metrics)); return; } XenAPI.PBD pbd = XenObject as XenAPI.PBD; if (pbd != null) { WriteObject(new XenRef <XenAPI.PBD>(pbd)); return; } XenAPI.Crashdump crashdump = XenObject as XenAPI.Crashdump; if (crashdump != null) { WriteObject(new XenRef <XenAPI.Crashdump>(crashdump)); return; } XenAPI.VTPM vtpm = XenObject as XenAPI.VTPM; if (vtpm != null) { WriteObject(new XenRef <XenAPI.VTPM>(vtpm)); return; } XenAPI.Console console = XenObject as XenAPI.Console; if (console != null) { WriteObject(new XenRef <XenAPI.Console>(console)); return; } XenAPI.User user = XenObject as XenAPI.User; if (user != null) { WriteObject(new XenRef <XenAPI.User>(user)); return; } XenAPI.Data_source data_source = XenObject as XenAPI.Data_source; if (data_source != null) { WriteObject(new XenRef <XenAPI.Data_source>(data_source)); return; } XenAPI.Blob blob = XenObject as XenAPI.Blob; if (blob != null) { WriteObject(new XenRef <XenAPI.Blob>(blob)); return; } XenAPI.Message message = XenObject as XenAPI.Message; if (message != null) { WriteObject(new XenRef <XenAPI.Message>(message)); return; } XenAPI.Secret secret = XenObject as XenAPI.Secret; if (secret != null) { WriteObject(new XenRef <XenAPI.Secret>(secret)); return; } XenAPI.Tunnel tunnel = XenObject as XenAPI.Tunnel; if (tunnel != null) { WriteObject(new XenRef <XenAPI.Tunnel>(tunnel)); return; } XenAPI.PCI pci = XenObject as XenAPI.PCI; if (pci != null) { WriteObject(new XenRef <XenAPI.PCI>(pci)); return; } XenAPI.PGPU pgpu = XenObject as XenAPI.PGPU; if (pgpu != null) { WriteObject(new XenRef <XenAPI.PGPU>(pgpu)); return; } XenAPI.GPU_group gpu_group = XenObject as XenAPI.GPU_group; if (gpu_group != null) { WriteObject(new XenRef <XenAPI.GPU_group>(gpu_group)); return; } XenAPI.VGPU vgpu = XenObject as XenAPI.VGPU; if (vgpu != null) { WriteObject(new XenRef <XenAPI.VGPU>(vgpu)); return; } XenAPI.VGPU_type vgpu_type = XenObject as XenAPI.VGPU_type; if (vgpu_type != null) { WriteObject(new XenRef <XenAPI.VGPU_type>(vgpu_type)); return; } XenAPI.PVS_site pvs_site = XenObject as XenAPI.PVS_site; if (pvs_site != null) { WriteObject(new XenRef <XenAPI.PVS_site>(pvs_site)); return; } XenAPI.PVS_server pvs_server = XenObject as XenAPI.PVS_server; if (pvs_server != null) { WriteObject(new XenRef <XenAPI.PVS_server>(pvs_server)); return; } XenAPI.PVS_proxy pvs_proxy = XenObject as XenAPI.PVS_proxy; if (pvs_proxy != null) { WriteObject(new XenRef <XenAPI.PVS_proxy>(pvs_proxy)); return; } XenAPI.PVS_cache_storage pvs_cache_storage = XenObject as XenAPI.PVS_cache_storage; if (pvs_cache_storage != null) { WriteObject(new XenRef <XenAPI.PVS_cache_storage>(pvs_cache_storage)); return; } XenAPI.Feature feature = XenObject as XenAPI.Feature; if (feature != null) { WriteObject(new XenRef <XenAPI.Feature>(feature)); return; } XenAPI.SDN_controller sdn_controller = XenObject as XenAPI.SDN_controller; if (sdn_controller != null) { WriteObject(new XenRef <XenAPI.SDN_controller>(sdn_controller)); return; } XenAPI.Vdi_nbd_server_info vdi_nbd_server_info = XenObject as XenAPI.Vdi_nbd_server_info; if (vdi_nbd_server_info != null) { WriteObject(new XenRef <XenAPI.Vdi_nbd_server_info>(vdi_nbd_server_info)); return; } XenAPI.PUSB pusb = XenObject as XenAPI.PUSB; if (pusb != null) { WriteObject(new XenRef <XenAPI.PUSB>(pusb)); return; } XenAPI.USB_group usb_group = XenObject as XenAPI.USB_group; if (usb_group != null) { WriteObject(new XenRef <XenAPI.USB_group>(usb_group)); return; } XenAPI.VUSB vusb = XenObject as XenAPI.VUSB; if (vusb != null) { WriteObject(new XenRef <XenAPI.VUSB>(vusb)); return; } }
public LicenseDataStruct(XenAPI.Host host) { Edition = host.edition; ExpiryDate = host.license_params.ContainsKey("expiry") ? host.license_params["expiry"] : ""; }
/// <summary> /// scan each ip address (from the guest agent) for an open port /// </summary> /// <param name="port"></param> public String PollPort(int port, bool vnc) { try { if (Source == null) { return(null); } VM vm = Source; XenRef <VM_guest_metrics> guestMetricsRef = vm.guest_metrics; if (guestMetricsRef == null || Helper.IsNullOrEmptyOpaqueRef(guestMetricsRef.opaque_ref)) { return(null); } VM_guest_metrics metrics = vm.Connection.Resolve(guestMetricsRef); if (metrics == null) { return(null); } Dictionary <string, string> networks = metrics.networks; if (networks == null) { return(null); } List <string> ipAddresses = new List <string>(); List <string> ipv6Addresses = new List <string>(); foreach (VIF vif in vm.Connection.ResolveAll(vm.VIFs)) { XenAPI.Network network = vif.Connection.Resolve(vif.network); XenAPI.Host host = vm.Connection.Resolve(vm.resident_on); XenAPI.PIF pif = Helpers.FindPIF(network, host); if (pif != null && pif.LinkStatus == PIF.LinkState.Connected) { foreach (var networkInfo in networks.Where(n => n.Key.StartsWith(String.Format("{0}/ip", vif.device)))) { if (networkInfo.Key.EndsWith("ip")) // IPv4 address { ipAddresses.Add(networkInfo.Value); } else { if (networkInfo.Key.Contains("ipv6")) // IPv6 address, enclose in square brackets { ipv6Addresses.Add(String.Format("[{0}]", networkInfo.Value)); } else { continue; } } } } } ipAddresses.AddRange(ipv6Addresses); // make sure IPv4 addresses are scanned first (CA-102755) foreach (String ipAddress in ipAddresses) { try { Log.DebugFormat("Poll port {0}:{1}", ipAddress, port); Stream s = connectGuest(ipAddress, port, vm.Connection); if (vnc) { Log.DebugFormat("Connected. Set Pending Vnc connection {0}:{1}", ipAddress, port); SetPendingVNCConnection(s); } else { s.Close(); } return(ipAddress); } catch (Exception exn) { Log.Debug(exn); } } } catch (WebException) { // xapi has gone away. } catch (IOException) { // xapi has gone away. } catch (Failure exn) { if (exn.ErrorDescription[0] == Failure.HANDLE_INVALID) { // HANDLE_INVALID is fine -- the guest metrics are not there yet. } else if (exn.ErrorDescription[0] == Failure.SESSION_INVALID) { // SESSION_INVALID is fine -- these will expire from time to time. // We need to invalidate the session though. lock (activeSessionLock) { activeSession = null; } } else { Log.Warn("Exception while polling VM for port " + port + ".", exn); } } catch (Exception e) { Log.Warn("Exception while polling VM for port " + port + ".", e); } return(null); }