Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content deletion - initial merge to master #479

Merged
merged 111 commits into from Aug 20, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
dd76693
Added action type to changeset to accomadate content deletion
parthaa Jul 19, 2012
c4e941e
Made some modifications on the initial model based on comments
parthaa Jul 19, 2012
09cd3d2
Forgot to undo one part
parthaa Jul 19, 2012
ae0df9e
Merge pull request #337 from parthaa/init-content-deletion-model
bbuckingham Jul 19, 2012
0ef2a89
content-deletion - update ui to support defining an action type on ch…
bbuckingham Jul 20, 2012
a304694
content-deletion - remove 'promotion' from several display text items
bbuckingham Jul 20, 2012
70ada4a
promotions - fix bugs with removing packages from a changeset
bbuckingham Jul 23, 2012
2a5f732
promotions - bug - promoted repo can be promoted over and over
bbuckingham Jul 24, 2012
e1f562d
content-deletion - initial ui chgs for add/remove to deletion changeset
bbuckingham Jul 24, 2012
fec8354
content-deletion - show cs type on promotions cs edit details pane
bbuckingham Jul 24, 2012
89742bf
content-deletion - changeset history - show changeset type
bbuckingham Jul 24, 2012
f1cd155
Merge pull request #363 from bbuckingham/fork-content-deletion
parthaa Jul 25, 2012
fbe7209
content-deletion - fix broken spec
bbuckingham Jul 25, 2012
227d2c4
Merge pull request #366 from bbuckingham/fork-content-deletion
parthaa Jul 25, 2012
93af58c
content-deletion - associate proper env with changeset upon creation
bbuckingham Jul 25, 2012
17103e0
content-deletion - fix specs broken on previous commit
bbuckingham Jul 25, 2012
8046155
content-deletion - only allow promotion changesets when in Library
bbuckingham Jul 25, 2012
12ec614
content-deletion - update navigation for changesets
bbuckingham Jul 25, 2012
0a7a7ee
content-deletion - set the ui action button to promote/delete based o…
bbuckingham Jul 25, 2012
3a3086b
content deletion - adding CLI actions
Jul 26, 2012
f3aaa54
content deletion - removing hard coded type
Jul 26, 2012
6dd8a50
Merge pull request #370 from mccun934/content-deletion
mccun934 Jul 26, 2012
5aa305c
Merge pull request #367 from bbuckingham/fork-content-deletion
parthaa Jul 26, 2012
e060ef5
Adding a new changeset model for Content Deletion
parthaa Jul 26, 2012
ef93a8a
fixed a typo
parthaa Jul 26, 2012
081a79a
Fixed some unit tests.
parthaa Jul 27, 2012
d8164f3
Merge pull request #373 from parthaa/real-content-delete-model
mccun934 Jul 27, 2012
c8dd3a0
INitial work on remove packages
parthaa Jul 27, 2012
0b8f0af
content-deletion - minor changes to allow creation of changeset in UI
bbuckingham Jul 27, 2012
34bc2a9
content-deletion - fix promotion... accidental regression for env han…
bbuckingham Jul 27, 2012
b4b497d
Fixed a compile glitch
parthaa Jul 27, 2012
2f308d0
Added the deleting state
parthaa Jul 27, 2012
fbc62af
content-deletion - first mods to integrate js w/ controller (apply/st…
bbuckingham Jul 27, 2012
cad2565
content-deletion - skip dependency resolution for deletion changesets
bbuckingham Jul 27, 2012
3089259
content-deletion - update how changesets are listed when page loaded
bbuckingham Jul 27, 2012
791e778
Merge pull request #382 from bbuckingham/fork-content-deletion
parthaa Jul 27, 2012
f801e41
content deletion - adding back in the CLI promote and apply
Jul 27, 2012
58e75bd
Made the deletion changeset more bare bones . Trying to just get pack…
parthaa Jul 27, 2012
50ac570
Merge pull request #383 from mccun934/content-deletion
parthaa Jul 27, 2012
f228097
Merge branch 'content-deletion' into package-changes
parthaa Jul 27, 2012
af09f05
Merge pull request #384 from parthaa/package-changes1
mccun934 Jul 27, 2012
e852d8e
Made the delete packages call use packages object
parthaa Jul 27, 2012
c61d421
Added methods to generate repo metadata when packages are deleted
parthaa Jul 28, 2012
cd5471a
Made the promotion UI use the 'apply' method generated by the model
parthaa Jul 28, 2012
a61eff9
Adding a missing 'deleted' state to indicate succesfu completion of d…
parthaa Jul 28, 2012
94e6726
Merge pull request #385 from parthaa/package-deux
bbuckingham Jul 28, 2012
dd2792d
content-deletion - add backend support for deleting errata
bbuckingham Jul 28, 2012
5ba5c97
content-deletion - add backend support for deleting distributions
bbuckingham Jul 28, 2012
c76a64d
Merge pull request #386 from bbuckingham/fork-content-deletion
parthaa Jul 28, 2012
0646dd3
content-deletion - add backend support for deleting repos
bbuckingham Jul 29, 2012
77c93b0
content-deletion - update cs create to default to promotion
bbuckingham Jul 29, 2012
1bab3be
content-deletion - change cs promote status text to apply (to be gene…
bbuckingham Jul 29, 2012
64576a8
content-deletion - update specs to account for the promote vs apply n…
bbuckingham Jul 29, 2012
f64c056
content-deletion - add changeset type to changeset listing (changeset…
bbuckingham Jul 29, 2012
8027215
content-deletion - minor changes to changeset history
bbuckingham Jul 29, 2012
e10b443
Merge pull request #387 from bbuckingham/fork-content-deletion
mccun934 Jul 29, 2012
340a0a2
content deletion - proper deletion support in the CLI
Jul 30, 2012
5712c68
Merge pull request #402 from mccun934/content-deletion
xsuchy Jul 31, 2012
abeda25
Fixed some merge conflicts
parthaa Aug 2, 2012
7a0a8d1
Merge pull request #422 from parthaa/master-content-delete-merge
bbuckingham Aug 2, 2012
530e8d4
content-deletion - updates to handle last env in path
bbuckingham Aug 2, 2012
b62a512
content-deletion - update repo deletion to disable or remove based on…
bbuckingham Aug 2, 2012
98eaedc
Updating the converge-ui version
parthaa Aug 2, 2012
e106a09
Merge pull request #425 from parthaa/master-content-delete-merge
bbuckingham Aug 2, 2012
2d83955
content deletion - taking out unecessary fields from the JSON
Aug 2, 2012
0953ee6
Merge remote-tracking branch 'upstream/content-deletion' into content…
Aug 2, 2012
94f166a
update converge ui
Aug 2, 2012
20226e2
Revert "update converge ui"
Aug 2, 2012
fe86627
Merge pull request #426 from mccun934/content-deletion
bbuckingham Aug 3, 2012
0a471bf
Merge pull request #424 from bbuckingham/fork-content-deletion-3
parthaa Aug 3, 2012
1c32b78
Speeded up package deletion and promotion by using a differnt call in…
parthaa Aug 2, 2012
d559ecb
content-deletion - add a promotion/deletion banner to the changeset tree
bbuckingham Aug 3, 2012
5f3de4c
Moved the add+remove repo packages method to orchestration layer
parthaa Aug 6, 2012
15a844b
Removed unused methods in the pulp and reporb
parthaa Aug 7, 2012
84eb51d
Merge pull request #432 from parthaa/speedier-package-delete
mccun934 Aug 7, 2012
0dc43a7
Merge remote-tracking branch 'upstream/content-deletion' into fork-co…
bbuckingham Aug 8, 2012
18ed8a2
Fixed broken spec tests that occured after master merge
parthaa Aug 8, 2012
e352940
Fixed more spec tests
parthaa Aug 8, 2012
0e42bfc
Merge pull request #451 from parthaa/merge-unit-test-fixes
mccun934 Aug 8, 2012
51cceef
content-deletion - initial chgs to support 2 changeset trees (deletio…
bbuckingham Aug 13, 2012
5f7762e
changesets - fix the locked icon image on changeset list
bbuckingham Aug 13, 2012
1f69053
content-deletion - fix some references to accessing current chgset br…
bbuckingham Aug 13, 2012
5de99c7
Quick fix to a bug introduced in the package deletion and promotion
parthaa Aug 13, 2012
f74d101
content-deletion - load changeset sliding tree based on changeset hash
bbuckingham Aug 14, 2012
5079bd4
content-deletion - remove the changeset type from the sliding tree li…
bbuckingham Aug 14, 2012
2accabc
Merge pull request #458 from parthaa/speedy-package-fix
mccun934 Aug 14, 2012
b34536e
content-deletion - update the content tree to use 'Added (Undo)' vs '…
bbuckingham Aug 14, 2012
907b522
content-deletion - update the content tree to use 'Added (Undo)' vs '…
bbuckingham Aug 14, 2012
b1cdc64
content-deletion - add title attribute to the changeset action bar
bbuckingham Aug 14, 2012
cc3ee59
content-deletion - add custom confirms for changeset deletion
bbuckingham Aug 15, 2012
ff4f2f9
content-deletion - add a tipsy to the 'Added' item in content tree
bbuckingham Aug 15, 2012
81c5d78
content-deletion - update helptip to include both deletion and promotion
bbuckingham Aug 15, 2012
7c56615
content-deletion - convert action titles to tipsy for consistency
bbuckingham Aug 15, 2012
e63b4b3
Merge remote-tracking branch 'upstream/content-deletion' into fork-co…
bbuckingham Aug 15, 2012
fe7eadd
Merge pull request #468 from bbuckingham/fork-content-deletion-3
parthaa Aug 16, 2012
3710ad1
Added system template deletion feature
parthaa Aug 13, 2012
ea18172
changesets - fix notice type on successful promotion/deletion
bbuckingham Aug 16, 2012
acea01e
content-deletion - fix issue w/ deletion tree not loading on last env
bbuckingham Aug 16, 2012
e324921
Merge pull request #474 from bbuckingham/fork-content-deletion-3
mccun934 Aug 16, 2012
cdb1707
Commented out unused parent template logic
parthaa Aug 17, 2012
8453ec1
Merge pull request #473 from parthaa/delete-sys-templates
mccun934 Aug 17, 2012
af313dd
Removed misleading/unused code in the deletion_changesets
parthaa Aug 17, 2012
f8ebab6
Merge pull request #477 from parthaa/delete-sys-templates
bbuckingham Aug 17, 2012
98cb0b5
content deletion - adding support for product deletion
Aug 17, 2012
ac86f5b
content deletion - adding support for product deletion
Aug 17, 2012
7f232b4
Merge branch 'content-deletion' of github.com:mccun934/katello into c…
Aug 17, 2012
b6acb66
content deletion - putting commented code back in
Aug 17, 2012
71715ae
Merge pull request #478 from mccun934/content-deletion
bbuckingham Aug 17, 2012
7665054
Merge remote-tracking branch 'upstream/master' into content-deletion
bbuckingham Aug 18, 2012
3878e0c
converge-ui - accidentally downgraded during previous merge... :(
bbuckingham Aug 18, 2012
c8bccce
Merge remote-tracking branch 'upstream/master' into content-deletion
bbuckingham Aug 20, 2012
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions cli/src/katello/client/api/changeset.py
Expand Up @@ -36,11 +36,12 @@ def changeset_by_name(self, orgName, envId, csName):
else:
return None

def create(self, orgName, envId, name, description=None):
def create(self, orgName, envId, name, type, description=None):
data = {
"changeset": {
"name": name,
"description": description
"description": description,
"type": type
}
}
path = "/api/organizations/%s/environments/%s/changesets/" % (orgName, envId)
Expand All @@ -63,8 +64,8 @@ def dependencies(self, csId):
deps = self.server.GET(path)[1]
return deps

def promote(self, csId):
path = "/api/changesets/%s/promote" % (csId)
def apply(self, csId):
path = "/api/changesets/%s/apply" % (csId)
return self.server.POST(path)[1]

def update_content(self, csId, patch):
Expand Down
66 changes: 53 additions & 13 deletions cli/src/katello/client/core/changeset.py
Expand Up @@ -56,6 +56,7 @@ def run(self):

self.printer.add_column('id')
self.printer.add_column('name')
self.printer.add_column('type')
self.printer.add_column('updated_at', formatter=format_date)
self.printer.add_column('state')
self.printer.add_column('environment_id')
Expand Down Expand Up @@ -109,6 +110,7 @@ def run(self):

self.printer.add_column('id')
self.printer.add_column('name')
self.printer.add_column('action_type')
self.printer.add_column('description', multiline=True, show_with=printer.VerboseStrategy)
self.printer.add_column('updated_at', formatter=format_date)
self.printer.add_column('state')
Expand Down Expand Up @@ -142,6 +144,12 @@ def setup_parser(self, parser):
help=_("changeset name (required)"))
parser.add_option('--description', dest='description',
help=_("changeset description"))
parser.add_option('--promotion', dest='type_promotion', action="store_true", default=False,
help=_("changeset type promotion: pushes changes to the next environment [DEFAULT]"))
parser.add_option('--deletion', dest='type_deletion', action="store_true", default=False,
help=_("changeset type deletion: deletes items in changeset from current environment"))



def check_options(self, validator):
validator.require(('org', 'name', 'env'))
Expand All @@ -151,9 +159,18 @@ def run(self):
envName = self.get_option('env')
csName = self.get_option('name')
csDescription = self.get_option('description')
csType = 'PROMOTION'

# Check for duplicate type flags
if self.get_option('type_promotion') and self.get_option('type_deletion'):
raise OptionValueError(_("specify either --promotion or --deletion but not both"))
if self.get_option('type_promotion'):
csType = 'PROMOTION'
elif self.get_option('type_deletion'):
csType = 'DELETION'

env = get_environment(orgName, envName)
cset = self.api.create(orgName, env["id"], csName, csDescription)
cset = self.api.create(orgName, env["id"], csName, csType, csDescription)
test_record(cset,
_("Successfully created changeset [ %s ] for environment [ %s ]") % (csName, env["name"]),
_("Could not create changeset [ %s ] for environment [ %s ]") % (csName, env["name"])
Expand All @@ -177,11 +194,15 @@ def build_patch(action, itemBuilder, items):
return patch

class PatchItemBuilder(object):
def __init__(self, org_name, env_name):
def __init__(self, org_name, env_name, type):
self.org_name = org_name
self.env_name = env_name
self.prior_env_name = get_environment(org_name, env_name)['prior']

self.type = type
# Use current env if we are doing a deletion otherwise use the prior
if self.type == 'deletion':
self.env_name = get_environment(org_name, env_name)['name']
else:
self.env_name = get_environment(org_name, env_name)['prior']

def product_id(self, options):
if 'product' in options:
Expand All @@ -193,11 +214,11 @@ def product_id(self, options):
return prod['id']

def repo_id(self, options):
repo = get_repo(self.org_name, options['product'], options['name'], self.prior_env_name)
repo = get_repo(self.org_name, options['product'], options['name'], self.env_name)
return repo['id']

def template_id(self, options):
tpl = get_template(self.org_name, self.prior_env_name, options['name'])
tpl = get_template(self.org_name, self.env_name, options['name'])
return tpl['id']


Expand Down Expand Up @@ -353,10 +374,11 @@ def run(self):
csDescription = self.get_option('description')

cset = get_changeset(orgName, envName, csName)
csType = cset['action_type']

self.update(cset["id"], csNewName, csDescription)
addPatch = self.PatchBuilder.build_patch('add', self.AddPatchItemBuilder(orgName, envName), items)
removePatch = self.PatchBuilder.build_patch('remove', self.RemovePatchItemBuilder(orgName, envName), items)
addPatch = self.PatchBuilder.build_patch('add', self.AddPatchItemBuilder(orgName, envName, csType), items)
removePatch = self.PatchBuilder.build_patch('remove', self.RemovePatchItemBuilder(orgName, envName, csType), items)
self.update_content(cset["id"], addPatch, self.api.add_content)
self.update_content(cset["id"], removePatch, self.api.remove_content)

Expand Down Expand Up @@ -402,8 +424,8 @@ def run(self):


# ==============================================================================
class Promote(ChangesetAction):
description = _('promotes a changeset to the next environment')
class Apply(ChangesetAction):
description = _('applies a changeset based on the type (promotion, deletion)')

def setup_parser(self, parser):
parser.add_option('--name', dest='name',
Expand All @@ -423,18 +445,36 @@ def run(self):

cset = get_changeset(orgName, envName, csName)

task = self.api.promote(cset["id"])
task = self.api.apply(cset["id"])
task = AsyncTask(task)

run_spinner_in_bg(wait_for_async_task, [task], message=_("Promoting the changeset, please wait... "))
run_spinner_in_bg(wait_for_async_task, [task], message=_("Applying the changeset, please wait... "))

if task.succeeded():
print _("Changeset [ %s ] promoted" % csName)
print _("Changeset [ %s ] applied" % csName)
return os.EX_OK
else:
print _("Changeset [ %s ] promotion failed: %s" % (csName, format_task_errors(task.errors())))
return os.EX_DATAERR

# ==============================================================================
class Promote(Apply):
description = _('promotes a changeset to the next environment - DEPRECATED')

def run(self):
csName = self.get_option('name')
orgName = self.get_option('org')
envName = self.get_option('env')

# Block attempts to call this on deletion changesets, otherwise continue
cset = get_changeset(orgName, envName, csName)
if cset['type'] == 'DELETION':
print _("This is a deletion changeset and does not support promotion")
return os.EX_DATAERR

super(Promote, self).run()



# changeset command ============================================================
class Changeset(Command):
Expand Down
1 change: 1 addition & 0 deletions cli/src/katello/client/main.py
Expand Up @@ -242,6 +242,7 @@ def setup_admin(katello_cmd):
cset_cmd.add_command('info', changeset.Info())
cset_cmd.add_command('update', changeset.UpdateContent())
cset_cmd.add_command('delete', changeset.Delete())
cset_cmd.add_command('apply', changeset.Apply())
cset_cmd.add_command('promote', changeset.Promote())
katello_cmd.add_command('changeset', cset_cmd)

Expand Down
55 changes: 55 additions & 0 deletions cli/test/katello/tests/core/changeset/changeset_create_test.py
@@ -0,0 +1,55 @@
import unittest
from mock import Mock
import os

from katello.tests.core.action_test_utils import CLIOptionTestCase, CLIActionTestCase
from katello.tests.core.organization.organization_data import ORGS, ENVS

import katello.client.core.changeset
from katello.client.core.changeset import Create

class RequiredCLIOptionsTests(CLIOptionTestCase):

action = Create()

disallowed_options = [
('--name=changeset1', ),
('--org=ACME', )
]

allowed_options = [
('--org=ACME', '--name=changeset1', '--env=DEV', '--promotion', '--deletion')
]


class ChangesetAddTest(CLIActionTestCase):
ORG = 'org'
NAME = 'changeset1'
DESCRIPTION = 'description'
TYPE = 'promotion'

OPTIONS = {
'org':ORG,
'name':NAME,
'description':DESCRIPTION,
'type':TYPE
}

def setUp(self):
self.set_action(Create())
self.set_module(katello.client.core.changeset)
self.mock_printer()
self.mock_options(self.OPTIONS)

self.mock(self.action.api, 'create', [])
self.mock(self.module, 'get_environment', ENVS[0])

def tearDown(self):
self.restore_mocks()


def test_it_uses_filter_create_api(self):
self.run_action()
self.action.api.create.assert_called_once_with(self.ORG, ENVS[0]['id'], self.NAME, self.DESCRIPTION, self.TYPE)


28 changes: 23 additions & 5 deletions src/app/controllers/api/changesets_controller.rb
Expand Up @@ -12,7 +12,7 @@

class Api::ChangesetsController < Api::ApiController

before_filter :find_changeset, :only => [:show, :update, :destroy, :promote, :dependencies]
before_filter :find_changeset, :only => [:show, :update, :destroy, :promote, :apply, :dependencies]
before_filter :find_environment
before_filter :authorize

Expand All @@ -26,6 +26,7 @@ def rules
:create => manage_perm,
:update => manage_perm,
:promote => promote_perm,
:apply => promote_perm,
:destroy => manage_perm,
}
end
Expand All @@ -35,8 +36,9 @@ def rules
api :GET, "/organizations/:organization_id/environments/:environment_id/changesets", "List changesets in an environment"
param :name, String, :desc => "An optional changeset name to filter upon"
def index
render :json => Changeset.select("changesets.*, environments.name AS environment_name").
changesets = Changeset.select("changesets.*, environments.name AS environment_name").
joins(:environment).where(params.slice(:name, :environment_id))
render :json => changesets.to_json
end

api :GET, "/changesets/:id", "Show a changeset"
Expand Down Expand Up @@ -68,18 +70,34 @@ def dependencies
param :name, String, :desc => "The name of the changeset"
end
def create
@changeset = Changeset.new(params[:changeset])
csType = params[:changeset][:type]
if params[:changeset][:type] == 'PROMOTION'
@changeset = PromotionChangeset.new(params[:changeset])
elsif params[:changeset][:type] == 'DELETION'
@changeset = DeletionChangeset.new(params[:changeset])
else
raise HttpErrors::ApiError, _("Unknown changeset type, must be PROMOTION or DELETION: #{csType}")
end

@changeset.environment = @environment
@changeset.save!

render :json => @changeset
end

api :POST, "/changesets/:id/promote", "Promote a changeset into a new envrionment"
# DEPRICATED - TODO: Note this in the new API doc format
api :POST, "/changesets/:id/promote", "Promote a changeset into a new envrionment."
def promote
@changeset.state = Changeset::REVIEW
@changeset.save!
async_job = @changeset.promote :async => true
async_job = @changeset.apply :async => true
render :json => async_job, :status => 202
end

def apply
@changeset.state = Changeset::REVIEW
@changeset.save!
async_job = @changeset.apply :async => true
render :json => async_job, :status => 202
end

Expand Down