Changing rsdns_records table name to be rax independent.

This commit is contained in:
Sudarshan Acharya 2012-05-25 10:50:59 -05:00
parent 0c34c75dc4
commit ad6b8c3c5e
7 changed files with 27 additions and 15 deletions

View File

@ -51,6 +51,16 @@ mount_point = /var/lib/mysql
# Reddwarf DNS
reddwarf_dns_support = False
#dns_driver=reddwarf.dns.rsdns.driver.RsDnsDriver
#dns_instance_entry_factory=reddwarf.dns.rsdns.driver.RsDnsInstanceEntryFactory
#dns_account_id=0
#dns_domain_id=0
#dns_username=username
#dns_passkey=passkey
#dns_domain_name=test.domain-test.com
#dns_management_base_url=
#dns_auth_url=
#dns_ttl=300
# ============ notifer queue kombu connection options ========================

View File

@ -34,8 +34,8 @@ def map(engine, models):
Table('service_images', meta, autoload=True))
orm.mapper(models['service_statuses'],
Table('service_statuses', meta, autoload=True))
orm.mapper(models['rsdns_records'],
Table('rsdns_records', meta, autoload=True))
orm.mapper(models['dns_records'],
Table('dns_records', meta, autoload=True))
def mapping_exists(model):

View File

@ -29,16 +29,16 @@ from reddwarf.db.sqlalchemy.migrate_repo.schema import String
meta = MetaData()
rsdns_records = Table('rsdns_records', meta,
dns_records = Table('dns_records', meta,
Column('name', String(length=255), primary_key=True),
Column('record_id', String(length=64)))
def upgrade(migrate_engine):
meta.bind = migrate_engine
create_tables([rsdns_records])
create_tables([dns_records])
def downgrade(migrate_engine):
meta.bind = migrate_engine
drop_tables([rsdns_records])
drop_tables([dns_records])

View File

@ -40,7 +40,7 @@ def configure_db(options, models_mapper=None):
models_mapper.map(_ENGINE)
else:
from reddwarf.instance import models as base_models
from reddwarf.dns.rsdns import models as dns_models
from reddwarf.dns import models as dns_models
from reddwarf.extensions.mysql import models as mysql_models
model_modules = [

View File

@ -22,7 +22,6 @@ import logging
from reddwarf.common import utils
from reddwarf.common import config
from reddwarf.dns.rsdns.driver import RsDnsInstanceEntryFactory
LOG = logging.getLogger(__name__)

View File

@ -31,14 +31,14 @@ LOG = logging.getLogger(__name__)
def persisted_models():
return {
'rsdns_records': RsDnsRecord,
'dns_records': DnsRecord,
}
class RsDnsRecord(ModelBase):
class DnsRecord(ModelBase):
_data_fields = ['name', 'record_id']
_table_name = 'rsdns_records'
_table_name = 'dns_records'
def __init__(self, name, record_id):
self.name = name

View File

@ -19,13 +19,15 @@
Dns Driver that uses Rackspace DNSaaS.
"""
__version__ = '2.4'
import hashlib
import logging
from reddwarf.common import config
from reddwarf.common import exception
from reddwarf.common.exception import NotFound
from reddwarf.dns.rsdns.models import RsDnsRecord
from reddwarf.dns.models import DnsRecord
from rsdns.client import DNSaas
from rsdns.client.future import RsDnsError
@ -127,16 +129,17 @@ class RsDnsDriver(object):
try:
#poll_until(lambda : future.ready, sleep_time=2,
# time_out=60*2)
while(future.ready is None):
while(future.ready is False):
import time
time.sleep(2)
LOG.info("Waiting for the dns record_id.. ")
if len(future.resource) < 1:
raise RsDnsError("No DNS records were created.")
elif len(future.resource) > 1:
LOG.error("More than one DNS record created. Ignoring.")
actual_record = future.resource[0]
RsDnsRecord.create(name=name, record_id=actual_record.id)
DnsRecord.create(name=name, record_id=actual_record.id)
LOG.debug("Added RS DNS entry.")
except RsDnsError as rde:
LOG.error("An error occurred creating DNS entry!")
@ -148,9 +151,9 @@ class RsDnsDriver(object):
def delete_entry(self, name, type, dns_zone=None):
dns_zone = dns_zone or self.default_dns_zone
long_name = name
db_record = RsDnsRecord.find_by(name=name)
db_record = DnsRecord.find_by(name=name)
record = self.dns_client.records.get(domain_id=dns_zone.id,
record_id=db_record.id)
record_id=db_record.record_id)
if record.name != name or record.type != 'A':
LOG.error("Tried to delete DNS record with name=%s, id=%s, but the"
" database returned a DNS record with the name %s and "