Add create_network method in etcd db.

Add create_network method in etcd db. Now support two db types,
both etcd and sql for storing network.

Relatated bug: https://bugs.launchpad.net/zun/+bug/1777770

Change-Id: I6542a7889d0e355a5ddc394aa209db5e8dcc7ead
This commit is contained in:
caishan
2018-06-19 18:36:13 -07:00
parent ae18250d50
commit 864ec75a57

View File

@@ -1336,3 +1336,17 @@ class EtcdAPI(object):
except Exception as e:
LOG.error('Error occurred while retrieving quota usage: %s',
six.text_type(e))
@lockutils.synchronized('etcd_network')
def create_network(self, context, network_value):
if not network_value.get('uuid'):
network_value['uuid'] = uuidutils.generate_uuid()
if network_value.get('name'):
self._validate_unique_container_name(context,
network_value['name'])
network = models.Network(network_value)
try:
network.save()
except Exception:
raise
return network