[Ovirt-devel] [PATCH server] make network usages disablable and disable 'admin' usage
Mohammed Morsi
mmorsi at redhat.com
Tue Mar 31 19:05:14 UTC 2009
---
src/app/controllers/network_controller.rb | 4 +-
.../migrate/037_make_network_usages_disablable.rb | 42 ++++++++++++++++++++
2 files changed, 44 insertions(+), 2 deletions(-)
create mode 100644 src/db/migrate/037_make_network_usages_disablable.rb
diff --git a/src/app/controllers/network_controller.rb b/src/app/controllers/network_controller.rb
index a99cf8d..bc5dd1d 100644
--- a/src/app/controllers/network_controller.rb
+++ b/src/app/controllers/network_controller.rb
@@ -67,7 +67,7 @@ class NetworkController < ApplicationController
def new
@boot_types = BootType.find(:all)
- @usage_types = Usage.find(:all)
+ @usage_types = Usage.find(:all, :conditions => ['not disabled'])
render :layout => 'popup'
end
@@ -88,7 +88,7 @@ class NetworkController < ApplicationController
def edit
@network = Network.find(params[:id])
- @usage_types = Usage.find(:all)
+ @usage_types = Usage.find(:all, :conditions => ['not disabled'])
@boot_types = BootType.find(:all)
render :layout => 'popup'
end
diff --git a/src/db/migrate/037_make_network_usages_disablable.rb b/src/db/migrate/037_make_network_usages_disablable.rb
new file mode 100644
index 0000000..9797af6
--- /dev/null
+++ b/src/db/migrate/037_make_network_usages_disablable.rb
@@ -0,0 +1,42 @@
+# Copyright (C) 2008 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.
+
+# allow network usages to be disabled,
+# rename 'management' to 'admin' and disable it
+class MakeNetworkUsagesDisablable < ActiveRecord::Migration
+ def self.up
+ add_column :usages, :disabled, :bool, :null => false, :default => false
+
+ usage = Usage.find(:first, :conditions => ["usage = 'management'"])
+ usage.label = 'Admin'
+ usage.usage = "admin"
+ usage.disabled = true
+ usage.save!
+ end
+
+ def self.down
+ remove_column :usages, :disabled
+
+ usage = Usage.find(:first, :conditions => ["usage = 'admin'"])
+ usage.label = 'Management'
+ usage.usage = "management"
+ usage.save!
+ end
+end
+
+
--
1.6.0.6
More information about the ovirt-devel
mailing list