Created
November 13, 2014 20:47
-
-
Save hkumarmk/2cd18c36f4059d8ba4d0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Puppet::Type.type(:contrail_vgw).provide( | |
:provisioner | |
) do | |
# commands :provision_vgw => setCommand | |
# commands :provision_vgw => 'export PYTHONPATH=/usr/lib/python2.7/dist-packages/contrail_vrouter_api/gen_py/instance_service;/usr/sbin/contrail-provision-vgw-interface' | |
# commands :provision_vgw => '/usr/sbin/contrail-provision-vgw-interface' | |
def provision_vgw(*args) | |
# path=`find /usr/lib/python2.7/ -name instance_service -type d| grep contrail | head -1`.chomp.strip | |
# command = "export PYTHONPATH=#{path};/usr/sbin/contrail-provision-vgw-interfaces " + args.join(' ') | |
command = "export PYTHONPATH=/usr/lib/python2.7/dist-packages/contrail_vrouter_api/gen_py/instance_service;/usr/sbin/contrail-provision-vgw-interfaces " + args.join(' ') | |
puts "HHHHHHHHHHHHH" | |
begin | |
puts "before execute" | |
execute(command, :failonfail => true, :override_locale => false, :squelch => true, :combine => true) | |
puts "after exec" | |
rescue Puppet::ExecutionFailure => detail | |
puts "in rescue" | |
@resource.fail Puppet::Error, "Could not #{@resource.ref}: #{detail}", detail | |
end | |
nil | |
end | |
def exists? | |
Facter.value(:interfaces).split(',').include?(resource[:name]) | |
end | |
def create_or_update | |
provision_linklocal( | |
'--admin_user', resource[:admin_user], | |
'--admin_password', resource[:admin_password], | |
'--api_server_ip', resource[:api_server_address], | |
'--api_server_port', resource[:api_server_port], | |
'--linklocal_service_name', resource[:name], | |
'--linklocal_service_ip', resource[:service_address], | |
'--linklocal_service_port', resource[:service_port], | |
'--ipfabric_service_ip', resource[:ipfabric_service_address], | |
'--ipfabric_service_port', resource[:ipfabric_service_port], | |
'--oper add') | |
end | |
def create | |
provision_vgw( | |
'--interface', resource[:name], | |
'--subnets', resource[:subnets], | |
'--routes', resource[:dest_net], | |
'--vrf', resource[:vrf] , | |
'--oper create') | |
puts "END CREATE" | |
end | |
def destroy | |
provision_vgw( | |
'--interface', resource[:name], | |
'--subnets', resource[:subnets], | |
'--routes', resource[:dest_net], | |
'--vrf', resource[:vrf], | |
'--oper delete') | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment