Fix warnings from code check utilites(shellcheck/flake8)

Change-Id: I7c3759639b3edca41860c1c47590237afa3e8092
This commit is contained in:
Artem Savinov 2016-04-26 11:15:42 +03:00
parent 1ff86077ac
commit 2940fc9aff
3 changed files with 28 additions and 14 deletions

View File

@ -1,23 +1,37 @@
#!/usr/bin/env python
"""
"""Copyright 2016 Mirantis, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may
not use this file except in compliance with the License. You may obtain
copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations
under the License.
Script adds restrictions to built-in roles, so they get hidden when plugin is
enabled for environment.
Get all releases in available state and list all roles in this release.
If role incompatible with NSXv then add restrictions(hide role if NSXv in
cluster:components list). If first argument for script exists, then delete all
restrictions, which NSXv component checks.
enabled for environment. Get all releases in available state and list all roles
in this release. If role incompatible with NSXv then add restrictions(hide role
if NSXv in cluster:components list). If first argument for script exists, then
delete all restrictions, which NSXv component checks.
"""
import sys
from fuelclient.objects.release import Release
from fuelclient.objects.role import Role
incompatible_roles = ["compute", "ironic", "cinder", "cinder-block-device"]
restrictions = {
u"condition": u"'network:neutron:core:nsx' in cluster:components", u"action": u"hide"}
u"condition": u"'network:neutron:core:nsx' in cluster:components",
u"action": u"hide"}
role_available_state = "available"
nsx_component_name = u"network:neutron:core:nsx"
clean_restrictions = True if (len(sys.argv) > 1) else False
clean = True if (len(sys.argv) > 1) else False
try:
for release in Release.get_all_data():
@ -28,15 +42,15 @@ try:
if "restrictions" in meta.keys():
for restriction in meta["restrictions"]:
if nsx_component_name in restriction["condition"]:
if len(meta["restrictions"]) == 1 and clean_restrictions:
if len(meta["restrictions"]) == 1 and clean:
del meta["restrictions"]
else:
meta["restrictions"].remove(restriction)
if not clean_restrictions:
if not clean:
meta["restrictions"].append(restrictions)
else:
if not clean_restrictions:
if not clean:
meta["restrictions"] = [restrictions]
Role.update(release["id"], role["name"], role)
except:
except Exception:
raise

View File

@ -1,2 +1,2 @@
#!/bin/bash
/usr/bin/python /var/www/nailgun/plugins/%{name}/deployment_scripts/disable_role.py
/usr/bin/python "/var/www/nailgun/plugins/%{name}/deployment_scripts/disable_role.py"

View File

@ -1,2 +1,2 @@
#!/bin/bash
/usr/bin/python /var/www/nailgun/plugins/%{name}/deployment_scripts/disable_role.py clean
/usr/bin/python "/var/www/nailgun/plugins/%{name}/deployment_scripts/disable_role.py" clean