cloud-toaster 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/LICENSE +202 -0
- data/README.md +54 -0
- data/Rakefile +51 -0
- data/VERSION +1 -0
- data/bin/strace-4.8_patched/strace-i686 +0 -0
- data/bin/strace-4.8_patched/strace-x86_64 +0 -0
- data/bin/toaster +74 -0
- data/chef/cookbooks/chef-solo-search/CHANGELOG +16 -0
- data/chef/cookbooks/chef-solo-search/Gemfile +8 -0
- data/chef/cookbooks/chef-solo-search/LICENSE +202 -0
- data/chef/cookbooks/chef-solo-search/NOTICE +18 -0
- data/chef/cookbooks/chef-solo-search/README.md +143 -0
- data/chef/cookbooks/chef-solo-search/Rakefile +10 -0
- data/chef/cookbooks/chef-solo-search/libraries/search/overrides.rb +100 -0
- data/chef/cookbooks/chef-solo-search/libraries/search/parser.rb +222 -0
- data/chef/cookbooks/chef-solo-search/libraries/search.rb +75 -0
- data/chef/cookbooks/chef-solo-search/libraries/vendor/chef/solr_query/lucene.treetop +150 -0
- data/chef/cookbooks/chef-solo-search/libraries/vendor/chef/solr_query/lucene_nodes.rb +285 -0
- data/chef/cookbooks/chef-solo-search/libraries/vendor/chef/solr_query/query_transform.rb +65 -0
- data/chef/cookbooks/chef-solo-search/metadata.rb +11 -0
- data/chef/cookbooks/chef-solo-search/recipes/default.rb +3 -0
- data/chef/cookbooks/chef-solo-search/tests/data/data_bags/node/alpha.json +10 -0
- data/chef/cookbooks/chef-solo-search/tests/data/data_bags/node/beta.json +10 -0
- data/chef/cookbooks/chef-solo-search/tests/data/data_bags/node/without_json_class.json +7 -0
- data/chef/cookbooks/chef-solo-search/tests/data/data_bags/users/jerry.json +8 -0
- data/chef/cookbooks/chef-solo-search/tests/data/data_bags/users/lea.json +10 -0
- data/chef/cookbooks/chef-solo-search/tests/data/data_bags/users/mike.json +13 -0
- data/chef/cookbooks/chef-solo-search/tests/data/data_bags/users/tom.json +10 -0
- data/chef/cookbooks/chef-solo-search/tests/gemfiles/Gemfile.10 +4 -0
- data/chef/cookbooks/chef-solo-search/tests/gemfiles/Gemfile.11 +5 -0
- data/chef/cookbooks/chef-solo-search/tests/test_data_bags.rb +45 -0
- data/chef/cookbooks/chef-solo-search/tests/test_search.rb +244 -0
- data/chef/cookbooks/lxc/attributes/create_lxc.rb +8 -0
- data/chef/cookbooks/lxc/attributes/general.rb +15 -0
- data/chef/cookbooks/lxc/attributes/init_bare_os.rb +15 -0
- data/chef/cookbooks/lxc/attributes/init_proto.rb +18 -0
- data/chef/cookbooks/lxc/attributes/install_ruby.rb +51 -0
- data/chef/cookbooks/lxc/attributes/mount_volume.rb +11 -0
- data/chef/cookbooks/lxc/attributes/setup_host.rb +9 -0
- data/chef/cookbooks/lxc/attributes/setup_proxy.rb +3 -0
- data/chef/cookbooks/lxc/attributes/start_lxc.rb +11 -0
- data/chef/cookbooks/lxc/attributes/stop_lxc.rb +3 -0
- data/chef/cookbooks/lxc/files/install.chef.sh +78 -0
- data/chef/cookbooks/lxc/metadata.json +6 -0
- data/chef/cookbooks/lxc/recipes/create_lxc.rb +106 -0
- data/chef/cookbooks/lxc/recipes/init_bare_os.rb +82 -0
- data/chef/cookbooks/lxc/recipes/init_proto.rb +417 -0
- data/chef/cookbooks/lxc/recipes/install_docker.rb +61 -0
- data/chef/cookbooks/lxc/recipes/install_ruby.rb +28 -0
- data/chef/cookbooks/lxc/recipes/mount_volume.rb +63 -0
- data/chef/cookbooks/lxc/recipes/setup_database.rb +22 -0
- data/chef/cookbooks/lxc/recipes/setup_host.rb +179 -0
- data/chef/cookbooks/lxc/recipes/setup_proxy.rb +157 -0
- data/chef/cookbooks/lxc/recipes/start_lxc.rb +180 -0
- data/chef/cookbooks/lxc/recipes/stop_lxc.rb +86 -0
- data/chef/cookbooks/mysql/CHANGELOG.md +391 -0
- data/chef/cookbooks/mysql/README.md +211 -0
- data/chef/cookbooks/mysql/attributes/default.rb +22 -0
- data/chef/cookbooks/mysql/libraries/helpers.rb +277 -0
- data/chef/cookbooks/mysql/libraries/matchers.rb +17 -0
- data/chef/cookbooks/mysql/libraries/provider_mysql_client.rb +10 -0
- data/chef/cookbooks/mysql/libraries/provider_mysql_client_debian.rb +37 -0
- data/chef/cookbooks/mysql/libraries/provider_mysql_client_fedora.rb +38 -0
- data/chef/cookbooks/mysql/libraries/provider_mysql_client_freebsd.rb +33 -0
- data/chef/cookbooks/mysql/libraries/provider_mysql_client_omnios.rb +41 -0
- data/chef/cookbooks/mysql/libraries/provider_mysql_client_rhel.rb +42 -0
- data/chef/cookbooks/mysql/libraries/provider_mysql_client_smartos.rb +33 -0
- data/chef/cookbooks/mysql/libraries/provider_mysql_client_suse.rb +37 -0
- data/chef/cookbooks/mysql/libraries/provider_mysql_client_ubuntu.rb +37 -0
- data/chef/cookbooks/mysql/libraries/provider_mysql_service.rb +10 -0
- data/chef/cookbooks/mysql/libraries/provider_mysql_service_debian.rb +193 -0
- data/chef/cookbooks/mysql/libraries/provider_mysql_service_fedora.rb +157 -0
- data/chef/cookbooks/mysql/libraries/provider_mysql_service_freebsd.rb +151 -0
- data/chef/cookbooks/mysql/libraries/provider_mysql_service_omnios.rb +232 -0
- data/chef/cookbooks/mysql/libraries/provider_mysql_service_rhel.rb +318 -0
- data/chef/cookbooks/mysql/libraries/provider_mysql_service_smartos.rb +216 -0
- data/chef/cookbooks/mysql/libraries/provider_mysql_service_suse.rb +170 -0
- data/chef/cookbooks/mysql/libraries/provider_mysql_service_ubuntu.rb +218 -0
- data/chef/cookbooks/mysql/libraries/resource_mysql_client.rb +11 -0
- data/chef/cookbooks/mysql/libraries/resource_mysql_service.rb +194 -0
- data/chef/cookbooks/mysql/metadata.json +40 -0
- data/chef/cookbooks/mysql/metadata.rb +20 -0
- data/chef/cookbooks/mysql/recipes/client.rb +22 -0
- data/chef/cookbooks/mysql/recipes/server.rb +33 -0
- data/chef/cookbooks/mysql/recipes/server_deprecated.rb +23 -0
- data/chef/cookbooks/mysql/templates/default/5.0/my.cnf.erb +38 -0
- data/chef/cookbooks/mysql/templates/default/5.1/my.cnf.erb +38 -0
- data/chef/cookbooks/mysql/templates/default/5.5/my.cnf.erb +38 -0
- data/chef/cookbooks/mysql/templates/default/5.6/my.cnf.erb +39 -0
- data/chef/cookbooks/mysql/templates/default/apparmor/usr.sbin.mysqld.erb +40 -0
- data/chef/cookbooks/mysql/templates/default/debian/debian.cnf.erb +12 -0
- data/chef/cookbooks/mysql/templates/default/debian/mysql-server.seed.erb +10 -0
- data/chef/cookbooks/mysql/templates/default/deprecated/my.cnf.erb +374 -0
- data/chef/cookbooks/mysql/templates/default/grants/grants.sql.erb +27 -0
- data/chef/cookbooks/mysql/templates/default/omnios/mysql.xml.erb +26 -0
- data/chef/cookbooks/mysql/templates/default/omnios/svc.method.mysqld.erb +29 -0
- data/chef/cookbooks/mysql/templates/default/smartos/mysql.xml.erb +32 -0
- data/chef/cookbooks/mysql/templates/default/smartos/svc.method.mysqld.erb +29 -0
- data/chef/cookbooks/openssl/README.md +37 -0
- data/chef/cookbooks/openssl/libraries/secure_password.rb +37 -0
- data/chef/cookbooks/openssl/metadata.json +30 -0
- data/chef/cookbooks/openssl/metadata.rb +8 -0
- data/chef/cookbooks/openssl/recipes/default.rb +19 -0
- data/chef/cookbooks/ssh/attributes/default.rb +8 -0
- data/chef/cookbooks/ssh/recipes/authorize_key.rb +20 -0
- data/chef/cookbooks/toaster/attributes/testing.rb +37 -0
- data/chef/cookbooks/toaster/libraries/default.rb +61 -0
- data/chef/cookbooks/toaster/recipes/post__cakephp__default.rb +27 -0
- data/chef/cookbooks/toaster/recipes/post__cube__default.rb +26 -0
- data/chef/cookbooks/toaster/recipes/post__drupal__default.rb +16 -0
- data/chef/cookbooks/toaster/recipes/post__icinga__default.rb +9 -0
- data/chef/cookbooks/toaster/recipes/post__node__default.rb +16 -0
- data/chef/cookbooks/toaster/recipes/post__virtualbox__default.rb +12 -0
- data/chef/cookbooks/toaster/recipes/post__wordpress__default.rb +12 -0
- data/chef/cookbooks/toaster/recipes/pre__aegir__default.rb +12 -0
- data/chef/cookbooks/toaster/recipes/pre__app__default.rb +3 -0
- data/chef/cookbooks/toaster/recipes/pre__cakephp__default.rb +24 -0
- data/chef/cookbooks/toaster/recipes/pre__cube__default.rb +9 -0
- data/chef/cookbooks/toaster/recipes/pre__disco__default.rb +21 -0
- data/chef/cookbooks/toaster/recipes/pre__drbd__default.rb +7 -0
- data/chef/cookbooks/toaster/recipes/pre__eaccelerator__default.rb +2 -0
- data/chef/cookbooks/toaster/recipes/pre__elasticsearch-head__default.rb +11 -0
- data/chef/cookbooks/toaster/recipes/pre__elasticsearch__default.rb +6 -0
- data/chef/cookbooks/toaster/recipes/pre__gitosis__default.rb +17 -0
- data/chef/cookbooks/toaster/recipes/pre__kafka__default.rb +3 -0
- data/chef/cookbooks/toaster/recipes/pre__munin__server.rb +6 -0
- data/chef/cookbooks/toaster/recipes/pre__mysql__server.rb +4 -0
- data/chef/cookbooks/toaster/recipes/pre__nagios__default.rb +3 -0
- data/chef/cookbooks/toaster/recipes/pre__netkernel__default.rb +24 -0
- data/chef/cookbooks/toaster/recipes/pre__php__default.rb +2 -0
- data/chef/cookbooks/toaster/recipes/pre__postgresql__server.rb +3 -0
- data/chef/cookbooks/toaster/recipes/pre__pxe_dust__default.rb +9 -0
- data/chef/cookbooks/toaster/recipes/pre__pxe_install_server__default.rb +6 -0
- data/chef/cookbooks/toaster/recipes/pre__riak__default.rb +40 -0
- data/chef/cookbooks/toaster/recipes/pre__sensu__default.rb +9 -0
- data/chef/cookbooks/toaster/recipes/pre__sol__default.rb +2 -0
- data/chef/cookbooks/toaster/recipes/pre__solr__default.rb +6 -0
- data/chef/cookbooks/toaster/recipes/pre__sonar__default.rb +2 -0
- data/chef/cookbooks/toaster/recipes/pre__storm__default.rb +3 -0
- data/chef/cookbooks/toaster/recipes/pre__vmware__tools.rb +4 -0
- data/chef/cookbooks/toaster/recipes/pre__wordpress__default.rb +17 -0
- data/chef/cookbooks/toaster/recipes/pre__xen__default.rb +7 -0
- data/chef/cookbooks/toaster/recipes/pre__znc__default.rb +7 -0
- data/chef/cookbooks/toaster/recipes/testing.rb +241 -0
- data/chef/cookbooks/toaster/recipes/testing_post.rb +36 -0
- data/chef/cookbooks/yum/CHANGELOG.md +212 -0
- data/chef/cookbooks/yum/README.md +268 -0
- data/chef/cookbooks/yum/attributes/main.rb +97 -0
- data/chef/cookbooks/yum/libraries/matchers.rb +27 -0
- data/chef/cookbooks/yum/metadata.json +34 -0
- data/chef/cookbooks/yum/metadata.rb +13 -0
- data/chef/cookbooks/yum/providers/globalconfig.rb +37 -0
- data/chef/cookbooks/yum/providers/repository.rb +85 -0
- data/chef/cookbooks/yum/recipes/default.rb +34 -0
- data/chef/cookbooks/yum/resources/globalconfig.rb +105 -0
- data/chef/cookbooks/yum/resources/repository.rb +63 -0
- data/chef/cookbooks/yum/templates/default/main.erb +251 -0
- data/chef/cookbooks/yum/templates/default/repo.erb +109 -0
- data/chef/cookbooks/yum-mysql-community/CHANGELOG.md +67 -0
- data/chef/cookbooks/yum-mysql-community/README.md +137 -0
- data/chef/cookbooks/yum-mysql-community/attributes/mysql-connectors-community.rb +31 -0
- data/chef/cookbooks/yum-mysql-community/attributes/mysql55-community.rb +29 -0
- data/chef/cookbooks/yum-mysql-community/attributes/mysql56-community.rb +31 -0
- data/chef/cookbooks/yum-mysql-community/files/default/mysql_pubkey.asc +33 -0
- data/chef/cookbooks/yum-mysql-community/metadata.json +30 -0
- data/chef/cookbooks/yum-mysql-community/metadata.rb +8 -0
- data/chef/cookbooks/yum-mysql-community/recipes/connectors.rb +48 -0
- data/chef/cookbooks/yum-mysql-community/recipes/mysql55.rb +48 -0
- data/chef/cookbooks/yum-mysql-community/recipes/mysql56.rb +48 -0
- data/config.json +34 -0
- data/lib/toaster/api.rb +447 -0
- data/lib/toaster/chef/chef_listener.rb +514 -0
- data/lib/toaster/chef/chef_node_inspector.rb +165 -0
- data/lib/toaster/chef/chef_util.rb +865 -0
- data/lib/toaster/chef/failsafe_resource_parser.rb +140 -0
- data/lib/toaster/chef/resource_inspector.rb +536 -0
- data/lib/toaster/db/cache.rb +98 -0
- data/lib/toaster/db/cached_db.rb +53 -0
- data/lib/toaster/db/cgi_session_cache.rb +209 -0
- data/lib/toaster/db/db.rb +98 -0
- data/lib/toaster/db/mysql.rb +18 -0
- data/lib/toaster/db/ram_cache.rb +203 -0
- data/lib/toaster/markup/jdom-1.1.jar +0 -0
- data/lib/toaster/markup/jdom-b7.jar +0 -0
- data/lib/toaster/markup/markup_util.rb +437 -0
- data/lib/toaster/markup/vmtools-utils-0.5.jar +0 -0
- data/lib/toaster/markup/xmldiff.sh +5 -0
- data/lib/toaster/model/additional_property.rb +11 -0
- data/lib/toaster/model/automation.rb +218 -0
- data/lib/toaster/model/automation_attribute.rb +13 -0
- data/lib/toaster/model/automation_run.rb +104 -0
- data/lib/toaster/model/ignore_property.rb +11 -0
- data/lib/toaster/model/key_value_pair.rb +59 -0
- data/lib/toaster/model/run_attribute.rb +17 -0
- data/lib/toaster/model/state.rb +17 -0
- data/lib/toaster/model/state_change.rb +79 -0
- data/lib/toaster/model/task.rb +292 -0
- data/lib/toaster/model/task_execution.rb +76 -0
- data/lib/toaster/model/task_parameter.rb +66 -0
- data/lib/toaster/model/user.rb +32 -0
- data/lib/toaster/ohai/_disabled_/network_ports.rb +81 -0
- data/lib/toaster/ohai/apache/apache.rb +48 -0
- data/lib/toaster/ohai/cron/cron.rb +32 -0
- data/lib/toaster/ohai/files/_meta.rb +30 -0
- data/lib/toaster/ohai/files/files.rb +20 -0
- data/lib/toaster/ohai/gems/gems.rb +19 -0
- data/lib/toaster/ohai/groups/groups.rb +20 -0
- data/lib/toaster/ohai/iptables/iptables.rb +48 -0
- data/lib/toaster/ohai/mounts/mounts.rb +26 -0
- data/lib/toaster/ohai/mysql/mysql.rb +31 -0
- data/lib/toaster/ohai/packages/_meta.rb +86 -0
- data/lib/toaster/ohai/packages/packages.rb +33 -0
- data/lib/toaster/ohai/ports/ports.rb +21 -0
- data/lib/toaster/ohai/routes/routes.rb +25 -0
- data/lib/toaster/ohai/services/services.rb +42 -0
- data/lib/toaster/ohai/users/users.rb +17 -0
- data/lib/toaster/state/convergence.rb +197 -0
- data/lib/toaster/state/idempotence.rb +192 -0
- data/lib/toaster/state/ptrace_util.rb +48 -0
- data/lib/toaster/state/state_node.rb +105 -0
- data/lib/toaster/state/state_transition.rb +38 -0
- data/lib/toaster/state/state_transition_graph.rb +701 -0
- data/lib/toaster/state/syscall_tracer.rb +317 -0
- data/lib/toaster/state/system_state.rb +349 -0
- data/lib/toaster/state/transition_edge.rb +65 -0
- data/lib/toaster/test/test_attribute.rb +19 -0
- data/lib/toaster/test/test_case.rb +175 -0
- data/lib/toaster/test/test_coverage.rb +147 -0
- data/lib/toaster/test/test_coverage_goal.rb +108 -0
- data/lib/toaster/test/test_generator.rb +246 -0
- data/lib/toaster/test/test_orchestrator.rb +165 -0
- data/lib/toaster/test/test_result.rb +73 -0
- data/lib/toaster/test/test_runner.rb +394 -0
- data/lib/toaster/test/test_suite.rb +151 -0
- data/lib/toaster/test_manager.rb +281 -0
- data/lib/toaster/toaster_app_service.rb +141 -0
- data/lib/toaster/util/blocking_map.rb +80 -0
- data/lib/toaster/util/combinatorial.rb +58 -0
- data/lib/toaster/util/config.rb +103 -0
- data/lib/toaster/util/docker.rb +71 -0
- data/lib/toaster/util/logging.rb +19 -0
- data/lib/toaster/util/lxc.rb +383 -0
- data/lib/toaster/util/mem_dump.rb +38 -0
- data/lib/toaster/util/proxy.rb +23 -0
- data/lib/toaster/util/timestamp.rb +131 -0
- data/lib/toaster/util/util.rb +437 -0
- data/lib/toaster/web_ui.rb +7 -0
- data/webapp/Gemfile +46 -0
- data/webapp/Gemfile.lock +237 -0
- data/webapp/Rakefile +6 -0
- data/webapp/app/assets/fonts/font.woff +0 -0
- data/webapp/app/assets/images/final_state.gif +0 -0
- data/webapp/app/assets/images/initial_state.gif +0 -0
- data/webapp/app/assets/images/loading.gif +0 -0
- data/webapp/app/assets/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/webapp/app/assets/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/webapp/app/assets/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/webapp/app/assets/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/webapp/app/assets/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/webapp/app/assets/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/webapp/app/assets/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/webapp/app/assets/images/ui-icons_222222_256x240.png +0 -0
- data/webapp/app/assets/javascripts/analysis.js.coffee +3 -0
- data/webapp/app/assets/javascripts/application.js +16 -0
- data/webapp/app/assets/javascripts/execs.js.coffee +3 -0
- data/webapp/app/assets/javascripts/graph.js +441 -0
- data/webapp/app/assets/javascripts/jquery-1.7.2.js +9404 -0
- data/webapp/app/assets/javascripts/jquery-ui-1.8.22.js +11529 -0
- data/webapp/app/assets/javascripts/jquery.cookie.js +96 -0
- data/webapp/app/assets/javascripts/jquery.hotkeys.js +99 -0
- data/webapp/app/assets/javascripts/jquery.jstree.js +4551 -0
- data/webapp/app/assets/javascripts/jsPlumb/jquery.jsPlumb-1.3.14-all-min.js +1 -0
- data/webapp/app/assets/javascripts/jstree.util.js +53 -0
- data/webapp/app/assets/javascripts/scripts.js.coffee +3 -0
- data/webapp/app/assets/javascripts/settings.js.coffee +3 -0
- data/webapp/app/assets/javascripts/test.js.coffee +3 -0
- data/webapp/app/assets/javascripts/util.js.coffee +3 -0
- data/webapp/app/assets/stylesheets/analysis.css.scss +3 -0
- data/webapp/app/assets/stylesheets/application.css +49 -0
- data/webapp/app/assets/stylesheets/execs.css.scss +3 -0
- data/webapp/app/assets/stylesheets/graph.css +159 -0
- data/webapp/app/assets/stylesheets/jquery-ui-1.8.6.custom.css +572 -0
- data/webapp/app/assets/stylesheets/layout.css +151 -0
- data/webapp/app/assets/stylesheets/menu.css +186 -0
- data/webapp/app/assets/stylesheets/reset.css +41 -0
- data/webapp/app/assets/stylesheets/scripts.css.scss +3 -0
- data/webapp/app/assets/stylesheets/settings.css.scss +3 -0
- data/webapp/app/assets/stylesheets/test.css.scss +3 -0
- data/webapp/app/assets/stylesheets/util.css.scss +3 -0
- data/webapp/app/assets/stylesheets/websymbols/websymbols-regular-webfont.eot +0 -0
- data/webapp/app/assets/stylesheets/websymbols/websymbols-regular-webfont.svg +1 -0
- data/webapp/app/assets/stylesheets/websymbols/websymbols-regular-webfont.ttf +0 -0
- data/webapp/app/assets/stylesheets/websymbols/websymbols-regular-webfont.woff +0 -0
- data/webapp/app/controllers/analysis_controller.rb +7 -0
- data/webapp/app/controllers/application_controller.rb +14 -0
- data/webapp/app/controllers/base_controller.rb +91 -0
- data/webapp/app/controllers/execs_controller.rb +59 -0
- data/webapp/app/controllers/graph_controller.rb +17 -0
- data/webapp/app/controllers/scripts_controller.rb +166 -0
- data/webapp/app/controllers/settings_controller.rb +10 -0
- data/webapp/app/controllers/test_controller.rb +127 -0
- data/webapp/app/controllers/util_controller.rb +6 -0
- data/webapp/app/helpers/analysis_helper.rb +2 -0
- data/webapp/app/helpers/application_helper.rb +2 -0
- data/webapp/app/helpers/automations_helper.rb +2 -0
- data/webapp/app/helpers/execs_helper.rb +2 -0
- data/webapp/app/helpers/scripts_helper.rb +2 -0
- data/webapp/app/helpers/settings_helper.rb +2 -0
- data/webapp/app/helpers/test_helper.rb +2 -0
- data/webapp/app/helpers/util_helper.rb +2 -0
- data/webapp/app/views/analysis/convergence.html.erb +156 -0
- data/webapp/app/views/analysis/idempotence.html.erb +2 -0
- data/webapp/app/views/execs/automation_runs.html.erb +98 -0
- data/webapp/app/views/execs/task_executions.html.erb +154 -0
- data/webapp/app/views/graph/graph_frame.html +101 -0
- data/webapp/app/views/layouts/application.html.erb +114 -0
- data/webapp/app/views/scripts/edit.html.erb +58 -0
- data/webapp/app/views/scripts/graph.html.erb +75 -0
- data/webapp/app/views/scripts/import_chef.html.erb +104 -0
- data/webapp/app/views/scripts/scripts.html.erb +116 -0
- data/webapp/app/views/scripts/tasks.html.erb +139 -0
- data/webapp/app/views/settings/containers.html.erb +161 -0
- data/webapp/app/views/settings/index.html.erb +51 -0
- data/webapp/app/views/test/cases.html.erb +2 -0
- data/webapp/app/views/test/gen.html.erb +229 -0
- data/webapp/app/views/test/suites.html.erb +205 -0
- data/webapp/app/views/util/chef.html.erb +53 -0
- data/webapp/bin/bundle +3 -0
- data/webapp/bin/rails +4 -0
- data/webapp/bin/rake +4 -0
- data/webapp/config/application.rb +28 -0
- data/webapp/config/boot.rb +18 -0
- data/webapp/config/database.yml +42 -0
- data/webapp/config/environment.rb +5 -0
- data/webapp/config/environments/development.rb +35 -0
- data/webapp/config/environments/production.rb +80 -0
- data/webapp/config/environments/test.rb +36 -0
- data/webapp/config/initializers/backtrace_silencers.rb +7 -0
- data/webapp/config/initializers/devise.rb +256 -0
- data/webapp/config/initializers/filter_parameter_logging.rb +4 -0
- data/webapp/config/initializers/inflections.rb +16 -0
- data/webapp/config/initializers/mime_types.rb +5 -0
- data/webapp/config/initializers/patches.rb +13 -0
- data/webapp/config/initializers/secret_token.rb +12 -0
- data/webapp/config/initializers/session_store.rb +6 -0
- data/webapp/config/initializers/wrap_parameters.rb +16 -0
- data/webapp/config/locales/devise.en.yml +59 -0
- data/webapp/config/locales/en.yml +23 -0
- data/webapp/config/routes.rb +113 -0
- data/webapp/config.ru +4 -0
- data/webapp/db/development.sqlite3 +0 -0
- data/webapp/db/migrate/20140624002037_devise_create_users.rb +42 -0
- data/webapp/db/migrate/20140628002058_create_all_tables.rb +159 -0
- data/webapp/db/schema.rb +162 -0
- data/webapp/db/seeds.rb +7 -0
- data/webapp/log/development.log +167823 -0
- data/webapp/public/404.html +58 -0
- data/webapp/public/422.html +58 -0
- data/webapp/public/500.html +57 -0
- data/webapp/public/favicon.ico +0 -0
- data/webapp/public/robots.txt +5 -0
- data/webapp/test/controllers/analysis_controller_test.rb +14 -0
- data/webapp/test/controllers/automations_controller_test.rb +49 -0
- data/webapp/test/controllers/execs_controller_test.rb +9 -0
- data/webapp/test/controllers/executions_controller_test.rb +9 -0
- data/webapp/test/controllers/runs_controller_test.rb +7 -0
- data/webapp/test/controllers/scripts_controller_test.rb +9 -0
- data/webapp/test/controllers/settings_controller_test.rb +9 -0
- data/webapp/test/controllers/test_controller_test.rb +14 -0
- data/webapp/test/controllers/util_controller_test.rb +9 -0
- data/webapp/test/fixtures/users.yml +11 -0
- data/webapp/test/helpers/analysis_helper_test.rb +4 -0
- data/webapp/test/helpers/automations_helper_test.rb +4 -0
- data/webapp/test/helpers/execs_helper_test.rb +4 -0
- data/webapp/test/helpers/executions_helper_test.rb +4 -0
- data/webapp/test/helpers/runs_helper_test.rb +4 -0
- data/webapp/test/helpers/scripts_helper_test.rb +4 -0
- data/webapp/test/helpers/settings_helper_test.rb +4 -0
- data/webapp/test/helpers/test_helper_test.rb +4 -0
- data/webapp/test/helpers/util_helper_test.rb +4 -0
- data/webapp/test/models/user_test.rb +7 -0
- data/webapp/test/test_helper.rb +15 -0
- data/webapp/tmp/cache/assets/development/sass/1330a34c6b24ed44c0f194c03246f627289a985a/analysis.css.scssc +0 -0
- data/webapp/tmp/cache/assets/development/sass/1330a34c6b24ed44c0f194c03246f627289a985a/automations.css.scssc +0 -0
- data/webapp/tmp/cache/assets/development/sass/1330a34c6b24ed44c0f194c03246f627289a985a/execs.css.scssc +0 -0
- data/webapp/tmp/cache/assets/development/sass/1330a34c6b24ed44c0f194c03246f627289a985a/executions.css.scssc +0 -0
- data/webapp/tmp/cache/assets/development/sass/1330a34c6b24ed44c0f194c03246f627289a985a/scripts.css.scssc +0 -0
- data/webapp/tmp/cache/assets/development/sass/1330a34c6b24ed44c0f194c03246f627289a985a/settings.css.scssc +0 -0
- data/webapp/tmp/cache/assets/development/sass/1330a34c6b24ed44c0f194c03246f627289a985a/test.css.scssc +0 -0
- data/webapp/tmp/cache/assets/development/sass/1330a34c6b24ed44c0f194c03246f627289a985a/util.css.scssc +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/06a1cdb3d5472dd126cffc18f548c342 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/0dc0562647e703ca0535da3b9fcad796 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/113f1c71cb0f2a786729477989122982 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/151a1c6b128721d8923ba0c380a2af17 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/1722fb8a6daad566c8a6d5ef31969459 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/1a05555c46560c6b246aa0a996679bc6 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/1cb7fb6aa8bd1c2b7df8f7c52442e345 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/1d76f803b0a83adc5ea7e7c848657967 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/200152f95fc464d69c425ed8fdc2fbcc +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/2049c8927ebd046c8a3291f81041d5f1 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/207907100aabd08a6767e39a95b364e3 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/249e2d4db815922fc72419c4a1407caf +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/3034e4c334b1ebed9433e33050555f18 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/316c88d859cc3666044e51b1dd89e872 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/347f43d816178c8ba11a28a771696924 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/36ab92a3b8d527ed1eff0944b5f1263d +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/3893b852ff196f05ff6ca8e38bb2237f +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/3c358bd5fa32d151c7aa44971dd9b96f +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/3ce88fad85146e0bed233f5419c24d29 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/3dabcb7c89677292e1e019a9bac446e5 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/4116fac01e6d379ede37af725a592477 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/42628e032b8f0b16a5ba01a1fcc7b6d7 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/437b258a98e8fe2c87fa8e24b7ce9abf +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/43e98ed206f05738ae305e7e1b09a840 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/468da8933ba442b88b2f4b0e40c2ac30 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/48ef3fa68e9084c7cfa84e525decc318 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/4b68dcc030691297629a7156361018dc +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/50368b1bd77c9130d821cbad89ab83ac +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/511a980807b8d16fc3fb839991041865 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/516a0973874a73d0d15feec9448f7466 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/569e21b0ca1a230c7880f8d7a8b1febf +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/5b5543d2ed5bed100f1739fc12ebf2c5 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/5c10dbffb918651dc0498579ba9a6853 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/5c366b5370316b3e9c03d1a58cb5eb44 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/5fcb9466e0d5cb0e31b35957fe2d3901 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/61da396fb86c5ecd844a2d83ac759b4b +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/624ba87170059068845a4651b3cd2c7c +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/6391f61b6121feda70da6d0a22520fdd +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/653a981829c12a52bd57b7918168a148 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/66479793d9e5683d9f7fa67522d1962d +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/69c589bd224ee0df5ab02e4568e0ab39 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/6dd7c564897b7e66eecbb180baeef2c6 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/6e2b92a4e6966cb78e63207bc7888391 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/70adb410f59a0edc5aea8c2b2ef8a441 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/72cbfd5bf33945bcce154f7a4feaf04d +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/740ee9d355ada8cf5e9beb620f2cd5cc +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/74770a22b5d1b0b3bc3527da83706f96 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/759bf97655af50852816720db7b59fcb +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/76e9c19246c684413a02af695fa2b0bc +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/7728beeace48ca12e336d2bce0158871 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/77f49730c7b689f75a2e174fbd3ace2a +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/78021a57030fd36cf82699aad9910b26 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/796b349b06da691fe5f069f9e3947fcb +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/79e7505c70697cc7d34d4a8351c3b840 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/7b2b7d9034fc7b77daf5da1436667e6f +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/7c2ea2ca2cdd89b062bf23f44e8f599c +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/7ea112af55e6df12cdff377052b71420 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/7f27632588dd316836b009a621c0176c +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/7fcef9f644290dea8d0e4bf13f6bb8e9 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/81c6bf67419a29257ed79f442c24907d +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/83656ce9260eb473c1654420e0180167 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/83e8bdddefc2dce069b56e6650135397 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/880c796f41e5d67ae68ed239acfc91e3 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/8c1c39dd537d2c9990fe9c70a5646b06 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/8d763042da5254015767385ce324b348 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/91e1ccbf65ff4d9b0f42b1159796bcf2 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/92cdfac7698b6bb68983cf317c1cedef +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/94cab8cbc120e152ce4c444492a3fc1d +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/96b918c3c041b6a089c8adc870fa3aaa +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/97cbe306627b432ab3bfb52416690d1d +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/98da83d396c0c00eb03937ecbc2e6bfa +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/9db04db20ec9c4a0f84ed01caa5e6e2b +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/9dc1c251f50c828fae95d6107619c53e +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/9e91711ab34bbf89ad1cfb4351027d36 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/9f587881f98b328b656e6456178418b5 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/9fc981560caba00621bb95d0974ad076 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/9fd4385f8fda99f3ddd3f133a89231d1 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/a32ab71649e3db15eca95bcc3a7588da +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/a497c976969bdbb1f69875358d39d3b5 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/b06058d455770c1d9db6b6670bc4bf4d +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/b3da405f1e68470ad6146a1322f2438c +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/b4ba5853663f6721d15942ce08dd76bf +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/b6f1534bcdbff92a16c85487f363235a +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/b9c57b9750f8af3551b1a5d9e27f0a92 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/bb5be6a0ee889a15214e2442aee8c6e1 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/bc80a81b2d67b5ad40f3c7a2bb6e6f22 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/bfaba27d5ce71d292f453659b0755511 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/bfac6cd2984fbd5e0d762389e3c37164 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/c17bec9e3b5db6d8385c3d6eb362e628 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/c1a9eceddc0a1e41eb2992e9204f71e6 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/c50cd87be040044504b5c3fde1047e24 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/c5907cfd07b24ad19b8c80e8af618a57 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/c8da5594caf845a183dd1c6cd45c5433 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/cbc6968ed49fa14db439a64dd0a46abc +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/cedf710ee090647b81c08675583eca62 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/cf1e3cebfad43293c3c470a5e437ebc9 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/d5a14f86bb4b422fdd8eb4722d966c9a +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/d66b9cdd3230f9e5354e495e17097c49 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/dfa0ed87d851222fe58ada385e3f037d +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/e1aa402390382db4d97b27cb094485fa +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/e4f1db35ef9d9fbbf53252a44e381eb8 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/e57eb6c1ad51fd8c13afc0e719a259b5 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/e7c37b542e914e392ec326190cea1aa2 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/e923d7e19c216d4a924831f3896e007a +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/e96a414a621483bbc89e73f11be5e7b4 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/eafcfc3d2561c18743c1b32f0f710c68 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/ecdd630f5466d45a2afa7515aaa5fc3b +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/ee60a0a35d60cff425373970547694bd +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/eee2c36b75709b0c3797c2a151fdd5d3 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/f104b66c0f89b453d0c8c73980fbab18 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/f26d1bc86590415685e9836ad75d1774 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/f4081e868eb565527099dba2c9d8c4de +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/f813030b97e30415ad276bbd1f7e1fb4 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/f8e3e28bc9640c25da58aea46c3ac4b3 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/f9169d0a8b70eaf95de52b3c6ad51105 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/f939450f7a481e3fbeb158b81b39c624 +0 -0
- data/webapp/tmp/cache/assets/development/sprockets/fce73296b8298ac4c74b3e95cde4dfdb +0 -0
- metadata +941 -0
@@ -0,0 +1,865 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
#
|
4
|
+
# Author: Waldemar Hummer (hummer@dsg.tuwien.ac.at)
|
5
|
+
#
|
6
|
+
|
7
|
+
require 'rubygems'
|
8
|
+
require 'chef/log'
|
9
|
+
require 'chef/run_context'
|
10
|
+
require 'chef/client'
|
11
|
+
require 'toaster/markup/markup_util'
|
12
|
+
|
13
|
+
# the requires below are required, otherwise:
|
14
|
+
# uninitialized constant RubyLexer::RubyParserStuff
|
15
|
+
# [...]/ruby_parser-3.1.1/lib/ruby_lexer.rb:241:in
|
16
|
+
require 'ruby_lexer'
|
17
|
+
require 'ruby_parser_extras'
|
18
|
+
class RubyLexer
|
19
|
+
begin
|
20
|
+
RubyParserStuff = Kernel.const_get("RubyParserStuff")
|
21
|
+
rescue Object => exc
|
22
|
+
begin
|
23
|
+
RubyParserStuff = ::RubyParserStuff
|
24
|
+
rescue Object => exc1
|
25
|
+
puts "WARN: Unable to load the module 'RubyParserStuff' into class RubyLexer"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
require 'ruby_parser'
|
31
|
+
require 'chef/application/solo'
|
32
|
+
require 'toaster/markup/markup_util'
|
33
|
+
require 'toaster/util/util'
|
34
|
+
require 'rexml/document'
|
35
|
+
|
36
|
+
module Toaster
|
37
|
+
class ChefUtil
|
38
|
+
@@chef_classes = {}
|
39
|
+
@@create_backups = false
|
40
|
+
|
41
|
+
#OPSCODE_API_URL = "http://cookbooks.opscode.com/api/v1/"
|
42
|
+
OPSCODE_API_URL = "https://supermarket.getchef.com/api/v1/"
|
43
|
+
OPSCODE_SEARCH_URL = "http://community.opscode.com/search"
|
44
|
+
|
45
|
+
@@DEFAULT_CHEF_DIR = "/tmp/toaster_cookbooks/"
|
46
|
+
@@DEFAULT_COOKBOOKS_DIR = "#{@@DEFAULT_CHEF_DIR}/cookbooks/"
|
47
|
+
|
48
|
+
def self.guess_cookbook_from_runlist(runlist)
|
49
|
+
guess_cookbook_or_recipe_from_runlist(runlist, "cookbook")
|
50
|
+
end
|
51
|
+
def self.guess_recipe_from_runlist(runlist)
|
52
|
+
guess_cookbook_or_recipe_from_runlist(runlist, "recipe")
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.guess_cookbook_or_recipe_from_runlist(runlist, type)
|
56
|
+
candidates = []
|
57
|
+
runlist.each do |i|
|
58
|
+
if !i.match(/toaster::testing/)
|
59
|
+
if i.include?("recipe[")
|
60
|
+
if type == "cookbook"
|
61
|
+
candidates << i.gsub(/recipe\[(.*::)*([^\]]+)\]/, '\1').gsub(/::/, '')
|
62
|
+
elsif type == "recipe"
|
63
|
+
candidates << i.gsub(/recipe\[(.*::)*([^\]]+)\]/, '\2')
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
return "default" if candidates.empty?
|
69
|
+
puts "WARN: Multiple #{type}s found in runlist #{runlist}: #{candidates}" if candidates.size > 1
|
70
|
+
return candidates[0]
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.extract_node_name(name)
|
74
|
+
short_name = name
|
75
|
+
short_name = short_name.gsub(/.*node\[(.+)\]/, '\1') if short_name.include?("node[")
|
76
|
+
return short_name
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.get_chef_log_level()
|
80
|
+
return Chef::Log.level
|
81
|
+
end
|
82
|
+
def self.set_chef_log_level(level)
|
83
|
+
Chef::Log.level = level
|
84
|
+
end
|
85
|
+
|
86
|
+
def self.get_absolute_file_path(cookbook_paths, relative_file_path)
|
87
|
+
cookbook_paths.each do |path|
|
88
|
+
f_path = File.join(path, relative_file_path)
|
89
|
+
return f_path if File.exist?(f_path)
|
90
|
+
end
|
91
|
+
return nil
|
92
|
+
end
|
93
|
+
|
94
|
+
def self.get_attribute_file(recipe_file)
|
95
|
+
attr_dir = File.join(File.dirname(recipe_file), "..", "attributes")
|
96
|
+
recipe_name = recipe_file.gsub(/.*\/([^\/]+)\.rb$/, '\1')
|
97
|
+
dflt_attr_file = File.join(attr_dir, "#{recipe_name}.rb")
|
98
|
+
return dflt_attr_file if File.exist?(dflt_attr_file)
|
99
|
+
return nil if !File.exist?(attr_dir)
|
100
|
+
content = Dir.entries(attr_dir)
|
101
|
+
content.each do |f|
|
102
|
+
if f.to_s.match(/.*\.rb$/)
|
103
|
+
return File.join(attr_dir, f)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
return nil
|
107
|
+
end
|
108
|
+
|
109
|
+
def self.wrap_node_name(node_name)
|
110
|
+
node_name = "node[#{node_name}]" if !node_name.include?("node[")
|
111
|
+
end
|
112
|
+
|
113
|
+
def self.get_reduced_run_list(run_list)
|
114
|
+
reduced_run_list = run_list.select{ |i|
|
115
|
+
!"#{i}".match(/toaster::testing/) &&
|
116
|
+
!"#{i}".match(/chef-solo-search::default/)
|
117
|
+
}
|
118
|
+
return reduced_run_list
|
119
|
+
end
|
120
|
+
|
121
|
+
def self.prepare_run_list(chef_node, run_list_hash_OR_chef_node_file)
|
122
|
+
run_list = []
|
123
|
+
|
124
|
+
#puts "run_list_hash_OR_chef_node_file - #{run_list_hash_OR_chef_node_file} - #{run_list_hash_OR_chef_node_file.class}"
|
125
|
+
if !run_list_hash_OR_chef_node_file ||
|
126
|
+
(run_list_hash_OR_chef_node_file.kind_of?(Array) && run_list_hash_OR_chef_node_file.empty?)
|
127
|
+
run_list = ["recipe[#{chef_node}::default]"]
|
128
|
+
elsif run_list_hash_OR_chef_node_file.kind_of?(Array)
|
129
|
+
run_list = run_list_hash_OR_chef_node_file
|
130
|
+
else
|
131
|
+
node_file = run_list_hash_OR_chef_node_file
|
132
|
+
if File.exist?(node_file)
|
133
|
+
run_list = JSON.parse(File.read(node_file))["run_list"]
|
134
|
+
else
|
135
|
+
run_list = [node_file]
|
136
|
+
end
|
137
|
+
end
|
138
|
+
run_list = [run_list] if !run_list.kind_of?(Array)
|
139
|
+
# append toaster::testing recipe to the beginning of the
|
140
|
+
# run list to enable the testing mechanism!
|
141
|
+
if run_list[0] != "recipe[toaster::testing]"
|
142
|
+
# due to recent changes in Chef 11, we also need to add
|
143
|
+
# chef-solo-search::default into the run_list, in order
|
144
|
+
# to load the libraries defined there (we depend on
|
145
|
+
# a library function that overwrites the search(...)
|
146
|
+
# function). More info concerning this Chef 11 change:
|
147
|
+
# http://docs.opscode.com/breaking_changes_chef_11.html#non-recipe-file-evaluation-includes-dependencies
|
148
|
+
run_list.unshift("recipe[chef-solo-search::default]")
|
149
|
+
# ... and now add toaster::testing to the beginning
|
150
|
+
run_list.unshift("recipe[toaster::testing]")
|
151
|
+
end
|
152
|
+
# ... and append toaster::testing_post to the end of the run list
|
153
|
+
if run_list[-1] != "recipe[toaster::testing_post]"
|
154
|
+
run_list << "recipe[toaster::testing_post]"
|
155
|
+
end
|
156
|
+
return run_list
|
157
|
+
end
|
158
|
+
|
159
|
+
def self.create_chef_config(solo_file)
|
160
|
+
root_dir = Util.project_root_dir()
|
161
|
+
puts "DEBUG: Writing Chef configuration (cookbook_path) to '#{solo_file}'"
|
162
|
+
Util.write(solo_file, (<<-EOF
|
163
|
+
cookbook_path [
|
164
|
+
"#{File.expand_path(File.join(Dir.pwd, "cookbooks"))}",
|
165
|
+
"#{File.expand_path(Dir.pwd)}",
|
166
|
+
"#{File.join(root_dir, "chef", "cookbooks")}",
|
167
|
+
"#{@@DEFAULT_COOKBOOKS_DIR}"
|
168
|
+
]
|
169
|
+
EOF
|
170
|
+
), true)
|
171
|
+
end
|
172
|
+
|
173
|
+
def self.run_chef(chef_solo_file, node_file, print_output=true)
|
174
|
+
cmd = "chef-solo -c #{chef_solo_file} -j #{node_file} 2>&1 | grep -v 'FATAL: No cookbook found in'"
|
175
|
+
if print_output
|
176
|
+
system(cmd)
|
177
|
+
else
|
178
|
+
`#{cmd}`
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
def self.read_sourcecode(start_source_line)
|
183
|
+
# start_source_line looks like the following example:
|
184
|
+
# /home/user/dir/file.rb:82:in `from_file'
|
185
|
+
file = get_sourcefile(start_source_line)
|
186
|
+
line = get_sourceline(start_source_line)
|
187
|
+
read_sourcecode_from_line(file, line)
|
188
|
+
end
|
189
|
+
|
190
|
+
def self.read_sourcecode_from_line(file, line)
|
191
|
+
lines = File.readlines(file)
|
192
|
+
parsed_source = nil
|
193
|
+
last_line = -1
|
194
|
+
# read the source code file line by line and attempt to parse.
|
195
|
+
for endline in line..lines.size
|
196
|
+
code = lines[(line-1)..(endline-1)].join
|
197
|
+
previous_stderr = $stderr
|
198
|
+
$stderr.sync = true
|
199
|
+
$stderr = StringIO.open('','w')
|
200
|
+
begin
|
201
|
+
|
202
|
+
parser = RubyParser.new
|
203
|
+
parser.process(code.dup)
|
204
|
+
parsed_source = code
|
205
|
+
last_line = endline
|
206
|
+
break
|
207
|
+
rescue Exception => ex
|
208
|
+
## swallow
|
209
|
+
ensure
|
210
|
+
$stderr = previous_stderr
|
211
|
+
end
|
212
|
+
end
|
213
|
+
#puts "source code, lines #{line} to #{last_line} of file #{file}:\n #{parsed_source}"
|
214
|
+
return parsed_source
|
215
|
+
end
|
216
|
+
|
217
|
+
def self.get_sourcefile(start_source_line)
|
218
|
+
l = start_source_line.split(":")
|
219
|
+
return l[0]
|
220
|
+
end
|
221
|
+
|
222
|
+
def self.get_sourceline(start_source_line)
|
223
|
+
l = start_source_line.split(":")
|
224
|
+
return l[1].to_i
|
225
|
+
end
|
226
|
+
|
227
|
+
def self.get_cookbook_download_link(name, version="latest")
|
228
|
+
url = "#{OPSCODE_API_URL}cookbooks/#{name}/versions/#{version}"
|
229
|
+
puts "DEBUG: Getting Chef cookbook metadata from URL: '#{url}'"
|
230
|
+
json = `curl #{url} 2> /dev/null`
|
231
|
+
begin
|
232
|
+
json = MarkupUtil.parse_json(json)
|
233
|
+
rescue => ex
|
234
|
+
raise "Unable to parse string as JSON (received from URL #{url}): #{json}"
|
235
|
+
end
|
236
|
+
return json["file"]
|
237
|
+
end
|
238
|
+
|
239
|
+
def self.download_cookbook_version(name, version="latest",
|
240
|
+
target_dir=@@DEFAULT_COOKBOOKS_DIR, quiet=false, num_attempts=2)
|
241
|
+
link = get_cookbook_download_link(name, version)
|
242
|
+
download_cookbook_url(link, target_dir, quiet, num_attempts)
|
243
|
+
end
|
244
|
+
|
245
|
+
# TODO remove?
|
246
|
+
def self.download_cookbook_version1(name, version="latest",
|
247
|
+
target_dir=@@DEFAULT_COOKBOOKS_DIR, quiet=false, num_attempts=2)
|
248
|
+
|
249
|
+
link = get_cookbook_download_link(name, version)
|
250
|
+
|
251
|
+
`mkdir -p '#{target_dir}'` if !File.exist?(target_dir)
|
252
|
+
tgz_file = File.join(target_dir, "#{name}.tgz")
|
253
|
+
tar_file = File.join(target_dir, "#{name}.tar")
|
254
|
+
File.delete(tar_file) if File.exist?(tar_file)
|
255
|
+
cookbook_dir = File.join(target_dir, name)
|
256
|
+
if @@create_backups
|
257
|
+
if File.exist?(cookbook_dir) && !File.exist?("#{cookbook_dir}.bak")
|
258
|
+
`mv #{cookbook_dir} #{cookbook_dir}.bak`
|
259
|
+
end
|
260
|
+
end
|
261
|
+
while num_attempts > 0
|
262
|
+
`rm -rf #{cookbook_dir}`
|
263
|
+
if !quiet
|
264
|
+
puts "DEBUG: Downloading '#{link}' to #{target_dir}"
|
265
|
+
end
|
266
|
+
error = false
|
267
|
+
`wget #{link} -O #{tgz_file} > /dev/null 2>&1`
|
268
|
+
error ||= $?.exitstatus != 0
|
269
|
+
out = `cd #{target_dir} && tar zxf #{name}.tgz`
|
270
|
+
# tar reports status code 2 in case of error...
|
271
|
+
if $?.exitstatus > 1
|
272
|
+
# sometimes, the files are in tar format,
|
273
|
+
# not in tgz format - let's give it a try!
|
274
|
+
puts "DEBUG: 'cd #{target_dir} && tar zxf #{name}.tgz' returned exit code #{$?.exitstatus}, trying to extract as tar file..."
|
275
|
+
full_file = "#{target_dir}/#{name}.tgz"
|
276
|
+
puts "DEBUG: File #{full_file} exists: #{File.exist?(full_file)}}"
|
277
|
+
out += `cd #{target_dir} && cp #{name}.tgz #{name}.tar`
|
278
|
+
out += `cd #{target_dir} && tar xf #{name}.tar`
|
279
|
+
end
|
280
|
+
error ||= $?.exitstatus > 1
|
281
|
+
break if !error
|
282
|
+
puts "WARN: Could not download/extract #{link} to #{target_dir} . Remaining attempts: #{num_attempts}"
|
283
|
+
num_attempts -= 1
|
284
|
+
sleep 2
|
285
|
+
end
|
286
|
+
|
287
|
+
return out
|
288
|
+
end
|
289
|
+
|
290
|
+
def self.download_cookbook_url(link, target_dir=@@DEFAULT_COOKBOOKS_DIR,
|
291
|
+
quiet=false, num_attempts=2)
|
292
|
+
out = ""
|
293
|
+
if !File.exist?(target_dir)
|
294
|
+
FileUtils.mkpath(target_dir)
|
295
|
+
end
|
296
|
+
cookbooks_before = Dir.entries(target_dir)
|
297
|
+
Toaster::Util.mktmpfile() { |tgz_file|
|
298
|
+
while num_attempts > 0
|
299
|
+
if !quiet
|
300
|
+
puts "DEBUG: Downloading '#{link}' to #{target_dir}"
|
301
|
+
end
|
302
|
+
error = false
|
303
|
+
`wget #{link} -O #{tgz_file} > /dev/null 2>&1`
|
304
|
+
error ||= $?.exitstatus != 0
|
305
|
+
cmd = "cd #{target_dir} && tar -z -x -f #{tgz_file}"
|
306
|
+
out = `#{cmd}`
|
307
|
+
# tar reports status code 2 in case of error...
|
308
|
+
if $?.exitstatus > 1
|
309
|
+
# sometimes, the files are in tar format,
|
310
|
+
# not in tgz format - let's give it a try!
|
311
|
+
puts "DEBUG: '#{cmd}' returned exit code #{$?.exitstatus}, trying to extract as tar file..."
|
312
|
+
#full_file = "#{target_dir}/#{name}.tgz"
|
313
|
+
#puts "DEBUG: File #{full_file} exists: #{File.exist?(full_file)}}"
|
314
|
+
#out += `cd #{target_dir} && cp #{name}.tgz #{name}.tar`
|
315
|
+
out += `cd #{target_dir} && tar -x -f #{tgz_file}`
|
316
|
+
end
|
317
|
+
error ||= $?.exitstatus > 1
|
318
|
+
break if !error
|
319
|
+
puts "WARN: Could not download/extract #{link} to #{target_dir} . Remaining attempts: #{num_attempts}"
|
320
|
+
num_attempts -= 1
|
321
|
+
sleep 2
|
322
|
+
end
|
323
|
+
}
|
324
|
+
|
325
|
+
cookbooks_after = Dir.entries(target_dir)
|
326
|
+
new_cb = cookbooks_after - cookbooks_before
|
327
|
+
puts "INFO: Downloaded and installed new cookbooks: #{new_cb}"
|
328
|
+
|
329
|
+
# download dependencies
|
330
|
+
new_cb.each do |cb|
|
331
|
+
download_dependencies(cb, nil, target_dir, true)
|
332
|
+
end
|
333
|
+
|
334
|
+
return new_cb
|
335
|
+
end
|
336
|
+
|
337
|
+
def self.fix_encodings(target_dir=@@DEFAULT_COOKBOOKS_DIR)
|
338
|
+
# add 'encoding' headers to avoid "invalid multibyte char" errors
|
339
|
+
out1 = `cd #{target_dir} && magic_encoding`
|
340
|
+
puts "DEBUG: magic_encoding: #{out1}"
|
341
|
+
end
|
342
|
+
|
343
|
+
def self.download_cookbook_url_in_lxc(lxc, link, target_dir=@@DEFAULT_COOKBOOKS_DIR)
|
344
|
+
cookbook_dir = "#{lxc['rootdir']}/#{target_dir}"
|
345
|
+
download_cookbook_url(link, cookbook_dir)
|
346
|
+
end
|
347
|
+
|
348
|
+
def self.download_cookbook_version_in_lxc(lxc, name, version="latest", target_dir=@@DEFAULT_COOKBOOKS_DIR)
|
349
|
+
cookbook_dir = "#{lxc['rootdir']}/#{target_dir}"
|
350
|
+
download_cookbook_version(name, version, cookbook_dir)
|
351
|
+
end
|
352
|
+
|
353
|
+
def self.download_latest_cookbook(name, target_dir=@@DEFAULT_COOKBOOKS_DIR)
|
354
|
+
download_cookbook_version(name, "latest", target_dir)
|
355
|
+
end
|
356
|
+
|
357
|
+
def self.download_latest_cookbook_in_lxc(lxc, name, target_dir=@@DEFAULT_COOKBOOKS_DIR)
|
358
|
+
download_cookbook_version_in_lxc(lxc, name, "latest", target_dir)
|
359
|
+
end
|
360
|
+
|
361
|
+
def self.lxc_cookbook_dir(lxc, relative_dir=@@DEFAULT_COOKBOOKS_DIR)
|
362
|
+
return "#{lxc['rootdir']}/#{relative_dir}"
|
363
|
+
end
|
364
|
+
|
365
|
+
def self.fix_known_bugs_in_recipes(cookbook_dir=@@DEFAULT_COOKBOOKS_DIR, phase="after")
|
366
|
+
|
367
|
+
if phase == "before"
|
368
|
+
puts "DEBUG: Cleaning up cookbooks directory before downloading.."
|
369
|
+
|
370
|
+
# it seems that there is an issue with hadoop_cluster/attributes/default.rb
|
371
|
+
if File.exist?("#{cookbook_dir}/hadoop_cluster")
|
372
|
+
puts "DEBUG: Removing cookbook directory #{cookbook_dir}/hadoop_cluster (bug in attributes)"
|
373
|
+
`rm -rf "#{cookbook_dir}/hadoop_cluster"`
|
374
|
+
end
|
375
|
+
|
376
|
+
elsif phase == "after"
|
377
|
+
puts "DEBUG: Fixing some known bugs in existing recipes.."
|
378
|
+
|
379
|
+
# get rid of the col on at the end of this line:
|
380
|
+
# "if (not new_resource.dependency.empty?):"
|
381
|
+
if File.exist?("#{cookbook_dir}/node/providers/nodejs.rb")
|
382
|
+
`sed -i "s/empty?):/empty?)/" #{cookbook_dir}/node/providers/nodejs.rb`
|
383
|
+
end
|
384
|
+
|
385
|
+
# recipe php::php5 doesn't exist anymore (bug in recipe cakephp::default)
|
386
|
+
if File.exist?("#{cookbook_dir}/cakephp/recipes/default.rb")
|
387
|
+
`sed -i 's/include_recipe .*php5.*$/include_recipe %w{php::default php::module_mysql}/' #{cookbook_dir}/cakephp/recipes/default.rb`
|
388
|
+
end
|
389
|
+
|
390
|
+
# cookbook "recognizer" uses old Chef syntax, incompatible with new Chef versions
|
391
|
+
if File.exist?("#{cookbook_dir}/recognizer/libraries/json_file.rb")
|
392
|
+
`sed -i 's/attribute :content, :kind_of => Hash/state_attrs :content/' #{cookbook_dir}/recognizer/libraries/json_file.rb`
|
393
|
+
end
|
394
|
+
|
395
|
+
# cookbook "netkernel" uses invalid syntax
|
396
|
+
file = "#{cookbook_dir}/netkernel/recipes/default.rb"
|
397
|
+
if File.exist?(file)
|
398
|
+
`sed -i 's/source defaults.erb/source "defaults.erb"/' #{file}`
|
399
|
+
end
|
400
|
+
|
401
|
+
# cookbook "recognizer" uses invalid syntax
|
402
|
+
file = "#{cookbook_dir}/recognizer/recipes/default.rb"
|
403
|
+
if File.exist?(file)
|
404
|
+
`sed -i 's/content recognizer_config/content recognizer_config.to_s/' #{file}`
|
405
|
+
end
|
406
|
+
|
407
|
+
# cookbook "bacula" uses invalid syntax
|
408
|
+
file = "#{cookbook_dir}/bacula/recipes/bat.rb"
|
409
|
+
if File.exist?(file)
|
410
|
+
`sed -i 's/=> n\\[/=> node[/' #{file}`
|
411
|
+
end
|
412
|
+
|
413
|
+
# cookbook "openvpn" uses invalid syntax
|
414
|
+
file = "#{cookbook_dir}/openvpn/recipes/default.rb"
|
415
|
+
if File.exist?(file)
|
416
|
+
`sed -i 's/routes.flatten\!/routes.dup.flatten\!/' #{file}`
|
417
|
+
end
|
418
|
+
|
419
|
+
# cookbook "bacula" uses invalid syntax
|
420
|
+
file = "#{cookbook_dir}/sanitize/recipes/default.rb"
|
421
|
+
if File.exist?(file)
|
422
|
+
`sed -i 's/node\\[\\'build_essential\\'][\\'compiletime\\'] = /node.set\\[\\'build_essential\\'][\\'compiletime\\'] = /' #{file}`
|
423
|
+
end
|
424
|
+
|
425
|
+
# cookbook "riak" uses invalid attribute syntax
|
426
|
+
files = ["#{cookbook_dir}/riak/attributes/kv.rb",
|
427
|
+
"#{cookbook_dir}/riak/attributes/sasl.rb",
|
428
|
+
"#{cookbook_dir}/riak/attributes/bitcask.rb"]
|
429
|
+
files.each do |file|
|
430
|
+
if File.exist?(file)
|
431
|
+
`sed -i 's/node.riak.kv.storage_backend = /set["riak"]["kv"]["storage_backend"] = /' #{file}`
|
432
|
+
`sed -i 's/node.riak.sasl.errlog_type = /set["riak"]["sasl"]["errlog_type"] = /' #{file}`
|
433
|
+
`sed -i 's/node.riak.bitcask.sync_strategy = /set["riak"]["bitcask"]["sync_strategy"] = /' #{file}`
|
434
|
+
end
|
435
|
+
end
|
436
|
+
|
437
|
+
# openldap/attributes/default.rb attempts to access node['domain'] which is nil
|
438
|
+
file = "#{cookbook_dir}/openldap/attributes/default.rb"
|
439
|
+
if File.exist?(file)
|
440
|
+
if !File.read(file).match("file_patched_for_toaster_testing")
|
441
|
+
`sed -i "1idefault['domain']='' if !node['domain']" "#{file}"`
|
442
|
+
`sed -i "2i#file_patched_for_toaster_testing" "#{file}"`
|
443
|
+
end
|
444
|
+
end
|
445
|
+
|
446
|
+
# fix new syntax of resource notifications
|
447
|
+
files = ["apache2/definitions/apache_site.rb", "tomcat6/recipes/default.rb"]
|
448
|
+
files.each do |file|
|
449
|
+
file = "#{cookbook_dir}/#{file}"
|
450
|
+
if File.exist?(file)
|
451
|
+
`sed -i 's/resources(:\\([a-z_]*\\) => "\\([^"]*\\)")/"\\1[\\2]"/g' "#{file}"`
|
452
|
+
end
|
453
|
+
end
|
454
|
+
|
455
|
+
# new attribute access in Chef 11
|
456
|
+
file = "#{cookbook_dir}/kafka/recipes/default.rb"
|
457
|
+
if File.exist?(file)
|
458
|
+
`sed -i "s/node\\\\[:kafka\\\\]\\\\[:broker_host_name\\\\] =/node.set[:kafka][:broker_host_name] =/" "#{file}"`
|
459
|
+
`sed -i "s/node\\\\[:kafka\\\\]\\\\[:broker_id\\\\] =/node.set[:kafka][:broker_id] =/" "#{file}"`
|
460
|
+
end
|
461
|
+
file = "#{cookbook_dir}/network_interfaces/recipes/default.rb"
|
462
|
+
if File.exist?(file)
|
463
|
+
`sed -i 's/node\\["network_interfaces"\\]\\["order"\\]=/node.set["network_interfaces"]["order"]=/' "#{file}"`
|
464
|
+
end
|
465
|
+
|
466
|
+
# add cookbook dependencies
|
467
|
+
dependencies = { "vmware" => ["apt"],
|
468
|
+
"maven" => ["ark"],
|
469
|
+
"sonar" => ["ark", "maven"],
|
470
|
+
"eaccelerator" => ["apache2"],
|
471
|
+
"netkernel" => ["apache"],
|
472
|
+
"chef-client-cron" => ["chef-client"]
|
473
|
+
}
|
474
|
+
dependencies.each do |cb,deps|
|
475
|
+
deps.each do |dep|
|
476
|
+
# add dependency to cookbook metadata
|
477
|
+
file1 = "#{cookbook_dir}/#{dep}/"
|
478
|
+
file2 = "#{cookbook_dir}/#{cb}/metadata.rb"
|
479
|
+
if File.exist?(file1) && File.exist?(file2)
|
480
|
+
if !File.read(file2).match(/depends\s+["']#{dep}["']/)
|
481
|
+
`echo '' >> "#{file2}"`
|
482
|
+
`echo 'depends "#{dep}"' >> "#{file2}"`
|
483
|
+
end
|
484
|
+
end
|
485
|
+
end
|
486
|
+
end
|
487
|
+
|
488
|
+
# fix encodings in cookbook files
|
489
|
+
fix_encodings(cookbook_dir)
|
490
|
+
end
|
491
|
+
|
492
|
+
end
|
493
|
+
|
494
|
+
def self.download_dependencies(cookbook, recipe, cookbook_dir=@@DEFAULT_COOKBOOKS_DIR,
|
495
|
+
overwrite_all=false, downloaded_so_far=[], parsed_so_far=[])
|
496
|
+
|
497
|
+
includes = []
|
498
|
+
if recipe
|
499
|
+
|
500
|
+
include_commands = "((include_recipe)|(include_attribute)|(include_library))"
|
501
|
+
|
502
|
+
recipe_files = []
|
503
|
+
recipe = recipe.split("::")[1] if recipe.include?("::")
|
504
|
+
recipe_files << File.join(cookbook_dir, cookbook, "recipes", "#{recipe}.rb")
|
505
|
+
|
506
|
+
recipe_files.each do |recipe_file|
|
507
|
+
|
508
|
+
if !File.exist?(recipe_file)
|
509
|
+
puts "WARN: Expected recipe file does not exist: #{recipe_file}"
|
510
|
+
return
|
511
|
+
end
|
512
|
+
file = File.read(recipe_file)
|
513
|
+
parsed_so_far << "#{cookbook}::#{recipe}"
|
514
|
+
file.scan(/(#{include_commands}[\s'"]+.*)$/) { |rec,total_match|
|
515
|
+
tmp_includes = []
|
516
|
+
# use eval(..) to handle cases like the following:
|
517
|
+
# include_recipe %w{apache2 apache2::mod_php5}
|
518
|
+
# include_recipe "apache2"
|
519
|
+
# include_recipe ["apache2", "apache2::mod_php5"]
|
520
|
+
rec.sub!(/#{include_commands}/, "tmp_includes=")
|
521
|
+
begin
|
522
|
+
eval(rec)
|
523
|
+
rescue => ex
|
524
|
+
puts "WARN: Unable to evaluate expression while parsing Chef recipe dependencies in file #{recipe_file}: '#{rec}': #{ex}"
|
525
|
+
# this could be a case like the following:
|
526
|
+
# include_recipe "nodejs::install_from_#{node['nodejs']['install_method']}"
|
527
|
+
rec.scan(/["'](.*)::([^"']*)["']/) { |cb,rc|
|
528
|
+
if rc.match(/^[a-z_\-A-Z0-9\.]+$/)
|
529
|
+
tmp_includes << "#{cb}::#{rc}"
|
530
|
+
else
|
531
|
+
available_recipes_for_cookbook(cb, cookbook_dir).each do |rec_hash|
|
532
|
+
tmp_includes << "#{cb}::#{rec_hash['recipe_name']}"
|
533
|
+
end
|
534
|
+
end
|
535
|
+
}
|
536
|
+
end
|
537
|
+
tmp_includes = [tmp_includes] if !tmp_includes.kind_of?(Array)
|
538
|
+
includes.concat(tmp_includes)
|
539
|
+
}
|
540
|
+
end
|
541
|
+
|
542
|
+
end
|
543
|
+
|
544
|
+
# additionally, load dependencies from metadata files
|
545
|
+
metadata_json = File.join(cookbook_dir, cookbook, "metadata.json")
|
546
|
+
if File.exist?(metadata_json)
|
547
|
+
#puts "DEBUG: Reading dependencies from '#{metadata_json}'"
|
548
|
+
json = MarkupUtil.parse_json(File.read(metadata_json))
|
549
|
+
if json["dependencies"]
|
550
|
+
json["dependencies"].each do |dep_cb,dep_version|
|
551
|
+
includes << dep_cb if !includes.include?(dep_cb)
|
552
|
+
end
|
553
|
+
end
|
554
|
+
end
|
555
|
+
metadata_rb = File.join(cookbook_dir, cookbook, "metadata.rb")
|
556
|
+
#puts "DEBUG: Reading dependencies from '#{metadata_rb}'"
|
557
|
+
if File.exist?(metadata_rb)
|
558
|
+
file = File.read(metadata_rb)
|
559
|
+
file.scan(/depends\s+["']([^"']+)["']/) { |dep_cb,total_string|
|
560
|
+
includes << dep_cb if !includes.include?(dep_cb)
|
561
|
+
}
|
562
|
+
end
|
563
|
+
|
564
|
+
puts "INFO: Recipe #{cookbook}::#{recipe} depends on: #{includes.inspect}" if !includes.empty?
|
565
|
+
includes.each do |i|
|
566
|
+
dep_recipe = i.include?("::") ? i.split("::")[1] : "default"
|
567
|
+
dep_book = i.include?("::") ? i.split("::")[0] : i
|
568
|
+
dep_file = File.join(cookbook_dir, dep_book, "recipes", "#{dep_recipe}.rb")
|
569
|
+
if parsed_so_far.include?("#{dep_book}::#{dep_recipe}") ||
|
570
|
+
downloaded_so_far.include?(dep_book)
|
571
|
+
#puts "INFO: possible loop detected in cookbook dependencies for #{cookbook}::#{dep_recipe}: #{dep_book.inspect}. Stopping recursive lookup at this point."
|
572
|
+
else
|
573
|
+
downloaded_so_far << dep_book
|
574
|
+
if !File.exist?(dep_file) || overwrite_all
|
575
|
+
download_latest_cookbook(dep_book, cookbook_dir)
|
576
|
+
end
|
577
|
+
# recursively download cookbook dependencies
|
578
|
+
#puts "DEBUG: Recursively downloading dependencies for '#{dep_book}::#{dep_recipe}'"
|
579
|
+
download_dependencies(dep_book, dep_recipe, cookbook_dir, overwrite_all, downloaded_so_far, parsed_so_far)
|
580
|
+
end
|
581
|
+
end
|
582
|
+
end
|
583
|
+
|
584
|
+
def self.available_recipes_for_cookbook(cookbook_name, cookbooks_dir=@@DEFAULT_COOKBOOKS_DIR)
|
585
|
+
result = []
|
586
|
+
out = `ls #{cookbooks_dir}/#{cookbook_name}/recipes`
|
587
|
+
out = out.strip.split(/\s+/)
|
588
|
+
out.each do |file|
|
589
|
+
recipe = file.sub(/(.*)\.rb/, '\1')
|
590
|
+
result << { "recipe_name" => recipe }
|
591
|
+
end
|
592
|
+
return result
|
593
|
+
end
|
594
|
+
|
595
|
+
def self.available_recipes_from_opscode(cookbook_name, version="latest",
|
596
|
+
overwrite_downloads=false, target_dir="/tmp/opscode_cookbooks/")
|
597
|
+
if target_dir
|
598
|
+
FileUtils.mkpath(target_dir) if !File.directory?(target_dir)
|
599
|
+
# check if cookbook folder already exists
|
600
|
+
cookbook_folder = File.join(target_dir, cookbook_name)
|
601
|
+
if File.directory?(cookbook_folder) && overwrite_downloads
|
602
|
+
FileUtils.rm_rf(cookbook_folder)
|
603
|
+
end
|
604
|
+
if !File.directory?(cookbook_folder)
|
605
|
+
download_cookbook_version(cookbook_name, version, target_dir, true)
|
606
|
+
end
|
607
|
+
return available_recipes_for_cookbook(cookbook_name, target_dir)
|
608
|
+
else
|
609
|
+
Util.mktmpdir() { |file|
|
610
|
+
download_cookbook_version(cookbook_name, version, file, true)
|
611
|
+
return available_recipes_for_cookbook(cookbook_name, file)
|
612
|
+
}
|
613
|
+
end
|
614
|
+
end
|
615
|
+
|
616
|
+
def self.runtime_resource_sourcecode(resource)
|
617
|
+
return resource.to_text if resource.respond_to?("to_text")
|
618
|
+
end
|
619
|
+
|
620
|
+
def self.available_cookbooks_from_opscode(query_details=false, overwrite_downloads=false)
|
621
|
+
result = []
|
622
|
+
tmpmap = {}
|
623
|
+
max = 1000
|
624
|
+
start = 0
|
625
|
+
while start < max
|
626
|
+
url = "#{OPSCODE_API_URL}cookbooks?start=#{start}&items=100"
|
627
|
+
json = `curl '#{url}' 2> /dev/null`
|
628
|
+
books = MarkupUtil.parse_json(json.strip)
|
629
|
+
if books["items"].kind_of?(Array)
|
630
|
+
result.concat(books["items"])
|
631
|
+
books["items"].each do |item|
|
632
|
+
tmpmap[item["cookbook_name"]] = item
|
633
|
+
end
|
634
|
+
end
|
635
|
+
max = books["total"].to_i if books["total"] && books["total"].to_i > 0 && books["total"].to_i < 2000
|
636
|
+
start += 100
|
637
|
+
end
|
638
|
+
if query_details
|
639
|
+
# download all (!) cookbooks from opscode
|
640
|
+
download_all_from_opscode(nil, overwrite_downloads)
|
641
|
+
# get information about all resources
|
642
|
+
resources = parse_all_resources("*.rb")
|
643
|
+
|
644
|
+
begin
|
645
|
+
html = `curl '#{OPSCODE_SEARCH_URL}?page=1' 2> /dev/null`
|
646
|
+
doc = Toaster::MarkupUtil.parse_xml(html, true)
|
647
|
+
|
648
|
+
num_pages = REXML::XPath.match(doc, "//a[text()='Next']/preceding-sibling::a[1]/text()")
|
649
|
+
num_pages = "#{num_pages[0]}".to_i
|
650
|
+
(2..num_pages).each do |page_num|
|
651
|
+
REXML::XPath.match(doc, "//ul[@class='cookbook-list']/li").each do |cbxml|
|
652
|
+
cbxml = REXML::Document.new cbxml.to_s
|
653
|
+
title = REXML::XPath.match(cbxml, "//a[@class='title']/text()")[0]
|
654
|
+
title = "#{title}".strip
|
655
|
+
if tmpmap[title]
|
656
|
+
ratings = REXML::XPath.match(cbxml, "//span[@class='count']/text()")[0]
|
657
|
+
downloads = REXML::XPath.match(cbxml, "//div[@class='downloads']/text()")[0]
|
658
|
+
followers = REXML::XPath.match(cbxml, "//div[@class='followers']/text()")[0]
|
659
|
+
platforms = REXML::XPath.match(cbxml, "//div[@class='platforms']/p/text()")[0]
|
660
|
+
category = REXML::XPath.match(cbxml, "//div[@class='category']/a/text()")[0]
|
661
|
+
ratings = "#{ratings}".gsub(/(\\n)|\s*/, "").gsub(/rating(s)*/, "").strip.to_i
|
662
|
+
downloads = "#{downloads}".gsub(/(\\n)|\s*/, "").gsub(/download(s)*/, "").strip.to_i
|
663
|
+
followers = "#{followers}".gsub(/(\\n)|\s*/, "").gsub(/follower(s)*/, "").strip.to_i
|
664
|
+
platforms = "#{platforms}".gsub(/\\n/, "").gsub(/Platforms:/, "").gsub(">", ">").strip
|
665
|
+
category = "#{category}".gsub(/\\n/, "").gsub("&", "&").strip
|
666
|
+
#puts "ratings #{title}: #{ratings} - #{downloads} - #{followers} - #{platforms} - #{category}"
|
667
|
+
tmpmap[title]["_ratings"] = ratings
|
668
|
+
tmpmap[title]["_downloads"] = downloads
|
669
|
+
tmpmap[title]["_followers"] = followers
|
670
|
+
tmpmap[title]["_platforms"] = platforms
|
671
|
+
tmpmap[title]["_category"] = category
|
672
|
+
end
|
673
|
+
end
|
674
|
+
html = `curl '#{OPSCODE_SEARCH_URL}?page=#{page_num}' 2> /dev/null`
|
675
|
+
doc = Toaster::MarkupUtil.parse_xml(html, true)
|
676
|
+
end
|
677
|
+
result.each do |cbook|
|
678
|
+
fetch_cookbook_details(cbook["cookbook_name"], cbook, resources)
|
679
|
+
end
|
680
|
+
rescue Object => exc
|
681
|
+
puts "WARN: Exception when querying cookbook details from #{OPSCODE_SEARCH_URL}?page=1: #{exc} - #{exc.backtrace}"
|
682
|
+
end
|
683
|
+
# sort results
|
684
|
+
result.sort! { |a,b|
|
685
|
+
a["_downloads"] = 0 if !a["_downloads"]
|
686
|
+
b["_downloads"] = 0 if !b["_downloads"]
|
687
|
+
a["_average_rating"] = 0 if !a["_average_rating"]
|
688
|
+
b["_average_rating"] = 0 if !b["_average_rating"]
|
689
|
+
(b["_downloads"] <=> a["_downloads"]) != 0 ?
|
690
|
+
b["_downloads"] <=> a["_downloads"] :
|
691
|
+
b["_average_rating"] <=> a["_average_rating"]
|
692
|
+
}
|
693
|
+
result.each_with_index do |cb,idx|
|
694
|
+
cb["_position"] = idx + 1
|
695
|
+
end
|
696
|
+
end
|
697
|
+
return result
|
698
|
+
end
|
699
|
+
|
700
|
+
def self.fetch_cookbook_details(cookbook_name, cbook={}, resources={}, overwrite_downloads=false)
|
701
|
+
url = "#{OPSCODE_API_URL}cookbooks/#{cookbook_name}/"
|
702
|
+
json = `curl '#{url}' 2> /dev/null`
|
703
|
+
details = MarkupUtil.parse_json(json.strip)
|
704
|
+
latest_version = details['latest_version'].gsub(/.*\/([^\/]+)/, '\1')
|
705
|
+
cbook['_latest_version'] = latest_version
|
706
|
+
versions = []
|
707
|
+
details['versions'].each do |ver|
|
708
|
+
versions << ver.gsub(/.*\/([^\/]+)/, '\1')
|
709
|
+
end
|
710
|
+
cbook["_versions"] = versions
|
711
|
+
if !details["average_rating"].nil?
|
712
|
+
cbook["_average_rating"] = details["average_rating"]
|
713
|
+
end
|
714
|
+
# load all recipe names for this cookbook
|
715
|
+
if !cbook["_recipes"]
|
716
|
+
cb_name = cookbook_name
|
717
|
+
recipes = Toaster::ChefUtil.available_recipes_from_opscode(
|
718
|
+
cb_name, cbook["_latest_version"], overwrite_downloads)
|
719
|
+
cbook["_recipes"] = {} if !cbook["_recipes"]
|
720
|
+
recipe_names = []
|
721
|
+
recipes.each do |r|
|
722
|
+
rec_name = r["recipe_name"]
|
723
|
+
recipe_names << rec_name
|
724
|
+
cbook["_recipes"][rec_name] = {}
|
725
|
+
cbook["_recipes"][rec_name]["_resource_names"] = []
|
726
|
+
if resources[cb_name] && resources[cb_name][rec_name]
|
727
|
+
if resources[cb_name][rec_name]["_possibly_non_idempotent"]
|
728
|
+
cbook["_possibly_non_idempotent"] = true
|
729
|
+
end
|
730
|
+
resources[cb_name][rec_name]["resources"].each do |line,code|
|
731
|
+
if code
|
732
|
+
code = code.split("\n")[0]
|
733
|
+
resrc_name = code.gsub(/^\s*([a-zA-Z0-9_\-]*)\s+(.*)\s+((do)|\{).*$/, '\1[\2]')
|
734
|
+
resrc_name = resrc_name.strip
|
735
|
+
#puts "TRACE: resource name: #{resrc_name}"
|
736
|
+
cbook["_recipes"][rec_name]["_resource_names"] << resrc_name
|
737
|
+
end
|
738
|
+
end
|
739
|
+
else
|
740
|
+
puts "WARN: Did not find detailed Chef resource information for '#{cb_name}'::'#{rec_name}'"
|
741
|
+
end
|
742
|
+
end
|
743
|
+
cbook["_recipe_names"] = recipe_names
|
744
|
+
end
|
745
|
+
return cbook
|
746
|
+
end
|
747
|
+
|
748
|
+
def self.available_cookbook_versions(cookbook_name)
|
749
|
+
fetch_cookbook_details(cookbook_name)["_versions"].uniq
|
750
|
+
end
|
751
|
+
|
752
|
+
def self.download_all_from_opscode(target_dir="/tmp/opscode_cookbooks/", overwrite_downloads=false)
|
753
|
+
target_dir = "/tmp/opscode_cookbooks/" if !target_dir
|
754
|
+
if overwrite_downloads || !File.exist?(target_dir)
|
755
|
+
`mkdir -p "#{target_dir}"`
|
756
|
+
cookbooks = available_cookbooks_from_opscode()
|
757
|
+
cookbooks.each do |cb|
|
758
|
+
cookbook_name = cb["cookbook_name"]
|
759
|
+
#puts "downloading cookbook #{cookbook_name} to #{target_dir}"
|
760
|
+
download_cookbook_version(cookbook_name, "latest", target_dir, true)
|
761
|
+
end
|
762
|
+
end
|
763
|
+
end
|
764
|
+
|
765
|
+
def self.parse_resources(cookbook, recipe_name, version="latest", result = {}, cookbook_dir="/tmp/opscode_cookbooks/")
|
766
|
+
recipe_file = "#{cookbook_dir}/#{cookbook}/recipes/#{recipe_name}.rb"
|
767
|
+
attributes_file = "#{cookbook_dir}/#{cookbook}/attributes/#{recipe_name}.rb"
|
768
|
+
recipe_file_relative = "#{cookbook}/recipes/#{recipe_name}.rb"
|
769
|
+
attributes_source = File.exist?(attributes_file) ? File.read(attributes_file) : ""
|
770
|
+
|
771
|
+
if !File.exist?(recipe_file)
|
772
|
+
download_cookbook_version(cookbook, version, cookbook_dir)
|
773
|
+
end
|
774
|
+
|
775
|
+
puts "TRACE: Scanning recipe file: #{recipe_file}"
|
776
|
+
resource_lines = []
|
777
|
+
script_resource_lines = []
|
778
|
+
result[cookbook] = {} if !result[cookbook]
|
779
|
+
result[cookbook][recipe_name] = {} if !result[cookbook][recipe_name]
|
780
|
+
result[cookbook][recipe_name]["file"] = recipe_file_relative
|
781
|
+
result[cookbook][recipe_name]["resources"] = {} if !result[cookbook][recipe_name]["resources"]
|
782
|
+
result[cookbook][recipe_name]["resource_objs"] = {} if !result[cookbook][recipe_name]["resource_objs"]
|
783
|
+
|
784
|
+
# resource names taken from
|
785
|
+
# http://docs.opscode.com/resource.html
|
786
|
+
# http://wiki.opscode.com/display/chef/Resources
|
787
|
+
resource_names = ["apt_package", "bash", "chef_gem", "csh", "cron", "deploy",
|
788
|
+
"directory", "dpkg_package", "easy_install_package", "env", "erlang_call", "erl_call",
|
789
|
+
"execute", "file", "freebsd_package", "gem_package", "git", "group", "http_request",
|
790
|
+
"ifconfig", "link", "log", "macports_package", "mdadm", "mount", "ohai", "package", "perl",
|
791
|
+
"portage_package", "powershell_script", "python", "remote_directory", "remote_file", "route",
|
792
|
+
"rpm_package", "ruby_block", "ruby", "scm", "script", "service", "solaris_package",
|
793
|
+
"template", "user", "yum_package", "zypper_package",
|
794
|
+
"mysql_service" # additional resource types
|
795
|
+
]
|
796
|
+
script_resource_names = ["execute", "bash", "script", "ruby_block", "csh"]
|
797
|
+
|
798
|
+
File.open(recipe_file) do |io|
|
799
|
+
io.each_with_index { |line,idx|
|
800
|
+
#if line.match(/^\s*((#{resource_names.join(")|(")}))\s+.*((do)|(\{)).*$/)
|
801
|
+
if line.match(/^(\s*[0-9a-zA-Z_]+\s*=\s*)?\s*((#{resource_names.join(")|(")}))((\s+)|($)|(\s*\())/)
|
802
|
+
resource_lines << idx
|
803
|
+
elsif line.match(/execute.*do/) && !line.match(/^\s*#/)
|
804
|
+
puts "WARN: NO resource line: #{line}"
|
805
|
+
end
|
806
|
+
}
|
807
|
+
resource_lines.each do |line|
|
808
|
+
code = read_sourcecode_from_line(recipe_file, line + 1)
|
809
|
+
if !code
|
810
|
+
puts "WARN: Could not parse code file #{recipe_file} : #{line + 1}"
|
811
|
+
else
|
812
|
+
resource_obj = ResourceInspector.get_resource_from_source(code, attributes_source)
|
813
|
+
puts "received resource_obj: #{resource_obj}"
|
814
|
+
result[cookbook][recipe_name]["resources"][line] = code
|
815
|
+
result[cookbook][recipe_name]["resource_objs"][line] = resource_obj
|
816
|
+
if !code.match(/not_if\s*/) && !code.match(/only_if\s*/)
|
817
|
+
resource_type = code.split("\n")[0].gsub(/^\s*([a-zA-Z0-9_\-]*)\s+(.*)\s+((do)|\{).*$/, '\1')
|
818
|
+
if script_resource_names.include?(resource_type)
|
819
|
+
result[cookbook][recipe_name]["_possibly_non_idempotent"] = true
|
820
|
+
end
|
821
|
+
end
|
822
|
+
end
|
823
|
+
end
|
824
|
+
end
|
825
|
+
return result
|
826
|
+
end
|
827
|
+
|
828
|
+
def self.parse_all_resources(recipe_pattern="default.rb", cookbook_dir="/tmp/opscode_cookbooks/")
|
829
|
+
# cookbook_name -> recipe_file -> line_no -> resource_code
|
830
|
+
result = {}
|
831
|
+
scanned_files = 0
|
832
|
+
Dir.entries(cookbook_dir).each do |cookbook|
|
833
|
+
if cookbook.match(/^[a-zA-Z0-9_\-]+$/)
|
834
|
+
recipe_dir = "#{cookbook_dir}/#{cookbook}/recipes"
|
835
|
+
Dir["#{recipe_dir}/#{recipe_pattern}"].each do |recipe_file|
|
836
|
+
recipe_name = recipe_file.gsub(/.*\/([^\/]+)\.rb$/, '\1')
|
837
|
+
parse_resources(cookbook, recipe_name, "latest", result, cookbook_dir)
|
838
|
+
scanned_files += 1
|
839
|
+
end
|
840
|
+
end
|
841
|
+
end
|
842
|
+
puts "INFO: Scanned #{scanned_files} files for resource information."
|
843
|
+
return result
|
844
|
+
end
|
845
|
+
|
846
|
+
def self.diff_cookbook_versions(cookb, v1, v2)
|
847
|
+
v1.gsub!(".", "_")
|
848
|
+
v2.gsub!(".", "_")
|
849
|
+
target_dir = "/tmp/toaster/tmp_chef_cb/#{cookb}"
|
850
|
+
dir1 = "#{target_dir}/#{v1}"
|
851
|
+
dir2 = "#{target_dir}/#{v2}"
|
852
|
+
`mkdir -p '#{target_dir}'`
|
853
|
+
if !File.directory?(dir1)
|
854
|
+
`mkdir -p '#{dir1}'`
|
855
|
+
download_cookbook_version(cookb, v1, dir1)
|
856
|
+
end
|
857
|
+
if !File.directory?(dir2)
|
858
|
+
`mkdir -p '#{dir2}'`
|
859
|
+
download_cookbook_version(cookb, v2, dir2)
|
860
|
+
end
|
861
|
+
return Util.diff_dirs(dir1, dir2)
|
862
|
+
end
|
863
|
+
|
864
|
+
end
|
865
|
+
end
|