Skip to content

Instantly share code, notes, and snippets.

diff --git a/app/models/concerns/taxonomix.rb b/app/models/concerns/taxonomix.rb
index b20d81c..c7930b7 100644
--- a/app/models/concerns/taxonomix.rb
+++ b/app/models/concerns/taxonomix.rb
@@ -92,7 +92,11 @@ module Taxonomix
inner_ids ||= inner_ids_org if inner_ids_org
# In the case of users we want the taxonomy scope to get both the users of the taxonomy and admins.
inner_ids.concat(admin_ids) if inner_ids && self == User
- inner_ids
+ if inner_ids.nil? && User.current.try(:admin?)
@ares
ares / 17104.diff
Created October 26, 2016 08:35
Allow ignore types configuration via API v2
diff --git a/app/controllers/concerns/api/v2/taxonomies_controller.rb b/app/controllers/concerns/api/v2/taxonomies_controller.rb
index 1c82e20..bf5e19a 100644
--- a/app/controllers/concerns/api/v2/taxonomies_controller.rb
+++ b/app/controllers/concerns/api/v2/taxonomies_controller.rb
@@ -29,6 +29,7 @@ module Api::V2::TaxonomiesController
param :environment_ids, Array, N_("Environment IDs"), :required => false
param :subnet_ids, Array, N_("Subnet IDs"), :required => false
param :parent_id, :number, :desc => N_('Parent ID'), :required => false
+ param :ignore_types, Array, N_("List of resources types that will be automatically associated"), :required => false
end
@ares
ares / move_code.diff
Created November 8, 2016 16:16
Testing ##3984 refactoring
diff --git a/app/models/parameter.rb b/app/models/parameter.rb
index ade2067..0dc1be2 100644
--- a/app/models/parameter.rb
+++ b/app/models/parameter.rb
@@ -13,27 +13,6 @@ class Parameter < ActiveRecord::Base
scoped_search :on => :type, :complete_value => true
scoped_search :on => :value, :complete_value => true
- # children associations must be defined here, otherwise scoped search definitions won't find them
- belongs_to :domain, :foreign_key => :reference_id, :inverse_of => :domain_parameters
@ares
ares / migrate.rb
Created January 12, 2017 18:03
Convert templates in files to use parameters macros
Dir.glob('./**/*.erb').each do |template|
puts "Found #{template}"
content = File.read(template)
content = content.gsub(/@host\.param_true\?\((.*?)\)/, 'host_param_true?(\1)')
content = content.gsub(/@host\.param_false\?\((.*?)\)/, 'host_param_false?(\1)')
content = content.gsub(/@host\.params\[(.*?)\]/, 'host_param(\1)')
content = content.gsub(/@host\.info/, 'host_enc')
File.write(template, content)
end
SMART PROXY SETUP
<% if @host.operatingsystem.family == 'Redhat' -%>
# TODO parametrize
yum -y install "http://yum.theforeman.org/nightly/el7/x86_64/foreman-release.rpm"
yum -y install 'foreman-installer' # TODO through package macro possibly
<% elsif @host.operatingsystem.family == 'Debian' -%>
# TODO
<% end -%>
foreman-installer \
@ares
ares / gist:f0a4f4bcee1e0f2e9e16e9c4b6ec6325
Created January 25, 2017 07:38
changes required for InputTemplateRenderer in core
diff --git a/app/controllers/concerns/foreman/controller/parameters/provisioning_template.rb b/app/controllers/concerns/foreman/controller/parameters/provisioning_template.rb
index 59a26ab..cdde672 100644
--- a/app/controllers/concerns/foreman/controller/parameters/provisioning_template.rb
+++ b/app/controllers/concerns/foreman/controller/parameters/provisioning_template.rb
@@ -3,12 +3,13 @@ module Foreman::Controller::Parameters::ProvisioningTemplate
include Foreman::Controller::Parameters::Taxonomix
include Foreman::Controller::Parameters::Template
include Foreman::Controller::Parameters::TemplateCombination
+ include Foreman::Controller::Parameters::TemplateInput
diff --git a/app/models/foreman_tasks/concerns/action_triggering.rb b/app/models/foreman_tasks/concerns/action_triggering.rb
index 924c82a..08fe738 100644
--- a/app/models/foreman_tasks/concerns/action_triggering.rb
+++ b/app/models/foreman_tasks/concerns/action_triggering.rb
@@ -152,7 +152,7 @@ module ForemanTasks
run = ::ForemanTasks.dynflow.world.execute(@execution_plan.id)
if @dynflow_sync_action
run.wait
- if run.value.error?
+ if run.value.try(:error?)
[root@dell-pe-fm120-1c ~]# foreman-installer --scenario katello --help | grep dynflow
--foreman-plugin-tasks-dynflow-in-core Whether Foreman ships the Dynflow executor service (true on 1.15+) (current: UNDEF)
[root@dell-pe-fm120-1c ~]# foreman-installer --scenario katello
Parameter foreman-dynflow-in-core invalid: true is not a valid string
Parameter foreman-plugin-tasks-dynflow-in-core invalid: nil is not a valid string
ares@tony:[~/z/hammer][master✓]$ be bin/hammer virt-who-config deploy --id 2
404 Not Found
ares@tony:[~/z/hammer][master✓]$ be bin/hammer virt-who-config fetch --id 2
404 Not Found
ares@tony:[~/z/hammer][master✓]$ be bin/hammer virt-who-config info --id 2
404 Not Found
ares@tony:[~/z/hammer][master✓]$ be bin/hammer virt-who-config delete --id 2
Could not delete the Virt Who configuration:
404 Not Found
@ares
ares / gist:a5291136d3eb58d9dc11db8f29bd0f2f
Created May 31, 2017 07:47
SQL query when I search for subnets by "organization_id = 1"
SELECT "subnets"."id" AS t0_r0, "subnets"."network" AS t0_r1, "subnets"."mask" AS t0_r2, "subnets"."priority" AS t0_r3, "subnets"."name" AS t0_r4, "subnets"."vlanid" AS t0_r5, "subnets"."created_at" AS t0_r6, "subnets"."updated_at" AS t0_r7, "subnets"."dhcp_id" AS t0_r8, "subnets"."tftp_id" AS t0_r9, "subnets"."gateway" AS t0_r10, "subnets"."dns_primary" AS t0_r11, "subnets"."dns_secondary" AS t0_r12, "subnets"."from" AS t0_r13, "subnets"."to" AS t0_r14, "subnets"."dns_id" AS t0_r15, "subnets"."boot_mode" AS t0_r16, "subnets"."ipam" AS t0_r17, "subnets"."discovery_id" AS t0_r18, "subnets"."type" AS t0_r19, "subnets"."description" AS t0_r20, "domains"."id" AS t1_r0, "domains"."name" AS t1_r1, "domains"."fullname" AS t1_r2, "domains"."created_at" AS t1_r3, "domains"."updated_at" AS t1_r4, "domains"."dns_id" AS t1_r5, "smart_proxies"."id" AS t2_r0, "smart_proxies"."name" AS t2_r1, "smart_proxies"."url" AS t2_r2, "smart_proxies"."created_at" AS t2_r3, "smart_proxies"."updated_at" AS t2_r4, "smart_proxies"."pubkey