summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfujinhua <fu.jinhua@zte.com.cn>2018-11-23 20:52:36 +0800
committerFu Jinhua <fu.jinhua@zte.com.cn>2018-11-24 01:49:43 +0000
commit83fd23578ce2b5accee89a7cd6441c8e37b88f59 (patch)
tree79551888afdd99b8be6bfa1cc4f519d54125df0e
parent34a773827e5a6ba01d115093f00da05fecb6e573 (diff)
Add lock for create net and subnet
Change-Id: I09f08261bf333570bcc9780d07c580533555e30d Issue-ID: VFC-1163 Signed-off-by: fujinhua <fu.jinhua@zte.com.cn> (cherry picked from commit bcfaf700e2b64f20eb1dadb6b78473a76ea2bd80)
-rw-r--r--lcm/lcm/pub/vimapi/api.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/lcm/lcm/pub/vimapi/api.py b/lcm/lcm/pub/vimapi/api.py
index 2ceb82d0..1679a564 100644
--- a/lcm/lcm/pub/vimapi/api.py
+++ b/lcm/lcm/pub/vimapi/api.py
@@ -13,12 +13,15 @@
# limitations under the License.
import json
+from multiprocessing import Lock
from lcm.pub.msapi.aai import delete_aai_flavor
from lcm.pub.utils.restcall import req_by_msb
from .exceptions import VimException
VIM_DRIVER_BASE_URL = "api/multicloud/v0"
+MUTEX_NET = Lock()
+MUTEX_SUBNET = Lock()
def call(vim_id, tenant_id, res, method, data=''):
@@ -56,7 +59,8 @@ def list_image(vim_id, tenant_id):
def create_network(vim_id, tenant_id, data):
- return call(vim_id, tenant_id, "networks", "POST", data)
+ with MUTEX_NET:
+ return call(vim_id, tenant_id, "networks", "POST", data)
def delete_network(vim_id, tenant_id, network_id):
@@ -74,7 +78,8 @@ def list_network(vim_id, tenant_id):
def create_subnet(vim_id, tenant_id, data):
- return call(vim_id, tenant_id, "subnets", "POST", data)
+ with MUTEX_SUBNET:
+ return call(vim_id, tenant_id, "subnets", "POST", data)
def delete_subnet(vim_id, tenant_id, subnet_id):