[Ovirt-devel] [PATCH server] provide default vm allocated cpu and memory values

Mohammed Morsi mmorsi at redhat.com
Fri Jun 19 21:29:03 UTC 2009


adds a migration to provides default values for the vm table
columns num_vcpus_allocated and memory_allocated. These
propogate up to the add vm form so the user doesn't have
to specify them

default cpus = 1, memory = 262144 (256MB)
---
 src/db/migrate/039_vm_cpu_and_memory_defaults.rb |   29 ++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)
 create mode 100644 src/db/migrate/039_vm_cpu_and_memory_defaults.rb

diff --git a/src/db/migrate/039_vm_cpu_and_memory_defaults.rb b/src/db/migrate/039_vm_cpu_and_memory_defaults.rb
new file mode 100644
index 0000000..f33bc52
--- /dev/null
+++ b/src/db/migrate/039_vm_cpu_and_memory_defaults.rb
@@ -0,0 +1,29 @@
+# Copyright (C) 2009 Red Hat, Inc.
+# Written by Mohammed Morsi <mmorsi at redhat.com>
+#
+# 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; version 2 of the License.
+#
+# 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.  A copy of the GNU General Public License is
+# also available at http://www.gnu.org/copyleft/gpl.html.
+
+class VmCpuAndMemoryDefaults < ActiveRecord::Migration
+  def self.up
+    change_column :vms, :num_vcpus_allocated, :integer, :default => 1
+    change_column :vms, :memory_allocated, :integer, :default => 262144 #256MB
+  end
+
+  def self.down
+    change_column :vms, :num_vcpus_allocated, :integer, :default => nil
+    change_column :vms, :memory_allocated, :integer, :default => nil
+  end
+end
-- 
1.6.0.6




More information about the ovirt-devel mailing list