diff --git a/NOTICE b/NOTICE
new file mode 100644
index 0000000000..4dab5e63f4
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,18 @@
+OpenNebula Open Source Project
+Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org)
+-----------------------------------------
+
+You can find more information about the project, relase notes and
+documentation at www.OpenNebula.org
+
+AUTHORS
+
+- Ruben Santiago Montero (rubensm@dacya.ucm.es)
+- Ignacio Martín Llorente (llorente@dacya.ucm.es)
+
+ACKNOWLEDGEMENTS
+
+The following people have contributed to the development of the technology
+- Javier Fontán Muiños (jfontan@fdi.ucm.es)
+- Constantino Vázquez Blanco (tinova@fdi.ucm.es)
+- Jaime Melis Bayo (j.melis@fdi.ucm.es)
diff --git a/SConstruct b/SConstruct
index cc6e98a210..8029757457 100644
--- a/SConstruct
+++ b/SConstruct
@@ -1,6 +1,5 @@
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/include/ActionManager.h b/include/ActionManager.h
index d2a66398ff..f93806ac8b 100644
--- a/include/ActionManager.h
+++ b/include/ActionManager.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/Attribute.h b/include/Attribute.h
index 6c6441688b..0cec75e889 100644
--- a/include/Attribute.h
+++ b/include/Attribute.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/DispatchManager.h b/include/DispatchManager.h
index 50c78b4f94..dfb388fd1c 100644
--- a/include/DispatchManager.h
+++ b/include/DispatchManager.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/FixedLeases.h b/include/FixedLeases.h
index ec11ffdfd1..cb5f6e2ec4 100644
--- a/include/FixedLeases.h
+++ b/include/FixedLeases.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/History.h b/include/History.h
index a06936de95..5c42205dcb 100644
--- a/include/History.h
+++ b/include/History.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/Hook.h b/include/Hook.h
index 090688834b..99ed350328 100644
--- a/include/Hook.h
+++ b/include/Hook.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/HookManager.h b/include/HookManager.h
index 773990bbff..453d371dc5 100644
--- a/include/HookManager.h
+++ b/include/HookManager.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/HookManagerDriver.h b/include/HookManagerDriver.h
index 576ce7b8e4..00e46ab7d2 100644
--- a/include/HookManagerDriver.h
+++ b/include/HookManagerDriver.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/Host.h b/include/Host.h
index 0be4b79619..5507cbbb4b 100644
--- a/include/Host.h
+++ b/include/Host.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
@@ -284,7 +283,11 @@ public:
*
*
*/
-
+ int get_share_running_vms()
+ {
+ return host_share.running_vms;
+ }
+
int get_share_disk_usage()
{
return host_share.disk_usage;
diff --git a/include/HostPool.h b/include/HostPool.h
index 98a59b35a7..0bd48f03a6 100644
--- a/include/HostPool.h
+++ b/include/HostPool.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/HostShare.h b/include/HostShare.h
index 0afcefcd6c..55c455b99c 100644
--- a/include/HostShare.h
+++ b/include/HostShare.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/HostTemplate.h b/include/HostTemplate.h
index 0c3bcaa51a..0121ce889d 100644
--- a/include/HostTemplate.h
+++ b/include/HostTemplate.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/InformationManager.h b/include/InformationManager.h
index a38a72d871..f7b12ff5db 100644
--- a/include/InformationManager.h
+++ b/include/InformationManager.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/InformationManagerDriver.h b/include/InformationManagerDriver.h
index 403ba4ad5f..f725a21213 100644
--- a/include/InformationManagerDriver.h
+++ b/include/InformationManagerDriver.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/Leases.h b/include/Leases.h
index 3e5ce7eae1..9e50d571c0 100644
--- a/include/Leases.h
+++ b/include/Leases.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/LibVirtDriver.h b/include/LibVirtDriver.h
index 14a34e2812..814e72b328 100644
--- a/include/LibVirtDriver.h
+++ b/include/LibVirtDriver.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/LifeCycleManager.h b/include/LifeCycleManager.h
index 52c3a13ebd..32e01bf904 100644
--- a/include/LifeCycleManager.h
+++ b/include/LifeCycleManager.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/Log.h b/include/Log.h
index bc127305f6..83f11c1f8b 100644
--- a/include/Log.h
+++ b/include/Log.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/Mad.h b/include/Mad.h
index 7b5b30b02a..ae3c093c9e 100644
--- a/include/Mad.h
+++ b/include/Mad.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/MadManager.h b/include/MadManager.h
index 6574c79b89..6724480006 100644
--- a/include/MadManager.h
+++ b/include/MadManager.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/Nebula.h b/include/Nebula.h
index aa3d43c405..77790f436c 100644
--- a/include/Nebula.h
+++ b/include/Nebula.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
@@ -223,7 +222,7 @@ public:
static string version()
{
- return "OpenNebula 1.3.80";
+ return "OpenNebula 1.5.0";
};
void start();
diff --git a/include/NebulaTemplate.h b/include/NebulaTemplate.h
index 0c7537fcb9..d3b1accc35 100644
--- a/include/NebulaTemplate.h
+++ b/include/NebulaTemplate.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/ObjectSQL.h b/include/ObjectSQL.h
index c70da259c7..2a649374fe 100644
--- a/include/ObjectSQL.h
+++ b/include/ObjectSQL.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/OneClient.h b/include/OneClient.h
index 97e9ec6d4f..32a4262711 100644
--- a/include/OneClient.h
+++ b/include/OneClient.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/PoolObjectSQL.h b/include/PoolObjectSQL.h
index 4ae73da9f6..cf6966d6b7 100644
--- a/include/PoolObjectSQL.h
+++ b/include/PoolObjectSQL.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/PoolSQL.h b/include/PoolSQL.h
index 010dbb9095..83a5163e64 100644
--- a/include/PoolSQL.h
+++ b/include/PoolSQL.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/RangedLeases.h b/include/RangedLeases.h
index e0955a863e..1d79f6af93 100644
--- a/include/RangedLeases.h
+++ b/include/RangedLeases.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/RequestManager.h b/include/RequestManager.h
index fd97e250e9..59835b5a72 100644
--- a/include/RequestManager.h
+++ b/include/RequestManager.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/Scheduler.h b/include/Scheduler.h
index ddfe3ce879..d0e45d1aff 100644
--- a/include/Scheduler.h
+++ b/include/Scheduler.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/SchedulerHost.h b/include/SchedulerHost.h
index 563105ba7b..5d3c548c66 100644
--- a/include/SchedulerHost.h
+++ b/include/SchedulerHost.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/SchedulerPolicy.h b/include/SchedulerPolicy.h
index 80dc522375..09efa5dc7b 100644
--- a/include/SchedulerPolicy.h
+++ b/include/SchedulerPolicy.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
@@ -45,10 +44,10 @@ public:
if(priority.empty()!=true)
{
- sw.max = *max_element(
+ sw.max = fabs(*max_element(
priority.begin(),
priority.end(),
- SchedulerHostPolicy::abs_cmp);
+ SchedulerHostPolicy::abs_cmp));
transform(
priority.begin(),
diff --git a/include/SchedulerVirtualMachine.h b/include/SchedulerVirtualMachine.h
index 4c4002e2d3..674d37f7c7 100644
--- a/include/SchedulerVirtualMachine.h
+++ b/include/SchedulerVirtualMachine.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
@@ -111,10 +110,15 @@ private:
~Host(){};
- bool operator<(const Host& b) { //Sort by priority
+ bool operator<(const Host& b) const { //Sort by priority
return priority < b.priority;
}
};
+
+ static bool host_cmp (const Host * a, const Host * b )
+ {
+ return (*a < *b );
+ };
//--------------------------------------------------------------------------
diff --git a/include/SqliteDB.h b/include/SqliteDB.h
index 00ed3d5f54..79aee3ef2c 100644
--- a/include/SqliteDB.h
+++ b/include/SqliteDB.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/Template.h b/include/Template.h
index 478d222e2f..b8d7030197 100644
--- a/include/Template.h
+++ b/include/Template.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/TemplateSQL.h b/include/TemplateSQL.h
index 94e06f0892..23dd515faa 100644
--- a/include/TemplateSQL.h
+++ b/include/TemplateSQL.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/TransferManager.h b/include/TransferManager.h
index bf81385406..2beee20569 100644
--- a/include/TransferManager.h
+++ b/include/TransferManager.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/TransferManagerDriver.h b/include/TransferManagerDriver.h
index 42f1bf863b..4a4ba38cd0 100644
--- a/include/TransferManagerDriver.h
+++ b/include/TransferManagerDriver.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/User.h b/include/User.h
index 0d0609f0a7..d34440a657 100644
--- a/include/User.h
+++ b/include/User.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/UserPool.h b/include/UserPool.h
index 3916719877..75809e21a7 100644
--- a/include/UserPool.h
+++ b/include/UserPool.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/VirtualMachine.h b/include/VirtualMachine.h
index 850a24e484..7fe2b33577 100644
--- a/include/VirtualMachine.h
+++ b/include/VirtualMachine.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/VirtualMachineHook.h b/include/VirtualMachineHook.h
index 629d5b2178..3a9fcca190 100644
--- a/include/VirtualMachineHook.h
+++ b/include/VirtualMachineHook.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/VirtualMachineManager.h b/include/VirtualMachineManager.h
index 87eb746865..8e41739c29 100644
--- a/include/VirtualMachineManager.h
+++ b/include/VirtualMachineManager.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/VirtualMachineManagerDriver.h b/include/VirtualMachineManagerDriver.h
index c9a2b3b1f2..2b4ef2bd25 100644
--- a/include/VirtualMachineManagerDriver.h
+++ b/include/VirtualMachineManagerDriver.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/VirtualMachinePool.h b/include/VirtualMachinePool.h
index fcded8b6c8..ccbe76350e 100644
--- a/include/VirtualMachinePool.h
+++ b/include/VirtualMachinePool.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/VirtualMachineTemplate.h b/include/VirtualMachineTemplate.h
index 1392a07e42..c661663dd2 100644
--- a/include/VirtualMachineTemplate.h
+++ b/include/VirtualMachineTemplate.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/VirtualNetwork.h b/include/VirtualNetwork.h
index 7aae346946..3317f20b00 100644
--- a/include/VirtualNetwork.h
+++ b/include/VirtualNetwork.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/VirtualNetworkPool.h b/include/VirtualNetworkPool.h
index 31c0113026..433d87b33a 100644
--- a/include/VirtualNetworkPool.h
+++ b/include/VirtualNetworkPool.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/VirtualNetworkTemplate.h b/include/VirtualNetworkTemplate.h
index 92536c49fd..82cb99473d 100644
--- a/include/VirtualNetworkTemplate.h
+++ b/include/VirtualNetworkTemplate.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/XMLDriver.h b/include/XMLDriver.h
index 77c3f87ae8..1242ef3909 100644
--- a/include/XMLDriver.h
+++ b/include/XMLDriver.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/include/XenDriver.h b/include/XenDriver.h
index 266c4269a3..72571138c6 100644
--- a/include/XenDriver.h
+++ b/include/XenDriver.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/install.sh b/install.sh
index f358a38306..40218d6af9 100755
--- a/install.sh
+++ b/install.sh
@@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@@ -30,20 +29,22 @@
usage() {
echo
echo "Usage: install.sh [-u install_user] [-g install_group] [-k keep conf]"
- echo " [-d ONE_LOCATION] [-r] [-h]"
+ echo " [-d ONE_LOCATION] [-c occi|ec2] [-r] [-h]"
echo
echo "-u: user that will run opennebula, defults to user executing install.sh"
echo "-g: group of the user that will run opennebula, defults to user"
echo " executing install.sh"
echo "-k: keep current configuration files, useful when upgrading"
echo "-d: target installation directory, if not defined it'd be root"
+ echo "-c: install only 'occi' or 'ec2' client files"
echo "-r: remove Opennebula, only useful if -d was not specified, otherwise"
echo " rm -rf \$ONE_LOCATION would do the job"
+ echo "-l: creates symlinks instead of copying files, useful for development"
echo "-h: prints this help"
}
#-------------------------------------------------------------------------------
-TEMP_OPT=`getopt -o hkru:g:d: -n 'install.sh' -- "$@"`
+TEMP_OPT=`getopt -o hkrlc:u:g:d: -n 'install.sh' -- "$@"`
if [ $? != 0 ] ; then
usage
@@ -54,6 +55,8 @@ eval set -- "$TEMP_OPT"
INSTALL_ETC="yes"
UNINSTALL="no"
+LINK="no"
+CLIENT="no"
ONEADMIN_USER=`id -u`
ONEADMIN_GROUP=`id -g`
SRC_DIR=$PWD
@@ -63,6 +66,8 @@ while true ; do
-h) usage; exit 0;;
-k) INSTALL_ETC="no" ; shift ;;
-r) UNINSTALL="yes" ; shift ;;
+ -l) LINK="yes" ; shift ;;
+ -c) CLIENT="$2" ; shift 2;;
-u) ONEADMIN_USER="$2" ; shift 2;;
-g) ONEADMIN_GROUP="$2"; shift 2;;
-d) ROOT="$2" ; shift 2 ;;
@@ -71,6 +76,14 @@ while true ; do
esac
done
+if echo "$CLIENT" | egrep -ivq '^(no|occi|ec2)$'; then
+ echo "ERROR: client '$CLIENT' not valid. Use either 'occi' or 'ec2'."
+ usage
+ exit 1
+else
+ CLIENT=`echo $CLIENT | tr [:upper:] [:lower:]`
+fi
+
#-------------------------------------------------------------------------------
# Definition of locations
#-------------------------------------------------------------------------------
@@ -82,17 +95,27 @@ if [ -z "$ROOT" ] ; then
LOG_LOCATION="/var/log/one"
VAR_LOCATION="/var/lib/one"
RUN_LOCATION="/var/run/one"
+ LOCK_LOCATION="/var/lock/one"
INCLUDE_LOCATION="/usr/include"
SHARE_LOCATION="/usr/share/doc/opennebula"
+
+ if [ "$CLIENT" = "no" ]; then
+ MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION $ETC_LOCATION $VAR_LOCATION \
+ $INCLUDE_LOCATION $SHARE_LOCATION \
+ $LOG_LOCATION $RUN_LOCATION $LOCK_LOCATION"
+
+ DELETE_DIRS="$LIB_LOCATION $ETC_LOCATION $LOG_LOCATION $VAR_LOCATION \
+ $RUN_LOCATION $SHARE_DIRS"
- MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION $ETC_LOCATION $VAR_LOCATION \
- $INCLUDE_LOCATION $SHARE_LOCATION \
- $LOG_LOCATION $RUN_LOCATION"
+ CHOWN_DIRS="$LOG_LOCATION $VAR_LOCATION $RUN_LOCATION $LOCK_LOCATION"
+ else
+ MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION"
- DELETE_DIRS="$LIB_LOCATION $ETC_LOCATION $LOG_LOCATION $VAR_LOCATION \
- $RUN_LOCATION $SHARE_DIRS"
+ DELETE_DIRS=""
+
+ CHOWN_DIRS=""
+ fi
- CHOWN_DIRS="$LOG_LOCATION $VAR_LOCATION $RUN_LOCATION"
else
BIN_LOCATION="$ROOT/bin"
LIB_LOCATION="$ROOT/lib"
@@ -101,10 +124,18 @@ else
INCLUDE_LOCATION="$ROOT/include"
SHARE_LOCATION="$ROOT/share"
- MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION $ETC_LOCATION $VAR_LOCATION \
- $INCLUDE_LOCATION $SHARE_LOCATION"
-
- DELETE_DIRS="$MAKE_DIRS"
+ if [ "$CLIENT" = "no" ]; then
+ MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION $ETC_LOCATION $VAR_LOCATION \
+ $INCLUDE_LOCATION $SHARE_LOCATION"
+
+ DELETE_DIRS="$MAKE_DIRS"
+
+ CHOWN_DIRS="$ROOT"
+ else
+ MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION"
+
+ DELETE_DIRS="$MAKE_DIRS"
+ fi
CHOWN_DIRS="$ROOT"
fi
@@ -124,20 +155,41 @@ ETC_DIRS="$ETC_LOCATION/im_kvm \
$ETC_LOCATION/tm_nfs \
$ETC_LOCATION/tm_ssh \
$ETC_LOCATION/tm_dummy \
+ $ETC_LOCATION/tm_lvm \
$ETC_LOCATION/hm \
- $ETC_LOCATION/ec2query_templates"
+ $ETC_LOCATION/ec2query_templates \
+ $ETC_LOCATION/occi_templates"
LIB_DIRS="$LIB_LOCATION/im_probes \
$LIB_LOCATION/ruby \
$LIB_LOCATION/ruby/OpenNebula \
- $LIB_LOCATION/ruby/econe \
+ $LIB_LOCATION/ruby/cloud/ \
+ $LIB_LOCATION/ruby/cloud/econe \
+ $LIB_LOCATION/ruby/cloud/econe/views \
+ $LIB_LOCATION/ruby/cloud/occi \
$LIB_LOCATION/tm_commands \
$LIB_LOCATION/tm_commands/nfs \
$LIB_LOCATION/tm_commands/ssh \
$LIB_LOCATION/tm_commands/dummy \
+ $LIB_LOCATION/tm_commands/lvm \
$LIB_LOCATION/mads"
-MAKE_DIRS="$MAKE_DIRS $SHARE_DIRS $ETC_DIRS $LIB_DIRS"
+LIB_ECO_CLIENT_DIRS="$LIB_LOCATION/ruby \
+ $LIB_LOCATION/ruby/OpenNebula
+ $LIB_LOCATION/ruby/cloud/ \
+ $LIB_LOCATION/ruby/cloud/econe"
+
+LIB_OCCI_CLIENT_DIRS="$LIB_LOCATION/ruby \
+ $LIB_LOCATION/ruby/OpenNebula
+ $LIB_LOCATION/ruby/cloud/occi"
+
+if [ "$CLIENT" = "no" ]; then
+ MAKE_DIRS="$MAKE_DIRS $SHARE_DIRS $ETC_DIRS $LIB_DIRS"
+elif [ "$CLIENT" = "ec2" ]; then
+ MAKE_DIRS="$MAKE_DIRS $LIB_ECO_CLIENT_DIRS"
+elif [ "$CLIENT" = "occi" ]; then
+ MAKE_DIRS="$MAKE_DIRS $LIB_OCCI_CLIENT_DIRS"
+fi
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
@@ -155,11 +207,24 @@ INSTALL_FILES[6]="IM_PROBES_LIB_FILES:$LIB_LOCATION/im_probes"
INSTALL_FILES[7]="NFS_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/nfs"
INSTALL_FILES[8]="SSH_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/ssh"
INSTALL_FILES[9]="DUMMY_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/dummy"
-INSTALL_FILES[10]="EXAMPLE_SHARE_FILES:$SHARE_LOCATION/examples"
-INSTALL_FILES[11]="TM_EXAMPLE_SHARE_FILES:$SHARE_LOCATION/examples/tm"
-INSTALL_FILES[12]="HOOK_SHARE_FILES:$SHARE_LOCATION/hooks"
-INSTALL_FILES[13]="ECO_LIB_FILES:$LIB_LOCATION/ruby/econe"
-INSTALL_FILES[14]="ECO_BIN_FILES:$BIN_LOCATION"
+INSTALL_FILES[10]="LVM_TM_COMMANDS_LIB_FILES:$LIB_LOCATION/tm_commands/lvm"
+INSTALL_FILES[11]="EXAMPLE_SHARE_FILES:$SHARE_LOCATION/examples"
+INSTALL_FILES[12]="TM_EXAMPLE_SHARE_FILES:$SHARE_LOCATION/examples/tm"
+INSTALL_FILES[13]="HOOK_SHARE_FILES:$SHARE_LOCATION/hooks"
+INSTALL_FILES[14]="COMMON_CLOUD_LIB_FILES:$LIB_LOCATION/ruby/cloud"
+INSTALL_FILES[15]="ECO_LIB_FILES:$LIB_LOCATION/ruby/cloud/econe"
+INSTALL_FILES[16]="ECO_LIB_VIEW_FILES:$LIB_LOCATION/ruby/cloud/econe/views"
+INSTALL_FILES[17]="ECO_BIN_FILES:$BIN_LOCATION"
+INSTALL_FILES[18]="OCCI_LIB_FILES:$LIB_LOCATION/ruby/cloud/occi"
+INSTALL_FILES[19]="OCCI_BIN_FILES:$BIN_LOCATION"
+
+INSTALL_ECO_CLIENT_FILES[0]="COMMON_CLOUD_CLIENT_LIB_FILES:$LIB_LOCATION/ruby/cloud"
+INSTALL_ECO_CLIENT_FILES[1]="ECO_LIB_CLIENT_FILES:$LIB_LOCATION/ruby/cloud/econe"
+INSTALL_ECO_CLIENT_FILES[2]="ECO_BIN_CLIENT_FILES:$BIN_LOCATION"
+
+INSTALL_OCCI_CLIENT_FILES[0]="COMMON_CLOUD_CLIENT_LIB_FILES:$LIB_LOCATION/ruby/cloud"
+INSTALL_OCCI_CLIENT_FILES[1]="OCCI_LIB_CLIENT_FILES:$LIB_LOCATION/ruby/cloud/occi"
+INSTALL_OCCI_CLIENT_FILES[2]="OCCI_BIN_CLIENT_FILES:$BIN_LOCATION"
INSTALL_ETC_FILES[0]="ETC_FILES:$ETC_LOCATION"
INSTALL_ETC_FILES[1]="VMM_XEN_ETC_FILES:$ETC_LOCATION/vmm_xen"
@@ -173,9 +238,12 @@ INSTALL_ETC_FILES[8]="IM_EH_ETC_FILES:$ETC_LOCATION/im_eh"
INSTALL_ETC_FILES[9]="TM_NFS_ETC_FILES:$ETC_LOCATION/tm_nfs"
INSTALL_ETC_FILES[10]="TM_SSH_ETC_FILES:$ETC_LOCATION/tm_ssh"
INSTALL_ETC_FILES[11]="TM_DUMMY_ETC_FILES:$ETC_LOCATION/tm_dummy"
-INSTALL_ETC_FILES[12]="HM_ETC_FILES:$ETC_LOCATION/hm"
-INSTALL_ETC_FILES[13]="ECO_ETC_FILES:$ETC_LOCATION"
-INSTALL_ETC_FILES[14]="ECO_TEMPLATE_FILES:$ETC_LOCATION/ec2query_templates"
+INSTALL_ETC_FILES[12]="TM_LVM_ETC_FILES:$ETC_LOCATION/tm_lvm"
+INSTALL_ETC_FILES[13]="HM_ETC_FILES:$ETC_LOCATION/hm"
+INSTALL_ETC_FILES[14]="ECO_ETC_FILES:$ETC_LOCATION"
+INSTALL_ETC_FILES[15]="ECO_ETC_TEMPLATE_FILES:$ETC_LOCATION/ec2query_templates"
+INSTALL_ETC_FILES[16]="OCCI_ETC_FILES:$ETC_LOCATION"
+INSTALL_ETC_FILES[17]="OCCI_ETC_TEMPLATE_FILES:$ETC_LOCATION/occi_templates"
#-------------------------------------------------------------------------------
# Binary files, to be installed under $BIN_LOCATION
@@ -225,12 +293,11 @@ RUBY_OPENNEBULA_LIB_FILES="src/oca/ruby/OpenNebula/Host.rb \
src/oca/ruby/OpenNebula/VirtualNetwork.rb \
src/oca/ruby/OpenNebula/VirtualNetworkPool.rb \
src/oca/ruby/OpenNebula/XMLUtils.rb"
-
#-------------------------------------------------------------------------------
# Driver executable files, to be installed under $LIB_LOCATION/mads
#-------------------------------------------------------------------------------
-MADS_LIB_FILES="share/scripts/madcommon.sh \
+MADS_LIB_FILES="src/mad/sh/madcommon.sh \
src/tm_mad/tm_common.sh \
src/vmm_mad/xen/one_vmm_xen.rb \
src/vmm_mad/xen/one_vmm_xen \
@@ -266,6 +333,7 @@ IM_PROBES_LIB_FILES="src/im_mad/xen/xen.rb \
# - NFS TM, $LIB_LOCATION/tm_commands/nfs
# - SSH TM, $LIB_LOCATION/tm_commands/ssh
# - dummy TM, $LIB_LOCATION/tm_commands/dummy
+# - LVM TM, $LIB_LOCATION/tm_commands/lvm
#-------------------------------------------------------------------------------
NFS_TM_COMMANDS_LIB_FILES="src/tm_mad/nfs/tm_clone.sh \
@@ -286,6 +354,14 @@ SSH_TM_COMMANDS_LIB_FILES="src/tm_mad/ssh/tm_clone.sh \
DUMMY_TM_COMMANDS_LIB_FILES="src/tm_mad/dummy/tm_dummy.sh"
+LVM_TM_COMMANDS_LIB_FILES="src/tm_mad/lvm/tm_clone.sh \
+ src/tm_mad/lvm/tm_delete.sh \
+ src/tm_mad/lvm/tm_ln.sh \
+ src/tm_mad/lvm/tm_mkswap.sh \
+ src/tm_mad/lvm/tm_mkimage.sh \
+ src/tm_mad/lvm/tm_mv.sh \
+ src/tm_mad/lvm/tm_context.sh"
+
#-------------------------------------------------------------------------------
# Configuration files for OpenNebula, to be installed under $ETC_LOCATION
#-------------------------------------------------------------------------------
@@ -337,6 +413,7 @@ IM_EH_ETC_FILES="src/im_mad/eh/im_ehrc \
# - nfs, $ETC_LOCATION/tm_nfs
# - ssh, $ETC_LOCATION/tm_ssh
# - dummy, $ETC_LOCATION/tm_dummy
+# - lvm, $ETC_LOCATION/tm_lvm
#-------------------------------------------------------------------------------
TM_NFS_ETC_FILES="src/tm_mad/nfs/tm_nfs.conf \
@@ -348,6 +425,9 @@ TM_SSH_ETC_FILES="src/tm_mad/ssh/tm_ssh.conf \
TM_DUMMY_ETC_FILES="src/tm_mad/dummy/tm_dummy.conf \
src/tm_mad/dummy/tm_dummyrc"
+TM_LVM_ETC_FILES="src/tm_mad/lvm/tm_lvm.conf \
+ src/tm_mad/lvm/tm_lvmrc"
+
#-------------------------------------------------------------------------------
# Hook Manager driver config. files, to be installed under $ETC_LOCATION/hm
#-------------------------------------------------------------------------------
@@ -378,36 +458,93 @@ TM_EXAMPLE_SHARE_FILES="share/examples/tm/tm_clone.sh \
# HOOK scripts, to be installed under $SHARE_LOCATION/hooks
#-------------------------------------------------------------------------------
-HOOK_SHARE_FILES="share/hooks/ebtables-xen"
+HOOK_SHARE_FILES="share/hooks/ebtables-xen \
+ share/hooks/ebtables-kvm \
+ share/hooks/ebtables-flush"
#-------------------------------------------------------------------------------
-# OCA files
+# Common Cloud Files
#-------------------------------------------------------------------------------
-ECO_LIB_FILES="src/cloud/rm/image.rb \
- src/cloud/rm/repo_manager.rb \
- src/cloud/ec2/OcaConfiguration.rb \
- src/cloud/ec2/eco.rb \
- src/cloud/ec2/lib/EC2QueryClient.rb"
-
-ECO_BIN_FILES="src/cloud/ec2/econe-server \
- src/cloud/ec2/econe-describe-images \
- src/cloud/ec2/econe-describe-instances \
- src/cloud/ec2/econe-register \
- src/cloud/ec2/econe-run-instances \
- src/cloud/ec2/econe-terminate-instances \
- src/cloud/ec2/econe-upload"
-
-ECO_ETC_FILES="src/cloud/ec2/econe.conf"
-
-ECO_TEMPLATE_FILES="src/cloud/ec2/templates/m1.small.erb"
+COMMON_CLOUD_LIB_FILES="src/cloud/common/CloudServer.rb \
+ src/cloud/common/CloudClient.rb \
+ src/cloud/common/Configuration.rb \
+ src/cloud/rm/image.rb \
+ src/cloud/rm/repo_manager.rb"
+COMMON_CLOUD_CLIENT_LIB_FILES="src/cloud/common/CloudClient.rb"
#-------------------------------------------------------------------------------
+# EC2 Query for OpenNebula
#-------------------------------------------------------------------------------
+
+ECO_LIB_FILES="src/cloud/ec2/lib/EC2QueryClient.rb \
+ src/cloud/ec2/lib/EC2QueryServer.rb \
+ src/cloud/ec2/lib/econe-server.rb"
+
+ECO_LIB_CLIENT_FILES="src/cloud/ec2/lib/EC2QueryClient.rb"
+
+ECO_LIB_VIEW_FILES="src/cloud/ec2/lib/views/describe_images.erb \
+ src/cloud/ec2/lib/views/describe_instances.erb \
+ src/cloud/ec2/lib/views/register_image.erb \
+ src/cloud/ec2/lib/views/run_instances.erb \
+ src/cloud/ec2/lib/views/terminate_instances.erb"
+
+ECO_BIN_FILES="src/cloud/ec2/bin/econe-server \
+ src/cloud/ec2/bin/econe-describe-images \
+ src/cloud/ec2/bin/econe-describe-instances \
+ src/cloud/ec2/bin/econe-register \
+ src/cloud/ec2/bin/econe-run-instances \
+ src/cloud/ec2/bin/econe-terminate-instances \
+ src/cloud/ec2/bin/econe-upload"
+
+ECO_BIN_CLIENT_FILES="src/cloud/ec2/bin/econe-describe-images \
+ src/cloud/ec2/bin/econe-describe-instances \
+ src/cloud/ec2/bin/econe-register \
+ src/cloud/ec2/bin/econe-run-instances \
+ src/cloud/ec2/bin/econe-terminate-instances \
+ src/cloud/ec2/bin/econe-upload"
+
+ECO_ETC_FILES="src/cloud/ec2/etc/econe.conf"
+
+ECO_ETC_TEMPLATE_FILES="src/cloud/ec2/etc/templates/m1.small.erb"
+
+#-----------------------------------------------------------------------------
+# OCCI files
+#-----------------------------------------------------------------------------
+
+OCCI_LIB_FILES="src/cloud/occi/lib/OCCIServer.rb \
+ src/cloud/occi/lib/occi-server.rb \
+ src/cloud/occi/lib/OCCIClient.rb \
+ src/cloud/occi/lib/VirtualMachineOCCI.rb \
+ src/cloud/occi/lib/VirtualMachinePoolOCCI.rb \
+ src/cloud/occi/lib/VirtualNetworkOCCI.rb \
+ src/cloud/occi/lib/VirtualNetworkPoolOCCI.rb \
+ src/cloud/occi/lib/ImageOCCI.rb \
+ src/cloud/occi/lib/ImagePoolOCCI.rb"
+
+OCCI_LIB_CLIENT_FILES="src/cloud/occi/lib/OCCIClient.rb"
+
+OCCI_BIN_FILES="src/cloud/occi/bin/occi-server \
+ src/cloud/occi/bin/occi-compute \
+ src/cloud/occi/bin/occi-network \
+ src/cloud/occi/bin/occi-storage"
+
+OCCI_BIN_CLIENT_FILES="src/cloud/occi/bin/occi-compute \
+ src/cloud/occi/bin/occi-network \
+ src/cloud/occi/bin/occi-storage"
+
+OCCI_ETC_FILES="src/cloud/occi/etc/occi-server.conf"
+
+OCCI_ETC_TEMPLATE_FILES="src/cloud/occi/etc/templates/small.erb \
+ src/cloud/occi/etc/templates/medium.erb \
+ src/cloud/occi/etc/templates/large.erb"
+
+#-----------------------------------------------------------------------------
+#-----------------------------------------------------------------------------
# INSTALL.SH SCRIPT
-#-------------------------------------------------------------------------------
-#-------------------------------------------------------------------------------
+#-----------------------------------------------------------------------------
+#-----------------------------------------------------------------------------
# --- Create OpenNebula directories ---
@@ -423,11 +560,24 @@ do_file() {
if [ "$UNINSTALL" = "yes" ]; then
rm $2/`basename $1`
else
- cp $SRC_DIR/$1 $DESTDIR$2
+ if [ "$LINK" = "yes" ]; then
+ ln -s $SRC_DIR/$1 $DESTDIR$2
+ else
+ cp $SRC_DIR/$1 $DESTDIR$2
+ fi
fi
}
-for i in ${INSTALL_FILES[@]}; do
+
+if [ "$CLIENT" = "no" ]; then
+ INSTALL_SET=${INSTALL_FILES[@]}
+elif [ "$CLIENT" = "occi" ]; then
+ INSTALL_SET=${INSTALL_OCCI_CLIENT_FILES[@]}
+elif [ "$CLIENT" = "ec2" ]; then
+ INSTALL_SET=${INSTALL_ECO_CLIENT_FILES[@]}
+fi
+
+for i in ${INSTALL_SET[@]}; do
SRC=$`echo $i | cut -d: -f1`
DST=`echo $i | cut -d: -f2`
@@ -438,16 +588,21 @@ for i in ${INSTALL_FILES[@]}; do
done
done
-if [ "$INSTALL_ETC" = "yes" ] ; then
+if [ "$CLIENT" = "no" -a "$INSTALL_ETC" = "yes" ] ; then
for i in ${INSTALL_ETC_FILES[@]}; do
SRC=$`echo $i | cut -d: -f1`
DST=`echo $i | cut -d: -f2`
- eval SRC_FILES=$SRC
+ eval SRC_FILES=$SRC
+
+ OLD_LINK=$LINK
+ LINK="no"
for f in $SRC_FILES; do
do_file $f $DST
done
+
+ LINK=$OLD_LINK
done
fi
@@ -455,13 +610,15 @@ fi
if [ "$UNINSTALL" = "no" ] ; then
for d in $CHOWN_DIRS; do
- /bin/chown -R $ONEADMIN_USER:$ONEADMIN_GROUP $DESTDIR$d
+ chown -R $ONEADMIN_USER:$ONEADMIN_GROUP $DESTDIR$d
done
# Create library links
- ln -s $DESTDIR$LIB_LOCATION/liboneapi.so \
- $DESTDIR$LIB_LOCATION/liboneapi.so.1
- ln -s $DESTDIR$LIB_LOCATION/liboneapi.so.1 \
- $DESTDIR$LIB_LOCATION/liboneapi.so.1.2
+ if [ "$CLIENT" = "no" ] ; then
+ ln -s $DESTDIR$LIB_LOCATION/liboneapi.so \
+ $DESTDIR$LIB_LOCATION/liboneapi.so.1
+ ln -s $DESTDIR$LIB_LOCATION/liboneapi.so.1 \
+ $DESTDIR$LIB_LOCATION/liboneapi.so.1.4
+ fi
else
for d in `echo $DELETE_DIRS | awk '{for (i=NF;i>=1;i--) printf $i" "}'`; do
rmdir $d
diff --git a/share/etc/defaultrc b/share/etc/defaultrc
index 178521b3cb..5a70989d55 100644
--- a/share/etc/defaultrc
+++ b/share/etc/defaultrc
@@ -1,6 +1,5 @@
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/share/etc/oned.conf b/share/etc/oned.conf
index 00c9bb51a6..9fc39c6e41 100644
--- a/share/etc/oned.conf
+++ b/share/etc/oned.conf
@@ -171,6 +171,15 @@ TM_MAD = [
# arguments = "tm_dummy/tm_dummy.conf" ]
#-------------------------------------------------------------------------------
+#-------------------------------------------------------------------------------
+# LVM Transfer Manager Driver sample configuration
+#-------------------------------------------------------------------------------
+#TM_MAD = [
+# name = "tm_lvm",
+# executable = "one_tm",
+# arguments = "tm_lvm/tm_lvm.conf" ]
+#-------------------------------------------------------------------------------
+
#*******************************************************************************
# Hook Manager Configuration
#*******************************************************************************
@@ -190,9 +199,10 @@ TM_MAD = [
# - RUNNING, after the VM is successfully booted
# - SHUTDOWN, after the VM is shutdown
# - STOP, after the VM is stopped (including VM image transfers)
+# - DONE, after the VM is deleted or shutdown
# command : use absolute path here
# arguments : for the hook. You can access to VM template variables with $
-# - $ATTR, the value of an attribute e.g. $NAME or $VM_ID
+# - $ATTR, the value of an attribute e.g. $NAME or $VMID
# - $ATTR[VAR], the value of a vector e.g. $NIC[MAC]
# - $ATTR[VAR, COND], same of previous but COND select between
# multiple ATTRs e.g. $NIC[MAC, NETWORK="Public"]
@@ -210,7 +220,7 @@ HM_MAD = [
# name = "dhcp",
# on = "create",
# command = "/bin/echo",
-# arguments = "$NAME > /tmp/test.$VM_ID" ]
+# arguments = "$NAME > /tmp/test.$VMID" ]
#-------------------------------------------------------------------------------
#VM_HOOK = [
# name = "ebtables",
@@ -223,6 +233,6 @@ HM_MAD = [
# name = "mail",
# on = "running",
# command = "/usr/local/one/bin/send_mail",
-# arguments = "$VM_ID $NAME",
+# arguments = "$VMID $NAME",
# remote = "no" ]
#------------------------------------------------------------------------------
diff --git a/share/examples/tm/tm_clone.sh b/share/examples/tm/tm_clone.sh
index ea5e1e05a3..721041d627 100755
--- a/share/examples/tm/tm_clone.sh
+++ b/share/examples/tm/tm_clone.sh
@@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/share/examples/tm/tm_delete.sh b/share/examples/tm/tm_delete.sh
index 437ab0142f..7844ee2533 100755
--- a/share/examples/tm/tm_delete.sh
+++ b/share/examples/tm/tm_delete.sh
@@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/share/examples/tm/tm_ln.sh b/share/examples/tm/tm_ln.sh
index 29ba8ece6c..da107d43d7 100755
--- a/share/examples/tm/tm_ln.sh
+++ b/share/examples/tm/tm_ln.sh
@@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/share/examples/tm/tm_mkimage.sh b/share/examples/tm/tm_mkimage.sh
index bef6b86758..2e0fdb0fc7 100755
--- a/share/examples/tm/tm_mkimage.sh
+++ b/share/examples/tm/tm_mkimage.sh
@@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/share/examples/tm/tm_mkswap.sh b/share/examples/tm/tm_mkswap.sh
index 220ebbd02a..8b83e47473 100755
--- a/share/examples/tm/tm_mkswap.sh
+++ b/share/examples/tm/tm_mkswap.sh
@@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/share/examples/tm/tm_mv.sh b/share/examples/tm/tm_mv.sh
index 9030b97993..e7dc09af6e 100755
--- a/share/examples/tm/tm_mv.sh
+++ b/share/examples/tm/tm_mv.sh
@@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/share/hooks/ebtables-flush b/share/hooks/ebtables-flush
new file mode 100755
index 0000000000..1881b5aa34
--- /dev/null
+++ b/share/hooks/ebtables-flush
@@ -0,0 +1,65 @@
+#!/usr/bin/env ruby
+
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
+
+def deactivate(rule)
+ system "sudo ebtables -D #{rule}"
+end
+
+def get_interfaces
+ brctl_exit=`brctl show`
+ brctl_exit.split("\n")[1..-1].collect{|l| l.split.last }
+end
+
+RULE_TYPES=[
+ /-i ([\w\.\-]+) /,
+ /-o ([\w\.\-]+) /
+]
+
+def get_rules
+ rules=Array.new
+ RULE_TYPES.each do |reg|
+ ebtables_exit=`sudo ebtables -L FORWARD`
+ rules << ebtables_exit.split("\n")[3..-1].collect do |l|
+ line=l.strip
+ m=line.match(reg)
+ if m
+ interface=m[1]
+ {
+ :interface => interface,
+ :rule => line
+ }
+ else
+ nil
+ end
+ end.compact
+ end
+ rules.flatten
+end
+
+# if executed on "done", we must wait a bit until the tap is detached from the bridge
+sleep 1
+
+interfaces=get_interfaces
+all_rules=get_rules
+
+all_rules.each do |rule|
+ if !interfaces.include?(rule[:interface])
+ deactivate("FORWARD #{rule[:rule]}")
+ end
+end
+
diff --git a/share/hooks/ebtables-kvm b/share/hooks/ebtables-kvm
new file mode 100755
index 0000000000..b31ae342d7
--- /dev/null
+++ b/share/hooks/ebtables-kvm
@@ -0,0 +1,80 @@
+#!/usr/bin/env ruby
+
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
+
+require 'pp'
+require 'rexml/document'
+
+VM_NAME=ARGV[0]
+
+# Uncomment to act only on the listed bridges.
+#FILTERED_BRIDGES = ['beth0']
+
+def activate(rule)
+ system "sudo ebtables -A #{rule}"
+end
+
+def get_bridges
+ bridges = Hash.new
+ brctl_exit=`brctl show`
+ cur_bridge = ""
+ brctl_exit.split("\n")[1..-1].each do |l|
+ l = l.split
+ if l.length > 1
+ cur_bridge = l[0]
+ bridges[cur_bridge] = Array.new
+ bridges[cur_bridge] << l[3]
+ else
+ bridges[cur_bridge] << l[0]
+ end
+ end
+ bridges
+end
+
+def get_interfaces
+ bridges = get_bridges
+ if defined? FILTERED_BRIDGES
+ FILTERED_BRIDGES.collect {|k,v| bridges[k]}.flatten
+ else
+ bridges.values.flatten
+ end
+end
+
+nets=`virsh -c qemu:///system dumpxml #{VM_NAME}`
+
+doc=REXML::Document.new(nets).root
+
+interfaces = get_interfaces()
+
+doc.elements.each('/domain/devices/interface') {|net|
+ tap=net.elements['target'].attributes['dev']
+ if interfaces.include? tap
+ iface_mac=net.elements['mac'].attributes['address']
+
+ mac=iface_mac.split(':')
+ mac[-1]='00'
+ net_mac=mac.join(':')
+
+
+ in_rule="FORWARD -s ! #{net_mac}/ff:ff:ff:ff:ff:00 -o #{tap} -j DROP"
+ out_rule="FORWARD -s ! #{iface_mac} -i #{tap} -j DROP"
+
+ activate(in_rule)
+ activate(out_rule)
+ end
+}
+
diff --git a/share/hooks/ebtables-xen b/share/hooks/ebtables-xen
index 661fceec78..bff2864f29 100755
--- a/share/hooks/ebtables-xen
+++ b/share/hooks/ebtables-xen
@@ -1,42 +1,79 @@
#!/usr/bin/env ruby
-
-COMMAND=ARGV[0]
-VM_NAME=ARGV[1]
-
+
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
+
+VM_NAME=ARGV[0]
+
+# Uncomment to act only on the listed bridges.
+#FILTERED_BRIDGES = ['beth0']
+
def activate(rule)
system "sudo ebtables -A #{rule}"
end
-
-def deactivate(rule)
- system "sudo ebtables -D #{rule}"
+
+def get_bridges
+ bridges = Hash.new
+ brctl_exit=`brctl show`
+ cur_bridge = ""
+ brctl_exit.split("\n")[1..-1].each do |l|
+ l = l.split
+ if l.length > 1
+ cur_bridge = l[0]
+ bridges[cur_bridge] = Array.new
+ bridges[cur_bridge] << l[3]
+ else
+ bridges[cur_bridge] << l[0]
+ end
+ end
+ bridges
end
-
+
+def get_interfaces
+ bridges = get_bridges
+ if defined? FILTERED_BRIDGES
+ FILTERED_BRIDGES.collect {|k,v| bridges[k]}.flatten
+ else
+ bridges.values.flatten
+ end
+end
+
vm_id=`sudo xm domid #{VM_NAME}`.strip
networks=`sudo xm network-list #{vm_id}`.split("\n")[1..-1]
-
+
+interfaces = get_interfaces
+
networks.each {|net|
n=net.split
iface_id=n[0]
iface_mac=n[2]
-
- mac=iface_mac.split(':')
- mac[-1]='00'
- net_mac=mac.join(':')
-
+
tap="vif#{vm_id}.#{iface_id}"
-
- in_rule="INPUT -d ! #{iface_mac}/FF:FF:FF:FF:FF:FF -i #{tap} -j DROP"
- out_rule="OUTPUT -s ! #{net_mac}/FF:FF:FF:FF:FF:00 -o #{tap} -j DROP"
-
- case COMMAND
- when "start"
+
+ if interfaces.include? tap
+ mac=iface_mac.split(':')
+ mac[-1]='00'
+ net_mac=mac.join(':')
+
+
+ in_rule="FORWARD -s ! #{net_mac}/ff:ff:ff:ff:ff:00 -o #{tap} -j DROP"
+ out_rule="FORWARD -s ! #{iface_mac} -i #{tap} -j DROP"
+
activate(in_rule)
activate(out_rule)
- when "stop"
- deactivate(in_rule)
- deactivate(out_rule)
- else
- puts "First parameter should be start or stop"
end
}
diff --git a/share/scons/get_xmlrpc_config b/share/scons/get_xmlrpc_config
index 6e7bda8467..ebbdd45b55 100755
--- a/share/scons/get_xmlrpc_config
+++ b/share/scons/get_xmlrpc_config
@@ -1,8 +1,7 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/share/scons/lex_bison.py b/share/scons/lex_bison.py
index 27506aeed8..ed2b15fc7f 100644
--- a/share/scons/lex_bison.py
+++ b/share/scons/lex_bison.py
@@ -1,6 +1,5 @@
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/share/scons/xmlrpc_config.py b/share/scons/xmlrpc_config.py
index d2a9053e97..18eeb5f35a 100644
--- a/share/scons/xmlrpc_config.py
+++ b/share/scons/xmlrpc_config.py
@@ -1,6 +1,5 @@
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/share/scripts/bash_completion.d/one b/share/scripts/bash_completion.d/one
new file mode 100644
index 0000000000..5806b35db5
--- /dev/null
+++ b/share/scripts/bash_completion.d/one
@@ -0,0 +1,130 @@
+_one_list() {
+ local cmd filter
+ one_cmd=$1
+ if [ -n "$2" ]; then
+ filter="-f $2"
+ fi
+ echo $($one_cmd $filter list|sed 1d|awk '{print $1}')
+ return 0
+}
+
+_onevm() {
+ local cur prev opts cmd
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+ if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
+ pprev="${COMP_WORDS[COMP_CWORD-2]}"
+ fi
+ opts="create deploy shutdown livemigrate migrate hold release stop cancel suspend resume delete restart list show top history"
+ cmd=onevm
+ if [ $COMP_CWORD == 1 ]
+ then
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
+ elif [ $COMP_CWORD == 2 ]
+ then
+ case "$prev" in
+ show|delete)
+ vms=`_one_list $cmd`
+ COMPREPLY=( $(compgen -W "${vms}" -- ${cur}) )
+ return 0
+ ;;
+ cancel|shutdown|suspend|stop)
+ vms=`_one_list $cmd stat='runn'`
+ COMPREPLY=( $(compgen -W "${vms}" -- ${cur}) )
+ return 0
+ ;;
+ create|submit)
+ COMPREPLY=( $(compgen -A file -- ${cur}) )
+ return 0
+ ;;
+ migrate)
+ vms=`_one_list $cmd stat='runn'`
+ COMPREPLY=( $(compgen -W "${vms}" -- ${cur}) )
+ return 0
+ ;;
+ esac
+ elif [ $COMP_CWORD == 3 ]
+ then
+ case "$pprev" in
+ migrate)
+ hosts=`onehost list -f STAT=on|sed 1d|awk '{print $2}'`
+ COMPREPLY=( $(compgen -W "${hosts}" -- ${cur}) )
+ return 0
+ ;;
+ esac
+ fi
+}
+
+complete -F _onevm onevm
+
+_onevnet() {
+ local cur prev opts cmd
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+ opts="create delete list show"
+ cmd=onevnet
+ if [ $COMP_CWORD == 1 ]
+ then
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
+ elif [ $COMP_CWORD == 2 ]
+ then
+ case "$prev" in
+ create|submit)
+ COMPREPLY=( $(compgen -A file -- ${cur}) )
+ return 0
+ ;;
+ delete|show)
+ vnets=`_one_list $cmd`
+ COMPREPLY=( $(compgen -W "${vnets}" -- ${cur}) )
+ return 0
+ ;;
+ esac
+ fi
+
+}
+
+complete -F _onevnet onevnet
+
+_onehost() {
+ local cur prev opts cmd
+ COMPREPLY=()
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
+ opts="create show delete list enable disable top"
+ cmd=onehost
+ if [ $COMP_CWORD == 1 ]
+ then
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
+ return 0
+ elif [ $COMP_CWORD == 2 ]
+ then
+ case "$prev" in
+ create|submit)
+ COMPREPLY=( $(compgen -A file -- ${cur}) )
+ return 0
+ ;;
+ delete|show)
+ hosts=`_one_list $cmd`
+ COMPREPLY=( $(compgen -W "${hosts}" -- ${cur}) )
+ return 0
+ ;;
+ enable)
+ hosts=`_one_list $cmd stat='off'`
+ COMPREPLY=( $(compgen -W "${hosts}" -- ${cur}) )
+ return 0
+ ;;
+ disable)
+ hosts=`_one_list $cmd stat='on'`
+ COMPREPLY=( $(compgen -W "${hosts}" -- ${cur}) )
+ return 0
+ ;;
+ esac
+ fi
+
+}
+
+complete -F _onehost onehost
diff --git a/share/scripts/centos-5/context/centos.one b/share/scripts/centos-5/context/centos.one
new file mode 100644
index 0000000000..44f0053f87
--- /dev/null
+++ b/share/scripts/centos-5/context/centos.one
@@ -0,0 +1,22 @@
+NAME = Centos5
+CPU = 0.5
+MEMORY = 400
+DISK = [
+ source = "/home/srv/cloud/images/centos-5.img",
+ target = "hda",
+ readonly = "no" ]
+NIC = [ NETWORK = "Red Virtual" ]
+
+FEATURES=[ acpi="no" ]
+RAW = [ type = "kvm", data = " " ]
+
+CONTEXT = [
+ hostname = "$NAME",
+ #ip_public = "$NIC[IP, NETWORK=\"Red Virtual\"]",
+ ip_public = "192.168.0.5",
+ files = "/home/oneadmin/one-templates/centos-5/init.sh /home/oneadmin/one-templates/centos-5/id_dsa.pub",
+ target = "hdc",
+ root_pubkey = "id_dsa.pub",
+ username = "oneadmin",
+ user_pubkey = "id_dsa.pub"
+]
diff --git a/share/scripts/centos-5/context/init.sh b/share/scripts/centos-5/context/init.sh
new file mode 100644
index 0000000000..7d2b252f95
--- /dev/null
+++ b/share/scripts/centos-5/context/init.sh
@@ -0,0 +1,51 @@
+#!/bin/bash
+
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
+
+if [ -f /mnt/context.sh ]
+then
+ . /mnt/context.sh
+fi
+
+
+hostname $HOSTNAME
+sed -i "/HOSTNAME=/s/=.*$/=$HOSTNAME/" /etc/sysconfig/network
+
+if [ -n "$IP_PUBLIC" ]; then
+ ifconfig eth0 $IP_PUBLIC
+fi
+
+if [ -n "$NETMASK" ]; then
+ ifconfig eth0 netmask $NETMASK
+fi
+
+
+if [ -f /mnt/$ROOT_PUBKEY ]; then
+ mkdir -p /root/.ssh
+ cat /mnt/$ROOT_PUBKEY >> /root/.ssh/authorized_keys
+ chmod -R 600 /root/.ssh/
+fi
+
+if [ -n "$USERNAME" ]; then
+ useradd $USERNAME
+ if [ -f /mnt/$USER_PUBKEY ]; then
+ mkdir -p /home/$USERNAME/.ssh/
+ cat /mnt/$USER_PUBKEY >> /home/$USERNAME/.ssh/authorized_keys
+ chown -R $USERNAME:$USERNAME /home/$USERNAME/.ssh
+ chmod -R 600 /home/$USERNAME/.ssh/authorized_keys
+ fi
+fi
diff --git a/share/scripts/centos-5/net-vmcontext/vmcontext b/share/scripts/centos-5/net-vmcontext/vmcontext
new file mode 100755
index 0000000000..a8ec7663dc
--- /dev/null
+++ b/share/scripts/centos-5/net-vmcontext/vmcontext
@@ -0,0 +1,115 @@
+#!/bin/bash
+#
+# chkconfig: 2345 10 90
+# description: network reconfigure
+#
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
+
+# Gets IP address from a given MAC
+mac2ip() {
+ mac=$1
+
+ let ip_a=0x`echo $mac | cut -d: -f 3`
+ let ip_b=0x`echo $mac | cut -d: -f 4`
+ let ip_c=0x`echo $mac | cut -d: -f 5`
+ let ip_d=0x`echo $mac | cut -d: -f 6`
+
+ ip="$ip_a.$ip_b.$ip_c.$ip_d"
+
+ echo $ip
+}
+
+# Gets the network part of an IP
+get_network() {
+ IP=$1
+
+ echo $IP | cut -d'.' -f1,2,3
+}
+
+get_interfaces() {
+ IFCMD="/sbin/ifconfig -a"
+
+ $IFCMD | grep ^eth | sed 's/ *Link encap:Ethernet.*HWaddr /-/g'
+}
+
+get_dev() {
+ echo $1 | cut -d'-' -f 1
+}
+
+get_mac() {
+ echo $1 | cut -d'-' -f 2
+}
+
+gen_hosts() {
+ NETWORK=$1
+ echo "127.0.0.1 localhost"
+ for n in `seq -w 01 99`; do
+ n2=`echo $n | sed 's/^0*//'`
+ echo ${NETWORK}.$n2 cluster${n}
+ done
+}
+
+gen_exports() {
+ NETWORK=$1
+ echo "/images ${NETWORK}.0/255.255.255.0(rw,async,no_subtree_check)"
+}
+
+gen_hostname() {
+ MAC=$1
+ NUM=`mac2ip $MAC | cut -d'.' -f4`
+ NUM2=`echo 000000$NUM | sed 's/.*\(..\)/\1/'`
+ echo cluster$NUM2
+}
+
+gen_interface() {
+ DEV_MAC=$1
+ DEV=`get_dev $DEV_MAC`
+ MAC=`get_mac $DEV_MAC`
+ IP=`mac2ip $MAC`
+ NETWORK=`get_network $IP`
+
+cat < /etc/sysconfig/network-scripts/ifcfg-${DEV}
+done
+
+# gen_hosts $NETWORK > /etc/hosts
+# gen_exports $NETWORK > /etc/exports
+# gen_hostname $MAC > /etc/hostname
+
+#ifdown $DEV
+#ifup $DEV
diff --git a/share/scripts/one b/share/scripts/one
index f0ba1514dd..5feff915b9 100755
--- a/share/scripts/one
+++ b/share/scripts/one
@@ -1,8 +1,7 @@
#! /bin/sh
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@@ -26,7 +25,7 @@ if [ -z "$ONE_LOCATION" ]; then
ONED=/usr/bin/oned
ONE_SCHEDULER=/usr/bin/mm_sched
- LOCK_FILE=/var/lock/one
+ LOCK_FILE=/var/lock/one/one
else
ONE_PID=$ONE_LOCATION/var/oned.pid
ONE_SCHEDPID=$ONE_LOCATION/var/sched.pid
@@ -83,11 +82,13 @@ start()
fi
if [ ! -f "$ONE_DB" ]; then
- if [ -z "$ONE_AUTH" ]; then
- echo "You should have ONE_AUTH set the first time you start"
- echo "OpenNebula as it is used to set the credentials for"
- echo "the adminitrator user."
- exit 1
+ if [ ! -f "$HOME/.one/one_auth" ]; then
+ if [ -z "$ONE_AUTH" ]; then
+ echo "You should have ONE_AUTH set the first time you start"
+ echo "OpenNebula as it is used to set the credentials for"
+ echo "the adminitrator user."
+ exit 1
+ fi
fi
fi
diff --git a/share/scripts/openSUSE/context/init.sh b/share/scripts/openSUSE/context/init.sh
new file mode 100644
index 0000000000..ca078805df
--- /dev/null
+++ b/share/scripts/openSUSE/context/init.sh
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
+
+if [ -f /mnt/context.sh ]
+then
+ . /mnt/context.sh
+fi
+
+
+hostname $HOSTNAME
+sed -i "s/openSUSE/$HOSTNAME/g" /etc/hosts
+echo $HOSTNAME > /etc/HOSTNAME
+
+if [ -n "$IP_PUBLIC" ]; then
+ ifconfig eth0 $IP_PUBLIC
+fi
+
+if [ -n "$NETMASK" ]; then
+ ifconfig eth0 netmask $NETMASK
+fi
+
+
+if [ -f /mnt/$ROOT_PUBKEY ]; then
+ mkdir -p /root/.ssh
+ cat /mnt/$ROOT_PUBKEY >> /root/.ssh/authorized_keys
+ chmod -R 600 /root/.ssh/
+fi
+
+if [ -n "$USERNAME" ]; then
+ useradd -m $USERNAME
+ if [ -f /mnt/$USER_PUBKEY ]; then
+ mkdir -p /home/$USERNAME/.ssh/
+ cat /mnt/$USER_PUBKEY >> /home/$USERNAME/.ssh/authorized_keys
+ chown -R $USERNAME:users /home/$USERNAME/.ssh
+ chmod -R 600 /home/$USERNAME/.ssh/authorized_keys
+ fi
+fi
diff --git a/share/scripts/openSUSE/context/openSUSE.one b/share/scripts/openSUSE/context/openSUSE.one
new file mode 100644
index 0000000000..02397ed673
--- /dev/null
+++ b/share/scripts/openSUSE/context/openSUSE.one
@@ -0,0 +1,19 @@
+NAME = opensuse11
+CPU = 0.5
+MEMORY = 400
+DISK = [
+ source = "/home/srv/cloud/images/openSUSE-11.1-v2.img",
+ target = "hda",
+ readonly = "no" ]
+
+NIC = [ NETWORK = "Red Virtual" ]
+
+CONTEXT = [
+ hostname = "$NAME",
+ ip_public = "192.168.0.5",
+ files = "/home/oneadmin/one-templates/openSUSE/init.sh /home/oneadmin/one-templates/openSUSE/id_dsa.pub",
+ target = "hdc",
+ root_pubkey = "id_dsa.pub",
+ username = "oneadmin",
+ user_pubkey = "id_dsa.pub"
+]
diff --git a/share/scripts/openSUSE/net-vmcontext/vmcontext b/share/scripts/openSUSE/net-vmcontext/vmcontext
new file mode 100755
index 0000000000..a2b8966438
--- /dev/null
+++ b/share/scripts/openSUSE/net-vmcontext/vmcontext
@@ -0,0 +1,123 @@
+#!/bin/bash
+#
+# chkconfig: 2345 10 90
+# description: network reconfigure
+#
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
+
+# Gets IP address from a given MAC
+mac2ip() {
+ mac=$1
+
+ let ip_a=0x`echo $mac | cut -d: -f 3`
+ let ip_b=0x`echo $mac | cut -d: -f 4`
+ let ip_c=0x`echo $mac | cut -d: -f 5`
+ let ip_d=0x`echo $mac | cut -d: -f 6`
+
+ ip="$ip_a.$ip_b.$ip_c.$ip_d"
+
+ echo $ip
+}
+
+# Gets the network part of an IP
+get_network() {
+ IP=$1
+
+ echo $IP | cut -d'.' -f1,2,3
+}
+
+get_interfaces() {
+ IFCMD="/sbin/ifconfig -a"
+
+ $IFCMD | grep ^eth | sed 's/ *Link encap:Ethernet.*HWaddr /-/g'
+}
+
+get_dev() {
+ echo $1 | cut -d'-' -f 1
+}
+
+get_mac() {
+ echo $1 | cut -d'-' -f 2
+}
+
+gen_hosts() {
+ NETWORK=$1
+ echo "127.0.0.1 localhost"
+ for n in `seq -w 01 99`; do
+ n2=`echo $n | sed 's/^0*//'`
+ echo ${NETWORK}.$n2 cluster${n}
+ done
+}
+
+gen_exports() {
+ NETWORK=$1
+ echo "/images ${NETWORK}.0/255.255.255.0(rw,async,no_subtree_check)"
+}
+
+gen_hostname() {
+ MAC=$1
+ NUM=`mac2ip $MAC | cut -d'.' -f4`
+ NUM2=`echo 000000$NUM | sed 's/.*\(..\)/\1/'`
+ echo cluster$NUM2
+}
+
+gen_interface() {
+ DEV_MAC=$1
+ DEV=`get_dev $DEV_MAC`
+ MAC=`get_mac $DEV_MAC`
+ IP=`mac2ip $MAC`
+ NETWORK=`get_network $IP`
+
+cat < /etc/sysconfig/network/ifcfg-${DEV}
+ if [ $DEV == "eth0" ]; then
+ MAC=`get_mac $DEV_MAC`
+ IP=`mac2ip $MAC`
+ NETWORK=`get_network $IP`
+ echo "default $NETWORK.1" > /etc/sysconfig/network/routes
+ fi
+done
+
+# gen_hosts $NETWORK > /etc/hosts
+# gen_exports $NETWORK > /etc/exports
+# gen_hostname $MAC > /etc/hostname
+
+#ifdown $DEV
+#ifup $DEV
diff --git a/share/scripts/ttylinux/context/init.sh b/share/scripts/ttylinux/context/init.sh
new file mode 100644
index 0000000000..0051834eba
--- /dev/null
+++ b/share/scripts/ttylinux/context/init.sh
@@ -0,0 +1,49 @@
+#!/bin/bash
+
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
+
+if [ -f /mnt/context/context.sh ]
+then
+ . /mnt/context/context.sh
+fi
+
+
+echo $HOSTNAME > /etc/HOSTNAME
+hostname $HOSTNAME
+
+if [ -n "$IP_PUBLIC" ]; then
+ ifconfig eth0 $IP_PUBLIC
+fi
+
+if [ -n "$NETMASK" ]; then
+ ifconfig eth0 netmask $NETMASK
+fi
+
+
+if [ -f /mnt/context/$ROOT_PUBKEY ]; then
+ cat /mnt/context/$ROOT_PUBKEY >> /root/.ssh/authorized_keys
+fi
+
+if [ -n "$USERNAME" ]; then
+ adduser -s /bin/bash -D $USERNAME
+ if [ -f /mnt/context/$USER_PUBKEY ]; then
+ mkdir -p /home/$USERNAME/.ssh/
+ cat /mnt/context/$USER_PUBKEY >> /home/$USERNAME/.ssh/authorized_keys
+ chown -R $USERNAME /home/$USERNAME/.ssh
+ chmod -R 600 /home/$USERNAME/.ssh
+ fi
+fi
diff --git a/share/scripts/ttylinux/context/ttylinux.one b/share/scripts/ttylinux/context/ttylinux.one
new file mode 100644
index 0000000000..59bf09a122
--- /dev/null
+++ b/share/scripts/ttylinux/context/ttylinux.one
@@ -0,0 +1,22 @@
+NAME = myttyserver
+CPU = 0.1
+MEMORY = 64
+DISK = [
+ source = "/home/srv/cloud/images/ttylinux.0.4.img",
+ target = "hda",
+ readonly = "no" ]
+NIC = [ NETWORK = "Red Virtual" ]
+
+FEATURES=[ acpi="no" ]
+RAW = [ type = "kvm", data = " " ]
+
+# Context example
+CONTEXT = [
+ hostname = "$NAME",
+ ip_public = "$NIC[IP, NETWORK=\"Red Virtual\"]",
+ files = "/home/oneadmin/one-templates/ttylinux/init.sh /home/oneadmin/one-templates/ttylinux/id_dsa.pub",
+ target = "hdc",
+ root_pubkey = "id_dsa.pub",
+ username = "oneadmin",
+ user_pubkey = "id_dsa.pub"
+]
diff --git a/share/scripts/ttylinux/net-vmcontext/vmcontexttty b/share/scripts/ttylinux/net-vmcontext/vmcontexttty
new file mode 100755
index 0000000000..a1677b4356
--- /dev/null
+++ b/share/scripts/ttylinux/net-vmcontext/vmcontexttty
@@ -0,0 +1,119 @@
+#!/bin/bash
+#
+# chkconfig: 2345 10 90
+# description: network reconfigure
+#
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
+
+# Gets IP address from a given MAC
+mac2ip() {
+ mac=$1
+
+ let ip_a=0x`echo $mac | cut -d: -f 3`
+ let ip_b=0x`echo $mac | cut -d: -f 4`
+ let ip_c=0x`echo $mac | cut -d: -f 5`
+ let ip_d=0x`echo $mac | cut -d: -f 6`
+
+ ip="$ip_a.$ip_b.$ip_c.$ip_d"
+
+ echo $ip
+}
+
+# Gets the network part of an IP
+get_network() {
+ IP=$1
+
+ echo $IP | cut -d'.' -f1-3
+}
+
+get_interfaces() {
+ IFCMD="/sbin/ifconfig -a"
+
+ $IFCMD | grep ^eth | sed 's/ *Link encap:Ethernet.*HWaddr /-/g'
+}
+
+get_dev() {
+ echo $1 | cut -d'-' -f 1
+}
+
+get_mac() {
+ echo $1 | cut -d'-' -f 2
+}
+
+gen_hosts() {
+ NETWORK=$1
+ echo "127.0.0.1 localhost"
+ for n in `seq -w 01 99`; do
+ n2=`echo $n | sed 's/^0*//'`
+ echo ${NETWORK}.$n2 cluster${n}
+ done
+}
+
+gen_exports() {
+ NETWORK=$1
+ echo "/images ${NETWORK}.0/255.255.255.0(rw,async,no_subtree_check)"
+}
+
+gen_hostname() {
+ MAC=$1
+ NUM=`mac2ip $MAC | cut -d'.' -f4`
+ NUM2=`echo 000000$NUM | sed 's/.*\(..\)/\1/'`
+ echo cluster$NUM2
+}
+
+gen_interface() {
+ DEV_MAC=$1
+ DEV=`get_dev $DEV_MAC`
+ MAC=`get_mac $DEV_MAC`
+ IP=`mac2ip $MAC`
+ NETWORK=`get_network $IP`
+
+cat < /etc/sysconfig/network-scripts/ifcfg-${DEV}
+done
+
+# gen_hosts $NETWORK > /etc/hosts
+
+# gen_exports $NETWORK > /etc/exports
+
+# gen_hostname $MAC > /etc/hostname
+
+#ifdown $DEV
+#ifup $DEV
+
+# /bin/hostname `cat /etc/hostname`
diff --git a/share/scripts/ubuntu/context/init.sh b/share/scripts/ubuntu/context/init.sh
new file mode 100644
index 0000000000..edbe0b0b8c
--- /dev/null
+++ b/share/scripts/ubuntu/context/init.sh
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
+
+if [ -f /mnt/context.sh ]
+then
+ . /mnt/context.sh
+fi
+
+
+echo $HOSTNAME > /etc/hostname
+hostname $HOSTNAME
+sed -i "/127.0.1.1/s/ubuntu/$HOSTNAME/" /etc/hosts
+
+if [ -n "$IP_PUBLIC" ]; then
+ ifconfig eth0 $IP_PUBLIC
+fi
+
+if [ -n "$NETMASK" ]; then
+ ifconfig eth0 netmask $NETMASK
+fi
+
+
+if [ -f /mnt/$ROOT_PUBKEY ]; then
+ mkdir -p /root/.ssh
+ cat /mnt/$ROOT_PUBKEY >> /root/.ssh/authorized_keys
+ chmod -R 600 /root/.ssh/
+fi
+
+if [ -n "$USERNAME" ]; then
+ useradd -s /bin/bash -m $USERNAME
+ if [ -f /mnt/$USER_PUBKEY ]; then
+ mkdir -p /home/$USERNAME/.ssh/
+ cat /mnt/$USER_PUBKEY >> /home/$USERNAME/.ssh/authorized_keys
+ chown -R $USERNAME:$USERNAME /home/$USERNAME/.ssh
+ chmod -R 600 /home/$USERNAME/.ssh/authorized_keys
+ fi
+fi
diff --git a/share/scripts/ubuntu/context/ubuntu-server-9.04.one b/share/scripts/ubuntu/context/ubuntu-server-9.04.one
new file mode 100644
index 0000000000..9eb77fba63
--- /dev/null
+++ b/share/scripts/ubuntu/context/ubuntu-server-9.04.one
@@ -0,0 +1,23 @@
+NAME = myUbuntu
+CPU = 0.5
+MEMORY = 400
+DISK = [
+ source = "/home/srv/cloud/images/ubuntu-server-9.04.img",
+ target = "sda",
+ readonly = "no" ]
+NIC = [ NETWORK = "Red Virtual" ]
+
+FEATURES=[ acpi="no" ]
+RAW = [ type = "kvm", data = " " ]
+
+CONTEXT = [
+ hostname = "$NAME",
+ #ip_public = "$NIC[IP, NETWORK=\"Red Virtual\"]",
+ ip_public = "192.168.0.4",
+ files = "/home/oneadmin/one-templates/ubuntu/init.sh /home/oneadmin/one-templates/ubuntu/id_dsa.pub",
+ target = "sdb", # This distribution's udev assigns block device symlinks sequentally. If you only define two drives
+ # the second will be sdb.
+ root_pubkey = "id_dsa.pub",
+ username = "oneadmin",
+ user_pubkey = "id_dsa.pub"
+]
diff --git a/share/scripts/ubuntu/net-vmcontext/vmcontext b/share/scripts/ubuntu/net-vmcontext/vmcontext
new file mode 100755
index 0000000000..c0fd932a48
--- /dev/null
+++ b/share/scripts/ubuntu/net-vmcontext/vmcontext
@@ -0,0 +1,126 @@
+#!/bin/bash
+
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
+
+# Gets IP address from a given MAC
+mac2ip() {
+ mac=$1
+
+ let ip_a=0x`echo $mac | cut -d: -f 3`
+ let ip_b=0x`echo $mac | cut -d: -f 4`
+ let ip_c=0x`echo $mac | cut -d: -f 5`
+ let ip_d=0x`echo $mac | cut -d: -f 6`
+
+ ip="$ip_a.$ip_b.$ip_c.$ip_d"
+
+ echo $ip
+}
+
+# Gets the network part of an IP
+get_network() {
+ IP=$1
+
+ echo $IP | cut -d'.' -f1,2,3
+}
+
+get_interfaces() {
+ IFCMD="/sbin/ifconfig -a"
+
+ $IFCMD | grep ^eth | sed 's/ *Link encap:Ethernet.*HWaddr /-/g'
+}
+
+get_dev() {
+ echo $1 | cut -d'-' -f 1
+}
+
+get_mac() {
+ echo $1 | cut -d'-' -f 2
+}
+
+gen_hosts() {
+ NETWORK=$1
+ echo "127.0.0.1 localhost"
+ for n in `seq -w 01 99`; do
+ n2=`echo $n | sed 's/^0*//'`
+ echo ${NETWORK}.$n2 cluster${n}
+ done
+}
+
+gen_exports() {
+ NETWORK=$1
+ echo "/images ${NETWORK}.0/255.255.255.0(rw,async,no_subtree_check)"
+}
+
+gen_hostname() {
+ MAC=$1
+ NUM=`mac2ip $MAC | cut -d'.' -f4`
+ NUM2=`echo 000000$NUM | sed 's/.*\(..\)/\1/'`
+ echo cluster$NUM2
+}
+
+gen_interface() {
+ DEV_MAC=$1
+ DEV=`get_dev $DEV_MAC`
+ MAC=`get_mac $DEV_MAC`
+ IP=`mac2ip $MAC`
+ NETWORK=`get_network $IP`
+
+ cat < /etc/hosts
+
+# gen_exports $NETWORK > /etc/exports
+
+# gen_hostname $MAC > /etc/hostname
+
+(
+cat < /etc/network/interfaces
+
+# /bin/hostname `cat /etc/hostname`
diff --git a/share/scripts/vmcontext.sh b/share/scripts/vmcontext.sh
index 47681ce167..c0fd932a48 100755
--- a/share/scripts/vmcontext.sh
+++ b/share/scripts/vmcontext.sh
@@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/share/test/one.db b/share/test/one.db
index 2d4b4c7b5d..e87cb27bae 100644
Binary files a/share/test/one.db and b/share/test/one.db differ
diff --git a/share/test/src/im/ImTest.cc b/share/test/src/im/ImTest.cc
index 7a5256fbfe..e7f12400b7 100644
--- a/share/test/src/im/ImTest.cc
+++ b/share/test/src/im/ImTest.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2008, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/share/test/src/mad/mad_echo.sh b/share/test/src/mad/mad_echo.sh
index 97e3ae75fb..0092ea27a7 100755
--- a/share/test/src/mad/mad_echo.sh
+++ b/share/test/src/mad/mad_echo.sh
@@ -1,8 +1,7 @@
#!/bin/bash
# --------------------------------------------------------------------------
-# Copyright 2002-2006 GridWay Team, Distributed Systems Architecture
-# Group, Universidad Complutense de Madrid
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org)
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
diff --git a/src/client/OneClient.cc b/src/client/OneClient.cc
index 2f9c12b9cd..91097d0047 100644
--- a/src/client/OneClient.cc
+++ b/src/client/OneClient.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/client/OneClient_C_Wrapper.cc b/src/client/OneClient_C_Wrapper.cc
index 995ca626c0..a8acc4a04a 100644
--- a/src/client/OneClient_C_Wrapper.cc
+++ b/src/client/OneClient_C_Wrapper.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/client/SConstruct b/src/client/SConstruct
index 999cb0623e..e4eb8e5186 100644
--- a/src/client/SConstruct
+++ b/src/client/SConstruct
@@ -1,8 +1,7 @@
# SConstruct for src/mad
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/client/ruby/client_utilities.rb b/src/client/ruby/client_utilities.rb
index b5a8fd158b..c73d506abc 100644
--- a/src/client/ruby/client_utilities.rb
+++ b/src/client/ruby/client_utilities.rb
@@ -1,6 +1,5 @@
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@@ -217,10 +216,6 @@ end
################
def get_one_client(session=nil)
- if !ENV["ONE_AUTH"] or ENV["ONE_AUTH"].empty? or !ENV["ONE_AUTH"].match(".+:.+")
- puts "$ONE_AUTH not defined or malformed"
- exit -1
- end
OpenNebula::Client.new(session)
end
@@ -301,3 +296,45 @@ def str_running_time(data)
"%02d %02d:%02d:%02d" % [dtime.yday-1, dtime.hour, dtime.min, dtime.sec]
end
+
+
+REG_RANGE=/(.*)\[(\d+)([+-])(\d+)\](.*)/
+
+def expand_range(param)
+ if match=param.match(REG_RANGE)
+ pre=match[1]
+ start=match[2]
+ operator=match[3]
+ last=match[4]
+ post=match[5]
+ size=0
+
+ result=Array.new
+
+ if operator=='-'
+ range=(start.to_i..last.to_i)
+ size=last.size
+ elsif operator=='+'
+ size=(start.to_i+last.to_i-1).to_s.size
+ range=(start.to_i..(start.to_i+last.to_i-1))
+ end
+
+ if start[0]==?0
+ range.each do |num|
+ result< {
- :name => "HID",
+ :id => {
+ :name => "ID",
:desc => "ONE identifier for host",
:size => 4,
:proc => lambda {|d,e| d.id }
@@ -99,7 +98,7 @@ ShowTableHost={
},
- :default => [:hid, :name, :rvm, :tcpu, :fcpu, :acpu, :tmem, :fmem, :stat]
+ :default => [:id, :name, :rvm, :tcpu, :fcpu, :acpu, :tmem, :fmem, :stat]
}
class HostShow
@@ -210,7 +209,7 @@ def vms_in_host?(host_id)
exit -1
end
- host['host_shares/running_vms'].to_i
+ host['host_share/running_vms'].to_i
end
@@ -236,6 +235,8 @@ when "add", "create"
when "show"
check_parameters("show", 1)
+ #args=expand_args(ARGV)
+
host_id=get_host_id(ARGV[0])
host=OpenNebula::Host.new_with_id(host_id, get_one_client)
@@ -282,29 +283,34 @@ when "show"
when "delete"
check_parameters("delete", 1)
- host_id=get_host_id(ARGV[0])
-
- host = OpenNebula::Host.new_with_id(host_id,get_one_client)
+ args=expand_args(ARGV)
- rc = host.info
+ args.each do |param|
+ host_id=get_host_id(param)
+
+ host = OpenNebula::Host.new_with_id(host_id,get_one_client)
- if OpenNebula::is_error?(rc)
- puts rc.message
- exit -1
- end
+ rc = host.info
- if host['host_shares/running_vms'].to_i != 0
- puts "Host still has associated VMs. It will be disabled instead."
- result=host.disable
- if is_successful?(result)
- puts "Host disabled" if ops[:verbose]
- exit 0
+ if OpenNebula::is_error?(rc)
+ puts rc.message
+ exit -1
end
- else
- result=host.delete
- if is_successful?(result)
- puts "Host deleted" if ops[:verbose]
- exit 0
+
+ if host['host_share/running_vms'].to_i != 0
+ puts "Host still has associated VMs. It will be disabled instead."
+ result=host.disable
+ if is_successful?(result)
+ puts "Host disabled" if ops[:verbose]
+ else
+ break
+ end
+ else
+ result=host.delete
+ if is_successful?(result)
+ puts "Host deleted" if ops[:verbose]
+ exit 0
+ end
end
end
@@ -326,22 +332,32 @@ when "top"
when "enable"
check_parameters("enable", 1)
- host_id=get_host_id(ARGV[0])
- host = OpenNebula::Host.new_with_id(host_id,get_one_client)
- result=host.enable
- if is_successful?(result)
- puts "Host enabled" if ops[:verbose]
- exit 0
+ args=expand_args(ARGV)
+
+ args.each do |param|
+ host_id=get_host_id(param)
+ host = OpenNebula::Host.new_with_id(host_id,get_one_client)
+ result=host.enable
+ if is_successful?(result)
+ puts "Host enabled" if ops[:verbose]
+ else
+ break
+ end
end
when "disable"
check_parameters("disable", 1)
- host_id=get_host_id(ARGV[0])
- host = OpenNebula::Host.new_with_id(host_id,get_one_client)
- result=host.disable
- if is_successful?(result)
- puts "Host disabled" if ops[:verbose]
- exit 0
+ args=expand_args(ARGV)
+
+ args.each do |param|
+ host_id=get_host_id(param)
+ host = OpenNebula::Host.new_with_id(host_id,get_one_client)
+ result=host.disable
+ if is_successful?(result)
+ puts "Host disabled" if ops[:verbose]
+ else
+ break
+ end
end
else
diff --git a/src/client/ruby/oneuser b/src/client/ruby/oneuser
index a6ed0a464e..8bbeff18ce 100755
--- a/src/client/ruby/oneuser
+++ b/src/client/ruby/oneuser
@@ -1,8 +1,7 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@@ -34,14 +33,14 @@ require 'command_parse'
ShowTableUP={
- :uid => {
- :name => "UID",
+ :id => {
+ :name => "ID",
:desc => "ONE identifier for user",
:size => 4,
:proc => lambda {|d,e| d.id }
},
- :name => {
- :name => "NAME",
+ :user => {
+ :name => "USER",
:desc => "name of the user",
:size => 15,
:left => true,
@@ -61,7 +60,7 @@ ShowTableUP={
:proc => lambda {|d,e| d[:enabled] }
},
- :default => [:uid, :name, :password, :enable]
+ :default => [:id, :user, :password, :enable]
}
class UPShow
@@ -123,7 +122,7 @@ Commands:
oneuser create username password
* delete (Removes a user)
- oneuser delete
+ oneuser delete
* list (Lists all the users in the pool)
oneuser list
@@ -161,34 +160,38 @@ when "create"
sha_password = Digest::SHA1.hexdigest(ARGV[1])
result=user.allocate(ARGV[0],sha_password)
if !OpenNebula.is_error?(result)
- puts "UID: " + user.id.to_s if ops[:verbose]
+ puts "ID: " + user.id.to_s if ops[:verbose]
exit 0
end
when "delete"
check_parameters("delete", 1)
- user_id=get_user_id(ARGV[0])
+ args=expand_args(ARGV)
- # Check if the user has defined VM's
- vms=false
- vmpool=OpenNebula::VirtualMachinePool.new(
- get_one_client, user_id)
- vmpool.info
- vmpool.each{ vms=true ; break }
+ args.each do |param|
+ user_id=get_user_id(param)
- if vms
- puts "The user still has VM's defined, type YES if you are sure you"
- print "want to delete this user: "
- answer=STDIN.gets.strip
- exit -1 if answer != 'YES'
- end
+ # Check if the user has defined VM's
+ vms=false
+ vmpool=OpenNebula::VirtualMachinePool.new(
+ get_one_client, user_id)
+ vmpool.info
+ vmpool.each{ vms=true ; break }
- user=OpenNebula::User.new(
- OpenNebula::User.build_xml(user_id), get_one_client)
- result=user.delete
- if !OpenNebula.is_error?(result)
- puts "User deleted" if ops[:verbose]
- exit 0
+ if vms
+ puts "The user #{param} still has VM's defined, "+
+ "type YES if you are sure you"
+ print "want to delete this user: "
+ answer=STDIN.gets.strip
+ exit -1 if answer != 'YES'
+ end
+
+ user=OpenNebula::User.new(
+ OpenNebula::User.build_xml(user_id), get_one_client)
+ result=user.delete
+ if !OpenNebula.is_error?(result)
+ puts "User deleted" if ops[:verbose]
+ end
end
when "list"
diff --git a/src/client/ruby/onevm b/src/client/ruby/onevm
index 8c3dc2bd76..9e40e67632 100755
--- a/src/client/ruby/onevm
+++ b/src/client/ruby/onevm
@@ -1,8 +1,7 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@@ -48,7 +47,7 @@ ShowTableVM={
d.name
}
},
- :username => {
+ :user=> {
:name => "USER",
:desc => "Name of the owner",
:size => 8,
@@ -93,7 +92,7 @@ ShowTableVM={
:proc => lambda {|d,e| str_running_time(d) }
},
- :default => [:id, :username, :name, :stat, :cpu, :mem, :hostname, :time]
+ :default => [:id, :user, :name, :stat, :cpu, :mem, :hostname, :time]
}
ShowTableHistory={
@@ -356,7 +355,7 @@ Commands:
a, all --> all the known VMs
m, mine --> the VMs belonging to the user in ONE_AUTH
uid --> VMs of the user identified by this uid
- username --> VMs of the user identified by the username
+ user--> VMs of the user identified by the username
* show (Gets information about a specific VM)
onevm show
@@ -436,136 +435,191 @@ when "submit", "create"
when "deploy"
check_parameters("deploy", 2)
- vm_id=get_vm_id(ARGV[0])
- host_id=get_host_id(ARGV[1])
+ host_id=get_host_id(ARGV[-1])
+ args=expand_args(ARGV[0..-2])
- vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
+ args.each do |param|
+ vm_id=get_vm_id(param)
- result=vm.deploy(host_id)
- if is_successful?(result)
- puts "Deploying VM" if ops[:verbose]
- exit 0
+ vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
+
+ result=vm.deploy(host_id)
+ if is_successful?(result)
+ puts "Deploying VM" if ops[:verbose]
+ else
+ break
+ end
end
when "shutdown"
check_parameters("shutdown", 1)
- vm_id=get_vm_id(ARGV[0])
+ args=expand_args(ARGV)
+
+ args.each do |param|
+ vm_id=get_vm_id(param)
- vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
- result=vm.shutdown
- if is_successful?(result)
- puts "Shutting down VM" if ops[:verbose]
- exit 0
+ vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
+ result=vm.shutdown
+ if is_successful?(result)
+ puts "Shutting down VM" if ops[:verbose]
+ else
+ break
+ end
end
when "livemigrate"
check_parameters("livemigrate", 2)
- vm_id=get_vm_id(ARGV[0])
- host_id=get_host_id(ARGV[1])
+ host_id=get_host_id(ARGV[-1])
+ args=expand_args(ARGV[0..-2])
- vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
+ args.each do |param|
+ vm_id=get_vm_id(param)
- result=vm.live_migrate(host_id)
- if is_successful?(result)
- puts "Migrating VM" if ops[:verbose]
- exit 0
+ vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
+
+ result=vm.live_migrate(host_id)
+ if is_successful?(result)
+ puts "Migrating VM" if ops[:verbose]
+ else
+ break
+ end
end
when "migrate"
check_parameters("migrate", 2)
- vm_id=get_vm_id(ARGV[0])
- host_id=get_host_id(ARGV[1])
+ host_id=get_host_id(ARGV[-1])
+ args=expand_args(ARGV[0..-2])
- vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
+ args.each do |param|
+ vm_id=get_vm_id(param)
- result=vm.migrate(host_id)
- if is_successful?(result)
- puts "Migrating VM" if ops[:verbose]
- exit 0
+ vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
+
+ result=vm.migrate(host_id)
+ if is_successful?(result)
+ puts "Migrating VM" if ops[:verbose]
+ else
+ break
+ end
end
when "hold"
check_parameters("hold", 1)
- vm_id=get_vm_id(ARGV[0])
+ args=expand_args(ARGV)
- vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
+ args.each do |param|
+ vm_id=get_vm_id(param)
- result=vm.hold
- if is_successful?(result)
- puts "Setting VM to hold state" if ops[:verbose]
- exit 0
+ vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
+
+ result=vm.hold
+ if is_successful?(result)
+ puts "Setting VM to hold state" if ops[:verbose]
+ else
+ break
+ end
end
when "release"
check_parameters("release", 1)
- vm_id=get_vm_id(ARGV[0])
+ args=expand_args(ARGV)
- vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
+ args.each do |param|
+ vm_id=get_vm_id(param)
- result=vm.release
- if is_successful?(result)
- puts "Releasing VM" if ops[:verbose]
- exit 0
+ vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
+
+ result=vm.release
+ if is_successful?(result)
+ puts "Releasing VM" if ops[:verbose]
+ else
+ break
+ end
end
when "stop"
check_parameters("stop", 1)
- vm_id=get_vm_id(ARGV[0])
+ args=expand_args(ARGV)
- vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
+ args.each do |param|
+ vm_id=get_vm_id(param)
- result=vm.stop
- if is_successful?(result)
- puts "Stopping VM" if ops[:verbose]
- exit 0
+ vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
+
+ result=vm.stop
+ if is_successful?(result)
+ puts "Stopping VM" if ops[:verbose]
+ else
+ break
+ end
end
when "cancel"
check_parameters("cancel", 1)
- vm_id=get_vm_id(ARGV[0])
+ args=expand_args(ARGV)
- vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
-
- result=vm.cancel
- if is_successful?(result)
- puts "Cancelling VM" if ops[:verbose]
- exit 0
+ args.each do |param|
+ vm_id=get_vm_id(param)
+
+ vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
+
+ result=vm.cancel
+ if is_successful?(result)
+ puts "Cancelling VM" if ops[:verbose]
+ else
+ break
+ end
end
when "suspend"
check_parameters("suspend", 1)
- vm_id=get_vm_id(ARGV[0])
+ args=expand_args(ARGV)
- vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
+ args.each do |param|
+ vm_id=get_vm_id(param)
- result=vm.suspend
- if is_successful?(result)
- puts "Suspending VM" if ops[:verbose]
- exit 0
+ vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
+
+ result=vm.suspend
+ if is_successful?(result)
+ puts "Suspending VM" if ops[:verbose]
+ else
+ break
+ end
end
when "resume"
check_parameters("resume", 1)
- vm_id=get_vm_id(ARGV[0])
+ args=expand_args(ARGV)
- vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
+ args.each do |param|
+ vm_id=get_vm_id(param)
- result=vm.resume
- if is_successful?(result)
- puts "Resuming VM" if ops[:verbose]
- exit 0
+ vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
+
+ result=vm.resume
+ if is_successful?(result)
+ puts "Resuming VM" if ops[:verbose]
+ else
+ break
+ end
end
when "restart"
check_parameters("restart", 1)
- vm_id=get_vm_id(ARGV[0])
+ args=expand_args(ARGV)
- vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
+ args.each do |param|
+ vm_id=get_vm_id(param)
- result=vm.restart
- if is_successful?(result)
- puts "Restarting VM" if ops[:verbose]
- exit 0
+ vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
+
+ result=vm.restart
+ if is_successful?(result)
+ puts "Restarting VM" if ops[:verbose]
+ else
+ break
+ end
end
when "list"
@@ -602,62 +656,71 @@ when "history"
when "delete"
check_parameters("delete", 1)
- vm_id=get_vm_id(ARGV[0])
+ args=expand_args(ARGV)
- vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
+ args.each do |param|
+ vm_id=get_vm_id(param)
- result=vm.finalize
- if is_successful?(result)
- puts "VM correctly deleted" if ops[:verbose]
- exit 0
+ vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
+
+ result=vm.finalize
+ if is_successful?(result)
+ puts "VM correctly deleted" if ops[:verbose]
+ else
+ break
+ end
end
when "show"
check_parameters("get_info", 1)
- vm_id=get_vm_id(ARGV[0])
+ args=expand_args(ARGV)
+
+ args.each do |param|
+
+ vm_id=get_vm_id(param)
- vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
- vm.info
+ vm=OpenNebula::VirtualMachine.new_with_id(vm_id, get_one_client)
+ vm.info
- if !ops[:xml]
- str="%-15s: %-20s"
- str_h1="%-80s"
+ if !ops[:xml]
+ str="%-15s: %-20s"
+ str_h1="%-80s"
- print_header(str_h1, "VIRTUAL MACHINE #{vm[:id]} INFORMATION", true)
+ print_header(str_h1, "VIRTUAL MACHINE #{vm[:id]} INFORMATION", true)
- puts str % ["ID", vm[:id]]
- puts str % ["NAME", vm[:name]]
- puts str % ["STATE", vm.state_str]
- puts str % ["LCM_STATE", vm.lcm_state_str]
+ puts str % ["ID", vm[:id]]
+ puts str % ["NAME", vm[:name]]
+ puts str % ["STATE", vm.state_str]
+ puts str % ["LCM_STATE", vm.lcm_state_str]
- value=vm[:stime].to_i
- if value==0
- value='-'
+ value=vm[:stime].to_i
+ if value==0
+ value='-'
+ else
+ value=Time.at(value).strftime("%m/%d %H:%M:%S")
+ end
+ puts str % ["START TIME", value]
+
+ value=vm[:etime].to_i
+ if value==0
+ value='-'
+ else
+ value=Time.at(value).strftime("%m/%d %H:%M:%S")
+ end
+ puts str % ["END TIME", value]
+
+ value=vm[:deploy_id]
+ puts str % ["DEPLOY ID:", value=="" ? "-" : value]
+
+ puts
+
+ print_header(str_h1,"VIRTUAL MACHINE TEMPLATE",false)
+
+ puts vm.template_str
else
- value=Time.at(value).strftime("%m/%d %H:%M:%S")
+ puts vm.to_xml
end
- puts str % ["START TIME", value]
-
- value=vm[:etime].to_i
- if value==0
- value='-'
- else
- value=Time.at(value).strftime("%m/%d %H:%M:%S")
- end
- puts str % ["END TIME", value]
-
- value=vm[:deploy_id]
- puts str % ["DEPLOY ID:", value=="" ? "-" : value]
-
- puts
-
- print_header(str_h1,"VIRTUAL MACHINE TEMPLATE",false)
-
- puts vm.template_str
- else
- puts vm.to_xml
- end
-
+ end
else
onevm_opts.print_help
exit -1
diff --git a/src/client/ruby/onevnet b/src/client/ruby/onevnet
index 7072eb9b4a..55171dcbd6 100755
--- a/src/client/ruby/onevnet
+++ b/src/client/ruby/onevnet
@@ -1,8 +1,7 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@@ -34,8 +33,8 @@ require 'command_parse'
ShowTableVN={
- :nid => {
- :name => "NID",
+ :id => {
+ :name => "ID",
:desc => "ONE identifier for virtual network",
:size => 4,
:proc => lambda {|d,e| d.id }
@@ -47,7 +46,7 @@ ShowTableVN={
:left => true,
:proc => lambda {|d,e| d.name }
},
- :username => {
+ :user => {
:name => "USER",
:desc => "Username of the virtual network owner",
:size => 8,
@@ -87,7 +86,7 @@ ShowTableVN={
:proc => lambda {|d,e| d["TOTAL_LEASES"] }
},
- :default => [:nid, :username, :name, :type, :bridge, :totalleases]
+ :default => [:id, :user, :name, :type, :bridge, :totalleases]
}
class VNShow
@@ -169,7 +168,7 @@ Commands:
a, all --> all the known VNs
m, mine --> the VNs belonging to the user in ONE_AUTH
uid --> VNs of the user identified by this uid
- username --> VNs of the user identified by the username
+ user --> VNs of the user identified by the username
EOT
def text_commands
@@ -203,53 +202,61 @@ when "create"
template=File.read(ARGV[0])
result=vn.allocate(template)
if !OpenNebula.is_error?(result)
- puts "NID: " + vn.id.to_s if ops[:verbose]
+ puts "ID: " + vn.id.to_s if ops[:verbose]
exit 0
end
when "show"
check_parameters("show", 1)
- vn_id=get_vn_id(ARGV[0])
- vn=OpenNebula::VirtualNetwork.new_with_id(vn_id, get_one_client)
- result=vn.info
- if is_successful?(result)
- if !ops[:xml]
- str_h1="%-80s"
- str="%-10s: %-20s"
- print_header(str_h1,
- "VIRTUAL NETWORK #{vn.id.to_s} INFORMATION",true)
+ args=expand_args(ARGV)
+
+ args.each do |param|
+ vn_id=get_vn_id(param)
+ vn=OpenNebula::VirtualNetwork.new_with_id(vn_id, get_one_client)
+ result=vn.info
+ if is_successful?(result)
+ if !ops[:xml]
+ str_h1="%-80s"
+ str="%-10s: %-20s"
+ print_header(str_h1,
+ "VIRTUAL NETWORK #{vn.id.to_s} INFORMATION",true)
- puts str % ["ID: ",vn.id.to_s]
- puts str % ["UID: ",vn["UID"]]
- puts
- print_header(str_h1,"VIRTUAL NETWORK TEMPLATE",false)
-
- puts vn.template_str(false)
-
- leases_str = vn.template_like_str('/VNET/LEASES', false)
-
- if !leases_str.empty?
+ puts str % ["ID: ",vn.id.to_s]
+ puts str % ["UID: ",vn["UID"]]
puts
- print_header(str_h1,"LEASES INFORMATION",false)
- puts leases_str
+ print_header(str_h1,"VIRTUAL NETWORK TEMPLATE",false)
+
+ puts vn.template_str(false)
+
+ leases_str = vn.template_like_str('/VNET/LEASES', false)
+
+ if !leases_str.empty?
+ puts
+ print_header(str_h1,"LEASES INFORMATION",false)
+ puts leases_str
+ end
+ else
+ puts vn.to_xml
end
else
- puts vn.to_xml
+ puts "Error: "+result.message
+ break
end
- else
- puts "Error: "+result.message
- exit -1
end
when "delete"
check_parameters("delete", 1)
- vn_id=get_vn_id(ARGV[0])
- vn=OpenNebula::VirtualNetwork.new(
- OpenNebula::VirtualNetwork.build_xml(vn_id), get_one_client)
- result=vn.delete
- if !OpenNebula.is_error?(result)
- puts "Virtual Network deleted" if ops[:verbose]
- exit 0
+ args=expand_args(ARGV)
+
+ args.each do |param|
+ vn_id=get_vn_id(param)
+ vn=OpenNebula::VirtualNetwork.new(
+ OpenNebula::VirtualNetwork.build_xml(vn_id), get_one_client)
+ result=vn.delete
+ if !OpenNebula.is_error?(result)
+ puts "Virtual Network deleted" if ops[:verbose]
+ break
+ end
end
when "list"
diff --git a/src/cloud/common/CloudClient.rb b/src/cloud/common/CloudClient.rb
new file mode 100644
index 0000000000..17c6dc9e66
--- /dev/null
+++ b/src/cloud/common/CloudClient.rb
@@ -0,0 +1,121 @@
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
+
+require 'rubygems'
+require 'uri'
+
+require 'digest'
+require 'net/https'
+
+begin
+ require 'curb'
+ CURL_LOADED=true
+rescue LoadError
+ CURL_LOADED=false
+end
+
+begin
+ require 'net/http/post/multipart'
+rescue LoadError
+end
+
+###############################################################################
+# The CloudClient module contains general functionality to implement a
+# Cloud Client
+###############################################################################
+module CloudClient
+ # #########################################################################
+ # Default location for the authentication file
+ # #########################################################################
+ DEFAULT_AUTH_FILE = ENV["HOME"]+"/.one/one_auth"
+
+ # #########################################################################
+ # Gets authorization credentials from ONE_AUTH or default
+ # auth file.
+ #
+ # Raises an error if authorization is not found
+ # #########################################################################
+ def self.get_one_auth
+ if ENV["ONE_AUTH"] and !ENV["ONE_AUTH"].empty? and
+ File.file?(ENV["ONE_AUTH"])
+ one_auth=File.read(ENV["ONE_AUTH"]).strip.split(':')
+ elsif File.file?(DEFAULT_AUTH_FILE)
+ one_auth=File.read(DEFAULT_AUTH_FILE).strip.split(':')
+ else
+ raise "No authorization data present"
+ end
+
+ raise "Authorization data malformed" if one_auth.length < 2
+
+ one_auth
+ end
+
+ # #########################################################################
+ # Starts an http connection and calls the block provided. SSL flag
+ # is set if needed.
+ # #########################################################################
+ def self.http_start(url, &block)
+ http = Net::HTTP.new(url.host, url.port)
+ if url.scheme=='https'
+ http.use_ssl = true
+ http.verify_mode=OpenSSL::SSL::VERIFY_NONE
+ end
+
+ begin
+ http.start do |connection|
+ block.call(connection)
+ end
+ rescue Errno::ECONNREFUSED => e
+ str = "Error connecting to server (#{e.to_s})."
+ str << "Server: #{url.host}:#{url.port}"
+
+ return CloudClient::Error.new(str)
+ end
+ end
+
+ # #########################################################################
+ # The Error Class represents a generic error in the Cloud Client
+ # library. It contains a readable representation of the error.
+ # #########################################################################
+ class Error
+ attr_reader :message
+
+ # +message+ a description of the error
+ def initialize(message=nil)
+ @message=message
+ end
+
+ def to_s()
+ @message
+ end
+ end
+
+ # #########################################################################
+ # Returns true if the object returned by a method of the OpenNebula
+ # library is an Error
+ # #########################################################################
+ def self.is_error?(value)
+ value.class==CloudClient::Error
+ end
+end
+
+# Command line help functions
+module CloudCLI
+ # Returns the command name
+ def cmd_name
+ File.basename($0)
+ end
+end
diff --git a/src/cloud/common/CloudServer.rb b/src/cloud/common/CloudServer.rb
new file mode 100755
index 0000000000..f4d4ea3446
--- /dev/null
+++ b/src/cloud/common/CloudServer.rb
@@ -0,0 +1,152 @@
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
+
+require 'repo_manager'
+require 'Configuration'
+require 'OpenNebula'
+require 'pp'
+
+##############################################################################
+# This class represents a generic Cloud Server using the OpenNebula Cloud
+# API (OCA). Any cloud implementation should derive from this class
+##############################################################################
+class CloudServer
+
+ ##########################################################################
+ # Public attributes
+ ##########################################################################
+ attr_reader :config
+ attr_reader :one_client
+
+ # Initializes the Cloud server based on a config file
+ # config_file:: _String_ for the server. MUST include the following
+ # variables:
+ # USER
+ # PASSWORD
+ # VM_TYPE
+ # IMAGE_DIR
+ # DATABASE
+ def initialize(config_file)
+
+ # --- Load the Cloud Server configuration file ---
+
+ @config = Configuration.new(config_file)
+ @auth = "#{@config[:user]}:#{@config[:password]}"
+
+ @instance_types = Hash.new
+
+ if @config[:vm_type].kind_of?(Array)
+ @config[:vm_type].each {|type|
+ @instance_types[type['NAME']]=type
+ }
+ else
+ @instance_types[@config[:vm_type]['NAME']]=@config[:vm_type]
+ end
+
+ # --- Start a Repository Manager ---
+
+ @rm = RepoManager.new(@config[:database])
+ Image.image_dir = @config[:image_dir]
+
+ # --- Start an OpenNebula Session ---
+
+ @one_client = Client.new(@auth)
+ @user_pool = UserPool.new(@one_client)
+ end
+
+ #
+ # Prints the configuration of the server
+ #
+ def print_configuration
+ puts "--------------------------------------"
+ puts " Server configuration "
+ puts "--------------------------------------"
+ pp @config
+
+ puts "--------------------------------------"
+ puts " Registered Instance Types "
+ puts "--------------------------------------"
+ pp @instance_types
+ end
+
+ ###########################################################################
+ # USER and OpenNebula Session Methods
+ ###########################################################################
+
+ # Generates an OpenNebula Session for the given user
+ # user:: _Hash_ the user information
+ # [return] an OpenNebula client session
+ def one_client_user(user)
+ client = Client.new("dummy:dummy")
+ client.one_auth = "#{user[:name]}:#{user[:password]}"
+
+ return client
+ end
+
+ # Authenticates a user
+ # name:: _String_ of the user
+ # password:: _String_ of the user
+ # [return] true if authenticated
+ def authenticate?(name, password)
+ user = get_user(name)
+
+ return user && user.password == password
+ end
+
+ # Gets the data associated with a user
+ # name:: _String_ the name of the user
+ # [return] _Hash_ with the user data
+ def get_user(name)
+ user = nil
+
+ @user_pool.info
+ @user_pool.each{ |u|
+ if u.name==name
+ user=Hash.new
+
+ user[:id] = u.id
+ user[:name] = u.name
+ user[:password] = u[:password]
+ end
+ }
+ return user
+ end
+
+
+ ###########################################################################
+ # Repository Methods
+ ###########################################################################
+
+ # Adds a new image to the repository and deletes the temp_file
+ # uid:: _Integer_ owner of the image
+ # path:: _String_ path of the tmp file
+ # metadata:: Additional metadata for the file
+ # [return] _Image_ Newly created image object
+ def add_image(uid, file, metadata={})
+ image = @rm.add(uid,file.path,metadata)
+ file.unlink
+
+ return image
+ end
+
+ # Gets an image from the repository
+ # image_id:: _Integer_ Image identifier
+ # [return] _Image_ Image object
+ def get_image(image_id)
+ return @rm.get(image_id)
+ end
+end
+
diff --git a/src/cloud/common/Configuration.rb b/src/cloud/common/Configuration.rb
new file mode 100644
index 0000000000..1502bd5e88
--- /dev/null
+++ b/src/cloud/common/Configuration.rb
@@ -0,0 +1,115 @@
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
+
+###############################################################################
+# The Configuration Class represents a simple configuration file for the
+# Cloud servers. It does not check syntax.
+###############################################################################
+class Configuration
+
+ ###########################################################################
+ # Patterns to parse the Configuration File
+ ###########################################################################
+
+ NAME_REG =/[\w\d_-]+/
+ VARIABLE_REG =/\s*(#{NAME_REG})\s*=\s*/
+
+ SIMPLE_VARIABLE_REG =/#{VARIABLE_REG}([^\[]+?)(#.*)?/
+ SINGLE_VARIABLE_REG =/^#{SIMPLE_VARIABLE_REG}$/
+ ARRAY_VARIABLE_REG =/^#{VARIABLE_REG}\[(.*?)\]/m
+
+ ###########################################################################
+ ###########################################################################
+
+ def initialize(file)
+ @conf=parse_conf(file)
+ end
+
+ def add_configuration_value(key,value)
+ add_value(@conf,key,value)
+ end
+
+ def [](key)
+ @conf[key.to_s.upcase]
+ end
+
+ ###########################################################################
+ ###########################################################################
+
+private
+
+ #
+ #
+ #
+ def add_value(conf, key, value)
+ if conf[key]
+ if !conf[key].kind_of?(Array)
+ conf[key]=[conf[key]]
+ end
+ conf[key]< e
- puts "#{$0}: #{e.message}"
+ puts "#{cmd_name}: #{e.message}"
exit -1
end
rc = ec2_client.describe_images()
-if OpenNebula::is_error?(rc)
- puts "#{$0}: #{rc.message}"
+if CloudClient::is_error?(rc)
+ puts "#{cmd_name}: #{rc.message}"
exit -1
end
@@ -118,14 +119,11 @@ if headers
puts "------------------------------------------------------------------------------"
end
-images.each { |img|
+if images
+ images.each { |img|
puts fmt % [img['imageOwnerId'],img['imageId'],img['imageLocation']]
}
+end
exit 0
-
-
-
-
-
diff --git a/src/cloud/ec2/econe-describe-instances b/src/cloud/ec2/bin/econe-describe-instances
similarity index 87%
rename from src/cloud/ec2/econe-describe-instances
rename to src/cloud/ec2/bin/econe-describe-instances
index 5103fc6d4d..a171c12e5e 100755
--- a/src/cloud/ec2/econe-describe-instances
+++ b/src/cloud/ec2/bin/econe-describe-instances
@@ -3,12 +3,11 @@
# == Synopsis
# econe-describe-instances
#
-# List and describe previously uploaded images of a user for use
-# with an OpenNebula Cloud.
+# List and describe running instances
#
# == Usage
#
-# econe-describe-images [OPTIONS]
+# econe-describe-instances [OPTIONS]
#
# -h, --help:
# show help
@@ -26,8 +25,7 @@
# Display column headers
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@@ -50,15 +48,16 @@ else
RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby"
end
-
$: << RUBY_LIB_LOCATION
-$: << RUBY_LIB_LOCATION+"/econe"
+$: << RUBY_LIB_LOCATION+"/cloud"
-require 'EC2QueryClient'
+require 'econe/EC2QueryClient'
+require 'CloudClient'
require 'getoptlong'
require 'rdoc/usage'
require 'pp'
+include CloudCLI
opts = GetoptLong.new(
['--help', '-h',GetoptLong::NO_ARGUMENT],
@@ -98,14 +97,14 @@ auth = "#{access}:#{secret}" if secret && access
begin
ec2_client = EC2QueryClient::Client.new(auth,url)
rescue Exception => e
- puts "#{$0}: #{e.message}"
+ puts "#{cmd_name}: #{e.message}"
exit -1
end
rc = ec2_client.describe_instances()
-if OpenNebula::is_error?(rc)
- puts "#{$0}: #{rc.message}"
+if CloudClient::is_error?(rc)
+ puts "#{cmd_name}: #{rc.message}"
exit -1
end
@@ -119,14 +118,9 @@ if headers
puts "------------------------------------------------------------------------------------------------------------"
end
-instances.each { |img|
+if instances
+ instances.each { |img|
puts fmt % [owner, img['instanceId'],img['imageId'],img['instanceState']['name'],img['dnsName'],img['instanceType']]
}
-
+end
exit 0
-
-
-
-
-
-
diff --git a/src/cloud/ec2/econe-register b/src/cloud/ec2/bin/econe-register
similarity index 89%
rename from src/cloud/ec2/econe-register
rename to src/cloud/ec2/bin/econe-register
index 2aed2631d4..ce30d39fb4 100755
--- a/src/cloud/ec2/econe-register
+++ b/src/cloud/ec2/bin/econe-register
@@ -31,8 +31,7 @@
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@@ -55,15 +54,16 @@ else
RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby"
end
-
$: << RUBY_LIB_LOCATION
-$: << RUBY_LIB_LOCATION+"/econe"
+$: << RUBY_LIB_LOCATION+"/cloud"
-require 'EC2QueryClient'
+require 'econe/EC2QueryClient'
+require 'CloudClient'
require 'getoptlong'
require 'rdoc/usage'
require 'pp'
+include CloudCLI
opts = GetoptLong.new(
['--help', '-h',GetoptLong::NO_ARGUMENT],
@@ -101,7 +101,7 @@ end
image_id = ARGV.shift
if !image_id
- puts "#{$0}: missing ImageId parameter"
+ puts "#{cmd_name}: missing ImageId parameter"
exit -1
end
@@ -110,23 +110,17 @@ auth = "#{access}:#{secret}" if secret && access
begin
ec2_client = EC2QueryClient::Client.new(auth,url)
rescue Exception => e
- puts "#{$0}: #{e.message}"
+ puts "#{cmd_name}: #{e.message}"
exit -1
end
rc = ec2_client.register_image(image_id)
-if OpenNebula::is_error?(rc)
- puts "#{$0}: #{rc.message}"
+if CloudClient::is_error?(rc)
+ puts "#{cmd_name}: #{rc.message}"
exit -1
end
puts "Success: ImageId #{rc['imageId']}"
exit 0
-
-
-
-
-
-
diff --git a/src/cloud/ec2/econe-run-instances b/src/cloud/ec2/bin/econe-run-instances
similarity index 87%
rename from src/cloud/ec2/econe-run-instances
rename to src/cloud/ec2/bin/econe-run-instances
index 59b4e68520..e2d33ecf2c 100755
--- a/src/cloud/ec2/econe-run-instances
+++ b/src/cloud/ec2/bin/econe-run-instances
@@ -3,12 +3,11 @@
# == Synopsis
# econe-run-instances
#
-# List and describe previously uploaded images of a user for use
-# with an OpenNebula Cloud.
+# Runs an instance of a particular image
#
# == Usage
#
-# econe-describe-images [OPTIONS]
+# econe-run-instances [OPTIONS]
#
# -h, --help:
# show help
@@ -28,8 +27,7 @@
# Display column headers
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@@ -54,13 +52,15 @@ end
$: << RUBY_LIB_LOCATION
-$: << RUBY_LIB_LOCATION+"/econe"
+$: << RUBY_LIB_LOCATION+"/cloud"
-require 'EC2QueryClient'
+require 'econe/EC2QueryClient'
+require 'CloudClient'
require 'getoptlong'
require 'rdoc/usage'
require 'pp'
+include CloudCLI
opts = GetoptLong.new(
['--help', '-h',GetoptLong::NO_ARGUMENT],
@@ -102,7 +102,7 @@ end
image_id = ARGV.shift
if !image_id
- puts "#{$0}: missing IMAGE-ID parameter"
+ puts "#{cmd_name}: missing IMAGE-ID parameter"
exit -1
end
@@ -115,14 +115,14 @@ auth = "#{access}:#{secret}" if secret && access
begin
ec2_client = EC2QueryClient::Client.new(auth,url)
rescue Exception => e
- puts "#{$0}: #{e.message}"
+ puts "#{cmd_name}: #{e.message}"
exit -1
end
rc = ec2_client.run_instances(image_id,type)
-if OpenNebula::is_error?(rc)
- puts "#{$0}: #{rc.message}"
+if CloudClient::is_error?(rc)
+ puts "#{cmd_name}: #{rc.message}"
exit -1
end
@@ -140,9 +140,3 @@ images.each { |img|
}
exit 0
-
-
-
-
-
-
diff --git a/src/cloud/ec2/bin/econe-server b/src/cloud/ec2/bin/econe-server
new file mode 100755
index 0000000000..fdb285c75d
--- /dev/null
+++ b/src/cloud/ec2/bin/econe-server
@@ -0,0 +1,123 @@
+#! /bin/sh
+
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
+
+if [ -z "$ONE_LOCATION" ]; then
+ ECONE_PID=/var/run/one/econe-server.pid
+ ECONE_SERVER=/usr/lib/one/ruby/cloud/econe/econe-server.rb
+ ECONE_LOCK_FILE=/var/lock/one/.econe.lock
+ ECONE_LOG=/var/log/one/econe-server.log
+ ECONE_ETC=/etc/one/econe.conf
+else
+ ECONE_PID=$ONE_LOCATION/var/econe-server.pid
+ ECONE_SERVER=$ONE_LOCATION/lib/ruby/cloud/econe/econe-server.rb
+ ECONE_LOCK_FILE=$ONE_LOCATION/var/.econe.lock
+ ECONE_LOG=$ONE_LOCATION/var/econe-server.log
+ ECONE_ETC=$ONE_LOCATION/etc/econe.conf
+fi
+
+setup()
+{
+ eval `grep ^IMAGE_DIR= $ECONE_ETC`
+ export TMPDIR=$IMAGE_DIR/tmp
+ mkdir -p $TMPDIR
+
+ if [ -f $ECONE_LOCK_FILE ]; then
+ if [ -f $ECONE_PID ]; then
+ ONEPID=`cat $ECONE_PID`
+ ps $ECONE_PID > /dev/null 2>&1
+ if [ $? -eq 0 ]; then
+ echo "econe-server is still running (PID:$ECONE_PID). Please try 'occi-server stop' first."
+ exit 1
+ fi
+ fi
+ echo "Stale .lock detected. Erasing it."
+ rm $LOCK_FILE
+ fi
+}
+
+start()
+{
+ if [ ! -f "$ECONE_SERVER" ]; then
+ echo "Can not find $ECONE_SERVER."
+ exit 1
+ fi
+
+ # Start the econe-server daemon
+ ruby $ECONE_SERVER > $ECONE_LOG 2>&1 &
+
+ LASTRC=$?
+ LASTPID=$!
+
+ if [ $LASTRC -ne 0 ]; then
+ echo "Error executing $ECONE_SERVER"
+ exit 1
+ else
+ echo $LASTPID > $ECONE_PID
+ fi
+
+ sleep 1
+ ps $LASTPID > /dev/null 2>&1
+
+ if [ $? -ne 0 ]; then
+ echo "Error executing $ECONE_SERVER."
+ exit 1
+ fi
+
+ echo "econe-server started"
+}
+
+#
+# Function that stops the daemon/service
+#
+stop()
+{
+ if [ ! -f $ECONE_PID ]; then
+ echo "Couldn't find econe-server process pid."
+ exit 1
+ fi
+
+ # Kill the econe-server daemon
+
+ kill -INT `cat $ECONE_PID` > /dev/null 2>&1
+
+ # Remove pid files
+
+ rm -f $ECONE_PID > /dev/null 2>&1
+
+ echo "econe-server stopped"
+}
+
+
+case "$1" in
+ start)
+ setup
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ *)
+ echo "Usage: econe-server {start|stop}" >&2
+ exit 3
+ ;;
+esac
+
+
+
+
+
diff --git a/src/cloud/ec2/econe-terminate-instances b/src/cloud/ec2/bin/econe-terminate-instances
similarity index 89%
rename from src/cloud/ec2/econe-terminate-instances
rename to src/cloud/ec2/bin/econe-terminate-instances
index 1b7c302077..bf1e42c34d 100755
--- a/src/cloud/ec2/econe-terminate-instances
+++ b/src/cloud/ec2/bin/econe-terminate-instances
@@ -27,8 +27,7 @@
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@@ -53,13 +52,15 @@ end
$: << RUBY_LIB_LOCATION
-$: << RUBY_LIB_LOCATION+"/econe"
+$: << RUBY_LIB_LOCATION+"/cloud"
-require 'EC2QueryClient'
+require 'econe/EC2QueryClient'
+require 'CloudClient'
require 'getoptlong'
require 'rdoc/usage'
require 'pp'
+include CloudCLI
opts = GetoptLong.new(
['--help', '-h',GetoptLong::NO_ARGUMENT],
@@ -95,7 +96,7 @@ end
instance = ARGV.shift
if !instance
- puts "#{$0}: missing INSTANCE-ID parameter"
+ puts "#{cmd_name}: missing INSTANCE-ID parameter"
exit -1
end
@@ -104,14 +105,14 @@ auth = "#{access}:#{secret}" if secret && access
begin
ec2_client = EC2QueryClient::Client.new(auth,url)
rescue Exception => e
- puts "#{$0}: #{e.message}"
+ puts "#{cmd_name}: #{e.message}"
exit -1
end
rc = ec2_client.terminate_instances(instance)
-if OpenNebula::is_error?(rc)
- puts "#{$0}: #{rc.message}"
+if CloudClient::is_error?(rc)
+ puts "#{cmd_name}: #{rc.message}"
exit -1
end
diff --git a/src/cloud/ec2/econe-upload b/src/cloud/ec2/bin/econe-upload
similarity index 82%
rename from src/cloud/ec2/econe-upload
rename to src/cloud/ec2/bin/econe-upload
index 89bc9ad591..6a4762b19d 100755
--- a/src/cloud/ec2/econe-upload
+++ b/src/cloud/ec2/bin/econe-upload
@@ -22,11 +22,13 @@
# --url , -U :
# Set url as the web service url to use
#
+# --multipart, -M:
+# Use 'multipart-post' library instead of Curb/Curl
+#
# IMAGE-PATH: Path to the image to upload
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@@ -49,27 +51,30 @@ else
RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby"
end
-
$: << RUBY_LIB_LOCATION
-$: << RUBY_LIB_LOCATION+"/econe"
+$: << RUBY_LIB_LOCATION+"/cloud"
-require 'EC2QueryClient'
+require 'econe/EC2QueryClient'
+require 'CloudClient'
require 'getoptlong'
require 'rdoc/usage'
require 'pp'
+include CloudCLI
opts = GetoptLong.new(
['--help', '-h',GetoptLong::NO_ARGUMENT],
['--access-key', '-K',GetoptLong::REQUIRED_ARGUMENT],
['--secret-key', '-S',GetoptLong::REQUIRED_ARGUMENT],
- ['--url', '-U',GetoptLong::REQUIRED_ARGUMENT]
+ ['--url', '-U',GetoptLong::REQUIRED_ARGUMENT],
+ ['--multipart', '-M',GetoptLong::NO_ARGUMENT]
)
url = nil
access = nil
secret = nil
auth = nil
+curb = true
begin
opts.each do |opt, arg|
@@ -82,6 +87,8 @@ begin
secret = arg
when '--url'
url = arg
+ when '--multipart'
+ curb = false
end
end
rescue Exception => e
@@ -91,7 +98,7 @@ end
image = ARGV.shift
if !image || !File.exists?(image)
- puts "#{$0}: missing IMAGE-PATH parameter or file not found"
+ puts "#{cmd_name}: missing IMAGE-PATH parameter or file not found"
exit -1
end
@@ -100,14 +107,14 @@ auth = "#{access}:#{secret}" if secret && access
begin
ec2_client = EC2QueryClient::Client.new(auth,url)
rescue Exception => e
- puts "#{$0}: #{e.message}"
+ puts "#{cmd_name}: #{e.message}"
exit -1
end
-rc = ec2_client.upload_image(image)
+rc = ec2_client.upload_image(image, curb)
-if OpenNebula::is_error?(rc)
- puts "#{$0}: #{rc.message}"
+if CloudClient::is_error?(rc)
+ puts "#{cmd_name}: #{rc.message}"
exit -1
end
diff --git a/src/cloud/ec2/eco.rb b/src/cloud/ec2/eco.rb
deleted file mode 100644
index 13d32b0e75..0000000000
--- a/src/cloud/ec2/eco.rb
+++ /dev/null
@@ -1,392 +0,0 @@
-
-
-ONE_LOCATION=ENV["ONE_LOCATION"]
-
-if !ONE_LOCATION
- RUBY_LIB_LOCATION="/usr/lib/one/ruby"
-else
- RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby"
- TEMPLATES_LOCATION=ONE_LOCATION+"/etc/ec2query_templates"
- CONF_LOCATION=ONE_LOCATION+"/etc"
-end
-
-$: << RUBY_LIB_LOCATION
-$: << RUBY_LIB_LOCATION+"/econe"
-
-
-require 'rubygems'
-require 'sinatra'
-require 'EC2'
-require 'time'
-
-require 'OpenNebula'
-#require 'repo_manager'
-require 'OcaConfiguration'
-
-require 'pp'
-
-include OpenNebula
-
-CONFIG=OcaConfiguration.new(CONF_LOCATION+'/econe.conf')
-AUTH="#{CONFIG[:user]}:#{CONFIG[:password]}"
-ONE_RM_DATABASE=CONFIG[:database]
-
-# Load this gere to use ONE_RM_DATABASE form the configuration file
-require 'repo_manager'
-Image.image_dir=CONFIG[:image_dir]
-
-
-INSTANCE_TYPES=Hash.new
-
-pp CONFIG
-
-if CONFIG[:vm_type].kind_of?(Array)
- # Multiple instance types
- CONFIG[:vm_type].each {|type|
- INSTANCE_TYPES[type['NAME']]=type
- }
-else
- # When only one instance type is defined
- INSTANCE_TYPES[CONFIG[:vm_type]['NAME']]=CONFIG[:vm_type]
-end
-
-pp INSTANCE_TYPES
-
-set :host, CONFIG[:server]
-set :port, CONFIG[:port]
-
-
-EC2_STATES={
- :pending => {:code => 0, :name => 'pending'},
- :running => {:code => 16, :name => 'running'},
- :shutdown => {:code => 32, :name => 'shutting-down'},
- :terminated => {:code => 48, :name => 'terminated'}
-}
-
-ONE_STATES={
- 'init' => :pending,
- 'pend' => :pending,
- 'hold' => :pending,
- 'stop' => :pending,
- 'susp' => :pending,
- 'done' => :terminated,
- 'fail' => :terminated,
- 'prol' => :pend,
- 'boot' => :running,
- 'runn' => :running,
- 'migr' => :running,
- 'save' => :pend,
- 'epil' => :shutdown,
- 'shut' => :shutdown,
- 'fail' => :terminated,
- 'dele' => :terminated,
- 'unkn' => :terminated
-}
-
-$repoman=RepoManager.new
-
-def get_one_client
- Client.new(AUTH)
-end
-
-def get_one_client_user(user_name)
- user=get_user(user_name)
-
-
- auth="#{user[:name]}:#{user[:password]}"
-
- client=Client.new("dummy:dummy")
- client.one_auth=auth
- client
-end
-
-def get_user(name)
- user=nil
-
- user_pool=UserPool.new(get_one_client)
- user_pool.info
- user_pool.each{|u|
- if u.name==name
- user=Hash.new
- user[:id]=u.id
- user[:name]=u.name
- user[:password]=u[:password]
- end
- }
-
- user
-end
-
-def render_state(vm)
- one_state=vm.status
- ec2_state=EC2_STATES[ONE_STATES[one_state]]
-
- "#{ec2_state[:code]}
- #{ec2_state[:name]}"
-end
-
-def render_launch_time(vm)
- "#{Time.at(vm[:stime].to_i).xmlschema}"
-end
-
-def authenticate(params)
- user_name=params['AWSAccessKeyId']
- user=get_user(user_name)
-
- halt 401, "User does not exist" if !user
-
- signature_params=params.reject {|key,value|
- key=='Signature' or key=='file' }
- canonical=EC2.canonical_string(signature_params, CONFIG[:server])
- signature=EC2.encode(user[:password], canonical, false)
-
- halt 401, "Bad password" if params['Signature']!=signature
-end
-
-before do
- authenticate(params)
-end
-
-
-def upload_image(params)
- user=get_user(params['AWSAccessKeyId'])
- file=params["file"]
-
- # tmpfile where the file is stored
- f_tmp=file[:tempfile]
- img=$repoman.add(user[:id], f_tmp.path)
- f_tmp.unlink
-
- @img_id=img.uuid
-
- erb :register_image
-end
-
-def register_image(params)
- user=get_user(params['AWSAccessKeyId'])
- uuid=params['ImageLocation']
-
- img=$repoman.get(uuid)
-
- halt 404, 'Image not found' if !img
- halt 401, 'Not permited to use image' if user[:id]!=img[:owner]
-
- @img_id=img.uuid
-
- erb :register_image
-end
-
-def describe_images(params)
- @user=get_user(params['AWSAccessKeyId'])
-
- @images=Image.filter(:owner => @user[:id])
-
- pp @images
-
- erb :describe_images
-end
-
-
-def run_instances(params)
- @user=get_user(params['AWSAccessKeyId'])
-
- image_id=params['ImageId']
- image=$repoman.get(image_id)
-
- @vm_info=Hash.new
- @vm_info[:img_path]=image.path
- @vm_info[:img_id]=image_id
-
- instance_type_name=params['InstanceType']
- instance_type=INSTANCE_TYPES[instance_type_name]
-
- halt 400, "Bad instance type" if !instance_type
-
- @vm_info[:instance_type]=instance_type_name
-
- template=ERB.new(File.read(
- TEMPLATES_LOCATION+"/#{instance_type['TEMPLATE']}"))
- template_text=template.result(binding)
-
- pp template_text
-
- vm=VirtualMachine.new(
- VirtualMachine.build_xml, get_one_client_user(@user[:name]))
- response=vm.allocate(template_text)
-
- pp response
-
- vm.info
-
- @vm_info[:vm_id]=vm.id
- @vm_info[:vm]=vm
-
- erb :run_instances
-end
-
-def describe_instances(params)
- @user=get_user(params['AWSAccessKeyId'])
-
- client=get_one_client_user(@user[:name])
-
- @vmpool=VirtualMachinePool.new(client)
- @vmpool.info
-
- pp @vmpool
-
- erb :describe_instances
-end
-
-def terminate_instances(params)
- @user=get_user(params['AWSAccessKeyId'])
- vmid=params['InstanceId.1']
-
- client=get_one_client_user(@user[:name])
- @vm=VirtualMachine.new(VirtualMachine.build_xml(vmid), client)
- res=@vm.info
-
- halt 401, res.message if OpenNebula::is_error?(res)
-
- if @vm.status=='runn'
- res=@vm.shutdown
- else
- res=@vm.finalize
- end
-
- halt 401, res.message if OpenNebula::is_error?(res)
-
- erb :terminate_instances
-end
-
-post '/' do
- pp params
-
- case params['Action']
- when 'UploadImage'
- upload_image(params)
- when 'RegisterImage'
- register_image(params)
- when 'DescribeImages'
- describe_images(params)
- when 'RunInstances'
- run_instances(params)
- when 'DescribeInstances'
- describe_instances(params)
- when 'TerminateInstances'
- terminate_instances(params)
- end
-end
-
-
-__END__
-
-@@ register_image
-
- <%= @img_id %>
-
-
-
-@@ describe_images
-
-
- <% for image in @images %>
-
- <%= image.uuid %>
- <%= image.path %>
- available
- <%= @user[:name] %>
- false
- i386
- machine
-
- <% end %>
-
-
-
-
-@@ run_instances
-
- r-47a5402e
- <%= @user[:name] %>
-
-
- default
-
-
-
-
- <%= @vm_info[:vm_id] %>
- <%= @vm_info[:img_id] %>
-
- 0
- pending
-
- <%= @vm_info[:vm]["TEMPLATE/NIC/IP"]%>
- <%= @vm_info[:vm]["TEMPLATE/NIC/IP"]%>
- default
- 0
- <%= @vm_info[:instance_type] %>
- <%= render_launch_time(@vm_info[:vm]) %>
-
- default
-
-
- true
-
-
-
-
-
-@@ describe_instances
-
-
-
- default
- <%= @user[:name] %>
-
-
- default
-
-
-
- <% @vmpool.each do |vm| %>
- <% vm.info %>
-
- <%= vm.id %>
- <%= vm['TEMPLATE/IMAGE_ID'] %>
-
- <%= render_state(vm) %>
-
- <%= vm["TEMPLATE/NIC/IP"] %>
- <%= vm["TEMPLATE/NIC/IP"] %>
- default
- 0
- <%= vm['TEMPLATE/INSTANCE_TYPE'] %>
- <%= render_launch_time(vm) %>
-
- default
-
-
- <% end %>
-
-
-
-
-
-@@ terminate_instances
-
-
-
- <%= @vm.id %>
-
- 32
- shutting-down
-
-
- <%= render_state(@vm) %>
-
-
-
-
-
-
diff --git a/src/cloud/ec2/econe-server b/src/cloud/ec2/econe-server
deleted file mode 100755
index 008cbcfd4b..0000000000
--- a/src/cloud/ec2/econe-server
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/bash
-
-eval `grep ^IMAGE_DIR= $ONE_LOCATION/etc/econe.conf `
-export TMPDIR=$IMAGE_DIR/tmp
-mkdir -p $TMPDIR
-
-nohup ruby $ONE_LOCATION/lib/ruby/econe/eco.rb >> $ONE_LOCATION/var/econe.log &
-
-
diff --git a/src/cloud/ec2/econe.conf b/src/cloud/ec2/etc/econe.conf
similarity index 85%
rename from src/cloud/ec2/econe.conf
rename to src/cloud/ec2/etc/econe.conf
index 19e714fdce..dac46dd86c 100644
--- a/src/cloud/ec2/econe.conf
+++ b/src/cloud/ec2/etc/econe.conf
@@ -9,6 +9,9 @@ ONE_XMLRPC=http://localhost:2633/RPC2
SERVER=
PORT=4567
+# SSL proxy that serves the API (set if is being used)
+#SSL_SERVER=fqdm.of.the.server
+
# Configuration for the image repository
DATABASE=
diff --git a/src/cloud/ec2/templates/m1.small.erb b/src/cloud/ec2/etc/templates/m1.small.erb
similarity index 67%
rename from src/cloud/ec2/templates/m1.small.erb
rename to src/cloud/ec2/etc/templates/m1.small.erb
index 75883aa748..aadc207263 100644
--- a/src/cloud/ec2/templates/m1.small.erb
+++ b/src/cloud/ec2/etc/templates/m1.small.erb
@@ -9,7 +9,7 @@ OS = [ kernel = /vmlinuz,
root = sda1,
kernel_cmd = "ro xencons=tty console=tty1"]
-DISK = [ source = <%= @vm_info[:img_path] %>,
+DISK = [ source = <%= erb_vm_info[:img_path] %>,
clone = no,
target = sda1,
readonly = no]
@@ -18,6 +18,6 @@ DISK = [ source = <%= @vm_info[:img_path] %>,
NIC=[NETWORK="Public EC2"]
-IMAGE_ID = <%= @vm_info[:img_id] %>
-INSTANCE_TYPE = <%= @vm_info[:instance_type ]%>
+IMAGE_ID = <%= erb_vm_info[:img_id] %>
+INSTANCE_TYPE = <%= erb_vm_info[:instance_type ]%>
diff --git a/src/cloud/ec2/lib/EC2QueryClient.rb b/src/cloud/ec2/lib/EC2QueryClient.rb
index c82222da9b..0f0e56ae92 100644
--- a/src/cloud/ec2/lib/EC2QueryClient.rb
+++ b/src/cloud/ec2/lib/EC2QueryClient.rb
@@ -1,4 +1,19 @@
#!/usr/bin/ruby
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
$ec2url = nil
@@ -7,45 +22,43 @@ if ENV["EC2_URL"]
ENV["EC2_URL"]=nil
end
-require 'rubygems'
-require 'EC2'
-require 'curb'
-require 'uri'
-require 'OpenNebula'
+require 'CloudClient'
+require 'AWS'
module EC2QueryClient
- ###########################################################################
+ ##########################################################################
#
#
- ###########################################################################
- class Client
+ ##########################################################################
+ class Client
API_VERSION = '2008-12-01'
- #######################################################################
+ ######################################################################
#
#
- #######################################################################
+ ######################################################################
def initialize(secret=nil, endpoint=nil)
# Autentication
+ ec2auth=nil
if secret
- ec2auth = secret
+ ec2auth = secret.split(':')
elsif ENV["EC2_ACCESS_KEY"] and ENV["EC2_SECRET_KEY"]
- ec2auth = ENV["EC2_ACCESS_KEY"] + ":" + ENV["EC2_SECRET_KEY"]
- elsif ENV["ONE_AUTH"]
- ec2auth = ENV["ONE_AUTH"]
- elsif
+ ec2auth = [ENV["EC2_ACCESS_KEY"], ENV["EC2_SECRET_KEY"]]
+ else
+ ec2auth=CloudClient::get_one_auth
+ end
+
+ if !ec2auth
raise "No authorization data present"
end
-
- ec2auth=~/(\w+):(\w+)/
- @access_key_id = $1
- @access_key_secret = Digest::SHA1.hexdigest($2)
-
+ @access_key_id = ec2auth[0]
+ @access_key_secret = Digest::SHA1.hexdigest(ec2auth[1])
+
# Server location
-
+
if !endpoint
if $ec2url
endpoint = $ec2url
@@ -55,40 +68,35 @@ module EC2QueryClient
end
@uri = URI.parse(endpoint)
-
- if !@uri.scheme or @uri.scheme != "http"
- raise "Only http protocol supported"
- elsif !@uri.host
- raise "Wrong URI format, host not found"
- end
- @ec2_connection = EC2::Base.new(
+ @ec2_connection = AWS::EC2::Base.new(
:access_key_id => @access_key_id,
:secret_access_key => @access_key_secret,
:server => @uri.host,
:port => @uri.port,
- :use_ssl => false)
+ :use_ssl => @uri.scheme == 'https')
end
- #######################################################################
+
+ ######################################################################
#
#
- #######################################################################
+ ######################################################################
def describe_instances()
begin
response = @ec2_connection.describe_instances
rescue Exception => e
- error = OpenNebula::Error.new(e.message)
+ error = CloudClient::Error.new(e.message)
return error
end
return response
end
- #######################################################################
+ ######################################################################
# :image_id
# :instance_type
- #######################################################################
+ ######################################################################
def run_instances(ami_id, type)
begin
response = @ec2_connection.run_instances(
@@ -98,35 +106,35 @@ module EC2QueryClient
:instance_type => type
)
rescue Exception => e
- error = OpenNebula::Error.new(e.message)
+ error = CloudClient::Error.new(e.message)
return error
end
return response
end
- #######################################################################
+ ######################################################################
#
#
- #######################################################################
+ ######################################################################
def terminate_instances(instance_id)
begin
response = @ec2_connection.terminate_instances(
:instance_id => instance_id
)
rescue Exception => e
- error = OpenNebula::Error.new(e.message)
+ error = CloudClient::Error.new(e.message)
return error
end
return response
end
- #######################################################################
+ ######################################################################
#
# Returns true if HTTP code is 200,
- #######################################################################
- def upload_image(file_name)
+ ######################################################################
+ def upload_image(file_name, curb=true)
params = { "Action" => "UploadImage",
"SignatureVersion" => "2",
"SignatureMethod" => 'HmacSHA1',
@@ -134,57 +142,78 @@ module EC2QueryClient
"Version" => API_VERSION,
"Timestamp" => Time.now.getutc.iso8601 }
- str = EC2.canonical_string(params, @uri.host)
- sig = EC2.encode(@access_key_secret, str, false)
+ str = AWS.canonical_string(params, @uri.host)
+ sig = AWS.encode(@access_key_secret, str, false)
post_fields = Array.new;
- params.each { |k,v|
- post_fields << Curl::PostField.content(k,v)
- }
+ if curb and CURL_LOADED
+ params.each { |k,v|
+ post_fields << Curl::PostField.content(k,v)
+ }
- post_fields << Curl::PostField.content("Signature",sig)
- post_fields << Curl::PostField.file("file",file_name)
+ post_fields << Curl::PostField.content("Signature",sig)
+ post_fields << Curl::PostField.file("file",file_name)
- connection = Curl::Easy.new(@uri.to_s)
- connection.multipart_form_post = true
+ connection = Curl::Easy.new(@uri.to_s)
+ connection.multipart_form_post = true
- connection.http_post(*post_fields)
+ connection.http_post(*post_fields)
- if connection.response_code == 200
- return EC2::Response.parse(:xml => connection.body_str)
+ if connection.response_code == 200
+ return AWS::Response.parse(:xml => connection.body_str)
+ else
+ return CloudClient::Error.new(connection.body_str)
+ end
else
- return OpenNebula::Error.new(connection.body_str)
+ params["Signature"]=sig
+
+ file=File.open(file_name)
+ params["file"]=UploadIO.new(file,
+ 'application/octet-stream', file_name)
+
+ req = Net::HTTP::Post::Multipart.new('/', params)
+ res = CloudClient.http_start(@uri) do |http|
+ http.request(req)
+ end
+
+ file.close
+
+ if res.code == '200'
+ return AWS::Response.parse(:xml => res.body)
+ else
+ return CloudClient::Error.new(res.body)
+ end
end
end
- #######################################################################
+ ######################################################################
#
#
- #######################################################################
+ ######################################################################
def register_image(image_id)
begin
response = @ec2_connection.register_image(
:image_location => image_id
)
rescue Exception => e
- error = OpenNebula::Error.new(e.message)
+ error = CloudClient::Error.new(e.message)
return error
end
return response
end
- #######################################################################
+ ######################################################################
# :image_id --> ALL
# :owner_id --> mine (ALWAYS)
# :executable_by --> Always Public (NO ACLS)
- #######################################################################
+ ######################################################################
def describe_images()
begin
response = @ec2_connection.describe_images
rescue Exception => e
- error = OpenNebula::Error.new(e.message)
+ error = CloudClient::Error.new(e.message)
return error
end
@@ -192,5 +221,3 @@ module EC2QueryClient
end
end
end
-
-
diff --git a/src/cloud/ec2/lib/EC2QueryServer.rb b/src/cloud/ec2/lib/EC2QueryServer.rb
new file mode 100644
index 0000000000..4609d7a26a
--- /dev/null
+++ b/src/cloud/ec2/lib/EC2QueryServer.rb
@@ -0,0 +1,242 @@
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
+
+require 'rubygems'
+require 'sinatra'
+require 'erb'
+require 'time'
+require 'AWS'
+require 'CloudServer'
+###############################################################################
+# The EC2Query Server implements a EC2 compatible server based on the
+# OpenNebula Engine
+###############################################################################
+class EC2QueryServer < CloudServer
+
+ ###########################################################################
+ # Class Constants. Defined the EC2 and OpenNebula State mapping
+ ###########################################################################
+ EC2_STATES={
+ :pending => {:code => 0, :name => 'pending'},
+ :running => {:code => 16,:name => 'running'},
+ :shutdown => {:code => 32,:name => 'shutting-down'},
+ :terminated => {:code => 48,:name => 'terminated'}
+ }
+
+ ONE_STATES={
+ 'init' => :pending,
+ 'pend' => :pending,
+ 'hold' => :pending,
+ 'stop' => :pending,
+ 'susp' => :pending,
+ 'done' => :terminated,
+ 'fail' => :terminated,
+ 'prol' => :pend,
+ 'boot' => :running,
+ 'runn' => :running,
+ 'migr' => :running,
+ 'save' => :pend,
+ 'epil' => :shutdown,
+ 'shut' => :shutdown,
+ 'fail' => :terminated,
+ 'dele' => :terminated,
+ 'unkn' => :terminated
+ }
+
+ ###########################################################################
+
+ def initialize(config_file,template,views)
+ super(config_file)
+ @config.add_configuration_value("TEMPLATE_LOCATION",template)
+ @config.add_configuration_value("VIEWS",views)
+
+ if @config[:ssl_server]
+ @server_host=@config[:ssl_server]
+ else
+ @server_host=@config[:server]
+ end
+
+ print_configuration
+ end
+
+ ###########################################################################
+ # Authentication functions
+ ###########################################################################
+
+ # EC2 protocol authentication function
+ # params:: of the request
+ # [return] true if authenticated
+ def authenticate?(params)
+ user = get_user(params['AWSAccessKeyId'])
+ return false if !user
+
+ signature_params = params.reject { |key,value|
+ key=='Signature' or key=='file' }
+
+ signature = AWS.encode(
+ user[:password],
+ AWS.canonical_string(signature_params, @server_host),
+ false)
+
+ return params['Signature']==signature
+ end
+
+ ###########################################################################
+ # Repository Interface
+ ###########################################################################
+
+ def upload_image(params)
+ user = get_user(params['AWSAccessKeyId'])
+
+ image = add_image(user[:id],params["file"][:tempfile])
+ erb_img_id = image.id
+
+ response = ERB.new(File.read(@config[:views]+"/register_image.erb"))
+ return response.result(binding), 200
+ end
+
+ def register_image(params)
+ user = get_user(params['AWSAccessKeyId'])
+ image = get_image(params['ImageLocation'])
+
+ if !image
+ return OpenNebula::Error.new('Image not found'), 404
+ elsif user[:id] != image[:owner]
+ return OpenNebula::Error.new('Not permited to use image'), 401
+ end
+
+ erb_img_id=image.id
+
+ response = ERB.new(File.read(@config[:views]+"/register_image.erb"))
+ return response.result(binding), 200
+ end
+
+ def describe_images(params)
+ erb_user = get_user(params['AWSAccessKeyId'])
+ erb_images = Image.filter(:owner => erb_user[:id])
+
+ response = ERB.new(File.read(@config[:views]+"/describe_images.erb"))
+ return response.result(binding), 200
+ end
+
+ ###########################################################################
+ # Instance Interface
+ ###########################################################################
+
+ def run_instances(params)
+ # Get the instance type
+ instance_type_name = params['InstanceType']
+ instance_type = @instance_types[instance_type_name]
+
+ return OpenNebula::Error.new('Bad instance type'),400 if !instance_type
+
+ # Get the image
+ image = get_image(params['ImageId'])
+
+ return OpenNebula::Error.new('Bad image id'),400 if !image
+
+ # Get the user
+ user = get_user(params['AWSAccessKeyId'])
+ one_client = one_client_user(user)
+ erb_user_name = user[:name]
+
+ # Build the VM
+ erb_vm_info=Hash.new
+
+ erb_vm_info[:img_path] = image.path
+ erb_vm_info[:img_id] = params['ImageId']
+ erb_vm_info[:instance_type] = instance_type_name
+ erb_vm_info[:template] = @config[:template_location] +
+ "/#{instance_type['TEMPLATE']}"
+ template = ERB.new(File.read(erb_vm_info[:template]))
+ template_text = template.result(binding)
+
+ #Start the VM.
+ vm = VirtualMachine.new(VirtualMachine.build_xml, one_client)
+ rc = vm.allocate(template_text)
+
+ return rc, 401 if OpenNebula::is_error?(rc)
+
+ vm.info
+
+ erb_vm_info[:vm_id]=vm.id
+ erb_vm_info[:vm]=vm
+
+ response = ERB.new(File.read(@config[:views]+"/run_instances.erb"))
+ return response.result(binding), 200
+ end
+
+
+ def describe_instances(params)
+ # Get the user
+ user = get_user(params['AWSAccessKeyId'])
+ one_client = one_client_user(user)
+
+ erb_user_name = user[:name]
+
+ if user[:id]==0
+ user_flag=-2
+ else
+ user_flag=-1
+ end
+
+ erb_vmpool = VirtualMachinePool.new(one_client, user_flag)
+ erb_vmpool.info
+
+ response = ERB.new(File.read(@config[:views]+"/describe_instances.erb"))
+ return response.result(binding), 200
+ end
+
+ def terminate_instances(params)
+ # Get the user
+ user = get_user(params['AWSAccessKeyId'])
+ one_client = one_client_user(user)
+
+ vmid=params['InstanceId.1']
+
+ erb_vm = VirtualMachine.new(VirtualMachine.build_xml(vmid),one_client)
+ rc = erb_vm.info
+
+ return rc, 401 if OpenNebula::is_error?(rc)
+
+ if erb_vm.status == 'runn'
+ rc = erb_vm.shutdown
+ else
+ rc = erb_vm.finalize
+ end
+
+ return rc, 401 if OpenNebula::is_error?(rc)
+
+ response =ERB.new(File.read(@config[:views]+"/terminate_instances.erb"))
+ return response.result(binding), 200
+ end
+
+private
+ ###########################################################################
+ # Helper functions
+ ###########################################################################
+ def render_state(vm)
+ ec2_state = EC2_STATES[ONE_STATES[vm.status]]
+
+ return "#{ec2_state[:code]}
+ #{ec2_state[:name]}"
+ end
+
+ def render_launch_time(vm)
+ return "#{Time.at(vm[:stime].to_i).xmlschema}"
+ end
+end
+
diff --git a/src/cloud/ec2/lib/econe-server.rb b/src/cloud/ec2/lib/econe-server.rb
new file mode 100644
index 0000000000..3c38ece1ec
--- /dev/null
+++ b/src/cloud/ec2/lib/econe-server.rb
@@ -0,0 +1,88 @@
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
+
+##############################################################################
+# Environment Configuration for the Cloud Server
+##############################################################################
+ONE_LOCATION=ENV["ONE_LOCATION"]
+
+if !ONE_LOCATION
+ RUBY_LIB_LOCATION = "/usr/lib/one/ruby"
+ CONFIGURATION_FILE = "/etc/one/econe.conf"
+ TEMPLATE_LOCATION = "/etc/one/ec2query_templates"
+else
+ RUBY_LIB_LOCATION = ONE_LOCATION+"/lib/ruby"
+ CONFIGURATION_FILE = ONE_LOCATION+"/etc/econe.conf"
+ TEMPLATE_LOCATION = ONE_LOCATION+"/etc/ec2query_templates"
+end
+
+VIEWS_LOCATION = RUBY_LIB_LOCATION + "/cloud/econe/views"
+
+$: << RUBY_LIB_LOCATION
+$: << RUBY_LIB_LOCATION+"/cloud"
+$: << RUBY_LIB_LOCATION+"/cloud/econe"
+
+###############################################################################
+# Libraries
+###############################################################################
+require 'rubygems'
+require 'sinatra'
+
+require 'EC2QueryServer'
+
+include OpenNebula
+
+$econe_server = EC2QueryServer.new(CONFIGURATION_FILE,
+ TEMPLATE_LOCATION, VIEWS_LOCATION)
+
+##############################################################################
+# Sinatra Configuration
+##############################################################################
+set :host, $econe_server.config[:server]
+set :port, $econe_server.config[:port]
+
+##############################################################################
+# Actions
+##############################################################################
+
+before do
+ if !$econe_server.authenticate?(params)
+ halt 401, 'Invalid credentials'
+ end
+end
+
+post '/' do
+ case params['Action']
+ when 'UploadImage'
+ result,rc = $econe_server.upload_image(params)
+ when 'RegisterImage'
+ result,rc = $econe_server.register_image(params)
+ when 'DescribeImages'
+ result,rc = $econe_server.describe_images(params)
+ when 'RunInstances'
+ result,rc = $econe_server.run_instances(params)
+ when 'DescribeInstances'
+ result,rc = $econe_server.describe_instances(params)
+ when 'TerminateInstances'
+ result,rc = $econe_server.terminate_instances(params)
+ end
+
+ if OpenNebula::is_error?(result)
+ halt rc, result.message
+ end
+
+ result
+end
diff --git a/src/cloud/ec2/lib/views/describe_images.erb b/src/cloud/ec2/lib/views/describe_images.erb
new file mode 100644
index 0000000000..c7f2972a56
--- /dev/null
+++ b/src/cloud/ec2/lib/views/describe_images.erb
@@ -0,0 +1,15 @@
+
+
+ <% for image in erb_images %>
+
+ <%= image.id %>
+ <%= image.path %>
+ available
+ <%= erb_user[:name] %>
+ false
+ i386
+ machine
+
+ <% end %>
+
+
diff --git a/src/cloud/ec2/lib/views/describe_instances.erb b/src/cloud/ec2/lib/views/describe_instances.erb
new file mode 100644
index 0000000000..28740fcba0
--- /dev/null
+++ b/src/cloud/ec2/lib/views/describe_instances.erb
@@ -0,0 +1,34 @@
+
+
+
+ default
+ <%= erb_user_name %>
+
+
+ default
+
+
+
+ <% erb_vmpool.each do |vm| %>
+ <% vm.info %>
+
+ <%= vm.id %>
+ <%= vm['TEMPLATE/IMAGE_ID'] %>
+
+ <%= render_state(vm) %>
+
+ <%= vm["TEMPLATE/NIC/IP"] %>
+ <%= vm["TEMPLATE/NIC/IP"] %>
+ default
+ 0
+ <%= vm['TEMPLATE/INSTANCE_TYPE'] %>
+ <%= render_launch_time(vm) %>
+
+ default
+
+
+ <% end %>
+
+
+
+
diff --git a/src/cloud/ec2/lib/views/register_image.erb b/src/cloud/ec2/lib/views/register_image.erb
new file mode 100644
index 0000000000..753487bc2d
--- /dev/null
+++ b/src/cloud/ec2/lib/views/register_image.erb
@@ -0,0 +1,3 @@
+
+ <%= erb_img_id %>
+
diff --git a/src/cloud/ec2/lib/views/run_instances.erb b/src/cloud/ec2/lib/views/run_instances.erb
new file mode 100644
index 0000000000..7481d4f978
--- /dev/null
+++ b/src/cloud/ec2/lib/views/run_instances.erb
@@ -0,0 +1,32 @@
+
+ r-47a5402e
+ <%= erb_user_name %>
+
+
+ default
+
+
+
+
+ <%= erb_vm_info[:vm_id] %>
+ <%= erb_vm_info[:img_id] %>
+
+ 0
+ pending
+
+ <%= erb_vm_info[:vm]["TEMPLATE/NIC/IP"]%>
+ <%= erb_vm_info[:vm]["TEMPLATE/NIC/IP"]%>
+ default
+ 0
+ <%= erb_vm_info[:instance_type] %>
+ <%= render_launch_time(erb_vm_info[:vm]) %>
+
+ default
+
+
+ true
+
+
+
+
+
diff --git a/src/cloud/ec2/lib/views/terminate_instances.erb b/src/cloud/ec2/lib/views/terminate_instances.erb
new file mode 100644
index 0000000000..cdfc177699
--- /dev/null
+++ b/src/cloud/ec2/lib/views/terminate_instances.erb
@@ -0,0 +1,14 @@
+
+
+
+ <%= erb_vm.id %>
+
+ 32
+ shutting-down
+
+
+ <%= render_state(erb_vm) %>
+
+
+
+
diff --git a/src/cloud/occi/bin/occi-compute b/src/cloud/occi/bin/occi-compute
new file mode 100755
index 0000000000..6b2de39b35
--- /dev/null
+++ b/src/cloud/occi/bin/occi-compute
@@ -0,0 +1,188 @@
+#!/usr/bin/env ruby
+
+# == Synopsis
+# occi-compute
+#
+# Manages compute resources
+#
+# == Usage
+#
+# occi-compute [OPTIONS] [ARGUMENTS]
+#
+# COMMANDS
+#
+# create
+# creates a new compute resource described by the provided
+#
+#
+# list
+# lists available compute resources
+#
+# show
+# retrieves the OCCI XML representation of the compute resource
+# identified by
+#
+# update
+# updates the representation of the compute resource represented by the
+# provided
+#
+# delete
+# deletes the compute resource idenfitied by
+#
+#
+# OPTIONS
+#
+# -h, --help:
+# show help
+#
+# --username , -U :
+# The username of the user
+#
+# --password , -P :
+# The password of the user
+#
+# --url , -R :
+# Set url as the web service url to use
+#
+# --debug, -D
+# Enables verbosity
+#
+#
+
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
+
+ONE_LOCATION=ENV["ONE_LOCATION"]
+
+if !ONE_LOCATION
+ RUBY_LIB_LOCATION="/usr/lib/one/ruby"
+else
+ RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby"
+ TEMPLATES_LOCATION=ONE_LOCATION+"/etc/occi_templates"
+ CONF_LOCATION=ONE_LOCATION+"/etc"
+end
+
+$: << RUBY_LIB_LOCATION
+$: << RUBY_LIB_LOCATION+"/cloud"
+
+require 'occi/OCCIClient'
+require 'getoptlong'
+require 'rdoc/usage'
+require 'pp'
+
+include CloudCLI
+
+opts = GetoptLong.new(
+ ['--help', '-h',GetoptLong::NO_ARGUMENT],
+ ['--username', '-U',GetoptLong::REQUIRED_ARGUMENT],
+ ['--password', '-P',GetoptLong::REQUIRED_ARGUMENT],
+ ['--url', '-R',GetoptLong::REQUIRED_ARGUMENT],
+ ['--debug', '-D',GetoptLong::NO_ARGUMENT]
+ )
+
+url = nil
+username = nil
+password = nil
+auth = nil
+debug = false
+
+begin
+ opts.each do |opt, arg|
+ case opt
+ when '--help'
+ RDoc::usage
+ when '--username'
+ username = arg
+ when '--password'
+ password = arg
+ when '--url'
+ url = arg
+ when '--debug'
+ debug = true
+ end
+ end
+rescue Exception => e
+ exit(-1)
+end
+
+begin
+ occi_client = OCCIClient::Client.new(url,username,password,debug)
+rescue Exception => e
+ puts "#{cmd_name}: #{e.message}"
+ exit(-1)
+end
+
+if !ARGV[0]
+ puts "#{cmd_name}: [COMMAND] not present"
+ puts "#{cmd_name}: Execute #{cmd_name} -h for help."
+ exit(-1)
+end
+
+case ARGV[0].downcase
+ when 'list'
+ rc = occi_client.get_vms
+
+ when 'create'
+ vm_xml = ARGV[1]
+
+ if !vm_xml || !File.exists?(vm_xml)
+ puts "#{cmd_name} create: missing OCCI-XML or file not found"
+ exit(-1)
+ end
+
+ rc = occi_client.post_vms(vm_xml)
+
+ when 'show'
+ vm_id = ARGV[1]
+
+ if !vm_id
+ puts "#{cmd_name} show: missing VM-ID parameter"
+ exit(-1)
+ end
+
+ rc = occi_client.get_vm(vm_id)
+
+ when 'update'
+ vm_xml = ARGV[1]
+
+ if !vm_xml || !File.exists?(vm_xml)
+ puts "#{cmd_name} update: missing OCCI-XML or file not found"
+ exit -1
+ end
+
+ rc = occi_client.put_vm(vm_xml)
+
+ when 'delete'
+ vm_id = ARGV[1]
+
+ if !vm_id
+ puts "#{cmd_name} delete: missing VM-ID parameter"
+ exit -1
+ end
+
+ rc = occi_client.delete_vm(vm_id)
+
+ else
+ puts "Command #{ARGV[0]} not valid."
+ exit(-1)
+end
+
+if CloudClient::is_error?(rc)
+ puts rc.to_s()
+else
+ puts rc
+end
+
diff --git a/src/cloud/occi/bin/occi-network b/src/cloud/occi/bin/occi-network
new file mode 100755
index 0000000000..a85fc4baa3
--- /dev/null
+++ b/src/cloud/occi/bin/occi-network
@@ -0,0 +1,179 @@
+#!/usr/bin/env ruby
+
+# == Synopsis
+# occi-network
+#
+# Manages virtual networks
+#
+# == Usage
+#
+# occi-network [OPTIONS] [ARGUMENTS]
+#
+# COMMANDS
+#
+# create
+# creates a new virtual network described by the provided
+#
+#
+# list
+# lists available virtual networks
+#
+# show
+# retrieves the OCCI XML representation of the virtual network
+# identified by
+#
+# delete
+# deletes the virtual network idenfitied by
+#
+#
+#
+# OPTIONS
+#
+# -h, --help:
+# show help
+#
+# --username , -U :
+# The username of the user
+#
+# --password , -P :
+# The password of the user
+#
+# --url , -R :
+# Set url as the web service url to use
+#
+# --debug, -D
+# Enables verbosity
+#
+# --multipart, -M:
+# Use 'multipart-post' library instead of Curb/Curl
+#
+
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
+
+ONE_LOCATION=ENV["ONE_LOCATION"]
+
+if !ONE_LOCATION
+ RUBY_LIB_LOCATION="/usr/lib/one/ruby"
+else
+ RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby"
+ TEMPLATES_LOCATION=ONE_LOCATION+"/etc/occi_templates"
+ CONF_LOCATION=ONE_LOCATION+"/etc"
+end
+
+$: << RUBY_LIB_LOCATION
+$: << RUBY_LIB_LOCATION+"/cloud"
+
+require 'occi/OCCIClient'
+require 'CloudClient'
+require 'getoptlong'
+require 'rdoc/usage'
+require 'pp'
+
+include CloudCLI
+
+opts = GetoptLong.new(
+ ['--help', '-h',GetoptLong::NO_ARGUMENT],
+ ['--username', '-U',GetoptLong::REQUIRED_ARGUMENT],
+ ['--password', '-P',GetoptLong::REQUIRED_ARGUMENT],
+ ['--url', '-R',GetoptLong::REQUIRED_ARGUMENT],
+ ['--debug', '-D',GetoptLong::NO_ARGUMENT]
+ )
+
+url = nil
+username = nil
+password = nil
+auth = nil
+debug = false
+
+begin
+ opts.each do |opt, arg|
+ case opt
+ when '--help'
+ RDoc::usage
+ when '--username'
+ username = arg
+ when '--password'
+ password = arg
+ when '--url'
+ url = arg
+ when '--debug'
+ debug = true
+ end
+ end
+rescue Exception => e
+ exit(-1)
+end
+
+
+begin
+ occi_client = OCCIClient::Client.new(url,username,password,debug)
+rescue Exception => e
+ puts "#{cmd_name}: #{e.message}"
+ exit(-1)
+end
+
+if !ARGV[0]
+ puts "#{cmd_name}: [COMMAND] not present"
+ puts "#{cmd_name}: Execute #{cmd_name} -h for help."
+ exit(-1)
+end
+
+
+case ARGV[0].downcase
+ when 'create'
+ network_xml = ARGV[1]
+
+ if !network_xml || !File.exists?(network_xml)
+ puts "#{cmd_name} create: missing OCCI-XML or file not found"
+ exit(-1)
+ end
+
+ rc = occi_client.post_network(network_xml)
+
+ when 'list'
+ rc = occi_client.get_networks
+
+ when 'show'
+ network_id = ARGV[1]
+
+ if !network_id
+ puts "#{cmd_name} show: missing NETWORK-ID or file not found"
+ exit(-1)
+ end
+
+ rc = occi_client.get_network(network_id)
+
+ when 'delete'
+ network_id = ARGV[1]
+
+ if !network_id
+ puts "#{cmd_name} delete: missing NETWORK-ID parameter"
+ exit(-1)
+ end
+
+ rc = occi_client.delete_network(network_id)
+
+ else
+ puts "Command #{ARGV[0]} not valid."
+ exit(-1)
+end
+
+if CloudClient::is_error?(rc)
+ puts rc.to_s()
+else
+ puts rc
+end
diff --git a/src/cloud/occi/bin/occi-server b/src/cloud/occi/bin/occi-server
new file mode 100755
index 0000000000..56f3961afd
--- /dev/null
+++ b/src/cloud/occi/bin/occi-server
@@ -0,0 +1,119 @@
+#! /bin/sh
+
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
+
+if [ -z "$ONE_LOCATION" ]; then
+ OCCI_PID=/var/run/one/occi-server.pid
+ OCCI_SERVER=/usr/lib/one/ruby/cloud/occi/occi-server.rb
+ OCCI_LOCK_FILE=/var/lock/one/.occi.lock
+ OCCI_LOG=/var/log/one/occi-server.log
+ OCCI_ETC=/etc/one/occi-server.conf
+else
+ OCCI_PID=$ONE_LOCATION/var/occi-server.pid
+ OCCI_SERVER=$ONE_LOCATION/lib/ruby/cloud/occi/occi-server.rb
+ OCCI_LOCK_FILE=$ONE_LOCATION/var/.occi.lock
+ OCCI_LOG=$ONE_LOCATION/var/occi-server.log
+ OCCI_ETC=$ONE_LOCATION/etc/occi-server.conf
+fi
+
+setup()
+{
+ eval `grep ^IMAGE_DIR= $OCCI_ETC `
+ export TMPDIR=$IMAGE_DIR/tmp
+ mkdir -p $TMPDIR
+
+ if [ -f $OCCI_LOCK_FILE ]; then
+ if [ -f $OCCI_PID ]; then
+ ONEPID=`cat $OCCI_PID`
+ ps $OCCI_PID > /dev/null 2>&1
+ if [ $? -eq 0 ]; then
+ echo "OCCI Server is still running (PID:$OCCI_PID). Please try 'occi-server stop' first."
+ exit 1
+ fi
+ fi
+ echo "Stale .lock detected. Erasing it."
+ rm $LOCK_FILE
+ fi
+}
+
+start()
+{
+ if [ ! -x "$OCCI_SERVER" ]; then
+ echo "Can not find $OCCI_SERVER."
+ exit 1
+ fi
+
+ # Start the occi-server daemon
+ ruby $OCCI_SERVER > $OCCI_LOG 2>&1 &
+
+ LASTRC=$?
+ LASTPID=$!
+
+ if [ $LASTRC -ne 0 ]; then
+ echo "Error executing $OCCI_SERVER"
+ exit 1
+ else
+ echo $LASTPID > $OCCI_PID
+ fi
+
+ sleep 1
+ ps $LASTPID > /dev/null 2>&1
+
+ if [ $? -ne 0 ]; then
+ echo "Error executing $OCCI_SERVER."
+ exit 1
+ fi
+
+ echo "occi-server started"
+}
+
+#
+# Function that stops the daemon/service
+#
+stop()
+{
+ if [ ! -f $OCCI_PID ]; then
+ echo "Couldn't find occi-server process pid."
+ exit 1
+ fi
+
+ # Kill the occi-server daemon
+
+ kill -INT `cat $OCCI_PID` > /dev/null 2>&1
+
+ # Remove pid files
+ rm -f $OCCI_PID > /dev/null 2>&1
+
+ echo "occi-server stopped"
+}
+
+
+case "$1" in
+ start)
+ setup
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ *)
+ echo "Usage: occi-server {start|stop}" >&2
+ exit 3
+ ;;
+esac
+
+
diff --git a/src/cloud/occi/bin/occi-storage b/src/cloud/occi/bin/occi-storage
new file mode 100755
index 0000000000..22c8e2b92b
--- /dev/null
+++ b/src/cloud/occi/bin/occi-storage
@@ -0,0 +1,174 @@
+#!/usr/bin/env ruby
+
+# == Synopsis
+# occi-storage
+#
+# Manages OCCI storage resource
+#
+# == Usage
+#
+# occi-storage [OPTIONS] [PARAMETERS]
+#
+# COMMANDS
+#
+# create
+# creates a new storage resource described by the provided
+#
+#
+# list
+# lists available storage resources
+#
+# show
+# retrieves the OCCI XML representation of the storage resource
+# identified by
+#
+# delete
+# deletes the storage resource idenfitied by
+#
+#
+# OPTIONS
+# -h, --help:
+# show help
+#
+# --username , -U :
+# The username of the user
+#
+# --password , -P :
+# The password of the user
+#
+# --url , -R :
+# Set url as the web service url to use
+#
+# --debug, -D
+# Enables verbosity
+#
+# --multipart, -M:
+# Use 'multipart-post' library instead of Curb/Curl
+#
+
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
+
+ONE_LOCATION=ENV["ONE_LOCATION"]
+
+if !ONE_LOCATION
+ RUBY_LIB_LOCATION="/usr/lib/one/ruby"
+else
+ RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby"
+ TEMPLATES_LOCATION=ONE_LOCATION+"/etc/occi_templates"
+ CONF_LOCATION=ONE_LOCATION+"/etc"
+end
+
+$: << RUBY_LIB_LOCATION
+$: << RUBY_LIB_LOCATION+"/cloud"
+
+require 'occi/OCCIClient'
+require 'CloudClient'
+require 'getoptlong'
+require 'rdoc/usage'
+require 'pp'
+
+include CloudCLI
+
+opts = GetoptLong.new(
+ ['--help', '-h',GetoptLong::NO_ARGUMENT],
+ ['--username', '-U',GetoptLong::REQUIRED_ARGUMENT],
+ ['--password', '-P',GetoptLong::REQUIRED_ARGUMENT],
+ ['--url', '-R',GetoptLong::REQUIRED_ARGUMENT],
+ ['--debug', '-D',GetoptLong::NO_ARGUMENT],
+ ['--multipart', '-M',GetoptLong::NO_ARGUMENT]
+ )
+
+url = nil
+username = nil
+password = nil
+auth = nil
+debug = false
+curb = true
+
+begin
+ opts.each do |opt, arg|
+ case opt
+ when '--help'
+ RDoc::usage
+ when '--username'
+ username = arg
+ when '--password'
+ password = arg
+ when '--url'
+ url = arg
+ when '--debug'
+ debug = true
+ when '--multipart'
+ curb = false
+ end
+ end
+rescue Exception => e
+ exit(-1)
+end
+
+if !ARGV[0]
+ puts "#{cmd_name}: [COMMAND] not present"
+ puts "#{cmd_name}: Execute #{cmd_name} -h for help."
+ exit(-1)
+end
+
+
+begin
+ occi_client = OCCIClient::Client.new(url,username,password,debug)
+rescue Exception => e
+ puts "#{cmd_name}: #{e.message}"
+ exit(-1)
+end
+
+case ARGV[0].downcase
+ when 'create'
+ image_xml = ARGV[1]
+
+ if !image_xml || !File.exists?(image_xml)
+ puts "#{cmd_name} create: missing occi xml or file not found"
+ exit(-1)
+ end
+
+ rc = occi_client.post_image(image_xml, curb)
+
+ when 'list'
+ rc = occi_client.get_images
+
+ when 'show'
+ image_id = ARGV[1]
+
+ if !image_id
+ puts "#{cmd_name} show: missing storage id parameter"
+ exit(-1)
+ end
+
+ rc = occi_client.get_image(image_id)
+
+ when 'delete'
+ puts 'Delete not yet implemented'
+ exit(-1)
+
+ else
+ puts "Command #{ARGV[0]} not valid."
+ exit(-1)
+end
+
+if CloudClient::is_error?(rc)
+ puts rc.to_s()
+else
+ puts rc
+end
diff --git a/src/cloud/occi/etc/occi-server.conf b/src/cloud/occi/etc/occi-server.conf
new file mode 100644
index 0000000000..dfca56bb37
--- /dev/null
+++ b/src/cloud/occi/etc/occi-server.conf
@@ -0,0 +1,29 @@
+# OpenNebula administrator user
+USER=oneadmin
+PASSWORD=
+
+# OpenNebula server contact information
+ONE_XMLRPC=http://localhost:2633/RPC2
+
+# Host and port where the occi server will run
+SERVER=
+PORT=4567
+
+# SSL proxy that serves the API (set if is being used)
+#SSL_SERVER=https://localhost:443
+
+# Configuration for the image repository
+DATABASE=/var/occi.db
+IMAGE_DIR=
+
+# Configuration for OpenNebula's Virtual Networks
+BRIDGE=
+
+# Default format for FS
+FS_FORMAT=ext3
+
+# VM types allowed and its template file (inside templates directory)
+VM_TYPE=[NAME=small, TEMPLATE=small.erb]
+VM_TYPE=[NAME=medium, TEMPLATE=medium.erb]
+VM_TYPE=[NAME=large, TEMPLATE=large.erb]
+
diff --git a/src/cloud/occi/etc/templates/large.erb b/src/cloud/occi/etc/templates/large.erb
new file mode 100644
index 0000000000..b88a916363
--- /dev/null
+++ b/src/cloud/occi/etc/templates/large.erb
@@ -0,0 +1,55 @@
+NAME = <%= vm_info['NAME']%>
+
+CPU = 8
+MEMORY = 8192
+
+OS = [ kernel = /vmlinuz,
+ initrd = /initrd.img,
+ root = sda1,
+ kernel_cmd = "ro xencons=tty console=tty1"]
+
+<% if vm_info['STORAGE']
+ vm_info['STORAGE'].each do |key, image|
+ image=[image].flatten
+case key
+ when "SWAP"
+ image.each do |img|
+%>
+DISK = [ type = "swap",
+ size=<%= img['size']%>,
+ target=<%= img['dev']%> ]
+<%
+ end
+ when "DISK"
+ image.each do |img|
+%>
+DISK = [ type = "disk",
+ target=<%= img['dev']%>,
+ source=<%= img['source']%>,
+ image_id=<%= img['image']%> ]
+<%
+ end
+ when "FS"
+ image.each do |img|
+%>
+DISK = [ type = "fs",
+ target=<%= img['dev']%>,
+ size=<%= img['size']%>,
+ format=<%= @config[:fs_format]||"ext3"%> ]
+<% end %>
+<% end %>
+<% end %>
+<% end %>
+<% if vm_info['NETWORK'] and vm_info['NETWORK']['NIC'] %>
+<% vm_info['NETWORK']['NIC'].each do |nic| %>
+NIC = [
+<% if nic['ip'] %>
+ IP=<%= nic['ip'] %>,
+<% end %>
+ NETWORK="<%= nic['network']%>",
+ NETWORK_ID=<%= nic['network_id'] %>
+]
+<% end %>
+<% end %>
+INSTANCE_TYPE = <%= vm_info[:instance_type ]%>
+
diff --git a/src/cloud/occi/etc/templates/medium.erb b/src/cloud/occi/etc/templates/medium.erb
new file mode 100644
index 0000000000..1fa7f80b75
--- /dev/null
+++ b/src/cloud/occi/etc/templates/medium.erb
@@ -0,0 +1,55 @@
+NAME = <%= vm_info['NAME']%>
+
+CPU = 4
+MEMORY = 4096
+
+OS = [ kernel = /vmlinuz,
+ initrd = /initrd.img,
+ root = sda1,
+ kernel_cmd = "ro xencons=tty console=tty1"]
+
+<% if vm_info['STORAGE']
+ vm_info['STORAGE'].each do |key, image|
+ image=[image].flatten
+case key
+ when "SWAP"
+ image.each do |img|
+%>
+DISK = [ type = "swap",
+ size=<%= img['size']%>,
+ target=<%= img['dev']%> ]
+<%
+ end
+ when "DISK"
+ image.each do |img|
+%>
+DISK = [ type = "disk",
+ target=<%= img['dev']%>,
+ source=<%= img['source']%>,
+ image_id=<%= img['image']%> ]
+<%
+ end
+ when "FS"
+ image.each do |img|
+%>
+DISK = [ type = "fs",
+ target=<%= img['dev']%>,
+ size=<%= img['size']%>,
+ format=<%= @config[:fs_format]||"ext3"%> ]
+<% end %>
+<% end %>
+<% end %>
+<% end %>
+<% if vm_info['NETWORK'] and vm_info['NETWORK']['NIC'] %>
+<% vm_info['NETWORK']['NIC'].each do |nic| %>
+NIC = [
+<% if nic['ip'] %>
+ IP=<%= nic['ip'] %>,
+<% end %>
+ NETWORK="<%= nic['network']%>",
+ NETWORK_ID=<%= nic['network_id'] %>
+]
+<% end %>
+<% end %>
+INSTANCE_TYPE = <%= vm_info[:instance_type ]%>
+
diff --git a/src/cloud/occi/etc/templates/small.erb b/src/cloud/occi/etc/templates/small.erb
new file mode 100644
index 0000000000..84ec3648c0
--- /dev/null
+++ b/src/cloud/occi/etc/templates/small.erb
@@ -0,0 +1,55 @@
+NAME = <%= vm_info['NAME']%>
+
+CPU = 1
+MEMORY = 1024
+
+OS = [ kernel = /vmlinuz,
+ initrd = /initrd.img,
+ root = sda1,
+ kernel_cmd = "ro xencons=tty console=tty1"]
+
+<% if vm_info['STORAGE']
+ vm_info['STORAGE'].each do |key, image|
+ image=[image].flatten
+case key
+ when "SWAP"
+ image.each do |img|
+%>
+DISK = [ type = "swap",
+ size=<%= img['size']%>,
+ target=<%= img['dev']%> ]
+<%
+ end
+ when "DISK"
+ image.each do |img|
+%>
+DISK = [ type = "disk",
+ target=<%= img['dev']%>,
+ source=<%= img['source']%>,
+ image_id=<%= img['image']%> ]
+<%
+ end
+ when "FS"
+ image.each do |img|
+%>
+DISK = [ type = "fs",
+ target=<%= img['dev']%>,
+ size=<%= img['size']%>,
+ format=<%= @config[:fs_format]||"ext3"%> ]
+<% end %>
+<% end %>
+<% end %>
+<% end %>
+<% if vm_info['NETWORK'] and vm_info['NETWORK']['NIC'] %>
+<% vm_info['NETWORK']['NIC'].each do |nic| %>
+NIC = [
+<% if nic['ip'] %>
+ IP=<%= nic['ip'] %>,
+<% end %>
+ NETWORK="<%= nic['network']%>",
+ NETWORK_ID=<%= nic['network_id'] %>
+]
+<% end %>
+<% end %>
+INSTANCE_TYPE = <%= vm_info[:instance_type ]%>
+
diff --git a/src/cloud/occi/lib/ImageOCCI.rb b/src/cloud/occi/lib/ImageOCCI.rb
new file mode 100755
index 0000000000..4565189754
--- /dev/null
+++ b/src/cloud/occi/lib/ImageOCCI.rb
@@ -0,0 +1,38 @@
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
+
+require 'OpenNebula'
+require 'erb'
+
+include OpenNebula
+
+module ImageOCCI
+ OCCI_IMAGE = %q{
+
+ <%= self.id %>
+ <%= name %>
+ <%= ((size/1024)/1024).to_s %>
+ <%= description %>
+
+ }.gsub(/^ /, '')
+
+
+ # Creates the OCCI representation of an Image
+ def to_occi()
+ occi = ERB.new(OCCI_IMAGE)
+ return occi.result(binding)
+ end
+end
diff --git a/src/cloud/occi/lib/ImagePoolOCCI.rb b/src/cloud/occi/lib/ImagePoolOCCI.rb
new file mode 100755
index 0000000000..d082e8efcb
--- /dev/null
+++ b/src/cloud/occi/lib/ImagePoolOCCI.rb
@@ -0,0 +1,40 @@
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
+
+require 'OpenNebula'
+
+
+include OpenNebula
+
+class ImagePoolOCCI
+ OCCI_IMAGE_POOL = %q{
+ <%
+ for image in @images do %>
+ <%
+ end %>
+
+ }.gsub(/^ /, '')
+
+ def initialize(user_id)
+ @images=Image.filter(:owner => user_id)
+ end
+
+ def to_occi(base_url)
+ occi = ERB.new(OCCI_IMAGE_POOL)
+ return occi.result(binding)
+ end
+end
+
diff --git a/src/cloud/occi/lib/OCCIClient.rb b/src/cloud/occi/lib/OCCIClient.rb
new file mode 100755
index 0000000000..f54df2abb9
--- /dev/null
+++ b/src/cloud/occi/lib/OCCIClient.rb
@@ -0,0 +1,372 @@
+#!/usr/bin/ruby
+
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
+
+require 'rubygems'
+require 'crack'
+require 'uri'
+
+require 'CloudClient'
+
+
+module OCCIClient
+
+ #####################################################################
+ # Client Library to interface with the OpenNebula OCCI Service
+ #####################################################################
+ class Client
+
+ ######################################################################
+ # Initialize client library
+ ######################################################################
+ def initialize(endpoint_str=nil, user=nil, pass=nil, debug_flag=true)
+ @debug = debug_flag
+
+ # Server location
+ if endpoint_str
+ @endpoint = endpoint_str
+ elsif ENV["OCCI_URL"]
+ @endpoint = ENV["OCCI_URL"]
+ else
+ @endpoint = "http://localhost:4567"
+ end
+
+ # Autentication
+ if user && pass
+ @occiauth = [user, pass]
+ else
+ @occiauth = CloudClient::get_one_auth
+ end
+
+ if !@occiauth
+ raise "No authorization data present"
+ end
+
+ @occiauth[1] = Digest::SHA1.hexdigest(@occiauth[1])
+ end
+
+ #################################
+ # Pool Resource Request Methods #
+ #################################
+
+ ######################################################################
+ # Post a new VM to the VM Pool
+ # :instance_type
+ # :xmlfile
+ ######################################################################
+ def post_vms(xmlfile)
+ xml=File.read(xmlfile)
+
+ url = URI.parse(@endpoint+"/compute")
+
+ req = Net::HTTP::Post.new(url.path)
+ req.body=xml
+
+ req.basic_auth @occiauth[0], @occiauth[1]
+
+ res = CloudClient::http_start(url) do |http|
+ http.request(req)
+ end
+
+ if CloudClient::is_error?(res)
+ return res
+ else
+ return res.body
+ end
+ end
+
+ ######################################################################
+ # Retieves the pool of Virtual Machines
+ ######################################################################
+ def get_vms
+ url = URI.parse(@endpoint+"/compute")
+ req = Net::HTTP::Get.new(url.path)
+
+ req.basic_auth @occiauth[0], @occiauth[1]
+
+ res = CloudClient::http_start(url) {|http|
+ http.request(req)
+ }
+
+ if CloudClient::is_error?(res)
+ return res
+ else
+ return res.body
+ end
+ end
+
+ ######################################################################
+ # Post a new Network to the VN Pool
+ # :xmlfile xml description of the Virtual Network
+ ######################################################################
+ def post_network(xmlfile)
+ xml=File.read(xmlfile)
+
+ url = URI.parse(@endpoint+"/network")
+
+ req = Net::HTTP::Post.new(url.path)
+ req.body=xml
+
+ req.basic_auth @occiauth[0], @occiauth[1]
+
+ res = CloudClient::http_start(url) do |http|
+ http.request(req)
+ end
+
+ if CloudClient::is_error?(res)
+ return res
+ else
+ return res.body
+ end
+ end
+
+ ######################################################################
+ # Retieves the pool of Virtual Networks
+ ######################################################################
+ def get_networks
+ url = URI.parse(@endpoint+"/network")
+ req = Net::HTTP::Get.new(url.path)
+
+ req.basic_auth @occiauth[0], @occiauth[1]
+
+ res = CloudClient::http_start(url) {|http|
+ http.request(req)
+ }
+
+ if CloudClient::is_error?(res)
+ return res
+ else
+ return res.body
+ end
+ end
+
+ ######################################################################
+ # Post a new Image to the Image Pool
+ # :xmlfile
+ ######################################################################
+ def post_image(xmlfile, curb=true)
+ xml=File.read(xmlfile)
+ image_info=Crack::XML.parse(xml)
+
+ file_path = image_info['DISK']['URL']
+
+ m=file_path.match(/^\w+:\/\/(.*)$/)
+
+ if m
+ file_path="/"+m[1]
+ end
+
+ if curb and CURL_LOADED
+ curl=Curl::Easy.new(@endpoint+"/storage")
+
+ curl.http_auth_types = Curl::CURLAUTH_BASIC
+ curl.userpwd = "#{@occiauth[0]}:#{@occiauth[1]}"
+ curl.verbose = true if @debug
+ curl.multipart_form_post = true
+
+ begin
+ curl.http_post(
+ Curl::PostField.content('occixml', xml),
+ Curl::PostField.file('file', file_path)
+ )
+ rescue Exception => e
+ return CloudClient::Error.new(e.message)
+ end
+
+ return curl.body_str
+ else
+ file=File.open(file_path)
+
+ params=Hash.new
+ params["file"]=UploadIO.new(file,
+ 'application/octet-stream', file_path)
+
+ params['occixml'] = xml
+
+ url = URI.parse(@endpoint+"/storage")
+
+ req = Net::HTTP::Post::Multipart.new(url.path, params)
+
+ req.basic_auth @occiauth[0], @occiauth[1]
+
+ res = CloudClient::http_start(url) do |http|
+ http.request(req)
+ end
+
+ file.close
+
+ if CloudClient::is_error?(res)
+ return res
+ else
+ return res.body
+ end
+ end
+ end
+
+ ######################################################################
+ # Retieves the pool of Images owned by the user
+ ######################################################################
+ def get_images
+ url = URI.parse(@endpoint+"/storage")
+ req = Net::HTTP::Get.new(url.path)
+
+ req.basic_auth @occiauth[0], @occiauth[1]
+
+ res = CloudClient::http_start(url) {|http|
+ http.request(req)
+ }
+
+ if CloudClient::is_error?(res)
+ return res
+ else
+ return res.body
+ end
+ end
+
+ ####################################
+ # Entity Resource Request Methods #
+ ####################################
+
+ ######################################################################
+ # :id VM identifier
+ ######################################################################
+ def get_vm(id)
+ url = URI.parse(@endpoint+"/compute/" + id.to_s)
+ req = Net::HTTP::Get.new(url.path)
+
+ req.basic_auth @occiauth[0], @occiauth[1]
+
+ res = CloudClient::http_start(url) {|http|
+ http.request(req)
+ }
+
+ if CloudClient::is_error?(res)
+ return res
+ else
+ return res.body
+ end
+ end
+
+ ######################################################################
+ # Puts a new Compute representation in order to change its state
+ # :xmlfile Compute OCCI xml representation
+ ######################################################################
+ def put_vm(xmlfile)
+ xml=File.read(xmlfile)
+ vm_info=Crack::XML.parse(xml)
+
+ url = URI.parse(@endpoint+'/compute/' + vm_info['COMPUTE']['ID'])
+
+ req = Net::HTTP::Put.new(url.path)
+ req.body = xml
+
+ req.basic_auth @occiauth[0], @occiauth[1]
+
+ res = CloudClient::http_start(url) do |http|
+ http.request(req)
+ end
+
+ if CloudClient::is_error?(res)
+ return res
+ else
+ return res.body
+ end
+ end
+
+ ####################################################################
+ # :id Compute identifier
+ ####################################################################
+ def delete_vm(id)
+ url = URI.parse(@endpoint+"/compute/" + id.to_s)
+ req = Net::HTTP::Delete.new(url.path)
+
+ req.basic_auth @occiauth[0], @occiauth[1]
+
+ res = CloudClient::http_start(url) {|http|
+ http.request(req)
+ }
+
+ if CloudClient::is_error?(res)
+ return res
+ else
+ return res.body
+ end
+ end
+
+ ######################################################################
+ # Retrieves a Virtual Network
+ # :id Virtual Network identifier
+ ######################################################################
+ def get_network(id)
+ url = URI.parse(@endpoint+"/network/" + id.to_s)
+ req = Net::HTTP::Get.new(url.path)
+
+ req.basic_auth @occiauth[0], @occiauth[1]
+
+ res = CloudClient::http_start(url) {|http|
+ http.request(req)
+ }
+
+ if CloudClient::is_error?(res)
+ return res
+ else
+ return res.body
+ end
+ end
+
+ ######################################################################
+ # :id VM identifier
+ ######################################################################
+ def delete_network(id)
+ url = URI.parse(@endpoint+"/network/" + id.to_s)
+ req = Net::HTTP::Delete.new(url.path)
+
+ req.basic_auth @occiauth[0], @occiauth[1]
+
+ res = CloudClient::http_start(url) {|http|
+ http.request(req)
+ }
+
+ if CloudClient::is_error?(res)
+ return res
+ else
+ return res.body
+ end
+ end
+
+ #######################################################################
+ # Retieves an Image
+ # :image_uuid Image identifier
+ ######################################################################
+ def get_image(image_uuid)
+ url = URI.parse(@endpoint+"/storage/"+image_uuid)
+ req = Net::HTTP::Get.new(url.path)
+
+ req.basic_auth @occiauth[0], @occiauth[1]
+
+ res = CloudClient::http_start(url) {|http|
+ http.request(req)
+ }
+
+ if CloudClient::is_error?(res)
+ return res
+ else
+ return res.body
+ end
+ end
+ end
+end
diff --git a/src/cloud/occi/lib/OCCIServer.rb b/src/cloud/occi/lib/OCCIServer.rb
new file mode 100755
index 0000000000..b45d4b4661
--- /dev/null
+++ b/src/cloud/occi/lib/OCCIServer.rb
@@ -0,0 +1,498 @@
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
+
+# Common cloud libs
+require 'rubygems'
+require 'sinatra'
+require 'CloudServer'
+
+# OCA
+require 'OpenNebula'
+include OpenNebula
+
+# OCCI libs
+require 'VirtualMachineOCCI'
+require 'VirtualMachinePoolOCCI'
+require 'VirtualNetworkOCCI'
+require 'VirtualNetworkPoolOCCI'
+require 'ImageOCCI'
+require 'ImagePoolOCCI'
+
+include ImageOCCI
+
+
+##############################################################################
+# The OCCI Server provides an OCCI implementation based on the
+# OpenNebula Engine
+##############################################################################
+class OCCIServer < CloudServer
+
+ # Server initializer
+ # config_file:: _String_ path of the config file
+ # template:: _String_ path to the location of the templates
+ def initialize(config_file,template)
+ super(config_file)
+
+ @config.add_configuration_value("TEMPLATE_LOCATION",template)
+
+ if @config[:ssl_server]
+ @base_url=@config[:ssl_server]
+ else
+ @base_url="http://#{@config[:server]}:#{@config[:port]}"
+ end
+
+ print_configuration
+ end
+
+ # Authorization function
+ # requestenv:: _Hash_ Hash containing the environment of the request
+ # [return] _Boolean_ Whether the user is authorized or not
+ def authenticate?(requestenv)
+ auth ||= Rack::Auth::Basic::Request.new(requestenv)
+
+ if !(auth.provided? && auth.basic? && auth.credentials)
+ return false
+ end
+
+ user = get_user(requestenv, auth)
+
+ if user
+ if user[:password] == auth.credentials[1]
+ return true
+ end
+ else
+ return false
+ end
+ end
+
+ # Retrieve the user crendentials
+ # requestenv:: _Hash_ Hash containing the environment of the request
+ # [return] _User_ User structure
+ def get_user(requestenv, auth=nil)
+ auth = Rack::Auth::Basic::Request.new(requestenv) if !auth
+ super(auth.credentials.first)
+ end
+
+ # Retrieve a client with the user credentials
+ # requestenv:: _Hash_ Hash containing the environment of the request
+ # [return] _Client_ client with the user credentials
+ def get_client(requestenv)
+ user = get_user(requestenv)
+ return one_client_user(user)
+ end
+
+ ###################################################
+ # Pool Resources methods
+ ###################################################
+
+ # Post a new compute to the COMPUTE pool
+ # request:: _Hash_ hash containing the data of the request
+ # [return] _String_,_Integer_ COMPUTE Representation or error, status code
+ def post_compute(request)
+ # Get client with user credentials
+ client = get_client(request.env)
+
+ if request.body
+ vm_info=Crack::XML.parse(request.body.read)
+ else
+ error = OpenNebula::Error.new(
+ "OCCI XML representation of VM not present")
+ return error, 400
+ end
+
+ vm_info=vm_info['COMPUTE']
+
+ disks=vm_info['STORAGE']
+
+ disks['DISK']=[disks['DISK']].flatten if disks and disks['DISK']
+
+ disks['DISK'].each{|disk|
+ next if !disk['image']
+ image = get_image(disk['image'])
+ if !image
+ error = OpenNebula::Error.new(
+ "Invalid image (#{disk['image']}) referred")
+ return error, 400
+ end
+ disk['source']=image.path
+ } if disks and disks['DISK']
+
+ vm_info['STORAGE']=disks
+
+ if vm_info['NETWORK'] and vm_info['NETWORK']['NIC']
+
+ if vm_info['NETWORK']['NIC'].class==Array
+ nics=vm_info['NETWORK']['NIC']
+ else
+ nics=[vm_info['NETWORK']['NIC']]
+ end
+
+ nics.each{|nic|
+ next if nic==nil
+ vn=VirtualNetwork.new(
+ VirtualNetwork.build_xml(nic['network']),
+ client)
+ vn.info
+ vn_xml=Crack::XML.parse(vn.to_xml)
+ if !vn_xml['VNET']['NAME']
+ error = OpenNebula::Error.new(
+ "Invalid network referred")
+ return error, 400
+ end
+ nic['network_id']=nic['network']
+ nic['network']=vn_xml['VNET']['NAME'].strip
+ } if nics
+
+ vm_info['NETWORK']['NIC']=nics
+ end
+
+ instance_type_name=vm_info['INSTANCE_TYPE']
+ instance_type=@instance_types[instance_type_name]
+
+ if !instance_type
+ error = OpenNebula::Error.new("Bad instance type")
+ return error, 400
+ end
+
+ vm_info[:instance_type]=instance_type_name
+
+ template=ERB.new(File.read(
+ @config[:template_location]+"/#{instance_type['TEMPLATE']}"))
+ template_text=template.result(binding)
+
+ vm=VirtualMachineOCCI.new(
+ VirtualMachine.build_xml,
+ client)
+ response=vm.allocate(template_text)
+
+ if OpenNebula.is_error?(response)
+ return response, 400
+ else
+ vm.info
+ return vm.to_occi(@base_url), 201
+ end
+ end
+
+ # Gets the pool representation of COMPUTES
+ # request:: _Hash_ hash containing the data of the request
+ # [return] _String_,_Integer_ Pool Representation or error, status code
+ def get_computes(request)
+ # Get client with user credentials
+ client = get_client(request.env)
+
+ # Just show resources from the user making the request
+ user_flag = -1
+
+ vmpool = VirtualMachinePoolOCCI.new(client,user_flag)
+ vmpool.info
+
+ # OCCI conversion
+ begin
+ compute_xml = vmpool.to_occi(@base_url)
+ return compute_xml, 200
+ rescue Exception => e
+ error = OpenNebula::Error.new(e.message)
+ return error, 500
+ end
+ end
+
+ # Post a new network to the NETWORK pool
+ # request:: _Hash_ hash containing the data of the request
+ # [return] _String_,_Integer_ Network Representation or error, status code
+ def post_network(request)
+ # Get client with user credentials
+ client = get_client(request.env)
+
+ # Info retrieval from post params
+ if request.body
+ network_info=Crack::XML.parse(request.body.read)
+ else
+ error_msg = "OCCI XML representation of Virtual Network" +
+ " not present in the request"
+ error = OpenNebula::Error.new(error_msg)
+ return error, 400
+ end
+ # Allocate the VirtualNetwork
+ network = VirtualNetworkOCCI.new(
+ VirtualNetwork.build_xml,
+ client)
+
+ begin
+ vntemplate = network.to_one_template(
+ network_info['NETWORK'],
+ @config[:bridge])
+ rc = network.allocate(vntemplate)
+ network.info
+ network_xml = network.to_occi
+ return network_xml, 201
+ rescue Exception => e
+ error_msg = "Error creating the Virtual Network:" + e.to_s
+ error_msg = ".Reason:" + rc if rc
+ error = OpenNebula::Error.new(error_msg)
+ return error, 500
+ end
+ end
+
+ # Gets the pool representation of NETWORKS
+ # request:: _Hash_ hash containing the data of the request
+ # [return] _String_,_Integer_ Network pool representation or error,
+ # => status code
+ def get_networks(request)
+ # Get client with user credentials
+ client = get_client(request.env)
+
+ # Info retrieval
+ network_pool = VirtualNetworkPoolOCCI.new(client)
+ network_pool.info
+ # OCCI conversion
+ begin
+ network_pool.to_occi(@base_url)
+ rescue Exception => e
+ error = OpenNebula::Error.new(e.message)
+ return error, 500
+ end
+ end
+
+ # Post a new image to the STORAGE pool
+ # request:: _Hash_ hash containing the data of the request
+ # [return] _String_,_Integer_ Image representation or error, status code
+ def post_storage(request)
+ # Info retrieval from post params
+ if request.params['occixml']
+ image_info=Crack::XML.parse(request.params['occixml'])
+ else
+ error_msg = "OCCI XML representation of Image" +
+ " not present in the request"
+ error = OpenNebula::Error.new(error_msg)
+ return error, 400
+ end
+
+ if request.params['file']
+ file=request.params["file"]
+ else
+ error_msg = "File not present in the request"
+ error = OpenNebula::Error.new(error_msg)
+ return error, 400
+ end
+
+ user = get_user(request.env)
+
+ # tmpfile where the file is stored
+ f_tmp=file[:tempfile]
+ img=add_image(user[:id], f_tmp, {:name=>image_info['DISK']['NAME'],
+ :description=>image_info['DISK']['URL']})
+
+ img.extend(ImageOCCI)
+ xml_response = img.to_occi
+
+ return xml_response, 201
+ end
+
+ # Gets the pool representation of STORAGES
+ # request:: _Hash_ hash containing the data of the request
+ # [return] _String_,_Integer_ Image pool representation or error,
+ # status code
+ def get_storages(request)
+ # Retrieve images owned by this user
+ user = get_user(request.env)
+
+ image_pool = ImagePoolOCCI.new(user[:id])
+ return image_pool.to_occi(@base_url), 200
+ end
+
+ ###################################################
+ # Entity Resources methods
+ ###################################################
+
+ # Get the representation of a COMPUTE resource
+ # request:: _Hash_ hash containing the data of the request
+ # [return] _String_,_Integer_ COMPUTE representation or error,
+ # status code
+ def get_compute(request, params)
+ # Get client with user credentials
+ client = get_client(request.env)
+
+ vm = VirtualMachineOCCI.new(
+ VirtualMachine.build_xml(params[:id]),
+ client)
+
+ result=vm.info
+
+ if OpenNebula::is_error?(result)
+ return result, 404
+ end
+
+ begin
+ return vm.to_occi(@base_url), 200
+ rescue Exception => e
+ error_msg = "Error converting COMPUTE resource to OCCI format"
+ error_msg = "\n Reason: " + e.message
+ error = OpenNebula::Error.new(error_msg)
+ return error, 500
+ end
+ end
+
+ # Deletes a COMPUTE resource
+ # request:: _Hash_ hash containing the data of the request
+ # [return] _String_,_Integer_ Delete confirmation msg or error,
+ # status code
+ def delete_compute(request, params)
+ # Get client with user credentials
+ client = get_client(request.env)
+
+ vm = VirtualMachineOCCI.new(
+ VirtualMachine.build_xml(params[:id]),
+ client)
+
+ result = vm.finalize
+
+ if OpenNebula::is_error?(result)
+ return result, 500
+ else
+ return "", 204
+ end
+ end
+
+ # Updates a COMPUTE resource
+ # request:: _Hash_ hash containing the data of the request
+ # [return] _String_,_Integer_ Update confirmation msg or error,
+ # status code
+ def put_compute(request, params)
+ # Get client with user credentials
+ client = get_client(request.env)
+
+ if request.body
+ vm_info=Crack::XML.parse(request.body.read)
+ else
+ error_msg = "OCCI XML representation of VM not present"
+ error = OpenNebula::Error.new(error_msg)
+ return error, 400
+ end
+
+ vm=VirtualMachineOCCI.new(
+ VirtualMachine.build_xml(params[:id]),
+ client)
+
+ if !vm_info['COMPUTE']['STATE']
+ error_msg = "State not defined in the OCCI XML"
+ error = OpenNebula::Error.new(error_msg)
+ return error, 400
+ end
+
+ case vm_info['COMPUTE']['STATE'].downcase
+ when "stopped"
+ rc = vm.stop
+ when "suspended"
+ rc = vm.suspend
+ when "resume"
+ rc = vm.resume
+ when "cancel"
+ rc = vm.cancel
+ when "shutdown"
+ rc = vm.shutdown
+ when "done"
+ rc = vm.finalize
+ else
+ error_msg = "Invalid state"
+ error = OpenNebula::Error.new(error_msg)
+ return error, 400
+ end
+
+ if OpenNebula.is_error?(rc)
+ return rc, 400
+ else
+ vm.info
+ response_text = vm.to_occi(@base_url)
+ return response_text, 202
+ end
+ end
+
+ # Retrieves a NETWORK resource
+ # request:: _Hash_ hash containing the data of the request
+ # [return] _String_,_Integer_ NETWORK occi representation or error,
+ # status code
+ def get_network(request, params)
+ # Get client with user credentials
+ client = get_client(request.env)
+
+ vn = VirtualNetworkOCCI.new(
+ VirtualNetwork.build_xml(params[:id]),
+ client)
+
+ result=vn.info
+
+ if OpenNebula::is_error?(result)
+ return result, 404
+ end
+
+ begin
+ return vn.to_occi, 200
+ rescue Exception => e
+ error = OpenNebula::Error.new(e.message)
+ return error, 500
+ end
+ end
+
+ # Deletes a NETWORK resource
+ # request:: _Hash_ hash containing the data of the request
+ # [return] _String_,_Integer_ Delete confirmation msg or error,
+ # status code
+ def delete_network(request, params)
+ # Get client with user credentials
+ client = get_client(request.env)
+
+ vn = VirtualNetworkOCCI.new(
+ VirtualNetwork.build_xml(params[:id]),
+ client)
+
+ result = vn.delete
+
+ if OpenNebula::is_error?(result)
+ return result, 500
+ else
+ return "", 204
+ end
+ end
+
+ # Get a STORAGE resource
+ # request:: _Hash_ hash containing the data of the request
+ # [return] _String_,_Integer_ STORAGE occi representation or error,
+ # status code
+ def get_storage(request, params)
+ # Get client with user credentials
+ client = get_client(request.env)
+
+ image=get_image(params[:id])
+
+ if image
+ image.extend(ImageOCCI)
+ return image.to_occi, 200
+ else
+ msg="Disk with id = \"" + params[:id] + "\" not found"
+ error = OpenNebula::Error.new(msg)
+ return error, 404
+ end
+ end
+
+ # Deletes a STORAGE resource (Not yet implemented)
+ # request:: _Hash_ hash containing the data of the request
+ # [return] _String_,_Integer_ Delete confirmation msg or error,
+ # status code
+ def delete_storage(request, params)
+ error = OpenNebula::Error.new("Not yet implemented")
+ return error, 501
+ end
+end
diff --git a/src/cloud/occi/lib/VirtualMachineOCCI.rb b/src/cloud/occi/lib/VirtualMachineOCCI.rb
new file mode 100755
index 0000000000..41aec5250b
--- /dev/null
+++ b/src/cloud/occi/lib/VirtualMachineOCCI.rb
@@ -0,0 +1,57 @@
+require 'OpenNebula'
+
+include OpenNebula
+
+class VirtualMachineOCCI < VirtualMachine
+ OCCI_VM = %q{
+
+ <%= id.to_s%>
+ <%= self['NAME']%>
+ <%= state_str %>
+ <% if template['DISK']!=nil
+ %><%
+ template['DISK'].each do |disk|
+ next if !disk
+ case disk['TYPE']
+ when "swap"%>
+ <% when "fs" %>
+ <%
+ else %>
+ <%
+ end
+ end %>
+
+ <% end
+ if template['NIC']
+ %><%
+ template['NIC'].each do |nic|
+ next if !nic %>
+ ip="<%= nic['IP']%>"<% end %>/><%
+ end
+ %>
+ <%
+ end
+ if template['INSTANCE_TYPE'] %>
+ <%=template['INSTANCE_TYPE']%><%
+ end %>
+
+ }.gsub(/^ /, '')
+
+
+ # Creates the VMI representation of a Virtual Machine
+ def to_occi(base_url)
+ # Let's parse the template
+ template=self.to_hash
+ template=template['VM']['TEMPLATE']
+ template['DISK']=[template['DISK']].flatten if template['DISK']
+ template['NIC']=[template['NIC']].flatten if template['NIC']
+
+ occi = ERB.new(OCCI_VM)
+ return occi.result(binding)
+
+ end
+end
+
+
+
+
diff --git a/src/cloud/occi/lib/VirtualMachinePoolOCCI.rb b/src/cloud/occi/lib/VirtualMachinePoolOCCI.rb
new file mode 100755
index 0000000000..3319da8ea7
--- /dev/null
+++ b/src/cloud/occi/lib/VirtualMachinePoolOCCI.rb
@@ -0,0 +1,26 @@
+require 'OpenNebula'
+
+include OpenNebula
+
+class VirtualMachinePoolOCCI < VirtualMachinePool
+ OCCI_VM_POOL = %q{
+ <%
+ if pool_hash['VM_POOL'] != nil
+ vmlist=[pool_hash['VM_POOL']['VM']].flatten
+ vmlist.each{|vm| %>
+ <%
+ }
+ end %>
+
+ }.gsub(/^ /, '')
+
+
+ # Creates the OCCI representation of a Virtual Machine Pool
+ def to_occi(base_url)
+ pool_hash=to_hash
+
+ occi = ERB.new(OCCI_VM_POOL)
+ return occi.result(binding)
+ end
+end
+
diff --git a/src/cloud/occi/lib/VirtualNetworkOCCI.rb b/src/cloud/occi/lib/VirtualNetworkOCCI.rb
new file mode 100755
index 0000000000..36ef471c3c
--- /dev/null
+++ b/src/cloud/occi/lib/VirtualNetworkOCCI.rb
@@ -0,0 +1,52 @@
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
+
+require 'OpenNebula'
+require 'erb'
+
+include OpenNebula
+
+class VirtualNetworkOCCI < VirtualNetwork
+ OCCI_NETWORK = %q{
+
+ <%= vn_hash['VNET']['ID'].strip %>
+ <%= vn_hash['VNET']['NAME'].strip %>
+ <%= vn_hash['VNET']['TEMPLATE']['NETWORK_ADDRESS'].strip %>
+ <%= vn_hash['VNET']['TEMPLATE']['NETWORK_SIZE'].strip %>
+
+ }.gsub(/^ /, '')
+
+ ONE_NETWORK = %q{
+ NAME = <%= network_hash['NAME'] %>
+ TYPE = RANGED
+ BRIDGE = <%= bridge %>
+ NETWORK_ADDRESS = <%= network_hash['ADDRESS'] %>
+ NETWORK_SIZE = <%= network_hash['SIZE'] %>
+ }.gsub(/^ /, '')
+
+ # Creates the OCCI representation of a Virtual Network
+ def to_occi()
+ vn_hash = to_hash
+
+ occi = ERB.new(OCCI_NETWORK)
+ return occi.result(binding)
+ end
+
+ def to_one_template(network_hash, bridge)
+ one = ERB.new(ONE_NETWORK)
+ return one.result(binding)
+ end
+end
diff --git a/src/cloud/occi/lib/VirtualNetworkPoolOCCI.rb b/src/cloud/occi/lib/VirtualNetworkPoolOCCI.rb
new file mode 100755
index 0000000000..b46e4ead7a
--- /dev/null
+++ b/src/cloud/occi/lib/VirtualNetworkPoolOCCI.rb
@@ -0,0 +1,25 @@
+require 'OpenNebula'
+
+include OpenNebula
+
+class VirtualNetworkPoolOCCI < VirtualNetworkPool
+ OCCI_NETWORK_POOL = %q{
+ <%
+ if network_pool_hash['VNET_POOL'] != nil
+ vnlist=[network_pool_hash['VNET_POOL']['VNET']].flatten
+ vnlist.each{|network|%>
+ <%
+ }
+ end %>
+
+ }.gsub(/^ /, '')
+
+ # Creates the OCCI representation of a Virtual Network
+ def to_occi(base_url)
+ network_pool_hash=to_hash
+
+ occi = ERB.new(OCCI_NETWORK_POOL)
+ return occi.result(binding)
+ end
+end
diff --git a/src/cloud/occi/lib/occi-server.rb b/src/cloud/occi/lib/occi-server.rb
new file mode 100755
index 0000000000..f42af095fa
--- /dev/null
+++ b/src/cloud/occi/lib/occi-server.rb
@@ -0,0 +1,158 @@
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
+
+##############################################################################
+# The OCCI Server provides compatible server based on the
+# OpenNebula Engine
+##############################################################################
+
+##############################################################################
+# Environment Configuration for the Cloud Server
+##############################################################################
+ONE_LOCATION=ENV["ONE_LOCATION"]
+
+if !ONE_LOCATION
+ RUBY_LIB_LOCATION="/usr/lib/one/ruby"
+ TEMPLATE_LOCATION="/etc/one/occi_templates"
+ CONFIGURATION_FILE = "/etc/one/occi-server.conf"
+else
+ RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby"
+ TEMPLATE_LOCATION=ONE_LOCATION+"/etc/occi_templates"
+ CONFIGURATION_FILE = ONE_LOCATION+"/etc/occi-server.conf"
+end
+
+$: << RUBY_LIB_LOCATION
+$: << RUBY_LIB_LOCATION+"/cloud/occi"
+$: << RUBY_LIB_LOCATION+"/cloud" # For the Repository Manager
+
+################################################
+# Required libraries
+################################################
+require 'rubygems'
+require 'sinatra'
+require 'OCCIServer'
+
+require 'OpenNebula'
+
+include OpenNebula
+
+$occi_server = OCCIServer.new(CONFIGURATION_FILE, TEMPLATE_LOCATION)
+
+##############################################################################
+# Sinatra Configuration
+##############################################################################
+set :host, $occi_server.config[:server]
+set :port, $occi_server.config[:port]
+
+##############################################################################
+# Helpers
+##############################################################################
+
+# Authentication
+before do
+ if !$occi_server.authenticate?(request.env)
+ halt 401, 'Invalid credentials'
+ end
+end
+
+# Response treatment
+helpers do
+ def treat_response(result,rc)
+ if OpenNebula::is_error?(result)
+ halt rc, result.message
+ end
+
+ status rc
+ result
+ end
+end
+
+##############################################################################
+# Actions
+##############################################################################
+
+###################################################
+# Pool Resources methods
+###################################################
+
+post '/compute' do
+ result,rc = $occi_server.post_compute(request)
+ treat_response(result,rc)
+end
+
+get '/compute' do
+ result,rc = $occi_server.get_computes(request)
+ treat_response(result,rc)
+end
+
+post '/network' do
+ result,rc = $occi_server.post_network(request)
+ treat_response(result,rc)
+end
+
+get '/network' do
+ result,rc = $occi_server.get_networks(request)
+ treat_response(result,rc)
+end
+
+post '/storage' do
+ result,rc = $occi_server.post_storage(request)
+ treat_response(result,rc)
+end
+
+get '/storage' do
+ result,rc = $occi_server.get_storages(request)
+ treat_response(result,rc)
+end
+
+###################################################
+# Entity Resources Methods
+###################################################
+
+get '/compute/:id' do
+ result,rc = $occi_server.get_compute(request, params)
+ treat_response(result,rc)
+end
+
+delete '/compute/:id' do
+ result,rc = $occi_server.delete_compute(request, params)
+ treat_response(result,rc)
+end
+
+put '/compute/:id' do
+ result,rc = $occi_server.put_compute(request, params)
+ treat_response(result,rc)
+end
+
+get '/network/:id' do
+ result,rc = $occi_server.get_network(request, params)
+ treat_response(result,rc)
+end
+
+delete '/network/:id' do
+ result,rc = $occi_server.delete_network(request, params)
+ treat_response(result,rc)
+end
+
+get '/storage/:id' do
+ result,rc = $occi_server.get_storage(request, params)
+ treat_response(result,rc)
+end
+
+delete '/storage/:id' do
+ result,rc = $occi_server.delete_storage(request, params)
+ treat_response(result,rc)
+end
diff --git a/src/cloud/rm/image.rb b/src/cloud/rm/image.rb
index f7cfcb05ec..15e9695d06 100644
--- a/src/cloud/rm/image.rb
+++ b/src/cloud/rm/image.rb
@@ -1,3 +1,18 @@
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
module OpenNebula
class Image < Sequel::Model
@@ -10,7 +25,6 @@ module OpenNebula
def self.initialize_table
set_schema do
primary_key :id, :type => Integer
- varchar :uuid
int :owner
varchar :name
varchar :description
@@ -46,29 +60,36 @@ module OpenNebula
# Creates a new Image object, fills it, copies the image
# to the repository and saves to the database
- # uuid:: _String_ UUID identifier for the image
# owner:: _Integer_ identifier of the user that owns this image
# path:: _String_ place where to copy the image from
# metadata:: _Hash_ extra data to add to the image, like name and description
# [return] _Image_ newly created image
- def self.create_image(uuid, owner, path, metadata={})
+ def self.create_image(owner, path, metadata={})
sanitized_metadata=sanitize_metadata(metadata)
data={
- :uuid => uuid,
:owner => owner,
}.merge(sanitized_metadata)
-
+
image=Image.new(data)
-
+
+ image.save
+
# TODO: make copy or movement configurable
image.copy_image(path, true)
image.get_image_info
+
image.save
-
+
+ image
+
# set metadata
end
+ def identifier
+ self.id
+ end
+
# Updates the image with the metadata provided. Currently only
# name and description can be changed
def change_metadata(metadata)
@@ -76,7 +97,7 @@ module OpenNebula
end
# Copies the image from the source path to the image repository.
- # Its name will be the image uuid. It also stores its new location
+ # Its name will be the image id. It also stores its new location
# in the object.
def copy_image(path, move=false)
if move
@@ -91,7 +112,7 @@ module OpenNebula
# this Image object.
def image_path
@@image_dir||='images'
- File.join(@@image_dir, uuid)
+ File.join(@@image_dir, self.id.to_s)
end
# Extracts md5 and size from the image file and stores these data
@@ -103,26 +124,26 @@ module OpenNebula
# Adds a user to the list of allowed users of this image
def add_acl(user)
- acl=ImageAcl.new({:uuid => self.uuid, :user => user})
+ acl=ImageAcl.new({:image_id => self.id, :user => user})
acl.save
end
# Deletes a user fom the list of allowed users of this image
def del_acl(user)
- acl=ImageAcl[:uuid => self.uuid, :user => user]
+ acl=ImageAcl[:image_id => self.id, :user => user]
acl.destroy if acl
end
# Checks if a user has permissions to use this image
def has_permission?(user)
return true if self.owner==user
- ImageAcl[:uuid => self.uuid, :user => user]!=nil
+ ImageAcl[:image_id => self.id, :user => user]!=nil
end
# Returns the xml representation of the image.
def to_xml
xml="\n"
- xml<<" #{uuid}\n"
+ xml<<" #{id}\n"
xml<<" #{owner}\n"
xml<<" #{name}\n"
xml<<" #{description}\n"
@@ -135,7 +156,7 @@ module OpenNebula
# Like to_xml but does not show image file path data
def to_xml_lite
xml="\n"
- xml<<" #{uuid}\n"
+ xml<<" #{id}\n"
xml<<" #{owner}\n"
xml<<" #{name}\n"
xml<<" #{description}\n"
@@ -151,11 +172,11 @@ module OpenNebula
def self.initialize_table
set_schema do
primary_key :id, :type => Integer
- varchar :uuid
+ varchar :image_id
int :user
end
create_table unless table_exists?
end
end
-end
\ No newline at end of file
+end
diff --git a/src/cloud/rm/repo_manager.rb b/src/cloud/rm/repo_manager.rb
index 2c171ca9e0..fd3139f83f 100644
--- a/src/cloud/rm/repo_manager.rb
+++ b/src/cloud/rm/repo_manager.rb
@@ -1,43 +1,47 @@
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
require 'rubygems'
-require 'uuid'
require 'fileutils'
require 'sequel'
require 'logger'
-# Seems that database should be opened before defining models
-# TODO: fix this
-if ONE_RM_DATABASE
- DB=Sequel.sqlite(ONE_RM_DATABASE)
-else
- DB=Sequel.sqlite('database.db')
-end
-#DB.loggers << Logger.new($stdout)
-require 'image'
-
-
-IMAGE_DIR='images'
-
module OpenNebula
class RepoManager
- def initialize
- @uuid=UUID.new
+ def initialize(rm_db=nil)
+ raise "DB not defined" if !rm_db
+
+ @db=Sequel.sqlite(rm_db)
+
+ require 'image'
+
Image.initialize_table
ImageAcl.initialize_table
end
def add(owner, path, metadata={})
- uuid=@uuid.generate
-
- Image.create_image(uuid, owner, path, metadata)
+ Image.create_image(owner, path, metadata)
end
- def get(uuid)
- Image[:uuid => uuid]
+ def get(image_id)
+ Image[:id => image_id]
end
- def update(uuid, metadata)
- image=get(uuid)
+ def update(image_id, metadata)
+ image=get(image_id)
image.update(metadata)
end
@@ -47,7 +51,7 @@ module OpenNebula
end
=begin
-OpenNebula::Image.create_image('uid', 10, 'repo_manager.rb',
+OpenNebula::Image.create_image(10, 'repo_manager.rb',
:name => 'nombre',
:noexiste => 'nada'
)
diff --git a/src/common/ActionManager.cc b/src/common/ActionManager.cc
index 5690ca6a7b..e2fe5cb467 100644
--- a/src/common/ActionManager.cc
+++ b/src/common/ActionManager.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/common/Attribute.cc b/src/common/Attribute.cc
index 9c27707821..50721a7764 100644
--- a/src/common/Attribute.cc
+++ b/src/common/Attribute.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/common/SConstruct b/src/common/SConstruct
index dda3707916..7ca42d71df 100644
--- a/src/common/SConstruct
+++ b/src/common/SConstruct
@@ -1,8 +1,7 @@
# SConstruct for src/common
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/dm/DispatchManager.cc b/src/dm/DispatchManager.cc
index f7c0b69404..efd1eb47d5 100644
--- a/src/dm/DispatchManager.cc
+++ b/src/dm/DispatchManager.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/dm/DispatchManagerActions.cc b/src/dm/DispatchManagerActions.cc
index 2ea44cf1a1..330cee2f87 100644
--- a/src/dm/DispatchManagerActions.cc
+++ b/src/dm/DispatchManagerActions.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/dm/DispatchManagerStates.cc b/src/dm/DispatchManagerStates.cc
index 6cc76aa383..658fdf5743 100644
--- a/src/dm/DispatchManagerStates.cc
+++ b/src/dm/DispatchManagerStates.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/dm/SConstruct b/src/dm/SConstruct
index 44c3d363ca..73c2fb8b7a 100644
--- a/src/dm/SConstruct
+++ b/src/dm/SConstruct
@@ -1,8 +1,7 @@
# SConstruct for src/vm
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/hm/HookManager.cc b/src/hm/HookManager.cc
index a165291ea3..5e87d224eb 100644
--- a/src/hm/HookManager.cc
+++ b/src/hm/HookManager.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/hm/HookManagerDriver.cc b/src/hm/HookManagerDriver.cc
index 5655241904..454e9fa2c5 100644
--- a/src/hm/HookManagerDriver.cc
+++ b/src/hm/HookManagerDriver.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/hm/SConstruct b/src/hm/SConstruct
index edd8794d88..9e810192bf 100755
--- a/src/hm/SConstruct
+++ b/src/hm/SConstruct
@@ -1,8 +1,7 @@
# SConstruct for src/hm
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/hm_mad/hmrc b/src/hm_mad/hmrc
index 919c811fa7..6f868dff5c 100644
--- a/src/hm_mad/hmrc
+++ b/src/hm_mad/hmrc
@@ -1,6 +1,5 @@
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/hm_mad/one_hm b/src/hm_mad/one_hm
index 1f75e25cc1..cc4e064093 100755
--- a/src/hm_mad/one_hm
+++ b/src/hm_mad/one_hm
@@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/hm_mad/one_hm.rb b/src/hm_mad/one_hm.rb
index 71ca59ddad..2a20a62fed 100755
--- a/src/hm_mad/one_hm.rb
+++ b/src/hm_mad/one_hm.rb
@@ -1,8 +1,7 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/host/Host.cc b/src/host/Host.cc
index 55fa1fd994..a4bc25a75c 100644
--- a/src/host/Host.cc
+++ b/src/host/Host.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/host/HostPool.cc b/src/host/HostPool.cc
index 1043505805..050b8721a2 100644
--- a/src/host/HostPool.cc
+++ b/src/host/HostPool.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/host/HostShare.cc b/src/host/HostShare.cc
index c3ea6c3148..d40285d4a5 100644
--- a/src/host/HostShare.cc
+++ b/src/host/HostShare.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/host/HostTemplate.cc b/src/host/HostTemplate.cc
index 4df8516c91..3e8d04a0e3 100644
--- a/src/host/HostTemplate.cc
+++ b/src/host/HostTemplate.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/host/SConstruct b/src/host/SConstruct
index ad7af690e0..bbd6f87a3b 100644
--- a/src/host/SConstruct
+++ b/src/host/SConstruct
@@ -1,8 +1,7 @@
# SConstruct for src/vm
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/host/host_parser.c b/src/host/host_parser.c
index 4de6dc32fe..4accae72dd 100644
--- a/src/host/host_parser.c
+++ b/src/host/host_parser.c
@@ -28,7 +28,7 @@
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 34
+#define YY_FLEX_SUBMINOR_VERSION 35
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
@@ -211,13 +211,6 @@ extern FILE *host_in, *host_out;
#define unput(c) yyunput( c, (yytext_ptr) )
-/* The following is because we cannot portably get our hands on size_t
- * (without autoconf's help, which isn't available because we want
- * flex-generated scanners to compile on their own).
- * Given that the standard has decreed that size_t exists since 1989,
- * I guess we can afford to depend on it. Manoj.
- */
-
#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
typedef size_t yy_size_t;
@@ -502,8 +495,7 @@ int host__flex_debug = 0;
char *host_text;
#line 1 "host_parser.l"
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
@@ -517,7 +509,7 @@ char *host_text;
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
-#line 19 "host_parser.l"
+#line 18 "host_parser.l"
#include
#include
#include
@@ -531,7 +523,7 @@ char *host_text;
#define YY_USER_ACTION llocp->first_line = host_lineno; \
llocp->first_column = llocp->last_column; \
llocp->last_column += host_leng;
-#line 535 "host_parser.c"
+#line 527 "host_parser.c"
#define INITIAL 0
@@ -549,6 +541,35 @@ char *host_text;
static int yy_init_globals (void );
+/* Accessor methods to globals.
+ These are made visible to non-reentrant scanners for convenience. */
+
+int host_lex_destroy (void );
+
+int host_get_debug (void );
+
+void host_set_debug (int debug_flag );
+
+YY_EXTRA_TYPE host_get_extra (void );
+
+void host_set_extra (YY_EXTRA_TYPE user_defined );
+
+FILE *host_get_in (void );
+
+void host_set_in (FILE * in_str );
+
+FILE *host_get_out (void );
+
+void host_set_out (FILE * out_str );
+
+int host_get_leng (void );
+
+char *host_get_text (void );
+
+int host_get_lineno (void );
+
+void host_set_lineno (int line_number );
+
/* Macros after this point can all be overridden by user definitions in
* section 1.
*/
@@ -682,11 +703,11 @@ YY_DECL
register char *yy_cp, *yy_bp;
register int yy_act;
-#line 39 "host_parser.l"
+#line 38 "host_parser.l"
/* --- Tokens --- */
-#line 690 "host_parser.c"
+#line 711 "host_parser.c"
if ( !(yy_init) )
{
@@ -781,26 +802,26 @@ do_action: /* This label is used only to access EOF actions. */
case 1:
YY_RULE_SETUP
-#line 42 "host_parser.l"
+#line 41 "host_parser.l"
{ return *host_text;}
YY_BREAK
/* --- Strings, also quoted form --- */
case 2:
YY_RULE_SETUP
-#line 46 "host_parser.l"
+#line 45 "host_parser.l"
{ lvalp->val_str = strdup(host_text);
return STRING;}
YY_BREAK
case 3:
YY_RULE_SETUP
-#line 49 "host_parser.l"
+#line 48 "host_parser.l"
{ lvalp->val_str = NULL;
return STRING;}
YY_BREAK
case 4:
/* rule 4 can match eol */
YY_RULE_SETUP
-#line 52 "host_parser.l"
+#line 51 "host_parser.l"
{ lvalp->val_str = strdup(host_text+1);
lvalp->val_str[host_leng-2] = '\0';
return STRING;}
@@ -808,28 +829,28 @@ YY_RULE_SETUP
/* --- Numbers --- */
case 5:
YY_RULE_SETUP
-#line 57 "host_parser.l"
+#line 56 "host_parser.l"
{ lvalp->val_int = atoi(host_text);
return INTEGER;}
YY_BREAK
case 6:
YY_RULE_SETUP
-#line 60 "host_parser.l"
+#line 59 "host_parser.l"
{ lvalp->val_float = atof(host_text);
return FLOAT;}
YY_BREAK
/* --- blanks --- */
case 7:
YY_RULE_SETUP
-#line 64 "host_parser.l"
+#line 63 "host_parser.l"
YY_BREAK
case 8:
YY_RULE_SETUP
-#line 66 "host_parser.l"
+#line 65 "host_parser.l"
ECHO;
YY_BREAK
-#line 833 "host_parser.c"
+#line 854 "host_parser.c"
case YY_STATE_EOF(INITIAL):
yyterminate();
@@ -1798,7 +1819,7 @@ void host_free (void * ptr )
#define YYTABLES_NAME "yytables"
-#line 66 "host_parser.l"
+#line 65 "host_parser.l"
diff --git a/src/host/host_parser.l b/src/host/host_parser.l
index ed3c8d97dc..0fd5a2851d 100644
--- a/src/host/host_parser.l
+++ b/src/host/host_parser.l
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/host/host_rank.cc b/src/host/host_rank.cc
index 9987a05693..a353006530 100644
--- a/src/host/host_rank.cc
+++ b/src/host/host_rank.cc
@@ -1,24 +1,23 @@
-/* A Bison parser, made by GNU Bison 2.3. */
+
+/* A Bison parser, made by GNU Bison 2.4.1. */
/* Skeleton implementation for Bison's Yacc-like parsers in C
-
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
+
+ This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ along with this program. If not, see . */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
@@ -29,7 +28,7 @@
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
-
+
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
@@ -47,7 +46,7 @@
#define YYBISON 1
/* Bison version. */
-#define YYBISON_VERSION "2.3"
+#define YYBISON_VERSION "2.4.1"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
@@ -55,40 +54,29 @@
/* Pure parsers. */
#define YYPURE 1
+/* Push parsers. */
+#define YYPUSH 0
+
+/* Pull parsers. */
+#define YYPULL 1
+
/* Using locations. */
#define YYLSP_NEEDED 1
/* Substitute the variable and function names. */
-#define yyparse host_rank_parse
-#define yylex host_rank_lex
-#define yyerror host_rank_error
-#define yylval host_rank_lval
-#define yychar host_rank_char
-#define yydebug host_rank_debug
-#define yynerrs host_rank_nerrs
-#define yylloc host_rank_lloc
-
-/* Tokens. */
-#ifndef YYTOKENTYPE
-# define YYTOKENTYPE
- /* Put the tokens into the symbol table, so that GDB and other debuggers
- know about them. */
- enum yytokentype {
- INTEGER = 258,
- STRING = 259,
- FLOAT = 260
- };
-#endif
-/* Tokens. */
-#define INTEGER 258
-#define STRING 259
-#define FLOAT 260
-
-
-
+#define yyparse host_rank_parse
+#define yylex host_rank_lex
+#define yyerror host_rank_error
+#define yylval host_rank_lval
+#define yychar host_rank_char
+#define yydebug host_rank_debug
+#define yynerrs host_rank_nerrs
+#define yylloc host_rank_lloc
/* Copy the first part of user declarations. */
-#line 18 "host_rank.y"
+
+/* Line 189 of yacc.c */
+#line 17 "host_rank.y"
#include
#include
@@ -122,6 +110,9 @@ int host_rank_parse(Host * host, int& result, char ** errmsg);
+/* Line 189 of yacc.c */
+#line 115 "host_rank.cc"
+
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
@@ -140,20 +131,40 @@ int host_rank_parse(Host * host, int& result, char ** errmsg);
# define YYTOKEN_TABLE 0
#endif
+
+/* Tokens. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum yytokentype {
+ INTEGER = 258,
+ STRING = 259,
+ FLOAT = 260
+ };
+#endif
+
+
+
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
-#line 55 "host_rank.y"
{
+
+/* Line 214 of yacc.c */
+#line 54 "host_rank.y"
+
char * val_str;
int val_int;
float val_float;
-}
-/* Line 187 of yacc.c. */
-#line 153 "host_rank.cc"
- YYSTYPE;
+
+
+
+/* Line 214 of yacc.c */
+#line 164 "host_rank.cc"
+} YYSTYPE;
+# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
-# define YYSTYPE_IS_TRIVIAL 1
#endif
#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
@@ -173,8 +184,8 @@ typedef struct YYLTYPE
/* Copy the second part of user declarations. */
-/* Line 216 of yacc.c. */
-#line 178 "host_rank.cc"
+/* Line 264 of yacc.c */
+#line 189 "host_rank.cc"
#ifdef short
# undef short
@@ -249,14 +260,14 @@ typedef short int yytype_int16;
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static int
-YYID (int i)
+YYID (int yyi)
#else
static int
-YYID (i)
- int i;
+YYID (yyi)
+ int yyi;
#endif
{
- return i;
+ return yyi;
}
#endif
@@ -338,9 +349,9 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */
/* A type that is properly aligned for any stack member. */
union yyalloc
{
- yytype_int16 yyss;
- YYSTYPE yyvs;
- YYLTYPE yyls;
+ yytype_int16 yyss_alloc;
+ YYSTYPE yyvs_alloc;
+ YYLTYPE yyls_alloc;
};
/* The size of the maximum gap between one aligned stack and the next. */
@@ -375,12 +386,12 @@ union yyalloc
elements in the stack, and YYPTR gives the new location of the
stack. Advance YYPTR to a properly aligned location for the next
stack. */
-# define YYSTACK_RELOCATE(Stack) \
+# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
do \
{ \
YYSIZE_T yynewbytes; \
- YYCOPY (&yyptr->Stack, Stack, yysize); \
- Stack = &yyptr->Stack; \
+ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
+ Stack = &yyptr->Stack_alloc; \
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
yyptr += yynewbytes / sizeof (*yyptr); \
} \
@@ -462,8 +473,8 @@ static const yytype_int8 yyrhs[] =
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const yytype_uint8 yyrline[] =
{
- 0, 77, 77, 78, 81, 85, 86, 87, 88, 89,
- 90, 91, 92
+ 0, 76, 76, 77, 80, 156, 157, 158, 159, 160,
+ 161, 162, 163
};
#endif
@@ -754,17 +765,20 @@ yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, host, result, error_ms
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static void
-yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
+yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
#else
static void
-yy_stack_print (bottom, top)
- yytype_int16 *bottom;
- yytype_int16 *top;
+yy_stack_print (yybottom, yytop)
+ yytype_int16 *yybottom;
+ yytype_int16 *yytop;
#endif
{
YYFPRINTF (stderr, "Stack now");
- for (; bottom <= top; ++bottom)
- YYFPRINTF (stderr, " %d", *bottom);
+ for (; yybottom <= yytop; yybottom++)
+ {
+ int yybot = *yybottom;
+ YYFPRINTF (stderr, " %d", yybot);
+ }
YYFPRINTF (stderr, "\n");
}
@@ -802,11 +816,11 @@ yy_reduce_print (yyvsp, yylsp, yyrule, host, result, error_msg)
/* The symbols being reduced. */
for (yyi = 0; yyi < yynrhs; yyi++)
{
- fprintf (stderr, " $%d = ", yyi + 1);
+ YYFPRINTF (stderr, " $%d = ", yyi + 1);
yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
&(yyvsp[(yyi + 1) - (yynrhs)])
, &(yylsp[(yyi + 1) - (yynrhs)]) , host, result, error_msg);
- fprintf (stderr, "\n");
+ YYFPRINTF (stderr, "\n");
}
}
@@ -1094,10 +1108,8 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp, host, result, error_msg)
break;
}
}
-
/* Prevent warnings from -Wmissing-prototypes. */
-
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int yyparse (void *YYPARSE_PARAM);
@@ -1116,10 +1128,9 @@ int yyparse ();
-
-/*----------.
-| yyparse. |
-`----------*/
+/*-------------------------.
+| yyparse or yypush_parse. |
+`-------------------------*/
#ifdef YYPARSE_PARAM
#if (defined __STDC__ || defined __C99__FUNC__ \
@@ -1145,24 +1156,59 @@ yyparse (host, result, error_msg)
#endif
#endif
{
- /* The look-ahead symbol. */
+/* The lookahead symbol. */
int yychar;
-/* The semantic value of the look-ahead symbol. */
+/* The semantic value of the lookahead symbol. */
YYSTYPE yylval;
-/* Number of syntax errors so far. */
-int yynerrs;
-/* Location data for the look-ahead symbol. */
+/* Location data for the lookahead symbol. */
YYLTYPE yylloc;
- int yystate;
+ /* Number of syntax errors so far. */
+ int yynerrs;
+
+ int yystate;
+ /* Number of tokens to shift before error messages enabled. */
+ int yyerrstatus;
+
+ /* The stacks and their tools:
+ `yyss': related to states.
+ `yyvs': related to semantic values.
+ `yyls': related to locations.
+
+ Refer to the stacks thru separate pointers, to allow yyoverflow
+ to reallocate them elsewhere. */
+
+ /* The state stack. */
+ yytype_int16 yyssa[YYINITDEPTH];
+ yytype_int16 *yyss;
+ yytype_int16 *yyssp;
+
+ /* The semantic value stack. */
+ YYSTYPE yyvsa[YYINITDEPTH];
+ YYSTYPE *yyvs;
+ YYSTYPE *yyvsp;
+
+ /* The location stack. */
+ YYLTYPE yylsa[YYINITDEPTH];
+ YYLTYPE *yyls;
+ YYLTYPE *yylsp;
+
+ /* The locations where the error started and ended. */
+ YYLTYPE yyerror_range[2];
+
+ YYSIZE_T yystacksize;
+
int yyn;
int yyresult;
- /* Number of tokens to shift before error messages enabled. */
- int yyerrstatus;
- /* Look-ahead token as an internal (translated) token number. */
- int yytoken = 0;
+ /* Lookahead token as an internal (translated) token number. */
+ int yytoken;
+ /* The variables used to return semantic value and location from the
+ action routines. */
+ YYSTYPE yyval;
+ YYLTYPE yyloc;
+
#if YYERROR_VERBOSE
/* Buffer for error messages, and its allocated size. */
char yymsgbuf[128];
@@ -1170,63 +1216,37 @@ YYLTYPE yylloc;
YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
#endif
- /* Three stacks and their tools:
- `yyss': related to states,
- `yyvs': related to semantic values,
- `yyls': related to locations.
-
- Refer to the stacks thru separate pointers, to allow yyoverflow
- to reallocate them elsewhere. */
-
- /* The state stack. */
- yytype_int16 yyssa[YYINITDEPTH];
- yytype_int16 *yyss = yyssa;
- yytype_int16 *yyssp;
-
- /* The semantic value stack. */
- YYSTYPE yyvsa[YYINITDEPTH];
- YYSTYPE *yyvs = yyvsa;
- YYSTYPE *yyvsp;
-
- /* The location stack. */
- YYLTYPE yylsa[YYINITDEPTH];
- YYLTYPE *yyls = yylsa;
- YYLTYPE *yylsp;
- /* The locations where the error started and ended. */
- YYLTYPE yyerror_range[2];
-
#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
- YYSIZE_T yystacksize = YYINITDEPTH;
-
- /* The variables used to return semantic value and location from the
- action routines. */
- YYSTYPE yyval;
- YYLTYPE yyloc;
-
/* The number of symbols on the RHS of the reduced rule.
Keep to zero when no symbol should be popped. */
int yylen = 0;
+ yytoken = 0;
+ yyss = yyssa;
+ yyvs = yyvsa;
+ yyls = yylsa;
+ yystacksize = YYINITDEPTH;
+
YYDPRINTF ((stderr, "Starting parse\n"));
yystate = 0;
yyerrstatus = 0;
yynerrs = 0;
- yychar = YYEMPTY; /* Cause a token to be read. */
+ yychar = YYEMPTY; /* Cause a token to be read. */
/* Initialize stack pointers.
Waste one element of value and location stack
so that they stay on the same level as the state stack.
The wasted elements are never initialized. */
-
yyssp = yyss;
yyvsp = yyvs;
yylsp = yyls;
+
#if YYLTYPE_IS_TRIVIAL
/* Initialize the default location before parsing starts. */
yylloc.first_line = yylloc.last_line = 1;
- yylloc.first_column = yylloc.last_column = 0;
+ yylloc.first_column = yylloc.last_column = 1;
#endif
goto yysetstate;
@@ -1265,6 +1285,7 @@ YYLTYPE yylloc;
&yyvs1, yysize * sizeof (*yyvsp),
&yyls1, yysize * sizeof (*yylsp),
&yystacksize);
+
yyls = yyls1;
yyss = yyss1;
yyvs = yyvs1;
@@ -1286,9 +1307,9 @@ YYLTYPE yylloc;
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
if (! yyptr)
goto yyexhaustedlab;
- YYSTACK_RELOCATE (yyss);
- YYSTACK_RELOCATE (yyvs);
- YYSTACK_RELOCATE (yyls);
+ YYSTACK_RELOCATE (yyss_alloc, yyss);
+ YYSTACK_RELOCATE (yyvs_alloc, yyvs);
+ YYSTACK_RELOCATE (yyls_alloc, yyls);
# undef YYSTACK_RELOCATE
if (yyss1 != yyssa)
YYSTACK_FREE (yyss1);
@@ -1309,6 +1330,9 @@ YYLTYPE yylloc;
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
+ if (yystate == YYFINAL)
+ YYACCEPT;
+
goto yybackup;
/*-----------.
@@ -1317,16 +1341,16 @@ YYLTYPE yylloc;
yybackup:
/* Do appropriate processing given the current state. Read a
- look-ahead token if we need one and don't already have one. */
+ lookahead token if we need one and don't already have one. */
- /* First try to decide what to do without reference to look-ahead token. */
+ /* First try to decide what to do without reference to lookahead token. */
yyn = yypact[yystate];
if (yyn == YYPACT_NINF)
goto yydefault;
- /* Not known => get a look-ahead token if don't already have one. */
+ /* Not known => get a lookahead token if don't already have one. */
- /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
+ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
if (yychar == YYEMPTY)
{
YYDPRINTF ((stderr, "Reading a token: "));
@@ -1358,20 +1382,16 @@ yybackup:
goto yyreduce;
}
- if (yyn == YYFINAL)
- YYACCEPT;
-
/* Count tokens shifted since error; after three, turn off error
status. */
if (yyerrstatus)
yyerrstatus--;
- /* Shift the look-ahead token. */
+ /* Shift the lookahead token. */
YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
- /* Discard the shifted token unless it is eof. */
- if (yychar != YYEOF)
- yychar = YYEMPTY;
+ /* Discard the shifted token. */
+ yychar = YYEMPTY;
yystate = yyn;
*++yyvsp = yylval;
@@ -1412,66 +1432,161 @@ yyreduce:
switch (yyn)
{
case 2:
-#line 77 "host_rank.y"
+
+/* Line 1455 of yacc.c */
+#line 76 "host_rank.y"
{ result = static_cast((yyvsp[(1) - (1)].val_float));;}
break;
case 3:
-#line 78 "host_rank.y"
+
+/* Line 1455 of yacc.c */
+#line 77 "host_rank.y"
{ result = 0; ;}
break;
case 4:
-#line 81 "host_rank.y"
+
+/* Line 1455 of yacc.c */
+#line 80 "host_rank.y"
{ string val;
- host->get_template_attribute((yyvsp[(1) - (1)].val_str),val);
- (yyval.val_float) = val.empty() ? 0.0 : atof(val.c_str());
- free((yyvsp[(1) - (1)].val_str)); ;}
+ string attr((yyvsp[(1) - (1)].val_str));
+
+ if (attr == "RUNNING_VMS")
+ {
+ (yyval.val_float) = static_cast
+ (host->get_share_running_vms());
+ }
+ else if (attr == "ALLOCATED_MEMORY")
+ {
+ (yyval.val_float) = static_cast
+ (host->get_share_mem_usage());
+ }
+ else if (attr == "ALLOCATED_CPU")
+ {
+ (yyval.val_float) = static_cast
+ (host->get_share_cpu_usage());
+ }
+ else if (attr == "ALLOCATED_DISK")
+ {
+ (yyval.val_float) = static_cast
+ (host->get_share_disk_usage());
+ }
+ else if (attr == "USED_MEMORY")
+ {
+ (yyval.val_float) = static_cast
+ (host->get_share_used_mem());
+ }
+ else if (attr == "USED_CPU")
+ {
+ (yyval.val_float) = static_cast
+ (host->get_share_used_cpu());
+ }
+ else if (attr == "USED_DISK")
+ {
+ (yyval.val_float) = static_cast
+ (host->get_share_used_disk());
+ }
+ else if (attr == "FREE_MEMORY")
+ {
+ (yyval.val_float) = static_cast
+ (host->get_share_free_mem());
+ }
+ else if (attr == "FREE_CPU")
+ {
+ (yyval.val_float) = static_cast
+ (host->get_share_free_cpu());
+ }
+ else if (attr == "FREE_DISK")
+ {
+ (yyval.val_float) = static_cast
+ (host->get_share_free_disk());
+ }
+ else if (attr == "MAX_MEMORY")
+ {
+ (yyval.val_float) = static_cast
+ (host->get_share_max_mem());
+ }
+ else if (attr == "MAX_CPU")
+ {
+ (yyval.val_float) = static_cast
+ (host->get_share_max_cpu());
+ }
+ else if (attr == "MAX_DISK")
+ {
+ (yyval.val_float) = static_cast
+ (host->get_share_max_disk());
+ }
+ else
+ {
+ host->get_template_attribute((yyvsp[(1) - (1)].val_str),val);
+ (yyval.val_float) = val.empty() ? 0.0 : atof(val.c_str());
+ }
+
+ free((yyvsp[(1) - (1)].val_str));
+ ;}
break;
case 5:
-#line 85 "host_rank.y"
+
+/* Line 1455 of yacc.c */
+#line 156 "host_rank.y"
{ (yyval.val_float) = (yyvsp[(1) - (1)].val_float); ;}
break;
case 6:
-#line 86 "host_rank.y"
+
+/* Line 1455 of yacc.c */
+#line 157 "host_rank.y"
{ (yyval.val_float) = static_cast((yyvsp[(1) - (1)].val_int)); ;}
break;
case 7:
-#line 87 "host_rank.y"
+
+/* Line 1455 of yacc.c */
+#line 158 "host_rank.y"
{ (yyval.val_float) = (yyvsp[(1) - (3)].val_float) + (yyvsp[(3) - (3)].val_float);;}
break;
case 8:
-#line 88 "host_rank.y"
+
+/* Line 1455 of yacc.c */
+#line 159 "host_rank.y"
{ (yyval.val_float) = (yyvsp[(1) - (3)].val_float) - (yyvsp[(3) - (3)].val_float);;}
break;
case 9:
-#line 89 "host_rank.y"
+
+/* Line 1455 of yacc.c */
+#line 160 "host_rank.y"
{ (yyval.val_float) = (yyvsp[(1) - (3)].val_float) * (yyvsp[(3) - (3)].val_float);;}
break;
case 10:
-#line 90 "host_rank.y"
+
+/* Line 1455 of yacc.c */
+#line 161 "host_rank.y"
{ (yyval.val_float) = (yyvsp[(1) - (3)].val_float) / (yyvsp[(3) - (3)].val_float);;}
break;
case 11:
-#line 91 "host_rank.y"
+
+/* Line 1455 of yacc.c */
+#line 162 "host_rank.y"
{ (yyval.val_float) = - (yyvsp[(2) - (2)].val_float);;}
break;
case 12:
-#line 92 "host_rank.y"
+
+/* Line 1455 of yacc.c */
+#line 163 "host_rank.y"
{ (yyval.val_float) = (yyvsp[(2) - (3)].val_float);;}
break;
-/* Line 1267 of yacc.c. */
-#line 1475 "host_rank.cc"
+
+/* Line 1455 of yacc.c */
+#line 1590 "host_rank.cc"
default: break;
}
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -1547,7 +1662,7 @@ yyerrlab:
if (yyerrstatus == 3)
{
- /* If just tried and failed to reuse look-ahead token after an
+ /* If just tried and failed to reuse lookahead token after an
error, discard it. */
if (yychar <= YYEOF)
@@ -1564,7 +1679,7 @@ yyerrlab:
}
}
- /* Else will try to reuse look-ahead token after shifting the error
+ /* Else will try to reuse lookahead token after shifting the error
token. */
goto yyerrlab1;
@@ -1622,14 +1737,11 @@ yyerrlab1:
YY_STACK_PRINT (yyss, yyssp);
}
- if (yyn == YYFINAL)
- YYACCEPT;
-
*++yyvsp = yylval;
yyerror_range[1] = yylloc;
/* Using YYLLOC is tempting, but would change the location of
- the look-ahead. YYLOC is available though. */
+ the lookahead. YYLOC is available though. */
YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
*++yylsp = yyloc;
@@ -1654,7 +1766,7 @@ yyabortlab:
yyresult = 1;
goto yyreturn;
-#ifndef yyoverflow
+#if !defined(yyoverflow) || YYERROR_VERBOSE
/*-------------------------------------------------.
| yyexhaustedlab -- memory exhaustion comes here. |
`-------------------------------------------------*/
@@ -1665,7 +1777,7 @@ yyexhaustedlab:
#endif
yyreturn:
- if (yychar != YYEOF && yychar != YYEMPTY)
+ if (yychar != YYEMPTY)
yydestruct ("Cleanup: discarding lookahead",
yytoken, &yylval, &yylloc, host, result, error_msg);
/* Do not reclaim the symbols of the rule which action triggered
@@ -1691,7 +1803,9 @@ yyreturn:
}
-#line 95 "host_rank.y"
+
+/* Line 1675 of yacc.c */
+#line 166 "host_rank.y"
extern "C" void host_rank_error(
diff --git a/src/host/host_rank.h b/src/host/host_rank.h
index 954d6d595f..0218495b62 100644
--- a/src/host/host_rank.h
+++ b/src/host/host_rank.h
@@ -1,24 +1,23 @@
-/* A Bison parser, made by GNU Bison 2.3. */
+
+/* A Bison parser, made by GNU Bison 2.4.1. */
/* Skeleton interface for Bison's Yacc-like parsers in C
-
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
+
+ This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ along with this program. If not, see . */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
@@ -29,10 +28,11 @@
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
-
+
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
+
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
@@ -44,28 +44,28 @@
FLOAT = 260
};
#endif
-/* Tokens. */
-#define INTEGER 258
-#define STRING 259
-#define FLOAT 260
-
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
-#line 55 "host_rank.y"
{
+
+/* Line 1676 of yacc.c */
+#line 54 "host_rank.y"
+
char * val_str;
int val_int;
float val_float;
-}
-/* Line 1489 of yacc.c. */
+
+
+
+/* Line 1676 of yacc.c */
#line 65 "host_rank.hh"
- YYSTYPE;
+} YYSTYPE;
+# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
-# define YYSTYPE_IS_TRIVIAL 1
#endif
@@ -84,3 +84,4 @@ typedef struct YYLTYPE
#endif
+
diff --git a/src/host/host_rank.y b/src/host/host_rank.y
index 3fedb6c3a6..43084a2011 100644
--- a/src/host/host_rank.y
+++ b/src/host/host_rank.y
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
@@ -79,9 +78,81 @@ stmt: expr { result = static_cast($1);}
;
expr: STRING { string val;
- host->get_template_attribute($1,val);
- $$ = val.empty() ? 0.0 : atof(val.c_str());
- free($1); }
+ string attr($1);
+
+ if (attr == "RUNNING_VMS")
+ {
+ $$ = static_cast
+ (host->get_share_running_vms());
+ }
+ else if (attr == "ALLOCATED_MEMORY")
+ {
+ $$ = static_cast
+ (host->get_share_mem_usage());
+ }
+ else if (attr == "ALLOCATED_CPU")
+ {
+ $$ = static_cast
+ (host->get_share_cpu_usage());
+ }
+ else if (attr == "ALLOCATED_DISK")
+ {
+ $$ = static_cast
+ (host->get_share_disk_usage());
+ }
+ else if (attr == "USED_MEMORY")
+ {
+ $$ = static_cast
+ (host->get_share_used_mem());
+ }
+ else if (attr == "USED_CPU")
+ {
+ $$ = static_cast
+ (host->get_share_used_cpu());
+ }
+ else if (attr == "USED_DISK")
+ {
+ $$ = static_cast
+ (host->get_share_used_disk());
+ }
+ else if (attr == "FREE_MEMORY")
+ {
+ $$ = static_cast
+ (host->get_share_free_mem());
+ }
+ else if (attr == "FREE_CPU")
+ {
+ $$ = static_cast
+ (host->get_share_free_cpu());
+ }
+ else if (attr == "FREE_DISK")
+ {
+ $$ = static_cast
+ (host->get_share_free_disk());
+ }
+ else if (attr == "MAX_MEMORY")
+ {
+ $$ = static_cast
+ (host->get_share_max_mem());
+ }
+ else if (attr == "MAX_CPU")
+ {
+ $$ = static_cast
+ (host->get_share_max_cpu());
+ }
+ else if (attr == "MAX_DISK")
+ {
+ $$ = static_cast
+ (host->get_share_max_disk());
+ }
+ else
+ {
+ host->get_template_attribute($1,val);
+ $$ = val.empty() ? 0.0 : atof(val.c_str());
+ }
+
+ free($1);
+ }
| FLOAT { $$ = $1; }
| INTEGER { $$ = static_cast($1); }
| expr '+' expr { $$ = $1 + $3;}
diff --git a/src/host/host_requirements.cc b/src/host/host_requirements.cc
index 4b73b96e66..d62eda1064 100644
--- a/src/host/host_requirements.cc
+++ b/src/host/host_requirements.cc
@@ -1,24 +1,23 @@
-/* A Bison parser, made by GNU Bison 2.3. */
+
+/* A Bison parser, made by GNU Bison 2.4.1. */
/* Skeleton implementation for Bison's Yacc-like parsers in C
-
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
+
+ This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ along with this program. If not, see . */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
@@ -29,7 +28,7 @@
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
-
+
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
@@ -47,7 +46,7 @@
#define YYBISON 1
/* Bison version. */
-#define YYBISON_VERSION "2.3"
+#define YYBISON_VERSION "2.4.1"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
@@ -55,40 +54,29 @@
/* Pure parsers. */
#define YYPURE 1
+/* Push parsers. */
+#define YYPUSH 0
+
+/* Pull parsers. */
+#define YYPULL 1
+
/* Using locations. */
#define YYLSP_NEEDED 1
/* Substitute the variable and function names. */
-#define yyparse host_requirements_parse
-#define yylex host_requirements_lex
-#define yyerror host_requirements_error
-#define yylval host_requirements_lval
-#define yychar host_requirements_char
-#define yydebug host_requirements_debug
-#define yynerrs host_requirements_nerrs
-#define yylloc host_requirements_lloc
-
-/* Tokens. */
-#ifndef YYTOKENTYPE
-# define YYTOKENTYPE
- /* Put the tokens into the symbol table, so that GDB and other debuggers
- know about them. */
- enum yytokentype {
- INTEGER = 258,
- STRING = 259,
- FLOAT = 260
- };
-#endif
-/* Tokens. */
-#define INTEGER 258
-#define STRING 259
-#define FLOAT 260
-
-
-
+#define yyparse host_requirements_parse
+#define yylex host_requirements_lex
+#define yyerror host_requirements_error
+#define yylval host_requirements_lval
+#define yychar host_requirements_char
+#define yydebug host_requirements_debug
+#define yynerrs host_requirements_nerrs
+#define yylloc host_requirements_lloc
/* Copy the first part of user declarations. */
-#line 18 "host_requirements.y"
+
+/* Line 189 of yacc.c */
+#line 17 "host_requirements.y"
#include
#include
@@ -122,6 +110,9 @@ int host_requirements_parse(Host * host, bool& result, char ** errmsg);
+/* Line 189 of yacc.c */
+#line 115 "host_requirements.cc"
+
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
@@ -140,20 +131,40 @@ int host_requirements_parse(Host * host, bool& result, char ** errmsg);
# define YYTOKEN_TABLE 0
#endif
+
+/* Tokens. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum yytokentype {
+ INTEGER = 258,
+ STRING = 259,
+ FLOAT = 260
+ };
+#endif
+
+
+
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
-#line 55 "host_requirements.y"
{
+
+/* Line 214 of yacc.c */
+#line 54 "host_requirements.y"
+
char * val_str;
int val_int;
float val_float;
-}
-/* Line 187 of yacc.c. */
-#line 153 "host_requirements.cc"
- YYSTYPE;
+
+
+
+/* Line 214 of yacc.c */
+#line 164 "host_requirements.cc"
+} YYSTYPE;
+# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
-# define YYSTYPE_IS_TRIVIAL 1
#endif
#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
@@ -173,8 +184,8 @@ typedef struct YYLTYPE
/* Copy the second part of user declarations. */
-/* Line 216 of yacc.c. */
-#line 178 "host_requirements.cc"
+/* Line 264 of yacc.c */
+#line 189 "host_requirements.cc"
#ifdef short
# undef short
@@ -249,14 +260,14 @@ typedef short int yytype_int16;
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static int
-YYID (int i)
+YYID (int yyi)
#else
static int
-YYID (i)
- int i;
+YYID (yyi)
+ int yyi;
#endif
{
- return i;
+ return yyi;
}
#endif
@@ -338,9 +349,9 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */
/* A type that is properly aligned for any stack member. */
union yyalloc
{
- yytype_int16 yyss;
- YYSTYPE yyvs;
- YYLTYPE yyls;
+ yytype_int16 yyss_alloc;
+ YYSTYPE yyvs_alloc;
+ YYLTYPE yyls_alloc;
};
/* The size of the maximum gap between one aligned stack and the next. */
@@ -375,12 +386,12 @@ union yyalloc
elements in the stack, and YYPTR gives the new location of the
stack. Advance YYPTR to a properly aligned location for the next
stack. */
-# define YYSTACK_RELOCATE(Stack) \
+# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
do \
{ \
YYSIZE_T yynewbytes; \
- YYCOPY (&yyptr->Stack, Stack, yysize); \
- Stack = &yyptr->Stack; \
+ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
+ Stack = &yyptr->Stack_alloc; \
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
yyptr += yynewbytes / sizeof (*yyptr); \
} \
@@ -465,8 +476,8 @@ static const yytype_int8 yyrhs[] =
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const yytype_uint8 yyrline[] =
{
- 0, 75, 75, 76, 79, 86, 93, 100, 107, 114,
- 121, 128, 135, 143, 151, 152, 153, 154
+ 0, 74, 74, 75, 78, 85, 92, 99, 106, 113,
+ 120, 127, 134, 142, 150, 151, 152, 153
};
#endif
@@ -760,17 +771,20 @@ yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, host, result, error_ms
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static void
-yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
+yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
#else
static void
-yy_stack_print (bottom, top)
- yytype_int16 *bottom;
- yytype_int16 *top;
+yy_stack_print (yybottom, yytop)
+ yytype_int16 *yybottom;
+ yytype_int16 *yytop;
#endif
{
YYFPRINTF (stderr, "Stack now");
- for (; bottom <= top; ++bottom)
- YYFPRINTF (stderr, " %d", *bottom);
+ for (; yybottom <= yytop; yybottom++)
+ {
+ int yybot = *yybottom;
+ YYFPRINTF (stderr, " %d", yybot);
+ }
YYFPRINTF (stderr, "\n");
}
@@ -808,11 +822,11 @@ yy_reduce_print (yyvsp, yylsp, yyrule, host, result, error_msg)
/* The symbols being reduced. */
for (yyi = 0; yyi < yynrhs; yyi++)
{
- fprintf (stderr, " $%d = ", yyi + 1);
+ YYFPRINTF (stderr, " $%d = ", yyi + 1);
yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
&(yyvsp[(yyi + 1) - (yynrhs)])
, &(yylsp[(yyi + 1) - (yynrhs)]) , host, result, error_msg);
- fprintf (stderr, "\n");
+ YYFPRINTF (stderr, "\n");
}
}
@@ -1100,10 +1114,8 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp, host, result, error_msg)
break;
}
}
-
/* Prevent warnings from -Wmissing-prototypes. */
-
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int yyparse (void *YYPARSE_PARAM);
@@ -1122,10 +1134,9 @@ int yyparse ();
-
-/*----------.
-| yyparse. |
-`----------*/
+/*-------------------------.
+| yyparse or yypush_parse. |
+`-------------------------*/
#ifdef YYPARSE_PARAM
#if (defined __STDC__ || defined __C99__FUNC__ \
@@ -1151,24 +1162,59 @@ yyparse (host, result, error_msg)
#endif
#endif
{
- /* The look-ahead symbol. */
+/* The lookahead symbol. */
int yychar;
-/* The semantic value of the look-ahead symbol. */
+/* The semantic value of the lookahead symbol. */
YYSTYPE yylval;
-/* Number of syntax errors so far. */
-int yynerrs;
-/* Location data for the look-ahead symbol. */
+/* Location data for the lookahead symbol. */
YYLTYPE yylloc;
- int yystate;
+ /* Number of syntax errors so far. */
+ int yynerrs;
+
+ int yystate;
+ /* Number of tokens to shift before error messages enabled. */
+ int yyerrstatus;
+
+ /* The stacks and their tools:
+ `yyss': related to states.
+ `yyvs': related to semantic values.
+ `yyls': related to locations.
+
+ Refer to the stacks thru separate pointers, to allow yyoverflow
+ to reallocate them elsewhere. */
+
+ /* The state stack. */
+ yytype_int16 yyssa[YYINITDEPTH];
+ yytype_int16 *yyss;
+ yytype_int16 *yyssp;
+
+ /* The semantic value stack. */
+ YYSTYPE yyvsa[YYINITDEPTH];
+ YYSTYPE *yyvs;
+ YYSTYPE *yyvsp;
+
+ /* The location stack. */
+ YYLTYPE yylsa[YYINITDEPTH];
+ YYLTYPE *yyls;
+ YYLTYPE *yylsp;
+
+ /* The locations where the error started and ended. */
+ YYLTYPE yyerror_range[2];
+
+ YYSIZE_T yystacksize;
+
int yyn;
int yyresult;
- /* Number of tokens to shift before error messages enabled. */
- int yyerrstatus;
- /* Look-ahead token as an internal (translated) token number. */
- int yytoken = 0;
+ /* Lookahead token as an internal (translated) token number. */
+ int yytoken;
+ /* The variables used to return semantic value and location from the
+ action routines. */
+ YYSTYPE yyval;
+ YYLTYPE yyloc;
+
#if YYERROR_VERBOSE
/* Buffer for error messages, and its allocated size. */
char yymsgbuf[128];
@@ -1176,63 +1222,37 @@ YYLTYPE yylloc;
YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
#endif
- /* Three stacks and their tools:
- `yyss': related to states,
- `yyvs': related to semantic values,
- `yyls': related to locations.
-
- Refer to the stacks thru separate pointers, to allow yyoverflow
- to reallocate them elsewhere. */
-
- /* The state stack. */
- yytype_int16 yyssa[YYINITDEPTH];
- yytype_int16 *yyss = yyssa;
- yytype_int16 *yyssp;
-
- /* The semantic value stack. */
- YYSTYPE yyvsa[YYINITDEPTH];
- YYSTYPE *yyvs = yyvsa;
- YYSTYPE *yyvsp;
-
- /* The location stack. */
- YYLTYPE yylsa[YYINITDEPTH];
- YYLTYPE *yyls = yylsa;
- YYLTYPE *yylsp;
- /* The locations where the error started and ended. */
- YYLTYPE yyerror_range[2];
-
#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
- YYSIZE_T yystacksize = YYINITDEPTH;
-
- /* The variables used to return semantic value and location from the
- action routines. */
- YYSTYPE yyval;
- YYLTYPE yyloc;
-
/* The number of symbols on the RHS of the reduced rule.
Keep to zero when no symbol should be popped. */
int yylen = 0;
+ yytoken = 0;
+ yyss = yyssa;
+ yyvs = yyvsa;
+ yyls = yylsa;
+ yystacksize = YYINITDEPTH;
+
YYDPRINTF ((stderr, "Starting parse\n"));
yystate = 0;
yyerrstatus = 0;
yynerrs = 0;
- yychar = YYEMPTY; /* Cause a token to be read. */
+ yychar = YYEMPTY; /* Cause a token to be read. */
/* Initialize stack pointers.
Waste one element of value and location stack
so that they stay on the same level as the state stack.
The wasted elements are never initialized. */
-
yyssp = yyss;
yyvsp = yyvs;
yylsp = yyls;
+
#if YYLTYPE_IS_TRIVIAL
/* Initialize the default location before parsing starts. */
yylloc.first_line = yylloc.last_line = 1;
- yylloc.first_column = yylloc.last_column = 0;
+ yylloc.first_column = yylloc.last_column = 1;
#endif
goto yysetstate;
@@ -1271,6 +1291,7 @@ YYLTYPE yylloc;
&yyvs1, yysize * sizeof (*yyvsp),
&yyls1, yysize * sizeof (*yylsp),
&yystacksize);
+
yyls = yyls1;
yyss = yyss1;
yyvs = yyvs1;
@@ -1292,9 +1313,9 @@ YYLTYPE yylloc;
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
if (! yyptr)
goto yyexhaustedlab;
- YYSTACK_RELOCATE (yyss);
- YYSTACK_RELOCATE (yyvs);
- YYSTACK_RELOCATE (yyls);
+ YYSTACK_RELOCATE (yyss_alloc, yyss);
+ YYSTACK_RELOCATE (yyvs_alloc, yyvs);
+ YYSTACK_RELOCATE (yyls_alloc, yyls);
# undef YYSTACK_RELOCATE
if (yyss1 != yyssa)
YYSTACK_FREE (yyss1);
@@ -1315,6 +1336,9 @@ YYLTYPE yylloc;
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
+ if (yystate == YYFINAL)
+ YYACCEPT;
+
goto yybackup;
/*-----------.
@@ -1323,16 +1347,16 @@ YYLTYPE yylloc;
yybackup:
/* Do appropriate processing given the current state. Read a
- look-ahead token if we need one and don't already have one. */
+ lookahead token if we need one and don't already have one. */
- /* First try to decide what to do without reference to look-ahead token. */
+ /* First try to decide what to do without reference to lookahead token. */
yyn = yypact[yystate];
if (yyn == YYPACT_NINF)
goto yydefault;
- /* Not known => get a look-ahead token if don't already have one. */
+ /* Not known => get a lookahead token if don't already have one. */
- /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
+ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
if (yychar == YYEMPTY)
{
YYDPRINTF ((stderr, "Reading a token: "));
@@ -1364,20 +1388,16 @@ yybackup:
goto yyreduce;
}
- if (yyn == YYFINAL)
- YYACCEPT;
-
/* Count tokens shifted since error; after three, turn off error
status. */
if (yyerrstatus)
yyerrstatus--;
- /* Shift the look-ahead token. */
+ /* Shift the lookahead token. */
YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
- /* Discard the shifted token unless it is eof. */
- if (yychar != YYEOF)
- yychar = YYEMPTY;
+ /* Discard the shifted token. */
+ yychar = YYEMPTY;
yystate = yyn;
*++yyvsp = yylval;
@@ -1418,17 +1438,23 @@ yyreduce:
switch (yyn)
{
case 2:
-#line 75 "host_requirements.y"
+
+/* Line 1455 of yacc.c */
+#line 74 "host_requirements.y"
{ result=(yyvsp[(1) - (1)].val_int); ;}
break;
case 3:
-#line 76 "host_requirements.y"
+
+/* Line 1455 of yacc.c */
+#line 75 "host_requirements.y"
{ result=true; ;}
break;
case 4:
-#line 79 "host_requirements.y"
+
+/* Line 1455 of yacc.c */
+#line 78 "host_requirements.y"
{ int val;
host->get_template_attribute((yyvsp[(1) - (3)].val_str),val);
@@ -1438,7 +1464,9 @@ yyreduce:
break;
case 5:
-#line 86 "host_requirements.y"
+
+/* Line 1455 of yacc.c */
+#line 85 "host_requirements.y"
{ int val;
host->get_template_attribute((yyvsp[(1) - (4)].val_str),val);
@@ -1448,7 +1476,9 @@ yyreduce:
break;
case 6:
-#line 93 "host_requirements.y"
+
+/* Line 1455 of yacc.c */
+#line 92 "host_requirements.y"
{ int val;
host->get_template_attribute((yyvsp[(1) - (3)].val_str),val);
@@ -1458,7 +1488,9 @@ yyreduce:
break;
case 7:
-#line 100 "host_requirements.y"
+
+/* Line 1455 of yacc.c */
+#line 99 "host_requirements.y"
{ int val;
host->get_template_attribute((yyvsp[(1) - (3)].val_str),val);
@@ -1468,7 +1500,9 @@ yyreduce:
break;
case 8:
-#line 107 "host_requirements.y"
+
+/* Line 1455 of yacc.c */
+#line 106 "host_requirements.y"
{ string val;
host->get_template_attribute((yyvsp[(1) - (3)].val_str),val);
@@ -1478,7 +1512,9 @@ yyreduce:
break;
case 9:
-#line 114 "host_requirements.y"
+
+/* Line 1455 of yacc.c */
+#line 113 "host_requirements.y"
{ string val;
host->get_template_attribute((yyvsp[(1) - (4)].val_str),val);
@@ -1488,7 +1524,9 @@ yyreduce:
break;
case 10:
-#line 121 "host_requirements.y"
+
+/* Line 1455 of yacc.c */
+#line 120 "host_requirements.y"
{ string val;
host->get_template_attribute((yyvsp[(1) - (3)].val_str),val);
@@ -1498,7 +1536,9 @@ yyreduce:
break;
case 11:
-#line 128 "host_requirements.y"
+
+/* Line 1455 of yacc.c */
+#line 127 "host_requirements.y"
{ string val;
host->get_template_attribute((yyvsp[(1) - (3)].val_str),val);
@@ -1508,7 +1548,9 @@ yyreduce:
break;
case 12:
-#line 135 "host_requirements.y"
+
+/* Line 1455 of yacc.c */
+#line 134 "host_requirements.y"
{ string val;
host->get_template_attribute((yyvsp[(1) - (3)].val_str),val);
@@ -1519,7 +1561,9 @@ yyreduce:
break;
case 13:
-#line 143 "host_requirements.y"
+
+/* Line 1455 of yacc.c */
+#line 142 "host_requirements.y"
{ string val;
host->get_template_attribute((yyvsp[(1) - (4)].val_str),val);
@@ -1530,28 +1574,37 @@ yyreduce:
break;
case 14:
-#line 151 "host_requirements.y"
+
+/* Line 1455 of yacc.c */
+#line 150 "host_requirements.y"
{ (yyval.val_int) = (yyvsp[(1) - (3)].val_int) && (yyvsp[(3) - (3)].val_int); ;}
break;
case 15:
-#line 152 "host_requirements.y"
+
+/* Line 1455 of yacc.c */
+#line 151 "host_requirements.y"
{ (yyval.val_int) = (yyvsp[(1) - (3)].val_int) || (yyvsp[(3) - (3)].val_int); ;}
break;
case 16:
-#line 153 "host_requirements.y"
+
+/* Line 1455 of yacc.c */
+#line 152 "host_requirements.y"
{ (yyval.val_int) = ! (yyvsp[(2) - (2)].val_int); ;}
break;
case 17:
-#line 154 "host_requirements.y"
+
+/* Line 1455 of yacc.c */
+#line 153 "host_requirements.y"
{ (yyval.val_int) = (yyvsp[(2) - (3)].val_int); ;}
break;
-/* Line 1267 of yacc.c. */
-#line 1555 "host_requirements.cc"
+
+/* Line 1455 of yacc.c */
+#line 1608 "host_requirements.cc"
default: break;
}
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -1627,7 +1680,7 @@ yyerrlab:
if (yyerrstatus == 3)
{
- /* If just tried and failed to reuse look-ahead token after an
+ /* If just tried and failed to reuse lookahead token after an
error, discard it. */
if (yychar <= YYEOF)
@@ -1644,7 +1697,7 @@ yyerrlab:
}
}
- /* Else will try to reuse look-ahead token after shifting the error
+ /* Else will try to reuse lookahead token after shifting the error
token. */
goto yyerrlab1;
@@ -1702,14 +1755,11 @@ yyerrlab1:
YY_STACK_PRINT (yyss, yyssp);
}
- if (yyn == YYFINAL)
- YYACCEPT;
-
*++yyvsp = yylval;
yyerror_range[1] = yylloc;
/* Using YYLLOC is tempting, but would change the location of
- the look-ahead. YYLOC is available though. */
+ the lookahead. YYLOC is available though. */
YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
*++yylsp = yyloc;
@@ -1734,7 +1784,7 @@ yyabortlab:
yyresult = 1;
goto yyreturn;
-#ifndef yyoverflow
+#if !defined(yyoverflow) || YYERROR_VERBOSE
/*-------------------------------------------------.
| yyexhaustedlab -- memory exhaustion comes here. |
`-------------------------------------------------*/
@@ -1745,7 +1795,7 @@ yyexhaustedlab:
#endif
yyreturn:
- if (yychar != YYEOF && yychar != YYEMPTY)
+ if (yychar != YYEMPTY)
yydestruct ("Cleanup: discarding lookahead",
yytoken, &yylval, &yylloc, host, result, error_msg);
/* Do not reclaim the symbols of the rule which action triggered
@@ -1771,7 +1821,9 @@ yyreturn:
}
-#line 157 "host_requirements.y"
+
+/* Line 1675 of yacc.c */
+#line 156 "host_requirements.y"
extern "C" void host_requirements_error(
diff --git a/src/host/host_requirements.h b/src/host/host_requirements.h
index 8178da758d..4958488af2 100644
--- a/src/host/host_requirements.h
+++ b/src/host/host_requirements.h
@@ -1,24 +1,23 @@
-/* A Bison parser, made by GNU Bison 2.3. */
+
+/* A Bison parser, made by GNU Bison 2.4.1. */
/* Skeleton interface for Bison's Yacc-like parsers in C
-
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
+
+ This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ along with this program. If not, see . */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
@@ -29,10 +28,11 @@
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
-
+
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
+
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
@@ -44,28 +44,28 @@
FLOAT = 260
};
#endif
-/* Tokens. */
-#define INTEGER 258
-#define STRING 259
-#define FLOAT 260
-
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
-#line 55 "host_requirements.y"
{
+
+/* Line 1676 of yacc.c */
+#line 54 "host_requirements.y"
+
char * val_str;
int val_int;
float val_float;
-}
-/* Line 1489 of yacc.c. */
+
+
+
+/* Line 1676 of yacc.c */
#line 65 "host_requirements.hh"
- YYSTYPE;
+} YYSTYPE;
+# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
-# define YYSTYPE_IS_TRIVIAL 1
#endif
@@ -84,3 +84,4 @@ typedef struct YYLTYPE
#endif
+
diff --git a/src/host/host_requirements.y b/src/host/host_requirements.y
index 38f4ee5631..a0e55ac4b7 100644
--- a/src/host/host_requirements.y
+++ b/src/host/host_requirements.y
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/im/InformationManager.cc b/src/im/InformationManager.cc
index f959506d61..76866c1e4f 100644
--- a/src/im/InformationManager.cc
+++ b/src/im/InformationManager.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/im/InformationManagerDriver.cc b/src/im/InformationManagerDriver.cc
index 874fc52d71..c49e1f61ee 100644
--- a/src/im/InformationManagerDriver.cc
+++ b/src/im/InformationManagerDriver.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/im/SConstruct b/src/im/SConstruct
index e1da40eaa2..63e00cc4b4 100755
--- a/src/im/SConstruct
+++ b/src/im/SConstruct
@@ -1,8 +1,7 @@
# SConstruct for src/im
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/im_mad/ec2/im_ec2rc b/src/im_mad/ec2/im_ec2rc
index 919c811fa7..6f868dff5c 100644
--- a/src/im_mad/ec2/im_ec2rc
+++ b/src/im_mad/ec2/im_ec2rc
@@ -1,6 +1,5 @@
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/im_mad/ec2/one_im_ec2 b/src/im_mad/ec2/one_im_ec2
index 4dbbbc3c86..fd6cba9afc 100755
--- a/src/im_mad/ec2/one_im_ec2
+++ b/src/im_mad/ec2/one_im_ec2
@@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/im_mad/ec2/one_im_ec2.rb b/src/im_mad/ec2/one_im_ec2.rb
index 4a9ceac159..d9bc8582ad 100755
--- a/src/im_mad/ec2/one_im_ec2.rb
+++ b/src/im_mad/ec2/one_im_ec2.rb
@@ -1,8 +1,7 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/im_mad/eh/im_ehrc b/src/im_mad/eh/im_ehrc
index e9238feca4..e740161f09 100644
--- a/src/im_mad/eh/im_ehrc
+++ b/src/im_mad/eh/im_ehrc
@@ -1,6 +1,5 @@
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/im_mad/eh/one_im_eh b/src/im_mad/eh/one_im_eh
index fe5f260c44..2c64a8c67f 100644
--- a/src/im_mad/eh/one_im_eh
+++ b/src/im_mad/eh/one_im_eh
@@ -1,7 +1,6 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@@ -40,4 +39,4 @@ export_rc_vars $EHCONF
cd $VAR_LOCATION
# Execute the actual MAD
-execute_mad $*
\ No newline at end of file
+execute_mad $*
diff --git a/src/im_mad/eh/one_im_eh.rb b/src/im_mad/eh/one_im_eh.rb
index 1eaec87157..d6eeb98168 100644
--- a/src/im_mad/eh/one_im_eh.rb
+++ b/src/im_mad/eh/one_im_eh.rb
@@ -1,8 +1,7 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@@ -59,4 +58,4 @@ class IM < ONEMad
end
im=IM.new(nil)
-im.loop
\ No newline at end of file
+im.loop
diff --git a/src/im_mad/im_ssh/one_im_ssh b/src/im_mad/im_ssh/one_im_ssh
index 4ea19ec9b2..6bf146355f 100755
--- a/src/im_mad/im_ssh/one_im_ssh
+++ b/src/im_mad/im_ssh/one_im_ssh
@@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/im_mad/im_ssh/one_im_ssh.rb b/src/im_mad/im_ssh/one_im_ssh.rb
index dd93a5e9c3..70340e11a1 100755
--- a/src/im_mad/im_ssh/one_im_ssh.rb
+++ b/src/im_mad/im_ssh/one_im_ssh.rb
@@ -1,8 +1,7 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/im_mad/kvm/im_kvmrc b/src/im_mad/kvm/im_kvmrc
index 799dec5871..32268dbd8b 100644
--- a/src/im_mad/kvm/im_kvmrc
+++ b/src/im_mad/kvm/im_kvmrc
@@ -1,6 +1,5 @@
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/im_mad/kvm/kvm.rb b/src/im_mad/kvm/kvm.rb
index 19aa2c2d50..0b7c664d7b 100755
--- a/src/im_mad/kvm/kvm.rb
+++ b/src/im_mad/kvm/kvm.rb
@@ -1,8 +1,7 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@@ -22,7 +21,7 @@
# TODO : use virsh freecell when available
######
-nodeinfo_text = `virsh nodeinfo`
+nodeinfo_text = `virsh -c qemu:///system nodeinfo`
nodeinfo_text.split(/\n/).each{|line|
if line.match('^CPU\(s\)')
diff --git a/src/im_mad/vmware/GetProperty.java b/src/im_mad/vmware/GetProperty.java
index e239a9cdb2..18da7c4067 100644
--- a/src/im_mad/vmware/GetProperty.java
+++ b/src/im_mad/vmware/GetProperty.java
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/im_mad/vmware/OneImVmware.java b/src/im_mad/vmware/OneImVmware.java
index f4fb042629..403c325b7b 100644
--- a/src/im_mad/vmware/OneImVmware.java
+++ b/src/im_mad/vmware/OneImVmware.java
@@ -1,30 +1,35 @@
-/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
-/* */
-/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
-/* not use this file except in compliance with the License. You may obtain */
-/* a copy of the License at */
-/* */
-/* http://www.apache.org/licenses/LICENSE-2.0 */
-/* */
-/* Unless required by applicable law or agreed to in writing, software */
-/* distributed under the License is distributed on an "AS IS" BASIS, */
-/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
-/* See the License for the specific language governing permissions and */
-/* limitations under the License. */
-/* -------------------------------------------------------------------------- */
-
+/*
+# -------------------------------------------------------------------------#
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------#
+*/
import java.io.*;
+import java.text.*;
+import java.util.*;
import com.vmware.vim.*;
import com.vmware.apputils.*;
import com.vmware.apputils.vim.*;
-
+/************************************
+ * Monitors physical VMware hosts *
+ * through the VI API *
+ ************************************/
class OneImVmware extends Thread
{
@@ -32,21 +37,14 @@ class OneImVmware extends Thread
boolean debug;
+ PrintStream stdout;
+ PrintStream stderr;
// Entry point - main procedure
-
public static void main(String[] args)
{
boolean debug_flag;
- // first, make redirection
-
- PrintStream stdout = System.out;
- PrintStream stderr = System.err;
-
- System.setOut(stderr);
- System.setErr(stdout);
-
if (System.getProperty("debug").equals("1"))
{
debug_flag=true;
@@ -55,7 +53,7 @@ class OneImVmware extends Thread
{
debug_flag=false;
}
-
+
OneImVmware oiv = new OneImVmware(args,debug_flag);
oiv.loop();
}
@@ -64,25 +62,34 @@ class OneImVmware extends Thread
OneImVmware(String[] args,boolean _debug)
{
debug = _debug;
-
arguments = args;
+
+ // Get out and err descriptors
+ stdout = System.out;
+ stderr = System.err;
+
+ // No VMware library output to standard out
+ // or err. This will be activated when needed
+ disable_standard_output();
+ disable_standard_error();
}
- // Main loop, threaded
+ // Main loop
void loop()
{
- String str = null;
- String action = null;
- String host;
- String hid_str = null;
- String hostToMonitor;
- boolean fin = false;
+ String str = null;
+ String action = null;
+ String host;
+ String hid_str = null;
+ String hostToMonitor;
+ boolean end = false;
- BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
+ BufferedReader in = new BufferedReader(
+ new InputStreamReader(System.in));
- while (!fin)
- {
+ while (!end)
+ {
// Read a line a parse it
try
{
@@ -91,15 +98,12 @@ class OneImVmware extends Thread
catch (IOException e)
{
String message = e.getMessage().replace('\n', ' ');
-
- synchronized (System.err)
- {
- System.err.println(action + " FAILURE " + hid_str + " " + message);
- }
+ send_message(action + " FAILURE " + hid_str + " " + message);
+ send_error (action + " FAILURE " + hid_str +
+ " Action malformed. Reason: " + message);
}
- String str_split[] = str.split(" ", 4);
-
+ String str_split[] = str.split(" ", 4);
action = str_split[0].toUpperCase();
// Perform the action
@@ -110,13 +114,10 @@ class OneImVmware extends Thread
else if (action.equals("FINALIZE"))
{
finalize_mad();
- fin = true;
+ end = true;
} else if (str_split.length != 3)
{
- synchronized (System.err)
- {
- System.err.println("FAILURE Unknown command");
- }
+ send_message("FAILURE Unknown command");
}
else
{
@@ -132,7 +133,8 @@ class OneImVmware extends Thread
boolean rf;
String response = "HYPERVISOR=vmware";
- String[] argsWithHost = new String[arguments.length+2];
+ String[] argsWithHost =
+ new String[arguments.length+2];
for(int i=0;iget(vid,true);
if ( vm == 0 )
diff --git a/src/rm/RequestManagerMigrate.cc b/src/rm/RequestManagerMigrate.cc
index b5f37863c7..dfb391a56e 100644
--- a/src/rm/RequestManagerMigrate.cc
+++ b/src/rm/RequestManagerMigrate.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/rm/RequestManagerPoolInfo.cc b/src/rm/RequestManagerPoolInfo.cc
index a3dec04d90..0da0a811ed 100644
--- a/src/rm/RequestManagerPoolInfo.cc
+++ b/src/rm/RequestManagerPoolInfo.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/rm/RequestManagerUserAllocate.cc b/src/rm/RequestManagerUserAllocate.cc
index 8a4cbf4179..757e856449 100644
--- a/src/rm/RequestManagerUserAllocate.cc
+++ b/src/rm/RequestManagerUserAllocate.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/rm/RequestManagerUserDelete.cc b/src/rm/RequestManagerUserDelete.cc
index 6cbdfd8287..a9d472c96d 100644
--- a/src/rm/RequestManagerUserDelete.cc
+++ b/src/rm/RequestManagerUserDelete.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/rm/RequestManagerUserInfo.cc b/src/rm/RequestManagerUserInfo.cc
index 391d0e2a71..188a63b41d 100644
--- a/src/rm/RequestManagerUserInfo.cc
+++ b/src/rm/RequestManagerUserInfo.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/rm/RequestManagerUserPoolInfo.cc b/src/rm/RequestManagerUserPoolInfo.cc
index 2ba3cc9cca..1882034929 100644
--- a/src/rm/RequestManagerUserPoolInfo.cc
+++ b/src/rm/RequestManagerUserPoolInfo.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/rm/RequestManagerVirtualNetworkAllocate.cc b/src/rm/RequestManagerVirtualNetworkAllocate.cc
index 31b85fd3e5..4480271802 100644
--- a/src/rm/RequestManagerVirtualNetworkAllocate.cc
+++ b/src/rm/RequestManagerVirtualNetworkAllocate.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/rm/RequestManagerVirtualNetworkDelete.cc b/src/rm/RequestManagerVirtualNetworkDelete.cc
index 9e25224bd7..8b390dfd59 100644
--- a/src/rm/RequestManagerVirtualNetworkDelete.cc
+++ b/src/rm/RequestManagerVirtualNetworkDelete.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/rm/RequestManagerVirtualNetworkInfo.cc b/src/rm/RequestManagerVirtualNetworkInfo.cc
index 31905966c2..113536d457 100644
--- a/src/rm/RequestManagerVirtualNetworkInfo.cc
+++ b/src/rm/RequestManagerVirtualNetworkInfo.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/rm/RequestManagerVirtualNetworkPoolInfo.cc b/src/rm/RequestManagerVirtualNetworkPoolInfo.cc
index 767c495fcb..a85e8b4489 100755
--- a/src/rm/RequestManagerVirtualNetworkPoolInfo.cc
+++ b/src/rm/RequestManagerVirtualNetworkPoolInfo.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/rm/SConstruct b/src/rm/SConstruct
index 9fa023656d..74a7d92d27 100644
--- a/src/rm/SConstruct
+++ b/src/rm/SConstruct
@@ -1,8 +1,7 @@
# SConstruct for src/rm
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/scheduler/RankPolicy.h b/src/scheduler/RankPolicy.h
index eb72039006..1f43705bc6 100644
--- a/src/scheduler/RankPolicy.h
+++ b/src/scheduler/RankPolicy.h
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/scheduler/SConstruct b/src/scheduler/SConstruct
index d0ebfc3259..2988ac6f65 100644
--- a/src/scheduler/SConstruct
+++ b/src/scheduler/SConstruct
@@ -1,8 +1,7 @@
# SConstruct for src/nebula
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/scheduler/Scheduler.cc b/src/scheduler/Scheduler.cc
index 864e8b690b..bf12223fcb 100644
--- a/src/scheduler/Scheduler.cc
+++ b/src/scheduler/Scheduler.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
@@ -23,6 +22,8 @@
#include
#include
#include
+#include
+#include
#include
@@ -63,10 +64,18 @@ extern "C" void * scheduler_action_loop(void *arg)
void Scheduler::start()
{
- int rc;
- Nebula& nd = Nebula::instance();
+ int rc;
+ Nebula& nd = Nebula::instance();
- pthread_attr_t pattr;
+ pthread_attr_t pattr;
+
+ const char * one_auth;
+
+ string one_name;
+ string one_pass;
+ string one_token;
+
+ ifstream file;
// -----------------------------------------------------------
// Log system
@@ -88,20 +97,49 @@ void Scheduler::start()
throw;
}
- const char * one_auth;
- string one_name;
- string one_pass;
-
one_auth = getenv("ONE_AUTH");
if (!one_auth)
{
- throw runtime_error("ONE_AUTH variable not defined");
+ struct passwd * pw_ent;
+
+ pw_ent = getpwuid(getuid());
+
+ if ((pw_ent != NULL) && (pw_ent->pw_dir != NULL))
+ {
+
+ string one_auth_file = pw_ent->pw_dir;
+
+ one_auth_file += "/.one/one_auth";
+ one_auth = one_auth_file.c_str();
+ }
+ else
+ {
+ throw runtime_error("Could not get one_auth file location");
+ }
+ }
+
+ file.open(one_auth);
+
+ if (file.good())
+ {
+ getline(file,one_token);
+
+ if (file.fail())
+ {
+ throw runtime_error("Error reading $ONE_AUTH file");
+ }
+ }
+ else
+ {
+ throw runtime_error("Could not open $ONE_AUTH file");
}
- if ( User::split_secret(one_auth,one_name,one_pass) != 0 )
+ file.close();
+
+ if ( User::split_secret(one_token,one_name,one_pass) != 0 )
{
- throw runtime_error("ONE_AUTH must be :");
+ throw runtime_error("Wrong format must be :");
}
secret = one_name + ":" + User::sha1_digest(one_pass);
@@ -398,7 +436,7 @@ void Scheduler::dispatch()
int rc;
oss << "Select hosts" << endl;
- oss << "\tPRI\tHID\tHSID" << endl;
+ oss << "\tPRI\tHID" << endl;
oss << "\t-------------------" << endl;
for (it=vmpool->pending_vms.begin();it!=vmpool->pending_vms.end();it++)
diff --git a/src/scheduler/SchedulerHost.cc b/src/scheduler/SchedulerHost.cc
index ed98344a70..7b1b167a41 100644
--- a/src/scheduler/SchedulerHost.cc
+++ b/src/scheduler/SchedulerHost.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
@@ -146,7 +145,8 @@ int SchedulerHostPool::set_up()
lock();
oss << "SELECT oid FROM " << Host::table
- << " WHERE state != " << Host::DISABLED;
+ << " WHERE state != " << Host::DISABLED
+ << " AND state != " << Host::ERROR;
rc = db->exec(oss,set_up_cb,(void *) &hids);
diff --git a/src/scheduler/SchedulerVirtualMachine.cc b/src/scheduler/SchedulerVirtualMachine.cc
index 55c488a4ce..5897d7a096 100644
--- a/src/scheduler/SchedulerVirtualMachine.cc
+++ b/src/scheduler/SchedulerVirtualMachine.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
@@ -76,7 +75,7 @@ void SchedulerVirtualMachine::set_priorities(vector& total)
//Sort the shares using the priority
- sort(hosts.begin(),hosts.end());
+ sort(hosts.begin(),hosts.end(),SchedulerVirtualMachine::host_cmp);
}
/* -------------------------------------------------------------------------- */
diff --git a/src/scheduler/mm_sched.cc b/src/scheduler/mm_sched.cc
index ba70993974..8df1f74a5a 100644
--- a/src/scheduler/mm_sched.cc
+++ b/src/scheduler/mm_sched.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/template/SConstruct b/src/template/SConstruct
index 38d024799f..aa0dfbfa5e 100644
--- a/src/template/SConstruct
+++ b/src/template/SConstruct
@@ -1,8 +1,7 @@
# SConstruct for src/template
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/template/Template.cc b/src/template/Template.cc
index 67020042b8..f6d9ab64fb 100644
--- a/src/template/Template.cc
+++ b/src/template/Template.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/template/TemplateSQL.cc b/src/template/TemplateSQL.cc
index 7f424e655d..e1ab343f0f 100644
--- a/src/template/TemplateSQL.cc
+++ b/src/template/TemplateSQL.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/template/template_parser.c b/src/template/template_parser.c
index 0324ec740b..9f76fa756c 100644
--- a/src/template/template_parser.c
+++ b/src/template/template_parser.c
@@ -28,7 +28,7 @@
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 34
+#define YY_FLEX_SUBMINOR_VERSION 35
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
@@ -211,13 +211,6 @@ extern FILE *template_in, *template_out;
#define unput(c) yyunput( c, (yytext_ptr) )
-/* The following is because we cannot portably get our hands on size_t
- * (without autoconf's help, which isn't available because we want
- * flex-generated scanners to compile on their own).
- * Given that the standard has decreed that size_t exists since 1989,
- * I guess we can afford to depend on it. Manoj.
- */
-
#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
typedef size_t yy_size_t;
@@ -528,8 +521,7 @@ int template__flex_debug = 0;
char *template_text;
#line 1 "template_parser.l"
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
@@ -543,7 +535,7 @@ char *template_text;
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
-#line 19 "template_parser.l"
+#line 18 "template_parser.l"
#include
#include
#include
@@ -557,7 +549,7 @@ char *template_text;
llocp->first_column = llocp->last_column; \
llocp->last_column += template_leng;
-#line 561 "template_parser.c"
+#line 553 "template_parser.c"
#define INITIAL 0
#define VALUE 1
@@ -576,6 +568,35 @@ char *template_text;
static int yy_init_globals (void );
+/* Accessor methods to globals.
+ These are made visible to non-reentrant scanners for convenience. */
+
+int template_lex_destroy (void );
+
+int template_get_debug (void );
+
+void template_set_debug (int debug_flag );
+
+YY_EXTRA_TYPE template_get_extra (void );
+
+void template_set_extra (YY_EXTRA_TYPE user_defined );
+
+FILE *template_get_in (void );
+
+void template_set_in (FILE * in_str );
+
+FILE *template_get_out (void );
+
+void template_set_out (FILE * out_str );
+
+int template_get_leng (void );
+
+char *template_get_text (void );
+
+int template_get_lineno (void );
+
+void template_set_lineno (int line_number );
+
/* Macros after this point can all be overridden by user definitions in
* section 1.
*/
@@ -709,13 +730,13 @@ YY_DECL
register char *yy_cp, *yy_bp;
register int yy_act;
-#line 41 "template_parser.l"
+#line 40 "template_parser.l"
/* ------------------------------------------------------------------------- */
/* Comments (lines with an starting #), and empty lines */
/* ------------------------------------------------------------------------- */
-#line 719 "template_parser.c"
+#line 740 "template_parser.c"
if ( !(yy_init) )
{
@@ -811,13 +832,13 @@ do_action: /* This label is used only to access EOF actions. */
case 1:
/* rule 1 can match eol */
YY_RULE_SETUP
-#line 46 "template_parser.l"
+#line 45 "template_parser.l"
;
YY_BREAK
case 2:
/* rule 2 can match eol */
YY_RULE_SETUP
-#line 47 "template_parser.l"
+#line 46 "template_parser.l"
;
YY_BREAK
/* ------------------------------------------------------------------------- */
@@ -825,7 +846,7 @@ YY_RULE_SETUP
/* ------------------------------------------------------------------------- */
case 3:
YY_RULE_SETUP
-#line 52 "template_parser.l"
+#line 51 "template_parser.l"
{ lvalp->val_str = strdup(template_text); return VARIABLE;}
YY_BREAK
/* ------------------------------------------------------------------------ */
@@ -835,31 +856,31 @@ YY_RULE_SETUP
/* ------------------------------------------------------------------------ */
case 4:
YY_RULE_SETUP
-#line 59 "template_parser.l"
+#line 58 "template_parser.l"
{ BEGIN VALUE; return EQUAL;}
YY_BREAK
case 5:
/* rule 5 can match eol */
YY_RULE_SETUP
-#line 61 "template_parser.l"
+#line 60 "template_parser.l"
{ return EQUAL_EMPTY;}
YY_BREAK
case 6:
/* rule 6 can match eol */
YY_RULE_SETUP
-#line 63 "template_parser.l"
+#line 62 "template_parser.l"
{ return COMMA;}
YY_BREAK
case 7:
/* rule 7 can match eol */
YY_RULE_SETUP
-#line 65 "template_parser.l"
+#line 64 "template_parser.l"
{ return CBRACKET;}
YY_BREAK
case 8:
/* rule 8 can match eol */
YY_RULE_SETUP
-#line 67 "template_parser.l"
+#line 66 "template_parser.l"
{ BEGIN(INITIAL); return OBRACKET;}
YY_BREAK
/* ------------------------------------------------------------------------ */
@@ -870,7 +891,7 @@ YY_RULE_SETUP
case 9:
/* rule 9 can match eol */
YY_RULE_SETUP
-#line 74 "template_parser.l"
+#line 73 "template_parser.l"
{ lvalp->val_str = strdup(template_text+1);
lvalp->val_str[template_leng-2] = '\0';
BEGIN(INITIAL); return STRING; }
@@ -882,16 +903,16 @@ YY_RULE_SETUP
*/
case 10:
YY_RULE_SETUP
-#line 83 "template_parser.l"
+#line 82 "template_parser.l"
{ lvalp->val_str = strdup(template_text);
BEGIN(INITIAL); return STRING;}
YY_BREAK
case 11:
YY_RULE_SETUP
-#line 85 "template_parser.l"
+#line 84 "template_parser.l"
ECHO;
YY_BREAK
-#line 895 "template_parser.c"
+#line 916 "template_parser.c"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(VALUE):
yyterminate();
@@ -1861,7 +1882,7 @@ void template_free (void * ptr )
#define YYTABLES_NAME "yytables"
-#line 85 "template_parser.l"
+#line 84 "template_parser.l"
diff --git a/src/template/template_parser.l b/src/template/template_parser.l
index 621b86dc82..6e5eeb6e0b 100644
--- a/src/template/template_parser.l
+++ b/src/template/template_parser.l
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/template/template_syntax.cc b/src/template/template_syntax.cc
index 2afa9c479a..e810414ca3 100644
--- a/src/template/template_syntax.cc
+++ b/src/template/template_syntax.cc
@@ -1,24 +1,23 @@
-/* A Bison parser, made by GNU Bison 2.3. */
+
+/* A Bison parser, made by GNU Bison 2.4.1. */
/* Skeleton implementation for Bison's Yacc-like parsers in C
-
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
+
+ This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ along with this program. If not, see . */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
@@ -29,7 +28,7 @@
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
-
+
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
@@ -47,7 +46,7 @@
#define YYBISON 1
/* Bison version. */
-#define YYBISON_VERSION "2.3"
+#define YYBISON_VERSION "2.4.1"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
@@ -55,48 +54,29 @@
/* Pure parsers. */
#define YYPURE 1
+/* Push parsers. */
+#define YYPUSH 0
+
+/* Pull parsers. */
+#define YYPULL 1
+
/* Using locations. */
#define YYLSP_NEEDED 1
/* Substitute the variable and function names. */
-#define yyparse template_parse
-#define yylex template_lex
-#define yyerror template_error
-#define yylval template_lval
-#define yychar template_char
-#define yydebug template_debug
-#define yynerrs template_nerrs
-#define yylloc template_lloc
-
-/* Tokens. */
-#ifndef YYTOKENTYPE
-# define YYTOKENTYPE
- /* Put the tokens into the symbol table, so that GDB and other debuggers
- know about them. */
- enum yytokentype {
- EQUAL = 258,
- COMMA = 259,
- OBRACKET = 260,
- CBRACKET = 261,
- EQUAL_EMPTY = 262,
- STRING = 263,
- VARIABLE = 264
- };
-#endif
-/* Tokens. */
-#define EQUAL 258
-#define COMMA 259
-#define OBRACKET 260
-#define CBRACKET 261
-#define EQUAL_EMPTY 262
-#define STRING 263
-#define VARIABLE 264
-
-
-
+#define yyparse template_parse
+#define yylex template_lex
+#define yyerror template_error
+#define yylval template_lval
+#define yychar template_char
+#define yydebug template_debug
+#define yynerrs template_nerrs
+#define yylloc template_lloc
/* Copy the first part of user declarations. */
-#line 18 "template_syntax.y"
+
+/* Line 189 of yacc.c */
+#line 17 "template_syntax.y"
#include
#include
@@ -128,6 +108,9 @@ int template_parse(Template * tmpl, char ** errmsg);
static string& unescape (string &str);
+/* Line 189 of yacc.c */
+#line 113 "template_syntax.cc"
+
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
@@ -146,19 +129,43 @@ static string& unescape (string &str);
# define YYTOKEN_TABLE 0
#endif
+
+/* Tokens. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum yytokentype {
+ EQUAL = 258,
+ COMMA = 259,
+ OBRACKET = 260,
+ CBRACKET = 261,
+ EQUAL_EMPTY = 262,
+ STRING = 263,
+ VARIABLE = 264
+ };
+#endif
+
+
+
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
-#line 52 "template_syntax.y"
{
+
+/* Line 214 of yacc.c */
+#line 51 "template_syntax.y"
+
char * val_str;
void * val_attr;
-}
-/* Line 187 of yacc.c. */
-#line 158 "template_syntax.cc"
- YYSTYPE;
+
+
+
+/* Line 214 of yacc.c */
+#line 165 "template_syntax.cc"
+} YYSTYPE;
+# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
-# define YYSTYPE_IS_TRIVIAL 1
#endif
#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
@@ -178,8 +185,8 @@ typedef struct YYLTYPE
/* Copy the second part of user declarations. */
-/* Line 216 of yacc.c. */
-#line 183 "template_syntax.cc"
+/* Line 264 of yacc.c */
+#line 190 "template_syntax.cc"
#ifdef short
# undef short
@@ -254,14 +261,14 @@ typedef short int yytype_int16;
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static int
-YYID (int i)
+YYID (int yyi)
#else
static int
-YYID (i)
- int i;
+YYID (yyi)
+ int yyi;
#endif
{
- return i;
+ return yyi;
}
#endif
@@ -343,9 +350,9 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */
/* A type that is properly aligned for any stack member. */
union yyalloc
{
- yytype_int16 yyss;
- YYSTYPE yyvs;
- YYLTYPE yyls;
+ yytype_int16 yyss_alloc;
+ YYSTYPE yyvs_alloc;
+ YYLTYPE yyls_alloc;
};
/* The size of the maximum gap between one aligned stack and the next. */
@@ -380,12 +387,12 @@ union yyalloc
elements in the stack, and YYPTR gives the new location of the
stack. Advance YYPTR to a properly aligned location for the next
stack. */
-# define YYSTACK_RELOCATE(Stack) \
+# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
do \
{ \
YYSIZE_T yynewbytes; \
- YYCOPY (&yyptr->Stack, Stack, yysize); \
- Stack = &yyptr->Stack; \
+ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
+ Stack = &yyptr->Stack_alloc; \
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
yyptr += yynewbytes / sizeof (*yyptr); \
} \
@@ -466,7 +473,7 @@ static const yytype_int8 yyrhs[] =
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const yytype_uint8 yyrline[] =
{
- 0, 72, 72, 73, 76, 89, 103, 117, 133
+ 0, 71, 71, 72, 75, 88, 102, 116, 132
};
#endif
@@ -750,17 +757,20 @@ yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, tmpl, error_msg)
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static void
-yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
+yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
#else
static void
-yy_stack_print (bottom, top)
- yytype_int16 *bottom;
- yytype_int16 *top;
+yy_stack_print (yybottom, yytop)
+ yytype_int16 *yybottom;
+ yytype_int16 *yytop;
#endif
{
YYFPRINTF (stderr, "Stack now");
- for (; bottom <= top; ++bottom)
- YYFPRINTF (stderr, " %d", *bottom);
+ for (; yybottom <= yytop; yybottom++)
+ {
+ int yybot = *yybottom;
+ YYFPRINTF (stderr, " %d", yybot);
+ }
YYFPRINTF (stderr, "\n");
}
@@ -797,11 +807,11 @@ yy_reduce_print (yyvsp, yylsp, yyrule, tmpl, error_msg)
/* The symbols being reduced. */
for (yyi = 0; yyi < yynrhs; yyi++)
{
- fprintf (stderr, " $%d = ", yyi + 1);
+ YYFPRINTF (stderr, " $%d = ", yyi + 1);
yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
&(yyvsp[(yyi + 1) - (yynrhs)])
, &(yylsp[(yyi + 1) - (yynrhs)]) , tmpl, error_msg);
- fprintf (stderr, "\n");
+ YYFPRINTF (stderr, "\n");
}
}
@@ -1087,10 +1097,8 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp, tmpl, error_msg)
break;
}
}
-
/* Prevent warnings from -Wmissing-prototypes. */
-
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int yyparse (void *YYPARSE_PARAM);
@@ -1109,10 +1117,9 @@ int yyparse ();
-
-/*----------.
-| yyparse. |
-`----------*/
+/*-------------------------.
+| yyparse or yypush_parse. |
+`-------------------------*/
#ifdef YYPARSE_PARAM
#if (defined __STDC__ || defined __C99__FUNC__ \
@@ -1137,24 +1144,59 @@ yyparse (tmpl, error_msg)
#endif
#endif
{
- /* The look-ahead symbol. */
+/* The lookahead symbol. */
int yychar;
-/* The semantic value of the look-ahead symbol. */
+/* The semantic value of the lookahead symbol. */
YYSTYPE yylval;
-/* Number of syntax errors so far. */
-int yynerrs;
-/* Location data for the look-ahead symbol. */
+/* Location data for the lookahead symbol. */
YYLTYPE yylloc;
- int yystate;
+ /* Number of syntax errors so far. */
+ int yynerrs;
+
+ int yystate;
+ /* Number of tokens to shift before error messages enabled. */
+ int yyerrstatus;
+
+ /* The stacks and their tools:
+ `yyss': related to states.
+ `yyvs': related to semantic values.
+ `yyls': related to locations.
+
+ Refer to the stacks thru separate pointers, to allow yyoverflow
+ to reallocate them elsewhere. */
+
+ /* The state stack. */
+ yytype_int16 yyssa[YYINITDEPTH];
+ yytype_int16 *yyss;
+ yytype_int16 *yyssp;
+
+ /* The semantic value stack. */
+ YYSTYPE yyvsa[YYINITDEPTH];
+ YYSTYPE *yyvs;
+ YYSTYPE *yyvsp;
+
+ /* The location stack. */
+ YYLTYPE yylsa[YYINITDEPTH];
+ YYLTYPE *yyls;
+ YYLTYPE *yylsp;
+
+ /* The locations where the error started and ended. */
+ YYLTYPE yyerror_range[2];
+
+ YYSIZE_T yystacksize;
+
int yyn;
int yyresult;
- /* Number of tokens to shift before error messages enabled. */
- int yyerrstatus;
- /* Look-ahead token as an internal (translated) token number. */
- int yytoken = 0;
+ /* Lookahead token as an internal (translated) token number. */
+ int yytoken;
+ /* The variables used to return semantic value and location from the
+ action routines. */
+ YYSTYPE yyval;
+ YYLTYPE yyloc;
+
#if YYERROR_VERBOSE
/* Buffer for error messages, and its allocated size. */
char yymsgbuf[128];
@@ -1162,63 +1204,37 @@ YYLTYPE yylloc;
YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
#endif
- /* Three stacks and their tools:
- `yyss': related to states,
- `yyvs': related to semantic values,
- `yyls': related to locations.
-
- Refer to the stacks thru separate pointers, to allow yyoverflow
- to reallocate them elsewhere. */
-
- /* The state stack. */
- yytype_int16 yyssa[YYINITDEPTH];
- yytype_int16 *yyss = yyssa;
- yytype_int16 *yyssp;
-
- /* The semantic value stack. */
- YYSTYPE yyvsa[YYINITDEPTH];
- YYSTYPE *yyvs = yyvsa;
- YYSTYPE *yyvsp;
-
- /* The location stack. */
- YYLTYPE yylsa[YYINITDEPTH];
- YYLTYPE *yyls = yylsa;
- YYLTYPE *yylsp;
- /* The locations where the error started and ended. */
- YYLTYPE yyerror_range[2];
-
#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
- YYSIZE_T yystacksize = YYINITDEPTH;
-
- /* The variables used to return semantic value and location from the
- action routines. */
- YYSTYPE yyval;
- YYLTYPE yyloc;
-
/* The number of symbols on the RHS of the reduced rule.
Keep to zero when no symbol should be popped. */
int yylen = 0;
+ yytoken = 0;
+ yyss = yyssa;
+ yyvs = yyvsa;
+ yyls = yylsa;
+ yystacksize = YYINITDEPTH;
+
YYDPRINTF ((stderr, "Starting parse\n"));
yystate = 0;
yyerrstatus = 0;
yynerrs = 0;
- yychar = YYEMPTY; /* Cause a token to be read. */
+ yychar = YYEMPTY; /* Cause a token to be read. */
/* Initialize stack pointers.
Waste one element of value and location stack
so that they stay on the same level as the state stack.
The wasted elements are never initialized. */
-
yyssp = yyss;
yyvsp = yyvs;
yylsp = yyls;
+
#if YYLTYPE_IS_TRIVIAL
/* Initialize the default location before parsing starts. */
yylloc.first_line = yylloc.last_line = 1;
- yylloc.first_column = yylloc.last_column = 0;
+ yylloc.first_column = yylloc.last_column = 1;
#endif
goto yysetstate;
@@ -1257,6 +1273,7 @@ YYLTYPE yylloc;
&yyvs1, yysize * sizeof (*yyvsp),
&yyls1, yysize * sizeof (*yylsp),
&yystacksize);
+
yyls = yyls1;
yyss = yyss1;
yyvs = yyvs1;
@@ -1278,9 +1295,9 @@ YYLTYPE yylloc;
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
if (! yyptr)
goto yyexhaustedlab;
- YYSTACK_RELOCATE (yyss);
- YYSTACK_RELOCATE (yyvs);
- YYSTACK_RELOCATE (yyls);
+ YYSTACK_RELOCATE (yyss_alloc, yyss);
+ YYSTACK_RELOCATE (yyvs_alloc, yyvs);
+ YYSTACK_RELOCATE (yyls_alloc, yyls);
# undef YYSTACK_RELOCATE
if (yyss1 != yyssa)
YYSTACK_FREE (yyss1);
@@ -1301,6 +1318,9 @@ YYLTYPE yylloc;
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
+ if (yystate == YYFINAL)
+ YYACCEPT;
+
goto yybackup;
/*-----------.
@@ -1309,16 +1329,16 @@ YYLTYPE yylloc;
yybackup:
/* Do appropriate processing given the current state. Read a
- look-ahead token if we need one and don't already have one. */
+ lookahead token if we need one and don't already have one. */
- /* First try to decide what to do without reference to look-ahead token. */
+ /* First try to decide what to do without reference to lookahead token. */
yyn = yypact[yystate];
if (yyn == YYPACT_NINF)
goto yydefault;
- /* Not known => get a look-ahead token if don't already have one. */
+ /* Not known => get a lookahead token if don't already have one. */
- /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
+ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
if (yychar == YYEMPTY)
{
YYDPRINTF ((stderr, "Reading a token: "));
@@ -1350,20 +1370,16 @@ yybackup:
goto yyreduce;
}
- if (yyn == YYFINAL)
- YYACCEPT;
-
/* Count tokens shifted since error; after three, turn off error
status. */
if (yyerrstatus)
yyerrstatus--;
- /* Shift the look-ahead token. */
+ /* Shift the lookahead token. */
YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
- /* Discard the shifted token unless it is eof. */
- if (yychar != YYEOF)
- yychar = YYEMPTY;
+ /* Discard the shifted token. */
+ yychar = YYEMPTY;
yystate = yyn;
*++yyvsp = yylval;
@@ -1404,7 +1420,9 @@ yyreduce:
switch (yyn)
{
case 4:
-#line 77 "template_syntax.y"
+
+/* Line 1455 of yacc.c */
+#line 76 "template_syntax.y"
{
Attribute * pattr;
string name((yyvsp[(1) - (3)].val_str));
@@ -1420,7 +1438,9 @@ yyreduce:
break;
case 5:
-#line 90 "template_syntax.y"
+
+/* Line 1455 of yacc.c */
+#line 89 "template_syntax.y"
{
Attribute * pattr;
string name((yyvsp[(1) - (5)].val_str));
@@ -1437,7 +1457,9 @@ yyreduce:
break;
case 6:
-#line 104 "template_syntax.y"
+
+/* Line 1455 of yacc.c */
+#line 103 "template_syntax.y"
{
Attribute * pattr;
string name((yyvsp[(1) - (2)].val_str));
@@ -1452,7 +1474,9 @@ yyreduce:
break;
case 7:
-#line 118 "template_syntax.y"
+
+/* Line 1455 of yacc.c */
+#line 117 "template_syntax.y"
{
map* vattr;
string name((yyvsp[(1) - (3)].val_str));
@@ -1471,7 +1495,9 @@ yyreduce:
break;
case 8:
-#line 134 "template_syntax.y"
+
+/* Line 1455 of yacc.c */
+#line 133 "template_syntax.y"
{
string name((yyvsp[(3) - (5)].val_str));
string value((yyvsp[(5) - (5)].val_str));
@@ -1490,8 +1516,9 @@ yyreduce:
break;
-/* Line 1267 of yacc.c. */
-#line 1495 "template_syntax.cc"
+
+/* Line 1455 of yacc.c */
+#line 1522 "template_syntax.cc"
default: break;
}
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -1567,7 +1594,7 @@ yyerrlab:
if (yyerrstatus == 3)
{
- /* If just tried and failed to reuse look-ahead token after an
+ /* If just tried and failed to reuse lookahead token after an
error, discard it. */
if (yychar <= YYEOF)
@@ -1584,7 +1611,7 @@ yyerrlab:
}
}
- /* Else will try to reuse look-ahead token after shifting the error
+ /* Else will try to reuse lookahead token after shifting the error
token. */
goto yyerrlab1;
@@ -1642,14 +1669,11 @@ yyerrlab1:
YY_STACK_PRINT (yyss, yyssp);
}
- if (yyn == YYFINAL)
- YYACCEPT;
-
*++yyvsp = yylval;
yyerror_range[1] = yylloc;
/* Using YYLLOC is tempting, but would change the location of
- the look-ahead. YYLOC is available though. */
+ the lookahead. YYLOC is available though. */
YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
*++yylsp = yyloc;
@@ -1674,7 +1698,7 @@ yyabortlab:
yyresult = 1;
goto yyreturn;
-#ifndef yyoverflow
+#if !defined(yyoverflow) || YYERROR_VERBOSE
/*-------------------------------------------------.
| yyexhaustedlab -- memory exhaustion comes here. |
`-------------------------------------------------*/
@@ -1685,7 +1709,7 @@ yyexhaustedlab:
#endif
yyreturn:
- if (yychar != YYEOF && yychar != YYEMPTY)
+ if (yychar != YYEMPTY)
yydestruct ("Cleanup: discarding lookahead",
yytoken, &yylval, &yylloc, tmpl, error_msg);
/* Do not reclaim the symbols of the rule which action triggered
@@ -1711,7 +1735,9 @@ yyreturn:
}
-#line 150 "template_syntax.y"
+
+/* Line 1675 of yacc.c */
+#line 149 "template_syntax.y"
string& unescape (string &str)
diff --git a/src/template/template_syntax.h b/src/template/template_syntax.h
index a2aeba6e7d..584fb9da38 100644
--- a/src/template/template_syntax.h
+++ b/src/template/template_syntax.h
@@ -1,24 +1,23 @@
-/* A Bison parser, made by GNU Bison 2.3. */
+
+/* A Bison parser, made by GNU Bison 2.4.1. */
/* Skeleton interface for Bison's Yacc-like parsers in C
-
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
+
+ This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ along with this program. If not, see . */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
@@ -29,10 +28,11 @@
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
-
+
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
+
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
@@ -48,31 +48,27 @@
VARIABLE = 264
};
#endif
-/* Tokens. */
-#define EQUAL 258
-#define COMMA 259
-#define OBRACKET 260
-#define CBRACKET 261
-#define EQUAL_EMPTY 262
-#define STRING 263
-#define VARIABLE 264
-
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
-#line 52 "template_syntax.y"
{
+
+/* Line 1676 of yacc.c */
+#line 51 "template_syntax.y"
+
char * val_str;
void * val_attr;
-}
-/* Line 1489 of yacc.c. */
-#line 72 "template_syntax.hh"
- YYSTYPE;
+
+
+
+/* Line 1676 of yacc.c */
+#line 68 "template_syntax.hh"
+} YYSTYPE;
+# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
-# define YYSTYPE_IS_TRIVIAL 1
#endif
@@ -91,3 +87,4 @@ typedef struct YYLTYPE
#endif
+
diff --git a/src/template/template_syntax.y b/src/template/template_syntax.y
index d88dd6adfc..eac691e007 100644
--- a/src/template/template_syntax.y
+++ b/src/template/template_syntax.y
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/tm/SConstruct b/src/tm/SConstruct
index f29721a069..b7e16228d5 100644
--- a/src/tm/SConstruct
+++ b/src/tm/SConstruct
@@ -1,8 +1,7 @@
# SConstruct for src/vm
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/tm/TransferManager.cc b/src/tm/TransferManager.cc
index 4333e07a5f..f54b5c053e 100644
--- a/src/tm/TransferManager.cc
+++ b/src/tm/TransferManager.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
@@ -197,26 +196,27 @@ void TransferManager::do_action(const string &action, void * arg)
void TransferManager::prolog_action(int vid)
{
- ofstream xfr;
- ostringstream os;
- string xfr_name;
+ ofstream xfr;
+ ostringstream os;
+ string xfr_name;
const VectorAttribute * disk;
- string source;
- string type;
- string clon;
- string files;
+ string source;
+ string type;
+ string clon;
+ string files;
+ string size;
+ string format;
- VirtualMachine * vm;
- Nebula& nd = Nebula::instance();
+ VirtualMachine * vm;
+ Nebula& nd = Nebula::instance();
const TransferManagerDriver * tm_md;
- vector attrs;
- int num;
-
- int context_result;
+ vector attrs;
+ int num;
+ int context_result;
// ------------------------------------------------------------------------
// Setup & Transfer script
@@ -264,11 +264,12 @@ void TransferManager::prolog_action(int vid)
continue;
}
- type = disk->vector_value("TYPE");
+ type = disk->vector_value("TYPE");
if ( type.empty() == false)
{
- transform(type.begin(),type.end(),type.begin(),(int(*)(int))toupper);
+ transform(type.begin(),type.end(),type.begin(),
+ (int(*)(int))toupper);
}
if ( type == "SWAP" )
@@ -276,7 +277,7 @@ void TransferManager::prolog_action(int vid)
// -----------------------------------------------------------------
// Generate a swap disk image
// -----------------------------------------------------------------
- string size = disk->vector_value("SIZE");
+ size = disk->vector_value("SIZE");
if (size.empty()==true)
{
@@ -292,8 +293,8 @@ void TransferManager::prolog_action(int vid)
// -----------------------------------------------------------------
// Create a clean file system disk image
// -----------------------------------------------------------------
- string size = disk->vector_value("SIZE");
- string format = disk->vector_value("FORMAT");
+ size = disk->vector_value("SIZE");
+ format = disk->vector_value("FORMAT");
if ( size.empty() || format.empty())
{
@@ -312,6 +313,7 @@ void TransferManager::prolog_action(int vid)
// CLONE or LINK disk images
// -----------------------------------------------------------------
clon = disk->vector_value("CLONE");
+ size = disk->vector_value("SIZE");
if ( clon.empty() == true )
{
@@ -319,7 +321,8 @@ void TransferManager::prolog_action(int vid)
}
else
{
- transform(clon.begin(),clon.end(),clon.begin(),(int(*)(int))toupper);
+ transform(clon.begin(),clon.end(),clon.begin(),
+ (int(*)(int))toupper);
}
if (clon == "YES")
@@ -351,7 +354,14 @@ void TransferManager::prolog_action(int vid)
}
xfr << vm->get_hostname() << ":" << vm->get_remote_dir()
- << "/disk." << i << endl;
+ << "/disk." << i;
+
+ if (!size.empty()) //Add size for dev based disks
+ {
+ xfr << " " << size;
+ }
+
+ xfr << endl;
}
}
diff --git a/src/tm/TransferManagerDriver.cc b/src/tm/TransferManagerDriver.cc
index 9191eb044a..9a3aac29db 100644
--- a/src/tm/TransferManagerDriver.cc
+++ b/src/tm/TransferManagerDriver.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/tm_mad/TMScript.rb b/src/tm_mad/TMScript.rb
index 6f272d23c6..628600418d 100644
--- a/src/tm_mad/TMScript.rb
+++ b/src/tm_mad/TMScript.rb
@@ -1,7 +1,6 @@
# -------------------------------------------------------------------------- #
-# Copyright 2002-2008, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/tm_mad/lvm/tm_clone.sh b/src/tm_mad/lvm/tm_clone.sh
new file mode 100755
index 0000000000..7ecfb781c2
--- /dev/null
+++ b/src/tm_mad/lvm/tm_clone.sh
@@ -0,0 +1,87 @@
+#!/bin/bash
+
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
+
+SRC=$1
+DST=$2
+SIZE=$3
+
+if [ -z "${ONE_LOCATION}" ]; then
+ TMCOMMON=/usr/lib/one/mads/tm_common.sh
+ LVMRC=/etc/one/tm_lvm/tm_lvmrc
+else
+ TMCOMMON=$ONE_LOCATION/lib/mads/tm_common.sh
+ LVMRC=$ONE_LOCATION/etc/tm_lvm/tm_lvmrc
+fi
+
+. $TMCOMMON
+. $LVMRC
+
+SRC_PATH=`arg_path $SRC`
+DST_PATH=`arg_path $DST`
+
+SRC_HOST=`arg_host $SRC`
+DST_HOST=`arg_host $DST`
+
+if [ -z $SIZE ] ; then
+ SIZE=$DEFAULT_LV_SIZE
+fi
+
+LV_NAME=`get_lv_name $DST_PATH`
+
+log "$1 $2"
+log "DST: $DST_PATH"
+
+DST_DIR=`dirname $DST_PATH`
+
+log "Creating directory $DST_DIR"
+exec_and_log "ssh $DST_HOST mkdir -p $DST_DIR"
+
+case $SRC in
+#------------------------------------------------------------------------------
+#Get the image from http repository and dump it to a new LV
+#------------------------------------------------------------------------------
+http://*)
+ log "Creating LV $LV_NAME"
+ exec_and_log "ssh $DST_HOST sudo lvcreate -L$SIZE -n $LV_NAME $VG_NAME"
+ exec_and_log "ssh $DST_HOST ln -s /dev/$VG_NAME/$LV_NAME $DST_PATH"
+
+ log "Dumping Image into /dev/$VG_NAME/$LV_NAME"
+ exec_and_log "eval ssh $DST_HOST 'wget $SRC -q -O- | sudo dd of=/dev/$VG_NAME/$LV_NAME bs=64k'"
+ ;;
+
+#------------------------------------------------------------------------------
+#Make a snapshot from the given dev (already in DST_HOST)
+#------------------------------------------------------------------------------
+*:/dev/*)
+ log "Cloning LV $LV_NAME"
+ exec_and_log "ssh $DST_HOST sudo lvcreate -s -L$SIZE -n $LV_NAME $SRC_PATH"
+ exec_and_log "ssh $DST_HOST ln -s /dev/$VG_NAME/$LV_NAME $DST_PATH"
+ ;;
+
+#------------------------------------------------------------------------------
+#Get the image from SRC_HOST and dump it to a new LV
+#------------------------------------------------------------------------------
+*)
+ log "Creating LV $LV_NAME"
+ exec_and_log "ssh $DST_HOST sudo lvcreate -L$SIZE -n $LV_NAME $VG_NAME"
+ exec_and_log "ssh $DST_HOST ln -s /dev/$VG_NAME/$LV_NAME $DST_PATH"
+
+ log "Dumping Image"
+ exec_and_log "eval cat $SRC_PATH | ssh $DST_HOST sudo dd of=/dev/$VG_NAME/$LV_NAME bs=64k"
+ ;;
+esac
diff --git a/src/tm_mad/lvm/tm_context.sh b/src/tm_mad/lvm/tm_context.sh
new file mode 100755
index 0000000000..6b1dcea8da
--- /dev/null
+++ b/src/tm_mad/lvm/tm_context.sh
@@ -0,0 +1,66 @@
+#!/bin/bash
+
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
+
+# Parameters: a b c d e f g h
+# SRC: a b c d e f g
+# DST: h
+while (( "$#" )); do
+ if [ "$#" == "1" ]; then
+ DST=$1
+ else
+ SRC="$SRC $1"
+ fi
+ shift
+done
+
+
+if [ -z "${ONE_LOCATION}" ]; then
+ TMCOMMON=/usr/lib/one/mads/tm_common.sh
+else
+ TMCOMMON=$ONE_LOCATION/lib/mads/tm_common.sh
+fi
+
+. $TMCOMMON
+
+
+DST_PATH=`arg_path $DST`
+DST_DIR=`dirname $DST_PATH`
+DST_FILE=`basename $DST_PATH`
+DST_HASH=`echo -n $DST | md5sum | awk '{print $1}'`
+TMP_DIR="$ONE_LOCATION/var/$DST_HASH"
+ISO_DIR="$TMP_DIR/isofiles"
+
+
+exec_and_log "mkdir -p $ISO_DIR"
+
+for f in $SRC; do
+ case $f in
+ http://*)
+ exec_and_log "wget -O $ISO_DIR $f"
+ ;;
+
+ *)
+ exec_and_log "cp -R $f $ISO_DIR"
+ ;;
+ esac
+done
+
+exec_and_log "mkisofs -o $TMP_DIR/$DST_FILE -J -R $ISO_DIR"
+exec_and_log "scp $TMP_DIR/$DST_FILE $DST"
+exec_and_log "rm -rf $TMP_DIR"
+
diff --git a/src/tm_mad/lvm/tm_delete.sh b/src/tm_mad/lvm/tm_delete.sh
new file mode 100755
index 0000000000..4973617abf
--- /dev/null
+++ b/src/tm_mad/lvm/tm_delete.sh
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
+
+SRC=$1
+DST=$2
+
+if [ -z "${ONE_LOCATION}" ]; then
+ TMCOMMON=/usr/lib/one/mads/tm_common.sh
+ LVMRC=/etc/one/tm_lvm/tm_lvmrc
+else
+ TMCOMMON=$ONE_LOCATION/lib/mads/tm_common.sh
+ LVMRC=$ONE_LOCATION/etc/tm_lvm/tm_lvmrc
+fi
+
+. $TMCOMMON
+. $LVMRC
+
+SRC_PATH=`arg_path $SRC`
+SRC_HOST=`arg_host $SRC`
+
+VID=`get_vid $SRC_PATH`
+
+log "Deleting remote LVs"
+exec_and_log "ssh $SRC_HOST sudo lvremove -f \$(echo $VG_NAME/\$(sudo lvs --noheadings $VG_NAME|awk '{print \$1}'|grep lv-one-$VID))"
+
+log "Deleting $SRC_PATH"
+exec_and_log "ssh $SRC_HOST rm -rf $SRC_PATH"
diff --git a/src/tm_mad/lvm/tm_ln.sh b/src/tm_mad/lvm/tm_ln.sh
new file mode 100755
index 0000000000..bc97921745
--- /dev/null
+++ b/src/tm_mad/lvm/tm_ln.sh
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
+
+SRC=$1
+DST=$2
+
+if [ -z "${ONE_LOCATION}" ]; then
+ TMCOMMON=/usr/lib/one/mads/tm_common.sh
+ TM_COMMANDS_LOCATION=/usr/lib/one/tm_commands/
+else
+ TMCOMMON=$ONE_LOCATION/lib/mads/tm_common.sh
+ TM_COMMANDS_LOCATION=$ONE_LOCATION/lib/tm_commands/
+fi
+
+. $TMCOMMON
+
+log "Link $SRC_PATH (non shared dir, will clone)"
+#exec_and_log "ln -s $SRC_PATH $DST_PATH"
+exec $TM_COMMANDS_LOCATION/ssh/tm_clone.sh $SRC $DST
diff --git a/src/tm_mad/lvm/tm_lvm.conf b/src/tm_mad/lvm/tm_lvm.conf
new file mode 100755
index 0000000000..199dbcec68
--- /dev/null
+++ b/src/tm_mad/lvm/tm_lvm.conf
@@ -0,0 +1,7 @@
+CLONE = lvm/tm_clone.sh
+LN = lvm/tm_ln.sh
+MKSWAP = lvm/tm_mkswap.sh
+MKIMAGE = lvm/tm_mkimage.sh
+DELETE = lvm/tm_delete.sh
+MV = lvm/tm_mv.sh
+CONTEXT = lvm/tm_context.sh
diff --git a/src/tm_mad/lvm/tm_lvmrc b/src/tm_mad/lvm/tm_lvmrc
new file mode 100644
index 0000000000..6d2a65e229
--- /dev/null
+++ b/src/tm_mad/lvm/tm_lvmrc
@@ -0,0 +1,39 @@
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
+
+# -------------------------------------------------------------------------- #
+
+# Volume Group to create logical volumes or snapshots in the cluster nodes #
+VG_NAME=
+
+# Default size for logical volumes if not specified
+DEFAULT_LV_SIZE="1G"
+
+
+# -------------------------------------------------------------------------- #
+# Helper functions for the LVM plugin #
+# -------------------------------------------------------------------------- #
+
+function get_vid {
+ echo $1 |sed -e 's%^.*/\([^/]*\)/images.*$%\1%'
+}
+
+function get_lv_name {
+ VID=`get_vid $1`
+ DISK=`echo $1|awk -F. '{printf $NF}'`
+ echo "lv-one-$VID-$DISK"
+}
+
diff --git a/src/tm_mad/lvm/tm_mkimage.sh b/src/tm_mad/lvm/tm_mkimage.sh
new file mode 100755
index 0000000000..55a42269e9
--- /dev/null
+++ b/src/tm_mad/lvm/tm_mkimage.sh
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
+
+if [ -z "${ONE_LOCATION}" ]; then
+ TMCOMMON=/usr/lib/one/mads/tm_common.sh
+else
+ TMCOMMON=$ONE_LOCATION/lib/mads/tm_common.sh
+fi
+
+. $TMCOMMON
+
+SIZE=$1
+FSTYPE=$2
+DST=$3
+
+DST_PATH=`arg_path $DST`
+DST_HOST=`arg_host $DST`
+DST_DIR=`dirname $DST_PATH`
+
+exec_and_log "ssh $DST_HOST mkdir -p $DST_DIR"
+exec_and_log "ssh $DST_HOST dd if=/dev/zero of=$DST_PATH bs=1 count=1 seek=${SIZE}M"
+exec_and_log "ssh $DST_HOST mkfs -t $FSTYPE -F $DST_PATH"
+exec_and_log "ssh $DST_HOST chmod a+rw $DST_PATH"
diff --git a/src/tm_mad/lvm/tm_mkswap.sh b/src/tm_mad/lvm/tm_mkswap.sh
new file mode 100755
index 0000000000..55914fc90f
--- /dev/null
+++ b/src/tm_mad/lvm/tm_mkswap.sh
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
+
+SIZE=$1
+DST=$2
+
+if [ -z "${ONE_LOCATION}" ]; then
+ TMCOMMON=/usr/lib/one/mads/tm_common.sh
+else
+ TMCOMMON=$ONE_LOCATION/lib/mads/tm_common.sh
+fi
+
+. $TMCOMMON
+
+DST_PATH=`arg_path $DST`
+DST_HOST=`arg_host $DST`
+
+DST_DIR=`dirname $DST_PATH`
+
+log "Creating ${SIZE}Mb image in $DST_PATH"
+exec_and_log "ssh $DST_HOST mkdir -p $DST_DIR"
+exec_and_log "ssh $DST_HOST dd if=/dev/zero of=$DST_PATH bs=1 count=1 seek=${SIZE}M"
+
+log "Initializing swap space"
+exec_and_log "ssh $DST_HOST /sbin/mkswap $DST_PATH"
+
+exec_and_log "ssh $DST_HOST chmod a+w $DST_PATH"
+
diff --git a/src/tm_mad/lvm/tm_mv.sh b/src/tm_mad/lvm/tm_mv.sh
new file mode 100755
index 0000000000..d4a682dcb0
--- /dev/null
+++ b/src/tm_mad/lvm/tm_mv.sh
@@ -0,0 +1,79 @@
+#!/bin/bash
+
+# -------------------------------------------------------------------------- #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------- #
+
+SRC=$1
+DST=$2
+
+if [ -z "${ONE_LOCATION}" ]; then
+ TMCOMMON=/usr/lib/one/mads/tm_common.sh
+ LVMRC=/etc/one/tm_lvm/tm_lvmrc
+else
+ TMCOMMON=$ONE_LOCATION/lib/mads/tm_common.sh
+ LVMRC=$ONE_LOCATION/etc/tm_lvm/tm_lvmrc
+fi
+
+. $TMCOMMON
+. $LVMRC
+
+SRC_PATH=`arg_path $SRC`
+DST_PATH=`arg_path $DST`
+
+SRC_HOST=`arg_host $SRC`
+DST_HOST=`arg_host $DST`
+
+DST_DIR=`dirname $DST_PATH`
+
+VID=`get_vid $SRC_PATH`
+
+if [ -z $SIZE ] ; then
+ SIZE=$DEFAULT_LV_SIZE
+fi
+
+# Check that we are not stopping, migrating or resuming
+if echo `basename $SRC_PATH`|grep -vq '^disk'; then
+ log_error "This TM does not support stop, migrating or resuming."
+ exit 1
+fi
+
+if [ "$SRC_HOST" != "$HOSTNAME" ]; then
+ log "Dumping LV to disk image"
+
+ echo "if [ -L "$SRC_PATH" ]; then
+ lv=\$(readlink $SRC_PATH)
+ rm $SRC_PATH
+ touch $SRC_PATH
+ sudo dd if=\$lv of=$SRC_PATH bs=64k
+ else
+ exit 1
+ fi" | ssh $SRC_HOST "bash -s"
+
+ [ "$?" != "0" ] && log_error "Error dumping LV to disk image"
+
+ log "Deleting remote LVs"
+ exec_and_log "ssh $SRC_HOST sudo lvremove -f \$(echo $VG_NAME/\$(sudo lvs --noheadings $VG_NAME|awk '{print \$1}'|grep lv-one-$VID))"
+fi
+
+log "Moving $SRC_PATH"
+exec_and_log "ssh $DST_HOST mkdir -p $DST_DIR"
+exec_and_log "scp -r $SRC $DST"
+exec_and_log "ssh $SRC_HOST rm -rf $SRC_PATH"
+
+if [ "$DST_HOST" != "$HOSTNAME" ]; then
+ log_error "This TM does not support resuming."
+fi
+
diff --git a/src/tm_mad/nfs/tm_clone.sh b/src/tm_mad/nfs/tm_clone.sh
index f1a453c6f4..ff2ed6730d 100755
--- a/src/tm_mad/nfs/tm_clone.sh
+++ b/src/tm_mad/nfs/tm_clone.sh
@@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@@ -28,9 +27,13 @@ fi
. $TMCOMMON
+get_vmdir
+
SRC_PATH=`arg_path $SRC`
DST_PATH=`arg_path $DST`
+fix_paths
+
log "$1 $2"
log "DST: $DST_PATH"
diff --git a/src/tm_mad/nfs/tm_context.sh b/src/tm_mad/nfs/tm_context.sh
index 291c5fb35c..1f54ebe647 100755
--- a/src/tm_mad/nfs/tm_context.sh
+++ b/src/tm_mad/nfs/tm_context.sh
@@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@@ -38,8 +37,12 @@ fi
. $TMCOMMON
+get_vmdir
DST_PATH=`arg_path $DST`
+
+fix_dst_path
+
DST_DIR=`dirname $DST_PATH`
ISO_DIR=$DST_DIR/isofiles
diff --git a/src/tm_mad/nfs/tm_delete.sh b/src/tm_mad/nfs/tm_delete.sh
index 876ed473a4..17475cac04 100755
--- a/src/tm_mad/nfs/tm_delete.sh
+++ b/src/tm_mad/nfs/tm_delete.sh
@@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@@ -28,7 +27,11 @@ fi
. $TMCOMMON
+get_vmdir
+
SRC_PATH=`arg_path $SRC`
+fix_src_path
+
log "Deleting $SRC_PATH"
exec_and_log "rm -rf $SRC_PATH"
diff --git a/src/tm_mad/nfs/tm_ln.sh b/src/tm_mad/nfs/tm_ln.sh
index f5c8bf98b0..98c033da51 100755
--- a/src/tm_mad/nfs/tm_ln.sh
+++ b/src/tm_mad/nfs/tm_ln.sh
@@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@@ -28,9 +27,13 @@ fi
. $TMCOMMON
+get_vmdir
+
SRC_PATH=`arg_path $SRC`
DST_PATH=`arg_path $DST`
+fix_dst_path
+
DST_DIR=`dirname $DST_PATH`
log "Creating directory $DST_DIR"
diff --git a/src/tm_mad/nfs/tm_mkimage.sh b/src/tm_mad/nfs/tm_mkimage.sh
index 8dd7a18b24..5bb7886107 100755
--- a/src/tm_mad/nfs/tm_mkimage.sh
+++ b/src/tm_mad/nfs/tm_mkimage.sh
@@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@@ -25,11 +24,16 @@ fi
. $TMCOMMON
+get_vmdir
+
SIZE=$1
FSTYPE=$2
DST=$3
DST_PATH=`arg_path $DST`
+
+fix_dst_path
+
DST_DIR=`dirname $DST_PATH`
exec_and_log "mkdir -p $DST_DIR"
diff --git a/src/tm_mad/nfs/tm_mkswap.sh b/src/tm_mad/nfs/tm_mkswap.sh
index aab637d8a3..72ea4252c3 100755
--- a/src/tm_mad/nfs/tm_mkswap.sh
+++ b/src/tm_mad/nfs/tm_mkswap.sh
@@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@@ -28,7 +27,12 @@ fi
. $TMCOMMON
+get_vmdir
+
DST_PATH=`arg_path $DST`
+
+fix_dst_path
+
DST_DIR=`dirname $DST_PATH`
log "Creating directory $DST_DIR"
diff --git a/src/tm_mad/nfs/tm_mv.sh b/src/tm_mad/nfs/tm_mv.sh
index 9be2dcc247..2df392eba7 100755
--- a/src/tm_mad/nfs/tm_mv.sh
+++ b/src/tm_mad/nfs/tm_mv.sh
@@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@@ -30,9 +29,13 @@ fi
. $TMCOMMON
+get_vmdir
+
SRC_PATH=`arg_path $SRC`
DST_PATH=`arg_path $DST`
+fix_paths
+
if [ "$SRC_PATH" == "$DST_PATH" ]; then
log "Will not move, source and destination are equal"
else
diff --git a/src/tm_mad/nfs/tm_nfsrc b/src/tm_mad/nfs/tm_nfsrc
index 919c811fa7..6f868dff5c 100644
--- a/src/tm_mad/nfs/tm_nfsrc
+++ b/src/tm_mad/nfs/tm_nfsrc
@@ -1,6 +1,5 @@
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/tm_mad/one_tm b/src/tm_mad/one_tm
index cbcc21732e..8e1c9d6a4e 100755
--- a/src/tm_mad/one_tm
+++ b/src/tm_mad/one_tm
@@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/tm_mad/one_tm.rb b/src/tm_mad/one_tm.rb
index e7359755f1..591d5c9c9d 100755
--- a/src/tm_mad/one_tm.rb
+++ b/src/tm_mad/one_tm.rb
@@ -1,8 +1,7 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/tm_mad/ssh/tm_clone.sh b/src/tm_mad/ssh/tm_clone.sh
index f6a2852ff8..b853119b81 100755
--- a/src/tm_mad/ssh/tm_clone.sh
+++ b/src/tm_mad/ssh/tm_clone.sh
@@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/tm_mad/ssh/tm_context.sh b/src/tm_mad/ssh/tm_context.sh
old mode 100644
new mode 100755
index e419eef714..6b1dcea8da
--- a/src/tm_mad/ssh/tm_context.sh
+++ b/src/tm_mad/ssh/tm_context.sh
@@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/tm_mad/ssh/tm_delete.sh b/src/tm_mad/ssh/tm_delete.sh
index 437ab0142f..7844ee2533 100755
--- a/src/tm_mad/ssh/tm_delete.sh
+++ b/src/tm_mad/ssh/tm_delete.sh
@@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/tm_mad/ssh/tm_ln.sh b/src/tm_mad/ssh/tm_ln.sh
index 15a5e80d4b..bc97921745 100755
--- a/src/tm_mad/ssh/tm_ln.sh
+++ b/src/tm_mad/ssh/tm_ln.sh
@@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/tm_mad/ssh/tm_mkimage.sh b/src/tm_mad/ssh/tm_mkimage.sh
index 7e47671148..55a42269e9 100755
--- a/src/tm_mad/ssh/tm_mkimage.sh
+++ b/src/tm_mad/ssh/tm_mkimage.sh
@@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/tm_mad/ssh/tm_mkswap.sh b/src/tm_mad/ssh/tm_mkswap.sh
index 9bb4adc7f6..55914fc90f 100755
--- a/src/tm_mad/ssh/tm_mkswap.sh
+++ b/src/tm_mad/ssh/tm_mkswap.sh
@@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/tm_mad/ssh/tm_mv.sh b/src/tm_mad/ssh/tm_mv.sh
index 216be37d26..e6438201d5 100755
--- a/src/tm_mad/ssh/tm_mv.sh
+++ b/src/tm_mad/ssh/tm_mv.sh
@@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/tm_mad/ssh/tm_ssh.conf b/src/tm_mad/ssh/tm_ssh.conf
index c5298d0c0e..411e1e41c0 100755
--- a/src/tm_mad/ssh/tm_ssh.conf
+++ b/src/tm_mad/ssh/tm_ssh.conf
@@ -4,3 +4,4 @@ MKSWAP = ssh/tm_mkswap.sh
MKIMAGE = ssh/tm_mkimage.sh
DELETE = ssh/tm_delete.sh
MV = ssh/tm_mv.sh
+CONTEXT = ssh/tm_context.sh
diff --git a/src/tm_mad/ssh/tm_sshrc b/src/tm_mad/ssh/tm_sshrc
index 919c811fa7..6f868dff5c 100644
--- a/src/tm_mad/ssh/tm_sshrc
+++ b/src/tm_mad/ssh/tm_sshrc
@@ -1,6 +1,5 @@
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/tm_mad/tm_common.sh b/src/tm_mad/tm_common.sh
index 46e0599ba2..0f589fe357 100644
--- a/src/tm_mad/tm_common.sh
+++ b/src/tm_mad/tm_common.sh
@@ -1,6 +1,5 @@
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@@ -15,6 +14,41 @@
# limitations under the License. #
#--------------------------------------------------------------------------- #
+if [ -z "$ONE_LOCATION" ]; then
+ ONE_CONF=/etc/one/oned.conf
+ ONE_LOCAL_VAR=/var/lib/one
+else
+ ONE_CONF=$ONE_LOCATION/etc/oned.conf
+ ONE_LOCAL_VAR=$ONE_LOCATION/var
+fi
+
+function get_vmdir
+{
+ VMDIR=`cat $ONE_CONF | grep ^VM_DIR= | cut -d= -f2`
+}
+
+function fix_paths
+{
+ if [ -n "$VMDIR" ]; then
+ SRC_PATH=${SRC_PATH/$VMDIR/$ONE_LOCAL_VAR}
+ DST_PATH=${DST_PATH/$VMDIR/$ONE_LOCAL_VAR}
+ fi
+}
+
+function fix_src_path
+{
+ if [ -n "$VMDIR" ]; then
+ SRC_PATH=${SRC_PATH/$VMDIR/$ONE_LOCAL_VAR}
+ fi
+}
+
+function fix_dst_path
+{
+ if [ -n "$VMDIR" ]; then
+ DST_PATH=${DST_PATH/$VMDIR/$ONE_LOCAL_VAR}
+ fi
+}
+
# Used for log messages
SCRIPT_NAME=`basename $0`
@@ -62,11 +96,12 @@ function arg_path
function exec_and_log
{
output=`$1 2>&1 1>/dev/null`
- if [ "x$?" != "x0" ]; then
+ code=$?
+ if [ "x$code" != "x0" ]; then
log_error "Command \"$1\" failed."
log_error "$output"
error_message "$output"
- exit -1
+ exit $code
fi
log "Executed \"$1\"."
}
@@ -96,7 +131,7 @@ function timeout_exec_and_log
) &
TIMEOUT_PID=$!
- # stopts the exution until the command finalizes
+ # stops the execution until the command finalizes
wait $CMD_PID 2>/dev/null
CMD_CODE=$?
diff --git a/src/tm_mad/vmware/tm_clone.sh b/src/tm_mad/vmware/tm_clone.sh
index 968f15fe7f..7856c6955b 100755
--- a/src/tm_mad/vmware/tm_clone.sh
+++ b/src/tm_mad/vmware/tm_clone.sh
@@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/tm_mad/vmware/tm_delete.sh b/src/tm_mad/vmware/tm_delete.sh
index e9e518b8d5..fdd5a7cf06 100755
--- a/src/tm_mad/vmware/tm_delete.sh
+++ b/src/tm_mad/vmware/tm_delete.sh
@@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/tm_mad/vmware/tm_vmwarerc b/src/tm_mad/vmware/tm_vmwarerc
index d1e202e5d9..b35183e2b8 100644
--- a/src/tm_mad/vmware/tm_vmwarerc
+++ b/src/tm_mad/vmware/tm_vmwarerc
@@ -1,6 +1,5 @@
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/um/SConstruct b/src/um/SConstruct
index 7f92eba6ac..14d86a9fb9 100644
--- a/src/um/SConstruct
+++ b/src/um/SConstruct
@@ -1,8 +1,7 @@
# SConstruct for src/vm
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/um/User.cc b/src/um/User.cc
index c49ff4a618..ea6f2ff1a6 100644
--- a/src/um/User.cc
+++ b/src/um/User.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/um/UserPool.cc b/src/um/UserPool.cc
index deb344cb9e..ccd2fb00c2 100644
--- a/src/um/UserPool.cc
+++ b/src/um/UserPool.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
@@ -22,6 +21,7 @@
#include "UserPool.h"
#include "Nebula.h"
+#include
#include
#include
@@ -67,45 +67,65 @@ UserPool::UserPool(SqliteDB * db):PoolSQL(db,User::table)
if ((int) known_users.size() == 0)
{
// User oneadmin needs to be added in the bootstrap
- struct passwd * pw_ent;
- int one_uid = -1;
-
+ int one_uid = -1;
ostringstream oss;
-
- pw_ent = getpwuid(getuid());
-
- if ((pw_ent != NULL) && (pw_ent->pw_name != NULL))
- {
- string one_name;
- string one_pass;
+ string one_token;
+ string one_name;
+ string one_pass;
- const char * one_auth;
+ const char * one_auth;
+ ifstream file;
- one_name = pw_ent->pw_name;
- one_auth = getenv("ONE_AUTH");
+ one_auth = getenv("ONE_AUTH");
- if ( one_auth != 0 )
+ if (!one_auth)
+ {
+ struct passwd * pw_ent;
+
+ pw_ent = getpwuid(getuid());
+
+ if ((pw_ent != NULL) && (pw_ent->pw_dir != NULL))
+ {
+ string one_auth_file = pw_ent->pw_dir;
+
+ one_auth_file += "/.one/one_auth";
+ one_auth = one_auth_file.c_str();
+ }
+ else
{
- if ( User::split_secret(one_auth,one_name,one_pass) == 0 )
+ oss << "Could not get one_auth file location";
+ }
+ }
+
+ file.open(one_auth);
+
+ if (file.good())
+ {
+ getline(file,one_token);
+
+ if (file.fail())
+ {
+ oss << "Error reading file: " << one_auth;
+ }
+ else
+ {
+ if (User::split_secret(one_token,one_name,one_pass) == 0)
{
string sha1_pass = User::sha1_digest(one_pass);
-
allocate(&one_uid, one_name, sha1_pass, true);
}
else
{
- oss << "ONE_AUTH must be :";
+ oss << "Wrong format must be :";
}
}
- else
- {
- oss << "Environment variable ONE_AUTH is not set";
- }
}
else
{
- oss << "Error getting the user info";
+ oss << "Cloud not open file: " << one_auth;
}
+
+ file.close();
if (one_uid != 0)
{
diff --git a/src/vm/History.cc b/src/vm/History.cc
index ac2dc4fabb..7cbf9c6c45 100644
--- a/src/vm/History.cc
+++ b/src/vm/History.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
@@ -445,4 +444,4 @@ string& History::to_xml(string& xml) const
xml = oss.str();
return xml;
-}
\ No newline at end of file
+}
diff --git a/src/vm/SConstruct b/src/vm/SConstruct
index 4704d3a634..db4e58b485 100644
--- a/src/vm/SConstruct
+++ b/src/vm/SConstruct
@@ -1,8 +1,7 @@
# SConstruct for src/vm
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/vm/VirtualMachine.cc b/src/vm/VirtualMachine.cc
index fbb6bc1fce..d486fdb1b0 100644
--- a/src/vm/VirtualMachine.cc
+++ b/src/vm/VirtualMachine.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
@@ -634,6 +633,7 @@ int VirtualMachine::get_network_leases()
string mac;
string bridge;
string network;
+ string model;
ostringstream vnid;
@@ -703,6 +703,13 @@ int VirtualMachine::get_network_leases()
new_nic.insert(make_pair("VNID" ,vnid.str()));
new_nic.insert(make_pair("IP" ,ip));
+ model = nic->vector_value("MODEL");
+
+ if ( !model.empty() )
+ {
+ new_nic.insert(make_pair("MODEL",model));
+ }
+
nic->replace(new_nic);
new_nic.erase(new_nic.begin(),new_nic.end());
@@ -877,7 +884,7 @@ int VirtualMachine::parse_attribute(VirtualMachine * vm,
YY_BUFFER_STATE str_buffer = 0;
const char * str;
int rc;
- ostringstream oss_parsed("DEBUG");
+ ostringstream oss_parsed;
*error_msg = 0;
diff --git a/src/vm/VirtualMachineHook.cc b/src/vm/VirtualMachineHook.cc
index 2c011e0a19..c2665ffd36 100644
--- a/src/vm/VirtualMachineHook.cc
+++ b/src/vm/VirtualMachineHook.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/vm/VirtualMachinePool.cc b/src/vm/VirtualMachinePool.cc
index 37c5dac468..4005d31053 100644
--- a/src/vm/VirtualMachinePool.cc
+++ b/src/vm/VirtualMachinePool.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
@@ -116,6 +115,16 @@ VirtualMachinePool::VirtualMachinePool(SqliteDB * db,
state_hook = true;
}
+ else if ( on == "DONE" )
+ {
+ VirtualMachineStateHook * hook;
+
+ hook = new VirtualMachineStateHook(name, cmd, arg, remote,
+ VirtualMachine::LCM_INIT, VirtualMachine::DONE);
+ add_hook(hook);
+
+ state_hook = true;
+ }
else
{
ostringstream oss;
diff --git a/src/vm/VirtualMachineTemplate.cc b/src/vm/VirtualMachineTemplate.cc
index ed77c94bc7..1c8375a95b 100644
--- a/src/vm/VirtualMachineTemplate.cc
+++ b/src/vm/VirtualMachineTemplate.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/vm/vm_var_parser.c b/src/vm/vm_var_parser.c
index 915b73edf9..6083651844 100644
--- a/src/vm/vm_var_parser.c
+++ b/src/vm/vm_var_parser.c
@@ -28,7 +28,7 @@
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 34
+#define YY_FLEX_SUBMINOR_VERSION 35
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
@@ -211,13 +211,6 @@ extern FILE *vm_var_in, *vm_var_out;
#define unput(c) yyunput( c, (yytext_ptr) )
-/* The following is because we cannot portably get our hands on size_t
- * (without autoconf's help, which isn't available because we want
- * flex-generated scanners to compile on their own).
- * Given that the standard has decreed that size_t exists since 1989,
- * I guess we can afford to depend on it. Manoj.
- */
-
#ifndef YY_TYPEDEF_YY_SIZE_T
#define YY_TYPEDEF_YY_SIZE_T
typedef size_t yy_size_t;
@@ -511,8 +504,7 @@ int vm_var__flex_debug = 0;
char *vm_var_text;
#line 1 "vm_var_parser.l"
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
@@ -526,7 +518,7 @@ char *vm_var_text;
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
-#line 19 "vm_var_parser.l"
+#line 18 "vm_var_parser.l"
#include
#include
#include
@@ -540,7 +532,7 @@ char *vm_var_text;
llocp->first_column = llocp->last_column; \
llocp->last_column += vm_var_leng;
-#line 544 "vm_var_parser.c"
+#line 536 "vm_var_parser.c"
#define INITIAL 0
#define VAR 1
@@ -559,6 +551,35 @@ char *vm_var_text;
static int yy_init_globals (void );
+/* Accessor methods to globals.
+ These are made visible to non-reentrant scanners for convenience. */
+
+int vm_var_lex_destroy (void );
+
+int vm_var_get_debug (void );
+
+void vm_var_set_debug (int debug_flag );
+
+YY_EXTRA_TYPE vm_var_get_extra (void );
+
+void vm_var_set_extra (YY_EXTRA_TYPE user_defined );
+
+FILE *vm_var_get_in (void );
+
+void vm_var_set_in (FILE * in_str );
+
+FILE *vm_var_get_out (void );
+
+void vm_var_set_out (FILE * out_str );
+
+int vm_var_get_leng (void );
+
+char *vm_var_get_text (void );
+
+int vm_var_get_lineno (void );
+
+void vm_var_set_lineno (int line_number );
+
/* Macros after this point can all be overridden by user definitions in
* section 1.
*/
@@ -692,7 +713,7 @@ YY_DECL
register char *yy_cp, *yy_bp;
register int yy_act;
-#line 39 "vm_var_parser.l"
+#line 38 "vm_var_parser.l"
/* ------------------------------------------------------------------------- */
@@ -703,7 +724,7 @@ YY_DECL
/* $NUM.CONTEXT_VARIABLE */
/* ------------------------------------------------------------------------- */
-#line 707 "vm_var_parser.c"
+#line 728 "vm_var_parser.c"
if ( !(yy_init) )
{
@@ -798,65 +819,65 @@ do_action: /* This label is used only to access EOF actions. */
case 1:
YY_RULE_SETUP
-#line 49 "vm_var_parser.l"
+#line 48 "vm_var_parser.l"
{ BEGIN VAR;}
YY_BREAK
case 2:
YY_RULE_SETUP
-#line 51 "vm_var_parser.l"
+#line 50 "vm_var_parser.l"
{ return EQUAL;}
YY_BREAK
case 3:
YY_RULE_SETUP
-#line 52 "vm_var_parser.l"
+#line 51 "vm_var_parser.l"
{ return COMMA;}
YY_BREAK
case 4:
YY_RULE_SETUP
-#line 53 "vm_var_parser.l"
+#line 52 "vm_var_parser.l"
{ return OBRACKET;}
YY_BREAK
case 5:
YY_RULE_SETUP
-#line 54 "vm_var_parser.l"
+#line 53 "vm_var_parser.l"
{ return CBRACKET;}
YY_BREAK
case 6:
YY_RULE_SETUP
-#line 56 "vm_var_parser.l"
+#line 55 "vm_var_parser.l"
{ vm_var_text[vm_var_leng-1] = '\0';
lvalp->val_int = atoi(vm_var_text);
return INTEGER;}
YY_BREAK
case 7:
YY_RULE_SETUP
-#line 59 "vm_var_parser.l"
+#line 58 "vm_var_parser.l"
{ lvalp->val_str = strdup(vm_var_text);
return VARIABLE;}
YY_BREAK
case 8:
/* rule 8 can match eol */
YY_RULE_SETUP
-#line 61 "vm_var_parser.l"
+#line 60 "vm_var_parser.l"
{ lvalp->val_str = strdup(vm_var_text+1);
lvalp->val_str[vm_var_leng-2] = '\0';
return STRING;}
YY_BREAK
case 9:
YY_RULE_SETUP
-#line 65 "vm_var_parser.l"
+#line 64 "vm_var_parser.l"
{ lvalp->val_char = '\0';
return EOA;}
YY_BREAK
case 10:
YY_RULE_SETUP
-#line 67 "vm_var_parser.l"
+#line 66 "vm_var_parser.l"
{ lvalp->val_char = *vm_var_text;
BEGIN(INITIAL);
return EOA;}
YY_BREAK
case YY_STATE_EOF(VAR):
-#line 70 "vm_var_parser.l"
+#line 69 "vm_var_parser.l"
{ lvalp->val_char = '\0';
BEGIN(INITIAL);
return EOA;}
@@ -867,15 +888,15 @@ case YY_STATE_EOF(VAR):
case 11:
/* rule 11 can match eol */
YY_RULE_SETUP
-#line 78 "vm_var_parser.l"
+#line 77 "vm_var_parser.l"
{ lvalp->val_str = strdup(vm_var_text); return RSTRING;}
YY_BREAK
case 12:
YY_RULE_SETUP
-#line 80 "vm_var_parser.l"
+#line 79 "vm_var_parser.l"
ECHO;
YY_BREAK
-#line 879 "vm_var_parser.c"
+#line 900 "vm_var_parser.c"
case YY_STATE_EOF(INITIAL):
yyterminate();
@@ -1844,7 +1865,7 @@ void vm_var_free (void * ptr )
#define YYTABLES_NAME "yytables"
-#line 80 "vm_var_parser.l"
+#line 79 "vm_var_parser.l"
diff --git a/src/vm/vm_var_parser.l b/src/vm/vm_var_parser.l
index 22ab2725e7..829cccf243 100644
--- a/src/vm/vm_var_parser.l
+++ b/src/vm/vm_var_parser.l
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/vm/vm_var_syntax.cc b/src/vm/vm_var_syntax.cc
index 05608c0f45..268b04d309 100644
--- a/src/vm/vm_var_syntax.cc
+++ b/src/vm/vm_var_syntax.cc
@@ -1,24 +1,23 @@
-/* A Bison parser, made by GNU Bison 2.3. */
+
+/* A Bison parser, made by GNU Bison 2.4.1. */
/* Skeleton implementation for Bison's Yacc-like parsers in C
-
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
+
+ This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ along with this program. If not, see . */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
@@ -29,7 +28,7 @@
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
-
+
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
@@ -47,7 +46,7 @@
#define YYBISON 1
/* Bison version. */
-#define YYBISON_VERSION "2.3"
+#define YYBISON_VERSION "2.4.1"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
@@ -55,52 +54,29 @@
/* Pure parsers. */
#define YYPURE 1
+/* Push parsers. */
+#define YYPUSH 0
+
+/* Pull parsers. */
+#define YYPULL 1
+
/* Using locations. */
#define YYLSP_NEEDED 1
/* Substitute the variable and function names. */
-#define yyparse vm_var_parse
-#define yylex vm_var_lex
-#define yyerror vm_var_error
-#define yylval vm_var_lval
-#define yychar vm_var_char
-#define yydebug vm_var_debug
-#define yynerrs vm_var_nerrs
-#define yylloc vm_var_lloc
-
-/* Tokens. */
-#ifndef YYTOKENTYPE
-# define YYTOKENTYPE
- /* Put the tokens into the symbol table, so that GDB and other debuggers
- know about them. */
- enum yytokentype {
- EQUAL = 258,
- COMMA = 259,
- OBRACKET = 260,
- CBRACKET = 261,
- EOA = 262,
- STRING = 263,
- VARIABLE = 264,
- RSTRING = 265,
- INTEGER = 266
- };
-#endif
-/* Tokens. */
-#define EQUAL 258
-#define COMMA 259
-#define OBRACKET 260
-#define CBRACKET 261
-#define EOA 262
-#define STRING 263
-#define VARIABLE 264
-#define RSTRING 265
-#define INTEGER 266
-
-
-
+#define yyparse vm_var_parse
+#define yylex vm_var_lex
+#define yyerror vm_var_error
+#define yylval vm_var_lval
+#define yychar vm_var_char
+#define yydebug vm_var_debug
+#define yynerrs vm_var_nerrs
+#define yylloc vm_var_lloc
/* Copy the first part of user declarations. */
-#line 18 "vm_var_syntax.y"
+
+/* Line 189 of yacc.c */
+#line 17 "vm_var_syntax.y"
#include
#include
@@ -245,6 +221,9 @@ error_name:
+/* Line 189 of yacc.c */
+#line 226 "vm_var_syntax.cc"
+
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
@@ -263,20 +242,46 @@ error_name:
# define YYTOKEN_TABLE 0
#endif
+
+/* Tokens. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum yytokentype {
+ EQUAL = 258,
+ COMMA = 259,
+ OBRACKET = 260,
+ CBRACKET = 261,
+ EOA = 262,
+ STRING = 263,
+ VARIABLE = 264,
+ RSTRING = 265,
+ INTEGER = 266
+ };
+#endif
+
+
+
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
-#line 167 "vm_var_syntax.y"
{
+
+/* Line 214 of yacc.c */
+#line 166 "vm_var_syntax.y"
+
char * val_str;
int val_int;
char val_char;
-}
-/* Line 187 of yacc.c. */
-#line 276 "vm_var_syntax.cc"
- YYSTYPE;
+
+
+
+/* Line 214 of yacc.c */
+#line 281 "vm_var_syntax.cc"
+} YYSTYPE;
+# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
-# define YYSTYPE_IS_TRIVIAL 1
#endif
#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
@@ -296,8 +301,8 @@ typedef struct YYLTYPE
/* Copy the second part of user declarations. */
-/* Line 216 of yacc.c. */
-#line 301 "vm_var_syntax.cc"
+/* Line 264 of yacc.c */
+#line 306 "vm_var_syntax.cc"
#ifdef short
# undef short
@@ -372,14 +377,14 @@ typedef short int yytype_int16;
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static int
-YYID (int i)
+YYID (int yyi)
#else
static int
-YYID (i)
- int i;
+YYID (yyi)
+ int yyi;
#endif
{
- return i;
+ return yyi;
}
#endif
@@ -461,9 +466,9 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */
/* A type that is properly aligned for any stack member. */
union yyalloc
{
- yytype_int16 yyss;
- YYSTYPE yyvs;
- YYLTYPE yyls;
+ yytype_int16 yyss_alloc;
+ YYSTYPE yyvs_alloc;
+ YYLTYPE yyls_alloc;
};
/* The size of the maximum gap between one aligned stack and the next. */
@@ -498,12 +503,12 @@ union yyalloc
elements in the stack, and YYPTR gives the new location of the
stack. Advance YYPTR to a properly aligned location for the next
stack. */
-# define YYSTACK_RELOCATE(Stack) \
+# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
do \
{ \
YYSIZE_T yynewbytes; \
- YYCOPY (&yyptr->Stack, Stack, yysize); \
- Stack = &yyptr->Stack; \
+ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
+ Stack = &yyptr->Stack_alloc; \
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
yyptr += yynewbytes / sizeof (*yyptr); \
} \
@@ -582,9 +587,9 @@ static const yytype_int8 yyrhs[] =
};
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
-static const yytype_uint16 yyrline[] =
+static const yytype_uint8 yyrline[] =
{
- 0, 191, 191, 192, 195, 200, 215, 233, 256
+ 0, 190, 190, 191, 194, 199, 214, 232, 255
};
#endif
@@ -880,17 +885,20 @@ yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, vm, vm_id, parsed, err
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static void
-yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
+yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
#else
static void
-yy_stack_print (bottom, top)
- yytype_int16 *bottom;
- yytype_int16 *top;
+yy_stack_print (yybottom, yytop)
+ yytype_int16 *yybottom;
+ yytype_int16 *yytop;
#endif
{
YYFPRINTF (stderr, "Stack now");
- for (; bottom <= top; ++bottom)
- YYFPRINTF (stderr, " %d", *bottom);
+ for (; yybottom <= yytop; yybottom++)
+ {
+ int yybot = *yybottom;
+ YYFPRINTF (stderr, " %d", yybot);
+ }
YYFPRINTF (stderr, "\n");
}
@@ -929,11 +937,11 @@ yy_reduce_print (yyvsp, yylsp, yyrule, vm, vm_id, parsed, errmsg)
/* The symbols being reduced. */
for (yyi = 0; yyi < yynrhs; yyi++)
{
- fprintf (stderr, " $%d = ", yyi + 1);
+ YYFPRINTF (stderr, " $%d = ", yyi + 1);
yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
&(yyvsp[(yyi + 1) - (yynrhs)])
, &(yylsp[(yyi + 1) - (yynrhs)]) , vm, vm_id, parsed, errmsg);
- fprintf (stderr, "\n");
+ YYFPRINTF (stderr, "\n");
}
}
@@ -1223,10 +1231,8 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp, vm, vm_id, parsed, errmsg)
break;
}
}
-
/* Prevent warnings from -Wmissing-prototypes. */
-
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int yyparse (void *YYPARSE_PARAM);
@@ -1245,10 +1251,9 @@ int yyparse ();
-
-/*----------.
-| yyparse. |
-`----------*/
+/*-------------------------.
+| yyparse or yypush_parse. |
+`-------------------------*/
#ifdef YYPARSE_PARAM
#if (defined __STDC__ || defined __C99__FUNC__ \
@@ -1275,24 +1280,59 @@ yyparse (vm, vm_id, parsed, errmsg)
#endif
#endif
{
- /* The look-ahead symbol. */
+/* The lookahead symbol. */
int yychar;
-/* The semantic value of the look-ahead symbol. */
+/* The semantic value of the lookahead symbol. */
YYSTYPE yylval;
-/* Number of syntax errors so far. */
-int yynerrs;
-/* Location data for the look-ahead symbol. */
+/* Location data for the lookahead symbol. */
YYLTYPE yylloc;
- int yystate;
+ /* Number of syntax errors so far. */
+ int yynerrs;
+
+ int yystate;
+ /* Number of tokens to shift before error messages enabled. */
+ int yyerrstatus;
+
+ /* The stacks and their tools:
+ `yyss': related to states.
+ `yyvs': related to semantic values.
+ `yyls': related to locations.
+
+ Refer to the stacks thru separate pointers, to allow yyoverflow
+ to reallocate them elsewhere. */
+
+ /* The state stack. */
+ yytype_int16 yyssa[YYINITDEPTH];
+ yytype_int16 *yyss;
+ yytype_int16 *yyssp;
+
+ /* The semantic value stack. */
+ YYSTYPE yyvsa[YYINITDEPTH];
+ YYSTYPE *yyvs;
+ YYSTYPE *yyvsp;
+
+ /* The location stack. */
+ YYLTYPE yylsa[YYINITDEPTH];
+ YYLTYPE *yyls;
+ YYLTYPE *yylsp;
+
+ /* The locations where the error started and ended. */
+ YYLTYPE yyerror_range[2];
+
+ YYSIZE_T yystacksize;
+
int yyn;
int yyresult;
- /* Number of tokens to shift before error messages enabled. */
- int yyerrstatus;
- /* Look-ahead token as an internal (translated) token number. */
- int yytoken = 0;
+ /* Lookahead token as an internal (translated) token number. */
+ int yytoken;
+ /* The variables used to return semantic value and location from the
+ action routines. */
+ YYSTYPE yyval;
+ YYLTYPE yyloc;
+
#if YYERROR_VERBOSE
/* Buffer for error messages, and its allocated size. */
char yymsgbuf[128];
@@ -1300,63 +1340,37 @@ YYLTYPE yylloc;
YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
#endif
- /* Three stacks and their tools:
- `yyss': related to states,
- `yyvs': related to semantic values,
- `yyls': related to locations.
-
- Refer to the stacks thru separate pointers, to allow yyoverflow
- to reallocate them elsewhere. */
-
- /* The state stack. */
- yytype_int16 yyssa[YYINITDEPTH];
- yytype_int16 *yyss = yyssa;
- yytype_int16 *yyssp;
-
- /* The semantic value stack. */
- YYSTYPE yyvsa[YYINITDEPTH];
- YYSTYPE *yyvs = yyvsa;
- YYSTYPE *yyvsp;
-
- /* The location stack. */
- YYLTYPE yylsa[YYINITDEPTH];
- YYLTYPE *yyls = yylsa;
- YYLTYPE *yylsp;
- /* The locations where the error started and ended. */
- YYLTYPE yyerror_range[2];
-
#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
- YYSIZE_T yystacksize = YYINITDEPTH;
-
- /* The variables used to return semantic value and location from the
- action routines. */
- YYSTYPE yyval;
- YYLTYPE yyloc;
-
/* The number of symbols on the RHS of the reduced rule.
Keep to zero when no symbol should be popped. */
int yylen = 0;
+ yytoken = 0;
+ yyss = yyssa;
+ yyvs = yyvsa;
+ yyls = yylsa;
+ yystacksize = YYINITDEPTH;
+
YYDPRINTF ((stderr, "Starting parse\n"));
yystate = 0;
yyerrstatus = 0;
yynerrs = 0;
- yychar = YYEMPTY; /* Cause a token to be read. */
+ yychar = YYEMPTY; /* Cause a token to be read. */
/* Initialize stack pointers.
Waste one element of value and location stack
so that they stay on the same level as the state stack.
The wasted elements are never initialized. */
-
yyssp = yyss;
yyvsp = yyvs;
yylsp = yyls;
+
#if YYLTYPE_IS_TRIVIAL
/* Initialize the default location before parsing starts. */
yylloc.first_line = yylloc.last_line = 1;
- yylloc.first_column = yylloc.last_column = 0;
+ yylloc.first_column = yylloc.last_column = 1;
#endif
goto yysetstate;
@@ -1395,6 +1409,7 @@ YYLTYPE yylloc;
&yyvs1, yysize * sizeof (*yyvsp),
&yyls1, yysize * sizeof (*yylsp),
&yystacksize);
+
yyls = yyls1;
yyss = yyss1;
yyvs = yyvs1;
@@ -1416,9 +1431,9 @@ YYLTYPE yylloc;
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
if (! yyptr)
goto yyexhaustedlab;
- YYSTACK_RELOCATE (yyss);
- YYSTACK_RELOCATE (yyvs);
- YYSTACK_RELOCATE (yyls);
+ YYSTACK_RELOCATE (yyss_alloc, yyss);
+ YYSTACK_RELOCATE (yyvs_alloc, yyvs);
+ YYSTACK_RELOCATE (yyls_alloc, yyls);
# undef YYSTACK_RELOCATE
if (yyss1 != yyssa)
YYSTACK_FREE (yyss1);
@@ -1439,6 +1454,9 @@ YYLTYPE yylloc;
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
+ if (yystate == YYFINAL)
+ YYACCEPT;
+
goto yybackup;
/*-----------.
@@ -1447,16 +1465,16 @@ YYLTYPE yylloc;
yybackup:
/* Do appropriate processing given the current state. Read a
- look-ahead token if we need one and don't already have one. */
+ lookahead token if we need one and don't already have one. */
- /* First try to decide what to do without reference to look-ahead token. */
+ /* First try to decide what to do without reference to lookahead token. */
yyn = yypact[yystate];
if (yyn == YYPACT_NINF)
goto yydefault;
- /* Not known => get a look-ahead token if don't already have one. */
+ /* Not known => get a lookahead token if don't already have one. */
- /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
+ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
if (yychar == YYEMPTY)
{
YYDPRINTF ((stderr, "Reading a token: "));
@@ -1488,20 +1506,16 @@ yybackup:
goto yyreduce;
}
- if (yyn == YYFINAL)
- YYACCEPT;
-
/* Count tokens shifted since error; after three, turn off error
status. */
if (yyerrstatus)
yyerrstatus--;
- /* Shift the look-ahead token. */
+ /* Shift the lookahead token. */
YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
- /* Discard the shifted token unless it is eof. */
- if (yychar != YYEOF)
- yychar = YYEMPTY;
+ /* Discard the shifted token. */
+ yychar = YYEMPTY;
yystate = yyn;
*++yyvsp = yylval;
@@ -1542,7 +1556,9 @@ yyreduce:
switch (yyn)
{
case 4:
-#line 196 "vm_var_syntax.y"
+
+/* Line 1455 of yacc.c */
+#line 195 "vm_var_syntax.y"
{
(*parsed) << (yyvsp[(1) - (1)].val_str);
free((yyvsp[(1) - (1)].val_str));
@@ -1550,7 +1566,9 @@ yyreduce:
break;
case 5:
-#line 201 "vm_var_syntax.y"
+
+/* Line 1455 of yacc.c */
+#line 200 "vm_var_syntax.y"
{
string name((yyvsp[(1) - (2)].val_str));
@@ -1568,7 +1586,9 @@ yyreduce:
break;
case 6:
-#line 216 "vm_var_syntax.y"
+
+/* Line 1455 of yacc.c */
+#line 215 "vm_var_syntax.y"
{
string name((yyvsp[(1) - (5)].val_str));
string vname((yyvsp[(3) - (5)].val_str));
@@ -1589,7 +1609,9 @@ yyreduce:
break;
case 7:
-#line 234 "vm_var_syntax.y"
+
+/* Line 1455 of yacc.c */
+#line 233 "vm_var_syntax.y"
{
string name((yyvsp[(1) - (9)].val_str));
string vname((yyvsp[(3) - (9)].val_str));
@@ -1615,7 +1637,9 @@ yyreduce:
break;
case 8:
-#line 257 "vm_var_syntax.y"
+
+/* Line 1455 of yacc.c */
+#line 256 "vm_var_syntax.y"
{
string name("CONTEXT");
string vname((yyvsp[(2) - (3)].val_str));
@@ -1634,8 +1658,9 @@ yyreduce:
break;
-/* Line 1267 of yacc.c. */
-#line 1639 "vm_var_syntax.cc"
+
+/* Line 1455 of yacc.c */
+#line 1664 "vm_var_syntax.cc"
default: break;
}
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -1711,7 +1736,7 @@ yyerrlab:
if (yyerrstatus == 3)
{
- /* If just tried and failed to reuse look-ahead token after an
+ /* If just tried and failed to reuse lookahead token after an
error, discard it. */
if (yychar <= YYEOF)
@@ -1728,7 +1753,7 @@ yyerrlab:
}
}
- /* Else will try to reuse look-ahead token after shifting the error
+ /* Else will try to reuse lookahead token after shifting the error
token. */
goto yyerrlab1;
@@ -1786,14 +1811,11 @@ yyerrlab1:
YY_STACK_PRINT (yyss, yyssp);
}
- if (yyn == YYFINAL)
- YYACCEPT;
-
*++yyvsp = yylval;
yyerror_range[1] = yylloc;
/* Using YYLLOC is tempting, but would change the location of
- the look-ahead. YYLOC is available though. */
+ the lookahead. YYLOC is available though. */
YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
*++yylsp = yyloc;
@@ -1818,7 +1840,7 @@ yyabortlab:
yyresult = 1;
goto yyreturn;
-#ifndef yyoverflow
+#if !defined(yyoverflow) || YYERROR_VERBOSE
/*-------------------------------------------------.
| yyexhaustedlab -- memory exhaustion comes here. |
`-------------------------------------------------*/
@@ -1829,7 +1851,7 @@ yyexhaustedlab:
#endif
yyreturn:
- if (yychar != YYEOF && yychar != YYEMPTY)
+ if (yychar != YYEMPTY)
yydestruct ("Cleanup: discarding lookahead",
yytoken, &yylval, &yylloc, vm, vm_id, parsed, errmsg);
/* Do not reclaim the symbols of the rule which action triggered
@@ -1855,7 +1877,9 @@ yyreturn:
}
-#line 273 "vm_var_syntax.y"
+
+/* Line 1675 of yacc.c */
+#line 272 "vm_var_syntax.y"
extern "C" void vm_var_error(
diff --git a/src/vm/vm_var_syntax.h b/src/vm/vm_var_syntax.h
index d33fb79e0d..5ef69dd31a 100644
--- a/src/vm/vm_var_syntax.h
+++ b/src/vm/vm_var_syntax.h
@@ -1,24 +1,23 @@
-/* A Bison parser, made by GNU Bison 2.3. */
+
+/* A Bison parser, made by GNU Bison 2.4.1. */
/* Skeleton interface for Bison's Yacc-like parsers in C
-
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
+
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify
+
+ This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ along with this program. If not, see . */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
@@ -29,10 +28,11 @@
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
-
+
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
+
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
@@ -50,34 +50,28 @@
INTEGER = 266
};
#endif
-/* Tokens. */
-#define EQUAL 258
-#define COMMA 259
-#define OBRACKET 260
-#define CBRACKET 261
-#define EOA 262
-#define STRING 263
-#define VARIABLE 264
-#define RSTRING 265
-#define INTEGER 266
-
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
-#line 167 "vm_var_syntax.y"
{
+
+/* Line 1676 of yacc.c */
+#line 166 "vm_var_syntax.y"
+
char * val_str;
int val_int;
char val_char;
-}
-/* Line 1489 of yacc.c. */
-#line 77 "vm_var_syntax.hh"
- YYSTYPE;
+
+
+
+/* Line 1676 of yacc.c */
+#line 71 "vm_var_syntax.hh"
+} YYSTYPE;
+# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
-# define YYSTYPE_IS_TRIVIAL 1
#endif
@@ -96,3 +90,4 @@ typedef struct YYLTYPE
#endif
+
diff --git a/src/vm/vm_var_syntax.y b/src/vm/vm_var_syntax.y
index 49da9a261e..4e8449c84b 100644
--- a/src/vm/vm_var_syntax.y
+++ b/src/vm/vm_var_syntax.y
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/vmm/LibVirtDriver.cc b/src/vmm/LibVirtDriver.cc
index 5e5b87cab1..394d218c28 100644
--- a/src/vmm/LibVirtDriver.cc
+++ b/src/vmm/LibVirtDriver.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
@@ -249,7 +248,7 @@ int LibVirtDriver::deployment_description(
num = vm->get_template_attribute("DISK",attrs);
- for (int i=0; i < num ;i++,target="",ro="")
+ for (int i=0; i < num ;i++)
{
disk = dynamic_cast(attrs[i]);
@@ -280,24 +279,24 @@ int LibVirtDriver::deployment_description(
}
}
- if ( type.empty() )
+ if (type.empty() == false)
{
- type = "disk";
+ transform(type.begin(),type.end(),type.begin(),(int(*)(int))toupper);
+ }
+
+ if ( type == "BLOCK" )
+ {
+ file << "\t\t" << endl
+ << "\t\t\t" << endl;
}
else
{
- string type_=type;
- transform(type_.begin(),type_.end(),
- type_.begin(),(int(*)(int))toupper);
- if ( type_ == "SWAP" )
- {
- type="disk";
- }
+ file << "\t\t" << endl
+ << "\t\t\t" << endl;
}
- file << "\t\t" << endl;
- file << "\t\t\t" << endl;
file << "\t\t\t" << endl;
+ file << "\t\t" << endl;
file << "\t\t\t" << endl;
file << "\t\t\t" << endl;
@@ -352,7 +351,7 @@ int LibVirtDriver::deployment_description(
num = vm->get_template_attribute("NIC",attrs);
- for(int i=0; i(attrs[i]);
@@ -362,6 +361,10 @@ int LibVirtDriver::deployment_description(
}
bridge = nic->vector_value("BRIDGE");
+ mac = nic->vector_value("MAC");
+ target = nic->vector_value("TARGET");
+ script = nic->vector_value("SCRIPT");
+ model = nic->vector_value("MODEL");
if ( bridge.empty() )
{
@@ -373,28 +376,20 @@ int LibVirtDriver::deployment_description(
file << "\t\t\t" << endl;
}
- mac = nic->vector_value("MAC");
-
if( !mac.empty() )
{
file << "\t\t\t" << endl;
}
- target = nic->vector_value("TARGET");
-
if( !target.empty() )
{
file << "\t\t\t" << endl;
}
- script = nic->vector_value("SCRIPT");
-
if( !script.empty() )
{
file << "\t\t\t" << endl;
}
-
- model = nic->vector_value("MODEL");
if( !model.empty() )
{
@@ -517,7 +512,7 @@ int LibVirtDriver::deployment_description(
get_default("FEATURES", "ACPI", acpi);
}
- if( acpi=="yes" || pae=="yes" )
+ if( acpi == "yes" || pae == "yes" )
{
file << "\t" << endl;
diff --git a/src/vmm/SConstruct b/src/vmm/SConstruct
index 84c8297d23..ab242c8289 100644
--- a/src/vmm/SConstruct
+++ b/src/vmm/SConstruct
@@ -1,8 +1,7 @@
# SConstruct for src/vmm
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/vmm/VirtualMachineManager.cc b/src/vmm/VirtualMachineManager.cc
index ff0ffb08b3..9da058cb1c 100644
--- a/src/vmm/VirtualMachineManager.cc
+++ b/src/vmm/VirtualMachineManager.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/vmm/VirtualMachineManagerDriver.cc b/src/vmm/VirtualMachineManagerDriver.cc
index 1483a90a36..3d5a27cc77 100644
--- a/src/vmm/VirtualMachineManagerDriver.cc
+++ b/src/vmm/VirtualMachineManagerDriver.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/vmm/XMLDriver.cc b/src/vmm/XMLDriver.cc
index ca24fe83d1..3dba16352e 100644
--- a/src/vmm/XMLDriver.cc
+++ b/src/vmm/XMLDriver.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/vmm/XenDriver.cc b/src/vmm/XenDriver.cc
index 465422bcda..4866bd583e 100644
--- a/src/vmm/XenDriver.cc
+++ b/src/vmm/XenDriver.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
@@ -49,6 +48,7 @@ int XenDriver::deployment_description(
string target = "";
string ro = "";
+ string type = "";
string mode;
const VectorAttribute * nic;
@@ -58,7 +58,6 @@ int XenDriver::deployment_description(
const VectorAttribute * graphics;
- string type = "";
string listen = "";
string port = "";
string passwd = "";
@@ -131,7 +130,7 @@ int XenDriver::deployment_description(
if (!vcpu.empty())
{
- file << "vcpu = '" << vcpu << "'" << endl;
+ file << "vcpus = '" << vcpu << "'" << endl;
}
// ------------------------------------------------------------------------
@@ -219,7 +218,7 @@ int XenDriver::deployment_description(
file << "disk = [" << endl;
- for (int i=0; i < num ;i++,target="",ro="")
+ for (int i=0; i < num ;i++)
{
disk = dynamic_cast(attrs[i]);
@@ -229,6 +228,7 @@ int XenDriver::deployment_description(
}
target = disk->vector_value("TARGET");
+ type = disk->vector_value("TYPE");
ro = disk->vector_value("READONLY");
if ( target.empty() )
@@ -236,6 +236,11 @@ int XenDriver::deployment_description(
goto error_disk;
}
+ if (type.empty() == false)
+ {
+ transform(type.begin(),type.end(),type.begin(),(int(*)(int))toupper);
+ }
+
mode = "w";
if ( !ro.empty() )
@@ -248,10 +253,16 @@ int XenDriver::deployment_description(
}
}
- // TODO: "file" method to specify disk images in xen is deprecated.
- // The new method is using "tap:aio:" instead of "file:"
- file << " "
- << "'tap:aio:" << vm->get_remote_dir() << "/disk." << i << ","
+ if ( type == "BLOCK" )
+ {
+ file << " 'phy:";
+ }
+ else
+ {
+ file << " 'tap:aio:";
+ }
+
+ file << vm->get_remote_dir() << "/disk." << i << ","
<< target << ","
<< mode
<< "'," << endl;
@@ -294,7 +305,7 @@ int XenDriver::deployment_description(
file << "vif = [" << endl;
- for(int i=0; ivector_value("MAC");
-
+ mac = nic->vector_value("MAC");
+ bridge = nic->vector_value("BRIDGE");
+
if( !mac.empty() )
{
file << "mac=" << mac;
pre_char = ',';
}
- bridge = nic->vector_value("BRIDGE");
-
if( !bridge.empty() )
{
file << pre_char << "bridge=" << bridge;
diff --git a/src/vmm_mad/ec2/one_vmm_ec2 b/src/vmm_mad/ec2/one_vmm_ec2
index 96d62307f2..924539a19d 100755
--- a/src/vmm_mad/ec2/one_vmm_ec2
+++ b/src/vmm_mad/ec2/one_vmm_ec2
@@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/vmm_mad/ec2/one_vmm_ec2.rb b/src/vmm_mad/ec2/one_vmm_ec2.rb
index 7b6fca0543..e2b19e05c9 100755
--- a/src/vmm_mad/ec2/one_vmm_ec2.rb
+++ b/src/vmm_mad/ec2/one_vmm_ec2.rb
@@ -1,7 +1,6 @@
#!/usr/bin/env ruby
# ---------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@@ -27,6 +26,8 @@ if !EC2_LOCATION
exit(-1)
end
+EC2_JVM_CONCURRENCY = ENV["EC2_JVM_CONCURRENCY"]
+
ONE_LOCATION = ENV["ONE_LOCATION"]
if !ONE_LOCATION
@@ -65,7 +66,14 @@ class EC2Driver < VirtualMachineDriver
# EC2 constructor, loads defaults for the EC2Driver #
# ------------------------------------------------------------------------ #
def initialize(ec2_conf = nil)
- super(5,true)
+
+ if !EC2_JVM_CONCURRENCY
+ concurrency = 5
+ else
+ concurrency = EC2_JVM_CONCURRENCY.to_i
+ end
+
+ super(concurrency,true)
@defaults = Hash.new
diff --git a/src/vmm_mad/ec2/vmm_ec2rc b/src/vmm_mad/ec2/vmm_ec2rc
index 1cd70de51e..ac8df4bca4 100644
--- a/src/vmm_mad/ec2/vmm_ec2rc
+++ b/src/vmm_mad/ec2/vmm_ec2rc
@@ -1,6 +1,5 @@
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@@ -13,10 +12,24 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
-#--------------------------------------------------------------------------- ##
+#--------------------------------------------------------------------------- #
#May be needed in some setups
#CLASSPATH=""
+
+#----------------------------------------------------------------------------
+# EC2 API TOOLS Configuration.
+#----------------------------------------------------------------------------
#EC2_HOME=""
#EC2_PRIVATE_KEY=""
#EC2_CERT=""
+
+#
+#----------------------------------------------------------------------------
+# Driver configuration
+#----------------------------------------------------------------------------
+# Arguments for the JAVA Virtual Machine
+EC2_JVM_ARGS="-Xms16m -Xmx64m"
+
+# Number of concurrent EC2 operations (not instances)
+EC2_JVM_CONCURRENCY=10
diff --git a/src/vmm_mad/eh/one_vmm_eh b/src/vmm_mad/eh/one_vmm_eh
index fe1b37511a..3bfabb0261 100644
--- a/src/vmm_mad/eh/one_vmm_eh
+++ b/src/vmm_mad/eh/one_vmm_eh
@@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@@ -36,4 +35,4 @@ export_rc_vars $DRIVERRC
cd $VAR_LOCATION
# Execute the actual MAD
-execute_mad $*
\ No newline at end of file
+execute_mad $*
diff --git a/src/vmm_mad/eh/one_vmm_eh.rb b/src/vmm_mad/eh/one_vmm_eh.rb
index d832df47a5..89f0b6038c 100644
--- a/src/vmm_mad/eh/one_vmm_eh.rb
+++ b/src/vmm_mad/eh/one_vmm_eh.rb
@@ -1,7 +1,6 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@@ -176,4 +175,4 @@ class DM < ONEMad
end
dm=DM.new
-dm.loop
\ No newline at end of file
+dm.loop
diff --git a/src/vmm_mad/eh/vmm_eh.conf b/src/vmm_mad/eh/vmm_eh.conf
index 15c1accf9e..22ec225dc7 100644
--- a/src/vmm_mad/eh/vmm_eh.conf
+++ b/src/vmm_mad/eh/vmm_eh.conf
@@ -1 +1 @@
-# Default configuration attributes for the ElasticHost driver
\ No newline at end of file
+# Default configuration attributes for the ElasticHost driver
diff --git a/src/vmm_mad/eh/vmm_ehrc b/src/vmm_mad/eh/vmm_ehrc
index 586ba5f74d..e47129a2db 100644
--- a/src/vmm_mad/eh/vmm_ehrc
+++ b/src/vmm_mad/eh/vmm_ehrc
@@ -1,6 +1,5 @@
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@@ -23,4 +22,4 @@
# MUST be in the PATH
#
-EHAUTH=":"
\ No newline at end of file
+EHAUTH=":"
diff --git a/src/vmm_mad/kvm/one_vmm_kvm b/src/vmm_mad/kvm/one_vmm_kvm
index cac9450ea3..df79f32b6f 100755
--- a/src/vmm_mad/kvm/one_vmm_kvm
+++ b/src/vmm_mad/kvm/one_vmm_kvm
@@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/vmm_mad/kvm/one_vmm_kvm.rb b/src/vmm_mad/kvm/one_vmm_kvm.rb
index 2af9c301e7..8fd8815fd7 100755
--- a/src/vmm_mad/kvm/one_vmm_kvm.rb
+++ b/src/vmm_mad/kvm/one_vmm_kvm.rb
@@ -1,7 +1,6 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@@ -30,6 +29,12 @@ else
ETC_LOCATION = ONE_LOCATION + "/etc/"
end
+if ENV["LIBVIRT_DEFAULT_URI"]
+ LIBVIRT_URI = ENV["LIBVIRT_DEFAULT_URI"]
+else
+ LIBVIRT_URI = "qemu:///system"
+end
+
$: << RUBY_LIB_LOCATION
require 'pp'
@@ -46,13 +51,13 @@ class LibVirtDriver < VirtualMachineDriver
QEMU_PROTOCOL = "qemu+ssh"
LIBVIRT = {
- :create => "virsh create",
- :shutdown => "virsh shutdown",
- :cancel => "virsh destroy",
- :save => "virsh save",
- :restore => "virsh restore",
- :migrate => "virsh migrate --live",
- :poll => "virsh dominfo"
+ :create => "virsh --connect #{LIBVIRT_URI} create",
+ :shutdown => "virsh --connect #{LIBVIRT_URI} shutdown",
+ :cancel => "virsh --connect #{LIBVIRT_URI} destroy",
+ :save => "virsh --connect #{LIBVIRT_URI} save",
+ :restore => "virsh --connect #{LIBVIRT_URI} restore",
+ :migrate => "virsh --connect #{LIBVIRT_URI} migrate --live",
+ :poll => "virsh --connect #{LIBVIRT_URI} dominfo"
}
# ------------------------------------------------------------------------ #
@@ -79,7 +84,9 @@ class LibVirtDriver < VirtualMachineDriver
domain = tmp.read
tmp.close()
- cmd = "cat > #{remote_dfile} && #{LIBVIRT[:create]} #{remote_dfile}"
+ images_path = File.dirname remote_dfile
+ cmd = "mkdir -p #{images_path} && cat > #{remote_dfile} && " \
+ "#{LIBVIRT[:create]} #{remote_dfile}"
deploy_exe = SSHCommand.run("'#{cmd}'", host, log_method(id), domain)
@@ -115,7 +122,7 @@ class LibVirtDriver < VirtualMachineDriver
end
def save(id, host, deploy_id, file)
- ssh_action("#{LIBVIRT[:save]} #{deploy_id} #{file}", id, host, :save)
+ ssh_action("'touch #{file};#{LIBVIRT[:save]} #{deploy_id} #{file}'",id,host,:save)
end
def restore(id, host, deploy_id, file)
@@ -124,7 +131,7 @@ class LibVirtDriver < VirtualMachineDriver
def migrate(id, host, deploy_id, dest_host)
cmd = "#{LIBVIRT[:migrate]} #{deploy_id} "\
- "#{QEMU_PROTOCOL}://#{dest_host}/session"
+ "#{QEMU_PROTOCOL}://#{dest_host}/system"
ssh_action(cmd, id, host, :migrate)
end
diff --git a/src/vmm_mad/kvm/vmm_kvmrc b/src/vmm_mad/kvm/vmm_kvmrc
index e9238feca4..5f10e4cabe 100644
--- a/src/vmm_mad/kvm/vmm_kvmrc
+++ b/src/vmm_mad/kvm/vmm_kvmrc
@@ -1,6 +1,5 @@
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@@ -14,4 +13,5 @@
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
+LIBVIRT_DEFAULT_URI="qemu:///system"
diff --git a/src/vmm_mad/vmware/DeployVM.java b/src/vmm_mad/vmware/DeployVM.java
index 983f85c6c8..3b7135d9e6 100644
--- a/src/vmm_mad/vmware/DeployVM.java
+++ b/src/vmm_mad/vmware/DeployVM.java
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
@@ -252,7 +251,13 @@ public class DeployVM
void configureNetwork()
{
String[][] nics = pXML.getNet();
- int nics_toRemove_counter = 0;
+ int nics_toRemove_counter = 0;
+
+ if(nics==null)
+ {
+ return;
+ }
+
if(nics.length==1 && nics[0].equals(""))
{
return;
diff --git a/src/vmm_mad/vmware/OneVmmVmware.java b/src/vmm_mad/vmware/OneVmmVmware.java
index af1a9784aa..423a944096 100644
--- a/src/vmm_mad/vmware/OneVmmVmware.java
+++ b/src/vmm_mad/vmware/OneVmmVmware.java
@@ -1,28 +1,33 @@
-/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
-/* */
-/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
-/* not use this file except in compliance with the License. You may obtain */
-/* a copy of the License at */
-/* */
-/* http://www.apache.org/licenses/LICENSE-2.0 */
-/* */
-/* Unless required by applicable law or agreed to in writing, software */
-/* distributed under the License is distributed on an "AS IS" BASIS, */
-/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
-/* See the License for the specific language governing permissions and */
-/* limitations under the License. */
-/* -------------------------------------------------------------------------- */
-
-
+/*
+# -------------------------------------------------------------------------#
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
+# #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may #
+# not use this file except in compliance with the License. You may obtain #
+# a copy of the License at #
+# #
+# http://www.apache.org/licenses/LICENSE-2.0 #
+# #
+# Unless required by applicable law or agreed to in writing, software #
+# distributed under the License is distributed on an "AS IS" BASIS, #
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
+# See the License for the specific language governing permissions and #
+# limitations under the License. #
+#--------------------------------------------------------------------------#
+*/
import java.io.*;
+import java.util.*;
+import java.text.*;
import com.vmware.vim.*;
import com.vmware.apputils.*;
import com.vmware.apputils.vim.*;
+/************************************
+ * Manages VMware VMs *
+ * through the VI API *
+ ************************************/
class OneVmmVmware extends Thread
{
private String[] arguments;
@@ -30,18 +35,14 @@ class OneVmmVmware extends Thread
DeployVM dVM;
boolean debug;
+
+ PrintStream stdout;
+ PrintStream stderr;
public static void main(String[] args)
{
boolean debug_flag;
-
- // first, make redirection
- PrintStream stdout = System.out;
- PrintStream stderr = System.err;
-
- System.setOut(stderr);
- System.setErr(stdout);
-
+
if (System.getProperty("debug").equals("1"))
{
debug_flag=true;
@@ -60,9 +61,18 @@ class OneVmmVmware extends Thread
{
debug = _debug;
arguments = args;
+
+ // Get out and err descriptors
+ stdout = System.out;
+ stderr = System.err;
+
+ // No VMware library output to standard out
+ // or err. This will be activated when needed
+ disable_standard_output();
+ disable_standard_error();
}
- // Main loop, threaded
+ // Main loop
void loop()
{
String str = null;
@@ -70,11 +80,11 @@ class OneVmmVmware extends Thread
String vid_str = null;
String hostName;
String fileName;
- boolean fin = false;
+ boolean end = false;
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
- while (!fin)
+ while (!end)
{
action = null;
vid_str = null;
@@ -90,10 +100,9 @@ class OneVmmVmware extends Thread
{
String message = e.getMessage().replace('\n', ' ');
- synchronized (System.err)
- {
- System.err.println(action + " FAILURE " + vid_str + " " + message);
- }
+ send_message(action + " FAILURE " + vid_str + " " + message);
+ send_error (action + " FAILURE " + vid_str +
+ " Action malformed. Reason: " + message);
}
String str_split[] = str.split(" ", 5);
@@ -108,7 +117,7 @@ class OneVmmVmware extends Thread
else if (action.equals("FINALIZE"))
{
finalize_mad();
- fin = true;
+ end = true;
}
else
{
@@ -116,13 +125,10 @@ class OneVmmVmware extends Thread
{
if (str_split.length != 5)
{
- System.out.println("FAILURE Wrong number of arguments for DEPLOY action. Number args = [" +
+ send_message(action + " FAILURE " + vid_str);
+ send_error("FAILURE Wrong number of arguments for DEPLOY action. Number args = [" +
str_split.length + "].");
- synchronized (System.err)
- {
- System.err.println(action + " FAILURE " + vid_str);
- continue;
- }
+ continue;
}
else
{
@@ -186,11 +192,9 @@ class OneVmmVmware extends Thread
catch(Exception e)
{
oVM.disconnect();
- synchronized (System.err)
- {
- System.err.println(action + " FAILURE " + vid_str + " Failed connection to host " +
- hostName +". Reason: " + e.getMessage());
- }
+ send_message(action + " FAILURE " + vid_str + " " + e.getMessage());
+ if (!debug)
+ send_error (action + " FAILURE " + vid_str + " " + e.getMessage());
continue;
}
@@ -209,11 +213,7 @@ class OneVmmVmware extends Thread
throw new Exception("Error powering on VM(" + pXML.getName() + ").");
}
- synchronized (System.err)
- {
- System.err.println("DEPLOY SUCCESS " + vid_str + " " + pXML.getName() + "-" + vid_str);
- }
-
+ send_message("DEPLOY SUCCESS " + vid_str + " " + pXML.getName() + "-" + vid_str);
oVM.disconnect();
continue;
@@ -221,17 +221,23 @@ class OneVmmVmware extends Thread
}
catch(Exception e)
{
- System.out.println("Failed deploying VM " + vid_str + " into " + hostName +
- ".Reason:" + e.getMessage());
+ send_message("DEPLOY FAILURE " + vid_str + " Failed deploying VM in host " +
+ hostName + ".");
+
if(debug)
{
- e.printStackTrace();
+ send_error("Failed deploying VM " + vid_str + " into " + hostName +
+ ".Reason: "+ e.getMessage() +
+ "\n---- Debug stack trace ----");
+ enable_standard_error();
+ e.printStackTrace();
+ disable_standard_error();
+ send_error("---------------------------");
}
-
- synchronized (System.err)
- {
- System.err.println("DEPLOY FAILURE " + vid_str + " Failed deploying VM in host " +
- hostName + ".");
+ else
+ { // If debug activated, this will be replicated in send_message
+ send_error("Failed deploying VM " + vid_str + " into " + hostName +
+ ".Reason:" + e.getMessage());
}
} // catch
} // else if (str_split.length != 4)
@@ -241,15 +247,10 @@ class OneVmmVmware extends Thread
{
if (str_split.length < 3 )
{
- System.out.println("FAILURE Wrong number of arguments for " + action +
+ send_message(action + " FAILURE " + vid_str);
+ send_error("FAILURE Wrong number of arguments for " + action +
" action. Number args = [" +
str_split.length + "].");
-
- synchronized (System.err)
- {
- System.err.println(action + " FAILURE " + vid_str);
- continue;
- }
}
else
{
@@ -268,42 +269,31 @@ class OneVmmVmware extends Thread
}
catch(Exception e)
{
- synchronized (System.err)
- {
- System.err.println(action + " FAILURE " + vid_str + " Failed connection to host " +
- hostName +". Reason: " + e.getMessage());
- }
+ send_message(action + " FAILURE " + vid_str + " " + e.getMessage());
+ if(!debug)
+ send_error(action + " FAILURE " + vid_str + " " + e.getMessage());
oVM.disconnect();
continue;
}
if(!oVM.powerOff(vmName))
{
- synchronized (System.err)
- {
- System.err.println(action + " FAILURE " + vid_str + " Failed shutdown VM in host " +
+ send_message(action + " FAILURE " + vid_str + " Failed shutdown VM in host " +
hostName);
- }
oVM.disconnect();
continue;
}
if(!oVM.deregisterVM(vmName))
{
- synchronized (System.err)
- {
- System.err.println(action + " FAILURE " + vid_str + " Failed deregistering of " +vmName
+ send_message(action + " FAILURE " + vid_str + " Failed deregistering of " +vmName
+ " in host " + hostName +".");
- }
oVM.disconnect();
continue;
}
else
{
- synchronized (System.err)
- {
- System.err.println(action + " SUCCESS " + vid_str);
- }
+ send_message(action + " SUCCESS " + vid_str);
}
}
oVM.disconnect();
@@ -314,14 +304,10 @@ class OneVmmVmware extends Thread
{
if (str_split.length < 5)
{
- System.out.println("FAILURE Wrong number of arguments for SAVE action. Number args = [" +
+ send_message(action + " FAILURE " + vid_str);
+ send_error("FAILURE Wrong number of arguments for SAVE action. Number args = [" +
str_split.length + "].");
-
- synchronized (System.err)
- {
- System.err.println(action + " FAILURE " + vid_str);
- continue;
- }
+ continue;
}
else
{
@@ -340,42 +326,31 @@ class OneVmmVmware extends Thread
}
catch(Exception e)
{
- synchronized (System.err)
- {
- System.err.println(action + " FAILURE " + vid_str + " Failed connection to host " +
- hostName +". Reason: " + e.getMessage());
- }
+ send_message(action + " FAILURE " + vid_str + " " + e.getMessage());
+ if(!debug)
+ send_error(action + " FAILURE " + vid_str + " " + e.getMessage());
oVM.disconnect();
continue;
}
if(!oVM.save(vmName))
{
- synchronized (System.err)
- {
- System.err.println(action + " FAILURE " + vid_str + " Failed suspending VM in host " +
+ send_message(action + " FAILURE " + vid_str + " Failed suspending VM in host " +
hostName);
- }
oVM.disconnect();
continue;
}
if(!oVM.deregisterVM(vmName))
{
- synchronized (System.err)
- {
- System.err.println(action + " FAILURE " + vid_str + " Failed deregistering of " +vmName
+ send_message(action + " FAILURE " + vid_str + " Failed deregistering of " +vmName
+ " in host " + hostName +".");
- }
oVM.disconnect();
continue;
}
else
{
- synchronized (System.err)
- {
- System.err.println(action + " SUCCESS " + vid_str);
- }
+ send_message(action + " SUCCESS " + vid_str);
}
oVM.disconnect();
continue;
@@ -386,13 +361,10 @@ class OneVmmVmware extends Thread
{
if (str_split.length < 4)
{
- System.out.println("FAILURE Wrong number of arguments for CHECKPOINT action. Number args = [" +
+ send_message(action + " FAILURE " + vid_str);
+ send_error("FAILURE Wrong number of arguments for CHECKPOINT action. Number args = [" +
str_split.length + "].");
- synchronized (System.err)
- {
- System.err.println(action + " FAILURE " + vid_str);
- continue;
- }
+ continue;
}
else
{
@@ -411,31 +383,21 @@ class OneVmmVmware extends Thread
}
catch(Exception e)
{
- synchronized (System.err)
- {
- System.err.println(action + " FAILURE " + vid_str + " Failed connection to host " +
- hostName +". Reason: " + e.getMessage());
- }
+ send_message(action + " FAILURE " + vid_str + " " + e.getMessage());
oVM.disconnect();
continue;
}
if(!oVM.createCheckpoint(vmName))
{
- synchronized (System.err)
- {
- System.err.println(action + " FAILURE " + vid_str + " Failed suspending VM in host " +
+ send_message(action + " FAILURE " + vid_str + " Failed suspending VM in host " +
hostName);
- }
oVM.disconnect();
continue;
}
else
{
- synchronized (System.err)
- {
- System.err.println(action + " SUCCESS " + vid_str);
- }
+ send_message(action + " SUCCESS " + vid_str);
}
oVM.disconnect();
continue;
@@ -446,13 +408,10 @@ class OneVmmVmware extends Thread
{
if (str_split.length < 4)
{
- System.out.println("FAILURE Wrong number of arguments for RESTORE " +
+ send_message(action + " FAILURE " + vid_str);
+ send_error("FAILURE Wrong number of arguments for RESTORE " +
"action. Number args = [" + str_split.length + "].");
- synchronized (System.err)
- {
- System.err.println(action + " FAILURE " + vid_str);
- continue;
- }
+ continue;
}
else
{
@@ -487,11 +446,9 @@ class OneVmmVmware extends Thread
}
catch(Exception e)
{
- synchronized (System.err)
- {
- System.err.println(action + " FAILURE " + vid_str + " Failed connection to host " +
- hostName +". Reason: " + e.getMessage());
- }
+ send_message(action + " FAILURE " + vid_str + " " + e.getMessage());
+ if(!debug)
+ send_error(action + " FAILURE " + vid_str + " " + e.getMessage());
oVM.disconnect();
dVM.disconnect();
continue;
@@ -499,11 +456,8 @@ class OneVmmVmware extends Thread
if(!oVM.restoreCheckpoint(vmName))
{
- synchronized (System.err)
- {
- System.err.println(action + " FAILURE " + vid_str + " Failed restoring VM in host " +
+ send_message(action + " FAILURE " + vid_str + " Failed restoring VM in host " +
hostName);
- }
oVM.disconnect();
dVM.disconnect();
continue;
@@ -514,15 +468,12 @@ class OneVmmVmware extends Thread
{
if(!oVM.powerOn(vmName))
{
- System.err.println(action + " FAILURE " + vid_str + " Failed restoring VM in host " +
+ send_message(action + " FAILURE " + vid_str + " Failed restoring VM in host " +
hostName);
}
else
{
- synchronized (System.err)
- {
- System.err.println(action + " SUCCESS " + vid_str);
- }
+ send_message(action + " SUCCESS " + vid_str);
oVM.disconnect();
dVM.disconnect();
continue;
@@ -530,11 +481,8 @@ class OneVmmVmware extends Thread
}
catch(Exception e)
{
- synchronized (System.err)
- {
- System.err.println(action + " FAILURE " + vid_str + " Failed connection to host " +
+ send_message(action + " FAILURE " + vid_str + " Failed connection to host " +
hostName +". Reason: " + e.getMessage());
- }
oVM.disconnect();
dVM.disconnect();
continue;
@@ -549,24 +497,20 @@ class OneVmmVmware extends Thread
if (action.equals("MIGRATE"))
{
- synchronized (System.err)
- {
- System.err.println(action + " FAILURE " + vid_str + " Action not implemented.");
- continue;
- }
+ send_message(action + " FAILURE " + vid_str + " Action not implemented.");
+ if(!debug)
+ send_error(action + " FAILURE " + vid_str + " Action not implemented.");
+ continue;
} // if (action.equals("MIGRATE"))
if (action.equals("POLL"))
{
if (str_split.length < 4)
{
- System.out.println("FAILURE Wrong number of arguments for POLL " +
- "action. Number args = [" + str_split.length + "].");
- synchronized (System.err)
- {
- System.err.println(action + " FAILURE " + vid_str);
- continue;
- }
+ send_message(action + " FAILURE " + vid_str);
+ send_error("FAILURE Wrong number of arguments for POLL " +
+ "action. Number args = [" + str_split.length + "].");
+ continue;
}
else
{
@@ -605,20 +549,38 @@ class OneVmmVmware extends Thread
{
throw new Exception();
}
-
- String vmCPUMhz =
- gPVM.getObjectProperty("summary.quickStats.overallCpuUsage").toString();
- String vmMEMMb =
- gPVM.getObjectProperty("summary.quickStats.guestMemoryUsage").toString();
+ String powerState =
+ gPVM.getObjectProperty("runtime.powerState").toString();
+
+ if (powerState.equals("poweredOn"))
+ {
- gPVM.disconnect();
-
- int hostCPUMhz_i = Integer.parseInt(hostCPUMhz);
- int vmCPUMhz_i = Integer.parseInt(vmCPUMhz);
- int vmCPUperc = (vmCPUMhz_i / hostCPUMhz_i) * 100;
+ String vmCPUMhz =
+ gPVM.getObjectProperty("summary.quickStats.overallCpuUsage").toString();
- pollInfo = "STATE=a USEDMEMORY=" + vmMEMMb + " USEDCPU=" + vmCPUperc;
+ String vmMEMMb =
+ gPVM.getObjectProperty("summary.quickStats.guestMemoryUsage").toString();
+
+ gPVM.disconnect();
+
+ int hostCPUMhz_i = Integer.parseInt(hostCPUMhz);
+ int vmCPUMhz_i = Integer.parseInt(vmCPUMhz);
+ int vmCPUperc = (vmCPUMhz_i / hostCPUMhz_i) * 100;
+
+ pollInfo = "STATE=a USEDMEMORY=" + vmMEMMb + " USEDCPU=" + vmCPUperc;
+ }
+ else
+ {
+ if (powerState.equals("suspended"))
+ {
+ pollInfo = "STATE=p";
+ }
+ else // Machine poweredOff
+ {
+ pollInfo = "STATE=d";
+ }
+ }
}
catch(Exception e)
@@ -626,11 +588,7 @@ class OneVmmVmware extends Thread
pollInfo = "STATE=-";
}
- synchronized (System.err)
- {
- System.err.println(action + " SUCCESS " + vid_str + " " + pollInfo);
- }
-
+ send_message(action + " SUCCESS " + vid_str + " " + pollInfo);
continue;
}
} // if (action.equals("POLL"))
@@ -641,18 +599,68 @@ class OneVmmVmware extends Thread
void init()
{
// Nothing to do here
- synchronized(System.err)
- {
- System.err.println("INIT SUCCESS");
- }
+ send_message("INIT SUCCESS");
}
void finalize_mad()
{
- // Nothing to do here
- synchronized(System.err)
- {
- System.err.println("FINALIZE SUCCESS");
+ send_message("FINALIZE SUCCESS");
+ }
+
+ void enable_standard_output()
+ {
+ System.setOut(stdout);
+ }
+
+ void enable_standard_error()
+ {
+ System.setErr(stderr);
+ }
+
+
+ void disable_standard_output()
+ {
+ try
+ {
+ System.setOut(new PrintStream(new FileOutputStream("/dev/null")));
+ }
+ catch(Exception e)
+ {}
+ }
+
+ void disable_standard_error()
+ {
+ try
+ {
+ System.setErr(new PrintStream(new FileOutputStream("/dev/null")));
+ }
+ catch(Exception e)
+ {}
+ }
+
+
+ void send_message(String str)
+ {
+ synchronized (System.out)
+ {
+ enable_standard_output();
+ System.out.println(str);
+ disable_standard_output();
+ }
+
+ if(debug){ send_error(str);}
+ }
+
+ void send_error(String str)
+ {
+ Date date = new Date();
+ Format formatter;
+ formatter = new SimpleDateFormat("[dd.MM.yyyy HH:mm:ss] ");
+ synchronized (System.err)
+ {
+ enable_standard_error();
+ System.err.println(formatter.format(date)+str);
+ disable_standard_error();
}
}
}
diff --git a/src/vmm_mad/vmware/OperationsOverVM.java b/src/vmm_mad/vmware/OperationsOverVM.java
index e322782949..1cc59ca41a 100644
--- a/src/vmm_mad/vmware/OperationsOverVM.java
+++ b/src/vmm_mad/vmware/OperationsOverVM.java
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/vmm_mad/vmware/Readme b/src/vmm_mad/vmware/Readme
index 6029ec8a33..23c14581cc 100644
--- a/src/vmm_mad/vmware/Readme
+++ b/src/vmm_mad/vmware/Readme
@@ -45,4 +45,4 @@ $ onehost add im_vmware vmm_vmware tm_dummy
[1] http://www.vmware.com/support/developer/vc-sdk/
[2] http://www.vmware.com/support/developer/vc-sdk/visdk25pubs/visdk25setupguide.pdf
-[3] http://ws.apache.org/axis/
\ No newline at end of file
+[3] http://ws.apache.org/axis/
diff --git a/src/vmm_mad/vmware/install-vmware.sh b/src/vmm_mad/vmware/install-vmware.sh
index 40df4b30db..efc8011dd2 100755
--- a/src/vmm_mad/vmware/install-vmware.sh
+++ b/src/vmm_mad/vmware/install-vmware.sh
@@ -11,7 +11,7 @@ if [ ! -f GetProperty.java ]; then
ln -s ../../im_mad/vmware/GetProperty.java GetProperty.java
fi
-javac OneVmmVmware.java
+javac *.java
cp *class $ONE_LOCATION/lib/mads
cp one_vmm_vmware $ONE_LOCATION/lib/mads
chmod +x $ONE_LOCATION/lib/mads/one_vmm_vmware
@@ -19,7 +19,7 @@ chmod +x $ONE_LOCATION/lib/mads/one_vmm_vmware
echo -n "."
cd ../../im_mad/vmware/
-javac OneImVmware.java
+javac *.java
cp *class $ONE_LOCATION/lib/mads
cp one_im_vmware $ONE_LOCATION/lib/mads
chmod +x $ONE_LOCATION/lib/mads/one_im_vmware
diff --git a/src/vmm_mad/vmware/one_vmm_vmware b/src/vmm_mad/vmware/one_vmm_vmware
index f8acd18f99..0193f21dee 100755
--- a/src/vmm_mad/vmware/one_vmm_vmware
+++ b/src/vmm_mad/vmware/one_vmm_vmware
@@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/vmm_mad/vmware/vmm_vmwarerc b/src/vmm_mad/vmware/vmm_vmwarerc
index 35f2531f4f..99efd415cc 100644
--- a/src/vmm_mad/vmware/vmm_vmwarerc
+++ b/src/vmm_mad/vmware/vmm_vmwarerc
@@ -1,6 +1,5 @@
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@@ -20,7 +19,7 @@
#VMWARE_TRUSTORE=
# Uncomment the following line to active MAD debug
-ONE_MAD_DEBUG=1
+#ONE_MAD_DEBUG=1
# Datastore name
VMWARE_DATASTORE=datastore1
diff --git a/src/vmm_mad/xen/one_vmm_xen b/src/vmm_mad/xen/one_vmm_xen
index 5930c7a1ec..7a47c040b6 100755
--- a/src/vmm_mad/xen/one_vmm_xen
+++ b/src/vmm_mad/xen/one_vmm_xen
@@ -1,8 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/vmm_mad/xen/one_vmm_xen.rb b/src/vmm_mad/xen/one_vmm_xen.rb
index 8f33b57257..0a0a81aea7 100755
--- a/src/vmm_mad/xen/one_vmm_xen.rb
+++ b/src/vmm_mad/xen/one_vmm_xen.rb
@@ -1,7 +1,6 @@
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@@ -53,7 +52,8 @@ class XenDriver < VirtualMachineDriver
:restore => "sudo #{XM_PATH} restore",
:migrate => "sudo #{XM_PATH} migrate -l",
:poll => "sudo #{XENTOP_PATH} -bi2",
- :credits => "sudo #{XM_PATH} sched-cred"
+ :credits => "sudo #{XM_PATH} sched-cred",
+ :list => "sudo #{XM_PATH} list"
}
XEN_INFO = {
@@ -127,7 +127,7 @@ class XenDriver < VirtualMachineDriver
def shutdown(id, host, deploy_id, not_used)
cmd=<<-EOS
function gdm {
- sudo xm list | grep '#{deploy_id}\\>'
+ #{XEN[:list]} | grep '#{deploy_id}\\>'
}
#{XEN[:shutdown]} #{deploy_id} || exit -1
@@ -181,7 +181,7 @@ EOS
exe = SSHCommand.run("#{XEN[:poll]} #{deploy_id}", host, log_method(id))
if exe.code != 0
- send_message(ACTION[:poll], RESULT[:failure], id, info)
+ send_message(ACTION[:poll], RESULT[:failure], id, "-")
return
end
diff --git a/src/vmm_mad/xen/vmm_xenrc b/src/vmm_mad/xen/vmm_xenrc
index 07b6e445b1..258c5f9339 100644
--- a/src/vmm_mad/xen/vmm_xenrc
+++ b/src/vmm_mad/xen/vmm_xenrc
@@ -1,6 +1,5 @@
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
@@ -21,4 +20,4 @@
XENTOP_PATH="/usr/sbin/xentop"
-XM_PATH="/usr/sbin/xm"
\ No newline at end of file
+XM_PATH="/usr/sbin/xm"
diff --git a/src/vnm/FixedLeases.cc b/src/vnm/FixedLeases.cc
index 3efb49905d..ab3574f1b6 100644
--- a/src/vnm/FixedLeases.cc
+++ b/src/vnm/FixedLeases.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/vnm/Leases.cc b/src/vnm/Leases.cc
index 566a742cef..a74c1e0025 100644
--- a/src/vnm/Leases.cc
+++ b/src/vnm/Leases.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/vnm/RangedLeases.cc b/src/vnm/RangedLeases.cc
index 4c1a8b439b..ac19d3fe99 100644
--- a/src/vnm/RangedLeases.cc
+++ b/src/vnm/RangedLeases.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/vnm/SConstruct b/src/vnm/SConstruct
index 841e8338be..dcedec0419 100644
--- a/src/vnm/SConstruct
+++ b/src/vnm/SConstruct
@@ -1,8 +1,7 @@
# SConstruct for src/vnm
# -------------------------------------------------------------------------- #
-# Copyright 2002-2009, Distributed Systems Architecture Group, Universidad #
-# Complutense de Madrid (dsa-research.org) #
+# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
diff --git a/src/vnm/VirtualNetwork.cc b/src/vnm/VirtualNetwork.cc
index cabdd9eb50..5c38882290 100644
--- a/src/vnm/VirtualNetwork.cc
+++ b/src/vnm/VirtualNetwork.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/vnm/VirtualNetworkPool.cc b/src/vnm/VirtualNetworkPool.cc
index da177811ad..f7178386cf 100644
--- a/src/vnm/VirtualNetworkPool.cc
+++ b/src/vnm/VirtualNetworkPool.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
diff --git a/src/vnm/VirtualNetworkTemplate.cc b/src/vnm/VirtualNetworkTemplate.cc
index d07f3c5377..63622f9995 100644
--- a/src/vnm/VirtualNetworkTemplate.cc
+++ b/src/vnm/VirtualNetworkTemplate.cc
@@ -1,6 +1,5 @@
/* -------------------------------------------------------------------------- */
-/* Copyright 2002-2009, Distributed Systems Architecture Group, Universidad */
-/* Complutense de Madrid (dsa-research.org) */
+/* Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */