Repair Flake8's warnings & errors 07/24307/2
authorKingPoo <haojingbo@huawei.com>
Mon, 14 Nov 2016 07:16:24 +0000 (02:16 -0500)
committerJustin chi <chigang@huawei.com>
Tue, 15 Nov 2016 03:20:08 +0000 (03:20 +0000)
Change-Id: I67e71bc37c0464a0714e1e59b3402973786e4aa6
Signed-off-by: KingPoo <haojingbo@huawei.com>
17 files changed:
build/gen_ins_pkg_script.py
deploy/adapters/ansible/openstack_mitaka/roles/onos_cluster/files/setup_networks/setup_networks.py
deploy/adapters/ansible/openstack_mitaka_xenial/roles/moon/files/controllers.py
deploy/adapters/ansible/openstack_newton_xenial/roles/moon/files/controllers.py
deploy/adapters/ansible/openstack_osp9/roles/onos_cluster/files/setup_networks/setup_networks.py
deploy/adapters/ansible/roles/odl_cluster/files/recover_network.py
deploy/adapters/ansible/roles/odl_cluster/files/recover_network_odl_l3.py
deploy/adapters/ansible/roles/odl_cluster/files/setup_networks_odl_l3.py
deploy/adapters/ansible/roles/open-contrail/files/recover_network_opencontrail.py
deploy/adapters/ansible/roles/open-contrail/files/setup_networks_opencontrail.py
deploy/adapters/ansible/roles/setup-network/files/setup_networks/setup_networks.py
deploy/client.py
deploy/rename_nics.py
deploy/reset_compute.py
deploy/setup_vnic.py
deploy/status_callback.py
util/check_valid.py

index e89b428..ae6fa1c 100644 (file)
@@ -49,8 +49,8 @@ def get_packages_name_list(file_list, special_packages):
     return package_name_list
 
 
-def generate_download_script(root="", arch="", tmpl="", docker_tmpl="", default_packages="",
-                             special_packages="", special_packages_script_dir="", special_packages_dir=""):
+def generate_download_script(root="", arch="", tmpl="", docker_tmpl="", default_packages="",  # noqa
+                             special_packages="", special_packages_script_dir="", special_packages_dir=""):   # noqa
     package_name_list = get_packages_name_list(
         get_file_list(root, arch), special_packages) if root else []
 
@@ -85,5 +85,5 @@ def generate_download_script(root="", arch="", tmpl="", docker_tmpl="", default_
 
 if __name__ == '__main__':
     # generate_download_script('ansible', 'Debian', 'Debian.tmpl')
-    generate_download_script(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4],
-                             sys.argv[5].split(' '), sys.argv[6].split(' '), sys.argv[7], sys.argv[8])
+    generate_download_script(sys.argv[1], sys.argv[2], sys.argv[3],
+                             sys.argv[4], sys.argv[5].split(' '), sys.argv[6].split(' '), sys.argv[7], sys.argv[8])   # noqa
index cdd4ae0..086edb2 100644 (file)
@@ -26,8 +26,7 @@ def add_ovs_port(ovs_br, ifname, uplink, vlan_id=None):
     if vlan_id:
         cmd += " tag=%s" % vlan_id
     cmd += " -- set Interface %s type=internal;" % ifname
-    cmd += "ip link set dev %s address `ip link show %s |awk '/link\/ether/{print $2}'`;" \
-        % (ifname, uplink)
+    cmd += "ip link set dev %s address `ip link show %s |awk '/link\/ether/{print $2}'`;" % (ifname, uplink)    # noqa
     cmd += "ip link set %s up;" % ifname
     LOG.info("add_ovs_port: cmd=%s" % cmd)
     os.system(cmd)
@@ -60,7 +59,7 @@ def setup_ips(ip_settings, sys_intf_mappings):
         else:
             intf_name = intf_info["alias"]
         cmd = "ip addr add %s/%s brd %s dev %s;" \
-              % (intf_info["ip"], intf_info["netmask"], str(network.broadcast), intf_name)
+              % (intf_info["ip"], intf_info["netmask"], str(network.broadcast), intf_name)   # noqa
         if "gw" in intf_info:
             cmd += "route del default;"
             cmd += "ip route add default via %s dev %s" % (
@@ -79,6 +78,6 @@ def main(config):
     setup_ips(config["ip_settings"], config["sys_intf_mappings"])
 
 if __name__ == "__main__":
-    os.system("service openvswitch-switch status|| service openvswitch-switch start")
+    os.system("service openvswitch-switch status|| service openvswitch-switch start")  # noqa
     config = yaml.load(open(config_path))
     main(config)
index 8171e23..b4466ef 100644 (file)
@@ -1,13 +1,13 @@
 # Copyright 2015 Open Platform for NFV Project, Inc. and its contributors
-# This software is distributed under the terms and conditions of the 'Apache-2.0'
-# license which can be found in the file 'LICENSE' in this package distribution
-# or at 'http://www.apache.org/licenses/LICENSE-2.0'.
+# This software is distributed under the terms and conditions of
+# the 'Apache-2.0' license which can be found in the file 'LICENSE' in this
+# package distribution or at 'http://www.apache.org/licenses/LICENSE-2.0'.
 
 from keystone.common import controller
 from keystone import config
 from keystone import exception
 from keystone.models import token_model
-from keystone.contrib.moon.exception import *
+from keystone.contrib.moon.exception import *   # noqa
 from oslo_log import log
 from uuid import uuid4
 import requests
@@ -66,7 +66,7 @@ class Tenants(controller.V3Controller):
         return self.tenant_api.get_tenants_dict(user_id)
 
     def __get_keystone_tenant_dict(
-            self, tenant_id="", tenant_name="", tenant_description="", domain="default"):
+            self, tenant_id="", tenant_name="", tenant_description="", domain="default"):   # noqa
         tenants = self.resource_api.list_projects()
         for tenant in tenants:
             if tenant_id and tenant_id == tenant['id']:
@@ -305,7 +305,7 @@ class IntraExtensions(controller.V3Controller):
         subject_category_dict['description'] = kw.get(
             'subject_category_description', None)
         return self.admin_api.set_subject_category_dict(
-            user_id, intra_extension_id, subject_category_id, subject_category_dict)
+            user_id, intra_extension_id, subject_category_id, subject_category_dict)  # noqa
 
     @controller.protected()
     def get_object_categories(self, context, **kw):
@@ -351,7 +351,7 @@ class IntraExtensions(controller.V3Controller):
         object_category_dict['description'] = kw.get(
             'object_category_description', None)
         return self.admin_api.set_object_category_dict(
-            user_id, intra_extension_id, object_category_id, object_category_dict)
+            user_id, intra_extension_id, object_category_id, object_category_dict)  # noqa
 
     @controller.protected()
     def get_action_categories(self, context, **kw):
@@ -397,7 +397,7 @@ class IntraExtensions(controller.V3Controller):
         action_category_dict['description'] = kw.get(
             'action_category_description', None)
         return self.admin_api.set_action_category_dict(
-            user_id, intra_extension_id, action_category_id, action_category_dict)
+            user_id, intra_extension_id, action_category_id, action_category_dict)   # noqa
 
     # Perimeter functions
     @controller.protected()
@@ -547,7 +547,7 @@ class IntraExtensions(controller.V3Controller):
         subject_scope_dict['description'] = kw.get(
             'subject_scope_description', None)
         return self.admin_api.add_subject_scope_dict(
-            user_id, intra_extension_id, subject_category_id, subject_scope_dict)
+            user_id, intra_extension_id, subject_category_id, subject_scope_dict)   # noqa
 
     @controller.protected()
     def get_subject_scope(self, context, **kw):
@@ -581,7 +581,7 @@ class IntraExtensions(controller.V3Controller):
         subject_scope_dict['description'] = kw.get(
             'subject_scope_description', None)
         return self.admin_api.set_subject_scope_dict(
-            user_id, intra_extension_id, subject_category_id, subject_scope_id, subject_scope_dict)
+            user_id, intra_extension_id, subject_category_id, subject_scope_id, subject_scope_dict)   # noqa
 
     @controller.protected()
     def get_object_scopes(self, context, **kw):
@@ -635,7 +635,7 @@ class IntraExtensions(controller.V3Controller):
         object_scope_dict['description'] = kw.get(
             'object_scope_description', None)
         return self.admin_api.set_object_scope_dict(
-            user_id, intra_extension_id, object_category_id, object_scope_id, object_scope_dict)
+            user_id, intra_extension_id, object_category_id, object_scope_id, object_scope_dict)   # noqa
 
     @controller.protected()
     def get_action_scopes(self, context, **kw):
@@ -689,7 +689,7 @@ class IntraExtensions(controller.V3Controller):
         action_scope_dict['description'] = kw.get(
             'action_scope_description', None)
         return self.admin_api.set_action_scope_dict(
-            user_id, intra_extension_id, action_category_id, action_scope_id, action_scope_dict)
+            user_id, intra_extension_id, action_category_id, action_scope_id, action_scope_dict)   # noqa
 
     # Assignment functions
 
@@ -701,7 +701,7 @@ class IntraExtensions(controller.V3Controller):
         subject_category_id = kw.get('subject_category_id', None)
         subject_scope_id = kw.get('subject_scope_id', None)
         return self.admin_api.add_subject_assignment_list(
-            user_id, intra_extension_id, subject_id, subject_category_id, subject_scope_id)
+            user_id, intra_extension_id, subject_id, subject_category_id, subject_scope_id)   # noqa
 
     @controller.protected()
     def get_subject_assignment(self, context, **kw):
@@ -734,7 +734,7 @@ class IntraExtensions(controller.V3Controller):
         object_category_id = kw.get('object_category_id', None)
         object_scope_id = kw.get('object_scope_id', None)
         return self.admin_api.add_object_assignment_list(
-            user_id, intra_extension_id, object_id, object_category_id, object_scope_id)
+            user_id, intra_extension_id, object_id, object_category_id, object_scope_id)  # noqa
 
     @controller.protected()
     def get_object_assignment(self, context, **kw):
@@ -767,7 +767,7 @@ class IntraExtensions(controller.V3Controller):
         action_category_id = kw.get('action_category_id', None)
         action_scope_id = kw.get('action_scope_id', None)
         return self.admin_api.add_action_assignment_list(
-            user_id, intra_extension_id, action_id, action_category_id, action_scope_id)
+            user_id, intra_extension_id, action_id, action_category_id, action_scope_id)   # noqa
 
     @controller.protected()
     def get_action_assignment(self, context, **kw):
@@ -921,7 +921,7 @@ class IntraExtensions(controller.V3Controller):
         subject_category_list = kw.get('subject_categories', [])
         object_category_list = kw.get('object_categories', [])
         action_category_list = kw.get('action_categories', [])
-        rule_list = subject_category_list + action_category_list + object_category_list
+        rule_list = subject_category_list + action_category_list + object_category_list   # noqa
         return self.admin_api.set_rule_dict(
             user_id, intra_extension_id, sub_meta_rule_id, rule_id, rule_list)
 
@@ -1031,7 +1031,7 @@ class MoonAuth(controller.V3Controller):
             else:
                 message = {
                     "error": {
-                        "message": "Unable to find project {}".format(kw['project']),
+                        "message": "Unable to find project {}".format(kw['project']),   # noqa
                         "code": 200,
                         "title": "UnScopedToken"
                     }}
index 8171e23..f55191d 100644 (file)
@@ -1,13 +1,13 @@
 # Copyright 2015 Open Platform for NFV Project, Inc. and its contributors
-# This software is distributed under the terms and conditions of the 'Apache-2.0'
-# license which can be found in the file 'LICENSE' in this package distribution
-# or at 'http://www.apache.org/licenses/LICENSE-2.0'.
+# This software is distributed under the terms and conditions of the
+# 'Apache-2.0' license which can be found in the file 'LICENSE' in this
+# package distribution or at 'http://www.apache.org/licenses/LICENSE-2.0'.
 
 from keystone.common import controller
 from keystone import config
 from keystone import exception
 from keystone.models import token_model
-from keystone.contrib.moon.exception import *
+from keystone.contrib.moon.exception import *   # noqa
 from oslo_log import log
 from uuid import uuid4
 import requests
@@ -66,7 +66,7 @@ class Tenants(controller.V3Controller):
         return self.tenant_api.get_tenants_dict(user_id)
 
     def __get_keystone_tenant_dict(
-            self, tenant_id="", tenant_name="", tenant_description="", domain="default"):
+            self, tenant_id="", tenant_name="", tenant_description="", domain="default"):  # noqa
         tenants = self.resource_api.list_projects()
         for tenant in tenants:
             if tenant_id and tenant_id == tenant['id']:
@@ -305,7 +305,7 @@ class IntraExtensions(controller.V3Controller):
         subject_category_dict['description'] = kw.get(
             'subject_category_description', None)
         return self.admin_api.set_subject_category_dict(
-            user_id, intra_extension_id, subject_category_id, subject_category_dict)
+            user_id, intra_extension_id, subject_category_id, subject_category_dict)  # noqa
 
     @controller.protected()
     def get_object_categories(self, context, **kw):
@@ -351,7 +351,7 @@ class IntraExtensions(controller.V3Controller):
         object_category_dict['description'] = kw.get(
             'object_category_description', None)
         return self.admin_api.set_object_category_dict(
-            user_id, intra_extension_id, object_category_id, object_category_dict)
+            user_id, intra_extension_id, object_category_id, object_category_dict)  # noqa
 
     @controller.protected()
     def get_action_categories(self, context, **kw):
@@ -397,7 +397,7 @@ class IntraExtensions(controller.V3Controller):
         action_category_dict['description'] = kw.get(
             'action_category_description', None)
         return self.admin_api.set_action_category_dict(
-            user_id, intra_extension_id, action_category_id, action_category_dict)
+            user_id, intra_extension_id, action_category_id, action_category_dict)  # noqa
 
     # Perimeter functions
     @controller.protected()
@@ -547,7 +547,7 @@ class IntraExtensions(controller.V3Controller):
         subject_scope_dict['description'] = kw.get(
             'subject_scope_description', None)
         return self.admin_api.add_subject_scope_dict(
-            user_id, intra_extension_id, subject_category_id, subject_scope_dict)
+            user_id, intra_extension_id, subject_category_id, subject_scope_dict)   # noqa
 
     @controller.protected()
     def get_subject_scope(self, context, **kw):
@@ -581,7 +581,7 @@ class IntraExtensions(controller.V3Controller):
         subject_scope_dict['description'] = kw.get(
             'subject_scope_description', None)
         return self.admin_api.set_subject_scope_dict(
-            user_id, intra_extension_id, subject_category_id, subject_scope_id, subject_scope_dict)
+            user_id, intra_extension_id, subject_category_id, subject_scope_id, subject_scope_dict)  # noqa
 
     @controller.protected()
     def get_object_scopes(self, context, **kw):
@@ -635,7 +635,7 @@ class IntraExtensions(controller.V3Controller):
         object_scope_dict['description'] = kw.get(
             'object_scope_description', None)
         return self.admin_api.set_object_scope_dict(
-            user_id, intra_extension_id, object_category_id, object_scope_id, object_scope_dict)
+            user_id, intra_extension_id, object_category_id, object_scope_id, object_scope_dict)  # noqa
 
     @controller.protected()
     def get_action_scopes(self, context, **kw):
@@ -689,7 +689,7 @@ class IntraExtensions(controller.V3Controller):
         action_scope_dict['description'] = kw.get(
             'action_scope_description', None)
         return self.admin_api.set_action_scope_dict(
-            user_id, intra_extension_id, action_category_id, action_scope_id, action_scope_dict)
+            user_id, intra_extension_id, action_category_id, action_scope_id, action_scope_dict)  # noqa
 
     # Assignment functions
 
@@ -701,7 +701,7 @@ class IntraExtensions(controller.V3Controller):
         subject_category_id = kw.get('subject_category_id', None)
         subject_scope_id = kw.get('subject_scope_id', None)
         return self.admin_api.add_subject_assignment_list(
-            user_id, intra_extension_id, subject_id, subject_category_id, subject_scope_id)
+            user_id, intra_extension_id, subject_id, subject_category_id, subject_scope_id)   # noqa
 
     @controller.protected()
     def get_subject_assignment(self, context, **kw):
@@ -734,7 +734,7 @@ class IntraExtensions(controller.V3Controller):
         object_category_id = kw.get('object_category_id', None)
         object_scope_id = kw.get('object_scope_id', None)
         return self.admin_api.add_object_assignment_list(
-            user_id, intra_extension_id, object_id, object_category_id, object_scope_id)
+            user_id, intra_extension_id, object_id, object_category_id, object_scope_id)  # noqa
 
     @controller.protected()
     def get_object_assignment(self, context, **kw):
@@ -767,7 +767,7 @@ class IntraExtensions(controller.V3Controller):
         action_category_id = kw.get('action_category_id', None)
         action_scope_id = kw.get('action_scope_id', None)
         return self.admin_api.add_action_assignment_list(
-            user_id, intra_extension_id, action_id, action_category_id, action_scope_id)
+            user_id, intra_extension_id, action_id, action_category_id, action_scope_id)  # noqa
 
     @controller.protected()
     def get_action_assignment(self, context, **kw):
@@ -921,7 +921,7 @@ class IntraExtensions(controller.V3Controller):
         subject_category_list = kw.get('subject_categories', [])
         object_category_list = kw.get('object_categories', [])
         action_category_list = kw.get('action_categories', [])
-        rule_list = subject_category_list + action_category_list + object_category_list
+        rule_list = subject_category_list + action_category_list + object_category_list   # noqa
         return self.admin_api.set_rule_dict(
             user_id, intra_extension_id, sub_meta_rule_id, rule_id, rule_list)
 
@@ -1031,7 +1031,7 @@ class MoonAuth(controller.V3Controller):
             else:
                 message = {
                     "error": {
-                        "message": "Unable to find project {}".format(kw['project']),
+                        "message": "Unable to find project {}".format(kw['project']),  # noqa
                         "code": 200,
                         "title": "UnScopedToken"
                     }}
index cdd4ae0..315d5c8 100755 (executable)
@@ -26,8 +26,7 @@ def add_ovs_port(ovs_br, ifname, uplink, vlan_id=None):
     if vlan_id:
         cmd += " tag=%s" % vlan_id
     cmd += " -- set Interface %s type=internal;" % ifname
-    cmd += "ip link set dev %s address `ip link show %s |awk '/link\/ether/{print $2}'`;" \
-        % (ifname, uplink)
+    cmd += "ip link set dev %s address `ip link show %s |awk '/link\/ether/{print $2}'`;" % (ifname, uplink)  # noqa
     cmd += "ip link set %s up;" % ifname
     LOG.info("add_ovs_port: cmd=%s" % cmd)
     os.system(cmd)
@@ -60,7 +59,7 @@ def setup_ips(ip_settings, sys_intf_mappings):
         else:
             intf_name = intf_info["alias"]
         cmd = "ip addr add %s/%s brd %s dev %s;" \
