Ejemplo n.º 1
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();
        }
        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);
                }
            });
        }
        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);
                }
            });
        }
        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();
        }
Ejemplo n.º 5
0
        protected void GetSession()
        {
            sessions = CommonCmdletFunctions.GetAllSessions(this);

            if (sessions.Count == 0)
            {
                ThrowTerminatingError(new ErrorRecord(
                                          new Exception("Could not find open sessions to any XenServers."),
                                          "",
                                          ErrorCategory.InvalidArgument, null));
            }

            session = null;

            if (string.IsNullOrEmpty(SessionOpaqueRef))
            {
                if (sessions.Count == 1)
                {
                    foreach (KeyValuePair <string, Session> kvp in sessions)
                    {
                        session = kvp.Value;
                    }
                }
                else
                {
                    Session defaultSession = CommonCmdletFunctions.GetDefaultXenSession(this);

                    if (sessions.ContainsValue(defaultSession))
                    {
                        session = defaultSession;
                    }

                    if (session == null)
                    {
                        ThrowTerminatingError(new ErrorRecord(
                                                  new Exception("A default XenServer session has not beeen set."),
                                                  "",
                                                  ErrorCategory.InvalidArgument, null));
                    }
                }
            }
            else
            {
                if (sessions.ContainsKey(SessionOpaqueRef))
                {
                    session = sessions[SessionOpaqueRef];
                }

                if (session == null)
                {
                    ThrowTerminatingError(new ErrorRecord(
                                              new Exception("Could not locate the specified session in the open XenServer sessions."),
                                              "",
                                              ErrorCategory.InvalidArgument, SessionOpaqueRef));
                }
            }
        }
        private void ProcessRecordStatus(string tunnel)
        {
            RunApiCall(() =>
            {
                var dict = XenAPI.Tunnel.get_status(session, tunnel);

                Hashtable ht = CommonCmdletFunctions.ConvertDictionaryToHashtable(dict);
                WriteObject(ht, true);
            });
        }
Ejemplo n.º 7
0
        private void ProcessRecordSubjectInformationFromIdentifier(string auth)
        {
            RunApiCall(() =>
                       { var contxt = _context as XenAuthPropertySubjectInformationFromIdentifierDynamicParameters;

                         var dict = XenAPI.Auth.get_subject_information_from_identifier(session, contxt.SubjectIdentifier);

                         Hashtable ht = CommonCmdletFunctions.ConvertDictionaryToHashtable(dict);
                         WriteObject(ht, true); });
        }
        private void ProcessRecordGuestAgentConfig(string pool)
        {
            RunApiCall(() =>
            {
                var dict = XenAPI.Pool.get_guest_agent_config(session, pool);

                Hashtable ht = CommonCmdletFunctions.ConvertDictionaryToHashtable(dict);
                WriteObject(ht, true);
            });
        }
Ejemplo n.º 9
0
        private void ProcessRecordSupportedVGPUMaxCapacities(string pgpu)
        {
            RunApiCall(() =>
            {
                var dict = XenAPI.PGPU.get_supported_VGPU_max_capacities(session, pgpu);

                Hashtable ht = CommonCmdletFunctions.ConvertDictionaryToHashtable(dict);
                WriteObject(ht, true);
            });
        }
        private void ProcessRecordCompatibilityMetadata(string vgpu)
        {
            RunApiCall(() =>
            {
                var dict = XenAPI.VGPU.get_compatibility_metadata(session, vgpu);

                Hashtable ht = CommonCmdletFunctions.ConvertDictionaryToHashtable(dict);
                WriteObject(ht, true);
            });
        }
Ejemplo n.º 11
0
        private void ProcessRecordAlarmConfig(string vmpp)
        {
            RunApiCall(() =>
            {
                var dict = XenAPI.VMPP.get_alarm_config(session, vmpp);

                Hashtable ht = CommonCmdletFunctions.ConvertDictionaryToHashtable(dict);
                WriteObject(ht, true);
            });
        }
        private void ProcessRecordXenstoreData(string vdi)
        {
            RunApiCall(() =>
            {
                var dict = XenAPI.VDI.get_xenstore_data(session, vdi);

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

                         var dict = XenAPI.Message.get_since(session, contxt.Since);

                         Hashtable ht = CommonCmdletFunctions.ConvertDictionaryToHashtable(dict);
                         WriteObject(ht, true); });
        }
        private void ProcessRecordRuntimeProperties(string vif)
        {
            RunApiCall(() =>
            {
                var dict = XenAPI.VIF.get_runtime_properties(session, vif);

                Hashtable ht = CommonCmdletFunctions.ConvertDictionaryToHashtable(dict);
                WriteObject(ht, true);
            });
        }
        private void ProcessRecordQosAlgorithmParams(string vif)
        {
            RunApiCall(() =>
            {
                var dict = XenAPI.VIF.get_qos_algorithm_params(session, vif);

                Hashtable ht = CommonCmdletFunctions.ConvertDictionaryToHashtable(dict);
                WriteObject(ht, true);
            });
        }
        private void ProcessRecordOtherConfig(string vm_guest_metrics)
        {
            RunApiCall(() =>
            {
                var dict = XenAPI.VM_guest_metrics.get_other_config(session, vm_guest_metrics);

                Hashtable ht = CommonCmdletFunctions.ConvertDictionaryToHashtable(dict);
                WriteObject(ht, true);
            });
        }
