def metadata_forward():
 if (CONF.metadata_host != '127.0.0.1'):
  iptables_manager.ipv4['nat'].add_rule('PREROUTING', ('-s 0.0.0.0/0 -d 169.254.169.254/32 -p tcp -m tcp --dport 80 -j DNAT --to-destination %s:%s' % (CONF.metadata_host, CONF.metadata_port)))
 else:
  iptables_manager.ipv4['nat'].add_rule('PREROUTING', ('-s 0.0.0.0/0 -d 169.254.169.254/32 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports %s' % CONF.metadata_port))
 iptables_manager.apply()

def metadata_forward ( ) : if ( CONF . metadata_host != '127.0.0.1' ) : iptables_manager . ipv4 [ 'nat' ] . add_rule ( 'PREROUTING' , ( '-s 0.0.0.0/0 -d 169.254.169.254/32 -p tcp -m tcp --dport 80 -j DNAT --to-destination %s:%s' % ( CONF . metadata_host , CONF . metadata_port ) ) ) else : iptables_manager . ipv4 [ 'nat' ] . add_rule ( 'PREROUTING' , ( '-s 0.0.0.0/0 -d 169.254.169.254/32 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports %s' % CONF . metadata_port ) ) iptables_manager . apply ( )
create forwarding rule for metadata .