-              % (intf_info["ip"], intf_info["netmask"], str(network.broadcast), intf_name)
+              % (intf_info["ip"], intf_info["netmask"], str(network.broadcast), intf_name)  # noqa
         if "gw" in intf_info:
             cmd += "route del default;"
             cmd += "ip route add default via %s dev %s" % (
@@ -79,6 +78,6 @@ def main(config):
     setup_ips(config["ip_settings"], config["sys_intf_mappings"])
 
 if __name__ == "__main__":
-    os.system("service openvswitch-switch status|| service openvswitch-switch start")
+    os.system("service openvswitch-switch status|| service openvswitch-switch start")  # noqa
     config = yaml.load(open(config_path))
     main(config)
index 2d79388..3e7d5cb 100755 (executable)
@@ -17,8 +17,7 @@ def add_ovs_port(ovs_br, ifname, uplink, vlan_id=None):
     if vlan_id:
         cmd += " tag=%s" % vlan_id
     cmd += " -- set Interface %s type=internal;" % ifname
-    cmd += "ip link set dev %s address `ip link show %s |awk '/link\/ether/{print $2}'`;" \
-        % (ifname, uplink)
+    cmd += "ip link set dev %s address `ip link show %s |awk '/link\/ether/{print $2}'`;" % (ifname, uplink)   # noqa
     cmd += "ip link set %s up;" % ifname
     LOG.info("add_ovs_port: cmd=%s" % cmd)
     os.system(cmd)
@@ -34,7 +33,7 @@ def setup_ips(ip_settings, sys_intf_mappings):
             intf_name = intf_info["alias"]
         if "gw" in intf_info:
             cmd = "ip addr add %s/%s brd %s dev %s;" \
-                  % (intf_info["ip"], intf_info["netmask"], str(network.broadcast), intf_name)
+                  % (intf_info["ip"], intf_info["netmask"], str(network.broadcast), intf_name)  # noqa
             cmd += "route del default;"
             cmd += "ip route add default via %s dev %s" % (
                 intf_info["gw"], intf_name)
@@ -66,6 +65,6 @@ def main(config):
 
 
 if __name__ == "__main__":
-    os.system("service openvswitch-switch status|| service openvswitch-switch start")
+    os.system("service openvswitch-switch status|| service openvswitch-switch start")  # noqa
     config = yaml.load(open(config_path))
     main(config)
index 48b4d48..07ccba1 100755 (executable)
@@ -14,10 +14,10 @@ def setup_bondings(bond_mappings):
 def setup_ips_new(config):
     LOG.info("setup_ips_new enter")
     network = netaddr.IPNetwork(config["ip_settings"]["br-prv"]["cidr"])
-    intf_name = config["provider_net_mappings"][0]["interface"]
+#    intf_name = config["provider_net_mappings"][0]["interface"]
     cmd = "ip link set br-ex up;"
     cmd += "ip addr add %s/%s brd %s dev %s;" \
-        % (config["ip_settings"]["br-prv"]["ip"], config["ip_settings"]["br-prv"]["netmask"], str(network.broadcast), 'br-ex')
+        % (config["ip_settings"]["br-prv"]["ip"], config["ip_settings"]["br-prv"]["netmask"], str(network.broadcast), 'br-ex')  # noqa
     cmd += "route del default;"
     cmd += "ip route add default via %s dev %s" % (
         config["ip_settings"]["br-prv"]["gw"], 'br-ex')
@@ -29,6 +29,6 @@ def main(config):
     setup_ips_new(config)
 
 if __name__ == "__main__":
-    os.system("service openvswitch-switch status|| service openvswitch-switch start")
+    os.system("service openvswitch-switch status|| service openvswitch-switch start")  # noqa
     config = yaml.load(open(config_path))
     main(config)
index 08e3fbf..45e475d 100644 (file)
@@ -25,7 +25,7 @@ def add_vlan_link(interface, ifname, vlan_id):
 #    if vlan_id:
 #        cmd += " tag=%s" % vlan_id
 #    cmd += " -- set Interface %s type=internal;" % ifname
-#    cmd += "ip link set dev %s address `ip link show %s |awk '/link\/ether/{print $2}'`;" \
+#    cmd += "ip link set dev %s address `ip link show %s |awk '/link\/ether/{print $2}'`;" \  # noqa
 #            % (ifname, uplink)
 #    cmd += "ip link set %s up;" % ifname
 #    LOG.info("add_ovs_port: cmd=%s" % cmd)
@@ -61,10 +61,10 @@ def setup_ips(ip_settings, sys_intf_mappings):
         if "gw" in intf_info:
             continue
         cmd = "ip addr add %s/%s brd %s dev %s;" \
-              % (intf_info["ip"], intf_info["netmask"], str(network.broadcast), intf_name)
+              % (intf_info["ip"], intf_info["netmask"], str(network.broadcast), intf_name)  # noqa
 #        if "gw" in intf_info:
 #            cmd += "route del default;"
-#            cmd += "ip route add default via %s dev %s" % (intf_info["gw"], intf_name)
+#            cmd += "ip route add default via %s dev %s" % (intf_info["gw"], intf_name)  # noqa
         LOG.info("setup_ips: cmd=%s" % cmd)
         os.system(cmd)
 
@@ -72,14 +72,14 @@ def setup_ips(ip_settings, sys_intf_mappings):
 def setup_ips_new(config):
     LOG.info("setup_ips_new enter")
     network = netaddr.IPNetwork(config["ip_settings"]["br-prv"]["cidr"])
-    intf_name = config["provider_net_mappings"][0]["interface"]
+#    intf_name = config["provider_net_mappings"][0]["interface"]
 #    cmd = "ip addr add %s/%s brd %s dev %s;" \
-#          % (config["ip_settings"]["br-prv"]["ip"], config["ip_settings"]["br-prv"]["netmask"], str(network.broadcast), intf_name)
+#          % (config["ip_settings"]["br-prv"]["ip"], config["ip_settings"]["br-prv"]["netmask"], str(network.broadcast), intf_name)  # noqa
     cmd = "ip link set br-ex up;"
     cmd += "ip addr add %s/%s brd %s dev %s;" \
-        % (config["ip_settings"]["br-prv"]["ip"], config["ip_settings"]["br-prv"]["netmask"], str(network.broadcast), 'br-ex')
+        % (config["ip_settings"]["br-prv"]["ip"], config["ip_settings"]["br-prv"]["netmask"], str(network.broadcast), 'br-ex')  # noqa
     cmd += "route del default;"
-#    cmd += "ip route add default via %s dev %s" % (config["ip_settings"]["br-prv"]["gw"], intf_name)
+#    cmd += "ip route add default via %s dev %s" % (config["ip_settings"]["br-prv"]["gw"], intf_name)  # noqa
     cmd += "ip route add default via %s dev %s" % (
         config["ip_settings"]["br-prv"]["gw"], 'br-ex')
     LOG.info("setup_ips_new: cmd=%s" % cmd)
@@ -97,6 +97,6 @@ def main(config):
     setup_ips_new(config)
 
 if __name__ == "__main__":
-    os.system("service openvswitch-switch status|| service openvswitch-switch start")
+    os.system("service openvswitch-switch status|| service openvswitch-switch start")  # noqa
     config = yaml.load(open(config_path))
     main(config)
index e3b1fe8..554093b 100755 (executable)
@@ -16,14 +16,14 @@ def setup_ips_new(config):
     network = netaddr.IPNetwork(config["ip_settings"]["br-prv"]["cidr"])
     intf_name = config["provider_net_mappings"][0]["interface"]
     cmd = "ip addr add %s/%s brd %s dev %s;" \
-          % (config["ip_settings"]["br-prv"]["ip"], config["ip_settings"]["br-prv"]["netmask"], str(network.broadcast), intf_name)
-    #cmd = "ip link set br-ex up;"
-    #cmd += "ip addr add %s/%s brd %s dev %s;" \
-    #      % (config["ip_settings"]["br-prv"]["ip"], config["ip_settings"]["br-prv"]["netmask"], str(network.broadcast), 'br-ex')
+          % (config["ip_settings"]["br-prv"]["ip"], config["ip_settings"]["br-prv"]["netmask"], str(network.broadcast), intf_name)  # noqa
+    # cmd = "ip link set br-ex up;"
+    # cmd += "ip addr add %s/%s brd %s dev %s;" \
+    #      % (config["ip_settings"]["br-prv"]["ip"], config["ip_settings"]["br-prv"]["netmask"], str(network.broadcast), 'br-ex')   # noqa
     cmd += "route del default;"
     cmd += "ip route add default via %s dev %s" % (
         config["ip_settings"]["br-prv"]["gw"], intf_name)
-    #cmd += "ip route add default via %s dev %s" % (config["ip_settings"]["br-prv"]["gw"], 'br-ex')
+    # cmd += "ip route add default via %s dev %s" % (config["ip_settings"]["br-prv"]["gw"], 'br-ex')  # noqa
     LOG.info("setup_ips_new: cmd=%s" % cmd)
     os.system(cmd)
 
index e57d710..a427ee3 100755 (executable)
@@ -25,7 +25,7 @@ def add_vlan_link(interface, ifname, vlan_id):
 #    if vlan_id:
 #        cmd += " tag=%s" % vlan_id
 #    cmd += " -- set Interface %s type=internal;" % ifname
-#    cmd += "ip link set dev %s address `ip link show %s |awk '/link\/ether/{print $2}'`;" \
+#    cmd += "ip link set dev %s address `ip link show %s |awk '/link\/ether/{print $2}'`;" \  # noqa
 #            % (ifname, uplink)
 #    cmd += "ip link set %s up;" % ifname
 #    LOG.info("add_ovs_port: cmd=%s" % cmd)
@@ -61,10 +61,10 @@ def setup_ips(ip_settings, sys_intf_mappings):
         if "gw" in intf_info:
             continue
         cmd = "ip addr add %s/%s brd %s dev %s;" \
-              % (intf_info["ip"], intf_info["netmask"], str(network.broadcast), intf_name)
+              % (intf_info["ip"], intf_info["netmask"], str(network.broadcast), intf_name)  # noqa
 #        if "gw" in intf_info:
 #            cmd += "route del default;"
-#            cmd += "ip route add default via %s dev %s" % (intf_info["gw"], intf_name)
+#            cmd += "ip route add default via %s dev %s" % (intf_info["gw"], intf_name)  # noqa
         LOG.info("setup_ips: cmd=%s" % cmd)
         os.system(cmd)
 
@@ -74,22 +74,22 @@ def setup_ips_new(config):
     network = netaddr.IPNetwork(config["ip_settings"]["br-prv"]["cidr"])
     intf_name = config["provider_net_mappings"][0]["interface"]
     cmd = "ip addr add %s/%s brd %s dev %s;" \
-          % (config["ip_settings"]["br-prv"]["ip"], config["ip_settings"]["br-prv"]["netmask"], str(network.broadcast), intf_name)
+          % (config["ip_settings"]["br-prv"]["ip"], config["ip_settings"]["br-prv"]["netmask"], str(network.broadcast), intf_name)  # noqa
 #    cmd = "ip link set br-ex up;"
 #    cmd += "ip addr add %s/%s brd %s dev %s;" \
-#          % (config["ip_settings"]["br-prv"]["ip"], config["ip_settings"]["br-prv"]["netmask"], str(network.broadcast), 'br-ex')
+#          % (config["ip_settings"]["br-prv"]["ip"], config["ip_settings"]["br-prv"]["netmask"], str(network.broadcast), 'br-ex')   # noqa
     cmd += "route del default;"
     cmd += "ip route add default via %s dev %s" % (
         config["ip_settings"]["br-prv"]["gw"], intf_name)
-#    cmd += "ip route add default via %s dev %s" % (config["ip_settings"]["br-prv"]["gw"], 'br-ex')
+#    cmd += "ip route add default via %s dev %s" % (config["ip_settings"]["br-prv"]["gw"], 'br-ex')  # noqa
     LOG.info("setup_ips_new: cmd=%s" % cmd)
     os.system(cmd)
 
 
 def setup_default_router(config):
     LOG.info("setup_ips_new enter")
-    network = netaddr.IPNetwork(config["ip_settings"]["br-prv"]["cidr"])
-    intf_name = config["provider_net_mappings"][0]["interface"]
+#    network = netaddr.IPNetwork(config["ip_settings"]["br-prv"]["cidr"])
+#    intf_name = config["provider_net_mappings"][0]["interface"]
     cmd = "route del default;"
     cmd += "ip route add default via %s dev %s" % (
         config["ip_settings"]["br-prv"]["gw"], "vhost0")
index cdd4ae0..404c206 100644 (file)
@@ -26,8 +26,8 @@ def add_ovs_port(ovs_br, ifname, uplink, vlan_id=None):
     if vlan_id:
         cmd += " tag=%s" % vlan_id
     cmd += " -- set Interface %s type=internal;" % ifname
-    cmd += "ip link set dev %s address `ip link show %s |awk '/link\/ether/{print $2}'`;" \
-        % (ifname, uplink)
+    cmd += "ip link set dev %s address \
+        `ip link show %s |awk '/link\/ether/{print $2}'`;" % (ifname, uplink)
     cmd += "ip link set %s up;" % ifname
     LOG.info("add_ovs_port: cmd=%s" % cmd)
     os.system(cmd)
@@ -60,7 +60,7 @@ def setup_ips(ip_settings, sys_intf_mappings):
         else:
             intf_name = intf_info["alias"]
         cmd = "ip addr add %s/%s brd %s dev %s;" \
-              % (intf_info["ip"], intf_info["netmask"], str(network.broadcast), intf_name)
+              % (intf_info["ip"], intf_info["netmask"], str(network.broadcast), intf_name)  # noqa
         if "gw" in intf_info:
             cmd += "route del default;"
             cmd += "ip route add default via %s dev %s" % (
@@ -79,6 +79,6 @@ def main(config):
     setup_ips(config["ip_settings"], config["sys_intf_mappings"])
 
 if __name__ == "__main__":
-    os.system("service openvswitch-switch status|| service openvswitch-switch start")
+    os.system("service openvswitch-switch status|| service openvswitch-switch start")  # noqa
     config = yaml.load(open(config_path))
     main(config)
index e380da0..a0d7064 100644 (file)
@@ -17,7 +17,6 @@
 """binary to deploy a cluster by compass client api."""
 import os
 import re
-import socket
 import sys
 import time
 import yaml
@@ -28,14 +27,15 @@ import itertools
 import threading
 from collections import defaultdict
 from restful import Client
+import log as logging
+from oslo_config import cfg
+
 
 ROLE_UNASSIGNED = True
 ROLE_ASSIGNED = False
 
-import log as logging
 LOG = logging.getLogger(__name__)
 
-from oslo_config import cfg
 CONF = cfg.CONF
 
 
@@ -159,7 +159,7 @@ opts = [
     cfg.StrOpt('host_networks',
                help=(
                    'semicomma seperated host name and its networks '
-                   '<hostname>:<interface_name>=<ip>|<is_mgmt>|<is_promiscuous>,...'
+                   '<hostname>:<interface_name>=<ip>|<is_mgmt>|<is_promiscuous>,...'  # noqa
                ),
                default=''),
     cfg.StrOpt('partitions',
@@ -167,7 +167,7 @@ opts = [
                    'comma seperated partitions '
                    '<partition name>=<partition_value>'
                ),
-               default='tmp:percentage=10%,var:percentage=30%,home:percentage=30%'),
+               default='tmp:percentage=10%,var:percentage=30%,home:percentage=30%'),  # noqa
     cfg.StrOpt('network_mapping',
                help=(
                    'comma seperated network mapping '
@@ -677,7 +677,7 @@ class CompassClient(object):
         for service_credential in service_credentials:
             if ':' not in service_credential:
                 raise Exception(
-                    'there is no : in service credential %s' % service_credential
+                    'there is no : in service credential %s' % service_credential  # noqa
                 )
             service_name, service_pair = service_credential.split(':', 1)
             if '=' not in service_pair:
@@ -705,7 +705,7 @@ class CompassClient(object):
         for console_credential in console_credentials:
             if ':' not in console_credential:
                 raise Exception(
-                    'there is no : in console credential %s' % console_credential
+                    'there is no : in console credential %s' % console_credential  # noqa
                 )
             console_name, console_pair = console_credential.split(':', 1)
             if '=' not in console_pair:
@@ -718,8 +718,8 @@ class CompassClient(object):
                 'password': password
             }
 
-        package_config["security"] = {"service_credentials": service_credential_cfg,
-                                      "console_credentials": console_credential_cfg}
+        package_config["security"] = {"service_credentials": service_credential_cfg,  # noqa
+                                      "console_credentials": console_credential_cfg}  # noqa
 
         network_mapping = dict([
             network_pair.split('=', 1)
@@ -752,7 +752,7 @@ class CompassClient(object):
         package_config['enable_fwaas'] = (CONF.enable_fwaas == "true")
         package_config['enable_vpnaas'] = (CONF.enable_vpnaas == "true")
         package_config[
-            'odl_l3_agent'] = "Enable" if CONF.odl_l3_agent == "Enable" else "Disable"
+            'odl_l3_agent'] = "Enable" if CONF.odl_l3_agent == "Enable" else "Disable"   # noqa
         package_config[
             'moon'] = "Enable" if CONF.moon == "Enable" else "Disable"
         package_config[
@@ -796,8 +796,7 @@ class CompassClient(object):
             self.set_host_roles(cluster_id, host_id, roles)
             self.host_roles[hostname] = roles
 
-        unassigned_hostnames = list(set(self.host_mapping.keys())
-                                    - set(self.host_roles.keys()))
+        unassigned_hostnames = list(set(self.host_mapping.keys()) - set(self.host_roles.keys()))  # noqa
 
         unassigned_roles = [role for role, status in self.role_mapping.items()
                             if is_role_unassigned(status)]
@@ -810,8 +809,7 @@ class CompassClient(object):
             self.set_host_roles(cluster_id, host_id, [role])
             self.host_roles[hostname] = [role]
 
-        unassigned_hostnames = list(set(self.host_mapping.keys())
-                                    - set(self.host_roles.keys()))
+        unassigned_hostnames = list(set(self.host_mapping.keys()) - set(self.host_roles.keys()))  # noqa
 
         if not unassigned_hostnames:
             return
@@ -888,7 +886,7 @@ class CompassClient(object):
     def get_installing_progress(self, cluster_id):
         def _get_installing_progress():
             """get intalling progress."""
-            deployment_timeout = time.time() + 60 * float(CONF.deployment_timeout)
+            deployment_timeout = time.time() + 60 * float(CONF.deployment_timeout)  # noqa
             current_time = time.time
             while current_time() < deployment_timeout:
                 status, cluster_state = self.get_cluster_state(cluster_id)
@@ -948,14 +946,17 @@ class CompassClient(object):
 
 
 def print_ansible_log():
-    os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i %s root@192.168.200.2 \
-              'while ! tail -f /var/ansible/run/%s-%s/ansible.log 2>/dev/null; do :; sleep 1; done'" %
+    os.system("ssh -o StrictHostKeyChecking=no -o \
+              UserKnownHostsFile=/dev/null -i %s root@192.168.200.2 \
+              'while ! tail -f \
+              /var/ansible/run/%s-%s/ansible.log 2>/dev/null; do :; \
+              sleep 1; done'" %
               (CONF.rsa_file, CONF.adapter_name, CONF.cluster_name))
 
 
 def kill_print_proc():
     os.system(
-        "ps aux|grep -v grep|grep -E 'ssh.+root@192.168.200.2'|awk '{print $2}'|xargs kill -9")
+        "ps aux|grep -v grep|grep -E 'ssh.+root@192.168.200.2'|awk '{print $2}'|xargs kill -9")   # noqa
 
 
 def deploy():
index 99eed3c..a460e80 100644 (file)
@@ -20,13 +20,13 @@ def rename_nics(dha_info, rsa_file, compass_ip, os_version):
                 if os_version == 'xenial':
                     exec_cmd("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
                               -i %s root@%s \
-                              'cobbler system edit --name=%s --interface=%s --mac=%s --interface_type=static'"
-                             % (rsa_file, compass_ip, host_name, nic_name, mac))
+                              'cobbler system edit --name=%s --interface=%s --mac=%s --interface_type=static'"   # noqa
+                             % (rsa_file, compass_ip, host_name, nic_name, mac))   # noqa
                 else:
                     exec_cmd("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
                               -i %s root@%s \
-                              'cobbler system edit --name=%s --interface=%s --mac=%s'"
-                             % (rsa_file, compass_ip, host_name, nic_name, mac))
+                              'cobbler system edit --name=%s --interface=%s --mac=%s'"   # noqa
+                             % (rsa_file, compass_ip, host_name, nic_name, mac))  # noqa
 
     exec_cmd("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
               -i %s root@%s \
index d47f462..f27670b 100644 (file)
@@ -32,7 +32,7 @@ def reset_baremetal(dha_info):
             print ipmiPass
             print ipmiIp
             exec_cmd(
-                "ipmitool -I lanplus -H %s -U %s -P %s chassis power reset >/dev/null" %
+                "ipmitool -I lanplus -H %s -U %s -P %s chassis power reset >/dev/null" %   # noqa
                 (ipmiIp, ipmiUser, ipmiPass))
 
 
index e7ab0cc..12846fd 100644 (file)
@@ -6,7 +6,7 @@ if __name__ == "__main__":
     network_config_file = os.environ["NETWORK"]
     network_config = yaml.load(open(network_config_file, "r"))
     os.system(
-        "sudo ovs-vsctl --may-exist add-port br-external mgmt_vnic -- set Interface mgmt_vnic type=internal")
+        "sudo ovs-vsctl --may-exist add-port br-external mgmt_vnic -- set Interface mgmt_vnic type=internal")   # noqa
     os.system("sudo ip addr flush mgmt_vnic")
     os.system("sudo ip link set mgmt_vnic up")
     for sys_intf in network_config["sys_intf_mappings"]:
index d4712ef..30dffd3 100755 (executable)
@@ -7,8 +7,8 @@ import logging
 def task_error(host, data):
     logging.info("task_error: host=%s,data=%s" % (host, data))
 
-    if isinstance(data, dict):
-        invocation = data.pop('invocation', {})
+#    if isinstance(data, dict):
+#        invocation = data.pop('invocation', {})
 
     notify_host("localhost", host, "failed")
 
@@ -61,7 +61,7 @@ class CallbackModule(object):
         pass
 
     def playbook_on_vars_prompt(self, varname, private=True, prompt=None,
-                                encrypt=None, confirm=False, salt_size=None, salt=None, default=None):
+                                encrypt=None, confirm=False, salt_size=None, salt=None, default=None):   # noqa
         pass
 
     def playbook_on_setup(self):
index 87cd57e..36d74ba 100644 (file)
@@ -25,7 +25,7 @@ def is_valid_ip(ip):
     if not ip:
         return False
     res = re.search(
-        "^(0?\d{1,2}|1\d\d|2[0-4]\d|25[0-5])(\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])){3}(\/(\d|[1-2]\d|3[0-2]))?$",
+        "^(0?\d{1,2}|1\d\d|2[0-4]\d|25[0-5])(\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])){3}(\/(\d|[1-2]\d|3[0-2]))?$",  # noqa
         ip) is not None
     return res