summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBastian Wissler2009-02-26 17:33:11 +0100
committerBastian Wissler2009-02-26 17:33:11 +0100
commit746d3b79a6ebf6678d050fa1135be02c65f5bfc5 (patch)
tree3126b839ca762a8527aa8311c2e50484f436d9af
parentvmchooser source: (diff)
downloadvmchooser-746d3b79a6ebf6678d050fa1135be02c65f5bfc5.tar.gz
vmchooser-746d3b79a6ebf6678d050fa1135be02c65f5bfc5.tar.xz
vmchooser-746d3b79a6ebf6678d050fa1135be02c65f5bfc5.zip
vmchooser source:
* path to xml file included in node 'image_name' git-svn-id: http://svn.openslx.org/svn/openslx/openslx-src-tools/vmchooser/trunk@2644 95ad53e4-c205-0410-b2fa-d234c58c8868
-rw-r--r--vmchooser/addInfo.cxx52
-rw-r--r--vmchooser/inc/functions.h2
-rw-r--r--vmchooser/readXmlDir.cxx5
-rw-r--r--vmchooser/runImage.cxx2
4 files changed, 54 insertions, 7 deletions
diff --git a/vmchooser/addInfo.cxx b/vmchooser/addInfo.cxx
index 144e061..5d1301d 100644
--- a/vmchooser/addInfo.cxx
+++ b/vmchooser/addInfo.cxx
@@ -5,6 +5,10 @@
#include <pwd.h>
#include <sys/types.h>
+#include "boost/filesystem.hpp"
+
+namespace bfs=boost::filesystem;
+
/******************************************
* Adds user info and hostname to xml
*
@@ -12,7 +16,7 @@
* hostnamenode: <hostname param="host" />
* computername: needed for bootpgm <computername .../>
******************************************/
-void addInfo(xmlNode* node) {
+void addInfo(xmlNode* node, DataEntry* dat) {
if(node == NULL) {
return;
@@ -31,6 +35,7 @@ void addInfo(xmlNode* node) {
xmlNodePtr usernode = NULL;
xmlNodePtr hostnamenode = NULL;
xmlNodePtr compnamenode = NULL;
+ xmlNodePtr filenamenode = NULL;
xmlNodePtr firstchild = node->children;
// just use some standard Linux functions here ...
@@ -103,6 +108,51 @@ void addInfo(xmlNode* node) {
cerr << "<computername> node could not be created!" << endl;
}
+
+
+ // We need to add the filename to the xml
+ cout << "XML file name: " << dat->xml_name << endl;
+ if(dat->xml_name.empty()) return;
+ bfs::path path(dat->xml_name);
+ std::string folder = path.branch_path().string();
+
+ cout << "XML folder name: " << folder << endl;
+
+ if(folder.empty()) return;
+ cur = node->children;
+
+ // Get <hostname> node and add "hostname#param" attribute
+ while(cur != NULL) {
+ if (!xmlStrcmp(cur->name, (const xmlChar *)"image_name")){
+ filenamenode = cur;
+ break;
+ }
+ cur = cur->next;
+ }
+ if(! filenamenode) {
+ //filenamenode = xmlNewNode(NULL, (const xmlChar*) "xmlpath");
+ //if(filenamenode != NULL ) {
+ // xmlNewProp(filenamenode, (const xmlChar*) "param", (const xmlChar*) folder.c_str());
+ // xmlAddChild(node, filenamenode);
+ //}
+ //else {
+ // cerr << "<xmlpath> node could not be created!" << endl;
+ //}
+ cerr << "There is no node called 'image_name'. " << endl;
+ }
+ else {
+ // add param value to existant hostname-nodea
+ xmlChar* bla = xmlGetProp(filenamenode, "param");
+ if(!bla) {
+ cerr << "Could not read Attribute 'param' in 'image_name' node." << endl;
+ return;
+ }
+ else {
+ xmlSetProp(filenamenode, (const xmlChar*) "param", (xmlChar*) folder.append(bla).c_str());
+ }
+ }
+
+
return;
}
diff --git a/vmchooser/inc/functions.h b/vmchooser/inc/functions.h
index afccc9b..1ec76f4 100644
--- a/vmchooser/inc/functions.h
+++ b/vmchooser/inc/functions.h
@@ -27,7 +27,7 @@ char* getFolderName();
/* Adds the elements into xmlNode "printers" (1. argument) */
bool addPrinters(xmlNode* node, char* script);
bool addScanners(xmlNode* node, char* script);
-void addInfo(xmlNode* node); /* This is defined in addPrinters.cxx */
+void addInfo(xmlNode* node, DataEntry* dat); /* This is defined in addPrinters.cxx */
/* Write configuration xml */
string writeConfXml(DataEntry& dat);
diff --git a/vmchooser/readXmlDir.cxx b/vmchooser/readXmlDir.cxx
index 44188d1..68febaa 100644
--- a/vmchooser/readXmlDir.cxx
+++ b/vmchooser/readXmlDir.cxx
@@ -99,10 +99,6 @@ DataEntry* get_entry(xmlDoc * doc)
char *tempc = NULL;
DataEntry* de = new DataEntry();
- if(doc->name != NULL) {
- de->xml_name = string(doc->name);
- }
-
tempc = getAttribute(doc,(char *)"short_description");
if (tempc != NULL ) {
de->short_description = tempc;
@@ -282,6 +278,7 @@ DataEntry** readXmlDir(char* path)
result[c] = get_entry(doc);
if (result[c] != NULL) {
+ result[c]->xml_name = xmlVec[i];
c++;
}
/* xmlDoc still needed to write back information for VMware etc. */
diff --git a/vmchooser/runImage.cxx b/vmchooser/runImage.cxx
index 4b7c3e5..bed42ac 100644
--- a/vmchooser/runImage.cxx
+++ b/vmchooser/runImage.cxx
@@ -162,7 +162,7 @@ string writeConfXml(DataEntry& dat) {
addScanners(root, (char*)pskript.c_str());
// add hostname and username information
- addInfo(root);
+ addInfo(root, &dat);
srand(time(NULL));