protected override void ProcessRecord()
        {
            GetSession();
            if (Record != null)
            {
            }
            else if (HashTable != null)
            {
            }
            if (!ShouldProcess(session.Url, "Task.create"))
            {
                return;
            }

            RunApiCall(() =>
            {
                string objRef = XenAPI.Task.create(session, Label, Description);

                if (PassThru)
                {
                    XenAPI.Task obj = null;

                    if (objRef != "OpaqueRef:NULL")
                    {
                        obj            = XenAPI.Task.get_record(session, objRef);
                        obj.opaque_ref = objRef;
                    }

                    WriteObject(obj, true);
                }
            });

            UpdateSessions();
        }
Example #2
0
        protected override void ProcessRecord()
        {
            GetSession();
            if (Record == null && HashTable == null)
            {
                Record              = new XenAPI.Secret();
                Record.value        = Value;
                Record.other_config = CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(OtherConfig);
            }
            else if (Record == null)
            {
                Record = new XenAPI.Secret(HashTable);
            }

            if (!ShouldProcess(session.Url, "Secret.create"))
            {
                return;
            }

            RunApiCall(() =>
            {
                var contxt = _context as XenServerCmdletDynamicParameters;

                if (contxt != null && contxt.Async)
                {
                    taskRef = XenAPI.Secret.async_create(session, Record);

                    if (PassThru)
                    {
                        XenAPI.Task taskObj = null;
                        if (taskRef != "OpaqueRef:NULL")
                        {
                            taskObj            = XenAPI.Task.get_record(session, taskRef.opaque_ref);
                            taskObj.opaque_ref = taskRef.opaque_ref;
                        }

                        WriteObject(taskObj, true);
                    }
                }
                else
                {
                    string objRef = XenAPI.Secret.create(session, Record);

                    if (PassThru)
                    {
                        XenAPI.Secret obj = null;

                        if (objRef != "OpaqueRef:NULL")
                        {
                            obj            = XenAPI.Secret.get_record(session, objRef);
                            obj.opaque_ref = objRef;
                        }

                        WriteObject(obj, true);
                    }
                }
            });

            UpdateSessions();
        }
Example #3
0
        protected override void ProcessRecord()
        {
            GetSession();

            string host = ParseXenHost();

            if (_otherConfigIsSpecified)
            {
                ProcessRecordOtherConfig(host);
            }
            if (_loggingIsSpecified)
            {
                ProcessRecordLogging(host);
            }
            if (_tagsIsSpecified)
            {
                ProcessRecordTags(host);
            }
            if (_licenseServerIsSpecified)
            {
                ProcessRecordLicenseServer(host);
            }
            if (_guestVCPUsParamsIsSpecified)
            {
                ProcessRecordGuestVCPUsParams(host);
            }

            if (!PassThru)
            {
                return;
            }

            RunApiCall(() =>
            {
                var contxt = _context as XenServerCmdletDynamicParameters;

                if (contxt != null && contxt.Async)
                {
                    XenAPI.Task taskObj = null;
                    if (taskRef != null && taskRef != "OpaqueRef:NULL")
                    {
                        taskObj            = XenAPI.Task.get_record(session, taskRef.opaque_ref);
                        taskObj.opaque_ref = taskRef.opaque_ref;
                    }

                    WriteObject(taskObj, true);
                }
                else
                {
                    var obj = XenAPI.Host.get_record(session, host);
                    if (obj != null)
                    {
                        obj.opaque_ref = host;
                    }
                    WriteObject(obj, true);
                }
            });

            UpdateSessions();
        }
        protected override void ProcessRecord()
        {
            GetSession();
            if (Record == null && HashTable == null)
            {
                Record                  = new XenAPI.VM_appliance();
                Record.name_label       = NameLabel;
                Record.name_description = NameDescription;
            }
            else if (Record == null)
            {
                Record = new XenAPI.VM_appliance(HashTable);
            }

            if (!ShouldProcess(session.Url, "VM_appliance.create"))
            {
                return;
            }

            RunApiCall(() =>
            {
                var contxt = _context as XenServerCmdletDynamicParameters;

                if (contxt != null && contxt.Async)
                {
                    taskRef = XenAPI.VM_appliance.async_create(session, Record);

                    if (PassThru)
                    {
                        XenAPI.Task taskObj = null;
                        if (taskRef != "OpaqueRef:NULL")
                        {
                            taskObj            = XenAPI.Task.get_record(session, taskRef.opaque_ref);
                            taskObj.opaque_ref = taskRef.opaque_ref;
                        }

                        WriteObject(taskObj, true);
                    }
                }
                else
                {
                    string objRef = XenAPI.VM_appliance.create(session, Record);

                    if (PassThru)
                    {
                        XenAPI.VM_appliance obj = null;

                        if (objRef != "OpaqueRef:NULL")
                        {
                            obj            = XenAPI.VM_appliance.get_record(session, objRef);
                            obj.opaque_ref = objRef;
                        }

                        WriteObject(obj, true);
                    }
                }
            });

            UpdateSessions();
        }
        private void ProcessRecordServerCertificate(string host)
        {
            RunApiCall(() =>
            {
                var contxt = _context as XenHostPropertyServerCertificateDynamicParameters;

                if (contxt != null && contxt.Async)
                {
                    taskRef = XenAPI.Host.async_get_server_certificate(session, host);

                    XenAPI.Task taskObj = null;
                    if (taskRef != "OpaqueRef:NULL")
                    {
                        taskObj            = XenAPI.Task.get_record(session, taskRef.opaque_ref);
                        taskObj.opaque_ref = taskRef.opaque_ref;
                    }

                    WriteObject(taskObj, true);
                }
                else
                {
                    string obj = XenAPI.Host.get_server_certificate(session, host);

                    WriteObject(obj, true);
                }
            });
        }
Example #6
0
        private void ProcessRecordRemainingCapacity(string gpu_group)
        {
            RunApiCall(() =>
            {
                var contxt = _context as XenGPUGroupPropertyRemainingCapacityDynamicParameters;

                if (contxt != null && contxt.Async)
                {
                    taskRef = XenAPI.GPU_group.async_get_remaining_capacity(session, gpu_group, contxt.VgpuType);

                    XenAPI.Task taskObj = null;
                    if (taskRef != "OpaqueRef:NULL")
                    {
                        taskObj            = XenAPI.Task.get_record(session, taskRef.opaque_ref);
                        taskObj.opaque_ref = taskRef.opaque_ref;
                    }

                    WriteObject(taskObj, true);
                }
                else
                {
                    long obj = XenAPI.GPU_group.get_remaining_capacity(session, gpu_group, contxt.VgpuType);

                    WriteObject(obj, true);
                }
            });
        }
        protected override void ProcessRecord()
        {
            GetSession();
            if (Record == null && HashTable == null)
            {
                Record         = new XenAPI.VTPM();
                Record.VM      = VM == null ? null : new XenRef <XenAPI.VM>(VM.opaque_ref);
                Record.backend = Backend == null ? null : new XenRef <XenAPI.VM>(Backend.opaque_ref);
            }
            else if (Record == null)
            {
                Record = new XenAPI.VTPM(HashTable);
            }

            if (!ShouldProcess(session.Url, "VTPM.create"))
            {
                return;
            }

            RunApiCall(() =>
            {
                var contxt = _context as XenServerCmdletDynamicParameters;

                if (contxt != null && contxt.Async)
                {
                    taskRef = XenAPI.VTPM.async_create(session, Record);

                    if (PassThru)
                    {
                        XenAPI.Task taskObj = null;
                        if (taskRef != "OpaqueRef:NULL")
                        {
                            taskObj            = XenAPI.Task.get_record(session, taskRef.opaque_ref);
                            taskObj.opaque_ref = taskRef.opaque_ref;
                        }

                        WriteObject(taskObj, true);
                    }
                }
                else
                {
                    string objRef = XenAPI.VTPM.create(session, Record);

                    if (PassThru)
                    {
                        XenAPI.VTPM obj = null;

                        if (objRef != "OpaqueRef:NULL")
                        {
                            obj            = XenAPI.VTPM.get_record(session, objRef);
                            obj.opaque_ref = objRef;
                        }

                        WriteObject(obj, true);
                    }
                }
            });

            UpdateSessions();
        }
        private void ProcessRecordManagementInterface(string host)
        {
            RunApiCall(() =>
            {
                var contxt = _context as XenHostPropertyManagementInterfaceDynamicParameters;

                if (contxt != null && contxt.Async)
                {
                    taskRef = XenAPI.Host.async_get_management_interface(session, host);

                    XenAPI.Task taskObj = null;
                    if (taskRef != "OpaqueRef:NULL")
                    {
                        taskObj            = XenAPI.Task.get_record(session, taskRef.opaque_ref);
                        taskObj.opaque_ref = taskRef.opaque_ref;
                    }

                    WriteObject(taskObj, true);
                }
                else
                {
                    string objRef = XenAPI.Host.get_management_interface(session, host);

                    XenAPI.PIF obj = null;

                    if (objRef != "OpaqueRef:NULL")
                    {
                        obj            = XenAPI.PIF.get_record(session, objRef);
                        obj.opaque_ref = objRef;
                    }

                    WriteObject(obj, true);
                }
            });
        }
        private void ProcessRecordVmsWhichPreventEvacuation(string host)
        {
            RunApiCall(() =>
            {
                var contxt = _context as XenHostPropertyVmsWhichPreventEvacuationDynamicParameters;

                if (contxt != null && contxt.Async)
                {
                    taskRef = XenAPI.Host.async_get_vms_which_prevent_evacuation(session, host);

                    XenAPI.Task taskObj = null;
                    if (taskRef != "OpaqueRef:NULL")
                    {
                        taskObj            = XenAPI.Task.get_record(session, taskRef.opaque_ref);
                        taskObj.opaque_ref = taskRef.opaque_ref;
                    }

                    WriteObject(taskObj, true);
                }
                else
                {
                    var dict = XenAPI.Host.get_vms_which_prevent_evacuation(session, host);

                    Hashtable ht = CommonCmdletFunctions.ConvertDictionaryToHashtable(dict);
                    WriteObject(ht, true);
                }
            });
        }
        private void ProcessRecordLicenseState(string pool)
        {
            RunApiCall(() =>
            {
                var contxt = _context as XenPoolPropertyLicenseStateDynamicParameters;

                if (contxt != null && contxt.Async)
                {
                    taskRef = XenAPI.Pool.async_get_license_state(session, pool);

                    XenAPI.Task taskObj = null;
                    if (taskRef != "OpaqueRef:NULL")
                    {
                        taskObj            = XenAPI.Task.get_record(session, taskRef.opaque_ref);
                        taskObj.opaque_ref = taskRef.opaque_ref;
                    }

                    WriteObject(taskObj, true);
                }
                else
                {
                    var dict = XenAPI.Pool.get_license_state(session, pool);

                    Hashtable ht = CommonCmdletFunctions.ConvertDictionaryToHashtable(dict);
                    WriteObject(ht, true);
                }
            });
        }
Example #11
0
        protected override void ProcessRecord()
        {
            GetSession();

            string pool = ParsePool();

            if (_otherConfigIsSpecified)
            {
                ProcessRecordOtherConfig(pool);
            }
            if (_tagsIsSpecified)
            {
                ProcessRecordTags(pool);
            }
            if (_guiConfigIsSpecified)
            {
                ProcessRecordGuiConfig(pool);
            }
            if (_healthCheckConfigIsSpecified)
            {
                ProcessRecordHealthCheckConfig(pool);
            }
            if (_guestAgentConfigIsSpecified)
            {
                ProcessRecordGuestAgentConfig(pool);
            }

            if (!PassThru)
            {
                return;
            }

            RunApiCall(() =>
            {
                var contxt = _context as XenServerCmdletDynamicParameters;

                if (contxt != null && contxt.Async)
                {
                    XenAPI.Task taskObj = null;
                    if (taskRef != null && taskRef != "OpaqueRef:NULL")
                    {
                        taskObj            = XenAPI.Task.get_record(session, taskRef.opaque_ref);
                        taskObj.opaque_ref = taskRef.opaque_ref;
                    }

                    WriteObject(taskObj, true);
                }
                else
                {
                    var obj = XenAPI.Pool.get_record(session, pool);
                    if (obj != null)
                    {
                        obj.opaque_ref = pool;
                    }
                    WriteObject(obj, true);
                }
            });

            UpdateSessions();
        }
        private void ProcessRecordDestroy(string host_crashdump)
        {
            if (!ShouldProcess(host_crashdump, "Host_crashdump.destroy"))
            {
                return;
            }

            RunApiCall(() =>
            {
                var contxt = _context as XenServerCmdletDynamicParameters;

                if (contxt != null && contxt.Async)
                {
                    taskRef = XenAPI.Host_crashdump.async_destroy(session, host_crashdump);

                    if (PassThru)
                    {
                        XenAPI.Task taskObj = null;
                        if (taskRef != "OpaqueRef:NULL")
                        {
                            taskObj            = XenAPI.Task.get_record(session, taskRef.opaque_ref);
                            taskObj.opaque_ref = taskRef.opaque_ref;
                        }

                        WriteObject(taskObj, true);
                    }
                }
                else
                {
                    XenAPI.Host_crashdump.destroy(session, host_crashdump);
                }
            });
        }
