changeset 40:d3055f6c6fb7

debug
author AnaTofuZ <anatofuz@gmail.com>
date Sun, 22 Nov 2020 15:57:31 +0900
parents f667f3a4bbee
children 63e77a9de3ab
files src/command.rs src/virsh.rs
diffstat 2 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/command.rs	Sun Nov 22 15:47:37 2020 +0900
+++ b/src/command.rs	Sun Nov 22 15:57:31 2020 +0900
@@ -33,6 +33,7 @@
 
 pub fn define_from_template(user: &user::User, vm_name: &str, template: &str) {
     let vm_name = generate_vm_name(&user.name, &vm_name);
+    println!("{}", vm_name);
     let template_path = match virsh::get_template_path(template) {
         Some(path) => path,
         None => {
@@ -43,9 +44,11 @@
     let builder = xml::Builder::new(&user.name, &vm_name)
         .backing(&template_path)
         .finalize();
-    if let Ok(xml_path) = builder.generate() {
-        virsh::command_require_vm_name(&xml_path, "define")
-    }
+    let xml_path = match builder.generate() {
+        Ok(xml_path) => xml_path, 
+        Err(e) => { println!("{}", e); return;}
+    };
+    virsh::command_require_vm_name(&xml_path, "define")
 }
 
 pub fn start(user_name: &str, vm_name: &str) {
--- a/src/virsh.rs	Sun Nov 22 15:47:37 2020 +0900
+++ b/src/virsh.rs	Sun Nov 22 15:57:31 2020 +0900
@@ -5,6 +5,7 @@
 use std::path::Path;
 
 const TEMPLATE_DIR: &str = "/ie-ryukyu/kvm/images/templates/";
+const RENTAL_DIR : &str = "/ie-ryukyu/kvm/images/rental/";
 const TEMPLATE_SUFFIX: &str = "template-";
 const TEMPLATE_FILE_EXTENSION: &str = ".qcow2";
 const QCOW2: &str = "qcow2";
@@ -70,8 +71,8 @@
 
 pub fn generate_qemu_from_template(vm_name: &str, template_path: &str) {
     let vm_path = format!(
-        "{}{}{}{}",
-        TEMPLATE_DIR, TEMPLATE_SUFFIX, &vm_name, TEMPLATE_FILE_EXTENSION
+        "{}{}{}",
+        RENTAL_DIR, &vm_name, TEMPLATE_FILE_EXTENSION
     );
     //$qemu-img create -F qcow2 -b ibm-master.qcow2 -f qcow2 ibm-02.qcow2
     let output = Command::new("qemu-img")