Project

General

Profile

Actions

Bug #20785

closed

Kickstart repository assigned in UI to hostgroup difficult to set using Hammer

Added by Ondřej Pražák over 6 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
High
Category:
-
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

Assigning kickstart repository to hostgroup works in UI. Synced Content dropdown makes sure that only kickstart repos from lifecycle env and content view (previously selected in the form) can be selected as a synced content.
Using hammer/API, there are no checks. Any existing repository id can be passed as --kickstart-repository-id and it is accepted. We should not allow repositories that are not in associated content view to be set.

More importantly, there are multiple records with the same repo name, but user is always presented only with one record representing the repo. This makes it impossible to assign the same repo via hammer as I did using UI, because I cannot list all the repo records and find out the id for kickstart repo in a lifecycle environment.

Steps to reproduce:

1) create kickstart repo, sync, add to content view, publish

Mine looks like this, notice the kickstart repo ids:

[root@foreman ~]# hammer content-view info --id 2
ID:                     2
Name:                   RHEL 7 SOE
Label:                  RHEL_7_SOE
Composite:              false
Description:            Standard Operating Environment for RHEL7
Content Host Count:     0
Organization:           Default Organization
Yum Repositories:       
 1) ID:    1
    Name:  Red Hat Enterprise Linux 7 Server Kickstart x86_64 7.4
    Label: Red_Hat_Enterprise_Linux_7_Server_Kickstart_x86_64_7_4
 2) ID:    2
    Name:  Red Hat Enterprise Linux 7 Server RPMs x86_64 7Server
    Label: Red_Hat_Enterprise_Linux_7_Server_RPMs_x86_64_7Server
 3) ID:    3
    Name:  Tools
    Label: Tools
Docker Repositories:    

OSTree Repositories:    

Puppet Modules:         

Lifecycle Environments: 
 1) ID:   1
    Name: Library
Versions:               
 1) ID:        2
    Version:   1.0
    Published: 2017/08/29 06:40:41
Components:             

Activation Keys:        
 1) ak-rhel-7

[root@foreman ~]# hammer content-view version info --environment Library --content-view-id 2
ID:                     2
Name:                   RHEL 7 SOE 1.0
Version:                1.0
Description:            
Content View ID:        2
Content View Name:      RHEL 7 SOE
Content View Label:     RHEL_7_SOE
Lifecycle Environments: 
 1) ID:    1
    Name:  Library
    Label: Library
Repositories:           
 1) ID:    8
    Name:  Tools
    Label: Tools
 2) ID:    6
    Name:  Red Hat Enterprise Linux 7 Server RPMs x86_64 7Server
    Label: Red_Hat_Enterprise_Linux_7_Server_RPMs_x86_64_7Server
 3) ID:    4
    Name:  Red Hat Enterprise Linux 7 Server Kickstart x86_64 7.4
    Label: Red_Hat_Enterprise_Linux_7_Server_Kickstart_x86_64_7_4

2) go to the UI, create a hostgroup with content view from step 1) and appropriate lifecycle env (Library in my case), select kickstart repo and save
3) find out the id of kickstart repo assigned to hostgroup, use curl because hammer does not support this:

[root@foreman ~]# curl -H "Accept: application/json" -H "Content-Type: application/json" -k -X GET -u admin:changeme https://$(hostname)/api/v2/hostgroups/3 | json_reformat
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1586    0  1586    0     0   9598      0 --:--:-- --:--:-- --:--:--  9612
{
    "content_source_id": 1,
    "content_source_name": "cisco-c240m3-01.rhts.eng.bos.redhat.com",
    "content_view_id": 2,
    "content_view_name": "RHEL 7 SOE",
    "lifecycle_environment_id": 1,
    "lifecycle_environment_name": "Library",
    "kickstart_repository_id": 5,
    "subnet_id": 1,
    "subnet_name": "192.168.73.0/24",
    "operatingsystem_id": 1,
    "operatingsystem_name": "RHEL Server 7.4",
    "domain_id": 2,
    "domain_name": "example.com",
    "environment_id": 1,
...

4) Both 'content-view info' and 'content-view version info' show the kickstart repos, but they have ids 1 and 4, not 5. There is no way to get the id of the repo that was assigned in UI, because it is never listed.

Maybe we could add kickstart_repository_name and handle the association of correct record because we know lifecycle env and content view.


