<html><body><div><p dir="ltr">Hi</p>
<p dir="ltr">Didn't do a too deep code review, but from a first glance <br>
You need to add a new VdcActionType that is called BackupInfo, and use that when you call RunAction. </p>
<p dir="ltr">Hope it helps, <br>
Oved</p>
<div class="quote">On Aug 8, 2014 11:11 AM, =?UTF-8?B?5Yqb5rOiIOeOiw==?= <wlbleaboy@126.com> wrote:<br type='attribution'></div><br><div><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; font-size: 14px; font-family: 宋体, sans-serif;"><div style="color: rgb(0, 0, 0);">Hi, everyone:</div><div style="color: rgb(0, 0, 0);"><span class="Apple-tab-span" style="white-space:pre">        </span>I added a button on the Template Tab, in the client side, It’s OK,</div><div style="color: rgb(0, 0, 0);"><img src="cid:871E2E8A-B375-456F-B2CF-9E25AB718A23" type="image/png"></div><div style="color: rgb(0, 0, 0);"><br></div><div style="color: rgb(0, 0, 0);">Added the button’s callback like this:</div><div style="color: rgb(0, 0, 0);">=======================================================================</div><div style="color: rgb(0, 0, 0);"> private void backup()</div><div style="color: rgb(0, 0, 0);"> {</div><div style="color: rgb(0, 0, 0);"> BackupInfoParameters param = new BackupInfoParameters();</div><div style="color: rgb(0, 0, 0);"> Frontend.RunAction(VdcActionType.Unknown, param, new IFrontendActionAsyncCallback() {</div><div style="color: rgb(0, 0, 0);"> @Override</div><div style="color: rgb(0, 0, 0);"> public void executed(FrontendActionAsyncResult result) {</div><div style="color: rgb(0, 0, 0);"><br></div><div style="color: rgb(0, 0, 0);"> }</div><div style="color: rgb(0, 0, 0);"> });</div><div style="color: rgb(0, 0, 0);"> }</div><div style="color: rgb(0, 0, 0);">=======================================================================</div><div style="color: rgb(0, 0, 0);"><br></div><div style="color: rgb(0, 0, 0);">The BackupInfoCommand.java is :</div><div style="color: rgb(0, 0, 0);">=======================================================================</div><div style="color: rgb(0, 0, 0);">package org.ovirt.engine.core.bll;</div><div style="color: rgb(0, 0, 0);"><br></div><div style="color: rgb(0, 0, 0);">import org.ovirt.engine.core.bll.utils.PermissionSubject;</div><div style="color: rgb(0, 0, 0);">import org.ovirt.engine.core.common.action.BackupInfoParameters;</div><div style="color: rgb(0, 0, 0);"><br></div><div style="color: rgb(0, 0, 0);"><br></div><div style="color: rgb(0, 0, 0);">import java.io.IOException;</div><div style="color: rgb(0, 0, 0);">import java.util.Collections;</div><div style="color: rgb(0, 0, 0);">import java.util.List;</div><div style="color: rgb(0, 0, 0);"><br></div><div style="color: rgb(0, 0, 0);">/**</div><div style="color: rgb(0, 0, 0);"> * Created by leaboy on 8/7/14.</div><div style="color: rgb(0, 0, 0);"> */</div><div style="color: rgb(0, 0, 0);">public class BackupInfoCommand <T extends BackupInfoParameters> extends CommandBase<T>{</div><div style="color: rgb(0, 0, 0);"> public BackupInfoCommand(T parameters){</div><div style="color: rgb(0, 0, 0);"> super(parameters);</div><div style="color: rgb(0, 0, 0);"> }</div><div style="color: rgb(0, 0, 0);"><br></div><div style="color: rgb(0, 0, 0);"> @Override</div><div style="color: rgb(0, 0, 0);"> public List<PermissionSubject> getPermissionCheckSubjects() {</div><div style="color: rgb(0, 0, 0);"> return Collections.emptyList();</div><div style="color: rgb(0, 0, 0);"> }</div><div style="color: rgb(0, 0, 0);"><br></div><div style="color: rgb(0, 0, 0);"> @Override</div><div style="color: rgb(0, 0, 0);"> protected boolean canDoAction() {</div><div style="color: rgb(0, 0, 0);"> return true;</div><div style="color: rgb(0, 0, 0);"> }</div><div style="color: rgb(0, 0, 0);"><br></div><div style="color: rgb(0, 0, 0);"><br></div><div style="color: rgb(0, 0, 0);"> @Override</div><div style="color: rgb(0, 0, 0);"> protected void executeCommand() {</div><div style="color: rgb(0, 0, 0);"> int a;</div><div style="color: rgb(0, 0, 0);"> a = 1;</div><div style="color: rgb(0, 0, 0);"> try{</div><div style="color: rgb(0, 0, 0);"> Runtime.getRuntime().exec("touch /tmp/tmp.txt");</div><div style="color: rgb(0, 0, 0);"> }catch (IOException e){</div><div style="color: rgb(0, 0, 0);"> e.printStackTrace();</div><div style="color: rgb(0, 0, 0);"> }</div><div style="color: rgb(0, 0, 0);"><br></div><div style="color: rgb(0, 0, 0);"> }</div><div style="color: rgb(0, 0, 0);">}</div><div style="color: rgb(0, 0, 0);">=======================================================================</div><div style="color: rgb(0, 0, 0);"><br></div><div style="color: rgb(0, 0, 0);">And the BackupInfoParameters.java is:</div><div style="color: rgb(0, 0, 0);">=======================================================================</div><div style="color: rgb(0, 0, 0);">package org.ovirt.engine.core.common.action;</div><div style="color: rgb(0, 0, 0);"><br></div><div style="color: rgb(0, 0, 0);">/**</div><div style="color: rgb(0, 0, 0);"> * Created by leaboy on 8/7/14.</div><div style="color: rgb(0, 0, 0);"> */</div><div style="color: rgb(0, 0, 0);">public class BackupInfoParameters extends VdcActionParametersBase implements java.io.Serializable{</div><div style="color: rgb(0, 0, 0);"> private static final long serialVersionUID = -1363077467684414051L;</div><div style="color: rgb(0, 0, 0);"> private VdcActionType _actionType;</div><div style="color: rgb(0, 0, 0);"><br></div><div style="color: rgb(0, 0, 0);"> //public BackupInfoParameters(){}</div><div style="color: rgb(0, 0, 0);"><br></div><div style="color: rgb(0, 0, 0);"> public BackupInfoParameters(){_actionType = VdcActionType.Unknown;}</div><div style="color: rgb(0, 0, 0);"><br></div><div style="color: rgb(0, 0, 0);"> public VdcActionType getActionType() {</div><div style="color: rgb(0, 0, 0);"> return _actionType;</div><div style="color: rgb(0, 0, 0);"> }</div><div style="color: rgb(0, 0, 0);">}</div><div style="color: rgb(0, 0, 0);">=======================================================================</div><div style="color: rgb(0, 0, 0);"><br></div><div style="color: rgb(0, 0, 0);">Built the code success, but when I clicked the button, got a dialog with the error info:</div><div style="color: rgb(0, 0, 0);"><br></div><div><b><font color="#ff2600">Error while executing action: A Request to the Server failed with the following Status Code: 500</font></b></div><div style="color: rgb(0, 0, 0);"><br></div><div style="color: rgb(0, 0, 0);">I debug it , find the error is raised at :</div><div style="color: rgb(0, 0, 0);"><br></div><div><div style="color: rgb(0, 0, 0);">protected VdcReturnValueBase evaluateCorrelationId(CommandBase<?> commandBase) {</div><div style="color: rgb(0, 0, 0);"> VdcReturnValueBase returnValue = null;</div><div style="color: rgb(0, 0, 0);"><br></div><div style="color: rgb(0, 0, 0);"> // Evaluate and set the correlationId on the parameters, fails on invalid correlation id</div><div> <b> <font color="#ff2600">returnValue = ExecutionHandler.evaluateCorrelationId(commandBase.getParameters());</font></b></div><div style="color: rgb(0, 0, 0);"> if (returnValue != null) {</div><div style="color: rgb(0, 0, 0);"> log.warnFormat("CanDoAction of action {0} failed. Reasons: {1}", commandBase.getActionType(),</div><div style="color: rgb(0, 0, 0);"> StringUtils.join(returnValue.getCanDoActionMessages(), ','));</div><div style="color: rgb(0, 0, 0);"><br></div><div style="color: rgb(0, 0, 0);"> }</div><div style="color: rgb(0, 0, 0);"> // Set the correlation-id on the command</div><div style="color: rgb(0, 0, 0);"> commandBase.setCorrelationId(commandBase.getParameters().getCorrelationId());</div><div style="color: rgb(0, 0, 0);"> return returnValue;</div><div style="color: rgb(0, 0, 0);"> }</div></div></div></body></html>