예제 #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();
        }
예제 #2
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();
        }
        private void ProcessRecordSchedule(string vmss)
        {
            if (!ShouldProcess(vmss, "VMSS.set_schedule"))
            {
                return;
            }

            RunApiCall(() =>
            {
                XenAPI.VMSS.set_schedule(session, vmss, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(Schedule));
            });
        }
예제 #4
0
        private void ProcessRecordGuestVCPUsParams(string host)
        {
            if (!ShouldProcess(host, "Host.set_guest_VCPUs_params"))
            {
                return;
            }

            RunApiCall(() =>
            {
                XenAPI.Host.set_guest_VCPUs_params(session, host, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(GuestVCPUsParams));
            });
        }
예제 #5
0
        private void ProcessRecordOtherConfig(string host_patch)
        {
            if (!ShouldProcess(host_patch, "Host_patch.set_other_config"))
            {
                return;
            }

            RunApiCall(() =>
            {
                XenAPI.Host_patch.set_other_config(session, host_patch, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(OtherConfig));
            });
        }
예제 #6
0
        private void ProcessRecordHealthCheckConfig(string pool)
        {
            if (!ShouldProcess(session.Url, "Pool.set_health_check_config"))
            {
                return;
            }

            RunApiCall(() =>
            {
                XenAPI.Pool.set_health_check_config(session, pool, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(HealthCheckConfig));
            });
        }
예제 #7
0
        private void ProcessRecordSmConfig(string sr)
        {
            if (!ShouldProcess(sr, "SR.set_sm_config"))
            {
                return;
            }

            RunApiCall(() =>
            {
                XenAPI.SR.set_sm_config(session, sr, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(SmConfig));
            });
        }
        private void ProcessRecordOtherConfig(string gpu_group)
        {
            if (!ShouldProcess(gpu_group, "GPU_group.set_other_config"))
            {
                return;
            }

            RunApiCall(() =>
            {
                XenAPI.GPU_group.set_other_config(session, gpu_group, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(OtherConfig));
            });
        }
예제 #9
0
        private void ProcessRecordOtherConfig(string vm_guest_metrics)
        {
            if (!ShouldProcess(vm_guest_metrics, "VM_guest_metrics.set_other_config"))
            {
                return;
            }

            RunApiCall(() =>
            {
                XenAPI.VM_guest_metrics.set_other_config(session, vm_guest_metrics, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(OtherConfig));
            });
        }
예제 #10
0
        private void ProcessRecordLicenseServer(string host)
        {
            if (!ShouldProcess(host, "Host.set_license_server"))
            {
                return;
            }

            RunApiCall(() =>
            {
                XenAPI.Host.set_license_server(session, host, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(LicenseServer));
            });
        }
예제 #11
0
        private void ProcessRecordOtherConfig(string crashdump)
        {
            if (!ShouldProcess(crashdump, "Crashdump.set_other_config"))
            {
                return;
            }

            RunApiCall(() =>
            {
                XenAPI.Crashdump.set_other_config(session, crashdump, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(OtherConfig));
            });
        }
예제 #12
0
        private void ProcessRecordStatus(string tunnel)
        {
            if (!ShouldProcess(tunnel, "Tunnel.set_status"))
            {
                return;
            }

            RunApiCall(() =>
            {
                XenAPI.Tunnel.set_status(session, tunnel, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(Status));
            });
        }
예제 #13
0
        private void ProcessRecordOtherConfig(string tunnel)
        {
            if (!ShouldProcess(tunnel, "Tunnel.set_other_config"))
            {
                return;
            }

            RunApiCall(() =>
            {
                XenAPI.Tunnel.set_other_config(session, tunnel, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(OtherConfig));
            });
        }
예제 #14
0
        private void ProcessRecordAlarmConfig(string vmpp)
        {
            if (!ShouldProcess(vmpp, "VMPP.set_alarm_config"))
            {
                return;
            }

            RunApiCall(() =>
            {
                XenAPI.VMPP.set_alarm_config(session, vmpp, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(AlarmConfig));
            });
        }
        private void ProcessRecordOtherConfig(string pbd)
        {
            if (!ShouldProcess(pbd, "PBD.set_other_config"))
            {
                return;
            }

            RunApiCall(() =>
            {
                XenAPI.PBD.set_other_config(session, pbd, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(OtherConfig));
            });
        }
예제 #16
0
        private void ProcessRecordArchiveSchedule(string vmpp)
        {
            if (!ShouldProcess(vmpp, "VMPP.set_archive_schedule"))
            {
                return;
            }

            RunApiCall(() =>
            {
                XenAPI.VMPP.set_archive_schedule(session, vmpp, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(ArchiveSchedule));
            });
        }
