Skip to content

Commit

Permalink
Merge pull request #165 from tuxmea/onevnet_netmask
Browse files Browse the repository at this point in the history
add netmask property to onevnet type and provider
  • Loading branch information
michael-os committed Jun 22, 2015
2 parents f647dd3 + f6bc12e commit bcdea88
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ onevnet { '<name>':
gateway => '10.0.2.1',
# add vlanid
vlanid => '1550',
netmask => '255.255.0.0',
network_address => '10.0.2.0',
}
```

Expand Down
12 changes: 12 additions & 0 deletions lib/puppet/provider/onevnet/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ def create
resource[:gateway]
end
end if resource[:gateway]
xml.TEMPLATE do
xml.NETWORK_MASK do
resource[:netmask]
end
end if resource[:netmask]
xml.TEMPLATE do
xml.NETWORK_ADDRESS do
resource[:network_address]
end
end if resource[:network_address]
xml.CONTEXT do
resource[:context].each do |k,v|
xml.send(k.upcase, v)
Expand Down Expand Up @@ -89,6 +99,8 @@ def self.instances
:context => nil,
:dnsservers => (vnet.xpath('./TEMPLATE/DNS').text.to_a unless vnet.xpath('./TEMPLATE/DNS').nil?),
:gateway => (vnet.xpath('./TEMPLATE/GATEWAY').text unless vnet.xpath('./TEMPLATE/GATEWAY').nil?),
:netmask => (vnet.xpath('./TEMPLATE/NETWORK_MASK').text unless vnet.xpath('./TEMPLATE/NETWORK_MASK').nil?),
:network_address => (vnet.xpath('./TEMPLATE/NETWORK_ADDRESS').text unless vnet.xpath('./TEMPLATE/NETWORK_ADDRESS').nil?),
:model => (vnet.xpath('./TEMPLATE/MODEL').text unless vnet.xpath('./TEMPLATE/MODEL').nil?),
:phydev => vnet.xpath('./PHYDEV').text,
:vlanid => vnet.xpath('./VLAN_ID').text
Expand Down
8 changes: 8 additions & 0 deletions lib/puppet/type/onevnet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@
desc "Array of DNS servers to use"
end

newproperty(:netmask) do
desc "Netmask for the network"
end

newproperty(:network_address) do
desc "Network address for the network"
end

newproperty(:gateway) do
desc "Gateway for network"
end
Expand Down
12 changes: 11 additions & 1 deletion spec/type/onevnet_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
end
end

properties = [:dnsservers, :gateway, :model, :bridge, :vlanid, :context, :phydev]
properties = [:dnsservers, :gateway, :model, :bridge, :vlanid, :context, :phydev, :netmask, :network_address]

properties.each do |property|
it "should have a #{property} property" do
Expand Down Expand Up @@ -80,6 +80,16 @@
@vnet[:phydev].should == 'eth0'
end

it 'should have property :netmask' do
@vnet[:netmask] = '255.255.0.0'
@vnet[:netmask].should == '255.255.0.0'
end

it 'should have property network_address' do
@vnet[:network_address] = '10.0.2.0'
@vnet[:network_address].should == '10.0.2.0'
end

parameter_tests = {
:name => {
:valid => ["test", "foo"],
Expand Down

0 comments on commit bcdea88

Please sign in to comment.