Fix lp:861160 -- newly created network has no uuid

Implemented code review changes.
Fixed issue causing pep8 build failure.
Change-Id: If2cc0e23be8d4e1558a10fa86e6ba4cdec61b7d1
This commit is contained in:
Unmesh Gurjar 2011-10-19 14:44:01 +05:30
parent 5b8133a839
commit bef4ae5092
3 changed files with 11 additions and 0 deletions
Authors
nova
db/sqlalchemy
tests

@ -122,6 +122,7 @@ Todd Willey <todd@ansolabs.com>
Trey Morris <trey.morris@rackspace.com>
Troy Toman <troy.toman@rackspace.com>
Tushar Patil <tushar.vitthal.patil@gmail.com>
Unmesh Gurjar <unmesh.gurjar@vertex.co.in>
Vasiliy Shlykov <vash@vasiliyshlykov.org>
Vishvananda Ishaya <vishvananda@gmail.com>
Vivek Y S <vivek.ys@gmail.com>

@ -1792,6 +1792,7 @@ def network_count_reserved_ips(context, network_id):
@require_admin_context
def network_create_safe(context, values):
network_ref = models.Network()
network_ref['uuid'] = str(utils.gen_uuid())
network_ref.update(values)
try:
network_ref.save()

@ -147,3 +147,12 @@ class DbApiTestCase(test.TestCase):
results = db.instance_get_all_hung_in_rebooting(ctxt, 10)
self.assertEqual(0, len(results))
db.instance_update(ctxt, instance.id, {"task_state": None})
def test_network_create_safe(self):
ctxt = context.get_admin_context()
values = {'host': 'localhost', 'project_id': 'project1'}
network = db.network_create_safe(ctxt, values)
self.assertNotEqual(None, network.uuid)
self.assertEqual(36, len(network.uuid))
db_network = db.network_get(ctxt, network.id)
self.assertEqual(network.uuid, db_network.uuid)