Send Netdot-devel mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
https://osl.uoregon.edu/mailman/listinfo/netdot-devel
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Netdot-devel digest..."
Today's Topics:
1. [Netdot - Bug #1862] (New) Fix for Bug#1853 breaks Postgresql
compatibility ([email protected])
2. [Netdot - Bug #1862] Fix for Bug#1853 breaks Postgresql
compatibility ([email protected])
3. [SCM] Netdot branch netdot-1.0 updated.
netdot-1.0.7-18-gc682762 ([email protected])
4. [SCM] Netdot branch master updated. netdot-1.0.7-18-gc682762
([email protected])
5. [Netdot - Feature #1861] (Resolved) Ability to more easily
add aliases (CNAME records) to an existing record via REST
([email protected])
----------------------------------------------------------------------
Message: 1
Date: Thu, 21 May 2015 05:16:25 -0700
From: [email protected]
Subject: [Netdot-devel] [Netdot - Bug #1862] (New) Fix for Bug#1853
breaks Postgresql compatibility
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8
Issue #1862 has been reported by Petr ?ech.
----------------------------------------
Bug #1862: Fix for Bug#1853 breaks Postgresql compatibility
https://osl.uoregon.edu/redmine/issues/1862
Author: Petr ?ech
Status: New
Priority: Normal
Assignee:
Category: DeviceManagement
Target version: 1.0.8
Resolution:
Hi,
it seems that the change bc7307fb uses MySQL specific SQL syntax, which does't
work with PostgreSQL.
LEFT OUTER JOIN (asset a, product p, entity m) ON a.id=d.asset_id
AND a.product_id=p.id
AND m.id=p.manufacturer
should probably be replaced with
LEFT OUTER JOIN asset a ON a.id=d.asset_id
LEFT OUTER JOIN product p ON a.product_id=p.id
LEFT OUTER JOIN entity m ON m.id=p.manufacturer
That seems to work fine for me.
Regards
Petr
--
You have received this notification because you have either subscribed to it,
or are involved in it.
To change your notification preferences, please click here:
http://osl.uoregon.edu/redmine/my/account
------------------------------
Message: 2
Date: Thu, 21 May 2015 06:02:37 -0700
From: [email protected]
Subject: [Netdot-devel] [Netdot - Bug #1862] Fix for Bug#1853 breaks
Postgresql compatibility
To: [email protected], [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8
Issue #1862 has been updated by Carlos Vicente.
Assignee set to Carlos Vicente
----------------------------------------
Bug #1862: Fix for Bug#1853 breaks Postgresql compatibility
https://osl.uoregon.edu/redmine/issues/1862#change-3300
Author: Petr ?ech
Status: New
Priority: Normal
Assignee: Carlos Vicente
Category: DeviceManagement
Target version: 1.0.8
Resolution:
Hi,
it seems that the change bc7307fb uses MySQL specific SQL syntax, which does't
work with PostgreSQL.
LEFT OUTER JOIN (asset a, product p, entity m) ON a.id=d.asset_id
AND a.product_id=p.id
AND m.id=p.manufacturer
should probably be replaced with
LEFT OUTER JOIN asset a ON a.id=d.asset_id
LEFT OUTER JOIN product p ON a.product_id=p.id
LEFT OUTER JOIN entity m ON m.id=p.manufacturer
That seems to work fine for me.
Regards
Petr
--
You have received this notification because you have either subscribed to it,
or are involved in it.
To change your notification preferences, please click here:
http://osl.uoregon.edu/redmine/my/account
------------------------------
Message: 3
Date: Thu, 21 May 2015 06:36:01 -0700
From: [email protected]
Subject: [Netdot-devel] [SCM] Netdot branch netdot-1.0 updated.
netdot-1.0.7-18-gc682762
To: [email protected]
Message-ID: <[email protected]>
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Netdot".
The branch, netdot-1.0 has been updated
via c6827622422d45c026701ebd9e78ce8da260d1e2 (commit)
from b76eca08ae9fe76604a6e1f538806bc69f144f32 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit c6827622422d45c026701ebd9e78ce8da260d1e2
Author: Carlos Vicente <[email protected]>
Date: Thu May 21 09:33:34 2015 -0400
A few small improvements in RR.pm related to CNAMES
diff --git a/htdocs/management/host.html b/htdocs/management/host.html
index 16efbcc..ec9ad24 100644
--- a/htdocs/management/host.html
+++ b/htdocs/management/host.html
@@ -668,7 +668,7 @@ foreach my $o ( values %rrs ) {
#display/edit
print '<div class="containerbody">';
- if ( my @cnames = RRCNAME->search(cname=>$o->get_label) ){
+ if ( my @cnames = $o->aliases ){
foreach my $cname ( sort { $a->rr->name cmp $b->rr->name } @cnames
) {
$ui->add_to_fields(o=>$cname, edit=>0, fields=>['rr'],
field_headers=>\@field_headers,
cell_data=>\@cell_data,
diff --git a/htdocs/rest/host b/htdocs/rest/host
index 27d08ab..31be96e 100644
--- a/htdocs/rest/host
+++ b/htdocs/rest/host
@@ -202,7 +202,7 @@ if ( $method eq 'GET' ){
};
if ( my $e = $@ ){
$rest->throw(code=>Apache2::Const::HTTP_BAD_REQUEST,
- msg=>'Bad request: $e');
+ msg=>"Bad request: $e");
}
$rest->print_serialized($rest->get(obj=>$rr, depth=>0));
diff --git a/lib/Netdot/Model/RR.pm b/lib/Netdot/Model/RR.pm
index 7b11f80..d631b0c 100644
--- a/lib/Netdot/Model/RR.pm
+++ b/lib/Netdot/Model/RR.pm
@@ -157,24 +157,20 @@ sub insert {
# Set default zone if needed
if ( defined($argv->{type}) && $argv->{type} eq 'CNAME' &&
- defined($argv->{name}) && $argv->{name} =~ /\.$/ ){
- # In this particular case, the user specified a dot at the end, which
indicates
- # that the label should not get the zone name appended
- if ( my $z = (Zone->search(name=>$argv->{name}))[0] ){
- $argv->{zone} = $z;
- }
+ defined($argv->{name}) && $argv->{name} =~ /\.$/ ){
+ # In this particular case, the user specified a dot at the end, which
indicates
+ # that the label should not get the zone name appended
+ if ( my $z = (Zone->search(name=>$argv->{name}))[0] ){
+ $argv->{zone} = $z;
+ }
}else{
- $argv->{zone} = $class->config->get('DEFAULT_DNSDOMAIN') ||
'localdomain'
- unless ($argv->{zone});
+ $argv->{zone} = $class->config->get('DEFAULT_DNSDOMAIN') ||
'localdomain'
+ unless ($argv->{zone});
}
# Insert zone if necessary;
my $zone;
- if ( (ref( $zone = $argv->{zone} ) =~ /Zone/)
- || ( $zone = (Zone->search(id =>$argv->{zone}))[0] )
- || ( $zone = (Zone->search(name=>$argv->{zone}))[0] )
- ){
- }else{
+ unless ( $zone = Zone->objectify($argv->{zone}) ){
$logger->debug(sub{ sprintf("Zone not found: \"%s\". Inserting.",
$argv->{zone}) });
$zone = Zone->insert({ name => $argv->{zone} });
$logger->info(sprintf("Inserted new Zone: %s", $zone->get_label));
@@ -228,57 +224,81 @@ sub insert {
delete $args{$arg};
}
- if ( $argv->{type} eq 'A' || $argv->{type} eq 'AAAA' ){
- return RRADDR->insert(\%args);
-
- }elsif ( $argv->{type} eq 'CNAME' ){
- return RRCNAME->insert(\%args);
-
- }elsif ( $argv->{type} eq 'DS' ){
- return RRDS->insert(\%args);
+ if ( exists $argv->{type} ){
+ if ( $argv->{type} eq 'A' || $argv->{type} eq 'AAAA' ){
+ return RRADDR->insert(\%args);
+
+ }elsif ( $argv->{type} eq 'CNAME' ){
+ return RRCNAME->insert(\%args);
+
+ }elsif ( $argv->{type} eq 'DS' ){
+ return RRDS->insert(\%args);
+
+ }elsif ( $argv->{type} eq 'HINFO' ){
+ return RRHINFO->insert(\%args);
+
+ }elsif ( $argv->{type} eq 'LOC' ){
+ return RRLOC->insert(\%args);
+
+ }elsif ( $argv->{type} eq 'MX' ){
+ return RRMX->insert(\%args);
+
+ }elsif ( $argv->{type} eq 'NAPTR' ){
+ return RRNAPTR->insert(\%args);
+
+ }elsif ( $argv->{type} eq 'NS' ){
+ return RRNS->insert(\%args);
+
+ }elsif ( $argv->{type} eq 'PTR' ){
+ return RRPTR->insert(\%args);
+
+ }elsif ( $argv->{type} eq 'SRV' ){
+ return RRSRV->insert(\%args);
+
+ }elsif ( $argv->{type} eq 'TXT' ){
+ return RRTXT->insert(\%args);
+
+ }else{
+ $class->throw_user("Unrecognized type: ".$argv->{type});
+ }
+ }
+}
- }elsif ( $argv->{type} eq 'HINFO' ){
- return RRHINFO->insert(\%args);
-
- }elsif ( $argv->{type} eq 'LOC' ){
- return RRLOC->insert(\%args);
+=head1 INSTANCE METHODS
+=cut
- }elsif ( $argv->{type} eq 'MX' ){
- return RRMX->insert(\%args);
-
- }elsif ( $argv->{type} eq 'NAPTR' ){
- return RRNAPTR->insert(\%args);
+##################################################################
- }elsif ( $argv->{type} eq 'NS' ){
- return RRNS->insert(\%args);
+=head2 aliases - Get list of aliases pointing to this record
- }elsif ( $argv->{type} eq 'PTR' ){
- return RRPTR->insert(\%args);
+ NOTE: Not to be confused with $rr->cnames, which
+ gets the RRCNAME records associated with an RR that
+ is the alias name.
- }elsif ( $argv->{type} eq 'SRV' ){
- return RRSRV->insert(\%args);
+ Arguments:
+ None
+ Returns:
+ Array of RRCNAME objects
+ Examples:
+ @list = $rr->aliases()
- }elsif ( $argv->{type} eq 'TXT' ){
- return RRTXT->insert(\%args);
-
- }else{
- $class->throw_user("Unrecognized type: ".$argv->{type});
- }
+=cut
+sub aliases {
+ my $self = shift;
+ return RRCNAME->search(cname=>$self->get_label);
}
-=head1 INSTANCE METHODS
-=cut
-
##################################################################
=head2 update
Override base method to:
- - Add option to update related RRPTR if name changes
+ - Update existing CNAMES
+ - Add option to update related RRPTR if name changes
Arguments:
Hashref with key/value pairs, plus:
- update_ptr - (flag)
+ update_ptr - 0 or 1
Returns:
See Netdot::Model::update
Examples:
@@ -289,10 +309,10 @@ sub insert {
sub update {
my ($self, $argv) = @_;
$self->isa_object_method('update');
-
+
# Get CNAMEs that point to me
my $old_fqdn = $self->get_label;
- my @cnames = RRCNAME->search(cname=>$self->get_label);
+ my @cnames = $self->aliases();
my $update_ptr = 1; # On by default
if ( defined $argv->{update_ptr} && $argv->{update_ptr} == 0 ){
@@ -553,28 +573,11 @@ sub add_host {
$rr = $rraddr->rr;
+
# CNAMES
if ( $argv{aliases} ){
- my @cnames;
- my @aliases = split ',', $argv{aliases};
- foreach my $alias ( @aliases ){
- $alias =~ s/\s+//g;
- # In case they included the domain part in the alias
- my $domain = $zone->name;
- $alias =~ s/\.$domain$//;
- if ( my $h = RR->search(name=>$alias, zone=>$zone)->first ){
- $class->throw_user($h->get_label." from your aliases
list is already taken");
- }
- push @cnames, $alias;
- }
-
- foreach my $alias ( @cnames ){
- RR->insert({name => $alias,
- zone => $zone,
- type => 'CNAME',
- cname => $rr->get_label,
- });
- }
+ my @aliases = split(/\s*,\s*/, $argv{aliases});
+ map { $rr->add_alias($_) } @aliases;
}
# HINFO
@@ -674,9 +677,42 @@ sub sub_records {
}
############################################################################
+
+=head2 add_alias - Add CNAME record pointing to this one
+
+ Args:
+ String
+ Returns:
+ new RRCNAME object
+ Examples:
+ $rr->add_alias('my_alias');
+
+=cut
+
+sub add_alias {
+ my ($self, $alias) = @_;
+
+ $logger->debug(sprintf("RR::add_alias(): alias: %s", $alias));
+
+ # In case they included the domain part in the alias
+ my $domain = $self->zone->name;
+ $alias =~ s/\.$domain$//;
+ if ( my $h = RR->search(name=>$alias, zone=>$self->zone)->first ){
+ $self->throw_user("CNAME record: ".$h->get_label." already exists");
+ }
+ RR->insert({name => $alias,
+ zone => $self->zone,
+ type => 'CNAME',
+ cname => $self->get_label,
+ });
+}
+
+
+############################################################################
# PRIVATE METHODS
############################################################################
+
############################################################################
# _validate_args - Validate arguments to insert and update
#
@@ -744,8 +780,9 @@ sub _validate_args {
# labels (sections between dots) must not exceed 63 chars
foreach my $label ( split(/\./, $fqdn) ){
unless ( length($label) >= 1 && length($label) < 64 ){
- $self->throw_user("Invalid label: $label. Each label must be
between 1".
- " and 63 characters long");
+ $self->throw_user(sprintf("RR::validate_args(): '%s' has
Invalid label: '%s'. ".
+ "Each label must be between 1 and 63
characters long",
+ $fqdn, $label));
}
}
$argv->{name} = $name;
@@ -759,7 +796,7 @@ Carlos Vicente, C<< <cvicente at ns.uoregon.edu> >>
=head1 COPYRIGHT & LICENSE
-Copyright 2012 University of Oregon, all rights reserved.
+Copyright 2015 University of Oregon, all rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/t/RR.t b/t/RR.t
index 6e4715c..2e6f598 100644
--- a/t/RR.t
+++ b/t/RR.t
@@ -122,6 +122,11 @@ foreach my $rtype ( keys %$count ){
is($count->{$rtype}, 1, $rtype.'_record_count');
}
+$rr->add_alias('alias2');
+my @cnames = $rr->aliases();
+isa_ok($cnames[1], 'Netdot::Model::RRCNAME', 'add_alias');
+is($cnames[1]->as_text, "alias2.$domain. 86400 IN CNAME
$name.$domain.", 'alias_as_text');
+
# Clean up
$zone->delete;
$revzone->delete;
-----------------------------------------------------------------------
Summary of changes:
htdocs/management/host.html | 2 +-
htdocs/rest/host | 2 +-
lib/Netdot/Model/RR.pm | 183 ++++++++++++++++++++++++++------------------
t/RR.t | 5 ++
4 files changed, 117 insertions(+), 75 deletions(-)
hooks/post-receive
--
Netdot
------------------------------
Message: 4
Date: Thu, 21 May 2015 06:36:25 -0700
From: [email protected]
Subject: [Netdot-devel] [SCM] Netdot branch master updated.
netdot-1.0.7-18-gc682762
To: [email protected]
Message-ID: <[email protected]>
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Netdot".
The branch, master has been updated
via c6827622422d45c026701ebd9e78ce8da260d1e2 (commit)
via b76eca08ae9fe76604a6e1f538806bc69f144f32 (commit)
via 8963d657e1cf497a0b2427ac775d4c581df702e7 (commit)
via 62d085adc0326010bdcb8bea34a77fb5d66dc8e2 (commit)
from 6c067629f655bd998520c63d41067a1560499a91 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
-----------------------------------------------------------------------
Summary of changes:
htdocs/management/host.html | 2 +-
htdocs/rest/host | 2 +-
lib/Netdot/Model/RR.pm | 183 ++++++++++++++++++++++++++------------------
t/RR.t | 5 ++
4 files changed, 117 insertions(+), 75 deletions(-)
hooks/post-receive
--
Netdot
------------------------------
Message: 5
Date: Thu, 21 May 2015 06:39:57 -0700
From: [email protected]
Subject: [Netdot-devel] [Netdot - Feature #1861] (Resolved) Ability to
more easily add aliases (CNAME records) to an existing record via
REST
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=utf-8
Issue #1861 has been updated by Carlos Vicente.
Status changed from New to Resolved
Resolution set to fixed
After looking at the code I realized that it's already possible to do this
using the RR resource, with the appropriate arguments. I will, however, add a
method to the Ruby REST client.
Made some minor improvements to RR.pm the meantime.
----------------------------------------
Feature #1861: Ability to more easily add aliases (CNAME records) to an
existing record via REST
https://osl.uoregon.edu/redmine/issues/1861#change-3301
Author: Carlos Vicente
Status: Resolved
Priority: High
Assignee: Carlos Vicente
Category: RestAPI
Target version: 1.0.8
Resolution: fixed
--
You have received this notification because you have either subscribed to it,
or are involved in it.
To change your notification preferences, please click here:
http://osl.uoregon.edu/redmine/my/account
------------------------------
_______________________________________________
Netdot-devel mailing list
[email protected]
https://osl.uoregon.edu/mailman/listinfo/netdot-devel
End of Netdot-devel Digest, Vol 98, Issue 10
********************************************