Optimizing some logic in the code when creating pod

Bug #1691653 reported by zhangyanxian
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Tricircle
Fix Released
Medium
zhangyanxian

Bug Description

so many if branch for the az_name in pod.py as following:

  63 if az_name == '' and region_name == '':
  64 return Response(_('Valid region_name is required for top region'),
  65 422)
  66
  67 if az_name != '' and region_name == '':
  68 return Response(_('Valid region_name is required for pod'), 422)
  69
  70 if pod.get('az_name') is None:
  71 if self._get_top_region(context) != '':
  72 return Response(_('Top region already exists'), 409)
  73
  74 # if az_name is not null, then the pod region name should not
  75 # be same as that the top region
  76 if az_name != '':
  77 if (self._get_top_region(context) == region_name and
  78 region_name != ''):
  79 return Response(
  80 _('Pod region name duplicated with the top region name'),
  81 409)
  82
  83 # to create the top region, make the pod_az_name to null value
  84 if az_name == '':
  85 pod_az_name = ''

Maybe we can optimize them to keep the logic more clearly

Changed in tricircle:
assignee: nobody → zhangyanxian (zhang-yanxian)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to tricircle (master)

Fix proposed to branch: master
Review: https://review.openstack.org/465827

Changed in tricircle:
status: New → In Progress
Chaoyi Huang (joehuang)
Changed in tricircle:
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to tricircle (master)

Reviewed: https://review.openstack.org/465827
Committed: https://git.openstack.org/cgit/openstack/tricircle/commit/?id=62801d714b61bdea3f51c858ca0ff99ced00cb75
Submitter: Jenkins
Branch: master

commit 62801d714b61bdea3f51c858ca0ff99ced00cb75
Author: zhangyanxian <zhangyanxianmail@163.com>
Date: Thu May 18 06:16:05 2017 +0000

    Optimizing some logic in the code when creating pod

    1. What is the problem?
    There are so many if branches for az_name in pod.py,
    this will lead to confusion.

    2. What is the solution to the problem?
    We can optimize them to keep the logic more clearly

    3. What features need to be implemented to the Tricircle to realize
    the solution?
    None
    Closes-Bug: #1691653
    Change-Id: I1f31ff685de2e516d36027388a7b0eacc1a76f5e

Changed in tricircle:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/tricircle 3.3.0

This issue was fixed in the openstack/tricircle 3.3.0 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.