输出格式化
AVCLI 可创建用户友好的命令输出和程序友好的 XML 输出。
用户友好的命令输出
为实现易读性,对 AVCLI 输出进行了格式化。例如:
$ avance -u admin -p admin -H avance –x node-info
node:
-> name : node0
-> id : host:o14
-> state: running
-> sub-state : nil
-> standing-state : maintenance
-> mode : maintenance
-> primary : false
-> manufacturer : Dell
-> model : Dell PowerEdge 2950
-> maintenance-allowed : true
-> maintenance-guest-shutdown : false
-> cpus : 8
-> memory : 4,288,675,840
virtual machines:
node:
-> name : node1
-> id : host:o406
-> state : running
-> sub-state : nil
-> standing-state : warning
-> mode : normal
-> primary : true
-> manufacturer : Dell
-> model : Dell PowerEdge 2950
-> maintenance-allowed : true
-> maintenance-guest-shutdown : true
-> cpus : 8
-> memory : 4,288,675,840
virtual machines:
virtual machine:
-> name : eagles1
-> id : vm:o1836
注意: 这些命令的输出格式在各版本之间可能不同。
程序友好的 XML 输出
您可以通过使用 -x 或 --xml 全局选项创建程序友好的 XML 输出。例如:
$ avcli -u admin -p admin -H localhost -x node-info
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<avance>
<node>
<name>node1</name>
<id>host:o55</id>
<state>running</state>
<sub-state/>
<standing-state>normal</standing-state>
<mode>normal</mode>
<primary>false</primary>
<manufacturer>Intel Corporation</manufacturer>
<model>S5520UR</model>
<maintenance-allowed>true</maintenance-allowed>
<maintenance-guest-shutdown>false</maintenance-guest-shutdown>
<cpus>2</cpus>
<memory>25706889216</memory>
<virtual-machines/>
</node>
<node>
<name>node0</name>
<id>host:o23</id>
<state>running</state>
<sub-state/>
<standing-state>normal</standing-state>
<mode>normal</mode>
<primary>true</primary>
<manufacturer>Intel Corporation</manufacturer>
<model>S5520UR</model>
<maintenance-allowed>true</maintenance-allowed>
<maintenance-guest-shutdown>false</maintenance-guest-shutdown>
<cpus>2</cpus>
<memory>25706889216</memory>
<virtual-machines>
<virtual-machine>
<name>MyVM</name>
<id>vm:o6417</id>
</virtual-machine>
</virtual-machines>
</node>
</avance>
注意: 在各版本之间保留此架构定义。
如果您没有指定 –X 或--XML,则该命令会返回错误,并且显示冗长的消息。例如:
$ cli -H eagles vm-delete eagles23
%Error: Cannot find a resource that matches the identifier eagles23.
com.avance.yak.cli.exceptions.CommandLineException: Cannot find a resource that matches the identifier eagles23.
at com.avance.yak.cli.ResourceDisambiguateServiceProvider.throwNonExistentResource(ResourceDisambiguateServiceProvider.java:56)
at
com.avance.yak.cli.ResourceDisambiguateServiceProvider.getResourceId(ResourceDisambiguateServiceProvider.java:81)
at
com.avance.yak.cli.Command.findResourceId(Command.java:80)
at com.avance.yak.cli.CommandWithUnparsedAmbiguousResourcesInvokeEach.execute(CommandWithUnparsedAmbiguousResourcesInvokeEach.java:65)
at
com.avance.yak.cli.Command.execute(Command.java:194)
at
com.avance.yak.cli.CommandLine.execute(CommandLine.java:649)
at