Class: Wire::SpecTemplatesNetwork

Inherits:
Object
  • Object
show all
Defined in:
lib/wire/commands/spec_templates.rb

Overview

Templates for network-related stuff

Class Method Summary collapse

Class Method Details

.build_template__bridge_existsObject

rubocop:disable Lint/UnusedMethodArgument :reek:UnusedParameters



60
61
62
63
64
65
66
67
68
# File 'lib/wire/commands/spec_templates.rb', line 60

def self.build_template__bridge_exists
  <<ERB
  describe 'In zone <%= zone_name %> we should have an ovs bridge named <%= bridge_name %>' do
describe command "sudo ovs-vsctl list-br" do
  its(:stdout) { should match /<%= bridge_name %>/ }
end
  end
ERB
end

.build_template__bridge_vlan_id_and_trunkObject

rubocop:disable Lint/UnusedMethodArgument :reek:UnusedParameters



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/wire/commands/spec_templates.rb', line 85

def self.build_template__bridge_vlan_id_and_trunk
  <<ERB
  describe 'In zone <%= zone_name %>, ovs vlan bridge named <%= bridge_name %> ' \
       'should have id <%= vlanid %>' do
describe command "sudo ovs-vsctl br-to-vlan <%= bridge_name %>" do
  its(:stdout) { should match /<%= vlanid %>/ }
end
  end
  describe 'In zone <%= zone_name %>, ovs vlan bridge named <%= bridge_name %> ' \
       'should have parent <%= on_trunk %>' do
describe command "sudo ovs-vsctl br-to-parent <%= bridge_name %>" do
  its(:stdout) { should match /<%= on_trunk %>/ }
end
  end
ERB
end

.build_template__dhcp_is_validObject

rubocop:disable Lint/UnusedMethodArgument :reek:UnusedParameters requires zone_name, hostip, bridge_name, ip_start, ip_end



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/wire/commands/spec_templates.rb', line 118

def self.build_template__dhcp_is_valid
  <<ERB
  describe 'In zone <%= zone_name %> we should have dhcp service on ip <%= hostip %> ' \
       'on ovs bridge named <%= bridge_name %>, serving addresses from ' \
       '<%= ip_start %> to <%= ip_end %>' do

describe file '/etc/dnsmasq.d/wire__<%= zone_name %>__<%= bridge_name %>.conf' do
  it { should be_file }
  its(:content) { should match /<%= ip_start %>/ }
  its(:content) { should match /<%= ip_end %>/ }
  its(:content) { should match /<%= bridge_name %>/ }
end

describe process 'dnsmasq' do
  it { should be_running }
end

describe port(67) do
  it { should be_listening.with('udp') }
end

describe command '/bin/netstat -nlup' do
  its(:stdout) { should match /67.*dnsmasq/ }
end
  end
ERB
end

.build_template__ip_is_upObject

rubocop:disable Lint/UnusedMethodArgument :reek:UnusedParameters



104
105
106
107
108
109
110
111
112
113
# File 'lib/wire/commands/spec_templates.rb', line 104

def self.build_template__ip_is_up
  <<ERB
  describe 'In zone <%= zone_name %> we should have the ip <%= ip %> ' \
       'on ovs bridge named <%= bridge_name %>' do
describe interface "<%= bridge_name %>" do
  it { should have_ipv4_address '<%= ip %>' }
end
  end
ERB
end

.build_template__port_existsObject

rubocop:disable Lint/UnusedMethodArgument :reek:UnusedParameters



72
73
74
75
76
77
78
79
80
81
# File 'lib/wire/commands/spec_templates.rb', line 72

def self.build_template__port_exists
  <<ERB
  describe 'In zone <%= zone_name %> we should have a port <%= attach_intf %> on ovs ' \
       'bridge <%= bridge_name %>' do
describe command "sudo ovs-vsctl list-ports <%= bridge_name %>" do
  its(:stdout) { should match /<%= attach_intf %>/ }
end
  end
ERB
end