Example #13
0
        protected override void ProcessRecord()
        {
            GetSession();
            if (Record != null)
            {
                TaggedPIF = Record.tagged_PIF;
                Tag       = Record.tag;
            }
            else if (HashTable != null)
            {
                TaggedPIF = Marshalling.ParseRef <PIF>(HashTable, "tagged_PIF");
                Tag       = Marshalling.ParseLong(HashTable, "tag");
            }
            if (!ShouldProcess(session.Url, "VLAN.create"))
            {
                return;
            }

            RunApiCall(() =>
            {
                var contxt = _context as XenServerCmdletDynamicParameters;

                if (contxt != null && contxt.Async)
                {
                    taskRef = XenAPI.VLAN.async_create(session, TaggedPIF, Tag, Network);

                    if (PassThru)
                    {
                        XenAPI.Task taskObj = null;
                        if (taskRef != "OpaqueRef:NULL")
                        {
                            taskObj            = XenAPI.Task.get_record(session, taskRef.opaque_ref);
                            taskObj.opaque_ref = taskRef.opaque_ref;
                        }

                        WriteObject(taskObj, true);
                    }
                }
                else
                {
                    string objRef = XenAPI.VLAN.create(session, TaggedPIF, Tag, Network);

                    if (PassThru)
                    {
                        XenAPI.VLAN obj = null;

                        if (objRef != "OpaqueRef:NULL")
                        {
                            obj            = XenAPI.VLAN.get_record(session, objRef);
                            obj.opaque_ref = objRef;
                        }

                        WriteObject(obj, true);
                    }
                }
            });

            UpdateSessions();
        }
        protected override void ProcessRecord()
        {
            GetSession();
            if (Record != null)
            {
                Mode       = Record.mode;
                Properties = CommonCmdletFunctions.ConvertDictionaryToHashtable(Record.properties);
            }
            else if (HashTable != null)
            {
                Mode       = (bond_mode)CommonCmdletFunctions.EnumParseDefault(typeof(bond_mode), Marshalling.ParseString(HashTable, "mode"));
                Properties = (Marshalling.ParseHashTable(HashTable, "properties"));
            }
            if (!ShouldProcess(session.Url, "Bond.create"))
            {
                return;
            }

            RunApiCall(() =>
            {
                var contxt = _context as XenServerCmdletDynamicParameters;

                if (contxt != null && contxt.Async)
                {
                    taskRef = XenAPI.Bond.async_create(session, Network, Members, MAC, Mode, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(Properties));

                    if (PassThru)
                    {
                        XenAPI.Task taskObj = null;
                        if (taskRef != "OpaqueRef:NULL")
                        {
                            taskObj            = XenAPI.Task.get_record(session, taskRef.opaque_ref);
                            taskObj.opaque_ref = taskRef.opaque_ref;
                        }

                        WriteObject(taskObj, true);
                    }
                }
                else
                {
                    string objRef = XenAPI.Bond.create(session, Network, Members, MAC, Mode, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(Properties));

                    if (PassThru)
                    {
                        XenAPI.Bond obj = null;

                        if (objRef != "OpaqueRef:NULL")
                        {
                            obj            = XenAPI.Bond.get_record(session, objRef);
                            obj.opaque_ref = objRef;
                        }

                        WriteObject(obj, true);
                    }
                }
            });

            UpdateSessions();
        }
Example #15
0
        protected override void ProcessRecord()
        {
            GetSession();
            if (Record != null)
            {
                Site = Record.site;
                VIF  = Record.VIF;
            }
            else if (HashTable != null)
            {
                Site = Marshalling.ParseRef <PVS_site>(HashTable, "site");
                VIF  = Marshalling.ParseRef <VIF>(HashTable, "VIF");
            }
            if (!ShouldProcess(session.Url, "PVS_proxy.create"))
            {
                return;
            }

            RunApiCall(() =>
            {
                var contxt = _context as XenServerCmdletDynamicParameters;

                if (contxt != null && contxt.Async)
                {
                    taskRef = XenAPI.PVS_proxy.async_create(session, Site, VIF);

                    if (PassThru)
                    {
                        XenAPI.Task taskObj = null;
                        if (taskRef != "OpaqueRef:NULL")
                        {
                            taskObj            = XenAPI.Task.get_record(session, taskRef.opaque_ref);
                            taskObj.opaque_ref = taskRef.opaque_ref;
                        }

                        WriteObject(taskObj, true);
                    }
                }
                else
                {
                    string objRef = XenAPI.PVS_proxy.create(session, Site, VIF);

                    if (PassThru)
                    {
                        XenAPI.PVS_proxy obj = null;

                        if (objRef != "OpaqueRef:NULL")
                        {
                            obj            = XenAPI.PVS_proxy.get_record(session, objRef);
                            obj.opaque_ref = objRef;
                        }

                        WriteObject(obj, true);
                    }
                }
            });

            UpdateSessions();
        }
        protected override void ProcessRecord()
        {
            GetSession();

            string vmpp = ParseVMPP();

            if (_backupScheduleIsSpecified)
            {
                ProcessRecordBackupSchedule(vmpp);
            }
            if (_archiveTargetConfigIsSpecified)
            {
                ProcessRecordArchiveTargetConfig(vmpp);
            }
            if (_archiveScheduleIsSpecified)
            {
                ProcessRecordArchiveSchedule(vmpp);
            }
            if (_alarmConfigIsSpecified)
            {
                ProcessRecordAlarmConfig(vmpp);
            }

            if (!PassThru)
            {
                return;
            }

            RunApiCall(() =>
            {
                var contxt = _context as XenServerCmdletDynamicParameters;

                if (contxt != null && contxt.Async)
                {
                    XenAPI.Task taskObj = null;
                    if (taskRef != null && taskRef != "OpaqueRef:NULL")
                    {
                        taskObj            = XenAPI.Task.get_record(session, taskRef.opaque_ref);
                        taskObj.opaque_ref = taskRef.opaque_ref;
                    }

                    WriteObject(taskObj, true);
                }
                else
                {
                    var obj = XenAPI.VMPP.get_record(session, vmpp);
                    if (obj != null)
                    {
                        obj.opaque_ref = vmpp;
                    }
                    WriteObject(obj, true);
                }
            });

            UpdateSessions();
        }
        protected override void ProcessRecord()
        {
            GetSession();

            string gpu_group = ParseGPUGroup();

            if (_nameLabelIsSpecified)
            {
                ProcessRecordNameLabel(gpu_group);
            }
            if (_nameDescriptionIsSpecified)
            {
                ProcessRecordNameDescription(gpu_group);
            }
            if (_otherConfigIsSpecified)
            {
                ProcessRecordOtherConfig(gpu_group);
            }
            if (_allocationAlgorithmIsSpecified)
            {
                ProcessRecordAllocationAlgorithm(gpu_group);
            }

            if (!PassThru)
            {
                return;
            }

            RunApiCall(() =>
            {
                var contxt = _context as XenServerCmdletDynamicParameters;

                if (contxt != null && contxt.Async)
                {
                    XenAPI.Task taskObj = null;
                    if (taskRef != null && taskRef != "OpaqueRef:NULL")
                    {
                        taskObj            = XenAPI.Task.get_record(session, taskRef.opaque_ref);
                        taskObj.opaque_ref = taskRef.opaque_ref;
                    }

                    WriteObject(taskObj, true);
                }
                else
                {
                    var obj = XenAPI.GPU_group.get_record(session, gpu_group);
                    if (obj != null)
                    {
                        obj.opaque_ref = gpu_group;
                    }
                    WriteObject(obj, true);
                }
            });

            UpdateSessions();
        }
