Skip to content

Instantly share code, notes, and snippets.

View dLobatog's full-sized avatar
🤗

Daniel Lobato García dLobatog

🤗
View GitHub Profile
host = Host.new(:name => "whatever", :environment => Environment.first)
host.save
osfamily_fact = FactValue.new(:value => "windows", :fact_name => FactName.find_by_name('osfamily'), :host => host)
osfamily_fact.save
[:container, :image].each do |docker_object|
define_method("create_#{docker_object}") do |opts = {}|
logger.debug("Creating Docker #{docker_object.to_s.humanize} with the following options:
#{opts.inspect}")
"::Docker::#{a.to_s.capitalize}".constantize.send(:create, opts)
rescue Excon::Errors::Error, ::Docker::Error::DockerError => e
logger.debug "Fog error: #{e.message}\n " + e.backtrace.join("\n ")
errors.add(:base, _("Error creating #{docker_object}. Check the Foreman logs: %s") % e.message.to_s)
false
end
@dLobatog
dLobatog / gist:ef997b9030650fa610eb
Created April 7, 2015 08:43
0001-Patch-to-use-factories.patch
From f1e07517a2a155e410bcc5cfdb45e117ca93d6ab Mon Sep 17 00:00:00 2001
From: Daniel Lobato <elobatocs@gmail.com>
Date: Tue, 7 Apr 2015 11:38:12 +0300
Subject: [PATCH] Patch to use factories
---
test/fixtures/filterings.yml | 15 ---------------
test/fixtures/filters.yml | 2 --
test/fixtures/roles.yml | 5 -----
test/fixtures/user_roles.yml | 13 -------------
#!/bin/bash
GITHUB_TOKEN=$(cat ~/.codereview)
RED='\e[31m';
GREEN='\e[32m';
PRNUMBER=$1
LASTCOMMIT=$(git log | head -1 | cut -d ' ' -f2)
AUTHOR=$(curl --silent -H "Authorization: token ${GITHUB_TOKEN}" "https://api.github.com/repos/theforeman/foreman/issues/${PRNUMBER}" | ruby -e "require 'json'; puts JSON[STDIN.read]['user']['login'];")
echo -e "${GREEN} -- Checking out pull request $1\033[0m"
time->Fri May 22 13:21:54 2015
type=SYSCALL msg=audit(1432293714.170:116498): arch=c000003e syscall=59 success=yes exit=0 a0=f93980 a1=f93a50 a2=f92480 a3=7fff1393db80 items=0 ppid=31395 pid=31396 auid=4294967295 uid=990 gid=988 euid=990 suid=990 fsuid=990 egid=988 sgid=988 fsgid=988 tty=(none) ses=4294967295 comm="ldconfig" exe="/usr/sbin/ldconfig" subj=system_u:system_r:websockify_t:s0 key=(null)
type=AVC msg=audit(1432293714.170:116498): avc: denied { execute_no_trans } for pid=31396 comm="sh" path="/usr/sbin/ldconfig" dev="dm-1" ino=201341590 scontext=system_u:system_r:websockify_t:s0 tcontext=system_u:object_r:ldconfig_exec_t:s0 tclass=file
type=AVC msg=audit(1432293714.170:116498): avc: denied { read open } for pid=31396 comm="sh" path="/usr/sbin/ldconfig" dev="dm-1" ino=201341590 scontext=system_u:system_r:websockify_t:s0 tcontext=system_u:object_r:ldconfig_exec_t:s0 tclass=file
type=AVC msg=audit(1432293714.170:116498): avc: denied { execute } for pid=31396 comm="sh" name="ldconfig" dev="dm-
DEFAULT pxeboot
TIMEOUT 20
PROMPT 0
LABEL pxeboot
kernel vmlinuz_atomic
append initrd=<%= @host.medium.path %>isolinux/initrd.img repo=<%= @host.medium.path %> ks=<%= foreman_url('provision')%> ks.device=bootif network ks.sendmac
ks.device=bootif network ks.sendmac
IPAPPEND 2
DEFAULT pxeboot
TIMEOUT 20
PROMPT 0
LABEL pxeboot
kernel vmlinuz_atomic
append initrd=<%= @host.medium.path %>isolinux/initrd.img repo=<%= @host.medium.path %> ks=<%= foreman_url('provision')%> ks.device=bootif network ks.sendmac
ks.device=bootif network ks.sendmac
IPAPPEND 2
DEFAULT pxeboot
TIMEOUT 20
PROMPT 0
LABEL pxeboot
kernel vmlinuz_atomic
append initrd=<%= @host.medium.path %>isolinux/initrd.img repo=<%= @host.medium.path %> ks=<%= foreman_url('provision')%> ks.device=bootif network ks.sendmac
ks.device=bootif network ks.sendmac
IPAPPEND 2
#!/bin/bash
GITHUB_TOKEN=$(cat ~/.codereview)
RED='\e[31m';
GREEN='\e[32m';
PRNUMBER=$1
LASTCOMMIT=$(git log | head -1 | cut -d ' ' -f2)
AUTHOR=$(curl --silent -H "Authorization: token ${GITHUB_TOKEN}" "https://api.github.com/repos/theforeman/foreman/issues/${PRNUMBER}" | ruby -e "require 'json'; puts JSON[STDIN.read]['user']['login'];")
echo -e "${GREEN} -- Checking out pull request $1\033[0m"