Bug 1309944 - [RFE] Create/update composite content-view by content-view Names
Summary: [RFE] Create/update composite content-view by content-view Names
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Hammer - Content
Version: 6.1.5
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: Unspecified
Assignee: Andrew Kofink
QA Contact: Peter Ondrejka
URL: http://projects.theforeman.org/issues...
Whiteboard:
Depends On:
Blocks: 1167688
TreeView+ depends on / blocked
 
Reported: 2016-02-19 04:01 UTC by Amar Huchchanavar
Modified: 2019-08-12 14:08 UTC (History)
10 users (show)

Fixed In Version:
Doc Type: Enhancement
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-02-21 12:34:46 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Foreman Issue Tracker 14604 Normal Closed Create/update composite content-view by content-view Names 2020-08-31 16:25:18 UTC
Red Hat Product Errata RHSA-2018:0336 normal SHIPPED_LIVE Important: Satellite 6.3 security, bug fix, and enhancement update 2018-02-21 22:43:42 UTC

Comment 2 Andrew Kofink 2016-03-07 21:15:23 UTC
Katello::content_view names are unique to an organization, so we should be able to use find_by(name: ['name1', 'name2']).

Comment 3 Andrew Kofink 2016-03-07 21:40:35 UTC
Also, in order to add a content view to a composite view you must first publish an initial version of the content view. Right now, if finding components by ID, if you give hammer 4 IDs and only 3 are found, nothing happens. The same will be true of arrays that contain content_view names that are yet unpublished or do not exist.

Comment 4 Andrew Kofink 2016-03-08 15:56:24 UTC
Finding ContentViewVersion (CVV) objects by ContentView (CV) names may return multiple CVV objects. Should I make all CVVs a component of the parent CV, or should I add only the latest CVVs based on latest major.minor version number?

Comment 5 Andrew Kofink 2016-03-16 14:24:21 UTC
In order to get the latest CVV for a CV, this feature needs to be implemented as well: https://bugzilla.redhat.com/show_bug.cgi?id=1167688

Comment 7 Andrew Kofink 2016-04-13 12:05:25 UTC
Created redmine issue http://projects.theforeman.org/issues/14604 from this bug

Comment 8 Andrew Kofink 2016-05-02 12:29:51 UTC
CLI users can add a version to a composite with content view name, minor, and major options (e.g. `hammer content-view add-version --id 1 --component-content-view blah --component-major-version 1 --component-minor-version 2`)

Feedback on the PR states that this feature should not be implemented.

Comment 9 David Davis 2016-05-04 20:59:16 UTC
Andrew,

The parameters you mention should be there but they're not which means there is still a bug here. I would probably either fix as part of this bugzilla or open a new bugzilla.

Comment 10 David Davis 2016-05-04 21:02:06 UTC
By the way, sorry if there was any confusion in my PR feedback.

Comment 14 Andrew Kofink 2016-06-28 13:56:13 UTC
Final syntax:

hammer content-view add-version --id 2 --content-view-version 1.0 --content-view-version-content-view-id 3
hammer content-view remove-version --id 2 --content-view-version 1.0 --content-view-version-content-view-id 3

Comment 18 Peter Ondrejka 2016-10-19 12:59:18 UTC
Attempting to create a CCV on Satellite 6.3 snap 5:

# hammer content-view list

CONTENT VIEW ID | NAME        | LABEL     | COMPOSITE | LAST PUBLISHED      | REPOSITORY IDS
----------------|-------------|-----------|-----------|---------------------|---------------
5               | testview    | testview  |           | 2016/10/18 14:36:24 | 4, 2, 3       
3               | foo         | foo       |           | 2016/10/18 14:04:46 | 

When trying to create a composite with names (tried various versions with quotes for names, equal sign, etc.):

# hammer content-view create --name testcomposite --component-ids foo,testview --composite --organization-id 1
Could not create the content view:
  Couldn't find Katello::ContentViewVersion with 'id'=0

Whereas:
# hammer content-view create --name testcomposite --component-ids 5,3 --composite --organization-id 1
Content view created

Also, note that the change in functionality should be reflected in hammer help that currently reads:

Options:
 --component-ids COMPONENT_IDS           List of component content view version ids for composite views
                                         Comma separated list of values.

We should mention that component names can be used as well, maybe even change the option name that is strongly suggestive of IDs.

Comment 19 Bryan Kearney 2016-10-19 14:17:21 UTC
Upstream bug component is Hammer - Content

Comment 21 Andrew Kofink 2018-01-29 13:24:44 UTC
--component-ids does not work with names, as demonstrated in Comment 18. The way to add/remove components by version name is the following:

hammer content-view add-version --id 2 --content-view-version 1.0 --content-view-version-content-view-id 3
hammer content-view remove-version --id 2 --content-view-version 1.0 --content-view-version-content-view-id 3

Remember that the components of a composite content view are content view versions, not content views.

Comment 22 Peter Ondrejka 2018-01-31 14:19:21 UTC
Hi Andrew, looked again on Sat 6.3 snap 33, once I wrapped my head around it I can confirm the new member cvs can be added by name as this bug requested, though options look bit different:

]# hammer content-view add-version --id 3 --content-view test2 --content-view-version-id 2
The component version has been added

Though it would be nice if we could make help more informative for users, i.e. indicate which options relate to ccv and which to cv being added, currently we have:

~]# hammer content-view add-version -h
Usage:
    hammer content-view add-version [OPTIONS]

Options:
 --content-view CONTENT_VIEW_NAME                    Content view name to search by
 --content-view-id CONTENT_VIEW_ID                   content view numeric identifier
 --content-view-version CONTENT_VIEW_VERSION_VERSION Content view version number
 --content-view-version-id CONTENT_VIEW_VERSION_ID   Content view version identifier
 --id ID                                             content view numeric identifier
 --name NAME                                         Content view name to search by

Also trying to add a different version of a CV that is already in the CCV, fails, which is I suppose correct but the message could be more informative (not sure why I'm getting it twice):

~]# hammer content-view add-version --id 3 --content-view test2 --content-view-version-id 7
Could not add version:
  Validation failed: Content view components is invalid, Content view components is invalid

Anyways, let me know what you think

Comment 23 Andrew Kofink 2018-01-31 14:47:31 UTC
Yes, the error could definitely be better. There are 2 error messages because the composite content view is what is being validated here (server-side), and both versions associated (the existing one, and the one you are trying to add) are marked as incorrect because they're from the same component content view. I'm not sure the error message should block this bug or be reported as a separate bug. I will leave that up to you.

As for the help output, I'm not sure I understand the confusion. All the options in the output you posted either say "content_view_*" or "content_view_version_*". Perhaps I'm missing something here?

Comment 24 Peter Ondrejka 2018-02-02 13:16:26 UTC
Ok, I'm not going to block this bz on those nitpicks, I went with creating http://projects.theforeman.org/issues/22498

In that help I meant the right side, these explanations are the same for the cv and the ccv part.

Comment 25 Andrew Kofink 2018-02-02 14:36:41 UTC
Ah, yeah I see what you mean. Specifically `--id` and `--content-view-id`. Thanks for reporting the issue! I cloned it to BZ and set ? for 6.3.z

Comment 28 errata-xmlrpc 2018-02-21 12:34:46 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2018:0336


Note You need to log in before you can comment on or make changes to this bug.