~ubuntu-branches/ubuntu/raring/nova/raring-proposed

« back to all changes in this revision

Viewing changes to nova/network/ldapdns.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Adam Gandelman, Chuck Short
  • Date: 2012-11-23 09:04:58 UTC
  • mfrom: (1.1.66)
  • Revision ID: package-import@ubuntu.com-20121123090458-91565o7aev1i1h71
Tags: 2013.1~g1-0ubuntu1
[ Adam Gandelman ]
* debian/control: Ensure novaclient is upgraded with nova,
  require python-keystoneclient >= 1:2.9.0. (LP: #1073289)
* debian/patches/{ubuntu/*, rbd-security.patch}: Dropped, applied
  upstream.
* debian/control: Add python-testtools to Build-Depends.

[ Chuck Short ]
* New upstream version.
* Refreshed debian/patches/avoid_setuptools_git_dependency.patch.
* debian/rules: FTBFS if missing binaries.
* debian/nova-scheudler.install: Add missing rabbit-queues and
  nova-rpc-zmq-receiver.
* Remove nova-volume since it doesnt exist anymore, transition to cinder-*.
* debian/rules: install apport hook in the right place.
* debian/patches/ubuntu-show-tests.patch: Display test failures.
* debian/control: Add depends on genisoimage
* debian/control: Suggest guestmount.
* debian/control: Suggest websockify. (LP: #1076442)
* debian/nova.conf: Disable nova-volume service.
* debian/control: Depend on xen-system-* rather than the hypervisor.
* debian/control, debian/mans/nova-conductor.8, debian/nova-conductor.init,
  debian/nova-conductor.install, debian/nova-conductor.logrotate
  debian/nova-conductor.manpages, debian/nova-conductor.postrm
  debian/nova-conductor.upstart.in: Add nova-conductor service.
* debian/control: Add python-fixtures as a build deps.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
import ldap
16
16
import time
17
17
 
18
 
from nova.auth import fakeldap
19
18
from nova import exception
20
 
from nova import flags
21
19
from nova.openstack.common import cfg
22
20
from nova.openstack.common import log as logging
23
21
from nova import utils
24
22
 
25
 
 
 
23
CONF = cfg.CONF
26
24
LOG = logging.getLogger(__name__)
27
25
 
28
26
ldap_dns_opts = [
62
60
                    'Statement of Authority'),
63
61
    ]
64
62
 
65
 
flags.FLAGS.register_opts(ldap_dns_opts)
 
63
CONF.register_opts(ldap_dns_opts)
66
64
 
67
65
 
68
66
# Importing ldap.modlist breaks the tests for some reason,
91
89
 
92
90
    @classmethod
93
91
    def _get_tuple_for_domain(cls, lobj, domain):
94
 
        entry = lobj.search_s(flags.FLAGS.ldap_dns_base_dn, ldap.SCOPE_SUBTREE,
 
92
        entry = lobj.search_s(CONF.ldap_dns_base_dn, ldap.SCOPE_SUBTREE,
95
93
                              '(associatedDomain=%s)' % utils.utf8(domain))
96
94
        if not entry:
97
95
            return None
102
100
 
103
101
    @classmethod
104
102
    def _get_all_domains(cls, lobj):
105
 
        entries = lobj.search_s(flags.FLAGS.ldap_dns_base_dn,
 
103
        entries = lobj.search_s(CONF.ldap_dns_base_dn,
106
104
                                ldap.SCOPE_SUBTREE, '(sOARecord=*)')
107
105
        domains = []
108
106
        for entry in entries:
143
141
    def _soa(cls):
144
142
        date = time.strftime('%Y%m%d%H%M%S')
145
143
        soa = '%s %s %s %s %s %s %s' % (
146
 
                 flags.FLAGS.ldap_dns_servers[0],
147
 
                 flags.FLAGS.ldap_dns_soa_hostmaster,
 
144
                 CONF.ldap_dns_servers[0],
 
145
                 CONF.ldap_dns_soa_hostmaster,
148
146
                 date,
149
 
                 flags.FLAGS.ldap_dns_soa_refresh,
150
 
                 flags.FLAGS.ldap_dns_soa_retry,
151
 
                 flags.FLAGS.ldap_dns_soa_expiry,
152
 
                 flags.FLAGS.ldap_dns_soa_minimum)
 
147
                 CONF.ldap_dns_soa_refresh,
 
148
                 CONF.ldap_dns_soa_retry,
 
149
                 CONF.ldap_dns_soa_expiry,
 
150
                 CONF.ldap_dns_soa_minimum)
153
151
        return utils.utf8(soa)
154
152
 
155
153
    @classmethod
159
157
        if entry:
160
158
            raise exception.FloatingIpDNSExists(name=domain, domain='')
161
159
 
162
 
        newdn = 'dc=%s,%s' % (domain, flags.FLAGS.ldap_dns_base_dn)
 
160
        newdn = 'dc=%s,%s' % (domain, CONF.ldap_dns_base_dn)
163
161
        attrs = {'objectClass': ['domainrelatedobject', 'dnsdomain',
164
162
                                 'domain', 'dcobject', 'top'],
165
163
                 'sOARecord': [cls._soa()],
306
304
       in the top-level, aRecords only."""
307
305
 
308
306
    def __init__(self):
309
 
        self.lobj = ldap.initialize(flags.FLAGS.ldap_dns_url)
310
 
        self.lobj.simple_bind_s(flags.FLAGS.ldap_dns_user,
311
 
                                flags.FLAGS.ldap_dns_password)
 
307
        self.lobj = ldap.initialize(CONF.ldap_dns_url)
 
308
        self.lobj.simple_bind_s(CONF.ldap_dns_user,
 
309
                                CONF.ldap_dns_password)
312
310
 
313
311
    def get_domains(self):
314
312
        return DomainEntry._get_all_domains(self.lobj)
360
358
    def delete_dns_file(self):
361
359
        LOG.warn("This shouldn't be getting called except during testing.")
362
360
        pass
363
 
 
364
 
 
365
 
class FakeLdapDNS(LdapDNS):
366
 
    """For testing purposes, a DNS driver backed with a fake ldap driver."""
367
 
    def __init__(self):
368
 
        self.lobj = fakeldap.FakeLDAP()
369
 
        attrs = {'objectClass': ['domainrelatedobject', 'dnsdomain',
370
 
                                 'domain', 'dcobject', 'top'],
371
 
                 'associateddomain': ['root'],
372
 
                 'dc': ['root']}
373
 
        self.lobj.add_s(flags.FLAGS.ldap_dns_base_dn, create_modlist(attrs))