Ejemplo n.º 17
0
        private void ProcessRecordVCPUsFlags(string vm_metrics)
        {
            RunApiCall(() =>
            {
                var dict = XenAPI.VM_metrics.get_VCPUs_flags(session, vm_metrics);

                Hashtable ht = CommonCmdletFunctions.ConvertDictionaryToHashtable(dict);
                WriteObject(ht, true);
            });
        }
        private void ProcessRecordConfiguration(string sm)
        {
            RunApiCall(() =>
            {
                var dict = XenAPI.SM.get_configuration(session, sm);

                Hashtable ht = CommonCmdletFunctions.ConvertDictionaryToHashtable(dict);
                WriteObject(ht, true);
            });
        }
        private void ProcessRecordDeviceConfig(string pbd)
        {
            RunApiCall(() =>
            {
                var dict = XenAPI.PBD.get_device_config(session, pbd);

                Hashtable ht = CommonCmdletFunctions.ConvertDictionaryToHashtable(dict);
                WriteObject(ht, true);
            });
        }
        private void ProcessRecordChipsetInfo(string host)
        {
            RunApiCall(() =>
            {
                var dict = XenAPI.Host.get_chipset_info(session, host);

                Hashtable ht = CommonCmdletFunctions.ConvertDictionaryToHashtable(dict);
                WriteObject(ht, true);
            });
        }
        private void ProcessRecordCurrentOperations(string task)
        {
            RunApiCall(() =>
            {
                var dict = XenAPI.Task.get_current_operations(session, task);

                Hashtable ht = CommonCmdletFunctions.ConvertDictionaryToHashtable(dict);
                WriteObject(ht, true);
            });
        }
        private void ProcessRecordLicenseServer(string host)
        {
            RunApiCall(() =>
            {
                var dict = XenAPI.Host.get_license_server(session, host);

                Hashtable ht = CommonCmdletFunctions.ConvertDictionaryToHashtable(dict);
                WriteObject(ht, true);
            });
        }
Ejemplo n.º 23
0
        private void ProcessRecordBackupSchedule(string vmpp)
        {
            RunApiCall(() =>
            {
                var dict = XenAPI.VMPP.get_backup_schedule(session, vmpp);

                Hashtable ht = CommonCmdletFunctions.ConvertDictionaryToHashtable(dict);
                WriteObject(ht, true);
            });
        }
        private void ProcessRecordExternalAuthConfiguration(string host)
        {
            RunApiCall(() =>
            {
                var dict = XenAPI.Host.get_external_auth_configuration(session, host);

                Hashtable ht = CommonCmdletFunctions.ConvertDictionaryToHashtable(dict);
                WriteObject(ht, true);
            });
        }
        private void ProcessRecordHealthCheckConfig(string pool)
        {
            RunApiCall(() =>
            {
                var dict = XenAPI.Pool.get_health_check_config(session, pool);

                Hashtable ht = CommonCmdletFunctions.ConvertDictionaryToHashtable(dict);
                WriteObject(ht, true);
            });
        }
        private void ProcessRecordAssignedIps(string network)
        {
            RunApiCall(() =>
            {
                var dict = XenAPI.Network.get_assigned_ips(session, network);

                Hashtable ht = CommonCmdletFunctions.ConvertDictionaryToHashtable(dict);
                WriteObject(ht, true);
            });
        }
        private void ProcessRecordCpuInfo(string pool)
        {
            RunApiCall(() =>
            {
                var dict = XenAPI.Pool.get_cpu_info(session, pool);

                Hashtable ht = CommonCmdletFunctions.ConvertDictionaryToHashtable(dict);
                WriteObject(ht, true);
            });
        }
        private void ProcessRecordProperties(string bond)
        {
            RunApiCall(() =>
            {
                var dict = XenAPI.Bond.get_properties(session, bond);

                Hashtable ht = CommonCmdletFunctions.ConvertDictionaryToHashtable(dict);
                WriteObject(ht, true);
            });
        }
        private void ProcessRecordOtherConfig(string host_cpu)
        {
            RunApiCall(() =>
            {
                var dict = XenAPI.Host_cpu.get_other_config(session, host_cpu);

                Hashtable ht = CommonCmdletFunctions.ConvertDictionaryToHashtable(dict);
                WriteObject(ht, true);
            });
        }
        private void ProcessRecordBlobs(string sr)
        {
            RunApiCall(() =>
            {
                var dict = XenAPI.SR.get_blobs(session, sr);

                Hashtable ht = CommonCmdletFunctions.ConvertDictionaryToHashtable(dict);
                WriteObject(ht, true);
            });
        }