예제 #17
0
        private void ProcessRecordOtherConfig(string network)
        {
            if (!ShouldProcess(network, "Network.set_other_config"))
            {
                return;
            }

            RunApiCall(() =>
            {
                XenAPI.Network.set_other_config(session, network, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(OtherConfig));
            });
        }
        private void ProcessRecordXenstoreData(string vdi)
        {
            if (!ShouldProcess(vdi, "VDI.set_xenstore_data"))
            {
                return;
            }

            RunApiCall(() =>
            {
                XenAPI.VDI.set_xenstore_data(session, vdi, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(XenstoreData));
            });
        }
        private void ProcessRecordQosAlgorithmParams(string vbd)
        {
            if (!ShouldProcess(vbd, "VBD.set_qos_algorithm_params"))
            {
                return;
            }

            RunApiCall(() =>
            {
                XenAPI.VBD.set_qos_algorithm_params(session, vbd, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(QosAlgorithmParams));
            });
        }
예제 #20
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);
                    }
                }
            });
        }
        private void ProcessRecordDeviceConfig(string pbd)
        {
            if (!ShouldProcess(pbd, "PBD.set_device_config"))
            {
                return;
            }

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

                if (contxt != null && contxt.Async)
                {
                    taskRef = XenAPI.PBD.async_set_device_config(session, pbd, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(DeviceConfig));
                }
                else
                {
                    XenAPI.PBD.set_device_config(session, pbd, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(DeviceConfig));
                }
            });
        }
예제 #22
0
        private void ProcessRecordPowerOnMode(string host)
        {
            if (!ShouldProcess(host, "Host.set_power_on_mode"))
            {
                return;
            }

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

                if (contxt != null && contxt.Async)
                {
                    taskRef = XenAPI.Host.async_set_power_on_mode(session, host, PowerOnMode.Key, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(PowerOnMode.Value));
                }
                else
                {
                    XenAPI.Host.set_power_on_mode(session, host, PowerOnMode.Key, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(PowerOnMode.Value));
                }
            });
        }
        private void ProcessRecordProbe(string sr)
        {
            if (!ShouldProcess(sr, "SR.probe"))
            {
                return;
            }

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

                if (contxt != null && contxt.Async)
                {
                    taskRef = XenAPI.SR.async_probe(session, contxt.XenHost, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(contxt.DeviceConfig), contxt.Type, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(contxt.SmConfig));

                    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 obj = XenAPI.SR.probe(session, contxt.XenHost, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(contxt.DeviceConfig), contxt.Type, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(contxt.SmConfig));

                    if (PassThru)
                    {
                        WriteObject(obj, true);
                    }
                }
            });
        }
예제 #24
0
        protected override void ProcessRecord()
        {
            GetSession();
            if (Record != null)
            {
                VM          = Record.VM;
                USBGroup    = Record.USB_group;
                OtherConfig = CommonCmdletFunctions.ConvertDictionaryToHashtable(Record.other_config);
            }
            else if (HashTable != null)
            {
                VM          = Marshalling.ParseRef <VM>(HashTable, "VM");
                USBGroup    = Marshalling.ParseRef <USB_group>(HashTable, "USB_group");
                OtherConfig = (Marshalling.ParseHashTable(HashTable, "other_config"));
            }
            if (!ShouldProcess(session.Url, "VUSB.create"))
            {
                return;
            }

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

                if (contxt != null && contxt.Async)
                {
                    taskRef = XenAPI.VUSB.async_create(session, VM, USBGroup, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(OtherConfig));

                    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.VUSB.create(session, VM, USBGroup, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(OtherConfig));

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

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

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

            UpdateSessions();
        }
예제 #25
0
        private void ProcessRecordDbIntroduce(string vdi)
        {
            if (!ShouldProcess(vdi, "VDI.db_introduce"))
            {
                return;
            }

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

                if (contxt != null && contxt.Async)
                {
                    taskRef = XenAPI.VDI.async_db_introduce(session, contxt.UuidParam, contxt.NameLabel, contxt.NameDescription, contxt.SR, contxt.Type, contxt.Sharable, contxt.ReadOnly, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(contxt.OtherConfig), contxt.Location, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(contxt.XenstoreData), CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(contxt.SmConfig), contxt.Managed, contxt.VirtualSize, contxt.PhysicalUtilisation, contxt.MetadataOfPool, contxt.IsASnapshot, contxt.SnapshotTime, contxt.SnapshotOf, contxt.CbtEnabled);

                    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.db_introduce(session, contxt.UuidParam, contxt.NameLabel, contxt.NameDescription, contxt.SR, contxt.Type, contxt.Sharable, contxt.ReadOnly, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(contxt.OtherConfig), contxt.Location, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(contxt.XenstoreData), CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(contxt.SmConfig), contxt.Managed, contxt.VirtualSize, contxt.PhysicalUtilisation, contxt.MetadataOfPool, contxt.IsASnapshot, contxt.SnapshotTime, contxt.SnapshotOf, contxt.CbtEnabled);

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

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

                        WriteObject(obj, 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();
        }
        protected override void ProcessRecord()
        {
            GetSession();
            if (Record == null && HashTable == null)
            {
                Record                  = new XenAPI.VDI();
                Record.name_label       = NameLabel;
                Record.name_description = NameDescription;
                Record.SR               = SR == null ? null : new XenRef <XenAPI.SR>(SR.opaque_ref);
                Record.virtual_size     = VirtualSize;
                Record.type             = Type;
                Record.sharable         = Sharable;
                Record.read_only        = ReadOnly;
                Record.other_config     = CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(OtherConfig);
                Record.xenstore_data    = CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(XenstoreData);
                Record.sm_config        = CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(SmConfig);
                Record.tags             = Tags;
            }
            else if (Record == null)
            {
                Record = new XenAPI.VDI(HashTable);
            }

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

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

                if (contxt != null && contxt.Async)
                {
                    taskRef = XenAPI.VDI.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.VDI.create(session, Record);

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

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

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

            UpdateSessions();
        }
예제 #28
0
        protected override void ProcessRecord()
        {
            GetSession();
            if (Record == null && HashTable == null)
            {
                Record                      = new XenAPI.VBD();
                Record.VM                   = VM == null ? null : new XenRef <XenAPI.VM>(VM.opaque_ref);
                Record.VDI                  = VDI == null ? null : new XenRef <XenAPI.VDI>(VDI.opaque_ref);
                Record.userdevice           = Userdevice;
                Record.bootable             = Bootable;
                Record.mode                 = Mode;
                Record.type                 = Type;
                Record.unpluggable          = Unpluggable;
                Record.empty                = Empty;
                Record.other_config         = CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(OtherConfig);
                Record.qos_algorithm_type   = QosAlgorithmType;
                Record.qos_algorithm_params = CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(QosAlgorithmParams);
            }
            else if (Record == null)
            {
                Record = new XenAPI.VBD(HashTable);
            }

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

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

                if (contxt != null && contxt.Async)
                {
                    taskRef = XenAPI.VBD.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.VBD.create(session, Record);

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

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

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

            UpdateSessions();
        }
예제 #29
0
        protected override void ProcessRecord()
        {
            GetSession();
            if (Record != null)
            {
                NameLabel       = Record.name_label;
                NameDescription = Record.name_description;
                PhysicalSize    = Record.physical_size;
                Type            = Record.type;
                ContentType     = Record.content_type;
                Shared          = Record.shared;
                SmConfig        = CommonCmdletFunctions.ConvertDictionaryToHashtable(Record.sm_config);
            }
            else if (HashTable != null)
            {
                NameLabel       = Marshalling.ParseString(HashTable, "name_label");
                NameDescription = Marshalling.ParseString(HashTable, "name_description");
                PhysicalSize    = Marshalling.ParseLong(HashTable, "physical_size");
                Type            = Marshalling.ParseString(HashTable, "type");
                ContentType     = Marshalling.ParseString(HashTable, "content_type");
                Shared          = Marshalling.ParseBool(HashTable, "shared");
                SmConfig        = (Marshalling.ParseHashTable(HashTable, "sm_config"));
            }
            if (!ShouldProcess(session.Url, "SR.create"))
            {
                return;
            }

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

                if (contxt != null && contxt.Async)
                {
                    taskRef = XenAPI.SR.async_create(session, XenHost, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(DeviceConfig), PhysicalSize, NameLabel, NameDescription, Type, ContentType, Shared, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(SmConfig));

                    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.SR.create(session, XenHost, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(DeviceConfig), PhysicalSize, NameLabel, NameDescription, Type, ContentType, Shared, CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(SmConfig));

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

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

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

            UpdateSessions();
        }
예제 #30
0
        protected override void ProcessRecord()
        {
            GetSession();
            if (Record == null && HashTable == null)
            {
                Record                      = new XenAPI.VIF();
                Record.device               = Device;
                Record.network              = Network == null ? null : new XenRef <XenAPI.Network>(Network.opaque_ref);
                Record.VM                   = VM == null ? null : new XenRef <XenAPI.VM>(VM.opaque_ref);
                Record.MAC                  = MAC;
                Record.MTU                  = MTU;
                Record.other_config         = CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(OtherConfig);
                Record.qos_algorithm_type   = QosAlgorithmType;
                Record.qos_algorithm_params = CommonCmdletFunctions.ConvertHashTableToDictionary <string, string>(QosAlgorithmParams);
                Record.locking_mode         = LockingMode;
                Record.ipv4_allowed         = Ipv4Allowed;
                Record.ipv6_allowed         = Ipv6Allowed;
            }
            else if (Record == null)
            {
                Record = new XenAPI.VIF(HashTable);
            }

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

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

                if (contxt != null && contxt.Async)
                {
                    taskRef = XenAPI.VIF.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.VIF.create(session, Record);

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

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

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

            UpdateSessions();
        }