Add db.dnsdomain_get_all() method
Add a dnsdomain_get_all() method to the db API. This method returns the full model for each dnsdomain in the database. There is a method similar to this, dnsdomain_list(), but it doesn't return all of the data, just one column from each of the rows. That doesn't really map well to objects, so make a new method that will be used by the DNSDomainList object. Part of blueprint nova-network-objects Change-Id: I8753cf1e641a1a6040a32a9a43e8b29f2d32182f
This commit is contained in:
parent
e5ceb08b8a
commit
8412c53c50
@ -397,6 +397,11 @@ def dnsdomain_list(context):
|
||||
return IMPL.dnsdomain_list(context)
|
||||
|
||||
|
||||
def dnsdomain_get_all(context):
|
||||
"""Get a list of all dnsdomains in our database."""
|
||||
return IMPL.dnsdomain_get_all(context)
|
||||
|
||||
|
||||
def dnsdomain_register_for_zone(context, fqdomain, zone):
|
||||
"""Associated a DNS domain with an availability zone."""
|
||||
return IMPL.dnsdomain_register_for_zone(context, fqdomain, zone)
|
||||
|
@ -1103,6 +1103,10 @@ def dnsdomain_list(context):
|
||||
return [row.domain for row in query.all()]
|
||||
|
||||
|
||||
def dnsdomain_get_all(context):
|
||||
return model_query(context, models.DNSDomain, read_deleted="no").all()
|
||||
|
||||
|
||||
###################
|
||||
|
||||
|
||||
|
@ -6074,6 +6074,14 @@ class DnsdomainTestCase(test.TestCase):
|
||||
domain = db.dnsdomain_get(self.ctxt, self.domain)
|
||||
self.assertIsNone(domain)
|
||||
|
||||
def test_dnsdomain_get_all(self):
|
||||
d_list = ['test.domain.one', 'test.domain.two']
|
||||
db.dnsdomain_register_for_zone(self.ctxt, d_list[0], 'zone')
|
||||
db.dnsdomain_register_for_zone(self.ctxt, d_list[1], 'zone')
|
||||
db_list = db.dnsdomain_get_all(self.ctxt)
|
||||
db_domain_list = [d.domain for d in db_list]
|
||||
self.assertEqual(sorted(d_list), sorted(db_domain_list))
|
||||
|
||||
|
||||
class BwUsageTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user