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();
        }
Exemple #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();
        }