From 26a0b6dffc4f3f32fb43aebd3dba4e86b3ee27ad Mon Sep 17 00:00:00 2001 From: ts Date: Fri, 19 Oct 2018 16:13:09 +0100 Subject: [PATCH] snoop changes --- lib/output/project_files_creator.rb | 7 +++++++ lib/templates/Vagrantfile.erb | 10 +++++----- scenarios/test_scenario.xml | 16 ++-------------- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/lib/output/project_files_creator.rb b/lib/output/project_files_creator.rb index 0497e0753..be09760af 100644 --- a/lib/output/project_files_creator.rb +++ b/lib/output/project_files_creator.rb @@ -236,6 +236,13 @@ class ProjectFilesCreator split_ip.join('.') end + # Replace 'network' with 'snoop' where the system name contains snoop + def get_ovirt_network_name(system_name, network_name) + split_name = network_name.split('-') + split_name[1] = 'snoop' if system_name.include? 'snoop' + split_name.join('-') + end + # Returns binding for erb files (access to variables in this classes scope) # @return binding def get_binding diff --git a/lib/templates/Vagrantfile.erb b/lib/templates/Vagrantfile.erb index a79ac409b..535b943ba 100644 --- a/lib/templates/Vagrantfile.erb +++ b/lib/templates/Vagrantfile.erb @@ -131,22 +131,22 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| <% when 'network' -%> <% if (selected_module.attributes['range'].first.nil? || selected_module.attributes['range'].first == "dhcp") and (!selected_module.received_inputs.include? 'IP_address' and !@options[:ip_ranges])-%> <% if (@options.has_key? :ovirtnetwork) && (@options.has_key? :ovirtuser) && (@options.has_key? :ovirtpass) %> - <%= system.name %>.vm.network :<%= selected_module.attributes['type'].first %>, type: "dhcp", :ovirt__network_name => '<%= "#{@options[:ovirtnetwork]}" %>' + <%= system.name %>.vm.network :<%= selected_module.attributes['type'].first %>, type: "dhcp", :ovirt__network_name => '<%= get_ovirt_network_name(system.name, @options[:ovirtnetwork]) %>' <% else %> <%= system.name %>.vm.network :<%= selected_module.attributes['type'].first %>, type: "dhcp", auto_config: false <% end %> <% else -%> <% if (@options.has_key? :ovirtuser) && (@options.has_key? :ovirtpass) %> - <% if @ovirt_template and (@ovirt_template.include? 'kali_linux_msf' or @ovirt_template.include? 'debian_server' )%> + <% if @ovirt_template and (@ovirt_template.include? 'debian_server' )%> <%= system.name %>.vm.provision 'shell', inline: "echo \"auto lo\niface lo inet loopback\n\nauto eth0\niface eth0 inet static\n\taddress <%= resolve_network(selected_module)%>\" > /etc/network/interfaces" <%= system.name %>.vm.provision 'shell', inline: "echo '' > /etc/environment" <% elsif @ovirt_template and @ovirt_template.include? 'debian_desktop_kde' %> <%= system.name %>.vm.provision 'shell', inline: "echo \"\nauto eth1\niface eth1 inet static\n\taddress <%= resolve_network(selected_module)%>\" >> /etc/network/interfaces" <%= system.name %>.vm.provision 'shell', inline: "echo '' > /etc/environment" - <% elsif @ovirt_template and ( @ovirt_template.include? 'debian_stretch_server_n' or @ovirt_template.include? 'debian_stretch_desktop_kde') %> - <%= system.name %>.vm.provision 'shell', inline: "echo \"\nauto ens3\niface ens3 inet static\n\taddress <%= resolve_network(selected_module)%>\" > /etc/network/interfaces" + <% elsif @ovirt_template and (@ovirt_template.include? 'kali_linux_msf'or @ovirt_template.include? 'debian_stretch_server_n' or @ovirt_template.include? 'debian_stretch_desktop_kde') %> + <%= system.name %>.vm.network :<%= selected_module.attributes['type'].first %>, :ovirt__ip => "<%= resolve_network(selected_module)%>", :ovirt__network_name => '<%= get_ovirt_network_name(system.name, @options[:ovirtnetwork]) %>' <% else %> - <%= system.name %>.vm.network :<%= selected_module.attributes['type'].first %>, :ovirt__ip => "<%= resolve_network(selected_module)%>", :ovirt__network_name => '<%= "#{@options[:ovirtnetwork]}" %>' + <%= system.name %>.vm.network :<%= selected_module.attributes['type'].first %>, :ovirt__ip => "<%= resolve_network(selected_module)%>", :ovirt__network_name => '<%= get_ovirt_network_name(system.name, @options[:ovirtnetwork]) %>' <% end %> <% else %> <%= system.name %>.vm.network :<%= selected_module.attributes['type'].first %>, ip: "<%= resolve_network(selected_module)%>" diff --git a/scenarios/test_scenario.xml b/scenarios/test_scenario.xml index 25e29f3b1..ac20fb18e 100644 --- a/scenarios/test_scenario.xml +++ b/scenarios/test_scenario.xml @@ -6,16 +6,14 @@ - gitlist - + test + 172.16.0.2 172.16.0.3 - - IP_addresses @@ -24,14 +22,4 @@ - - desktop - - - - IP_addresses - - - -