Changeset 863
- Timestamp:
- 12/15/11 17:23:45 (13 years ago)
- Location:
- LATMOS-Accounts
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
LATMOS-Accounts/Changes
r861 r863 1 1 Revision history for Perl extension LATMOS::Accounts. 2 3 3.0.0 4 - hande IPv6 addresses 5 - support kerberos database (heidmal) 2 6 3 7 2.0.0 -
LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Netzone.pm
r861 r863 119 119 select * from ( 120 120 select host(network(value::inet)+ (generate_series(1, broadcast(value::inet) - network(value::inet) -1))) from netzone_attributes where 121 attr='net' and okey = $1 121 attr='net' and okey = $1 and family(value::inet) = 4 122 122 except 123 123 ( -
LATMOS-Accounts/lib/LATMOS/Accounts/BuildNet.pm
r861 r863 116 116 if (! -d $path) { 117 117 la_log(LA_INFO, 'Creating directory %s', $path); 118 m ake_path($path) or return;118 mkpath($path) or return; 119 119 } 120 120 my $output = join('/', $path, $ozone->get_attributes('outputD')); … … 340 340 nethost.ikey = nethost_attributes_ips.okey 341 341 where value::inet <<= any(?) 342 342 order by value, name 343 343 }); 344 344 $findhost->execute( … … 350 350 return; 351 351 }; 352 my @lists;352 my %lists; 353 353 my %names; 354 354 # Storing all name in %names to check later if CNAME does not conflict 355 355 while (my $res = $findhost->fetchrow_hashref) { 356 push(@lists, $res);357 $names{$res->{name}} = 1;356 $lists{$res->{name}} ||= {}; 357 push(@{$lists{$res->{name}}{ip}}, $res->{value}); 358 358 my $host_o = $self->_base->get_object('nethost', $res->{name}); 359 359 foreach (grep { $_ } $host_o->get_attributes('otherName')) { … … 362 362 } 363 363 364 foreach my $res ( @lists) {365 my $host_o = $self->_base->get_object('nethost', $res ->{name}) or do {364 foreach my $res (sort keys %lists) { 365 my $host_o = $self->_base->get_object('nethost', $res) or do { 366 366 la_log LA_ERR, "Cannot fetch host %s", $res->{name}; 367 367 return; … … 371 371 ? '; ' . $desc . "\n" 372 372 : ''; 373 $dbzone .= sprintf("%-30s IN A %s\n", $res->{name}, $res->{value}); 373 foreach my $ip (@{$lists{$res}{ip}}) { 374 $dbzone .= sprintf( 375 "%-30s IN %-4s %s\n", 376 $res, 377 ($ip =~ /:/ ? 'AAAA' : 'A'), 378 $ip 379 ); 380 } 374 381 foreach (grep { $_ } $host_o->get_attributes('otherName')) { 375 $dbzone .= sprintf("%-30s IN A %s\n", $_, $res->{value}); 382 foreach my $ip (@{$lists{$res}{ip}}) { 383 $dbzone .= sprintf( 384 "%-30s IN %-4s %s\n", 385 $_, 386 ($ip =~ /:/ ? 'AAAA' : 'A'), 387 $ip 388 ); 389 } 376 390 } 377 391 foreach (grep { $_ } $host_o->get_attributes('cname')) { … … 387 401 $dbzone .= "; $msg\n"; 388 402 } else { 389 $dbzone .= sprintf("%-30s IN CNAME %s\n", $_, $res->{name},);403 $dbzone .= sprintf("%-30s IN CNAME %s\n", $_, $res,); 390 404 } 391 405 } -
LATMOS-Accounts/sqldata/base.sql
r861 r863 148 148 END IF; 149 149 END;$$; 150 151 152 --153 -- Name: check_zone_name_unity(); Type: FUNCTION; Schema: public; Owner: -154 --155 156 CREATE FUNCTION check_zone_name_unity() RETURNS trigger157 LANGUAGE plpgsql158 AS $$declare159 list record;160 begin161 162 select into list * from (163 select count(*) as c, name, zone from164 (select nethost.name, zone_obj.name as zone from165 (select nethost_attributes_ips.okey, netzone.name from nethost_attributes_ips166 join netzone_attributes on167 netzone_attributes.attr='net' and nethost_attributes_ips.value::inet <<= netzone_attributes.value::inet168 join netzone on netzone.ikey = netzone_attributes.okey) as zone_obj169 join nethost on zone_obj.okey = nethost.ikey170 union all171 select nethost_attributes.value, zone_obj.name from172 (select nethost_attributes_ips.okey, netzone.name from nethost_attributes_ips173 join netzone_attributes on174 netzone_attributes.attr='net' and nethost_attributes_ips.value::inet <<= netzone_attributes.value::inet175 join netzone on netzone.ikey = netzone_attributes.okey176 join netzone_attributes as nza on nza.okey = netzone.ikey and nza.attr = 'type' and nza.value = 'dns') as zone_obj177 join nethost_attributes on nethost_attributes.attr = 'cname' and nethost_attributes.okey = zone_obj.okey178 ) as foo179 group by name, zone180 ) as foo where c > 1;181 182 IF FOUND THEN183 RAISE EXCEPTION 'record name found multiple time in a zone';184 END IF;185 186 RETURN new;187 END;$$;188 189 150 190 151 -- … … 1066 1027 -- 1067 1028 1068 CREATE TABLE nethost_attributes_ips ( CONSTRAINT nethost_is_single_ip CHECK ((netmask((value)::inet) = '255.255.255.255'::inet))1029 CREATE TABLE nethost_attributes_ips ( 1069 1030 ) 1070 1031 INHERITS (nethost_attributes); … … 2182 2143 -- 2183 2144 2184 CREATE UNIQUE INDEX nethost_cname_uniq_idx ON nethost_attributes USING btree (value , okey) WHERE (attr = 'cname'::text);2145 CREATE UNIQUE INDEX nethost_cname_uniq_idx ON nethost_attributes USING btree (value) WHERE (attr = 'cname'::text); 2185 2146 2186 2147 … … 2427 2388 2428 2389 -- 2429 -- Name: check_zone_name_unity_tg; Type: TRIGGER; Schema: public; Owner: -2430 --2431 2432 CREATE TRIGGER check_zone_name_unity_tg2433 AFTER INSERT OR UPDATE ON nethost2434 FOR EACH STATEMENT2435 EXECUTE PROCEDURE check_zone_name_unity();2436 2437 2438 --2439 -- Name: check_zone_name_unity_tg; Type: TRIGGER; Schema: public; Owner: -2440 --2441 2442 CREATE TRIGGER check_zone_name_unity_tg2443 AFTER INSERT OR UPDATE ON netzone2444 FOR EACH STATEMENT2445 EXECUTE PROCEDURE check_zone_name_unity();2446 2447 2448 --2449 2390 -- Name: department_group_upd_tg; Type: TRIGGER; Schema: public; Owner: - 2450 2391 --
Note: See TracChangeset
for help on using the changeset viewer.