mirror of
https://github.com/internetee/registry.git
synced 2025-07-06 11:13:27 +02:00
Add new task to import zones #2806
This commit is contained in:
parent
1a7360cc3c
commit
0fdbcadcf5
1 changed files with 160 additions and 209 deletions
|
@ -54,7 +54,7 @@ namespace :import do
|
||||||
Rake::Task['import:registrars'].invoke
|
Rake::Task['import:registrars'].invoke
|
||||||
Rake::Task['import:contacts'].invoke
|
Rake::Task['import:contacts'].invoke
|
||||||
Rake::Task['import:domains'].invoke
|
Rake::Task['import:domains'].invoke
|
||||||
Rake::Task['import:eis_domains'].invoke
|
Rake::Task['import:zones'].invoke
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'Import registrars'
|
desc 'Import registrars'
|
||||||
|
@ -473,246 +473,197 @@ namespace :import do
|
||||||
puts "-----> Imported #{count} new domains in #{(Time.zone.now.to_f - start).round(2)} seconds"
|
puts "-----> Imported #{count} new domains in #{(Time.zone.now.to_f - start).round(2)} seconds"
|
||||||
end
|
end
|
||||||
|
|
||||||
desc 'Import EIS domains'
|
desc 'Import zones'
|
||||||
task eis_domains: :environment do
|
task zones: :environment do
|
||||||
start = Time.zone.now.to_f
|
start = Time.zone.now.to_f
|
||||||
puts '-----> Importing EIS domains...'
|
puts '-----> Importing zones...'
|
||||||
|
|
||||||
eis = Registrar.where(
|
ns_records, a_records, a4_records = parse_zone_ns_data(1)
|
||||||
name: 'EIS',
|
|
||||||
reg_no: '90010019',
|
|
||||||
phone: '+3727271000',
|
|
||||||
country_code: 'EE',
|
|
||||||
vat_no: 'EE101286464',
|
|
||||||
email: 'info@internet.ee',
|
|
||||||
state: 'Harjumaa',
|
|
||||||
city: 'Tallinn',
|
|
||||||
street: 'Paldiski mnt 80',
|
|
||||||
zip: '10617',
|
|
||||||
url: 'www.internet.ee',
|
|
||||||
code: 'EIS'
|
|
||||||
).first_or_create!
|
|
||||||
|
|
||||||
unless eis.cash_account
|
ZonefileSetting.create!({
|
||||||
eis.accounts.create(account_type: Account::CASH, currency: 'EUR')
|
origin: 'ee',
|
||||||
eis.save
|
ttl: 43200,
|
||||||
end
|
refresh: 3600,
|
||||||
|
retry: 900,
|
||||||
c = Registrant.where(
|
expire: 1209600,
|
||||||
name: 'Eesti Interneti Sihtasutus',
|
minimum_ttl: 3600,
|
||||||
phone: '+372.7271000',
|
email: 'hostmaster.eestiinternet.ee',
|
||||||
email: 'info@internet.ee',
|
master_nameserver: 'ns.tld.ee',
|
||||||
ident: '90010019',
|
ns_records: ns_records,
|
||||||
ident_type: 'passport',
|
a_records: a_records,
|
||||||
city: 'Tallinn',
|
a4_records: a4_records
|
||||||
country_code: 'ee',
|
})
|
||||||
street: 'Paldiski mnt 80',
|
|
||||||
zip: '10617',
|
|
||||||
registrar: eis
|
|
||||||
).first_or_create!
|
|
||||||
|
|
||||||
# ee
|
|
||||||
ns_list = []
|
|
||||||
Legacy::ZoneNs.where(zone: 1).each do |x|
|
|
||||||
ipv4 = x.addrs.select { |addr| addr.ipv4? }.first
|
|
||||||
ipv6 = x.addrs.select { |addr| addr.ipv6? }.first
|
|
||||||
ns_list << Nameserver.new(hostname: x.fqdn, ipv4: ipv4, ipv6: ipv6)
|
|
||||||
end
|
|
||||||
|
|
||||||
Domain.create!(
|
|
||||||
name: 'ee',
|
|
||||||
valid_to: Date.new(9999, 1, 1),
|
|
||||||
period: 1,
|
|
||||||
period_unit: 'y',
|
|
||||||
registrant: c,
|
|
||||||
nameservers: ns_list,
|
|
||||||
admin_contacts: [c],
|
|
||||||
tech_contacts: [c],
|
|
||||||
registrar: eis
|
|
||||||
)
|
|
||||||
|
|
||||||
# edu.ee
|
# edu.ee
|
||||||
ns_list = []
|
ns_records, a_records, a4_records = parse_zone_ns_data(6)
|
||||||
Legacy::ZoneNs.where(zone: 6).each do |x|
|
|
||||||
ipv4 = x.addrs.select { |addr| addr.ipv4? }.first
|
|
||||||
ipv6 = x.addrs.select { |addr| addr.ipv6? }.first
|
|
||||||
ns_list << Nameserver.new(hostname: x.fqdn, ipv4: ipv4, ipv6: ipv6)
|
|
||||||
end
|
|
||||||
|
|
||||||
Domain.create!(
|
ZonefileSetting.create!({
|
||||||
name: 'edu.ee',
|
origin: 'edu.ee',
|
||||||
valid_to: Date.new(9999, 1, 1),
|
ttl: 43200,
|
||||||
period: 1,
|
refresh: 3600,
|
||||||
period_unit: 'y',
|
retry: 900,
|
||||||
registrant: c,
|
expire: 1209600,
|
||||||
nameservers: ns_list,
|
minimum_ttl: 3600,
|
||||||
admin_contacts: [c],
|
email: 'hostmaster.eestiinternet.ee',
|
||||||
tech_contacts: [c],
|
master_nameserver: 'ns.tld.ee',
|
||||||
registrar: eis
|
ns_records: ns_records,
|
||||||
)
|
a_records: a_records,
|
||||||
|
a4_records: a4_records
|
||||||
|
})
|
||||||
|
|
||||||
# aip.ee
|
# aip.ee
|
||||||
ns_list = []
|
ns_records, a_records, a4_records = parse_zone_ns_data(9)
|
||||||
Legacy::ZoneNs.where(zone: 9).each do |x|
|
|
||||||
ipv4 = x.addrs.select { |addr| addr.ipv4? }.first
|
|
||||||
ipv6 = x.addrs.select { |addr| addr.ipv6? }.first
|
|
||||||
ns_list << Nameserver.new(hostname: x.fqdn, ipv4: ipv4, ipv6: ipv6)
|
|
||||||
end
|
|
||||||
|
|
||||||
Domain.create!(
|
ZonefileSetting.create!({
|
||||||
name: 'aip.ee',
|
origin: 'aip.ee',
|
||||||
valid_to: Date.new(9999, 1, 1),
|
ttl: 43200,
|
||||||
period: 1,
|
refresh: 3600,
|
||||||
period_unit: 'y',
|
retry: 900,
|
||||||
registrant: c,
|
expire: 1209600,
|
||||||
nameservers: ns_list,
|
minimum_ttl: 3600,
|
||||||
admin_contacts: [c],
|
email: 'hostmaster.eestiinternet.ee',
|
||||||
tech_contacts: [c],
|
master_nameserver: 'ns.tld.ee',
|
||||||
registrar: eis
|
ns_records: ns_records,
|
||||||
)
|
a_records: a_records,
|
||||||
|
a4_records: a4_records
|
||||||
|
})
|
||||||
|
|
||||||
# org.ee
|
# org.ee
|
||||||
ns_list = []
|
ns_records, a_records, a4_records = parse_zone_ns_data(10)
|
||||||
Legacy::ZoneNs.where(zone: 10).each do |x|
|
|
||||||
ipv4 = x.addrs.select { |addr| addr.ipv4? }.first
|
|
||||||
ipv6 = x.addrs.select { |addr| addr.ipv6? }.first
|
|
||||||
ns_list << Nameserver.new(hostname: x.fqdn, ipv4: ipv4, ipv6: ipv6)
|
|
||||||
end
|
|
||||||
|
|
||||||
Domain.create!(
|
ZonefileSetting.create!({
|
||||||
name: 'org.ee',
|
origin: 'org.ee',
|
||||||
valid_to: Date.new(9999, 1, 1),
|
ttl: 43200,
|
||||||
period: 1,
|
refresh: 3600,
|
||||||
period_unit: 'y',
|
retry: 900,
|
||||||
registrant: c,
|
expire: 1209600,
|
||||||
nameservers: ns_list,
|
minimum_ttl: 3600,
|
||||||
admin_contacts: [c],
|
email: 'hostmaster.eestiinternet.ee',
|
||||||
tech_contacts: [c],
|
master_nameserver: 'ns.tld.ee',
|
||||||
registrar: eis
|
ns_records: ns_records,
|
||||||
)
|
a_records: a_records,
|
||||||
|
a4_records: a4_records
|
||||||
|
})
|
||||||
|
|
||||||
# pri.ee
|
# pri.ee
|
||||||
ns_list = []
|
ns_records, a_records, a4_records = parse_zone_ns_data(2)
|
||||||
Legacy::ZoneNs.where(zone: 2).each do |x|
|
|
||||||
ipv4 = x.addrs.select { |addr| addr.ipv4? }.first
|
|
||||||
ipv6 = x.addrs.select { |addr| addr.ipv6? }.first
|
|
||||||
ns_list << Nameserver.new(hostname: x.fqdn, ipv4: ipv4, ipv6: ipv6)
|
|
||||||
end
|
|
||||||
|
|
||||||
Domain.create!(
|
ZonefileSetting.create!({
|
||||||
name: 'pri.ee',
|
origin: 'pri.ee',
|
||||||
valid_to: Date.new(9999, 1, 1),
|
ttl: 43200,
|
||||||
period: 1,
|
refresh: 3600,
|
||||||
period_unit: 'y',
|
retry: 900,
|
||||||
registrant: c,
|
expire: 1209600,
|
||||||
nameservers: ns_list,
|
minimum_ttl: 3600,
|
||||||
admin_contacts: [c],
|
email: 'hostmaster.eestiinternet.ee',
|
||||||
tech_contacts: [c],
|
master_nameserver: 'ns.tld.ee',
|
||||||
registrar: eis
|
ns_records: ns_records,
|
||||||
)
|
a_records: a_records,
|
||||||
|
a4_records: a4_records
|
||||||
|
})
|
||||||
|
|
||||||
# med.ee
|
# med.ee
|
||||||
ns_list = []
|
ns_records, a_records, a4_records = parse_zone_ns_data(3)
|
||||||
Legacy::ZoneNs.where(zone: 3).each do |x|
|
|
||||||
ipv4 = x.addrs.select { |addr| addr.ipv4? }.first
|
|
||||||
ipv6 = x.addrs.select { |addr| addr.ipv6? }.first
|
|
||||||
ns_list << Nameserver.new(hostname: x.fqdn, ipv4: ipv4, ipv6: ipv6)
|
|
||||||
end
|
|
||||||
|
|
||||||
Domain.create!(
|
ZonefileSetting.create!({
|
||||||
name: 'med.ee',
|
origin: 'med.ee',
|
||||||
valid_to: Date.new(9999, 1, 1),
|
ttl: 43200,
|
||||||
period: 1,
|
refresh: 3600,
|
||||||
period_unit: 'y',
|
retry: 900,
|
||||||
registrant: c,
|
expire: 1209600,
|
||||||
nameservers: ns_list,
|
minimum_ttl: 3600,
|
||||||
admin_contacts: [c],
|
email: 'hostmaster.eestiinternet.ee',
|
||||||
tech_contacts: [c],
|
master_nameserver: 'ns.tld.ee',
|
||||||
registrar: eis
|
ns_records: ns_records,
|
||||||
)
|
a_records: a_records,
|
||||||
|
a4_records: a4_records
|
||||||
|
})
|
||||||
|
|
||||||
# fie.ee
|
# fie.ee
|
||||||
ns_list = []
|
ns_records, a_records, a4_records = parse_zone_ns_data(4)
|
||||||
Legacy::ZoneNs.where(zone: 4).each do |x|
|
|
||||||
ipv4 = x.addrs.select { |addr| addr.ipv4? }.first
|
|
||||||
ipv6 = x.addrs.select { |addr| addr.ipv6? }.first
|
|
||||||
ns_list << Nameserver.new(hostname: x.fqdn, ipv4: ipv4, ipv6: ipv6)
|
|
||||||
end
|
|
||||||
|
|
||||||
Domain.create!(
|
ZonefileSetting.create!({
|
||||||
name: 'fie.ee',
|
origin: 'fie.ee',
|
||||||
valid_to: Date.new(9999, 1, 1),
|
ttl: 43200,
|
||||||
period: 1,
|
refresh: 3600,
|
||||||
period_unit: 'y',
|
retry: 900,
|
||||||
registrant: c,
|
expire: 1209600,
|
||||||
nameservers: ns_list,
|
minimum_ttl: 3600,
|
||||||
admin_contacts: [c],
|
email: 'hostmaster.eestiinternet.ee',
|
||||||
tech_contacts: [c],
|
master_nameserver: 'ns.tld.ee',
|
||||||
registrar: eis
|
ns_records: ns_records,
|
||||||
)
|
a_records: a_records,
|
||||||
|
a4_records: a4_records
|
||||||
|
})
|
||||||
|
|
||||||
# com.ee
|
# com.ee
|
||||||
ns_list = []
|
ns_records, a_records, a4_records = parse_zone_ns_data(5)
|
||||||
Legacy::ZoneNs.where(zone: 5).each do |x|
|
|
||||||
ipv4 = x.addrs.select { |addr| addr.ipv4? }.first
|
|
||||||
ipv6 = x.addrs.select { |addr| addr.ipv6? }.first
|
|
||||||
ns_list << Nameserver.new(hostname: x.fqdn, ipv4: ipv4, ipv6: ipv6)
|
|
||||||
end
|
|
||||||
|
|
||||||
Domain.create!(
|
ZonefileSetting.create!({
|
||||||
name: 'com.ee',
|
origin: 'com.ee',
|
||||||
valid_to: Date.new(9999, 1, 1),
|
ttl: 43200,
|
||||||
period: 1,
|
refresh: 3600,
|
||||||
period_unit: 'y',
|
retry: 900,
|
||||||
registrant: c,
|
expire: 1209600,
|
||||||
nameservers: ns_list,
|
minimum_ttl: 3600,
|
||||||
admin_contacts: [c],
|
email: 'hostmaster.eestiinternet.ee',
|
||||||
tech_contacts: [c],
|
master_nameserver: 'ns.tld.ee',
|
||||||
registrar: eis
|
ns_records: ns_records,
|
||||||
)
|
a_records: a_records,
|
||||||
|
a4_records: a4_records
|
||||||
|
})
|
||||||
|
|
||||||
# gov.ee
|
# gov.ee
|
||||||
ns_list = []
|
ns_records, a_records, a4_records = parse_zone_ns_data(7)
|
||||||
Legacy::ZoneNs.where(zone: 7).each do |x|
|
|
||||||
ipv4 = x.addrs.select { |addr| addr.ipv4? }.first
|
|
||||||
ipv6 = x.addrs.select { |addr| addr.ipv6? }.first
|
|
||||||
ns_list << Nameserver.new(hostname: x.fqdn, ipv4: ipv4, ipv6: ipv6)
|
|
||||||
end
|
|
||||||
|
|
||||||
Domain.create!(
|
ZonefileSetting.create!({
|
||||||
name: 'gov.ee',
|
origin: 'gov.ee',
|
||||||
valid_to: Date.new(9999, 1, 1),
|
ttl: 43200,
|
||||||
period: 1,
|
refresh: 3600,
|
||||||
period_unit: 'y',
|
retry: 900,
|
||||||
registrant: c,
|
expire: 1209600,
|
||||||
nameservers: ns_list,
|
minimum_ttl: 3600,
|
||||||
admin_contacts: [c],
|
email: 'hostmaster.eestiinternet.ee',
|
||||||
tech_contacts: [c],
|
master_nameserver: 'ns.tld.ee',
|
||||||
registrar: eis
|
ns_records: ns_records,
|
||||||
)
|
a_records: a_records,
|
||||||
|
a4_records: a4_records
|
||||||
|
})
|
||||||
|
|
||||||
# riik.ee
|
# riik.ee
|
||||||
ns_list = []
|
ns_records, a_records, a4_records = parse_zone_ns_data(8)
|
||||||
Legacy::ZoneNs.where(zone: 8).each do |x|
|
|
||||||
|
ZonefileSetting.create!({
|
||||||
|
origin: 'riik.ee',
|
||||||
|
ttl: 43200,
|
||||||
|
refresh: 3600,
|
||||||
|
retry: 900,
|
||||||
|
expire: 1209600,
|
||||||
|
minimum_ttl: 3600,
|
||||||
|
email: 'hostmaster.eestiinternet.ee',
|
||||||
|
master_nameserver: 'ns.tld.ee',
|
||||||
|
ns_records: ns_records,
|
||||||
|
a_records: a_records,
|
||||||
|
a4_records: a4_records
|
||||||
|
})
|
||||||
|
|
||||||
|
puts "-----> Imported zones in #{(Time.zone.now.to_f - start).round(2)} seconds"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def parse_zone_ns_data(zone)
|
||||||
|
ns_records = ''
|
||||||
|
a_records = ''
|
||||||
|
a4_records = ''
|
||||||
|
Legacy::ZoneNs.where(zone: zone).each do |x|
|
||||||
ipv4 = x.addrs.select { |addr| addr.ipv4? }.first
|
ipv4 = x.addrs.select { |addr| addr.ipv4? }.first
|
||||||
ipv6 = x.addrs.select { |addr| addr.ipv6? }.first
|
ipv6 = x.addrs.select { |addr| addr.ipv6? }.first
|
||||||
ns_list << Nameserver.new(hostname: x.fqdn, ipv4: ipv4, ipv6: ipv6)
|
|
||||||
end
|
|
||||||
|
|
||||||
Domain.create!(
|
ns_records += "ee. IN NS #{x.fqdn}.\n"
|
||||||
name: 'riik.ee',
|
a_records += "#{x.fqdn}. IN A #{ipv4}\n" if ipv4.present?
|
||||||
valid_to: Date.new(9999, 1, 1),
|
a4_records += "#{x.fqdn}. IN AAAA #{ipv6}\n" if ipv6.present?
|
||||||
period: 1,
|
|
||||||
period_unit: 'y',
|
|
||||||
registrant: c,
|
|
||||||
nameservers: ns_list,
|
|
||||||
admin_contacts: [c],
|
|
||||||
tech_contacts: [c],
|
|
||||||
registrar: eis
|
|
||||||
)
|
|
||||||
|
|
||||||
puts "-----> Imported EIS domains in #{(Time.zone.now.to_f - start).round(2)} seconds"
|
|
||||||
end
|
end
|
||||||
|
[ns_records.strip, a_records.strip, a4_records.strip]
|
||||||
end
|
end
|
||||||
# rubocop: enable Performance/Detect
|
# rubocop: enable Performance/Detect
|
||||||
# rubocop: enable Style/SymbolProc
|
# rubocop: enable Style/SymbolProc
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue