[PATCH/foreman 1/1] fixes #1703 - Add Ok Hosts as Bookmark

Signed-off-by: Corey Osman <corey@logicminds.biz>

··· --- .../20120623002052_add_ok_hosts_book_mark.rb | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) create mode 100644 db/migrate/20120623002052_add_ok_hosts_book_mark.rb

diff --git a/db/migrate/20120623002052_add_ok_hosts_book_mark.rb b/db/migrate/20120623002052_add_ok_hosts_book_mark.rb
new file mode 100644
index 0000000…adc351a
— /dev/null
+++ b/db/migrate/20120623002052_add_ok_hosts_book_mark.rb
@@ -0,0 +1,8 @@
+class AddOkHostsBookMark < ActiveRecord::Migration

  • def self.up
  • Bookmark.find_or_create_by_name :name => "ok hosts", :query => 'last_report > "35 minutes ago" and status.enabled = true and status.applied = 0 and status.failed = 0 and status.pending = 0', :controller=> "hosts", :public => true
    
  • end
  • def self.down
  • end
    +end

    1.7.1

>
> Signed-off-by: Corey Osman <corey@logicminds.biz>
> —
> …/20120623002052_add_ok_hosts_book_mark.rb | 8 ++++++++
> 1 files changed, 8 insertions(+), 0 deletions(-)
> create mode 100644 db/migrate/20120623002052_add_ok_hosts_book_mark.rb
>
> diff --git a/db/migrate/20120623002052_add_ok_hosts_book_mark.rb
> b/db/migrate/20120623002052_add_ok_hosts_book_mark.rb
> new file mode 100644
> index 0000000…adc351a
> — /dev/null
> +++ b/db/migrate/20120623002052_add_ok_hosts_book_mark.rb
> @@ -0,0 +1,8 @@
> +class AddOkHostsBookMark < ActiveRecord::Migration
> + def self.up
> + Bookmark.find_or_create_by_name :name => "ok hosts", :query =>
> 'last_report > "35 minutes ago" and status.enabled = true and
> status.applied = 0 and status.failed = 0 and status.pending = 0',
> :controller=> "hosts", :public => true
> + end
>

does this really works? find_or_create_by_name? imhho, it should be either
find_or_create_by_name_and_query_and … or something else equiv?

··· On Sat, Jun 23, 2012 at 8:43 AM, Corey Osman wrote:
  • def self.down
  • end
    +end

    1.7.1

Not sure if it works. I just copied from a previous migration and changed the name and query. I assume if it fails it creates it regardless. Let me check to see what happens when it already exists.

Corey Osman
corey@logicminds.biz
678-348-0582 (Pacific Time)

Green IT and Datacenter Automation Specialist

··· On Jun 24, 2012, at 11:53 AM, Ohad Levy wrote:

On Sat, Jun 23, 2012 at 8:43 AM, Corey Osman corey@logicminds.biz wrote:

Signed-off-by: Corey Osman corey@logicminds.biz

…/20120623002052_add_ok_hosts_book_mark.rb | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
create mode 100644 db/migrate/20120623002052_add_ok_hosts_book_mark.rb

diff --git a/db/migrate/20120623002052_add_ok_hosts_book_mark.rb b/db/migrate/20120623002052_add_ok_hosts_book_mark.rb
new file mode 100644
index 0000000…adc351a
— /dev/null
+++ b/db/migrate/20120623002052_add_ok_hosts_book_mark.rb
@@ -0,0 +1,8 @@
+class AddOkHostsBookMark < ActiveRecord::Migration

  • def self.up
  • Bookmark.find_or_create_by_name :name => "ok hosts", :query => 'last_report > "35 minutes ago" and status.enabled = true and status.applied = 0 and status.failed = 0 and status.pending = 0', :controller=> "hosts", :public => true
    
  • end

does this really works? find_or_create_by_name? imhho, it should be either find_or_create_by_name_and_query_and … or something else equiv?
+

  • def self.down
  • end
    +end

    1.7.1

Ohad,

Yea this works great. Even tried in the console. I suppose if you already had something named "ok hosts" and the controller was different then it would fail. I will update the code to add the controller and query.

> Bookmark.find_or_create_by_name

Corey Osman
corey@logicminds.biz

Green IT and Datacenter Automation Specialist

··· On Jun 24, 2012, at 11:53 AM, Ohad Levy wrote:

On Sat, Jun 23, 2012 at 8:43 AM, Corey Osman corey@logicminds.biz wrote:

Signed-off-by: Corey Osman corey@logicminds.biz

…/20120623002052_add_ok_hosts_book_mark.rb | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
create mode 100644 db/migrate/20120623002052_add_ok_hosts_book_mark.rb

diff --git a/db/migrate/20120623002052_add_ok_hosts_book_mark.rb b/db/migrate/20120623002052_add_ok_hosts_book_mark.rb
new file mode 100644
index 0000000…adc351a
— /dev/null
+++ b/db/migrate/20120623002052_add_ok_hosts_book_mark.rb
@@ -0,0 +1,8 @@
+class AddOkHostsBookMark < ActiveRecord::Migration

  • def self.up
  • Bookmark.find_or_create_by_name :name => "ok hosts", :query => 'last_report > "35 minutes ago" and status.enabled = true and status.applied = 0 and status.failed = 0 and status.pending = 0', :controller=> "hosts", :public => true
    
  • end

does this really works? find_or_create_by_name? imhho, it should be either find_or_create_by_name_and_query_and … or something else equiv?
+

  • def self.down
  • end
    +end

    1.7.1