google-code-prettify

星期二, 1月 09, 2018

【XenServer】用指令 (Command) 開機 (vm-start)、關機 (vm-shutdown)、建立快照 (vm-snapshot)、快照列表 (snapshot-list)、還原快照 (snapshot-revert)、刪除快照 (snapshot-uninstall)

口白:
流動的水沒有形狀,漂流的風找不到蹤跡,任何案件的 Coding 都取決於心
唯一看透真相的是,外表看似卜朧共,智慧卻低於常人的 名卜朧共 刻爛
(謎之音:把 Code 刻到爛簡稱刻爛.爛..爛...)
Music:
#表升半音 []表高八度
4 3 2 6 4 2 3 #6 6 5 4 5 4 5 6 4 3 2 5 4 3 4 2 6 4 5 [2] [1] #6 6 5 6
4 3 2 6 4 2 3 #6 6 5 4 5 4 5 6 4 3 2 4 3 2 4 2 6 4 5 [2] #6 6 5 6
口白:
刻爛:真実はいつも一つ!

環境:
Citrix XenServer 7.1

指令列表:
指令:xe help --all

[root@xenserver3 ~]# xe help --all
Usage: xe  [-s server] [-pw passwd] [-p port] [-u user] [-pwf password-file]
  [command specific arguments]

To get help on a specific command: xe help 

