Exemplo n.º 1
0
    def test_get_available_ipop_address(self):
        self.config_parser.set('manager', 'IPOP_BASE_IP', '127.0.0.0')
        self.config_parser.set('manager', 'IPOP_NETMASK', '255.0.0.0')
        self.config_parser.set('manager', 'IPOP_SUBNET', '127.0.0.0/24')

        self.controller = controller.Controller(self.config_parser)

        self.assertEquals('127.0.0.3', 
            self.controller.get_available_ipop_address())
Exemplo n.º 2
0
    def test_controller_init(self):
        self.controller = controller.Controller(self.config_parser)

        self.assertEquals('agent', self.controller.role)

        self.assertEquals(None, self.controller._Controller__ipop_base_ip)
        self.assertEquals(None, self.controller._Controller__ipop_netmask)
        self.assertEquals(None, self.controller._Controller__ipop_subnet)

        self.assertEquals(None, self.controller._Controller__default_cloud)
Exemplo n.º 3
0
    def test_controller_init_ipop(self):
        self.config_parser.set('manager', 'IPOP_BASE_IP', '127.0.0.0')
        self.config_parser.set('manager', 'IPOP_NETMASK', '255.0.0.0')
        self.config_parser.set('manager', 'IPOP_SUBNET', '127.0.0.0/24')

        self.controller = controller.Controller(self.config_parser)

        self.assertEquals('127.0.0.0', 
            self.controller._Controller__ipop_base_ip)
        self.assertEquals('255.0.0.0', 
            self.controller._Controller__ipop_netmask)
        self.assertEquals(IPNetwork('127.0.0.0/24'), 
            self.controller._Controller__ipop_subnet)
Exemplo n.º 4
0
    def test_generate_context_with_cloud(self):
        self.config_parser.add_section('iaas')
        self.config_parser.set('iaas', 'DRIVER', 'dummy')

        self.config_parser.set('manager', 'BOOTSTRAP', 'test')
        self.config_parser.set('manager', 'MY_IP', '127.0.0.1')

        self.controller = controller.Controller(self.config_parser)

        self.controller.generate_context('mysql', 
            self.controller.get_cloud_by_name('iaas'))

        self.failUnless('MySQL_configuration' in 
            self.controller._Controller__default_cloud._context)
Exemplo n.º 5
0
    def test_controller_init_iaas_multicloud(self):
        # default cloud
        self.config_parser.add_section('iaas')
        self.config_parser.set('iaas', 'DRIVER', 'dummy')

        # additional cloud
        self.config_parser.set('iaas', 'OTHER_CLOUDS', 'dummy2')
        self.config_parser.add_section('dummy2')
        self.config_parser.set('dummy2', 'DRIVER', 'dummy')

        self.controller = controller.Controller(self.config_parser)

        clouds = self.controller._Controller__available_clouds

        self.assertEquals(2, len(clouds))
Exemplo n.º 6
0
    def test_create_nodes(self):
        self.config_parser.add_section('iaas')
        self.config_parser.set('iaas', 'DRIVER', 'dummy')

        self.config_parser.set('manager', 'TYPE', 'mysql')
        #self.config_parser.set('manager', 'IPOP_BASE_IP', '127.0.0.0')
        #self.config_parser.set('manager', 'IPOP_NETMASK', '255.0.0.0')
        #self.config_parser.set('manager', 'IPOP_SUBNET', '127.0.0.0/24')
        
        self.controller = controller.Controller(self.config_parser)

        nodes = self.controller.create_nodes(count=2, 
                                             test_agent=lambda x, y: True, 
                                             port='5555',
                                             inst_type='small')

        self.assertEquals('127.0.0.3', nodes[0].ip)
Exemplo n.º 7
0
    def test_generate_context(self):
        self.config_parser.add_section('iaas')
        self.config_parser.set('iaas', 'DRIVER', 'dummy')

        self.config_parser.set('manager', 'BOOTSTRAP', 'test')
        self.config_parser.set('manager', 'MY_IP', '127.0.0.1')
        self.config_parser.set('manager', 'IPOP_BASE_IP', '127.0.0.0')
        self.config_parser.set('manager', 'IPOP_NETMASK', '255.0.0.0')
        self.config_parser.set('manager', 'IPOP_SUBNET', '127.0.0.0/24')

        self.controller = controller.Controller(self.config_parser)

        self.assertEquals(None, self.controller.get_clouds()[0]._context)

        self.controller.generate_context('mysql')

        self.failUnless('MySQL_configuration' in 
            self.controller._Controller__default_cloud._context)
Exemplo n.º 8
0
    def test_controller_bootstrap_nodes_unset(self):
        self.config_parser.add_section('iaas')
        self.config_parser.set('iaas', 'DRIVER', 'dummy')
        self.config_parser.set('manager', 'BOOTSTRAP', 'test')
        self.config_parser.set('manager', 'MY_IP', '127.0.0.1')
        self.config_parser.set('manager', 'IPOP_BASE_IP', '127.0.0.0')
        self.config_parser.set('manager', 'IPOP_NETMASK', '255.0.0.0')
        self.config_parser.set('manager', 'IPOP_SUBNET', '127.0.0.0/24')
        if self.config_parser.has_option('manager', 'IPOP_BOOTSTRAP_NODES'):
            self.config_parser.remove_option('manager', 'IPOP_BOOTSTRAP_NODES')

        self.controller = controller.Controller(self.config_parser)

        self.assertIsNone(self.controller._Controller__ipop_bootstrap_nodes)

        not_expected = "\nIPOP_BOOTSTRAP_NODES = "
        context = self.controller._get_context_file('default-agent', 'dummy')
        self.assertTrue(not_expected not in context,
                        "Found option IPOP_BOOTSTRAP_NODES in context generated by manager for agent when it was not expected.")
Exemplo n.º 9
0
    def test_controller_bootstrap_nodes_set(self):
        bootstrap_nodes = 'udp://192.168.122.1:40000'
        self.config_parser.add_section('iaas')
        self.config_parser.set('iaas', 'DRIVER', 'dummy')
        self.config_parser.set('manager', 'BOOTSTRAP', 'test')
        self.config_parser.set('manager', 'MY_IP', '127.0.0.1')
        self.config_parser.set('manager', 'IPOP_BASE_IP', '127.0.0.0')
        self.config_parser.set('manager', 'IPOP_NETMASK', '255.0.0.0')
        self.config_parser.set('manager', 'IPOP_SUBNET', '127.0.0.0/24')
        self.config_parser.set('manager', 'IPOP_BOOTSTRAP_NODES', bootstrap_nodes)

        self.controller = controller.Controller(self.config_parser)

        self.assertEquals(bootstrap_nodes,
            self.controller._Controller__ipop_bootstrap_nodes)

        expected = "\nIPOP_BOOTSTRAP_NODES = " + bootstrap_nodes
        context = self.controller._get_context_file('default-agent', 'dummy')
        self.assertTrue(expected in context,
                        "Missing IPOP_BOOTSTRAP_NODES in context generated by manager to configure an agent: %s" % context)
Exemplo n.º 10
0
    def __get_dummy_controller(self):
        self.config_parser.add_section('iaas')
        self.config_parser.set('iaas', 'DRIVER', 'dummy')

        return controller.Controller(self.config_parser)