Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- entities = [#<Entity:0x0055f364d9cd78 @name="entity-B", @internal_asn_number=64514, @classification_id="B">,#<Entity:0x0055f364d89070 @name="entity-A", @internal_asn_number=64513, @classification_id="A">]
- array_hashes = [{"rulename"=>"entity-B_source_fqdn_1", "if"=>{"source.fqdn"=>"mail.tec.dsr.entityB.com"}, "then"=>{"event_description.text"=>"B"}}, {"rulename"=>"entity-B_destination_fqdn_1", "if"=>{"destination.fqdn"=>"mail.tec.dsr.entity_B.com"}, "then"=>{"event_description.text"=>"B"}}, {"rulename"=>"entity-A_source_fqdn_1", "if"=>{"source.fqdn"=>"194-65-57-128.entityA.com"}, "then"=>{"event_description.text"=>"A"}}, {"rulename"=>"entity-A_destination_fqdn_1", "if"=>{"destination.fqdn"=>"194-65-57-128.entityA.com"}, "then"=>{"event_description.text"=>"A"}}]
- path = "/home/mf370/Desktop/RubyProject/"
- file_name = "_url_fqdn.conf"
- entities.each do |entity|
- File.open(path + entity.name + file_name, "w") do |f|
- array_hashes.each do |rule|
- if rule['rulename'].match(entity.name)
- f.write(JSON.pretty_generate([rule]))
- end
- end
- end
- [
- {
- "rulename": "entity-A_source_fqdn_1",
- "if": {
- "source.fqdn": "194-65-57-128.entityA.com"
- },
- "then": {
- "event_description.text": "A"
- }
- }
- ][
- {
- "rulename": "entity-A_destination_fqdn_1",
- "if": {
- "destination.fqdn": "194-65-57-128.entityA.com"
- },
- "then": {
- "event_description.text": "A"
- }
- }
- ]
- [
- {
- "rulename": "entity-A_source_fqdn_1",
- "if": {
- "source.fqdn": "194-65-57-128.entityA.com"
- },
- "then": {
- "event_description.text": "A"
- }
- },
- {
- "rulename": "entity-A_destination_fqdn_1",
- "if": {
- "destination.fqdn": "194-65-57-128.entityA.com"
- },
- "then": {
- "event_description.text": "A"
- }
- }
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement