Beispiel #1
0
        // If success, use the next argument as the result;
        // if !success, use all the subsequent arguments as the error_info.
        public string CreateTask(TaskStatus status, params string[] result)
        {
            Proxy_Task task = new Proxy_Task();

            task.uuid             = String.Format("task{0}", rand.Next());
            task.name_label       = task.uuid;
            task.name_description = "";
            task.created          = DateTime.Now;
            task.status           = status.ToString();

            if (status != TaskStatus.pending)
            {
                task.finished = DateTime.Now;
                task.progress = 100.0;

                if (status == TaskStatus.success)
                {
                    task.result = result[0];
                }
                else
                {
                    task.error_info = result;
                }
            }

            tasks.Add(task.uuid, task);
            return(task.uuid);
        }
        public object Invoke(string proxyMethodName, string returnType, params object[] args)
        {
            if (proxyMethodName == "Url")
            {
                return(null);
            }
            ProxyMethodInfo pmi    = SimpleProxyMethodParser.ParseTypeAndNameOnly(proxyMethodName);
            string          method = pmi.TypeName + "." + pmi.MethodName;

            if (proxyMethodName == "task_get_record")
            {
                Proxy_Task task = new Proxy_Task()
                {
                    progress = 100, status = XenAPI.task_status_type.success.ToString(), result = ""
                };
                return(new Response <Proxy_Task>(task));
            }

            if (proxyMethodName == "host_call_plugin" && args != null && args.Length > 2 && "trim".Equals(args[2]))
            {
                return(new Response <string>("True"));
            }
            ;

            if (pmi.MethodName == "add_to_other_config" || pmi.MethodName == "remove_from_other_config")  // these calls are special because they can have per-key permissions
            {
                rbacMethods.Add(method, (string)args[2]);
            }
            else
            {
                rbacMethods.Add(method);
            }

            return(ResponseByType(returnType));
        }
Beispiel #3
0
        private void PoolPatchUpload(Dictionary <string, string> query)
        {
            string           task_ref   = query["task_id"];
            string           session_id = query["session_id"];
            Proxy_Task       task       = simProxy.proxy.GetTask(task_ref);
            Proxy_Pool_patch patch      = new Proxy_Pool_patch();

            patch.after_apply_guidance = new string[] { "unknown" };
            patch.name_label           = "fake-patch";
            patch.name_description     = "";
            patch.size    = "0";
            patch.uuid    = Guid.NewGuid().ToString();
            patch.version = "1.0";

            task.result   = new fakePool_Patch(simProxy.proxy).create(session_id, patch).Value;
            task.finished = DateTime.Now;
            task.status   = "success";
        }
Beispiel #4
0
        internal void UpdateFromProxy(Proxy_Task proxy)
        {
            uuid               = proxy.uuid == null ? null : (string)proxy.uuid;
            name_label         = proxy.name_label == null ? null : (string)proxy.name_label;
            name_description   = proxy.name_description == null ? null : (string)proxy.name_description;
            allowed_operations = proxy.allowed_operations == null ? null : Helper.StringArrayToEnumList <task_allowed_operations>(proxy.allowed_operations);
            current_operations = proxy.current_operations == null ? null : Maps.convert_from_proxy_string_task_allowed_operations(proxy.current_operations);
            created            = proxy.created;
            finished           = proxy.finished;
            status             = proxy.status == null ? (task_status_type)0 : (task_status_type)Helper.EnumParseDefault(typeof(task_status_type), (string)proxy.status);
            resident_on        = proxy.resident_on == null ? null : XenRef <Host> .Create(proxy.resident_on);

            progress     = Convert.ToDouble(proxy.progress);
            type         = proxy.type == null ? null : (string)proxy.type;
            result       = proxy.result == null ? null : (string)proxy.result;
            error_info   = proxy.error_info == null ? new string[] {} : (string [])proxy.error_info;
            other_config = proxy.other_config == null ? null : Maps.convert_from_proxy_string_string(proxy.other_config);
            subtask_of   = proxy.subtask_of == null ? null : XenRef <Task> .Create(proxy.subtask_of);

            subtasks = proxy.subtasks == null ? null : XenRef <Task> .Create(proxy.subtasks);
        }
Beispiel #5
0
        public Proxy_Task ToProxy()
        {
            Proxy_Task result_ = new Proxy_Task();

            result_.uuid               = (uuid != null) ? uuid : "";
            result_.name_label         = (name_label != null) ? name_label : "";
            result_.name_description   = (name_description != null) ? name_description : "";
            result_.allowed_operations = (allowed_operations != null) ? Helper.ObjectListToStringArray(allowed_operations) : new string[] {};
            result_.current_operations = Maps.convert_to_proxy_string_task_allowed_operations(current_operations);
            result_.created            = created;
            result_.finished           = finished;
            result_.status             = task_status_type_helper.ToString(status);
            result_.resident_on        = (resident_on != null) ? resident_on : "";
            result_.progress           = progress;
            result_.type               = (type != null) ? type : "";
            result_.result             = (result != null) ? result : "";
            result_.error_info         = error_info;
            result_.other_config       = Maps.convert_to_proxy_string_string(other_config);
            result_.subtask_of         = (subtask_of != null) ? subtask_of : "";
            result_.subtasks           = (subtasks != null) ? Helper.RefListToStringArray(subtasks) : new string[] {};
            return(result_);
        }
Beispiel #6
0
        public Proxy_Task ToProxy()
        {
            Proxy_Task result_ = new Proxy_Task();

            result_.uuid               = uuid ?? "";
            result_.name_label         = name_label ?? "";
            result_.name_description   = name_description ?? "";
            result_.allowed_operations = allowed_operations == null ? new string[] {} : Helper.ObjectListToStringArray(allowed_operations);
            result_.current_operations = Maps.convert_to_proxy_string_task_allowed_operations(current_operations);
            result_.created            = created;
            result_.finished           = finished;
            result_.status             = task_status_type_helper.ToString(status);
            result_.resident_on        = resident_on ?? "";
            result_.progress           = progress;
            result_.type               = type ?? "";
            result_.result             = result ?? "";
            result_.error_info         = error_info;
            result_.other_config       = Maps.convert_to_proxy_string_string(other_config);
            result_.subtask_of         = subtask_of ?? "";
            result_.subtasks           = subtasks == null ? new string[] {} : Helper.RefListToStringArray(subtasks);
            result_.backtrace          = backtrace ?? "";
            return(result_);
        }
Beispiel #7
0
 /// <summary>
 /// Creates a new Task from a Proxy_Task.
 /// </summary>
 /// <param name="proxy"></param>
 public Task(Proxy_Task proxy)
 {
     this.UpdateFromProxy(proxy);
 }
Beispiel #8
0
 /// <summary>
 /// Creates a new Task from a Proxy_Task.
 /// </summary>
 /// <param name="proxy"></param>
 public Task(Proxy_Task proxy)
 {
     UpdateFrom(proxy);
 }
Beispiel #9
0
        public Response <double> get_progress(string session, string opaque_ref)
        {
            Proxy_Task task = proxy.GetTask(opaque_ref);

            return(new Response <double>(task.progress));
        }