Exemplo n.º 1
0
def create_dhcprelayIPv4_object(user, ipv4_id, networkipv4_id):

    with distributedlock(LOCK_DCHCPv4_NET % networkipv4_id):
        dhcprelay_obj = DHCPRelayIPv4()
        dhcprelay_obj.create(ipv4_id, networkipv4_id)
        dhcprelay_obj.save()
        return dhcprelay_obj
Exemplo n.º 2
0
 def get(self, *args, **kwargs):
     """
     Lists dhcprelay ipv4 entry.
     """
     dhcprelay_id = kwargs['dhcprelay_id']
     dhcprelayipv4_obj = DHCPRelayIPv4.get_by_pk(id=dhcprelay_id)
     serializer_options = DHCPRelayIPv4Serializer(dhcprelayipv4_obj,
                                                  many=False)
     return Response(serializer_options.data)
Exemplo n.º 3
0
def delete_dhcprelayipv4(user, dhcprelayipv4_id):

    dhcprelayipv4_obj = DHCPRelayIPv4.get_by_pk(id=dhcprelayipv4_id)

    with distributedlock(LOCK_NETWORK_IPV4 % dhcprelayipv4_obj.networkipv4.id):
        if not dhcprelayipv4_obj.networkipv4.active:
            dhcprelayipv4_obj.delete()
            return True
        else:
            raise exceptions.CannotRemoveDHCPRelayFromActiveNetwork()
Exemplo n.º 4
0
def delete_dhcprelayipv4(user, dhcprelayipv4_id):

    dhcprelayipv4_obj = DHCPRelayIPv4.get_by_pk(id=dhcprelayipv4_id)

    with distributedlock(LOCK_NETWORK_IPV4 % dhcprelayipv4_obj.networkipv4.id):
        if not dhcprelayipv4_obj.networkipv4.active:
            dhcprelayipv4_obj.delete()
            return True
        else:
            raise exceptions.CannotRemoveDHCPRelayFromActiveNetwork()
Exemplo n.º 5
0
 def get(self, *args, **kwargs):
     '''Lists dhcprelay ipv4 entry
     '''
     dhcprelay_id = kwargs['dhcprelay_id']
     dhcprelayIPv4_obj = DHCPRelayIPv4.get_by_pk(id=dhcprelay_id)
     serializer_options = DHCPRelayIPv4Serializer(
         dhcprelayIPv4_obj,
         many=False
     )
     return Response(serializer_options.data)
    def test_deploy_networkipv4_configuration_with_active_vlan(self):
        self.networkv4.vlan.ativada = True

        ipv4 = Ip(oct1=192, oct2=168, oct3=0, oct4=0)
        self.mock_ip_get_by_octets(ipv4)
        self.mock_find_equipamento_ip([IpEquipamento()])
        self.mock_dhcp_relay_find([DHCPRelayIPv4(ipv4=ipv4)])
        self.mock_find_roteiro(
            EquipamentoRoteiro(roteiro=Roteiro(roteiro='roteiro')))
        self.mock_template_file_read('script content')
        deploy_config_mock = self.mock_deploy_config('config_deployed')
        network_activation_mock = self.mock_network_activation()
        vlan_activation_mock = self.mock_vlan_activation()

        response = deploy_networkIPv4_configuration(self.user, self.networkv4,
                                                    self.equipment_list)

        self.assertTrue(deploy_config_mock.called)
        network_activation_mock.assert_called_with(self.user)
        self.assertFalse(vlan_activation_mock.called)
        self.assertEquals({1: 'config_deployed'}, response)