foreman_pipeline 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/LICENSE +674 -0
- data/README.md +36 -0
- data/Rakefile +40 -0
- data/app/assets/javascripts/foreman_pipeline/foreman_pipeline-bootstrap.js +8 -0
- data/app/assets/javascripts/foreman_pipeline/foreman_pipeline.js +20 -0
- data/app/assets/javascripts/foreman_pipeline/jenkins-instances/details/jenkins-instance-details-info.controller.js +46 -0
- data/app/assets/javascripts/foreman_pipeline/jenkins-instances/details/jenkins-instance-details-users.controller.js +72 -0
- data/app/assets/javascripts/foreman_pipeline/jenkins-instances/details/jenkins-instance-details.controller.js +40 -0
- data/app/assets/javascripts/foreman_pipeline/jenkins-instances/details/views/jenkins-instance-details-info.html +36 -0
- data/app/assets/javascripts/foreman_pipeline/jenkins-instances/details/views/jenkins-instance-details-users.html +107 -0
- data/app/assets/javascripts/foreman_pipeline/jenkins-instances/details/views/jenkins-instance-details.html +53 -0
- data/app/assets/javascripts/foreman_pipeline/jenkins-instances/jenkins-instances.controller.js +34 -0
- data/app/assets/javascripts/foreman_pipeline/jenkins-instances/jenkins-instances.factory.js +14 -0
- data/app/assets/javascripts/foreman_pipeline/jenkins-instances/jenkins-instances.module.js +93 -0
- data/app/assets/javascripts/foreman_pipeline/jenkins-instances/new/new-jenkins-instance.controller.js +40 -0
- data/app/assets/javascripts/foreman_pipeline/jenkins-instances/new/views/new-jenkins-instance-form.html +50 -0
- data/app/assets/javascripts/foreman_pipeline/jenkins-instances/new/views/new-jenkins-instance.html +16 -0
- data/app/assets/javascripts/foreman_pipeline/jenkins-instances/views/jenkins-instances-table-collapsed.html +20 -0
- data/app/assets/javascripts/foreman_pipeline/jenkins-instances/views/jenkins-instances-table-full.html +30 -0
- data/app/assets/javascripts/foreman_pipeline/jenkins-instances/views/jenkins-instances.html +17 -0
- data/app/assets/javascripts/foreman_pipeline/jenkins-project-params/jenkins-project-params.factory.js +11 -0
- data/app/assets/javascripts/foreman_pipeline/jenkins-project-params/jenkins-project-params.module.js +6 -0
- data/app/assets/javascripts/foreman_pipeline/jenkins-projects/jenkins-projects.factory.js +9 -0
- data/app/assets/javascripts/foreman_pipeline/jenkins-projects/jenkins-projects.module.js +10 -0
- data/app/assets/javascripts/foreman_pipeline/jenkins-requests/jenkins-requests.factory.js +11 -0
- data/app/assets/javascripts/foreman_pipeline/jenkins-requests/jenkins-requests.module.js +10 -0
- data/app/assets/javascripts/foreman_pipeline/jenkins-users/details/jenkins-user-info.controller.js +39 -0
- data/app/assets/javascripts/foreman_pipeline/jenkins-users/details/views/jenkins-user-info.html +37 -0
- data/app/assets/javascripts/foreman_pipeline/jenkins-users/jenkins-users.factory.js +10 -0
- data/app/assets/javascripts/foreman_pipeline/jenkins-users/jenkins-users.module.js +6 -0
- data/app/assets/javascripts/foreman_pipeline/jenkins-users/new/new-jenkins-user.controller.js +45 -0
- data/app/assets/javascripts/foreman_pipeline/jenkins-users/new/views/new-jenkins-user.html +32 -0
- data/app/assets/javascripts/foreman_pipeline/jobs/details/job-details-add-paths.controller.js +63 -0
- data/app/assets/javascripts/foreman_pipeline/jobs/details/job-details-content-views.controller.js +55 -0
- data/app/assets/javascripts/foreman_pipeline/jobs/details/job-details-environments.controller.js +56 -0
- data/app/assets/javascripts/foreman_pipeline/jobs/details/job-details-hostgroups.controller.js +59 -0
- data/app/assets/javascripts/foreman_pipeline/jobs/details/job-details-info.controller.js +69 -0
- data/app/assets/javascripts/foreman_pipeline/jobs/details/job-details-jenkins-projects.controller.js +49 -0
- data/app/assets/javascripts/foreman_pipeline/jobs/details/job-details-jenkins.controller.js +56 -0
- data/app/assets/javascripts/foreman_pipeline/jobs/details/job-details-resources.controller.js +60 -0
- data/app/assets/javascripts/foreman_pipeline/jobs/details/job-details-to-environments.controller.js +157 -0
- data/app/assets/javascripts/foreman_pipeline/jobs/details/job-details.controller.js +34 -0
- data/app/assets/javascripts/foreman_pipeline/jobs/details/project-discovery/job-projects-discovery.controller.js +96 -0
- data/app/assets/javascripts/foreman_pipeline/jobs/details/project-discovery/job-projects-parameters.controller.js +54 -0
- data/app/assets/javascripts/foreman_pipeline/jobs/details/project-discovery/views/job-jenkins-projects.html +1 -0
- data/app/assets/javascripts/foreman_pipeline/jobs/details/project-discovery/views/job-projects-discovery.html +91 -0
- data/app/assets/javascripts/foreman_pipeline/jobs/details/project-discovery/views/job-projects-parameters.html +77 -0
- data/app/assets/javascripts/foreman_pipeline/jobs/details/views/job-details-content-views.html +83 -0
- data/app/assets/javascripts/foreman_pipeline/jobs/details/views/job-details-environments.html +50 -0
- data/app/assets/javascripts/foreman_pipeline/jobs/details/views/job-details-hostgroups.html +81 -0
- data/app/assets/javascripts/foreman_pipeline/jobs/details/views/job-details-info.html +117 -0
- data/app/assets/javascripts/foreman_pipeline/jobs/details/views/job-details-jenkins-projects.html +75 -0
- data/app/assets/javascripts/foreman_pipeline/jobs/details/views/job-details-jenkins.html +88 -0
- data/app/assets/javascripts/foreman_pipeline/jobs/details/views/job-details-paths-list.html +72 -0
- data/app/assets/javascripts/foreman_pipeline/jobs/details/views/job-details-resources.html +86 -0
- data/app/assets/javascripts/foreman_pipeline/jobs/details/views/job-details-to-environments.html +51 -0
- data/app/assets/javascripts/foreman_pipeline/jobs/details/views/job-details.html +80 -0
- data/app/assets/javascripts/foreman_pipeline/jobs/jobs.controller.js +40 -0
- data/app/assets/javascripts/foreman_pipeline/jobs/jobs.factory.js +54 -0
- data/app/assets/javascripts/foreman_pipeline/jobs/jobs.module.js +142 -0
- data/app/assets/javascripts/foreman_pipeline/jobs/new/new-job.controller.js +31 -0
- data/app/assets/javascripts/foreman_pipeline/jobs/new/views/new-job-form.html +47 -0
- data/app/assets/javascripts/foreman_pipeline/jobs/new/views/new-job.html +17 -0
- data/app/assets/javascripts/foreman_pipeline/jobs/views/jobs-table-collapsed.html +20 -0
- data/app/assets/javascripts/foreman_pipeline/jobs/views/jobs-table-full.html +66 -0
- data/app/assets/javascripts/foreman_pipeline/jobs/views/jobs.html +19 -0
- data/app/assets/javascripts/foreman_pipeline/jobs/views/pln-path-selector.html +10 -0
- data/app/assets/stylesheets/foreman_pipeline/foreman_pipeline.css +13 -0
- data/app/controllers/foreman_pipeline/api/jenkins_instances_controller.rb +124 -0
- data/app/controllers/foreman_pipeline/api/jenkins_project_params_controller.rb +34 -0
- data/app/controllers/foreman_pipeline/api/jenkins_projects_controller.rb +29 -0
- data/app/controllers/foreman_pipeline/api/jenkins_requests_controller.rb +28 -0
- data/app/controllers/foreman_pipeline/api/jenkins_users_controller.rb +89 -0
- data/app/controllers/foreman_pipeline/api/jobs_controller.rb +271 -0
- data/app/controllers/foreman_pipeline/application_controller.rb +4 -0
- data/app/helpers/foreman_pipeline/application_helper.rb +4 -0
- data/app/lib/actions/foreman_pipeline/jenkins/abstract_jenkins_action.rb +20 -0
- data/app/lib/actions/foreman_pipeline/jenkins/build.rb +35 -0
- data/app/lib/actions/foreman_pipeline/jenkins/build_project.rb +31 -0
- data/app/lib/actions/foreman_pipeline/jenkins/bulk_build.rb +23 -0
- data/app/lib/actions/foreman_pipeline/jenkins/get_build_details.rb +11 -0
- data/app/lib/actions/foreman_pipeline/jenkins/get_build_params.rb +11 -0
- data/app/lib/actions/foreman_pipeline/jenkins/get_version.rb +17 -0
- data/app/lib/actions/foreman_pipeline/jenkins/list.rb +15 -0
- data/app/lib/actions/foreman_pipeline/jenkins/wait_and_poll.rb +33 -0
- data/app/lib/actions/foreman_pipeline/jenkins/wait_for_build.rb +42 -0
- data/app/lib/actions/foreman_pipeline/jenkins/wait_host_ready.rb +36 -0
- data/app/lib/actions/foreman_pipeline/jenkins_instance/abstract_jenkins_instance_action.rb +17 -0
- data/app/lib/actions/foreman_pipeline/jenkins_instance/create_jenkins_instance_keys.rb +45 -0
- data/app/lib/actions/foreman_pipeline/job/create_activation_key.rb +20 -0
- data/app/lib/actions/foreman_pipeline/job/create_host.rb +88 -0
- data/app/lib/actions/foreman_pipeline/job/cv_promote_job_hook.rb +22 -0
- data/app/lib/actions/foreman_pipeline/job/cv_publish_job_hook.rb +22 -0
- data/app/lib/actions/foreman_pipeline/job/deploy_new_host.rb +25 -0
- data/app/lib/actions/foreman_pipeline/job/find_packages_to_install.rb +16 -0
- data/app/lib/actions/foreman_pipeline/job/job_hook.rb +24 -0
- data/app/lib/actions/foreman_pipeline/job/multiple_promotions.rb +18 -0
- data/app/lib/actions/foreman_pipeline/job/promote.rb +38 -0
- data/app/lib/actions/foreman_pipeline/job/redeploy.rb +45 -0
- data/app/lib/actions/foreman_pipeline/job/repo_sync_job_hook.rb +33 -0
- data/app/lib/actions/foreman_pipeline/job/run_job_manually.rb +25 -0
- data/app/lib/actions/foreman_pipeline/job/suspend_until_provisioned.rb +13 -0
- data/app/lib/actions/foreman_pipeline/mixins/ssh_extension.rb +41 -0
- data/app/lib/actions/foreman_pipeline/mixins/uri_extension.rb +14 -0
- data/app/lib/foreman_pipeline/api/rendering.rb +18 -0
- data/app/models/foreman_pipeline/authorization/base_model.rb +31 -0
- data/app/models/foreman_pipeline/authorization/jenkins_instance.rb +8 -0
- data/app/models/foreman_pipeline/authorization/jenkins_project.rb +8 -0
- data/app/models/foreman_pipeline/authorization/jenkins_project_param.rb +8 -0
- data/app/models/foreman_pipeline/authorization/jenkins_user.rb +7 -0
- data/app/models/foreman_pipeline/authorization/job.rb +7 -0
- data/app/models/foreman_pipeline/concerns/compute_resource_extension.rb +11 -0
- data/app/models/foreman_pipeline/concerns/content_view_extension.rb +12 -0
- data/app/models/foreman_pipeline/concerns/content_view_repository_extension.rb +12 -0
- data/app/models/foreman_pipeline/concerns/hostgroup_extension.rb +12 -0
- data/app/models/foreman_pipeline/concerns/kt_environment_extension.rb +18 -0
- data/app/models/foreman_pipeline/concerns/repository_extension.rb +12 -0
- data/app/models/foreman_pipeline/glue/elastic_search/base_model.rb +21 -0
- data/app/models/foreman_pipeline/glue/elastic_search/jenkins_instance.rb +11 -0
- data/app/models/foreman_pipeline/glue/elastic_search/jenkins_project.rb +11 -0
- data/app/models/foreman_pipeline/glue/elastic_search/jenkins_user.rb +11 -0
- data/app/models/foreman_pipeline/glue/elastic_search/job.rb +11 -0
- data/app/models/foreman_pipeline/jenkins_instance.rb +51 -0
- data/app/models/foreman_pipeline/jenkins_project.rb +18 -0
- data/app/models/foreman_pipeline/jenkins_project_param.rb +21 -0
- data/app/models/foreman_pipeline/jenkins_user.rb +15 -0
- data/app/models/foreman_pipeline/job.rb +72 -0
- data/app/models/foreman_pipeline/job_jenkins_project.rb +25 -0
- data/app/models/foreman_pipeline/job_to_environment.rb +19 -0
- data/app/views/foreman/unattended/snippets/_jenkins_instance_pubkey.erb +10 -0
- data/app/views/foreman_pipeline/api/common/async.json.rabl +3 -0
- data/app/views/foreman_pipeline/api/common/index.json.rabl +7 -0
- data/app/views/foreman_pipeline/api/compute_resources/index.json.rabl +3 -0
- data/app/views/foreman_pipeline/api/compute_resources/show.json.rabl +5 -0
- data/app/views/foreman_pipeline/api/content_views/index.json.rabl +3 -0
- data/app/views/foreman_pipeline/api/content_views/show.json.rabl +5 -0
- data/app/views/foreman_pipeline/api/environments/show.json.rabl +11 -0
- data/app/views/foreman_pipeline/api/hostgroups/index.json.rabl +3 -0
- data/app/views/foreman_pipeline/api/hostgroups/show.json.rabl +5 -0
- data/app/views/foreman_pipeline/api/jenkins_instances/index.json.rabl +3 -0
- data/app/views/foreman_pipeline/api/jenkins_instances/show.json.rabl +7 -0
- data/app/views/foreman_pipeline/api/jenkins_project_params/index.json.rabl +3 -0
- data/app/views/foreman_pipeline/api/jenkins_project_params/show.json.rabl +3 -0
- data/app/views/foreman_pipeline/api/jenkins_projects/index.json.rabl +3 -0
- data/app/views/foreman_pipeline/api/jenkins_projects/show.json.rabl +7 -0
- data/app/views/foreman_pipeline/api/jenkins_users/index.json.rabl +2 -0
- data/app/views/foreman_pipeline/api/jenkins_users/show.json.rabl +3 -0
- data/app/views/foreman_pipeline/api/jobs/available_paths.json.rabl +9 -0
- data/app/views/foreman_pipeline/api/jobs/index.json.rabl +3 -0
- data/app/views/foreman_pipeline/api/jobs/show.json.rabl +32 -0
- data/config/mount_engine.rb +3 -0
- data/config/routes.rb +53 -0
- data/db/migrate/20141003121914_create_job_table.rb +13 -0
- data/db/migrate/20141003145152_add_organization_to_jobs_table.rb +9 -0
- data/db/migrate/20141014125836_make_content_view_and_hostgroup_optional_for_job.rb +11 -0
- data/db/migrate/20141029121444_create_test_table.rb +11 -0
- data/db/migrate/20141029125423_add_organization_to_test_table.rb +9 -0
- data/db/migrate/20141030154210_create_jobs_tests_table.rb +12 -0
- data/db/migrate/20141120130350_add_resource_to_job.rb +9 -0
- data/db/migrate/20150121134503_create_jenkins_instances_table.rb +13 -0
- data/db/migrate/20150121134748_add_jenkins_instances_to_job_table.rb +9 -0
- data/db/migrate/20150122155819_add_kt_environment_to_jobs_table.rb +9 -0
- data/db/migrate/20150127101153_add_trigger_options_to_jobs_table.rb +13 -0
- data/db/migrate/20150202180711_add_content_column_to_tests_table.rb +9 -0
- data/db/migrate/20150209145400_add_pubkey_to_jenkins_instance_table.rb +9 -0
- data/db/migrate/20150209160604_add_jenkins_home_to_jenkins_instance_table.rb +9 -0
- data/db/migrate/20150212115234_add_uniqueness_to_jenkins_instance_url.rb +9 -0
- data/db/migrate/20150212125901_add_uniqueness_to_test_name.rb +9 -0
- data/db/migrate/20150213095447_add_cert_path_to_jenkins_instances.rb +9 -0
- data/db/migrate/20150216170951_add_build_step_to_tests_table.rb +9 -0
- data/db/migrate/20150223142315_change_jenkins_instance_cert_path_column.rb +9 -0
- data/db/migrate/20150224090100_create_jenkins_projects_table.rb +19 -0
- data/db/migrate/20150226182211_add_org_to_jenkins_project.rb +9 -0
- data/db/migrate/20150301134121_create_jenkins_project_params_table.rb +16 -0
- data/db/migrate/20150303134951_change_jenkins_project_param_value_column.rb +9 -0
- data/db/migrate/20150304123529_change_jenkins_project_params_table.rb +9 -0
- data/db/migrate/20150305122212_drop_tests_table.rb +5 -0
- data/db/migrate/20150312153833_create_jenkins_users.rb +15 -0
- data/db/migrate/20150313093244_add_jenkins_user_to_jobs.rb +9 -0
- data/db/migrate/20150313115956_change_jenkins_user_owner.rb +9 -0
- data/db/migrate/20150318141859_rename_tables.rb +19 -0
- data/db/migrate/20150323153355_remove_owner_from_jenkins_user.rb +9 -0
- data/db/migrate/20150323165954_add_jenkins_user_to_instance.rb +9 -0
- data/db/migrate/20150323175436_remove_jenkins_user_from_job.rb +9 -0
- data/db/migrate/20150324082437_remove_jenkins_instance_from_user.rb +9 -0
- data/db/migrate/20150324093416_add_promote_to_jobs.rb +9 -0
- data/db/migrate/20150324124034_create_job_path.rb +13 -0
- data/db/migrate/20150408143011_remove_cv_promote_from_job.rb +9 -0
- data/db/migrate/20150408145022_rename_job_path.rb +11 -0
- data/db/migrate/20150923073033_drop_orphaned_table.rb +8 -0
- data/lib/foreman_pipeline.rb +5 -0
- data/lib/foreman_pipeline/engine.rb +67 -0
- data/lib/foreman_pipeline/permissions.rb +3 -0
- data/lib/foreman_pipeline/permissions/jenkins_instance_permissions.rb +25 -0
- data/lib/foreman_pipeline/permissions/jenkins_project_params_permissions.rb +9 -0
- data/lib/foreman_pipeline/permissions/jenkins_projects_permissions.rb +9 -0
- data/lib/foreman_pipeline/permissions/jenkins_request_permissions.rb +9 -0
- data/lib/foreman_pipeline/permissions/jenkins_user_permissions.rb +24 -0
- data/lib/foreman_pipeline/permissions/job_permissions.rb +27 -0
- data/lib/foreman_pipeline/plugin.rb +17 -0
- data/lib/foreman_pipeline/roles.rb +13 -0
- data/lib/foreman_pipeline/tasks/foreman_pipeline_seed.rake +18 -0
- data/lib/foreman_pipeline/tasks/foreman_pipeline_test.rake +34 -0
- data/lib/foreman_pipeline/version.rb +3 -0
- data/test/factories/hostgroup_factory.rb +6 -0
- data/test/factories/jenkins_instance_related_factory.rb +20 -0
- data/test/foreman_pipeline_plugin_test_helper.rb +28 -0
- data/test/unit/job_test.rb +26 -0
- data/test/unit/sanity_test.rb +12 -0
- metadata +327 -0
@@ -0,0 +1,22 @@
|
|
1
|
+
module Actions
|
2
|
+
module ForemanPipeline
|
3
|
+
module Job
|
4
|
+
class CvPromoteJobHook < JobHook
|
5
|
+
|
6
|
+
def self.subscribe
|
7
|
+
Katello::ContentView::Promote
|
8
|
+
end
|
9
|
+
|
10
|
+
def plan(version, environment, is_force = false)
|
11
|
+
valid_jobs = version.content_view.jobs.select { |job| job.is_valid? }
|
12
|
+
jobs_to_run = valid_jobs.select { |job| version.eql? job.target_cv_version }
|
13
|
+
allowed_jobs = jobs_to_run.select { |job| job.levelup_trigger && !job.version_already_promoted? }
|
14
|
+
|
15
|
+
plan_self(:trigger => trigger.output,
|
16
|
+
:job_ids => allowed_jobs.map(&:id),
|
17
|
+
:job_names => allowed_jobs.map(&:name))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Actions
|
2
|
+
module ForemanPipeline
|
3
|
+
module Job
|
4
|
+
class CvPublishJobHook < JobHook
|
5
|
+
|
6
|
+
def self.subscribe
|
7
|
+
Katello::ContentView::Publish
|
8
|
+
end
|
9
|
+
|
10
|
+
def plan(content_view, descripton)
|
11
|
+
valid_jobs = content_view.jobs.select { |job| job.is_valid? }
|
12
|
+
jobs_to_run = valid_jobs.select { |job| job.environment.library? }
|
13
|
+
allowed_jobs = jobs_to_run.select { |job| job.levelup_trigger && !job.version_already_promoted? }
|
14
|
+
|
15
|
+
plan_self(:trigger => trigger.output,
|
16
|
+
:job_ids => allowed_jobs.map(&:id),
|
17
|
+
:job_names => allowed_jobs.map(&:name))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Actions
|
2
|
+
module ForemanPipeline
|
3
|
+
module Job
|
4
|
+
class DeployNewHost < Actions::EntryAction
|
5
|
+
include Mixins::UriExtension
|
6
|
+
middleware.use ::Actions::Middleware::KeepCurrentUser
|
7
|
+
|
8
|
+
def plan(job)
|
9
|
+
sequence do
|
10
|
+
redeploy = plan_action(Redeploy, job)
|
11
|
+
|
12
|
+
packages = plan_action(FindPackagesToInstall, :job_id => job.id)
|
13
|
+
|
14
|
+
bulk_build = plan_action(Jenkins::BulkBuild,
|
15
|
+
job.jenkins_projects,
|
16
|
+
:job_id => job.id,
|
17
|
+
:data => redeploy.output,
|
18
|
+
:packages => packages.output[:package_names])
|
19
|
+
plan_action(Promote, :job_id => job.id, :build_fails => bulk_build.output[:failed_count])
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Actions
|
2
|
+
module ForemanPipeline
|
3
|
+
module Job
|
4
|
+
class FindPackagesToInstall < Actions::EntryAction
|
5
|
+
middleware.use ::Actions::Middleware::RemoteAction
|
6
|
+
include ::Dynflow::Action::Cancellable
|
7
|
+
|
8
|
+
def run
|
9
|
+
job = ::ForemanPipeline::Job.find input.fetch(:job_id)
|
10
|
+
output[:package_names] = job.target_cv_version.packages.map(&:name)
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Actions
|
2
|
+
module ForemanPipeline
|
3
|
+
module Job
|
4
|
+
class JobHook < Actions::EntryAction
|
5
|
+
middleware.use ::Actions::Middleware::KeepCurrentUser
|
6
|
+
|
7
|
+
def run
|
8
|
+
fail "Multiple jobs defined for the same content view and environment: #{input[:job_names]}.
|
9
|
+
This may result in an unexpected behaviour.
|
10
|
+
Resolve the conflict to avoid skipping this action." if input[:job_names].length > 1
|
11
|
+
jobs = input[:job_ids].map { |id| ::ForemanPipeline::Job.find id }
|
12
|
+
jobs.map do |job|
|
13
|
+
ForemanTasks.trigger(DeployNewHost, job)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def rescue_strategy_for_self
|
18
|
+
Dynflow::Action::Rescue::Skip
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Actions
|
2
|
+
module ForemanPipeline
|
3
|
+
module Job
|
4
|
+
class MultiplePromotions < Actions::EntryAction
|
5
|
+
middleware.use ::Actions::Middleware::KeepCurrentUser
|
6
|
+
|
7
|
+
def plan(job)
|
8
|
+
sequence do
|
9
|
+
job.to_environments.each do |env|
|
10
|
+
plan_action(::Actions::Katello::ContentView::Promote, job.target_cv_version, env, false)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Actions
|
2
|
+
module ForemanPipeline
|
3
|
+
module Job
|
4
|
+
class Promote < Actions::EntryAction
|
5
|
+
middleware.use ::Actions::Middleware::KeepCurrentUser
|
6
|
+
|
7
|
+
def plan(opts)
|
8
|
+
plan_self(opts)
|
9
|
+
end
|
10
|
+
|
11
|
+
def run
|
12
|
+
unless job.environment.successors.empty?
|
13
|
+
fail "Content View promotion disabled" if job.to_environments.empty?
|
14
|
+
promote_environment
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def rescue_strategy_for_self
|
19
|
+
Dynflow::Action::Rescue::Skip
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def promote_environment
|
25
|
+
output[:cv_to_promote] = job.content_view.name
|
26
|
+
output[:target_environments] = job.to_environments.pluck(:name)
|
27
|
+
output[:in_job] = job.name
|
28
|
+
|
29
|
+
ForemanTasks.trigger(Job::MultiplePromotions, job)
|
30
|
+
end
|
31
|
+
|
32
|
+
def job
|
33
|
+
j = ::ForemanPipeline::Job.find input.fetch(:job_id)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Actions
|
2
|
+
module ForemanPipeline
|
3
|
+
module Job
|
4
|
+
class Redeploy < Actions::EntryAction
|
5
|
+
|
6
|
+
def plan(job)
|
7
|
+
sequence do
|
8
|
+
unique_hostname = "#{normalize_name job.name}-#{::Katello::Util::Model.uuid}"
|
9
|
+
|
10
|
+
create_candlepin_key = plan_action(::Actions::Candlepin::ActivationKey::Create, :organization_label => job.content_view.organization.name)
|
11
|
+
create_key = plan_action(CreateActivationKey, :name => unique_hostname,
|
12
|
+
:organization_id => job.content_view.organization.id,
|
13
|
+
:environment_id => job.environment_id,
|
14
|
+
:content_view_id => job.content_view.id,
|
15
|
+
:cp_id => create_candlepin_key.output[:response][:id])
|
16
|
+
|
17
|
+
create_host = plan_action(CreateHost, unique_hostname, job.hostgroup, job.compute_resource, {
|
18
|
+
:org_id => job.content_view.organization.id,
|
19
|
+
:content_view_id => job.content_view.id,
|
20
|
+
:activation_key => create_key.output[:new_key],
|
21
|
+
:jenkins_instance_id => job.jenkins_instance_id})
|
22
|
+
|
23
|
+
suspend_until = plan_action(SuspendUntilProvisioned, 'host_id' => create_host.output[:host][:id])
|
24
|
+
|
25
|
+
plan_self(:create_host => create_host.output[:host],
|
26
|
+
:installed_at => suspend_until.output[:object][:installed_at],
|
27
|
+
:new_key => create_key.output[:new_key])
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def run
|
33
|
+
output[:host] = input[:create_host]
|
34
|
+
output[:activation_key] = input[:new_key]
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def normalize_name(repo_name)
|
40
|
+
repo_name.gsub(/[^a-z0-9\-]/, '-')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Actions
|
2
|
+
module ForemanPipeline
|
3
|
+
module Job
|
4
|
+
class RepoSyncJobHook < JobHook
|
5
|
+
|
6
|
+
def self.subscribe
|
7
|
+
Katello::Repository::Sync
|
8
|
+
end
|
9
|
+
|
10
|
+
def plan(repo)
|
11
|
+
valid_jobs = repo.jobs.select { |job| job.is_valid? }
|
12
|
+
|
13
|
+
jobs_to_run = valid_jobs.select { |job| job.target_cv_version_avail? }
|
14
|
+
allowed_jobs = jobs_to_run.select { |job| job.sync_trigger && !job.version_already_promoted? }
|
15
|
+
grouped_jobs = allowed_jobs.group_by(&:target_cv_version).values
|
16
|
+
|
17
|
+
if grouped_jobs.max_by(&:length).length > 1
|
18
|
+
grouped_jobs = grouped_jobs.max_by(&:length)
|
19
|
+
|
20
|
+
plan_self(:trigger => trigger.output,
|
21
|
+
:job_ids => grouped_jobs.map(&:id),
|
22
|
+
:job_names => grouped_jobs.map(&:name))
|
23
|
+
else
|
24
|
+
grouped_jobs.flatten!
|
25
|
+
plan_self(:trigger => trigger.output,
|
26
|
+
:job_names => [],
|
27
|
+
:job_ids => grouped_jobs.map(&:id))
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Actions
|
2
|
+
module ForemanPipeline
|
3
|
+
module Job
|
4
|
+
class RunJobManually < Actions::EntryAction
|
5
|
+
|
6
|
+
def plan(job)
|
7
|
+
if job.is_valid? && job.target_cv_version_avail? && !job.version_already_promoted?
|
8
|
+
plan_action(DeployNewHost, job)
|
9
|
+
plan_self(:info => "Manually triggered job started.", :name => job.name)
|
10
|
+
else
|
11
|
+
plan_self(:info => "Manually triggered job execution skipped, check job configuration.", :name => job.name)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def run
|
16
|
+
output = input
|
17
|
+
end
|
18
|
+
|
19
|
+
def humanized_name
|
20
|
+
"Run manually ForemanPipeline::Job: #{input[:name]}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Actions
|
2
|
+
module ForemanPipeline
|
3
|
+
module Job
|
4
|
+
class SuspendUntilProvisioned < ::ForemanDeployments::Tasks::WaitUntilBuiltTaskDefinition::Action
|
5
|
+
include ::Dynflow::Action::Cancellable
|
6
|
+
|
7
|
+
def done?
|
8
|
+
output[:task][:build]
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Actions
|
2
|
+
module ForemanPipeline
|
3
|
+
module Mixins
|
4
|
+
module SshExtension
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
# http://stackoverflow.com/questions/3386233/how-to-get-exit-status-with-rubys-netssh-library
|
8
|
+
def ssh_exec!(ssh, command)
|
9
|
+
stdout_data = ""
|
10
|
+
stderr_data = ""
|
11
|
+
exit_code = nil
|
12
|
+
exit_signal = nil
|
13
|
+
ssh.open_channel do |channel|
|
14
|
+
channel.exec(command) do |ch, success|
|
15
|
+
unless success
|
16
|
+
abort "FAILED: couldn't execute command (ssh.channel.exec)"
|
17
|
+
end
|
18
|
+
channel.on_data do |ch, data|
|
19
|
+
stdout_data += data
|
20
|
+
end
|
21
|
+
|
22
|
+
channel.on_extended_data do |ch, type, data|
|
23
|
+
stderr_data += data
|
24
|
+
end
|
25
|
+
|
26
|
+
channel.on_request("exit-status") do |ch, data|
|
27
|
+
exit_code = data.read_long
|
28
|
+
end
|
29
|
+
|
30
|
+
channel.on_request("exit-signal") do |ch, data|
|
31
|
+
exit_signal = data.read_long
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
ssh.loop
|
36
|
+
[stdout_data, stderr_data, exit_code, exit_signal]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module ForemanPipeline
|
2
|
+
module Api
|
3
|
+
module Rendering
|
4
|
+
|
5
|
+
def respond_with_template(action, resource_name, options = {}, &block)
|
6
|
+
yield if block_given?
|
7
|
+
status = options[:status] || 200
|
8
|
+
|
9
|
+
render :template => "foreman_pipeline/api/#{resource_name}/#{action}",
|
10
|
+
:status => status,
|
11
|
+
:locals => { :object_name => options[:object_name],
|
12
|
+
:root_name => options[:root_name] },
|
13
|
+
:layout => "katello/api/v2/layouts/#{options[:layout]}"
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module ForemanPipeline
|
2
|
+
module Authorization::BaseModel
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
include Authorizable
|
6
|
+
include Katello::Authorization
|
7
|
+
|
8
|
+
def readable?
|
9
|
+
authorized?(self.normalize_name("read"))
|
10
|
+
end
|
11
|
+
|
12
|
+
def editable?
|
13
|
+
authorized?(self.normalize_name("edit"))
|
14
|
+
end
|
15
|
+
|
16
|
+
def deletable?
|
17
|
+
authorized?(self.normalize_name("delete"))
|
18
|
+
end
|
19
|
+
|
20
|
+
module ClassMethods
|
21
|
+
def readable
|
22
|
+
authorized(normalize_name("view"))
|
23
|
+
end
|
24
|
+
|
25
|
+
# TODO: remove argument
|
26
|
+
def normalize_name(action_string)
|
27
|
+
(action_string + self.class.name.demodulize.pluralize).underscore.to_sym
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|