Esempio n. 1
0
 def test_init(self):
     net.Network(uuid='notauuid',
                 vxlan_id=42,
                 provide_dhcp=True,
                 provide_nat=True,
                 physical_nic='eth0',
                 ipblock='192.168.1.0/24')
Esempio n. 2
0
 def test_is_okay_no_dns(self, mock_is_dnsmasq, mock_is_created):
     n = net.Network(uuid='actualuuid',
                     vxlan_id=42,
                     provide_dhcp=True,
                     provide_nat=True,
                     physical_nic='eth0',
                     ipblock='192.168.1.0/24')
     self.assertTrue(n.is_okay())
Esempio n. 3
0
 def test_str(self):
     n = net.Network(uuid='notauuid',
                     vxlan_id=42,
                     provide_dhcp=True,
                     provide_nat=True,
                     physical_nic='eth0',
                     ipblock='192.168.1.0/24')
     self.assertEqual('network(notauuid, vxid 42)', str(n))
Esempio n. 4
0
 def test_is_created_no_bridge(self, mock_execute):
     n = net.Network(uuid='1111111-d923-4441-b498-4f8e3c166804',
                     vxlan_id=111,
                     provide_dhcp=True,
                     provide_nat=True,
                     physical_nic='eth0',
                     ipblock='192.168.1.0/24')
     self.assertFalse(n.is_created())
Esempio n. 5
0
 def test_is_created_yes(self, mock_execute):
     n = net.Network(uuid='8abbc9a6-d923-4441-b498-4f8e3c166804',
                     vxlan_id=5,
                     provide_dhcp=True,
                     provide_nat=True,
                     physical_nic='eth0',
                     ipblock='192.168.1.0/24')
     self.assertTrue(n.is_created())
Esempio n. 6
0
 def test_init(self):
     net.Network({
         'uuid': 'notauuid',
         'vxid': 42,
         'provide_dhcp': True,
         'provide_nat': True,
         'physical_nic': 'eth0',
         'netblock': '192.168.1.0/24'
     })
Esempio n. 7
0
 def test_is_okay_no_dns(self, mock_is_dnsmasq, mock_is_created):
     n = net.Network({
         'uuid': 'actualuuid',
         'vxid': 42,
         'provide_dhcp': True,
         'provide_nat': True,
         'physical_nic': 'eth0',
         'netblock': '192.168.1.0/24'
     })
     self.assertTrue(n.is_okay())
Esempio n. 8
0
 def test_str(self):
     n = net.Network({
         'uuid': 'notauuid',
         'vxid': 42,
         'provide_dhcp': True,
         'provide_nat': True,
         'physical_nic': 'eth0',
         'netblock': '192.168.1.0/24'
     })
     self.assertEqual('network(notauuid, vxid 42)', str(n))
Esempio n. 9
0
 def test_is_created_no_bridge(self, mock_execute):
     n = net.Network({
         'uuid': '1111111-d923-4441-b498-4f8e3c166804',
         'vxid': 5,
         'provide_dhcp': True,
         'provide_nat': True,
         'physical_nic': 'eth0',
         'netblock': '192.168.1.0/24'
     })
     self.assertFalse(n.is_created())
Esempio n. 10
0
 def test_is_okay_not_created(self, mock_is_dnsmasq, mock_is_created):
     n = net.Network({
         'uuid': 'actualuuid',
         'vxid': 42,
         'name': 'bobnet',
         'namespace': 'finitespace',
         'provide_dhcp': True,
         'provide_nat': True,
         'egress_nic': 'eth0',
         'mesh_nic': 'eth0',
         'netblock': '192.168.1.0/24'
     })
     self.assertFalse(n.is_okay())
Esempio n. 11
0
 def test_str(self):
     n = net.Network({
         'uuid': 'notauuid',
         'vxid': 42,
         'name': 'bobnet',
         'namespace': 'finitespace',
         'provide_dhcp': True,
         'provide_nat': True,
         'egress_nic': 'eth0',
         'mesh_nic': 'eth0',
         'netblock': '192.168.1.0/24'
     })
     self.assertEqual('network(notauuid)', str(n))
Esempio n. 12
0
 def test_init(self):
     net.Network({
         'uuid': 'notauuid',
         'vxid': 2,
         'name': 'bobnet',
         'namespace': 'finitespace',
         'provide_dhcp': True,
         'provide_nat': True,
         'egress_nic': 'eth0',
         'mesh_nic': 'eth0',
         'mesh_nic': 'eth0',
         'netblock': '192.168.1.0/24'
     })
Esempio n. 13
0
 def test_is_created_no_bridge(self, mock_execute):
     n = net.Network({
         'uuid': '8abbc9a6-d923-4441-b498-4f8e3c166804',
         'vxid': 5,
         'name': 'bobnet',
         'namespace': 'finitespace',
         'provide_dhcp': True,
         'provide_nat': True,
         'egress_nic': 'eth0',
         'mesh_nic': 'eth0',
         'netblock': '192.168.1.0/24'
     })
     self.assertFalse(n.is_created())
Esempio n. 14
0
    def test_set_state_valid(
            self, mock_put, mock_attribute_set, mock_state_get, mock_lock):

        n = net.Network({
            'uuid': '8abbc9a6-d923-4441-b498-4f8e3c166804',
            'vxid': 5,
            'name': 'bobnet',
            'namespace': 'finitespace',
            'provide_dhcp': True,
            'provide_nat': True,
            'egress_nic': 'eth0',
            'mesh_nic': 'eth0',
            'netblock': '192.168.1.0/24'
        })
        with testtools.ExpectedException(exceptions.InvalidStateException):
            n.state = net.Network.STATE_INITIAL
        n.state = dbo.STATE_ERROR
        n.state = dbo.STATE_DELETED
        with testtools.ExpectedException(exceptions.InvalidStateException):
            n.state = dbo.STATE_CREATED
Esempio n. 15
0
    def test_delete_all_networks(self, mock_db_get_lock, mock_etcd_put,
                                 mock_update_network_state, mock_delete,
                                 mock_remove_dhcp, mock_get_ipmanager,
                                 mock_db_get_network_interfaces,
                                 mock_db_get_networks):

        mock_network = mock.patch('shakenfist.net.from_db',
                                  return_value=net.Network({'uuid': 'foo'}))
        mock_network.start()
        self.addCleanup(mock_network.stop)

        resp = self.client.delete('/networks',
                                  headers={'Authorization': self.auth_header},
                                  data=json.dumps({
                                      'confirm': True,
                                      'namespace': 'foo'
                                  }))
        self.assertEqual(['30f6da44-look-i-am-uuid'], resp.get_json())
        self.assertEqual(200, resp.status_code)

        mock_network.stop()