Project

General

Profile

Revision 0c7641a0

Added by Thomas McKay over 8 years ago

pfacts - facts working

View differences:

hammer-it
7 7
bundle exec hammer -v csv:domains            --verbose --csv-file test/data/domains.csv
8 8
bundle exec hammer -v csv:puppetenvironments --verbose --csv-file test/data/puppetenvironments.csv
9 9
bundle exec hammer -v csv:operatingsystems   --verbose --csv-file test/data/operatingsystems.csv
10
bundle exec hammer -v csv:hosts              --verbose --csv-file test/data/hosts.csv
10
bundle exec hammer -v csv:hosts              --verbose --csv-file test/data/hosts.csv
11
bundle exec hammer -v csv:puppetfacts        --verbose --csv-file test/data/puppetfacts.csv
lib/hammer_cli_csv/architectures.rb
41 41
module HammerCLICsv
42 42
  class ArchitecturesCommand < BaseCommand
43 43

  
44
    NAME = 'Name'
45
    COUNT = 'Count'
46 44
    OPERATINGSYSTEMS = 'Operating Systems'
47 45

  
48 46
    def execute
lib/hammer_cli_csv/base.rb
32 32
module HammerCLICsv
33 33
  class BaseCommand < HammerCLI::AbstractCommand
34 34

  
35
    NAME = 'Name'
36
    COUNT = 'Count'
37

  
35 38
    HEADERS = {'Accept' => 'version=2,application/json'}
36 39

  
37 40
    option ["-v", "--verbose"], :flag, "be verbose"
......
94 97
        lines = csv[start_index...finish_index].clone
95 98
        splits << Thread.new do
96 99
          lines.each do |line|
97
            if line.index('#') != 0
100
            if line[NAME][0] != '#'
98 101
              yield line
99 102
            end
100 103
          end
lib/hammer_cli_csv/domains.rb
40 40
module HammerCLICsv
41 41
  class DomainsCommand < BaseCommand
42 42

  
43
    NAME = 'Name'
44
    COUNT = 'Count'
45 43
    FULLNAME = 'Full Name'
46 44

  
47 45
    def execute
lib/hammer_cli_csv/hosts.rb
48 48
module HammerCLICsv
49 49
  class HostsCommand < BaseCommand
50 50

  
51
    NAME = 'Name'
52
    COUNT = 'Count'
53 51
    ORGANIZATION = 'Organization'
54 52
    ENVIRONMENT = 'Environment'
55 53
    OPERATINGSYSTEM = 'Operating System'
lib/hammer_cli_csv/operating_systems.rb
43 43
module HammerCLICsv
44 44
  class OperatingSystemsCommand < BaseCommand
45 45

  
46
    NAME = 'Name'
47
    COUNT = 'Count'
48 46
    FAMILY = 'Family'
49 47
    ARCHITECTURES = 'Architectures'
50 48
    PARTITIONTABLES = 'Partition Tables'
lib/hammer_cli_csv/organizations.rb
46 46
module HammerCLICsv
47 47
  class OrganizationsCommand < BaseCommand
48 48

  
49
    NAME = 'Name'
50
    COUNT = 'Count'
51 49
    ORGLABEL = 'Org Label'
52 50
    DESCRIPTION = 'Description'
53 51

  
lib/hammer_cli_csv/partition_tables.rb
40 40
module HammerCLICsv
41 41
  class PartitionTablesCommand < BaseCommand
42 42

  
43
    NAME = 'Name'
44
    COUNT = 'Count'
45 43
    OSFAMILY = 'OS Family'
46 44
    LAYOUT = 'Layout'
47 45

  
lib/hammer_cli_csv/puppet_environments.rb
40 40
module HammerCLICsv
41 41
  class PuppetEnvironmentsCommand < BaseCommand
42 42

  
43
    NAME = 'Name'
44
    COUNT = 'Count'
45

  
46 43
    def execute
47 44
      super
48 45
      csv_export? ? export : import
lib/hammer_cli_csv/puppet_facts.rb
42 42
module HammerCLICsv
43 43
  class PuppetFactsCommand < BaseCommand
44 44

  
45
    NAME = 'Name'
