Skip to content

Commit

Permalink
Initial changes for syncing containers
Browse files Browse the repository at this point in the history
  • Loading branch information
dymurray committed Jun 27, 2016
1 parent f132c83 commit 33c20da
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 20 deletions.
11 changes: 11 additions & 0 deletions server/app/lib/actions/fusor/content/manage_content.rb
Expand Up @@ -50,6 +50,9 @@ def plan(deployment)
# retrieve the repos needed for the deployment and use them in actions that follow
repositories = retrieve_deployment_repositories(deployment.organization, product_content_details)

if deployment.deploy_openshift
sync_openshift_docker_repos
end
plan_action(::Actions::Fusor::Content::SyncRepositories, repositories)

plan_action(::Actions::Fusor::Content::PublishContentView,
Expand Down Expand Up @@ -85,6 +88,14 @@ def enable_smart_class_parameter_overrides
end
end

def sync_openshift_docker_repos
repos = []
SETTINGS[:fusor][:docker_repos].each do |docker_repo|
repos << ::Katello::Repository.find_by_name(docker_repo[:name])
end
plan_action(::Actions::Fusor::Content::SyncRepositories, repos)
end

def yum_repositories(repositories)
repositories.select { |repo| repo.content_type == ::Katello::Repository::YUM_TYPE }
end
Expand Down
16 changes: 16 additions & 0 deletions server/app/lib/actions/fusor/content/publish_content_view.rb
Expand Up @@ -39,6 +39,18 @@ def plan(deployment, repositories)
end
rpm_view_version = rpm_view.version(deployment.organization.library)

# Find docker content view which is created during seeding
docker_view = find_content_view(deployment.organization, docker_content_view_name)
docker_view_version = docker_view.try(:version, deployment.organization.library)

component_version_ids = [rpm_view_version.id, docker_view_version.try(:id)].compact
unless component_version_ids.blank? ||
component_version_ids.to_set.subset?(composite_view.component_ids.to_set)
plan_action(::Actions::Katello::ContentView::Update, composite_view,
:component_ids => component_version_ids)
plan_action(::Actions::Katello::ContentView::Publish, composite_view)
end

#The puppet view is created during the seeding of the plugin; therefore, we should not need to create it
puppet_view = find_content_view(deployment.organization, puppet_content_view_name)
puppet_view_version = puppet_view.try(:version, deployment.organization.library)
Expand Down Expand Up @@ -104,6 +116,10 @@ def rpm_content_view_name
def puppet_content_view_name
SETTINGS[:fusor][:content][:content_view][:puppet_component_view_name]
end

def docker_content_view_name
SETTINGS[:fusor][:content][:content_view][:docker_component_view_name]
end
end
end
end
Expand Down
Expand Up @@ -19,15 +19,15 @@ def humanized_name
_("Create Content View")
end

def plan(deployment)
def plan(deployment, name)
super(deployment)
plan_self(:deployment_id => deployment.id)
plan_self(:deployment_id => deployment.id, :name => name)
end

def create_sub_plans
deployment = ::Fusor::Deployment.find(input[:deployment_id])
org = deployment.organization
content_view = ::Katello::ContentView.new(:name => 'Fusor Puppet Content', :organization_id => org.id)
content_view = ::Katello::ContentView.new(:name => input[:name], :organization_id => org.id)
trigger(::Actions::Katello::ContentView::Create, content_view)
end
end
Expand Down
@@ -0,0 +1,37 @@
#
# Copyright 2015 Red Hat, Inc.
#
# This software is licensed to you under the GNU General Public
# License as published by the Free Software Foundation; either version
# 2 of the License (GPLv2) or (at your option) any later version.
# There is NO WARRANTY for this software, express or implied,
# including the implied warranties of MERCHANTABILITY,
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
# have received a copy of GPLv2 along with this software; if not, see
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.

module Actions
module Fusor
module Deployment
module PrepareOrg
class CreateDockerRepository < Actions::Fusor::FusorActionWithSubPlans
def humanized_name
_("Create Docker Repository")
end

def plan(name, upstream_name)
super()
plan_self(:name => name, :upstream_name => upstream_name)
end

def create_sub_plans
product = ::Katello::Product.find_by_name('Fusor Docker Containers')
repository = product.add_repo(input[:name], input[:name], 'http://registry-1.docker.io/', 'docker', true)
repository[:docker_upstream_name] = input[:upstream_name]
trigger(::Actions::Katello::Repository::Create, repository, false, true)
end
end
end
end
end
end
Expand Up @@ -19,16 +19,16 @@ def humanized_name
_("Create Product")
end

def plan(deployment)
def plan(deployment, name)
super(deployment)
plan_self(:deployment_id => deployment.id)
plan_self(:deployment_id => deployment.id, :name => name)
end

def create_sub_plans
unless ::Katello::Product.find_by_name('Fusor')
unless ::Katello::Product.find_by_name(input[:name])
deployment = ::Fusor::Deployment.find(input[:deployment_id])
org = deployment.organization
product = ::Katello::Product.new({:name => 'Fusor', :organization_id => org.id})
product = ::Katello::Product.new({:name => input[:name], :organization_id => org.id})
trigger(::Actions::Katello::Product::Create, product, org)
end
end
Expand Down
Expand Up @@ -19,14 +19,14 @@ def humanized_name
_("Create Repository")
end

def plan
super
plan_self
def plan(name, type, label, url)
super()
plan_self(:name => name, :type => type, :label => label, :url => url)
end

def create_sub_plans
product = ::Katello::Product.find_by_name('Fusor')
repository = product.add_repo('Puppet1', 'Puppet', nil, 'puppet', 'unprotected')
product = ::Katello::Product.find_by_name(input[:name])
repository = product.add_repo(input[:label], input[:name], input[:url], input[:type], 'unprotected')
trigger(::Actions::Katello::Repository::Create, repository, false, true)
end
end
Expand Down
27 changes: 23 additions & 4 deletions server/app/lib/actions/fusor/deployment/prepare_org/prepare.rb
Expand Up @@ -24,17 +24,31 @@ def plan(deployment)

sequence do
unless ::Katello::Product.find_by_name('Fusor')
plan_action(::Actions::Fusor::Deployment::PrepareOrg::CreateProduct, deployment)
plan_action(::Actions::Fusor::Deployment::PrepareOrg::CreateProduct, deployment, 'Fusor')
end

unless ::Katello::Product.find_by_name('Fusor Docker Containers')
plan_action(::Actions::Fusor::Deployment::PrepareOrg::CreateProduct, deployment, 'Fusor Docker Containers')
end

unless ::Katello::Repository.find_by_name('Puppet')
plan_action(::Actions::Fusor::Deployment::PrepareOrg::CreateRepository)
plan_action(::Actions::Fusor::Deployment::PrepareOrg::CreateRepository, 'Puppet', 'puppet', 'Puppet1', nil)
end

SETTINGS[:fusor][:docker_repos].each do |repo|
unless ::Katello::Repository.find_by_name(repo[:name])
plan_action(::Actions::Fusor::Deployment::PrepareOrg::CreateDockerRepository, repo[:name], repo[:upstream_name])
end
end

plan_action(::Actions::Fusor::Deployment::PrepareOrg::UploadModule)

unless ::Katello::ContentView.find_by_name('Fusor Puppet Content')
plan_action(::Actions::Fusor::Deployment::PrepareOrg::CreateContentView, deployment)
plan_action(::Actions::Fusor::Deployment::PrepareOrg::CreateContentView, deployment, 'Fusor Puppet Content')
end

unless ::Katello::ContentView.find_by_name('Fusor Docker Containers')
plan_action(::Actions::Fusor::Deployment::PrepareOrg::CreateContentView, deployment, 'Fusor Docker Containers')
end

cv = ::Katello::ContentView.find_by_name('Fusor Puppet Content')
Expand All @@ -43,7 +57,12 @@ def plan(deployment)
end

unless cv && ::Katello::ContentView.find_by_name('Fusor Puppet Content').next_version > 1
plan_action(::Actions::Fusor::Deployment::PrepareOrg::PublishContentView)
plan_action(::Actions::Fusor::Deployment::PrepareOrg::PublishContentView, 'Fusor Puppet Content')
end

cv = ::Katello::ContentView.find_by_name('Fusor Docker Containers')
unless cv && cv.next_version > 1
plan_action(::Actions::Fusor::Deployment::PrepareOrg::PublishContentView, 'Fusor Docker Containers')
end
end
end
Expand Down
Expand Up @@ -19,13 +19,12 @@ def humanized_name
_("Publish Content View")
end

def plan
super
plan_self
def plan(name)
plan_self(:name => name)
end

def create_sub_plans
cv = ::Katello::ContentView.find_by_name('Fusor Puppet Content')
cv = ::Katello::ContentView.find_by_name(input[:name])
trigger(::Actions::Katello::ContentView::Publish, cv)
end
end
Expand Down
19 changes: 19 additions & 0 deletions server/config/fusor.yaml
Expand Up @@ -4,6 +4,7 @@
:composite_view_name: "Fusor Deployment"
:rpm_component_view_name: "Fusor RPM Content"
:puppet_component_view_name: "Fusor Puppet Content"
:docker_component_view_name: "Fusor Docker Content"

# NOTE: product_name and repository_set_name are provided only for
# convencience / display purposes. All repository finding should be
Expand Down Expand Up @@ -250,6 +251,24 @@
- :name: "ovirt::self_hosted::import_template"
- :name: "ovirt::self_hosted::run_vm"

:docker_repos:
- :name: "hello-openshift"
:upstream_name: "openshift/hello-openshift"
- :name: "origin-docker-registry"
:upstream_name: "openshift/origin-docker-registry"
- :name: "origin-haproxy-router"
:upstream_name: "openshift/origin-haproxy-router"
- :name: "origin-deployer"
:upstream_name: "openshift/origin-deployer"
- :name: "origin-sti-builder"
:upstream_name: "openshift/origin-sti-builder"
- :name: "origin-pod"
:upstream_name: "openshift/origin-pod"
- :name: "origin-docker-builder"
:upstream_name: "openshift/origin-docker-builder"
- :name: "origin-keepalived-ipfailover"
:upstream_name: "openshift/origin-keepalived-ipfailover"

:host_groups:
:rhev:
:root_name: "Fusor Base" # seeded by the fusor-installer
Expand Down

0 comments on commit 33c20da

Please sign in to comment.