Example #18
0
        protected override void ProcessRecord()
        {
            GetSession();

            string pif = ParsePIF();

            if (_otherConfigIsSpecified)
            {
                ProcessRecordOtherConfig(pif);
            }
            if (_disallowUnplugIsSpecified)
            {
                ProcessRecordDisallowUnplug(pif);
            }
            if (_primaryAddressTypeIsSpecified)
            {
                ProcessRecordPrimaryAddressType(pif);
            }
            if (_propertyIsSpecified)
            {
                ProcessRecordProperty(pif);
            }

            if (!PassThru)
            {
                return;
            }

            RunApiCall(() =>
            {
                var contxt = _context as XenServerCmdletDynamicParameters;

                if (contxt != null && contxt.Async)
                {
                    XenAPI.Task taskObj = null;
                    if (taskRef != null && taskRef != "OpaqueRef:NULL")
                    {
                        taskObj            = XenAPI.Task.get_record(session, taskRef.opaque_ref);
                        taskObj.opaque_ref = taskRef.opaque_ref;
                    }

                    WriteObject(taskObj, true);
                }
                else
                {
                    var obj = XenAPI.PIF.get_record(session, pif);
                    if (obj != null)
                    {
                        obj.opaque_ref = pif;
                    }
                    WriteObject(obj, true);
                }
            });

            UpdateSessions();
        }
Example #19
0
        protected override void ProcessRecord()
        {
            GetSession();

            string vif = ParseVIF();

            if (_otherConfigIsSpecified)
            {
                ProcessRecordOtherConfig(vif);
            }
            if (_qosAlgorithmParamsIsSpecified)
            {
                ProcessRecordQosAlgorithmParams(vif);
            }
            if (_ipv4AllowedIsSpecified)
            {
                ProcessRecordIpv4Allowed(vif);
            }
            if (_ipv6AllowedIsSpecified)
            {
                ProcessRecordIpv6Allowed(vif);
            }

            if (!PassThru)
            {
                return;
            }

            RunApiCall(() =>
            {
                var contxt = _context as XenServerCmdletDynamicParameters;

                if (contxt != null && contxt.Async)
                {
                    XenAPI.Task taskObj = null;
                    if (taskRef != null && taskRef != "OpaqueRef:NULL")
                    {
                        taskObj            = XenAPI.Task.get_record(session, taskRef.opaque_ref);
                        taskObj.opaque_ref = taskRef.opaque_ref;
                    }

                    WriteObject(taskObj, true);
                }
                else
                {
                    var obj = XenAPI.VIF.get_record(session, vif);
                    if (obj != null)
                    {
                        obj.opaque_ref = vif;
                    }
                    WriteObject(obj, true);
                }
            });

            UpdateSessions();
        }
        protected override void ProcessRecord()
        {
            GetSession();

            string vdi = ParseVDI();

            if (_otherConfigIsSpecified)
            {
                ProcessRecordOtherConfig(vdi);
            }
            if (_xenstoreDataIsSpecified)
            {
                ProcessRecordXenstoreData(vdi);
            }
            if (_smConfigIsSpecified)
            {
                ProcessRecordSmConfig(vdi);
            }
            if (_tagsIsSpecified)
            {
                ProcessRecordTags(vdi);
            }

            if (!PassThru)
            {
                return;
            }

            RunApiCall(() =>
            {
                var contxt = _context as XenServerCmdletDynamicParameters;

                if (contxt != null && contxt.Async)
                {
                    XenAPI.Task taskObj = null;
                    if (taskRef != null && taskRef != "OpaqueRef:NULL")
                    {
                        taskObj            = XenAPI.Task.get_record(session, taskRef.opaque_ref);
                        taskObj.opaque_ref = taskRef.opaque_ref;
                    }

                    WriteObject(taskObj, true);
                }
                else
                {
                    var obj = XenAPI.VDI.get_record(session, vdi);
                    if (obj != null)
                    {
                        obj.opaque_ref = vdi;
                    }
                    WriteObject(obj, true);
                }
            });

            UpdateSessions();
        }
Example #21
0
        protected override void ProcessRecord()
        {
            GetSession();
            if (Record != null)
            {
            }
            else if (HashTable != null)
            {
            }
            if (!ShouldProcess(session.Url, "DR_task.create"))
            {
                return;
            }

            RunApiCall(() =>
            {
                var contxt = _context as XenServerCmdletDynamicParameters;

                if (contxt != null && contxt.Async)
                {
                    taskRef = XenAPI.DR_task.async_create(session, Type, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(DeviceConfig), Whitelist);

                    if (PassThru)
                    {
                        XenAPI.Task taskObj = null;
                        if (taskRef != "OpaqueRef:NULL")
                        {
                            taskObj            = XenAPI.Task.get_record(session, taskRef.opaque_ref);
                            taskObj.opaque_ref = taskRef.opaque_ref;
                        }

                        WriteObject(taskObj, true);
                    }
                }
                else
                {
                    string objRef = XenAPI.DR_task.create(session, Type, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(DeviceConfig), Whitelist);

                    if (PassThru)
                    {
                        XenAPI.DR_task obj = null;

                        if (objRef != "OpaqueRef:NULL")
                        {
                            obj            = XenAPI.DR_task.get_record(session, objRef);
                            obj.opaque_ref = objRef;
                        }

                        WriteObject(obj, true);
                    }
                }
            });

            UpdateSessions();
        }
Example #22
0
        private void poll()
        {
            try
            {
                XenAPI.Task task = GetTask();
                _action.Tick((int)(task.progress * _scale + _lo),
                             task.Description == "" ? _action.Description : task.Description);
                switch (task.status)
                {
                case XenAPI.task_status_type.failure:
                    log.Warn("Action failed due to API failure:\n" + Environment.StackTrace);
                    throw new XenAPI.Failure(new List <string>(task.error_info));

                case XenAPI.task_status_type.success:
                    taskCompleted  = true;
                    _action.Result = task.result;
                    // Work around CA-6597.
                    if (_action.Result != "")
                    {
                        Match m = Regex.Match(_action.Result, "<value>(.*)</value>");
                        if (m.Success)
                        {
                            _action.Result = m.Groups[1].Value;
                        }
                    }
                    break;

                case XenAPI.task_status_type.cancelled:
                    log.Debug("Action cancelled");
                    throw new CancelledException();

                case XenAPI.task_status_type.cancelling:
                case XenAPI.task_status_type.pending:
                    break;
                }
            }
            catch (XenAPI.Failure exn)
            {
                if (exn.ErrorDescription.Count > 1 &&
                    exn.ErrorDescription[0] == XenAPI.Failure.HANDLE_INVALID &&
                    exn.ErrorDescription[1] == "task")
                {
                    // Task has gone away, which means it's finished.
                    taskCompleted           = true;
                    _action.PercentComplete = (int)(_scale + _lo);
                    _action.Result          = "";
                }
                else
                {
                    throw;
                }
            }
        }
Example #23
0
        protected override void ProcessRecord()
        {
            GetSession();

            string network = ParseNetwork();

            if (_otherConfigIsSpecified)
            {
                ProcessRecordOtherConfig(network);
            }
            if (_tagsIsSpecified)
            {
                ProcessRecordTags(network);
            }
            if (_purposeIsSpecified)
            {
                ProcessRecordPurpose(network);
            }

            if (!PassThru)
            {
                return;
            }

            RunApiCall(() =>
            {
                var contxt = _context as XenServerCmdletDynamicParameters;

                if (contxt != null && contxt.Async)
                {
                    XenAPI.Task taskObj = null;
                    if (taskRef != null && taskRef != "OpaqueRef:NULL")
                    {
                        taskObj            = XenAPI.Task.get_record(session, taskRef.opaque_ref);
                        taskObj.opaque_ref = taskRef.opaque_ref;
                    }

                    WriteObject(taskObj, true);
                }
                else
                {
                    var obj = XenAPI.Network.get_record(session, network);
                    if (obj != null)
                    {
                        obj.opaque_ref = network;
                    }
                    WriteObject(obj, true);
                }
            });

            UpdateSessions();
        }
        protected override void ProcessRecord()
        {
            GetSession();

            string pvs_site = ParsePVSSite();

            if (_nameLabelIsSpecified)
            {
                ProcessRecordNameLabel(pvs_site);
            }
            if (_nameDescriptionIsSpecified)
            {
                ProcessRecordNameDescription(pvs_site);
            }
            if (_pVSUuidIsSpecified)
            {
                ProcessRecordPVSUuid(pvs_site);
            }

            if (!PassThru)
            {
                return;
            }

            RunApiCall(() =>
            {
                var contxt = _context as XenServerCmdletDynamicParameters;

                if (contxt != null && contxt.Async)
                {
                    XenAPI.Task taskObj = null;
                    if (taskRef != null && taskRef != "OpaqueRef:NULL")
                    {
                        taskObj            = XenAPI.Task.get_record(session, taskRef.opaque_ref);
                        taskObj.opaque_ref = taskRef.opaque_ref;
                    }

                    WriteObject(taskObj, true);
                }
                else
                {
                    var obj = XenAPI.PVS_site.get_record(session, pvs_site);
                    if (obj != null)
                    {
                        obj.opaque_ref = pvs_site;
                    }
                    WriteObject(obj, true);
                }
            });

            UpdateSessions();
        }
Example #25
0
        protected override void ProcessRecord()
        {
            GetSession();

            string bond = ParseBond();

            if (_otherConfigIsSpecified)
            {
                ProcessRecordOtherConfig(bond);
            }
            if (_modeIsSpecified)
            {
                ProcessRecordMode(bond);
            }
            if (_propertyIsSpecified)
            {
                ProcessRecordProperty(bond);
            }

            if (!PassThru)
            {
                return;
            }

            RunApiCall(() =>
            {
                var contxt = _context as XenServerCmdletDynamicParameters;

                if (contxt != null && contxt.Async)
                {
                    XenAPI.Task taskObj = null;
                    if (taskRef != null && taskRef != "OpaqueRef:NULL")
                    {
                        taskObj            = XenAPI.Task.get_record(session, taskRef.opaque_ref);
                        taskObj.opaque_ref = taskRef.opaque_ref;
                    }

                    WriteObject(taskObj, true);
                }
                else
                {
                    var obj = XenAPI.Bond.get_record(session, bond);
                    if (obj != null)
                    {
                        obj.opaque_ref = bond;
                    }
                    WriteObject(obj, true);
                }
            });

            UpdateSessions();
        }
        protected override void ProcessRecord()
        {
            GetSession();

            string pgpu = ParsePGPU();

            if (_otherConfigIsSpecified)
            {
                ProcessRecordOtherConfig(pgpu);
            }
            if (_enabledVGPUTypesIsSpecified)
            {
                ProcessRecordEnabledVGPUTypes(pgpu);
            }
            if (_gPUGroupIsSpecified)
            {
                ProcessRecordGPUGroup(pgpu);
            }

            if (!PassThru)
            {
                return;
            }

            RunApiCall(() =>
            {
                var contxt = _context as XenServerCmdletDynamicParameters;

                if (contxt != null && contxt.Async)
                {
                    XenAPI.Task taskObj = null;
                    if (taskRef != null && taskRef != "OpaqueRef:NULL")
                    {
                        taskObj            = XenAPI.Task.get_record(session, taskRef.opaque_ref);
                        taskObj.opaque_ref = taskRef.opaque_ref;
                    }

                    WriteObject(taskObj, true);
                }
                else
                {
                    var obj = XenAPI.PGPU.get_record(session, pgpu);
                    if (obj != null)
                    {
                        obj.opaque_ref = pgpu;
                    }
                    WriteObject(obj, true);
                }
            });

            UpdateSessions();
        }
        protected override void ProcessRecord()
        {
            GetSession();

            string tunnel = ParseTunnel();

            if (_statusIsSpecified)
            {
                ProcessRecordStatus(tunnel);
            }
            if (_otherConfigIsSpecified)
            {
                ProcessRecordOtherConfig(tunnel);
            }

            if (!PassThru)
            {
                return;
            }

            RunApiCall(() =>
            {
                var contxt = _context as XenServerCmdletDynamicParameters;

                if (contxt != null && contxt.Async)
                {
                    XenAPI.Task taskObj = null;
                    if (taskRef != null && taskRef != "OpaqueRef:NULL")
                    {
                        taskObj            = XenAPI.Task.get_record(session, taskRef.opaque_ref);
                        taskObj.opaque_ref = taskRef.opaque_ref;
                    }

                    WriteObject(taskObj, true);
                }
                else
                {
                    var obj = XenAPI.Tunnel.get_record(session, tunnel);
                    if (obj != null)
                    {
                        obj.opaque_ref = tunnel;
                    }
                    WriteObject(obj, true);
                }
            });

            UpdateSessions();
        }
        private void ProcessRecordSubtaskOf(string task)
        {
            RunApiCall(() =>
            {
                string objRef = XenAPI.Task.get_subtask_of(session, task);

                XenAPI.Task obj = null;

                if (objRef != "OpaqueRef:NULL")
                {
                    obj            = XenAPI.Task.get_record(session, objRef);
                    obj.opaque_ref = objRef;
                }

                WriteObject(obj, true);
            });
        }
