From f1ee01cffa06b222d3fe529a1195fe42c1bca0df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Tue, 26 Feb 2013 13:03:40 +0100 Subject: [PATCH] Feature #1556: Move all the attributes used in the code to the internal template --- include/VirtualMachine.h | 6 ++++++ src/vm/VirtualMachine.cc | 43 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/include/VirtualMachine.h b/include/VirtualMachine.h index 99d4eca0a6..0c80ea48a9 100644 --- a/include/VirtualMachine.h +++ b/include/VirtualMachine.h @@ -1192,6 +1192,12 @@ private: */ void parse_graphics(); + /** + * Searches the meaningful attributes and moves them from the user template + * to the internal template + */ + void parse_well_known_attributes(); + /** * Function that renders the VM in XML format optinally including * extended information (all history records) diff --git a/src/vm/VirtualMachine.cc b/src/vm/VirtualMachine.cc index a1d1692214..7ea7d9576c 100644 --- a/src/vm/VirtualMachine.cc +++ b/src/vm/VirtualMachine.cc @@ -392,6 +392,8 @@ int VirtualMachine::insert(SqlDB * db, string& error_str) parse_graphics(); + parse_well_known_attributes(); + // ------------------------------------------------------------------------ // Insert the VM // ------------------------------------------------------------------------ @@ -866,6 +868,47 @@ error_cleanup: /* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */ +void VirtualMachine::parse_well_known_attributes() +{ + /* + * List of meaningful attributes, used in other places and expected in + * obj_template: + * + * DISK + * NIC + * VCPU + * MEMORY + * CPU + * CONTEXT + * OS + * GRAPHICS + * + * INPUT + * FEATURES + * RAW + */ + + vector v_attr; + vector::iterator it; + + string names[] = {"INPUT", "FEATURES", "RAW"}; + + for (int i=0; i<3; i++) + { + v_attr.clear(); + + user_obj_template->remove(names[i], v_attr); + + for (it=v_attr.begin(); it != v_attr.end(); it++) + { + obj_template->set(*it); + } + } +} + +/* ------------------------------------------------------------------------ */ +/* ------------------------------------------------------------------------ */ + static int check_and_set_cluster_id(const char * id_name, VectorAttribute * vatt, string& cluster_id)