from devops.helpers import ssh
from base import RecipeTestCase
from root import root
from settings import NODES

__author__ = 'vic'

import unittest

class MyTestCase(RecipeTestCase):
    def test_deploy_nova_rabbitmq(self):
        node01 = self.environment.node[NODES[0]]
        node02 = self.environment.node[NODES[1]]
        self.write_site_pp_manifest(
            root('fuel', 'deployment', 'puppet', 'cobbler', 'examples', 'server_site.pp'),
            cluster = 'true',
            cluster_nodes = [
                "%s" % node01.ip_address_by_network['internal'],
                "%s" % node02.ip_address_by_network['internal']
            ],
        )
        remote = ssh(node01.ip_address, username='root', password='r00tme')
        result1 = remote.sudo.ssh.execute('puppet agent --test')
        remote2 = ssh(node02.ip_address, username='root', password='r00tme')
        result2 = remote2.sudo.ssh.execute('puppet agent --test')
        self.assertResult(result1)
        self.assertResult(result2)


if __name__ == '__main__':
    unittest.main()


    #
    # # HERE IS IPTABLES RULES TO MAKE COBBLER AVAILABLE FROM OUTSIDE
    #      # https://github.com/cobbler/cobbler/wiki/Using%20Cobbler%20Import
    #      # SSH
    #      access_to_cobbler_port { "ssh":        port => '22' }
    #      # DNS
    #      access_to_cobbler_port { "dns_tcp":    port => '53' }
    #      access_to_cobbler_port { "dns_udp":    port => '53',  protocol => 'udp' }
    #      # DHCP
    #      access_to_cobbler_port { "dncp_67":    port => '67',  protocol => 'udp' }
    #      access_to_cobbler_port { "dncp_68":    port => '68',  protocol => 'udp' }
    #      # TFTP
    #      access_to_cobbler_port { "tftp_tcp":   port => '69' }
    #      access_to_cobbler_port { "tftp_udp":   port => '69',  protocol => 'udp' }
    #      # NTP
    #      access_to_cobbler_port { "ntp_udp":    port => '123', protocol => 'udp' }
    #      # HTTP/HTTPS
    #      access_to_cobbler_port { "http":       port => '80' }
    #      access_to_cobbler_port { "https":      port => '443'}
    #      # SYSLOG FOR COBBLER
    #      access_to_cobbler_port { "syslog_tcp": port => '25150'}
    #
    #
    #:80/api/distro/list
@@ -110,27 +110,8 @@
 ES%0A%0A
-__author__ = 'vic'%0A
 %0Aimp
@@ -134,10 +134,15 @@
 ass 
-My
+Cobbler
 Test
@@ -187,21 +187,15 @@
 loy_
-nova_rabbitmq
+cobbler
 (sel
@@ -251,57 +251,8 @@
 0%5D%5D%0A
-        node02 = self.environment.node%5BNODES%5B1%5D%5D%0A
     
@@ -377,213 +377,8 @@
 pp')
-,%0A            cluster = 'true',%0A            cluster_nodes = %5B%0A                %22%25s%22 %25 node01.ip_address_by_network%5B'internal'%5D,%0A                %22%25s%22 %25 node02.ip_address_by_network%5B'internal'%5D%0A            %5D,
 %0A   
@@ -474,17 +474,16 @@
   result
-1
  = remot
@@ -528,221 +528,42 @@
 t')%0A
-        remote2 = ssh(node02.ip_address, username='root', password='r00tme')%0A        result2 = remote2.sudo.ssh.execute('puppet agent --test')%0A        self.assertResult(result1)%0A        self.assertResult(result2)%0A
+%0A        self.assertResult(result)
 %0A%0Aif

Add example and test for cobbler