Project

General

Profile

Revision 5146ac68

Added by Thomas McKay almost 7 years ago

myriad changes in attempt to get import working against master/develop

View differences:

lib/hammer_cli_csv/hosts.rb
12 12
      MACADDRESS = 'MAC Address'
13 13
      DOMAIN = 'Domain'
14 14
      PARTITIONTABLE = 'Partition Table'
15
      SUBNET = 'Subnet'
16
      REALM = 'Realm'
17
      MEDIUM = 'Medium'
18
      HOSTGROUP = 'Hostgroup'
19
      COMPUTERESOURCE = 'Compute Resource'
20
      COMPUTEPROFILE = 'Compute Profile'
21
      IMAGE = 'Image'
22
      ENABLED = 'Enabled'
23
      MANAGED = 'Managed'
15 24

  
16 25
      def export
17 26
        CSV.open(option_file || '/dev/stdout', 'wb', {:force_quotes => true}) do |csv|
18
          csv << [NAME, ORGANIZATION, LOCATION, ENVIRONMENT, OPERATINGSYSTEM, ARCHITECTURE, MACADDRESS, DOMAIN, PARTITIONTABLE]
27
          csv << [NAME, ORGANIZATION, LOCATION, ENVIRONMENT, OPERATINGSYSTEM, ARCHITECTURE,
28
                  MACADDRESS, DOMAIN, PARTITIONTABLE, SUBNET, REALM, MEDIUM, HOSTGROUP,
29
                  COMPUTERESOURCE, COMPUTEPROFILE, IMAGE, ENABLED, MANAGED]
19 30
          search_options = {:per_page => 999999}
20 31
          search_options['search'] = "organization=\"#{option_organization}\"" if option_organization
21 32
          @api.resource(:hosts).call(:index, search_options)['results'].each do |host|
......
31 42
            mac = host['mac']
32 43
            domain = host['domain_name']
33 44
            ptable = host['ptable_name']
45
            subnet = host['subnet_name']
46
            realm = host['realm_name']
47
            medium = host['medium_name']
48
            hostgroup = host['hostgroup_name']
49
            compute_resource = host['compute_resource_name']
50
            compute_profile = host['compute_profile_name']
51
            image = host['image_name']
34 52

  
35
            csv << [name, organization, location, environment, operatingsystem, architecture, mac, domain, ptable]
53
            enabled = host['enabled'] ? 'Yes' : 'No'
54
            managed = host['managed'] ? 'Yes' : 'No'
55

  
56
            csv << [name, organization, location, environment, operatingsystem, architecture,
57
                    mac, domain, ptable, subnet, realm, medium, hostgroup, compute_resource,
58
                    compute_profile, image, enabled, managed]
36 59
          end
37 60
        end
38 61
      end

Also available in: Unified diff