NSX|V remove async calls to backend
Removing most of the backed calls that used async=true, because when the backend is overloaded those calls are sometimes dropped. Currently the only call that can still be async is deploy-edge. Change-Id: Icffb651a32bc37759eb45abd564e86bc363ad38c
This commit is contained in:
parent
d528f56b3e
commit
c48ecd9539
@ -73,7 +73,7 @@ class RouterExclusiveDriver(router_driver.RouterBaseDriver):
|
||||
edge_cfg = self.vcns.get_edge(edge_id)[1]
|
||||
if edge_cfg.get('appliances'):
|
||||
edge_cfg['appliances']['applianceSize'] = r['router_size']
|
||||
self.vcns.update_edge(edge_id, edge_cfg, async=False)
|
||||
self.vcns.update_edge(edge_id, edge_cfg)
|
||||
nsxv_db.update_nsxv_router_binding(
|
||||
context.session, router_id,
|
||||
appliance_size=r['router_size'])
|
||||
|
@ -622,9 +622,7 @@ class NsxVMetadataProxyHandler(object):
|
||||
virt_srvr.set_default_pool(pool)
|
||||
lb_obj.add_virtual_server(virt_srvr)
|
||||
|
||||
lb_obj.submit_to_backend(
|
||||
self.nsxv_plugin.nsx_v.vcns,
|
||||
edge_id, async=False)
|
||||
lb_obj.submit_to_backend(self.nsxv_plugin.nsx_v.vcns, edge_id)
|
||||
|
||||
def configure_router_edge(self, rtr_id, context=None):
|
||||
# Connect router interface to inter-edge network
|
||||
|
@ -869,37 +869,21 @@ class EdgeApplianceDriver(object):
|
||||
"service config"))
|
||||
|
||||
def _delete_port_group(self, task):
|
||||
try:
|
||||
header, response = self.vcns.get_edge_id(task.userdata['job_id'])
|
||||
except exceptions.VcnsApiException:
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.error(_LE("NSXv: Failed to get job for %s"),
|
||||
task.userdata)
|
||||
status = response['status']
|
||||
if status != 'COMPLETED':
|
||||
if (status == 'QUEUED' or status == 'RUNNING' or
|
||||
status == 'ROLLBACK'):
|
||||
LOG.debug("NSXv: job is still pending for %s", task.userdata)
|
||||
return task_constants.TaskStatus.PENDING
|
||||
try:
|
||||
self.vcns.delete_port_group(
|
||||
task.userdata['dvs_id'],
|
||||
task.userdata['port_group_id'])
|
||||
except Exception as e:
|
||||
LOG.error(_LE('Unable to delete %(pg)s (job status %(state)s) '
|
||||
'exception %(ex)s'),
|
||||
LOG.error(_LE('Unable to delete %(pg)s exception %(ex)s'),
|
||||
{'pg': task.userdata['port_group_id'],
|
||||
'state': status,
|
||||
'ex': e})
|
||||
if status == 'FAILED':
|
||||
return task_constants.TaskStatus.ERROR
|
||||
return task_constants.TaskStatus.COMPLETED
|
||||
|
||||
def delete_portgroup(self, dvs_id, port_group_id, job_id):
|
||||
def delete_portgroup(self, dvs_id, port_group_id):
|
||||
task_name = "delete-port-group-%s" % port_group_id
|
||||
userdata = {'dvs_id': dvs_id,
|
||||
'port_group_id': port_group_id,
|
||||
'job_id': job_id}
|
||||
'port_group_id': port_group_id}
|
||||
task = tasks.Task(task_name, port_group_id,
|
||||
self._delete_port_group,
|
||||
status_callback=self._delete_port_group,
|
||||
|
@ -439,13 +439,10 @@ class EdgeManager(object):
|
||||
header, _ = self.nsxv_manager.vcns.delete_interface(edge_id,
|
||||
vnic_index)
|
||||
if port_group_id:
|
||||
objuri = header['location']
|
||||
job_id = objuri[objuri.rfind("/") + 1:]
|
||||
dvs_id, net_type = self._get_physical_provider_network(
|
||||
context, network_id)
|
||||
self.nsxv_manager.delete_portgroup(dvs_id,
|
||||
port_group_id,
|
||||
job_id)
|
||||
port_group_id)
|
||||
else:
|
||||
self.nsxv_manager.vcns.update_interface(edge_id, vnic_config)
|
||||
except nsxapi_exc.VcnsApiException:
|
||||
|
@ -48,14 +48,11 @@ class NsxvEdgeCfgObj(object):
|
||||
|
||||
return v
|
||||
|
||||
def submit_to_backend(self, vcns_obj, edge_id, async=True):
|
||||
def submit_to_backend(self, vcns_obj, edge_id):
|
||||
uri = "%s/%s/%s/config" % (vcns.URI_PREFIX,
|
||||
edge_id,
|
||||
self.get_service_name())
|
||||
|
||||
if async:
|
||||
uri += '?async=true'
|
||||
|
||||
payload = jsonutils.dumps(self.serializable_payload(), sort_keys=True)
|
||||
|
||||
if payload:
|
||||
|
@ -148,10 +148,8 @@ class Vcns(object):
|
||||
uri += "?async=true"
|
||||
return self.do_request(HTTP_POST, uri, request, decode=False)
|
||||
|
||||
def update_edge(self, edge_id, request, async=False):
|
||||
def update_edge(self, edge_id, request):
|
||||
uri = "%s/%s" % (URI_PREFIX, edge_id)
|
||||
if async:
|
||||
uri += "?async=true"
|
||||
return self.do_request(HTTP_PUT, uri, request, decode=False)
|
||||
|
||||
def get_edge_id(self, job_id):
|
||||
@ -199,7 +197,7 @@ class Vcns(object):
|
||||
return self.do_request(HTTP_PUT, uri, vnic, decode=True)
|
||||
|
||||
def delete_interface(self, edge_id, vnic_index):
|
||||
uri = "%s/%s/vnics/%d?async=true" % (URI_PREFIX, edge_id, vnic_index)
|
||||
uri = "%s/%s/vnics/%d" % (URI_PREFIX, edge_id, vnic_index)
|
||||
return self.do_request(HTTP_DELETE, uri, decode=True)
|
||||
|
||||
def get_nat_config(self, edge_id):
|
||||
@ -207,7 +205,7 @@ class Vcns(object):
|
||||
return self.do_request(HTTP_GET, uri, decode=True)
|
||||
|
||||
def update_nat_config(self, edge_id, nat):
|
||||
uri = "%s/%s/nat/config?async=true" % (URI_PREFIX, edge_id)
|
||||
uri = "%s/%s/nat/config" % (URI_PREFIX, edge_id)
|
||||
return self.do_request(HTTP_PUT, uri, nat, decode=True)
|
||||
|
||||
def delete_nat_rule(self, edge_id, rule_id):
|
||||
@ -261,13 +259,11 @@ class Vcns(object):
|
||||
def update_firewall(self, edge_id, fw_req):
|
||||
uri = self._build_uri_path(
|
||||
edge_id, FIREWALL_SERVICE)
|
||||
uri += '?async=true'
|
||||
return self.do_request(HTTP_PUT, uri, fw_req)
|
||||
|
||||
def delete_firewall(self, edge_id):
|
||||
uri = self._build_uri_path(
|
||||
edge_id, FIREWALL_SERVICE, None)
|
||||
uri += '?async=true'
|
||||
return self.do_request(HTTP_DELETE, uri)
|
||||
|
||||
def update_firewall_rule(self, edge_id, vcns_rule_id, fwr_req):
|
||||
@ -908,11 +904,9 @@ class Vcns(object):
|
||||
return self.do_request(HTTP_PUT, uri, et.tostring(tuning),
|
||||
format='xml', decode=True)
|
||||
|
||||
def enable_ha(self, edge_id, request_config, async=True):
|
||||
def enable_ha(self, edge_id, request_config):
|
||||
"""Enable HA in the given edge."""
|
||||
uri = "/api/4.0/edges/%s/highavailability/config" % edge_id
|
||||
if async:
|
||||
uri += "?async=true"
|
||||
return self.do_request(HTTP_PUT, uri, request_config)
|
||||
|
||||
def change_edge_appliance_size(self, edge_id, size):
|
||||
|
@ -164,7 +164,7 @@ def change_edge_ha(ha, edge_id):
|
||||
'featureType': 'highavailability_4.0',
|
||||
'enabled': ha}
|
||||
try:
|
||||
nsxv.enable_ha(edge_id, request, async=False)
|
||||
nsxv.enable_ha(edge_id, request)
|
||||
except nsxv_exceptions.ResourceNotFound as e:
|
||||
LOG.error(_LE("Edge %s not found"), edge_id)
|
||||
except exceptions.NeutronException as e:
|
||||
|
@ -106,7 +106,7 @@ def nsx_redo_metadata_cfg(resource, event, trigger, **kwargs):
|
||||
monitor_port=s_port)
|
||||
pool.add_member(member)
|
||||
|
||||
lb.submit_to_backend(nsxv, edge_id, False)
|
||||
lb.submit_to_backend(nsxv, edge_id)
|
||||
|
||||
|
||||
@admin_utils.output_header
|
||||
@ -142,7 +142,7 @@ def update_shared_secret(resource, event, trigger, **kwargs):
|
||||
sign_app_rule = nsxv_lb.NsxvLBAppRule('insert-auth', sign)
|
||||
virt.add_app_rule('insert-auth', sign_app_rule)
|
||||
|
||||
lb.submit_to_backend(nsxv, edge_id, False)
|
||||
lb.submit_to_backend(nsxv, edge_id)
|
||||
|
||||
|
||||
def _md_member_status(title, edge_ids):
|
||||
|
@ -67,7 +67,7 @@ class NsxvLoadbalancerTestCase(base.BaseTestCase):
|
||||
'"169.254.0.3", "name": "MdSrv", "port": "8775", "protocol": '
|
||||
'"http", "virtualServerId": "virtualServer-1"}]}')
|
||||
|
||||
LB_URI = '/api/4.0/edges/%s/loadbalancer/config?async=true'
|
||||
LB_URI = '/api/4.0/edges/%s/loadbalancer/config'
|
||||
EDGE_1 = 'edge-x'
|
||||
EDGE_2 = 'edge-y'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user