46
    COUNT = 'Count'
47

  
48 45
    def execute
49 46
      super
50 47
      csv_export? ? export : import
......
88 85
        return
89 86
      end
90 87

  
91
      puts line
92 88
      line[COUNT].to_i.times do |number|
93 89
        name = namify(line[NAME], number)
94 90
        print "Updating puppetfacts '#{name}'..." if verbose?
......
99 95
        # Namify the values if the host name was namified
100 96
        if name != line[NAME]
101 97
          facts.each do |fact, value|
102
            facts[fact] = namify(value, number)
98
            facts[fact] = namify(value, number) unless value.nil? || value.empty?
103 99
          end
104 100
        end
105 101

  
lib/hammer_cli_csv/users.rb
44 44
module HammerCLICsv
45 45
  class UsersCommand < BaseCommand
46 46

  
47
    NAME = 'Login'
48
    COUNT = 'Count'
49 47
    FIRSTNAME = 'First Name'
50 48
    LASTNAME = 'Last Name'
51 49
    EMAIL = 'Email'
test/data/hosts.csv
1 1
Name,Count,Organization,Environment,Operating System,Architecture,MAC Address,Domain,Partition Table
2
dhcp129-0%02d.megacorp.com,5,Mega Corporation,Development,RHEL 6.4,x86_64,"14:FE:B5:EA:70:%02x",megacorp.com,RedHat default
3
dhcp129-4%02d.megacorp.com,5,Mega Corporation,Development,RHEL 6.3,x86_64,"FE:54:00:EB:83:%02x",megacorp.com,RedHat default
2
dhcp129-0%02d.megacorp.com,99,Mega Corporation,Development,RHEL 6.4,x86_64,"14:FE:B5:E0:70:%02x",megacorp.com,RedHat default
3
dhcp129-1%02d.megacorp.com,99,Mega Corporation,Development,RHEL 6.4,x86_64,"14:FE:B5:E1:70:%02x",megacorp.com,RedHat default
4
dhcp129-2%02d.megacorp.com,99,Mega Corporation,Development,RHEL 6.4,x86_64,"14:FE:B5:E2:70:%02x",megacorp.com,RedHat default
5
dhcp129-3%02d.megacorp.com,99,Mega Corporation,Development,RHEL 6.4,x86_64,"14:FE:B5:E3:70:%02x",megacorp.com,RedHat default
6
dhcp129-4%02d.megacorp.com,99,Mega Corporation,Development,RHEL 6.3,x86_64,"FE:54:00:E4:83:%02x",megacorp.com,RedHat default
7
dhcp129-5%02d.megacorp.com,99,Mega Corporation,Development,RHEL 6.3,x86_64,"FE:54:00:E5:83:%02x",megacorp.com,RedHat default
8
dhcp129-6%02d.megacorp.com,99,Mega Corporation,Development,RHEL 6.3,x86_64,"FE:54:00:E6:83:%02x",megacorp.com,RedHat default
9
dhcp129-7%02d.megacorp.com,99,Mega Corporation,Development,RHEL 6.3,x86_64,"FE:54:00:E7:83:%02x",megacorp.com,RedHat default
10
dhcp129-8%02d.megacorp.com,99,Mega Corporation,Development,RHEL 6.3,x86_64,"FE:54:00:E8:83:%02x",megacorp.com,RedHat default
11
dhcp129-9%02d.megacorp.com,99,Mega Corporation,Development,RHEL 6.3,x86_64,"FE:54:00:E9:83:%02x",megacorp.com,RedHat default
test/data/puppetfacts.csv
1
Name,Count,selinux_enforced,memorysize,selinux_policyversion,selinux,manufacturer,boardmanufacturer,architecture,selinux_config_policy,serialnumber,memorytotal,hardwareisa,operatingsystem,productname,uptime_hours,facterversion,hardwaremodel,kernel,boardproductname,swapsize,virtual,selinux_current_mode,processorcount,boardserialnumber,id,type,timezone,sshrsakey,lsbrelease,physicalprocessorcount,selinux_mode,ps,selinux_config_mode,osfamily,memoryfree,is_virtual,processor3,processor2,processor1,processor0,uptime_seconds
2
#dhcp129-0%02d.megacorp.com,99,TRUE,3.66 GB,28,TRUE,LENOVO,LENOVO,x86_64,unknown,R86RDMD,3.66 GB,x86_64,Fedora,2537CT4,123,1.6.18,x86_64,Linux,2537CT4,5.66 GB,physical,enforcing,4,1ZHXC0ARARX,root,Notebook,IDT,AAAAB3NzaC1yc2EAAAADAQABAAABAQDV4XXI/DFJ05PKdgUpJD0KQTC75DpQWkgPqcYJezPulFSIH/Cgm5aFSACAFqcs0iKhmad7kSyvLU+V765YImwBVbrlu+e3qECuF28WCNXaFBdEeookTXRhn+SjrZlkM0YZlc1HFH0fjTxhO8DZ2RcteF1hW3kFb7uRuP18m6teWZsNRJNGdY7LtSp0adpKdVAz20wVw6WBdVXuroXIv53lqsFFsnum/f3Llvo2LGvveYdrULO0OouXRSAvHzaaSJXDgVViybxe5/THdrbvH1aNBeSF0VjSgPEMMtcSxq/yooLgMmg4NGt49gs2ARNrr1vwVvX6oO+iTu+di/BAVTPv,:core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch,1,unknown,ps -ef,enforcing,RedHat,2.43 GB,FALSE,Intel(R) Core(TM) i5 CPU       M 540  @ 2.53GHz,Intel(R) Core(TM) i5 CPU       M 540  @ 2.53GHz,Intel(R) Core(TM) i5 CPU       M 540  @ 2.53GHz,Intel(R) Core(TM) i5 CPU       M 540  @ 2.53GHz,443234
3
dhcp129-1%02d.megacorp.com,99,TRUE,995.56 MB,28,TRUE,Red Hat,,x86_64,unknown,Not Specified,995.56 MB,x86_64,Fedora,KVM,0,1.6.18,x86_64,Linux,,2.03 GB,kvm,enforcing,1,,root,Other,UTC,AAAAB3NzaC1yc2EAAAADAQABAAABAQDomqiC/SbY95t2/PEUgFikdr3NSdkaLVZ/5esOzPGKdTutI0dQaVU1dvpAXIBKomkNerIsJ8EF7NItEdZ6X2WdlXb/x+zeRv+7bU4/Acc9lHrQM6weMg4psBo4rUdivHM8IinQDmH3LUskskpN24QUllBnMiZjIqxYioJMQVWIgSbNxnmxYOaJBFoq6fgwnspD0wwm9cQaogf9tOvLQ6SLjTJdnnU8MFOj9F/vSZGE25FSeoKHI8FGvzaJwdljTnhRvokRZg0PyEfnbJUWujfOdS8yw/AZPbqZGlItwOvumLuiuKFTYoFmFrBzCNqmPXVJsDakbPp1Udnzcsh+0Kbb,,1,unknown,ps -ef,enforcing,RedHat,867.86 MB,TRUE,,,,QEMU Virtual CPU version (cpu64-rhel6),517
4
dhcp129-2%02d.megacorp.com,99,TRUE,742.66 MB,24,TRUE,Red Hat,,x86_64,targeted,Not Specified,742.66 MB,x86_64,CentOS,KVM,71,1.6.18,x86_64,Linux,,1.47 GB,kvm,enforcing,1,,root,Other,GMT,AAAAB3NzaC1yc2EAAAABIwAAAQEAmBrQDH7tAB2cMQ+0/kq001RPUnCHbKlNyz/q7bHXOXX/25Evh5pGhldTPNPAKa0YnmIImmhJzbpTcaLcwT3A2iNV2gE+v+BbcndZpENfRp3acxRU5PdjX5ot23FCzee34lZTw09aWbB+f+3IuARjtZvWCGyhw36MuQ6g+WJjUELPr/9v5/oBq62i35iTSzzPI8QaBFXA+Sf/AStH+Qt09y8Nqd/ZiyymFEewjqYnNDabTra9+Wyynwf5osnY6SLZ5xzDfZCBYYvbuO086RVWF7NPJmXGgTXfbz41OGnOSRcpX0B3rAoJa04kkVf5ntF/a7dpEPWk8g6czaH+ISffGw==,,1,targeted,ps -ef,enforcing,RedHat,561.82 MB,TRUE,,,,QEMU Virtual CPU version (cpu64-rhel6),257463
5
dhcp129-4%02d.megacorp.com,99,TRUE,3.70 GB,28,TRUE,Dell Inc.,Dell Inc.,x86_64,unknown,JDTFM4J,3.70 GB,x86_64,Fedora,OptiPlex 780,7,1.6.18,x86_64,Linux,03NVJ6,5.69 GB,physical,enforcing,2,..CN7360499B01O7.,root,Space-saving,IDT,AAAAB3NzaC1yc2EAAAADAQABAAABAQDZnxMEA0zLC/sf9/OKxq+GUm39nELFee8YpEf7dzL+jYTR0lb1SDt0Yn73prRsFF59Z0LSqgM3iumaaiPCtvKSfnn+3xbxXw007jiJqFN/zvPMlbRC64+xY+kXYSM5PPLfbz73BlTAxtSPwyPU6wlrYYDTmwSvlsnLwKJr6t/iR5NAwJ7PRlpC7qi0mklvx6xV5z0qSC2zpgGbTkWuQ5FE27m+wEQyiqMEQnBo/70YUxA1rlXoKWtXKTIHdRkiO8NF3yXpEEC0bA+wQ1CHCI53xn8IV1O6IQLluMdE4itD32L6+3jgZdagm5qhrayVCY4s47M47zu8sl3dF5qYVp+9,,1,unknown,ps -ef,enforcing,RedHat,,FALSE,,,Intel(R) Core(TM)2 Duo CPU     E7500  @ 2.93GHz,Intel(R) Core(TM)2 Duo CPU     E7500  @ 2.93GHz,27269
6
dhcp129-5%02d.megacorp.com,99,,712.15 MB,,FALSE,"VMware, Inc.",Intel Corporation,x86_64,,VMware-42 29 8c 81 3d 2c c7 14-ba d1 03 26 01 29 6e 31,712.15 MB,x86_64,Fedora,VMware Virtual Platform,7834,1.6.6,x86_64,Linux,440BX Desktop Reference Platform,1.41 GB,vmware,,1,None,root,Other,EST,AAAAB3NzaC1yc2EAAAADAQABAAABAQDJU4BnwAyy3NqHRdSxKGroKdFq/ozFArR3OQNEtQY+EIYQ1w+yAte4g3dTkGliS7VDlnO7PKRJpShpTnovQGZ5f7rqNs8XGwqG4qggGF/aZzBO88sEPTTW5lUhDGpoSa5BiiL8VM2RTOPaE7Wne8HgVQo92nHaj9SCqHSmWDixOcBPgRSCZoSr+clBQ0LvHjjwXDr7mrvxFdXc6EiI87DbgRJbw4wD4IfXdWvzp5mhEBPTzMrcdBE8Njbe6oK1nypnAWb2ejZMmu8uDNWfbSoRWcP+PQtxo3hbWE4RglfcHL19V+sa3bb4Iya9xA82ehBKvGX8G/l77EqRM7LcrvCl,,1,,ps -ef,,RedHat,552.79 MB,TRUE,,,,Quad-Core AMD Opteron(tm) Processor 2344 HE,28202723
7
dhcp129-7%02d.megacorp.com,99,,996.50 MB,,FALSE,Red Hat,,x86_64,,Not Specified,996.50 MB,x86_64,CentOS,KVM,373,1.6.18,x86_64,Linux,,1.97 GB,kvm,,2,,root,Other,GMT,AAAAB3NzaC1yc2EAAAABIwAAAQEAz4BrW/qPfBThnLai1IAwpMa1kLgOu4iZOBuwiUwlWaX04pGOXnfNytYnCzlf3NAHoM3knNIbSGgjnlkdcQfyhlreqg3GcdNnDj6BTisH7ZLPJNUl9oMcFEzX7J8Ik6qyfkdNVzuU1EgU0XUYXdkgpPlFbr6I6HVTQGUeyy7pFGje2gW3ijukFap/gFPsrMPIczL+RSv26p4Mvez1xtfZsYXL1+oYs1pijgNNe00SajZ5nGkHW/ba79WjzrwITSorRJqyi+LPCJTzZm8Z3Px/lHqJB/y2ABmyqPDnHEMGvqy7avrNJX4o0sEER8MiHrus5jzwfVcfCJjcDMHCNvu0ZQ==,,2,,ps -ef,,RedHat,246.50 MB,TRUE,,,QEMU Virtual CPU version (cpu64-rhel6),QEMU Virtual CPU version (cpu64-rhel6),1344166
8
dhcp129-8%02d.megacorp.com,99,TRUE,996.66 MB,24,TRUE,Red Hat,,x86_64,targeted,Not Specified,996.66 MB,x86_64,CentOS,KVM,373,1.6.18,x86_64,Linux,,1.97 GB,kvm,enforcing,1,,root,Other,GMT,AAAAB3NzaC1yc2EAAAABIwAAAQEAtrOAN7oTm8enSDx6th8PrgoM2yZlM5gXChi4kza+zLph7XI8I9PCtiB+KMSJW8mvdqUbLluZYvnNCxDHzNGAfSv2uaRHA7nRo8PzVNvQzv9NQQlwJSUTsqVfqZbLzzT+dCqSkxjutUnYP4p5CsjsyzQhQNRiPI79rAvqk7xi0ztwowdrCk0/wTrndc63KS9/wRzGCEGXzzDg+iP/jDWE29Bx4S+5Te3rdSo9sKdSbuXl8h11P60Bx+TeQOdxn2gs4c/eEnKvMJd4c+/V+19Asc9Yu1UermUvzjYaabraHa0jWZ4y5gUNRu0g3E7n4Y8f95hKeHonfe/3X/+YQ0h2uQ==,,1,targeted,ps -ef,enforcing,RedHat,753.97 MB,TRUE,,,,QEMU Virtual CPU version (cpu64-rhel6),1343820
9
dhcp129-8%02d.megacorp.com,99,TRUE,5.63 GB,28,TRUE,LENOVO,LENOVO,x86_64,unknown,R987MPW,5.63 GB,x86_64,Fedora,3680B56,101,1.6.18,x86_64,Linux,3680B56,7.62 GB,physical,enforcing,4,1ZHWH0AF1NK,root,Notebook,IST,AAAAB3NzaC1yc2EAAAADAQABAAABAQCm159/GgIZVLznpCuGyG789j+6OAvIqiB1NYjIW5kVfzMvrlE+6WvH2zarKy1Hr/43lTYBqy0H5DE2IiREvjrJhBE/CRRqaFNqXvMAHsh9IakeiQ6dDb665SvZIGhV4eEJzgkgxYJJ8PiPOUFySSWtlWNDJ9cpK9WnGWHvKEuwHIj3HA3YB9q+j0Qu04dqC8Y9qzARjPoNQX+jh0epGgYQKG/xcVx/dIXjxRV4PQbVnoJ9Q87dfvp+qV4FW81S/vKcKjab+8BGGrXSFuRBmIHzfElb7F6JgOE4SzrfEtFdvldk9H6jk7r3a6Uz9fIkMODZ4J0OP8DyuUXfscnW3xSF,:core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch,1,unknown,ps -ef,enforcing,RedHat,1.58 GB,FALSE,Intel(R) Core(TM) i5 CPU       M 540  @ 2.53GHz,Intel(R) Core(TM) i5 CPU       M 540  @ 2.53GHz,Intel(R) Core(TM) i5 CPU       M 540  @ 2.53GHz,Intel(R) Core(TM) i5 CPU       M 540  @ 2.53GHz,363947
test/data/users.csv
1
Login,Count,First Name,Last Name,Email
1
Name,Count,First Name,Last Name,Email
2 2
damon.dials@megacorp.org,1,damon,dials,damon.dials@megacorp.org
3 3
jenee.jahns@megacorp.org,1,Jenee,Jahns,jenee.jahns@megacorp.org
4 4
gilbert.guerriero@megacorp.org,1,Gilbert,Guerriero,gilbert.guerriero@megacorp.org

Also available in: Unified diff