Example #1
0
 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 (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);
 }
Example #2
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;
        }