Bug 1223042
Summary: | Git based gems not available in CFME automate methods | ||
---|---|---|---|
Product: | Red Hat CloudForms Management Engine | Reporter: | jritenou |
Component: | Appliance | Assignee: | Joe Rafaniello <jrafanie> |
Status: | CLOSED ERRATA | QA Contact: | Milan Falešník <mfalesni> |
Severity: | high | Docs Contact: | |
Priority: | high | ||
Version: | 5.4.0 | CC: | abellott, cpelland, gjansen, jhardy, jprause, krain, mfalesni, mfeifer, mkanoor, obarenbo, tfitzger |
Target Milestone: | GA | ||
Target Release: | 5.4.0 | ||
Hardware: | x86_64 | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | Bug Fix | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2015-06-16 13:02:42 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
jritenou
2015-05-19 16:35:11 UTC
A really bad hack is to inject the lib paths for each of the bundler git based gems into the ruby automate method preamble: diff --git a/vmdb/lib/miq_automation_engine/engine/miq_ae_method.rb b/vmdb/lib/miq_automation_engine/engine/miq_ae_method.rb index 394c26c..d765392 100644 --- a/vmdb/lib/miq_automation_engine/engine/miq_ae_method.rb +++ b/vmdb/lib/miq_automation_engine/engine/miq_ae_method.rb @@ -140,6 +140,9 @@ begin Socket.do_not_reverse_lookup = true # turn off reverse DNS resolution require 'drb' + # HACK: inject each of the bundler git based gem lib paths from the current + # process into the preamble executed in the ruby method subproces. + #{$LOAD_PATH.grep(/bundler\/gems/).each_with_object("") { |path, string| string << "$LOAD_PATH << '#{path}'\n " } } MIQ_OK = 0 MIQ_WARN = 4 A better solution would be to symlink the gemset's bundler git gem directories so rubygems can find them. I was able to do this manually, just have to automate this as part of the gemset creation. For each gem in the bundler/gems directory (/opt/rh/cfme-gemset/bundler/gems) actionwebservice-fcb04f3fa857 handsoap-daec1277652f jquery-rjs-33e0fc1c0b25 rails-4842a8377644 rest-client-08480eb86aef rubyrep-fd866d906fcb rubywbem-f2c18cbe14a4 ruport-3ba69305f42e soap4r-514bdbe1d0bc WinRM-f4fa33eba82d ziya-597cc777c24f Get the gem version for each git based gem 1) Load rails console on a cfme 5.4 appliance: irb(main):014:0> Gem.loaded_specs.values.select { |s| s.full_gem_path.include?("bundler/gems") } => [#<Gem::Specification:0x1230ea0 activesupport-3.2.17>, #<Gem::Specification:0x1211e60 activemodel-3.2.17>, #<Gem::Specification:0x105a4f0 actionpack-3.2.17>, #<Gem::Specification:0x1267310 actionmailer-3.2.17>, #<Gem::Specification:0x10da844 activerecord-3.2.17>, #<Gem::Specification:0x12bce3c actionwebservice-3.1.0>, #<Gem::Specification:0x11f0698 activeresource-3.2.17>, #<Gem::Specification:0x15ed3cc rest-client-2.0.0.alpha>, #<Gem::Specification:0x112fb14 railties-3.2.17>, #<Gem::Specification:0x15fc2a0 handsoap-0.2.5>, #<Gem::Specification:0xf65b1c rails-3.2.17>, #<Gem::Specification:0x125cbcc jquery-rjs-0.1.1>, #<Gem::Specification:0x1246ee4 rubyrep-1.2.0>, #<Gem::Specification:0x1628b34 rubywbem-0.1.0>, #<Gem::Specification:0x163d250 ruport-1.7.0>, #<Gem::Specification:0x12002c8 soap4r-1.6.0>, #<Gem::Specification:0x15bd500 winrm-1.1.3>, #<Gem::Specification:0x1669954 ziya-2.3.0>] 2) Create the following symlinks for each gem using the above information. Note, use the Gem::Specification's gem name and version number for the destination symlink. For example, even though WinRM uses mixed case, the name of the gem is lowecase: #<Gem::Specification:0x15bd500 winrm-1.1.3> So: ln -s /opt/rh/cfme-gemset/bundler/gems/WinRM-f4fa33eba82d/ /opt/rh/cfme-gemset/gems/winrm-1.1.3 ln -s /opt/rh/cfme-gemset/bundler/gems/WinRM-f4fa33eba82d/winrm.gemspec /opt/rh/cfme-gemset/specifications/winrm-1.1.3.gemspec Produces: [root@10-16-6-93 vmdb]# ls -al /opt/rh/cfme-gemset/gems/winrm-1.1.3 lrwxrwxrwx. 1 root root 52 May 19 17:11 /opt/rh/cfme-gemset/gems/winrm-1.1.3 -> /opt/rh/cfme-gemset/bundler/gems/WinRM-f4fa33eba82d/ [root@10-16-6-93 vmdb]# ls -al /opt/rh/cfme-gemset/specifications/winrm-1.1.3.gemspec lrwxrwxrwx. 1 root root 65 May 19 17:06 /opt/rh/cfme-gemset/specifications/winrm-1.1.3.gemspec -> /opt/rh/cfme-gemset/bundler/gems/WinRM-f4fa33eba82d/winrm.gemspec ln -s /opt/rh/cfme-gemset/bundler/gems/rest-client-08480eb86aef/ /opt/rh/cfme-gemset/gems/rest-client-2.0.0.alpha ln -s /opt/rh/cfme-gemset/bundler/gems/rest-client-08480eb86aef/rest-client.gemspec /opt/rh/cfme-gemset/specifications/rest-client-2.0.0.alpha.gemspec [root@10-16-6-93 vmdb]# ls -al /opt/rh/cfme-gemset/gems/rest-client-2.0.0.alpha lrwxrwxrwx. 1 root root 58 May 19 16:38 /opt/rh/cfme-gemset/gems/rest-client-2.0.0.alpha -> /opt/rh/cfme-gemset/bundler/gems/rest-client-08480eb86aef/ [root@10-16-6-93 vmdb]# ls -al /opt/rh/cfme-gemset/specifications/rest-client-2.0.0.alpha.gemspec lrwxrwxrwx. 1 root root 77 May 19 16:38 /opt/rh/cfme-gemset/specifications/rest-client-2.0.0.alpha.gemspec -> /opt/rh/cfme-gemset/bundler/gems/rest-client-08480eb86aef/rest-client.gemspec We had success rebuilding the old cfme-gemset-5.4.0.1 using a change in our gemset creation process to do symlinking and a commit on the cfme-gemset.spec to change the /opt/rh/cfme-gemset/enable script to no longer set GEM_HOME but instead set GEM_PATH and BUNDLE_PATH. For testing: 1) gem install winrm should install to the default gem location, `gem env home`... not /opt/rh/cfme-gemset/gems 2) if you install a newer winrm (1.3.3), where we have 1.1.3 in our gemset, you should be able to write an automate method that does `require 'winrm'` and use the new 1.3.3 version. 3) if you install an older winrm (1.1.2), where we have 1.1.3 in our gemset, you can only use the older winrm, 1.1.2 by putting this in our automate method: gem 'winrm', "=1.1.2" require 'winrm' To test these, it was easiest to find the location of the gem by looking for it in the `gem env path` locations... then modify the winrm.rb file to `puts "hello 1.1.2"` at the top of the file, you should see the output in the log/automation.log file. On my 5.4 appliance, these locations were here: /opt/rh/ruby200/root/usr/local/share/gems/gems/winrm-1.1.2/lib/winrm.rb /opt/rh/ruby200/root/usr/local/share/gems/gems/winrm-1.3.3/lib/winrm.rb /opt/rh/cfme-gemset/bundler/gems/WinRM-f4fa33eba82d/lib/winrm.rb The next build of 5.4 will have the cfme-gemset rpm fixed. Verified in 5.4.0.4. I created an instance and a method in the Request class in similar manner as InspectMe is done. The instance had code like this: $evm.log(:info, (require "rest-client")) After running a simulation with executing the methods, the automation.log stated this: [----] I, [2015-06-02T04:31:48.409972 #2752:403ea4] INFO -- : Following Relationship [miqaedb:/System/Request/testit#create] [----] I, [2015-06-02T04:31:48.424474 #2752:403ea4] INFO -- : Updated namespace [miqaedb:/System/Request/testit#create Default/System] [----] I, [2015-06-02T04:31:48.444408 #2752:403ea4] INFO -- : Updated namespace [System/Request/testitmeth Default/System] [----] I, [2015-06-02T04:31:48.451307 #2752:403ea4] INFO -- : Invoking [inline] method [/Default/System/Request/testitmeth] with inputs [{}] [----] I, [2015-06-02T04:31:48.452285 #2752:403ea4] INFO -- : <AEMethod [/Default/System/Request/testitmeth]> Starting [----] I, [2015-06-02T04:31:49.176876 #2752:80f726c] INFO -- : <AEMethod testitmeth> true [----] I, [2015-06-02T04:31:49.190384 #2752:403ea4] INFO -- : <AEMethod [/Default/System/Request/testitmeth]> Ending [----] I, [2015-06-02T04:31:49.190495 #2752:403ea4] INFO -- : Method exited with rc=MIQ_OK [----] I, [2015-06-02T04:31:49.191228 #2752:403ea4] INFO -- : Followed Relationship [miqaedb:/System/Request/testit#create] Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://rhn.redhat.com/errata/RHBA-2015-1100.html |