Catch exception when cleanup fails
Print an error message instead of a full traceback.
Exit with code 1.
Cherry-picked from: c2a55c005e
Change-Id: I6102d14d1b4552a76d0aa694f758f2750abe5328
This commit is contained in:
parent
99e8366a9a
commit
306ac5e2c6
|
@ -14,15 +14,14 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import optparse
|
import optparse
|
||||||
|
import sys
|
||||||
import sqlalchemy as sa
|
|
||||||
|
|
||||||
from neutron.db.models import l3
|
from neutron.db.models import l3
|
||||||
from neutron.db.models import securitygroup
|
from neutron.db.models import securitygroup
|
||||||
from neutron.db.models import segment # noqa
|
from neutron.db.models import segment # noqa
|
||||||
from neutron.db import models_v2
|
from neutron.db import models_v2
|
||||||
from neutron.db.qos import models as qos_models
|
from neutron.db.qos import models as qos_models
|
||||||
|
import sqlalchemy as sa
|
||||||
from vmware_nsx.db import nsx_models
|
from vmware_nsx.db import nsx_models
|
||||||
from vmware_nsxlib import v3
|
from vmware_nsxlib import v3
|
||||||
from vmware_nsxlib.v3 import config
|
from vmware_nsxlib.v3 import config
|
||||||
|
@ -590,8 +589,13 @@ if __name__ == "__main__":
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
# Get NSX REST client
|
# Get NSX REST client
|
||||||
nsx_client = NSXClient(options.policy_ip, options.username,
|
try:
|
||||||
options.password, options.db_connection,
|
nsx_client = NSXClient(options.policy_ip, options.username,
|
||||||
options.allow_passthrough)
|
options.password, options.db_connection,
|
||||||
# Clean all objects created by OpenStack
|
options.allow_passthrough)
|
||||||
nsx_client.cleanup_all()
|
# Clean all objects created by OpenStack
|
||||||
|
nsx_client.cleanup_all()
|
||||||
|
except Exception as e:
|
||||||
|
print("Unable to cleanup NSX-T Policy resources due to: %s."
|
||||||
|
"Please retry." % e)
|
||||||
|
sys.exit(1)
|
||||||
|
|
Loading…
Reference in New Issue