Skip to content

Instantly share code, notes, and snippets.

View ohadlevy's full-sized avatar

Ohad Levy ohadlevy

  • Red Hat
  • Israel
View GitHub Profile
class LookupKey < ActiveRecord::Base
include Authorization
KEY_TYPES = %w( string boolean integer real array hash yaml json )
VALIDATOR_TYPES = %w( regexp list )
TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE', 'on', 'ON', 'yes', 'YES', 'y', 'Y'].to_set
FALSE_VALUES = [false, 0, '0', 'f', 'F', 'false', 'FALSE', 'off', 'OFF', 'no', 'NO', 'n', 'N'].to_set
KEY_DELM = ","
class LookupKey < ActiveRecord::Base
include Authorization
KEY_TYPES = %w( string boolean integer real array hash yaml json )
VALIDATOR_TYPES = %w( regexp list )
TRUE_VALUES = [true, 1, '1', 't', 'T', 'true', 'TRUE', 'on', 'ON', 'yes', 'YES', 'y', 'Y'].to_set
FALSE_VALUES = [false, 0, '0', 'f', 'F', 'false', 'FALSE', 'off', 'OFF', 'no', 'NO', 'n', 'N'].to_set
KEY_DELM = ","
diff --git a/app/models/lookup_key.rb b/app/models/lookup_key.rb
index 256f07d..5c45396 100644
--- a/app/models/lookup_key.rb
+++ b/app/models/lookup_key.rb
@@ -150,8 +150,8 @@ class LookupKey < ActiveRecord::Base
begin
self.default_value = cast_validate_value self.default_value
true
- rescue
- errors.add(:default_value, "is invalid")
diff --git a/lib/fog/vsphere/compute.rb b/lib/fog/vsphere/compute.rb
index 6c9fc1e..ed1ca99 100644
--- a/lib/fog/vsphere/compute.rb
+++ b/lib/fog/vsphere/compute.rb
@@ -11,6 +11,16 @@ module Fog
model_path 'fog/vsphere/models/compute'
model :server
collection :servers
+ model :datacenter
+ collection :datacenters
diff --git a/lib/fog/vsphere/compute.rb b/lib/fog/vsphere/compute.rb
index 6c9fc1e..ed1ca99 100644
--- a/lib/fog/vsphere/compute.rb
+++ b/lib/fog/vsphere/compute.rb
@@ -11,6 +11,16 @@ module Fog
model_path 'fog/vsphere/models/compute'
model :server
collection :servers
+ model :datacenter
+ collection :datacenters
module Fog
module Compute
class Vsphere
class Datacenter < Fog::Model
identity :id
attribute :name
attribute :status
diff --git a/lib/fog/vsphere/requests/compute/list_clusters.rb b/lib/fog/vsphere/requests/compute/list_clusters.rb
index 2092213..55980c7 100644
--- a/lib/fog/vsphere/requests/compute/list_clusters.rb
+++ b/lib/fog/vsphere/requests/compute/list_clusters.rb
@@ -11,7 +11,7 @@ module Fog
end
def raw_clusters(datacenter)
- find_raw_datacenter(datacenter).hostFolder.childEntity.grep(RbVmomi::VIM::ClusterComputeResource)
+ find_raw_datacenter(datacenter).hostFolder.childEntity.grep(RbVmomi::VIM::ComputeResource)
diff --git a/config/application.rb b/config/application.rb
index b744354..9544178 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -65,7 +65,7 @@ module Foreman
# enables in memory cache store with ttl
#config.cache_store = TimedCachedStore.new
- config.cache_store = :file_store, Rails.root.join("tmp")
+ config.cache_store = :file_store, Rails.root.join("tmp/cache")
diff --git a/app/models/auth_source_ldap.rb b/app/models/auth_source_ldap.rb
index 561628e..d31f0da 100644
--- a/app/models/auth_source_ldap.rb
+++ b/app/models/auth_source_ldap.rb
@@ -103,7 +103,7 @@ class AuthSourceLdap < AuthSource
end
def required_ldap_attributes
- return [] unless onthefly_register?
+ return {} unless onthefly_register?
#!/usr/bin/env ruby
require 'rubygems'
require 'rest-client'
require 'json'
client = RestClient::Resource.new('http://0.0.0.0:3000',
:user => 'admin',
:password => 'changeme',
:headers => { :accept => :json })