Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix duplicate hostname #3295

Merged
merged 8 commits into from
Aug 8, 2018
Merged

Conversation

m1kra
Copy link
Contributor

@m1kra m1kra commented Aug 2, 2018

If two IPs have the same hostname in DHCP, one is ignored. This PR adds validation of such scenario when "expose in DHCP" is selected while creating or updating IP address.

@coveralls
Copy link

coveralls commented Aug 2, 2018

Coverage Status

Coverage decreased (-0.1%) to 84.469% when pulling 29212c5 on m1kra:fix_duplicate_hostname into 571a5c9 on allegro:ng.

from ralph.dhcp.models import DHCPEntry
entries_with_hostname = DHCPEntry.objects.filter(
hostname=hostname,
dhcp_expose=True,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to filter it - it's already handled by DHCPEntry's manager

@@ -662,6 +662,32 @@ class Meta:
def __str__(self):
return self.address

def hostname_is_unique_in_dc(self, hostname, dc):
from ralph.dhcp.models import DHCPEntry
entries_with_hostname = DHCPEntry.objects.filter(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we exclude here current ip address (by its pk)?

@MarekBleschke MarekBleschke merged commit f51b400 into allegro:ng Aug 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants