hammer_cli_csv 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/hammer_cli_csv/base.rb +11 -10
- data/lib/hammer_cli_csv/content_hosts.rb +7 -39
- data/lib/hammer_cli_csv/headpin_api.rb +6 -4
- data/lib/hammer_cli_csv/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NWRiMTE4MzU5Y2ZmMTI3NDM2MGQ4OWZhNWM5M2RiODIyYmI4OWMyOQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZDc0MTdjMjliZDk4NTMyODZhNmFkYjhjN2M1NmM2OGY4NTlkMDczNw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YzIzNzhkYjE5OWJmZjQyNGRkZDJhNTExY2I0YWYxMWE5NWI2YWIxODA1MjIx
|
10
|
+
ODkwNDNiYWM5NjczZjY3NTlmMzlhNTJkN2ExOTllNmQ3Y2MxNWY0OWVmYTE4
|
11
|
+
ZTY3YWEwOGFkNmYzMjJlNTMyYjFiZjI0NGY2ZDk4YjA1NTQ3YzQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZWM4ODcwZTdmOGE2OTVkYTgyOWYxMzAxODI3ZmRjYTVjZmFmMGFjYzg4OWUw
|
14
|
+
ZWI4YmMzYmRhNTg1MDI1OWVkOTcwMTk4YjVkM2Y5N2NkOWUzNWY1MTRjMzlk
|
15
|
+
NDBmMmUxNGFlMTVjY2ViMDA5OTgxNTEyY2RkNzVhMzg1YjIzNDY=
|
data/lib/hammer_cli_csv/base.rb
CHANGED
@@ -56,19 +56,19 @@ module HammerCLICsv
|
|
56
56
|
|
57
57
|
@server_status = check_server_status
|
58
58
|
|
59
|
-
|
59
|
+
if @server_status['release'] == 'Headpin'
|
60
|
+
@headpin = HeadpinApi.new({
|
61
|
+
:server => server,
|
62
|
+
:username => username,
|
63
|
+
:password => password
|
64
|
+
})
|
65
|
+
else
|
60
66
|
@api = ApipieBindings::API.new({
|
61
67
|
:uri => server,
|
62
68
|
:username => username,
|
63
69
|
:password => password,
|
64
70
|
:api_version => 2
|
65
71
|
})
|
66
|
-
else
|
67
|
-
@headpin = HeadpinApi.new({
|
68
|
-
:server => server,
|
69
|
-
:username => username,
|
70
|
-
:password => password
|
71
|
-
})
|
72
72
|
end
|
73
73
|
|
74
74
|
option_csv_export? ? export : import
|
@@ -81,9 +81,10 @@ module HammerCLICsv
|
|
81
81
|
password = option_password || HammerCLI::Settings.get(:csv, :password)
|
82
82
|
url = "#{server}/api/status"
|
83
83
|
uri = URI(url)
|
84
|
-
|
85
|
-
|
86
|
-
|
84
|
+
nethttp = Net::HTTP.new(uri.host, uri.port)
|
85
|
+
nethttp.use_ssl = uri.scheme == 'https'
|
86
|
+
nethttp.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
87
|
+
server_status = nethttp.start do |http|
|
87
88
|
request = Net::HTTP::Get.new uri.request_uri
|
88
89
|
request.basic_auth(username, password)
|
89
90
|
response = http.request(request)
|
@@ -58,7 +58,7 @@ module HammerCLICsv
|
|
58
58
|
CSV.open(option_csv_file || '/dev/stdout', 'wb', {:force_quotes => false}) do |csv|
|
59
59
|
csv << [NAME, COUNT, ORGANIZATION, ENVIRONMENT, CONTENTVIEW, HOSTCOLLECTIONS, VIRTUAL, HOST,
|
60
60
|
OPERATINGSYSTEM, ARCHITECTURE, SOCKETS, RAM, CORES, SLA, PRODUCTS, SUBSCRIPTIONS]
|
61
|
-
if
|
61
|
+
if @server_status['release'] == 'Headpin'
|
62
62
|
export_sam csv
|
63
63
|
else
|
64
64
|
export_foretello csv
|
@@ -68,51 +68,19 @@ module HammerCLICsv
|
|
68
68
|
|
69
69
|
def export_sam(csv)
|
70
70
|
guests_host = {}
|
71
|
+
system_ids = []
|
71
72
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
url = "#{server}/api/systems?organization_id=satellite-1"
|
76
|
-
uri = URI(url)
|
77
|
-
system_ids = Net::HTTP.start(uri.host, uri.port,
|
78
|
-
:use_ssl => uri.scheme == 'https',
|
79
|
-
:verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http|
|
80
|
-
request = Net::HTTP::Get.new uri.request_uri
|
81
|
-
request.basic_auth(username, password)
|
82
|
-
response = http.request(request)
|
83
|
-
|
84
|
-
JSON.parse(response.body).collect do |system|
|
73
|
+
@headpin.get(:organizations).each do |organization|
|
74
|
+
#url = "#{server}/api/systems?organization_id=satellite-1"
|
75
|
+
system_ids = @headpin.get("organizations/#{organization['label']}/systems").collect do |system|
|
85
76
|
system['guests'].each { |guest| guests_host[guest['uuid']] = system['name'] }
|
86
77
|
system['uuid']
|
87
78
|
end
|
88
79
|
end
|
89
80
|
|
90
|
-
#system_ids = ['327bf5cc-5498-4927-aa27-39b1503edf58', 'eeb6de95-afaf-4b14-9f92-e845ff269ccb']
|
91
|
-
|
92
81
|
system_ids.each do |system_id|
|
93
|
-
|
94
|
-
|
95
|
-
system = Net::HTTP.start(uri.host, uri.port,
|
96
|
-
:use_ssl => uri.scheme == 'https',
|
97
|
-
:verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http|
|
98
|
-
request = Net::HTTP::Get.new uri.request_uri
|
99
|
-
request.basic_auth(username, password)
|
100
|
-
response = http.request(request)
|
101
|
-
|
102
|
-
JSON.parse(response.body)
|
103
|
-
end
|
104
|
-
|
105
|
-
url = "#{server}/api/systems/#{system_id}/subscriptions"
|
106
|
-
uri = URI(url)
|
107
|
-
system_subscriptions = Net::HTTP.start(uri.host, uri.port,
|
108
|
-
:use_ssl => uri.scheme == 'https',
|
109
|
-
:verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http|
|
110
|
-
request = Net::HTTP::Get.new uri.request_uri
|
111
|
-
request.basic_auth(username, password)
|
112
|
-
response = http.request(request)
|
113
|
-
|
114
|
-
JSON.parse(response.body)['entitlements']
|
115
|
-
end
|
82
|
+
system = @headpin.get("systems/#{system_id}")
|
83
|
+
system_subscriptions = @headpin.get("systems/#{system_id}/subscriptions")['entitlements']
|
116
84
|
|
117
85
|
name = system['name']
|
118
86
|
count = 1
|
@@ -22,14 +22,16 @@ module HammerCLICsv
|
|
22
22
|
def get(name)
|
23
23
|
url = "#{@server}/api/#{name}"
|
24
24
|
uri = URI(url)
|
25
|
-
Net::HTTP.
|
26
|
-
|
27
|
-
|
25
|
+
nethttp = Net::HTTP.new(uri.host, uri.port)
|
26
|
+
nethttp.use_ssl = uri.scheme == 'https'
|
27
|
+
nethttp.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
28
|
+
results = nethttp.start do |http|
|
28
29
|
request = Net::HTTP::Get.new uri.request_uri
|
29
30
|
request.basic_auth(@username, @password)
|
30
31
|
response = http.request(request)
|
31
|
-
|
32
|
+
JSON.parse(response.body)
|
32
33
|
end
|
34
|
+
results
|
33
35
|
end
|
34
36
|
|
35
37
|
def environment(id)
|