Beispiel #1
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();
        }
Beispiel #2
0
        protected override void ProcessRecord()
        {
            GetSession();
            if (Record != null)
            {
                Name     = Record.name;
                Priority = Record.priority;
                Cls      = Record.cls;
                ObjUuid  = Record.obj_uuid;
                Body     = Record.body;
            }
            else if (HashTable != null)
            {
                Name     = Marshalling.ParseString(HashTable, "name");
                Priority = Marshalling.ParseLong(HashTable, "priority");
                Cls      = (cls)CommonCmdletFunctions.EnumParseDefault(typeof(cls), Marshalling.ParseString(HashTable, "cls"));
                ObjUuid  = Marshalling.ParseString(HashTable, "obj_uuid");
                Body     = Marshalling.ParseString(HashTable, "body");
            }
            if (!ShouldProcess(session.Url, "Message.create"))
            {
                return;
            }

            RunApiCall(() =>
            {
                string objRef = XenAPI.Message.create(session, Name, Priority, Cls, ObjUuid, Body);

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

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

                    WriteObject(obj, true);
                }
            });

            UpdateSessions();
        }
Beispiel #3
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();
        }