diff --git a/include/VirtualRouter.h b/include/VirtualRouter.h index 53146e29df..d9b613bdd9 100644 --- a/include/VirtualRouter.h +++ b/include/VirtualRouter.h @@ -19,6 +19,7 @@ #include "PoolObjectSQL.h" #include "Template.h" +#include "ObjectCollection.h" /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ @@ -37,14 +38,9 @@ public: */ string& to_xml(string& xml) const; - int get_vmid() + int add_vmid(int vmid) { - return vmid; - } - - void set_vmid(int vmid) - { - this->vmid = vmid; + return vms.add_collection_id(vmid); } // ------------------------------------------------------------------------ @@ -81,7 +77,7 @@ private: // Attributes // ************************************************************************* - int vmid; + ObjectCollection vms; // ************************************************************************* // DataBase implementation (Private) diff --git a/src/cli/etc/onevrouter.yaml b/src/cli/etc/onevrouter.yaml index 92404405d5..4ccb9028dc 100644 --- a/src/cli/etc/onevrouter.yaml +++ b/src/cli/etc/onevrouter.yaml @@ -3,10 +3,6 @@ :desc: ONE identifier for the Virtual Router :size: 4 -:VMID: - :desc: VM associated with the Virtual Router - :size: 4 - :NAME: :desc: Name of the Virtual Router :size: 27 @@ -24,7 +20,6 @@ :default: - :ID -- :VMID - :USER - :GROUP - :NAME diff --git a/src/cli/one_helper/onevrouter_helper.rb b/src/cli/one_helper/onevrouter_helper.rb index a2fbaf3804..098b3e80ed 100644 --- a/src/cli/one_helper/onevrouter_helper.rb +++ b/src/cli/one_helper/onevrouter_helper.rb @@ -52,10 +52,6 @@ class OneVirtualRouterHelper < OpenNebulaHelper::OneHelper d["ID"] end - column :VMID, "VM associated with the Virtual Router", :size=>4 do |d| - d["VMID"] - end - column :NAME, "Name of the Virtual Router", :left, :size=>27 do |d| d["NAME"] end @@ -69,7 +65,7 @@ class OneVirtualRouterHelper < OpenNebulaHelper::OneHelper helper.group_name(d, options) end - default :ID, :VMID, :USER, :GROUP, :NAME + default :ID, :USER, :GROUP, :NAME end table @@ -98,7 +94,6 @@ class OneVirtualRouterHelper < OpenNebulaHelper::OneHelper str_h1 % "VIRTUAL ROUTER #{obj['ID']} INFORMATION") puts str % ["ID", obj.id.to_s] puts str % ["NAME", obj.name] - puts str % ["VIRTUAL MACHINE", obj['VMID']] puts str % ["USER", obj['UNAME']] puts str % ["GROUP", obj['GNAME']] puts @@ -117,5 +112,12 @@ class OneVirtualRouterHelper < OpenNebulaHelper::OneHelper CLIHelper.print_header(str_h1 % "TEMPLATE CONTENTS",false) puts obj.template_str + + puts + + CLIHelper.print_header("%-15s" % "VIRTUAL MACHINES") + obj.vm_ids.each do |id| + puts "%-15s" % [id] + end end end diff --git a/src/oca/ruby/opennebula/virtual_router.rb b/src/oca/ruby/opennebula/virtual_router.rb index e3b9829c3a..fb6f11970d 100644 --- a/src/oca/ruby/opennebula/virtual_router.rb +++ b/src/oca/ruby/opennebula/virtual_router.rb @@ -163,5 +163,16 @@ module OpenNebula def owner_id self['UID'].to_i end + + # Returns an array with the numeric VM ids + def vm_ids + array = Array.new + + self.each("VMS/ID") do |id| + array << id.text.to_i + end + + return array + end end end diff --git a/src/rm/RequestManagerVMTemplate.cc b/src/rm/RequestManagerVMTemplate.cc index 606daeadaa..b3d0afefc7 100644 --- a/src/rm/RequestManagerVMTemplate.cc +++ b/src/rm/RequestManagerVMTemplate.cc @@ -140,6 +140,7 @@ void VMTemplateInstantiate::request_execute(xmlrpc_c::paramList const& paramList // Temporary code to create Virtual Routers from regular VM Templates bool is_vrouter; + bool has_vrouter_id; int vrid; string vr_error_str; @@ -147,7 +148,9 @@ void VMTemplateInstantiate::request_execute(xmlrpc_c::paramList const& paramList tmpl->get("VROUTER", is_vrouter); - if (is_vrouter) + has_vrouter_id = tmpl->get("VROUTER_ID", vrid); + + if (is_vrouter && !has_vrouter_id) { Template * vr_tmpl = new Template; @@ -222,7 +225,7 @@ void VMTemplateInstantiate::request_execute(xmlrpc_c::paramList const& paramList //-------------------------------------------------------------------------- // Temporary code to create Virtual Routers from regular VM Templates - // Final code would need roolback to delete the new VR on error + // Final code would need rollback to delete the new VR on error VirtualRouter * vr; @@ -230,7 +233,7 @@ void VMTemplateInstantiate::request_execute(xmlrpc_c::paramList const& paramList if (vr != 0) { - vr->set_vmid(vid); + vr->add_vmid(vid); vrpool->update(vr); diff --git a/src/sunstone/etc/sunstone-views/admin.yaml b/src/sunstone/etc/sunstone-views/admin.yaml index 73709ebbd9..06e9fa6c2d 100644 --- a/src/sunstone/etc/sunstone-views/admin.yaml +++ b/src/sunstone/etc/sunstone-views/admin.yaml @@ -437,13 +437,13 @@ tabs: vrouters-tab: panel_tabs: virtual_router_info_tab: true + virtual_router_vms_tab: true table_columns: - 0 # Checkbox - 1 # ID - - 2 # VMID - - 3 # Owner - - 4 # Group - - 5 # Name + - 2 # Owner + - 3 # Group + - 4 # Name actions: VirtualRouter.refresh: true VirtualRouter.create_dialog: true diff --git a/src/sunstone/etc/sunstone-views/admin_vcenter.yaml b/src/sunstone/etc/sunstone-views/admin_vcenter.yaml index c01cccf4c2..488a67b080 100644 --- a/src/sunstone/etc/sunstone-views/admin_vcenter.yaml +++ b/src/sunstone/etc/sunstone-views/admin_vcenter.yaml @@ -431,13 +431,13 @@ tabs: vrouters-tab: panel_tabs: virtual_router_info_tab: true + virtual_router_vms_tab: true table_columns: - 0 # Checkbox - 1 # ID - - 2 # VMID - - 3 # Owner - - 4 # Group - - 5 # Name + - 2 # Owner + - 3 # Group + - 4 # Name actions: VirtualRouter.refresh: true VirtualRouter.create_dialog: true diff --git a/src/sunstone/etc/sunstone-views/user.yaml b/src/sunstone/etc/sunstone-views/user.yaml index 4d820d9016..6ba2462f11 100644 --- a/src/sunstone/etc/sunstone-views/user.yaml +++ b/src/sunstone/etc/sunstone-views/user.yaml @@ -432,13 +432,13 @@ tabs: vrouters-tab: panel_tabs: virtual_router_info_tab: true + virtual_router_vms_tab: true table_columns: - 0 # Checkbox - 1 # ID - - 2 # VMID - - 3 # Owner - - 4 # Group - - 5 # Name + - 2 # Owner + - 3 # Group + - 4 # Name actions: VirtualRouter.refresh: true VirtualRouter.create_dialog: true diff --git a/src/sunstone/public/app/tabs/vrouters-tab.js b/src/sunstone/public/app/tabs/vrouters-tab.js index f54e7e5e27..aac508e532 100644 --- a/src/sunstone/public/app/tabs/vrouters-tab.js +++ b/src/sunstone/public/app/tabs/vrouters-tab.js @@ -28,7 +28,8 @@ define(function(require) { ]; var _panels = [ - require('./vrouters-tab/panels/info') + require('./vrouters-tab/panels/info'), + require('./vrouters-tab/panels/vms') ]; var _panelsHooks = [ diff --git a/src/sunstone/public/app/tabs/vrouters-tab/datatable.js b/src/sunstone/public/app/tabs/vrouters-tab/datatable.js index edced70510..c9a6b79610 100644 --- a/src/sunstone/public/app/tabs/vrouters-tab/datatable.js +++ b/src/sunstone/public/app/tabs/vrouters-tab/datatable.js @@ -56,7 +56,6 @@ define(function(require) { this.columns = [ Locale.tr("ID"), - Locale.tr("VMID"), Locale.tr("Owner"), Locale.tr("Group"), Locale.tr("Name") @@ -64,7 +63,7 @@ define(function(require) { this.selectOptions = { "id_index": 1, - "name_index": 5, + "name_index": 4, "select_resource": Locale.tr("Please select a virtual router from the list"), "you_selected": Locale.tr("You selected the following virtual router:"), "select_resource_multiple": Locale.tr("Please select one or more virtual routers from the list"), @@ -92,7 +91,6 @@ define(function(require) { element.ID + '" name="selected_items" value="' + element.ID + '"/>', element.ID, - element.VMID, element.UNAME, element.GNAME, element.NAME diff --git a/src/sunstone/public/app/tabs/vrouters-tab/panels/info.js b/src/sunstone/public/app/tabs/vrouters-tab/panels/info.js index 877baf34ae..05a7baa90e 100644 --- a/src/sunstone/public/app/tabs/vrouters-tab/panels/info.js +++ b/src/sunstone/public/app/tabs/vrouters-tab/panels/info.js @@ -68,12 +68,6 @@ define(function(require) { function _html() { var renameTrHTML = RenameTr.html(TAB_ID, RESOURCE, this.element.NAME); - var vmid = this.element.VMID; - - if (vmid == "-1"){ - vmid = undefined; // Change made to use {{#if vmid}} in handlebars - } - var permissionsTableHTML = PermissionsTable.html(TAB_ID, RESOURCE, this.element); // TODO: simplify interface? @@ -87,7 +81,6 @@ define(function(require) { return TemplateInfo({ 'element': this.element, 'renameTrHTML': renameTrHTML, - 'vmid': vmid, 'permissionsTableHTML': permissionsTableHTML, 'templateTableHTML': templateTableHTML }); diff --git a/src/sunstone/public/app/tabs/vrouters-tab/panels/info/html.hbs b/src/sunstone/public/app/tabs/vrouters-tab/panels/info/html.hbs index c4846490f1..04f34b052e 100644 --- a/src/sunstone/public/app/tabs/vrouters-tab/panels/info/html.hbs +++ b/src/sunstone/public/app/tabs/vrouters-tab/panels/info/html.hbs @@ -28,16 +28,6 @@