Related issues 3 (0 open3 closed)

Related to Katello - Bug #21146: show kickstart repository name in hammer ClosedPartha Aji09/27/2017Actions
Related to Katello - Bug #21147: show kickstart repository name in content facet jsonClosedPartha Aji09/27/2017Actions
Related to Katello - Bug #21196: Support kickstart repository name parameter for host and hostgroupClosedPartha Aji10/04/2017Actions
Actions #1

Updated by John Mitsch over 6 years ago

  • Subject changed from Kickstart repository assigned in UI to hostgroup cannot be assigned using Hammer to Kickstart repository assigned in UI to hostgroup difficult to set using Hammer
  • translation missing: en.field_release set to 250

a workaround is to use -d and look at API output

Actions #2

Updated by Andrew Kofink over 6 years ago

  • Target version set to 160
Actions #3

Updated by Brad Buckingham over 6 years ago

  • Target version changed from 160 to 217
Actions #4

Updated by Jonathon Turel over 6 years ago

  • Status changed from New to Assigned
  • Assignee set to Jonathon Turel
Actions #5

Updated by Partha Aji over 6 years ago

  • Related to Bug #21146: show kickstart repository name in hammer added
Actions #6

Updated by Partha Aji over 6 years ago

  • Related to Bug #21147: show kickstart repository name in content facet json added
Actions #7

Updated by Partha Aji over 6 years ago

I have addressed couple of points referred to in this issue. Mainly the display of Kickstart repository name for hostgroups and hosts via hammer. Look at the associated issues (21146 and 21147).

Basically the repository information you see when you run

hammer content-view info --id 2

is different . That shows the list of repositories associated to the unpublished content view (i.e repos you added/removed).

What we are interested w.r.t KS repository id is the repository id pointing to a content view environment which you have appropriately captured with

# hammer content-view version info --environment Library --content-view-id 2

Given that the issue of ks repo display in hammer is being handled I propose scope of this bug be reduced to

  1. Using hammer/API, there are no checks. Any existing repository id can be passed as --kickstart-repository-id and it is accepted. We should not allow repositories that are not in associated content view to be set.
  2. Maybe we could add kickstart_repository_name and handle the association of correct record because we know lifecycle env and content view.

The latter may require to be addressed in a separate redmine issue depending on where the change is...

Actions #8

Updated by Partha Aji over 6 years ago

For the validation you probably need a logic that looks like

      validate :check_kickstart_repository, allow_blank: true

      def check_kickstart_repository(record)
        if !host.operatingsystem.is_a?(Redhat)
          msg = _("Cannot associate a kickstart repository to a host belonging to non-redhat family.")
          errors.add(:kickstart_repository, msg)
        elsif content_source.blank?
          msg = _("Cannot associate a kickstart repository: No content source selected")
          errors.add(:kickstart_repository, msg)
        elsif !host.operatingsystem.kickstart_repos(host).any? { |repo| repo[:id] == kickstart_repository_id }
          msg = _("No such repository in the hosts content view, environment, content source, os and architecture ")
          errors.add(:kickstart_repository, msg)
        end
      end

in your katello/app/models/katello/host/content_facet.rb

Actions #9

Updated by Jonathon Turel over 6 years ago

  • Related to Bug #21196: Support kickstart repository name parameter for host and hostgroup added
Actions #10

Updated by Jonathon Turel over 6 years ago

For now I am going to address the validation issues mentioned here. I've opened a separate issue to track supporting the KS repo name for host and hostgroup: http://projects.theforeman.org/issues/21196

Actions #11

Updated by The Foreman Bot over 6 years ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/Katello/katello/pull/6987 added
Actions #12

Updated by Brad Buckingham over 6 years ago

  • Target version changed from 217 to 225
Actions #13

Updated by The Foreman Bot over 6 years ago

  • Pull request https://github.com/Katello/katello/pull/7011 added
Actions #14

Updated by The Foreman Bot over 6 years ago

  • Pull request https://github.com/Katello/katello/pull/7014 added
Actions #15

Updated by Jonathon Turel over 6 years ago

  • Pull request deleted (https://github.com/Katello/katello/pull/7011, https://github.com/Katello/katello/pull/6987)
Actions #16

Updated by Anonymous over 6 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100
Actions

Also available in: Atom PDF