1 require File.join(File.dirname(__FILE__), '..','..','..',
2 'puppet/provider/neutron')
4 Puppet::Type.type(:neutron_router_interface).provide(
6 :parent => Puppet::Provider::Neutron
9 Neutron provider to manage neutron_router_interface type.
11 Assumes that the neutron service is configured on the same host.
13 It is not possible to manage an interface for the subnet used by
14 the gateway network, and such an interface will appear in the list
15 of resources ('puppet resource [type]'). Attempting to manage the
16 gateway interfae will result in an error.
20 commands :neutron => 'neutron'
26 Puppet::Type.type('neutron_subnet').instances.each do |instance|
27 subnet_name_hash[instance.provider.id] = instance.provider.name
30 Puppet::Type.type('neutron_router').instances.each do |instance|
31 list_router_ports(instance.provider.id).each do |port_hash|
32 router_name = instance.provider.name
33 subnet_name = subnet_name_hash[port_hash['subnet_id']]
34 name = "#{router_name}:#{subnet_name}"
38 :id => port_hash['id'],
39 :port => port_hash['name']
46 def self.prefetch(resources)
47 instances_ = instances
48 resources.keys.each do |name|
49 if provider = instances_.find{ |instance| instance.name == name }
50 resources[name].provider = provider
56 @property_hash[:ensure] == :present
60 router,subnet = resource[:name].split(':', 2)
61 port = resource[:port]
62 args = ["router-interface-add", "--format=shell", router]
64 args << "port=#{port}"
66 args << "subnet=#{subnet}"
68 results = auth_neutron(args)
70 if results =~ /Added interface.* to router/
73 :name => resource[:name],
76 fail("did not get expected message on interface addition, got #{results}")
81 name.split(':', 2).first
85 name.split(':', 2).last
89 auth_neutron('router-interface-delete', router_name, subnet_name)
90 @property_hash[:ensure] = :absent