Bug 1126155 - hammer import organization summary shows count of users instead of organizations
Summary: hammer import organization summary shows count of users instead of organizations
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Satellite 6
Classification: Red Hat
Component: Transitions
Version: Unspecified
Hardware: Unspecified
OS: Unspecified
unspecified
high vote
Target Milestone: Unspecified
Assignee: Matej Kollar
QA Contact: Grant Gainey
URL:
Whiteboard:
Depends On:
Blocks: stargate-GA-tracker
TreeView+ depends on / blocked
 
Reported: 2014-08-02 20:00 UTC by Lukas Pramuk
Modified: 2014-09-11 12:27 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-09-11 12:27:05 UTC


Attachments (Terms of Use)

Description Lukas Pramuk 2014-08-02 20:00:55 UTC
Description of problem:
hammer import organization shows incorrect summary. It shows count of users not organizations.

Version-Release number of selected component (if applicable):
rubygem-hammer_cli_import-0.9.0-1.el6.noarch

How reproducible:
100%

Steps to Reproduce:
1.
# hammer import organization --csv-file /tmp/exports/users.csv 
Summary
  Found 281 organizations.

Actual results:
shows count of users (281) instead of organizations (10)

Expected results:
shows count organizations.

Comment 1 RHEL Product and Program Management 2014-08-02 20:03:37 UTC
Since this issue was entered in Red Hat Bugzilla, the release flag has been
set to ? to ensure that it is properly evaluated for this release.

Comment 3 Lukas Pramuk 2014-08-02 20:28:08 UTC
And hammer import user summary shows no count. I would expect there:
"  Found 281 users."

# hammer import user --csv-file /tmp/exports/users.csv --new-passwords $(mktemp -u) 
Summary

Comment 4 Matej Kollar 2014-08-05 15:02:17 UTC
Seemingly wrong numbers are caused by the fact that we reuse same CSV for organization and users, so organization is repeated multiple times. One possibility is to check whether entity (organization) is created before attempting to create it in subcommand subclass. This might lead to code duplication though. Will discuss this with other team members before I proceed.

Comment 5 Matej Kollar 2014-08-06 09:36:40 UTC
hammer-cli-import.git: 46067a049eb8a63f879aab5d44a7c76324af3f2e

Through discussion we decided to proceed the following way: Instead of changing messages or changes proposed in comment #4, show :found messages only on info log level.

Comment 6 Matej Kollar 2014-08-06 09:42:09 UTC
One more related patch, just a stylistic one though

hammer-cli-import.git: 6b2bc5c5c9183b048fafc0c317b5dffcde47bce1

Comment 8 Tazim Kolhar 2014-09-02 11:27:55 UTC
FAILEDQA:

# hammer import organization --csv-file test1.csv
[Foreman] username: admin
[Foreman] password for admin: 
Error: FasterCSV::MalformedCSVError

# cat test1.csv
"organization_id"=>5, 
"organization"=> jhutar

Comment 9 Grant Gainey 2014-09-02 11:38:05 UTC
Your test1.csv doesn't look anything like the output of "spacewalk-report users" - the tool is telling you exactly what it should.

Returning to ON_QA

Comment 10 Tazim Kolhar 2014-09-03 06:01:08 UTC
VERIFIED

installed spacewalk-report tool and tested

# hammer import organization --csv-file test1.csv 
[Foreman] username: admin
[Foreman] password for admin: 
Summary
  Found 11 organizations.

Comment 11 Tazim Kolhar 2014-09-03 09:14:43 UTC
shifting this to ON_QA as discussed in the email will be handled by  @ggainey

Comment 12 Grant Gainey 2014-09-04 15:28:45 UTC
DEVELOPER-VERIFIED:

===
~/tests $ hammer import organization --csv-file /root/tests/1126155.csv 
Summary
  Created 2 organizations.
~/tests $ hammer import user --csv-file /root/tests/1126155.csv --new-passwords pwds.txt
Summary
  Created 7 users.
~/tests $ cat 1126155.csv 
organization_id,organization,user_id,username,last_name,first_name,position,email,role,creation_time,last_login_time,active
1000,KiloCompany,1001,kc-admin,Nimda,Admin,,root@localhost,Organization Administrator;Satellite Administrator,2014-03-24 23:47:57,2014-08-27 22:12:07,enabled
1000,Kilo Company,1008,kc-channel-admin,Admin,Channel,admin,root@localhost,Channel Administrator,2014-05-05 19:43:38,,enabled
1000,Kilo Company,1012,kc-anewlogin,NewLastName,NewFirst,,anewlogin@not.an.email,,2014-07-31 18:46:37,,enabled
1000,Kilo Company,1013,kc-anewlogin1,NewLastName,NewFirst,,anewlogin1@not.an.email,,2014-07-31 18:47:11,,enabled
1000,Kilo Company,1014,kc-anewlogin2,NewLastName,NewFirst,,anewlogin2@not.an.email,,2014-07-31 18:47:40,,enabled
7000,Septimus,7009,sept-admin-1,Admin,SOE,,root@localhost,Organization Administrator,2014-05-06 00:55:02,2014-08-27 19:07:46,enabled
7000,Septimus,7011,sept-app-admin-1,Admin,App,,root@localhost,,2014-05-07 20:14:39,,enabled
===

As noted in c#5, in the log we notice every line:

===
I, [2014-09-04T11:22:02.356647 #15344]  INFO -- : Importing from /root/tests/1126155.csv
I, [2014-09-04T11:22:02.358207 #15344]  INFO -- : Creating new organization: KiloCompany
I, [2014-09-04T11:22:07.349130 #15344]  INFO -- : Organization [1000->5] already imported.
I, [2014-09-04T11:22:07.349564 #15344]  INFO -- : Organization [1000->5] already imported.
I, [2014-09-04T11:22:07.349911 #15344]  INFO -- : Organization [1000->5] already imported.
I, [2014-09-04T11:22:07.350246 #15344]  INFO -- : Organization [1000->5] already imported.
I, [2014-09-04T11:22:07.350597 #15344]  INFO -- : Creating new organization: Septimus
I, [2014-09-04T11:22:09.738496 #15344]  INFO -- : Organization [7000->6] already imported.
I, [2014-09-04T11:22:09.740440 #15344]  INFO -- : Summary
I, [2014-09-04T11:22:09.740709 #15344]  INFO -- :   Found 5 organizations.
I, [2014-09-04T11:22:09.740950 #15344]  INFO -- :   Created 2 organizations.
===

Verified against 0.10.4

Comment 13 Bryan Kearney 2014-09-11 12:27:05 UTC
This was delivered with Satellite 6.0 which was released on 10 September 2014.


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