Full command list
-----------------
    host-all-editions, host-apply-edition, host-backup
    host-bugreport-upload, host-call-plugin, host-compute-free-memory
    host-compute-memory-overhead, host-cpu-info, host-cpu-list
    host-cpu-param-get, host-cpu-param-list, host-crashdump-destroy
    host-crashdump-list, host-crashdump-param-get, host-crashdump-param-list
    host-crashdump-upload, host-data-source-forget, host-data-source-list
    host-data-source-query, host-data-source-record, host-declare-dead
    host-disable, host-disable-display, host-disable-local-storage-caching
    host-dmesg, host-emergency-ha-disable
    host-emergency-management-reconfigure, host-enable, host-enable-display
    host-enable-local-storage-caching, host-evacuate, host-forget
    host-get-cpu-features, host-get-server-certificate
    host-get-sm-diagnostics, host-get-system-status
    host-get-system-status-capabilities, host-get-thread-diagnostics
    host-get-vms-which-prevent-evacuation, host-is-in-emergency-mode
    host-license-add, host-license-remove, host-license-view, host-list
    host-logs-download, host-management-disable, host-management-reconfigure
    host-param-add, host-param-clear, host-param-get, host-param-list
    host-param-remove, host-param-set, host-power-on, host-reboot
    host-restore, host-send-debug-keys, host-set-hostname-live
    host-set-power-on-mode, host-shutdown, host-shutdown-agent
    host-sm-dp-destroy, host-sync-data, host-syslog-reconfigure
    
    vm-assert-can-be-recovered, vm-call-plugin, vm-cd-add, vm-cd-eject
    vm-cd-insert, vm-cd-list, vm-cd-remove, vm-checkpoint, vm-clone
    vm-compute-maximum-memory, vm-compute-memory-overhead, vm-copy
    vm-copy-bios-strings, vm-crashdump-list, vm-data-source-forget
    vm-data-source-list, vm-data-source-query, vm-data-source-record
    vm-destroy, vm-disk-add, vm-disk-list, vm-disk-remove, vm-export
    vm-import, vm-install, vm-is-bios-customized, vm-list
    vm-memory-dynamic-range-set, vm-memory-limits-set, vm-memory-set
    vm-memory-shadow-multiplier-set, vm-memory-static-range-set
    vm-memory-target-set, vm-migrate, vm-param-add, vm-param-clear
    vm-param-get, vm-param-list, vm-param-remove, vm-param-set, vm-pause
    vm-reboot, vm-recover, vm-reset-powerstate, vm-resume
    vm-retrieve-wlb-recommendations, vm-shutdown, vm-snapshot
    vm-snapshot-with-quiesce, vm-start, vm-suspend, vm-uninstall, vm-unpause
    vm-vcpu-hotplug, vm-vif-list
    
    appliance-assert-can-be-recovered, appliance-create, appliance-destroy
    appliance-list, appliance-param-clear, appliance-param-get
    appliance-param-list, appliance-param-set, appliance-recover
    appliance-shutdown, appliance-start, audit-log-get, bond-create
    bond-destroy, bond-list, bond-param-clear, bond-param-get
    bond-param-list, bond-param-set, bond-set-mode, cd-list, console
    console-list, console-param-add, console-param-clear, console-param-get
    console-param-list, console-param-remove, console-param-set
    diagnostic-compact, diagnostic-db-log, diagnostic-db-stats
    diagnostic-gc-stats, diagnostic-license-status, diagnostic-net-stats
    diagnostic-timing-stats, diagnostic-vdi-status, diagnostic-vm-status
    drtask-create, drtask-destroy, drtask-list, drtask-param-get
    drtask-param-list, event-wait, gpu-group-create, gpu-group-destroy
    gpu-group-get-remaining-capacity, gpu-group-list, gpu-group-param-add
    gpu-group-param-clear, gpu-group-param-get, gpu-group-param-list
    gpu-group-param-remove, gpu-group-param-set, log-get, log-get-keys
    log-reopen, log-set-output, lvhd-enable-thin-provisioning
    message-create, message-destroy, message-list, message-param-get
    message-param-list, network-create, network-destroy, network-list
    network-param-add, network-param-clear, network-param-get
    network-param-list, network-param-remove, network-param-set, patch-apply
    patch-clean, patch-destroy, patch-list, patch-param-clear
    patch-param-get, patch-param-list, patch-pool-apply, patch-pool-clean
    patch-precheck, patch-upload, pbd-create, pbd-destroy, pbd-list
    pbd-param-add, pbd-param-clear, pbd-param-get, pbd-param-list
    pbd-param-remove, pbd-param-set, pbd-plug, pbd-unplug
    pgpu-disable-dom0-access, pgpu-enable-dom0-access, pgpu-list
    pgpu-param-add, pgpu-param-clear, pgpu-param-get, pgpu-param-list
    pgpu-param-remove, pgpu-param-set, pif-forget, pif-introduce, pif-list
    pif-param-add, pif-param-clear, pif-param-get, pif-param-list
    pif-param-remove, pif-param-set, pif-plug, pif-reconfigure-ip
    pif-reconfigure-ipv6, pif-scan, pif-set-primary-address-type, pif-unplug
    pool-apply-edition, pool-certificate-install, pool-certificate-list
    pool-certificate-sync, pool-certificate-uninstall, pool-crl-install
    pool-crl-list, pool-crl-uninstall, pool-deconfigure-wlb
    pool-designate-new-master, pool-disable-external-auth
    pool-disable-local-storage-caching, pool-disable-redo-log
    pool-disable-ssl-legacy, pool-dump-database, pool-eject
    pool-emergency-reset-master, pool-emergency-transition-to-master
    pool-enable-external-auth, pool-enable-local-storage-caching
    pool-enable-redo-log, pool-enable-ssl-legacy
    pool-ha-compute-hypothetical-max-host-failures-to-tolerate
    pool-ha-compute-max-host-failures-to-tolerate, pool-ha-disable
    pool-ha-enable, pool-initialize-wlb, pool-join, pool-list
    pool-param-add, pool-param-clear, pool-param-get, pool-param-list
    pool-param-remove, pool-param-set, pool-recover-slaves
    pool-restore-database, pool-retrieve-wlb-configuration
    pool-retrieve-wlb-diagnostics, pool-retrieve-wlb-recommendations
    pool-retrieve-wlb-report, pool-send-test-post
    pool-send-wlb-configuration, pool-sync-database, pool-vlan-create
    pvs-cache-storage-create, pvs-cache-storage-destroy
    pvs-cache-storage-list, pvs-cache-storage-param-get
    pvs-cache-storage-param-list, pvs-proxy-create, pvs-proxy-destroy
    pvs-proxy-list, pvs-proxy-param-get, pvs-proxy-param-list
    pvs-server-forget, pvs-server-introduce, pvs-server-list
    pvs-server-param-clear, pvs-server-param-get, pvs-server-param-list
    pvs-site-forget, pvs-site-introduce, pvs-site-list, pvs-site-param-clear
    pvs-site-param-get, pvs-site-param-list, pvs-site-param-set, role-list
    role-param-get, role-param-list, secret-create, secret-destroy
    secret-list, secret-param-clear, secret-param-get, secret-param-list
    secret-param-set, session-subject-identifier-list
    session-subject-identifier-logout, session-subject-identifier-logout-all
    sm-list, sm-param-clear, sm-param-get, sm-param-list, snapshot-clone
    snapshot-copy, snapshot-destroy, snapshot-disk-list
    snapshot-export-to-template, snapshot-list, snapshot-param-add
    snapshot-param-clear, snapshot-param-get, snapshot-param-list
    snapshot-param-remove, snapshot-param-set, snapshot-reset-powerstate
    snapshot-revert, snapshot-uninstall, sr-create, sr-data-source-forget
    sr-data-source-list, sr-data-source-query, sr-data-source-record
    sr-destroy, sr-disable-database-replication
    sr-enable-database-replication, sr-forget, sr-introduce, sr-list
    sr-param-add, sr-param-clear, sr-param-get, sr-param-list
    sr-param-remove, sr-param-set, sr-probe, sr-scan, sr-update, subject-add
    subject-list, subject-param-clear, subject-param-get, subject-param-list
    subject-remove, subject-role-add, subject-role-remove, task-cancel
    task-list, task-param-add, task-param-clear, task-param-get
    task-param-list, task-param-remove, task-param-set, template-export
    template-list, template-param-add, template-param-clear
    template-param-get, template-param-list, template-param-remove
    template-param-set, template-uninstall, tunnel-create, tunnel-destroy
    tunnel-list, tunnel-param-add, tunnel-param-clear, tunnel-param-get
    tunnel-param-list, tunnel-param-remove, tunnel-param-set, update-apply
    update-destroy, update-introduce, update-list, update-param-clear
    update-param-get, update-param-list, update-pool-apply
    update-pool-clean, update-precheck, update-upload, user-password-change
    vbd-create, vbd-destroy, vbd-eject, vbd-insert, vbd-list, vbd-param-add
    vbd-param-clear, vbd-param-get, vbd-param-list, vbd-param-remove
    vbd-param-set, vbd-plug, vbd-unplug, vdi-clone, vdi-copy, vdi-create
    vdi-destroy, vdi-export, vdi-forget, vdi-import, vdi-introduce, vdi-list
    vdi-param-add, vdi-param-clear, vdi-param-get, vdi-param-list
    vdi-param-remove, vdi-param-set, vdi-pool-migrate, vdi-resize
    vdi-snapshot, vdi-unlock, vdi-update, vgpu-create, vgpu-destroy
    vgpu-list, vgpu-param-add, vgpu-param-clear, vgpu-param-get
    vgpu-param-list, vgpu-param-remove, vgpu-param-set, vgpu-type-list
    vgpu-type-param-get, vgpu-type-param-list, vif-configure-ipv4
    vif-configure-ipv6, vif-create, vif-destroy, vif-list, vif-move
    vif-param-add, vif-param-clear, vif-param-get, vif-param-list
    vif-param-remove, vif-param-set, vif-plug, vif-unplug, vlan-create
    vlan-destroy, vlan-list, vlan-param-get, vlan-param-list

列表:
指令:xe vm-list
[root@xenserver3 ~]# xe vm-list 
uuid ( RO)           : 831797cb-265a-4469-856d-bacef341015d
     name-label ( RW): Control domain on host: xenserver3
    power-state ( RO): running

uuid ( RO)           : 11626c5a-463c-6303-a7c0-7bb51079365e
     name-label ( RW): LinuxMint18.3mate
    power-state ( RO): halted

開機:
指令:xe vm-start uuid=<vm uuid>
[root@xenserver3 ~]# xe vm-start uuid=11626c5a-463c-6303-a7c0-7bb51079365e

關機:
指令:xe vm-shutdown uuid=<vm uuid>
[root@xenserver3 ~]# xe vm-shutdown uuid=11626c5a-463c-6303-a7c0-7bb51079365e

建立快照:
指令:xe vm-snapshot uuid=<vm uuid>
[root@xenserver3 ~]# xe vm-snapshot new-name-label="LinuxMint18.3mate" vm=11626c5a-463c-6303-a7c0-7bb51079365e new-name-description="test Create snapshut"
0f5ef421-8ea6-0043-23c7-6c550066b0d5

快照列表:
指令:xe snapshot-list
[root@xenserver3 ~]# xe snapshot-list
uuid ( RO)                : 0f5ef421-8ea6-0043-23c7-6c550066b0d5
          name-label ( RW): LinuxMint18.3mate
    name-description ( RW): test Create snapshut

uuid ( RO)                : 24da34fe-5234-2dba-ee04-fe15dbbc7d6c
          name-label ( RW): 初始狀態
    name-description ( RW): 

還原快照:
指令:xe snapshot-revert snapshot-uuid=<還原點uuid>
[root@xenserver3 ~]# xe snapshot-revert snapshot-uuid=24da34fe-5234-2dba-ee04-fe15dbbc7d6c

刪除快照:
指令:xe snapshot-uninstall snapshot-uuid=<還原點uuid>
[root@xenserver3 ~]# xe snapshot-uninstall snapshot-uuid=0f5ef421-8ea6-0043-23c7-6c550066b0d5
The following items are about to be destroyed
VM : 0f5ef421-8ea6-0043-23c7-6c550066b0d5 (LinuxMint18.3mate)
VDI: 5c476c47-7643-4deb-a84d-1a81e0de56d0 (LinuxMint18.3mate 0) 
Type 'yes' to continue
yes
All objects destroyed

(謎之音…通通都抄來的…你還有什麼貢獻…)

【參考文獻】
(1) Restore/revert to snapshot
(2) How to take and restore VM snapshot using command line on XenServer
(3) How to export/import VM to/from a backup file using command line on XenServer
(4) Restore XenServer VM snapshots from the CLI / command line