# coding: utf-8
#
# Cookbook Name:: rax-wordpress
# Recipe:: mysql-firewall
#
# Copyright 2014
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

iface = 'eth1'

case node['platform_family']
when 'debian'
  firewall_rule "Firewall rule, tcp/#{node['mysql']['port']}" do
    port      node['mysql']['port']
    interface iface
    protocol  :tcp
    direction :in
    action    :allow
  end
when 'rhel'
  iptables_ng_rule "Firewall rule, tcp/#{node['mysql']['port']}" do
    name       'MySQL'
    chain      'INPUT'
    table      'filter'
    ip_version [4, 6]
    rule       "-i #{iface}-p tcp --dport #{node['mysql']['port']} -j ACCEPT"
    action     :create_if_missing
  end
end

# coding: utf-8
#
# Cookbook Name:: rax-wordpress
# Recipe:: mysql-firewall
#
# Copyright 2014
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

iface = 'eth1'

case node['platform_family']
when 'debian'
  firewall_rule "Firewall rule, tcp/#{node['mysql']['port']}" do
    port      node['mysql']['port'].to_i
    interface iface
    protocol  :tcp
    direction :in
    action    :allow
  end
when 'rhel'
  iptables_ng_rule "Firewall rule, tcp/#{node['mysql']['port']}" do
    name       'MySQL'
    chain      'INPUT'
    table      'filter'
    ip_version [4, 6]
    rule       "-i #{iface}-p tcp --dport #{node['mysql']['port']} -j ACCEPT"
    action     :create_if_missing
  end
end

Fix type error caused by using other cookbook attr
Fix type error caused by using other cookbook attr

I get the following error when using this wrapper cookbook with the
mysql cookbook: https://github.com/opscode-cookbooks/mysql
sha: a2ff53f0ca6deca75aebf6da55ac381194ec7728

Chef::Exceptions::ValidationFailed
----------------------------------
Option port must be a kind of Integer!  You passed "3306".

This fix the wrapper cookbook to use the type it requires.
