Revision c06f1783
Added by Thomas McKay over 6 years ago
lib/hammer_cli_csv/subnets.rb | ||
---|---|---|
19 | 19 |
DNS_SECONDARY = 'DNS Secondary' |
20 | 20 |
VLAN_ID = 'VLAN ID' |
21 | 21 |
|
22 |
def export |
|
23 |
CSV.open(option_file || '/dev/stdout', 'wb', {:force_quotes => true}) do |csv| |
|
24 |
csv << [NAME, ORGANIZATIONS, LOCATIONS, NETWORK, NETWORK_MASK, |
|
25 |
NETWORK_FROM, NETWORK_TO, DOMAINS, GATEWAY, DHCP_PROXY, TFTP_PROXY, DNS_PROXY, |
|
26 |
DNS_PRIMARY, DNS_SECONDARY, VLAN_ID] |
|
27 |
@api.resource(:subnets).call(:index, {:per_page => 999999})['results'].each do |subnet| |
|
28 |
subnet = @api.resource(:subnets).call(:show, {'id' => subnet['id']}) |
|
22 |
def export(csv) |
|
23 |
csv << [NAME, ORGANIZATIONS, LOCATIONS, NETWORK, NETWORK_MASK, |
|
24 |
NETWORK_FROM, NETWORK_TO, DOMAINS, GATEWAY, DHCP_PROXY, TFTP_PROXY, DNS_PROXY, |
|
25 |
DNS_PRIMARY, DNS_SECONDARY, VLAN_ID] |
|
26 |
@api.resource(:subnets).call(:index, {:per_page => 999999})['results'].each do |subnet| |
|
27 |
subnet = @api.resource(:subnets).call(:show, {'id' => subnet['id']}) |
|
29 | 28 |
|
30 |
name = subnet['name'] |
|
31 |
organizations = export_column(subnet, 'organizations', 'name') |
|
32 |
locations = export_column(subnet, 'locations', 'name') |
|
33 |
network = subnet['network'] |
|
34 |
network_mask = subnet['mask'] |
|
35 |
network_from = subnet['from'] |
|
36 |
network_to = subnet['to'] |
|
37 |
domains = export_column(subnet, 'domains', 'name') |
|
38 |
gateway = subnet['gateway'] |
|
39 |
dhcp_proxy = (subnet['dhcp'] && subnet['dhcp'].key?('name')) ? subnet['dhcp']['name'] : '' |
|
40 |
tftp_proxy = (subnet['tftp'] && subnet['tftp'].key?('name')) ? subnet['tftp']['name'] : '' |
|
41 |
dns_proxy = (subnet['dns'] && subnet['dns'].key?('name')) ? subnet['dns']['name'] : '' |
|
42 |
dns_primary = subnet['dns_primary'] |
|
43 |
dns_secondary = subnet['dns_secondary'] |
|
44 |
vlan_id = subnet['vlanid'] |
|
45 |
csv << [name, organizations, locations, network, network_mask, |
|
46 |
network_from, network_to, domains, gateway, dhcp_proxy, tftp_proxy, dns_proxy, |
|
47 |
dns_primary, dns_secondary, vlan_id] |
|
48 |
end |
|
29 |
name = subnet['name'] |
|
30 |
organizations = export_column(subnet, 'organizations', 'name') |
|
31 |
locations = export_column(subnet, 'locations', 'name') |
|
32 |
network = subnet['network'] |
|
33 |
network_mask = subnet['mask'] |
|
34 |
network_from = subnet['from'] |
|
35 |
network_to = subnet['to'] |
|
36 |
domains = export_column(subnet, 'domains', 'name') |
|
37 |
gateway = subnet['gateway'] |
|
38 |
dhcp_proxy = (subnet['dhcp'] && subnet['dhcp'].key?('name')) ? subnet['dhcp']['name'] : '' |
|
39 |
tftp_proxy = (subnet['tftp'] && subnet['tftp'].key?('name')) ? subnet['tftp']['name'] : '' |
|
40 |
dns_proxy = (subnet['dns'] && subnet['dns'].key?('name')) ? subnet['dns']['name'] : '' |
|
41 |
dns_primary = subnet['dns_primary'] |
|
42 |
dns_secondary = subnet['dns_secondary'] |
|
43 |
vlan_id = subnet['vlanid'] |
|
44 |
csv << [name, organizations, locations, network, network_mask, |
|
45 |
network_from, network_to, domains, gateway, dhcp_proxy, tftp_proxy, dns_proxy, |
|
46 |
dns_primary, dns_secondary, vlan_id] |
|
49 | 47 |
end |
50 | 48 |
end |
51 | 49 |
|
Also available in: Unified diff
fixes #15743 - import and export of subscriptions one-per-line