-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #151 from redBorder/development
Release 1.9.3
- Loading branch information
Showing
26 changed files
with
1,019 additions
and
881 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,14 @@ | ||
module Rb_manager | ||
module RbManager | ||
module Helpers | ||
def get_all_flow_sensors_info() | ||
def get_all_flow_sensors_info | ||
sensors_info = {} | ||
sensor_types = ["flow-sensor"] | ||
|
||
sensor_types = ['flow-sensor'] | ||
sensor_types.each do |s_type| | ||
sensors = search(:node, "role:#{s_type}").sort | ||
|
||
sensors_info[s_type] = [] | ||
sensors.each do |s| | ||
sensors_info[s_type] << s | ||
end | ||
sensors.each { |s| sensors_info[s_type] << s } | ||
end | ||
sensors_info | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,34 @@ | ||
module Rb_manager | ||
module RbManager | ||
module Helpers | ||
def get_cluster_info() | ||
def get_cluster_info | ||
cluster_info = {} | ||
manager_nodes = {} | ||
|
||
manager_nodes = search(:node, "recipes:rb-manager").sort | ||
manager_nodes = search(:node, 'recipes:rb-manager').sort | ||
|
||
#The search function above is looking for rb-manager value in "Recipes" key instead run_list, for this reason | ||
#in the first execution the node data is not added to managers hash, so it will be checked now and added | ||
#to managers array | ||
if !cluster_info.key?(node.name) and node.recipe?("rb-manager") and !manager_nodes.include?(node) | ||
# The search function above is looking for rb-manager value in 'Recipes' key instead run_list, for this reason | ||
# in the first execution the node data is not added to managers hash, so it will be checked now and added | ||
# to managers array | ||
if !cluster_info.key?(node.name) && node.recipe?('rb-manager') && !manager_nodes.include?(node) | ||
manager_nodes << node | ||
end | ||
|
||
manager_nodes.each do |mnode| | ||
name = mnode.name | ||
mnode.normal["rb_time"]=Time.now.to_i if mnode["rb_time"].nil? | ||
rb_time = mnode["rb_time"] | ||
mnode.normal['rb_time'] = Time.now.to_i if mnode['rb_time'].nil? | ||
rb_time = mnode['rb_time'] | ||
services = [] | ||
# add active services to array | ||
mnode_services = mnode["redborder"]["services"].to_h | ||
mnode_services = mnode['redborder']['services'].to_h | ||
mnode_services.each do |service, service_status| | ||
services << service if service_status | ||
end | ||
cluster_info[name] = {} | ||
cluster_info[name]["name"] = name | ||
cluster_info[name]["ip"] = mnode["ipaddress"] | ||
cluster_info[name]["rb_time"] = rb_time | ||
cluster_info[name]["services"] = services | ||
cluster_info[name]['name'] = name | ||
cluster_info[name]['ip'] = mnode['ipaddress'] | ||
cluster_info[name]['rb_time'] = rb_time | ||
cluster_info[name]['services'] = services | ||
end | ||
|
||
cluster_info = cluster_info.sort{|a,b| (a[1]["rb_time"]||999999999999999999999) <=> (b[1]["rb_time"]||999999999999999999999)}.to_h | ||
return cluster_info | ||
cluster_info = cluster_info.sort { |a, b| (a[1]['rb_time'] || 999999999999999999999) <=> (b[1]['rb_time'] || 999999999999999999999) }.to_h | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
module Rb_manager | ||
module RbManager | ||
module Helpers | ||
def get_namespaces | ||
namespaces = [] | ||
Chef::Role.list.keys.each do |rol| | ||
Chef::Role.list.each_key do |rol| | ||
ro = Chef::Role.load rol | ||
if ro and ro.override_attributes["redborder"] and ro.override_attributes["redborder"]["namespace"] and ro.override_attributes["redborder"]["namespace_uuid"] and !ro.override_attributes["redborder"]["namespace_uuid"].empty? | ||
namespaces.push(ro.override_attributes["redborder"]["namespace_uuid"]) | ||
end | ||
next unless ro && ro.override_attributes['redborder'] && ro.override_attributes['redborder']['namespace'] && ro.override_attributes['redborder']['namespace_uuid'] && !ro.override_attributes['redborder']['namespace_uuid'].empty? | ||
|
||
namespaces.push(ro.override_attributes['redborder']['namespace_uuid']) | ||
end | ||
|
||
namespaces.uniq | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,16 @@ | ||
module Rb_manager | ||
module RbManager | ||
module Helpers | ||
def get_orgs() | ||
|
||
def get_orgs | ||
organizations = [] | ||
|
||
Chef::Role.list.keys.each do |m_key| | ||
Chef::Role.list.each_key do |m_key| | ||
m = Chef::Role.load m_key | ||
if !m.override_attributes["redborder"].nil? and !m.override_attributes["redborder"]["organization_uuid"].nil? and m.override_attributes["redborder"]["sensor_uuid"] == m.override_attributes["redborder"]["organization_uuid"] | ||
organizations << m | ||
end | ||
next unless m.override_attributes['redborder'] && m.override_attributes['redborder']['organization_uuid'] && m.override_attributes['redborder']['sensor_uuid'] == m.override_attributes['redborder']['organization_uuid'] | ||
|
||
organizations << m | ||
end | ||
|
||
organizations | ||
|
||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,37 @@ | ||
module Rb_manager | ||
module RbManager | ||
module Helpers | ||
def get_sensors_info() | ||
def get_sensors_info | ||
sensors_info = {} | ||
sensor_types = %w(vault-sensor flow-sensor mse-sensor scanner-sensor meraki-sensor ale-sensor device-sensor | ||
cisco-cloudproxy proxy-sensor | ||
ips-sensor ipsv2-sensor ipscp-sensor ipsg-sensor) | ||
locations = node["redborder"]["locations"] | ||
locations = node['redborder']['locations'] | ||
sensor_types.each do |s_type| | ||
sensors = search(:node, "role:#{s_type} AND -redborder_parent_id:*?").sort #get sensor where parent_id is nil | ||
# get sensor where parent_id is nil | ||
sensors = search(:node, "role:#{s_type} AND -redborder_parent_id:*?").sort | ||
sensors_info[s_type] = {} | ||
sensors.each do |s| | ||
info = {} | ||
info["name"] = s.name | ||
info["ip"] = s["ipaddress"] | ||
info["sensor_uuid"] = s["redborder"]["sensor_uuid"] if !s["redborder"]["sensor_uuid"].nil? | ||
info["organization_uuid"] = s["redborder"]["organization_uuid"] if !s["redborder"]["organization_uuid"].nil? | ||
info["megabytes_limit"] = s["redborder"]["megabytes_limit"] if !s["redborder"]["megabytes_limit"].nil? | ||
info["index_partitions"] = s["redborder"]["index_partitions"] if !s["redborder"]["index_partitions"].nil? | ||
info["index_replicas"] = s["redborder"]["index_replicas"] if !s["redborder"]["index_replicas"].nil? | ||
info["sensors_mapping"] = s["redborder"]["sensors_mapping"] if !s["redborder"]["sensors_mapping"].nil? | ||
info["locations"] = {} | ||
info['name'] = s.name | ||
info['ip'] = s['ipaddress'] | ||
info['sensor_uuid'] = s['redborder']['sensor_uuid'] if s['redborder']['sensor_uuid'] | ||
info['organization_uuid'] = s['redborder']['organization_uuid'] if s['redborder']['organization_uuid'] | ||
info['megabytes_limit'] = s['redborder']['megabytes_limit'] if s['redborder']['megabytes_limit'] | ||
info['index_partitions'] = s['redborder']['index_partitions'] if s['redborder']['index_partitions'] | ||
info['index_replicas'] = s['redborder']['index_replicas'] if s['redborder']['index_replicas'] | ||
info['sensors_mapping'] = s['redborder']['sensors_mapping'] if s['redborder']['sensors_mapping'] | ||
info['locations'] = {} | ||
|
||
locations.each do |loc| | ||
if !s["redborder"][loc].nil? | ||
info["locations"][loc] = s["redborder"][loc] | ||
end | ||
next unless s['redborder'][loc] | ||
|
||
info['locations'][loc] = s['redborder'][loc] | ||
end | ||
sensors_info[s_type][s.name] = info | ||
end | ||
end | ||
return sensors_info | ||
|
||
sensors_info | ||
end | ||
end | ||
end |
Oops, something went wrong.