Example #29
0
        private void ProcessRecordPoolMigrate(string vdi)
        {
            if (!ShouldProcess(vdi, "VDI.pool_migrate"))
            {
                return;
            }

            RunApiCall(() =>
            {
                var contxt = _context as XenVDIActionPoolMigrateDynamicParameters;

                if (contxt != null && contxt.Async)
                {
                    taskRef = XenAPI.VDI.async_pool_migrate(session, vdi, contxt.SR, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(contxt.Options));

                    if (PassThru)
                    {
                        XenAPI.Task taskObj = null;
                        if (taskRef != "OpaqueRef:NULL")
                        {
                            taskObj            = XenAPI.Task.get_record(session, taskRef.opaque_ref);
                            taskObj.opaque_ref = taskRef.opaque_ref;
                        }

                        WriteObject(taskObj, true);
                    }
                }
                else
                {
                    string objRef = XenAPI.VDI.pool_migrate(session, vdi, contxt.SR, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(contxt.Options));

                    if (PassThru)
                    {
                        XenAPI.VDI obj = null;

                        if (objRef != "OpaqueRef:NULL")
                        {
                            obj            = XenAPI.VDI.get_record(session, objRef);
                            obj.opaque_ref = objRef;
                        }

                        WriteObject(obj, true);
                    }
                }
            });
        }
Example #30
0
        private void ProcessRecordOpenDatabase(string vdi)
        {
            if (!ShouldProcess(vdi, "VDI.open_database"))
            {
                return;
            }

            RunApiCall(() =>
            {
                var contxt = _context as XenVDIActionOpenDatabaseDynamicParameters;

                if (contxt != null && contxt.Async)
                {
                    taskRef = XenAPI.VDI.async_open_database(session, vdi);

                    if (PassThru)
                    {
                        XenAPI.Task taskObj = null;
                        if (taskRef != "OpaqueRef:NULL")
                        {
                            taskObj            = XenAPI.Task.get_record(session, taskRef.opaque_ref);
                            taskObj.opaque_ref = taskRef.opaque_ref;
                        }

                        WriteObject(taskObj, true);
                    }
                }
                else
                {
                    string objRef = XenAPI.VDI.open_database(session, vdi);

                    if (PassThru)
                    {
                        XenAPI.Session obj = null;

                        if (objRef != "OpaqueRef:NULL")
                        {
                            obj            = XenAPI.Session.get_record(session, objRef);
                            obj.opaque_ref = objRef;
                        }

                        WriteObject(obj, true);
                    }
                }
            });
        }
 private static void UpdateTask(Task task)
 {
     MatchedTasks[task.opaque_ref].Update(task, false);
 }
 public static void ForceAddTask(Task task)
 {
     TaskCollectionChanged(task, new CollectionChangeEventArgs(CollectionChangeAction.Add, task));
 }
 private static void RemoveUnmatchedTask(Task task)
 {
     // This is one of our tasks, or it's a subtask of something else, or it's one that we
     // just don't care about.  We're going to do no more with it.
     task.PropertyChanged -= Task_PropertyChanged;
     UnmatchedTasks.Remove(task.opaque_ref);
 }
 private static void UpdateAndDeleteTask(Task task)
 {
     task.PropertyChanged -= Task_PropertyChanged;
     MatchedTasks[task.opaque_ref].Update(task, true);
     MatchedTasks.Remove(task.opaque_ref);
 }
 public bool IsSatisfiedBy(Task task)
 {
     return task.status == task_status_type.success;
 }
 public bool IsSatisfiedBy(Task task)
 {
     return (task.AppliesTo != null ||
             task.created + task.Connection.ServerTimeOffset < DateTime.UtcNow - awareClientHeuristic);
 }
 private static void CompletelyForgetTask(Task task)
 {
     task.PropertyChanged -= Task_PropertyChanged;
     if (MatchedTasks.ContainsKey(task.opaque_ref))
     {
         MatchedTasks[task.opaque_ref].Update(task, true);
     }
     UnmatchedTasks.Remove(task.opaque_ref);
     MatchedTasks.Remove(task.opaque_ref);
 }
        private static void CreateMeddlingActionForTask(Task task)
        {
            // If AppliesTo is set, then the client that created this task knows about our scheme for passing
            // info between clients.  We give the client a window (AwareClientHeuristic) to set this field
            // before deciding that it's a non-aware client.  Having decided that it's one of those two cases,
            // we make a MeddlingAction.

            MeddlingAction a = new MeddlingAction(task);
            UnmatchedTasks.Remove(task.opaque_ref);
            MatchedTasks[task.opaque_ref] = a;
        }
 public bool IsSatisfiedBy(Task task)
 {
     return (task.XenCenterUUID == Program.XenCenterUUID ||
             task.Connection.Resolve(task.subtask_of) != null ||
             task.Hidden);
 }
 private static void AddTaskToUnmatchedList(Task task)
 {
     task.PropertyChanged += Task_PropertyChanged;
     UnmatchedTasks.Add(task.opaque_ref);
 }