aboutsummaryrefslogtreecommitdiffstats
path: root/deploy/adapters/ansible
diff options
context:
space:
mode:
authormeimei <meimei@huawei.com>2016-11-29 18:05:01 +0800
committermeimei <meimei@huawei.com>2016-11-29 18:09:16 +0800
commit6b2eccf0350f7f053e18ea2ac190489b00960809 (patch)
tree8968b2871c4bfc23bfa7077e857dae4d151e53d2 /deploy/adapters/ansible
parentfcd0eefae931bb7bed0380574c1c7acaa31ffa28 (diff)
Improve compass ci verification, clear all the warnnings
JIRA: COMPASS-494 MODIFY BY HAOJINGBO Change-Id: I2b95d84157c860254b3b3f68f7b2a54393caf8f4 Signed-off-by: meimei <meimei@huawei.com>
Diffstat (limited to 'deploy/adapters/ansible')
-rw-r--r--deploy/adapters/ansible/openstack_mitaka/roles/onos_cluster/files/setup_networks/log.py6
-rw-r--r--deploy/adapters/ansible/openstack_mitaka/roles/onos_cluster/files/setup_networks/setup_networks.py35
-rw-r--r--deploy/adapters/ansible/openstack_mitaka_xenial/roles/moon/files/controllers.py367
-rw-r--r--deploy/adapters/ansible/openstack_mitaka_xenial/roles/moon/files/get_deb_depends.py8
-rwxr-xr-xdeploy/adapters/ansible/roles/odl_cluster/files/recover_network.py26
-rwxr-xr-xdeploy/adapters/ansible/roles/odl_cluster/files/recover_network_odl_l3.py14
-rw-r--r--deploy/adapters/ansible/roles/odl_cluster/files/setup_networks_odl_l3.py40
-rwxr-xr-xdeploy/adapters/ansible/roles/open-contrail/files/recover_network_opencontrail.py21
-rwxr-xr-xdeploy/adapters/ansible/roles/open-contrail/files/setup_networks_opencontrail.py44
-rw-r--r--deploy/adapters/ansible/roles/setup-network/files/setup_networks/check_network.py16
-rw-r--r--deploy/adapters/ansible/roles/setup-network/files/setup_networks/log.py6
-rw-r--r--deploy/adapters/ansible/roles/setup-network/files/setup_networks/setup_networks.py35
12 files changed, 407 insertions, 211 deletions
diff --git a/deploy/adapters/ansible/openstack_mitaka/roles/onos_cluster/files/setup_networks/log.py b/deploy/adapters/ansible/openstack_mitaka/roles/onos_cluster/files/setup_networks/log.py
index fffeb589..a22ff0fe 100644
--- a/deploy/adapters/ansible/openstack_mitaka/roles/onos_cluster/files/setup_networks/log.py
+++ b/deploy/adapters/ansible/openstack_mitaka/roles/onos_cluster/files/setup_networks/log.py
@@ -1,12 +1,13 @@
import logging
import os
loggers = {}
-log_dir="/var/log/setup_network"
+log_dir = "/var/log/setup_network"
try:
os.makedirs(log_dir)
except:
pass
+
def getLogger(name):
if name in loggers:
return loggers[name]
@@ -29,7 +30,8 @@ def getLogger(name):
ch.setLevel(logging.ERROR)
# create formatter and add it to the handlers
- formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
+ formatter = logging.Formatter(
+ "%(asctime)s - %(name)s - %(levelname)s - %(message)s")
ch.setFormatter(formatter)
fh.setFormatter(formatter)
diff --git a/deploy/adapters/ansible/openstack_mitaka/roles/onos_cluster/files/setup_networks/setup_networks.py b/deploy/adapters/ansible/openstack_mitaka/roles/onos_cluster/files/setup_networks/setup_networks.py
index e58d6c72..a25d7ea9 100644
--- a/deploy/adapters/ansible/openstack_mitaka/roles/onos_cluster/files/setup_networks/setup_networks.py
+++ b/deploy/adapters/ansible/openstack_mitaka/roles/onos_cluster/files/setup_networks/setup_networks.py
@@ -6,42 +6,52 @@ import log as logging
LOG = logging.getLogger("net-init")
config_path = os.path.join(os.path.dirname(__file__), "network.cfg")
+
def setup_bondings(bond_mappings):
print bond_mappings
+
def add_vlan_link(interface, ifname, vlan_id):
LOG.info("add_vlan_link enter")
- cmd = "ip link add link %s name %s type vlan id %s; " % (ifname, interface, vlan_id)
+ cmd = "ip link add link %s name %s type vlan id %s; " % (
+ ifname, interface, vlan_id)
cmd += "ip link set %s up; ip link set %s up" % (interface, ifname)
LOG.info("add_vlan_link: cmd=%s" % cmd)
os.system(cmd)
+
def add_ovs_port(ovs_br, ifname, uplink, vlan_id=None):
LOG.info("add_ovs_port enter")
cmd = "ovs-vsctl --may-exist add-port %s %s" % (ovs_br, ifname)
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)
+
def setup_intfs(sys_intf_mappings, uplink_map):
LOG.info("setup_intfs enter")
for intf_name, intf_info in sys_intf_mappings.items():
if intf_info["type"] == "vlan":
- add_vlan_link(intf_name, intf_info["interface"], intf_info["vlan_tag"])
+ add_vlan_link(
+ intf_name,
+ intf_info["interface"],
+ intf_info["vlan_tag"])
elif intf_info["type"] == "ovs":
add_ovs_port(
- intf_info["interface"],
- intf_name,
- uplink_map[intf_info["interface"]],
- vlan_id=intf_info.get("vlan_tag"))
+ intf_info["interface"],
+ intf_name,
+ uplink_map[intf_info["interface"]],
+ vlan_id=intf_info.get("vlan_tag"))
else:
pass
+
def setup_ips(ip_settings, sys_intf_mappings):
LOG.info("setup_ips enter")
for intf_info in ip_settings.values():
@@ -51,13 +61,15 @@ 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: E501
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)
LOG.info("setup_ips: cmd=%s" % cmd)
os.system(cmd)
+
def main(config):
uplink_map = {}
setup_bondings(config["bond_mappings"])
@@ -68,6 +80,7 @@ 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")
config = yaml.load(open(config_path))
main(config)
diff --git a/deploy/adapters/ansible/openstack_mitaka_xenial/roles/moon/files/controllers.py b/deploy/adapters/ansible/openstack_mitaka_xenial/roles/moon/files/controllers.py
index 6da5b423..c46a95f2 100644
--- a/deploy/adapters/ansible/openstack_mitaka_xenial/roles/moon/files/controllers.py
+++ b/deploy/adapters/ansible/openstack_mitaka_xenial/roles/moon/files/controllers.py
@@ -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: F403
from oslo_log import log
from uuid import uuid4
import requests
@@ -17,7 +17,7 @@ CONF = config.CONF
LOG = log.getLogger(__name__)
-@dependency.requires('configuration_api')
+@dependency.requires('configuration_api') # noqa: F405
class Configuration(controller.V3Controller):
collection_name = 'configurations'
member_name = 'configuration'
@@ -27,7 +27,8 @@ class Configuration(controller.V3Controller):
def _get_user_id_from_token(self, token_id):
response = self.token_provider_api.validate_token(token_id)
- token_ref = token_model.KeystoneToken(token_id=token_id, token_data=response)
+ token_ref = token_model.KeystoneToken(
+ token_id=token_id, token_data=response)
return token_ref.get('user')
@controller.protected()
@@ -43,10 +44,10 @@ class Configuration(controller.V3Controller):
@controller.protected()
def get_sub_meta_rule_algorithms(self, context, **kw):
user_id = self._get_user_id_from_token(context.get('token_id'))
- return self.configuration_api.get_sub_meta_rule_algorithms_dict(user_id)
+ return self.configuration_api.get_sub_meta_rule_algorithms_dict(user_id) # noqa: E501
-@dependency.requires('tenant_api', 'resource_api')
+@dependency.requires('tenant_api', 'resource_api') # noqa: F405
class Tenants(controller.V3Controller):
def __init__(self):
@@ -54,7 +55,8 @@ class Tenants(controller.V3Controller):
def _get_user_id_from_token(self, token_id):
response = self.token_provider_api.validate_token(token_id)
- token_ref = token_model.KeystoneToken(token_id=token_id, token_data=response)
+ token_ref = token_model.KeystoneToken(
+ token_id=token_id, token_data=response)
return token_ref.get('user')
@controller.protected()
@@ -62,7 +64,8 @@ class Tenants(controller.V3Controller):
user_id = self._get_user_id_from_token(context.get('token_id'))
return self.tenant_api.get_tenants_dict(user_id)
- def __get_keystone_tenant_dict(self, tenant_id="", tenant_name="", tenant_description="", domain="default"):
+ def __get_keystone_tenant_dict(
+ self, tenant_id="", tenant_name="", tenant_description="", domain="default"): # noqa: E501
tenants = self.resource_api.list_projects()
for tenant in tenants:
if tenant_id and tenant_id == tenant['id']:
@@ -80,7 +83,8 @@ class Tenants(controller.V3Controller):
"enabled": True,
"domain_id": domain
}
- keystone_tenant = self.resource_api.create_project(tenant["id"], tenant)
+ keystone_tenant = self.resource_api.create_project(
+ tenant["id"], tenant)
return keystone_tenant
@controller.protected()
@@ -88,7 +92,9 @@ class Tenants(controller.V3Controller):
user_id = self._get_user_id_from_token(context.get('token_id'))
k_tenant_dict = self.__get_keystone_tenant_dict(
tenant_name=kw.get('tenant_name'),
- tenant_description=kw.get('tenant_description', kw.get('tenant_name')),
+ tenant_description=kw.get(
+ 'tenant_description',
+ kw.get('tenant_name')),
domain=kw.get('tenant_domain', "default"),
)
@@ -96,9 +102,11 @@ class Tenants(controller.V3Controller):
tenant_dict['id'] = k_tenant_dict['id']
tenant_dict['name'] = kw.get('tenant_name', None)
tenant_dict['description'] = kw.get('tenant_description', None)
- tenant_dict['intra_authz_extension_id'] = kw.get('tenant_intra_authz_extension_id', None)
- tenant_dict['intra_admin_extension_id'] = kw.get('tenant_intra_admin_extension_id', None)
- return self.tenant_api.add_tenant_dict(user_id, tenant_dict['id'], tenant_dict)
+ tenant_dict['intra_authz_extension_id'] = kw.get(
+ 'tenant_intra_authz_extension_id', None)
+ tenant_dict['intra_admin_extension_id'] = kw.get(
+ 'tenant_intra_admin_extension_id', None)
+ return self.tenant_api.add_tenant_dict(user_id, tenant_dict['id'], tenant_dict) # noqa: E501
@controller.protected()
def get_tenant(self, context, **kw):
@@ -116,16 +124,19 @@ class Tenants(controller.V3Controller):
def set_tenant(self, context, **kw):
user_id = self._get_user_id_from_token(context.get('token_id'))
# Next line will raise an error if tenant doesn't exist
- k_tenant_dict = self.resource_api.get_project(kw.get('tenant_id', None))
+ k_tenant_dict = self.resource_api.get_project(
+ kw.get('tenant_id', None))
tenant_id = kw.get('tenant_id', None)
tenant_dict = dict()
tenant_dict['name'] = k_tenant_dict.get('name', None)
if 'tenant_description' in kw:
tenant_dict['description'] = kw.get('tenant_description', None)
if 'tenant_intra_authz_extension_id' in kw:
- tenant_dict['intra_authz_extension_id'] = kw.get('tenant_intra_authz_extension_id', None)
+ tenant_dict['intra_authz_extension_id'] = kw.get(
+ 'tenant_intra_authz_extension_id', None)
if 'tenant_intra_admin_extension_id' in kw:
- tenant_dict['intra_admin_extension_id'] = kw.get('tenant_intra_admin_extension_id', None)
+ tenant_dict['intra_admin_extension_id'] = kw.get(
+ 'tenant_intra_admin_extension_id', None)
self.tenant_api.set_tenant_dict(user_id, tenant_id, tenant_dict)
@@ -140,21 +151,22 @@ def callback(self, context, prep_info, *args, **kwargs):
raise exception.Unauthorized
-@dependency.requires('authz_api')
+@dependency.requires('authz_api') # noqa: F405
class Authz_v3(controller.V3Controller):
def __init__(self):
super(Authz_v3, self).__init__()
@controller.protected(callback)
- def get_authz(self, context, tenant_id, subject_k_id, object_name, action_name):
+ def get_authz(self, context, tenant_id,
+ subject_k_id, object_name, action_name):
try:
- return self.authz_api.authz(tenant_id, subject_k_id, object_name, action_name)
+ return self.authz_api.authz(tenant_id, subject_k_id, object_name, action_name) # noqa: E501
except Exception as e:
return {'authz': False, 'comment': unicode(e)}
-@dependency.requires('admin_api', 'root_api')
+@dependency.requires('admin_api', 'root_api') # noqa: F405
class IntraExtensions(controller.V3Controller):
collection_name = 'intra_extensions'
member_name = 'intra_extension'
@@ -164,7 +176,8 @@ class IntraExtensions(controller.V3Controller):
def _get_user_id_from_token(self, token_id):
response = self.token_provider_api.validate_token(token_id)
- token_ref = token_model.KeystoneToken(token_id=token_id, token_data=response)
+ token_ref = token_model.KeystoneToken(
+ token_id=token_id, token_data=response)
return token_ref.get('user')['id']
# IntraExtension functions
@@ -180,30 +193,47 @@ class IntraExtensions(controller.V3Controller):
intra_extension_dict['name'] = kw.get('intra_extension_name', None)
intra_extension_dict['model'] = kw.get('intra_extension_model', None)
intra_extension_dict['genre'] = kw.get('intra_extension_genre', None)
- intra_extension_dict['description'] = kw.get('intra_extension_description', None)
- intra_extension_dict['subject_categories'] = kw.get('intra_extension_subject_categories', dict())
- intra_extension_dict['object_categories'] = kw.get('intra_extension_object_categories', dict())
- intra_extension_dict['action_categories'] = kw.get('intra_extension_action_categories', dict())
- intra_extension_dict['subjects'] = kw.get('intra_extension_subjects', dict())
- intra_extension_dict['objects'] = kw.get('intra_extension_objects', dict())
- intra_extension_dict['actions'] = kw.get('intra_extension_actions', dict())
- intra_extension_dict['subject_scopes'] = kw.get('intra_extension_subject_scopes', dict())
- intra_extension_dict['object_scopes'] = kw.get('intra_extension_object_scopes', dict())
- intra_extension_dict['action_scopes'] = kw.get('intra_extension_action_scopes', dict())
- intra_extension_dict['subject_assignments'] = kw.get('intra_extension_subject_assignments', dict())
- intra_extension_dict['object_assignments'] = kw.get('intra_extension_object_assignments', dict())
- intra_extension_dict['action_assignments'] = kw.get('intra_extension_action_assignments', dict())
- intra_extension_dict['aggregation_algorithm'] = kw.get('intra_extension_aggregation_algorithm', dict())
- intra_extension_dict['sub_meta_rules'] = kw.get('intra_extension_sub_meta_rules', dict())
+ intra_extension_dict['description'] = kw.get(
+ 'intra_extension_description', None)
+ intra_extension_dict['subject_categories'] = kw.get(
+ 'intra_extension_subject_categories', dict())
+ intra_extension_dict['object_categories'] = kw.get(
+ 'intra_extension_object_categories', dict())
+ intra_extension_dict['action_categories'] = kw.get(
+ 'intra_extension_action_categories', dict())
+ intra_extension_dict['subjects'] = kw.get(
+ 'intra_extension_subjects', dict())
+ intra_extension_dict['objects'] = kw.get(
+ 'intra_extension_objects', dict())
+ intra_extension_dict['actions'] = kw.get(
+ 'intra_extension_actions', dict())
+ intra_extension_dict['subject_scopes'] = kw.get(
+ 'intra_extension_subject_scopes', dict())
+ intra_extension_dict['object_scopes'] = kw.get(
+ 'intra_extension_object_scopes', dict())
+ intra_extension_dict['action_scopes'] = kw.get(
+ 'intra_extension_action_scopes', dict())
+ intra_extension_dict['subject_assignments'] = kw.get(
+ 'intra_extension_subject_assignments', dict())
+ intra_extension_dict['object_assignments'] = kw.get(
+ 'intra_extension_object_assignments', dict())
+ intra_extension_dict['action_assignments'] = kw.get(
+ 'intra_extension_action_assignments', dict())
+ intra_extension_dict['aggregation_algorithm'] = kw.get(
+ 'intra_extension_aggregation_algorithm', dict())
+ intra_extension_dict['sub_meta_rules'] = kw.get(
+ 'intra_extension_sub_meta_rules', dict())
intra_extension_dict['rules'] = kw.get('intra_extension_rules', dict())
- ref = self.admin_api.load_intra_extension_dict(user_id, intra_extension_dict=intra_extension_dict)
+ ref = self.admin_api.load_intra_extension_dict(
+ user_id,
+ intra_extension_dict=intra_extension_dict)
return self.admin_api.populate_default_data(ref)
@controller.protected()
def get_intra_extension(self, context, **kw):
user_id = self._get_user_id_from_token(context.get('token_id'))
intra_extension_id = kw.get('intra_extension_id', None)
- return self.admin_api.get_intra_extension_dict(user_id, intra_extension_id)
+ return self.admin_api.get_intra_extension_dict(user_id, intra_extension_id) # noqa: E501
@controller.protected()
def del_intra_extension(self, context, **kw):
@@ -219,8 +249,9 @@ class IntraExtensions(controller.V3Controller):
intra_extension_dict['name'] = kw.get('intra_extension_name', None)
intra_extension_dict['model'] = kw.get('intra_extension_model', None)
intra_extension_dict['genre'] = kw.get('intra_extension_genre', None)
- intra_extension_dict['description'] = kw.get('intra_extension_description', None)
- return self.admin_api.set_intra_extension_dict(user_id, intra_extension_id, intra_extension_dict)
+ intra_extension_dict['description'] = kw.get(
+ 'intra_extension_description', None)
+ return self.admin_api.set_intra_extension_dict(user_id, intra_extension_id, intra_extension_dict) # noqa: E501
@controller.protected()
def load_root_intra_extension(self, context, **kw):
@@ -231,7 +262,7 @@ class IntraExtensions(controller.V3Controller):
def get_subject_categories(self, context, **kw):
user_id = self._get_user_id_from_token(context.get('token_id'))
intra_extension_id = kw.get('intra_extension_id', None)
- return self.admin_api.get_subject_categories_dict(user_id, intra_extension_id)
+ return self.admin_api.get_subject_categories_dict(user_id, intra_extension_id) # noqa: E501
@controller.protected()
def add_subject_category(self, context, **kw):
@@ -239,22 +270,26 @@ class IntraExtensions(controller.V3Controller):
intra_extension_id = kw.get('intra_extension_id', None)
subject_category_dict = dict()
subject_category_dict['name'] = kw.get('subject_category_name', None)
- subject_category_dict['description'] = kw.get('subject_category_description', None)
- return self.admin_api.add_subject_category_dict(user_id, intra_extension_id, subject_category_dict)
+ subject_category_dict['description'] = kw.get(
+ 'subject_category_description', None)
+ return self.admin_api.add_subject_category_dict(user_id, intra_extension_id, subject_category_dict) # noqa: E501
@controller.protected()
def get_subject_category(self, context, **kw):
user_id = self._get_user_id_from_token(context.get('token_id'))
intra_extension_id = kw.get('intra_extension_id', None)
subject_category_id = kw.get('subject_category_id', None)
- return self.admin_api.get_subject_category_dict(user_id, intra_extension_id, subject_category_id)
+ return self.admin_api.get_subject_category_dict(user_id, intra_extension_id, subject_category_id) # noqa: E501
@controller.protected()
def del_subject_category(self, context, **kw):
user_id = self._get_user_id_from_token(context.get('token_id'))
intra_extension_id = kw.get('intra_extension_id', None)
subject_category_id = kw.get('subject_category_id', None)
- self.admin_api.del_subject_category(user_id, intra_extension_id, subject_category_id)
+ self.admin_api.del_subject_category(
+ user_id,
+ intra_extension_id,
+ subject_category_id)
@controller.protected()
def set_subject_category(self, context, **kw):
@@ -263,14 +298,15 @@ class IntraExtensions(controller.V3Controller):
subject_category_id = kw.get('subject_category_id', None)
subject_category_dict = dict()
subject_category_dict['name'] = kw.get('subject_category_name', None)
- 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)
+ 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) # noqa: E501
@controller.protected()
def get_object_categories(self, context, **kw):
user_id = self._get_user_id_from_token(context.get('token_id'))
intra_extension_id = kw.get('intra_extension_id', None)
- return self.admin_api.get_object_categories_dict(user_id, intra_extension_id)
+ return self.admin_api.get_object_categories_dict(user_id, intra_extension_id) # noqa: E501
@controller.protected()
def add_object_category(self, context, **kw):
@@ -278,22 +314,26 @@ class IntraExtensions(controller.V3Controller):
intra_extension_id = kw.get('intra_extension_id', None)
object_category_dict = dict()
object_category_dict['name'] = kw.get('object_category_name', None)
- object_category_dict['description'] = kw.get('object_category_description', None)
- return self.admin_api.add_object_category_dict(user_id, intra_extension_id, object_category_dict)
+ object_category_dict['description'] = kw.get(
+ 'object_category_description', None)
+ return self.admin_api.add_object_category_dict(user_id, intra_extension_id, object_category_dict) # noqa: E501
@controller.protected()
def get_object_category(self, context, **kw):
user_id = self._get_user_id_from_token(context.get('token_id'))
intra_extension_id = kw.get('intra_extension_id', None)
object_category_id = kw.get('object_category_id', None)
- return self.admin_api.get_object_categories_dict(user_id, intra_extension_id, object_category_id)
+ return self.admin_api.get_object_categories_dict(user_id, intra_extension_id, object_category_id) # noqa: E501
@controller.protected()
def del_object_category(self, context, **kw):
user_id = self._get_user_id_from_token(context.get('token_id'))
intra_extension_id = kw.get('intra_extension_id', None)
object_category_id = kw.get('object_category_id', None)
- self.admin_api.del_object_category(user_id, intra_extension_id, object_category_id)
+ self.admin_api.del_object_category(
+ user_id,
+ intra_extension_id,
+ object_category_id)
@controller.protected()
def set_object_category(self, context, **kw):
@@ -302,14 +342,15 @@ class IntraExtensions(controller.V3Controller):
object_category_id = kw.get('object_category_id', None)
object_category_dict = dict()
object_category_dict['name'] = kw.get('object_category_name', None)
- 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)
+ 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) # noqa: E501
@controller.protected()
def get_action_categories(self, context, **kw):
user_id = self._get_user_id_from_token(context.get('token_id'))
intra_extension_id = kw.get('intra_extension_id', None)
- return self.admin_api.get_action_categories_dict(user_id, intra_extension_id)
+ return self.admin_api.get_action_categories_dict(user_id, intra_extension_id) # noqa: E501
@controller.protected()
def add_action_category(self, context, **kw):
@@ -317,22 +358,26 @@ class IntraExtensions(controller.V3Controller):
intra_extension_id = kw.get('intra_extension_id', None)
action_category_dict = dict()
action_category_dict['name'] = kw.get('action_category_name', None)
- action_category_dict['description'] = kw.get('action_category_description', None)
- return self.admin_api.add_action_category_dict(user_id, intra_extension_id, action_category_dict)
+ action_category_dict['description'] = kw.get(
+ 'action_category_description', None)
+ return self.admin_api.add_action_category_dict(user_id, intra_extension_id, action_category_dict) # noqa: E501
@controller.protected()
def get_action_category(self, context, **kw):
user_id = self._get_user_id_from_token(context.get('token_id'))
intra_extension_id = kw.get('intra_extension_id', None)
action_category_id = kw.get('action_category_id', None)
- return self.admin_api.get_action_categories_dict(user_id, intra_extension_id, action_category_id)
+ return self.admin_api.get_action_categories_dict(user_id, intra_extension_id, action_category_id) # noqa: E501
@controller.protected()
def del_action_category(self, context, **kw):
user_id = self._get_user_id_from_token(context.get('token_id'))
intra_extension_id = kw.get('intra_extension_id', None)
action_category_id = kw.get('action_category_id', None)
- self.admin_api.del_action_category(user_id, intra_extension_id, action_category_id)
+ self.admin_api.del_action_category(
+ user_id,
+ intra_extension_id,
+ action_category_id)
@controller.protected()
def set_action_category(self, context, **kw):
@@ -341,8 +386,9 @@ class IntraExtensions(controller.V3Controller):
action_category_id = kw.get('action_category_id', None)
action_category_dict = dict()
action_category_dict['name'] = kw.get('action_category_name', None)
- 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)
+ 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) # noqa: E501
# Perimeter functions
@controller.protected()
@@ -360,14 +406,14 @@ class IntraExtensions(controller.V3Controller):
subject_dict['description'] = kw.get('subject_description', None)
subject_dict['password'] = kw.get('subject_password', None)
subject_dict['email'] = kw.get('subject_email', None)
- return self.admin_api.add_subject_dict(user_id, intra_extension_id, subject_dict)
+ return self.admin_api.add_subject_dict(user_id, intra_extension_id, subject_dict) # noqa: E501
@controller.protected()
def get_subject(self, context, **kw):
user_id = self._get_user_id_from_token(context.get('token_id'))
intra_extension_id = kw.get('intra_extension_id', None)
subject_id = kw.get('subject_id', None)
- return self.admin_api.get_subject_dict(user_id, intra_extension_id, subject_id)
+ return self.admin_api.get_subject_dict(user_id, intra_extension_id, subject_id) # noqa: E501
@controller.protected()
def del_subject(self, context, **kw):
@@ -384,7 +430,7 @@ class IntraExtensions(controller.V3Controller):
subject_dict = dict()
subject_dict['name'] = kw.get('subject_name', None)
subject_dict['description'] = kw.get('subject_description', None)
- return self.admin_api.set_subject_dict(user_id, intra_extension_id, subject_id, subject_dict)
+ return self.admin_api.set_subject_dict(user_id, intra_extension_id, subject_id, subject_dict) # noqa: E501
@controller.protected()
def get_objects(self, context, **kw):
@@ -399,14 +445,14 @@ class IntraExtensions(controller.V3Controller):
object_dict = dict()
object_dict['name'] = kw.get('object_name', None)
object_dict['description'] = kw.get('object_description', None)
- return self.admin_api.add_object_dict(user_id, intra_extension_id, object_dict)
+ return self.admin_api.add_object_dict(user_id, intra_extension_id, object_dict) # noqa: E501
@controller.protected()
def get_object(self, context, **kw):
user_id = self._get_user_id_from_token(context.get('token_id'))
intra_extension_id = kw.get('intra_extension_id', None)
object_id = kw.get('object_id', None)
- return self.admin_api.get_object_dict(user_id, intra_extension_id, object_id)
+ return self.admin_api.get_object_dict(user_id, intra_extension_id, object_id) # noqa: E501
@controller.protected()
def del_object(self, context, **kw):
@@ -423,7 +469,7 @@ class IntraExtensions(controller.V3Controller):
object_dict = dict()
object_dict['name'] = kw.get('object_name', None)
object_dict['description'] = kw.get('object_description', None)
- return self.admin_api.set_object_dict(user_id, intra_extension_id, object_id, object_dict)
+ return self.admin_api.set_object_dict(user_id, intra_extension_id, object_id, object_dict) # noqa: E501
@controller.protected()
def get_actions(self, context, **kw):
@@ -438,14 +484,14 @@ class IntraExtensions(controller.V3Controller):
action_dict = dict()
action_dict['name'] = kw.get('action_name', None)
action_dict['description'] = kw.get('action_description', None)
- return self.admin_api.add_action_dict(user_id, intra_extension_id, action_dict)
+ return self.admin_api.add_action_dict(user_id, intra_extension_id, action_dict) # noqa: E501
@controller.protected()
def get_action(self, context, **kw):
user_id = self._get_user_id_from_token(context.get('token_id'))
intra_extension_id = kw.get('intra_extension_id', None)
action_id = kw.get('action_id', None)
- return self.admin_api.get_action_dict(user_id, intra_extension_id, action_id)
+ return self.admin_api.get_action_dict(user_id, intra_extension_id, action_id) # noqa: E501
@controller.protected()
def del_action(self, context, **kw):
@@ -462,7 +508,7 @@ class IntraExtensions(controller.V3Controller):
action_dict = dict()
action_dict['name'] = kw.get('action_name', None)
action_dict['description'] = kw.get('action_description', None)
- return self.admin_api.set_action_dict(user_id, intra_extension_id, action_id, action_dict)
+ return self.admin_api.set_action_dict(user_id, intra_extension_id, action_id, action_dict) # noqa: E501
# Scope functions
@controller.protected()
@@ -470,7 +516,7 @@ class IntraExtensions(controller.V3Controller):
user_id = self._get_user_id_from_token(context.get('token_id'))
intra_extension_id = kw.get('intra_extension_id', None)
subject_category_id = kw.get('subject_category_id', None)
- return self.admin_api.get_subject_scopes_dict(user_id, intra_extension_id, subject_category_id)
+ return self.admin_api.get_subject_scopes_dict(user_id, intra_extension_id, subject_category_id) # noqa: E501
@controller.protected()
def add_subject_scope(self, context, **kw):
@@ -479,8 +525,9 @@ class IntraExtensions(controller.V3Controller):
subject_category_id = kw.get('subject_category_id', None)
subject_scope_dict = dict()
subject_scope_dict['name'] = kw.get('subject_scope_name', None)
- 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)
+ 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) # noqa: E501
@controller.protected()
def get_subject_scope(self, context, **kw):
@@ -488,7 +535,7 @@ class IntraExtensions(controller.V3Controller):
intra_extension_id = kw.get('intra_extension_id', None)
subject_category_id = kw.get('subject_category_id', None)
subject_scope_id = kw.get('subject_scope_id', None)
- return self.admin_api.get_subject_scope_dict(user_id, intra_extension_id, subject_category_id, subject_scope_id)
+ return self.admin_api.get_subject_scope_dict(user_id, intra_extension_id, subject_category_id, subject_scope_id) # noqa: E501
@controller.protected()
def del_subject_scope(self, context, **kw):
@@ -496,7 +543,11 @@ class IntraExtensions(controller.V3Controller):
intra_extension_id = kw.get('intra_extension_id', None)
subject_category_id = kw.get('subject_category_id', None)
subject_scope_id = kw.get('subject_scope_id', None)
- self.admin_api.del_subject_scope(user_id, intra_extension_id, subject_category_id, subject_scope_id)
+ self.admin_api.del_subject_scope(
+ user_id,
+ intra_extension_id,
+ subject_category_id,
+ subject_scope_id)
@controller.protected()
def set_subject_scope(self, context, **kw):
@@ -506,15 +557,16 @@ class IntraExtensions(controller.V3Controller):
subject_scope_id = kw.get('subject_scope_id', None)
subject_scope_dict = dict()
subject_scope_dict['name'] = kw.get('subject_scope_name', None)
- 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)
+ 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) # noqa: E501
@controller.protected()
def get_object_scopes(self, context, **kw):
user_id = self._get_user_id_from_token(context.get('token_id'))
intra_extension_id = kw.get('intra_extension_id', None)
object_category_id = kw.get('object_category_id', None)
- return self.admin_api.get_object_scopes_dict(user_id, intra_extension_id, object_category_id)
+ return self.admin_api.get_object_scopes_dict(user_id, intra_extension_id, object_category_id) # noqa: E501
@controller.protected()
def add_object_scope(self, context, **kw):
@@ -523,8 +575,9 @@ class IntraExtensions(controller.V3Controller):
object_category_id = kw.get('object_category_id', None)
object_scope_dict = dict()
object_scope_dict['name'] = kw.get('object_scope_name', None)
- object_scope_dict['description'] = kw.get('object_scope_description', None)
- return self.admin_api.add_object_scope_dict(user_id, intra_extension_id, object_category_id, object_scope_dict)
+ object_scope_dict['description'] = kw.get(
+ 'object_scope_description', None)
+ return self.admin_api.add_object_scope_dict(user_id, intra_extension_id, object_category_id, object_scope_dict) # noqa: E501
@controller.protected()
def get_object_scope(self, context, **kw):
@@ -532,7 +585,7 @@ class IntraExtensions(controller.V3Controller):
intra_extension_id = kw.get('intra_extension_id', None)
object_category_id = kw.get('object_category_id', None)
object_scope_id = kw.get('object_scope_id', None)
- return self.admin_api.get_object_scope_dict(user_id, intra_extension_id, object_category_id, object_scope_id)
+ return self.admin_api.get_object_scope_dict(user_id, intra_extension_id, object_category_id, object_scope_id) # noqa: E501
@controller.protected()
def del_object_scope(self, context, **kw):
@@ -540,7 +593,11 @@ class IntraExtensions(controller.V3Controller):
intra_extension_id = kw.get('intra_extension_id', None)
object_category_id = kw.get('object_category_id', None)
object_scope_id = kw.get('object_scope_id', None)
- self.admin_api.del_object_scope(user_id, intra_extension_id, object_category_id, object_scope_id)
+ self.admin_api.del_object_scope(
+ user_id,
+ intra_extension_id,
+ object_category_id,
+ object_scope_id)
@controller.protected()
def set_object_scope(self, context, **kw):
@@ -550,15 +607,16 @@ class IntraExtensions(controller.V3Controller):
object_scope_id = kw.get('object_scope_id', None)
object_scope_dict = dict()
object_scope_dict['name'] = kw.get('object_scope_name', None)
- 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)
+ 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) # noqa: E501
@controller.protected()
def get_action_scopes(self, context, **kw):
user_id = self._get_user_id_from_token(context.get('token_id'))
intra_extension_id = kw.get('intra_extension_id', None)
action_category_id = kw.get('action_category_id', None)
- return self.admin_api.get_action_scopes_dict(user_id, intra_extension_id, action_category_id)
+ return self.admin_api.get_action_scopes_dict(user_id, intra_extension_id, action_category_id) # noqa: E501
@controller.protected()
def add_action_scope(self, context, **kw):
@@ -567,8 +625,9 @@ class IntraExtensions(controller.V3Controller):
action_category_id = kw.get('action_category_id', None)
action_scope_dict = dict()
action_scope_dict['name'] = kw.get('action_scope_name', None)
- action_scope_dict['description'] = kw.get('action_scope_description', None)
- return self.admin_api.add_action_scope_dict(user_id, intra_extension_id, action_category_id, action_scope_dict)
+ action_scope_dict['description'] = kw.get(
+ 'action_scope_description', None)
+ return self.admin_api.add_action_scope_dict(user_id, intra_extension_id, action_category_id, action_scope_dict) # noqa: E501
@controller.protected()
def get_action_scope(self, context, **kw):
@@ -576,7 +635,7 @@ class IntraExtensions(controller.V3Controller):
intra_extension_id = kw.get('intra_extension_id', None)
action_category_id = kw.get('action_category_id', None)
action_scope_id = kw.get('action_scope_id', None)
- return self.admin_api.get_action_scope_dict(user_id, intra_extension_id, action_category_id, action_scope_id)
+ return self.admin_api.get_action_scope_dict(user_id, intra_extension_id, action_category_id, action_scope_id) # noqa: E501
@controller.protected()
def del_action_scope(self, context, **kw):
@@ -584,7 +643,11 @@ class IntraExtensions(controller.V3Controller):
intra_extension_id = kw.get('intra_extension_id', None)
action_category_id = kw.get('action_category_id', None)
action_scope_id = kw.get('action_scope_id', None)
- self.admin_api.del_action_scope(user_id, intra_extension_id, action_category_id, action_scope_id)
+ self.admin_api.del_action_scope(
+ user_id,
+ intra_extension_id,
+ action_category_id,
+ action_scope_id)
@controller.protected()
def set_action_scope(self, context, **kw):
@@ -594,8 +657,9 @@ class IntraExtensions(controller.V3Controller):
action_scope_id = kw.get('action_scope_id', None)
action_scope_dict = dict()
action_scope_dict['name'] = kw.get('action_scope_name', None)
- 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)
+ 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) # noqa: E501
# Assignment functions
@@ -606,7 +670,7 @@ class IntraExtensions(controller.V3Controller):
subject_id = kw.get('subject_id', None)
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)
+ return self.admin_api.add_subject_assignment_list(user_id, intra_extension_id, subject_id, subject_category_id, subject_scope_id) # noqa: E501
@controller.protected()
def get_subject_assignment(self, context, **kw):
@@ -614,7 +678,7 @@ class IntraExtensions(controller.V3Controller):
intra_extension_id = kw.get('intra_extension_id', None)
subject_id = kw.get('subject_id', None)
subject_category_id = kw.get('subject_category_id', None)
- return self.admin_api.get_subject_assignment_list(user_id, intra_extension_id, subject_id, subject_category_id)
+ return self.admin_api.get_subject_assignment_list(user_id, intra_extension_id, subject_id, subject_category_id) # noqa: E501
@controller.protected()
def del_subject_assignment(self, context, **kw):
@@ -623,7 +687,12 @@ class IntraExtensions(controller.V3Controller):
subject_id = kw.get('subject_id', None)
subject_category_id = kw.get('subject_category_id', None)
subject_scope_id = kw.get('subject_scope_id', None)
- self.admin_api.del_subject_assignment(user_id, intra_extension_id, subject_id, subject_category_id, subject_scope_id)
+ self.admin_api.del_subject_assignment(
+ user_id,
+ intra_extension_id,
+ subject_id,
+ subject_category_id,
+ subject_scope_id)
@controller.protected()
def add_object_assignment(self, context, **kw):
@@ -632,7 +701,7 @@ class IntraExtensions(controller.V3Controller):
object_id = kw.get('object_id', None)
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)
+ return self.admin_api.add_object_assignment_list(user_id, intra_extension_id, object_id, object_category_id, object_scope_id) # noqa: E501
@controller.protected()
def get_object_assignment(self, context, **kw):
@@ -640,7 +709,7 @@ class IntraExtensions(controller.V3Controller):
intra_extension_id = kw.get('intra_extension_id', None)
object_id = kw.get('object_id', None)
object_category_id = kw.get('object_category_id', None)
- return self.admin_api.get_object_assignment_list(user_id, intra_extension_id, object_id, object_category_id)
+ return self.admin_api.get_object_assignment_list(user_id, intra_extension_id, object_id, object_category_id) # noqa: E501
@controller.protected()
def del_object_assignment(self, context, **kw):
@@ -649,7 +718,12 @@ class IntraExtensions(controller.V3Controller):
object_id = kw.get('object_id', None)
object_category_id = kw.get('object_category_id', None)
object_scope_id = kw.get('object_scope_id', None)
- self.admin_api.del_object_assignment(user_id, intra_extension_id, object_id, object_category_id, object_scope_id)
+ self.admin_api.del_object_assignment(
+ user_id,
+ intra_extension_id,
+ object_id,
+ object_category_id,
+ object_scope_id)
@controller.protected()
def add_action_assignment(self, context, **kw):
@@ -658,7 +732,7 @@ class IntraExtensions(controller.V3Controller):
action_id = kw.get('action_id', None)
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)
+ return self.admin_api.add_action_assignment_list(user_id, intra_extension_id, action_id, action_category_id, action_scope_id) # noqa: E501
@controller.protected()
def get_action_assignment(self, context, **kw):
@@ -666,7 +740,7 @@ class IntraExtensions(controller.V3Controller):
intra_extension_id = kw.get('intra_extension_id', None)
action_id = kw.get('action_id', None)
action_category_id = kw.get('action_category_id', None)
- return self.admin_api.get_action_assignment_list(user_id, intra_extension_id, action_id, action_category_id)
+ return self.admin_api.get_action_assignment_list(user_id, intra_extension_id, action_id, action_category_id) # noqa: E501
@controller.protected()
def del_action_assignment(self, context, **kw):
@@ -675,7 +749,12 @@ class IntraExtensions(controller.V3Controller):
action_id = kw.get('action_id', None)
action_category_id = kw.get('action_category_id', None)
action_scope_id = kw.get('action_scope_id', None)
- self.admin_api.del_action_assignment(user_id, intra_extension_id, action_id, action_category_id, action_scope_id)
+ self.admin_api.del_action_assignment(
+ user_id,
+ intra_extension_id,
+ action_id,
+ action_category_id,
+ action_scope_id)
# Metarule functions
@@ -683,20 +762,20 @@ class IntraExtensions(controller.V3Controller):
def get_aggregation_algorithm(self, context, **kw):
user_id = self._get_user_id_from_token(context.get('token_id'))
intra_extension_id = kw.get('intra_extension_id', None)
- return self.admin_api.get_aggregation_algorithm_id(user_id, intra_extension_id)
+ return self.admin_api.get_aggregation_algorithm_id(user_id, intra_extension_id) # noqa: E501
@controller.protected()
def set_aggregation_algorithm(self, context, **kw):
user_id = self._get_user_id_from_token(context.get('token_id'))
intra_extension_id = kw.get('intra_extension_id', None)
aggregation_algorithm_id = kw.get('aggregation_algorithm_id', None)
- return self.admin_api.set_aggregation_algorithm_id(user_id, intra_extension_id, aggregation_algorithm_id)
+ return self.admin_api.set_aggregation_algorithm_id(user_id, intra_extension_id, aggregation_algorithm_id) # noqa: E501
@controller.protected()
def get_sub_meta_rules(self, context, **kw):
user_id = self._get_user_id_from_token(context.get('token_id'))
intra_extension_id = kw.get('intra_extension_id', None)
- return self.admin_api.get_sub_meta_rules_dict(user_id, intra_extension_id)
+ return self.admin_api.get_sub_meta_rules_dict(user_id, intra_extension_id) # noqa: E501
@controller.protected()
def add_sub_meta_rule(self, context, **kw):
@@ -704,25 +783,32 @@ class IntraExtensions(controller.V3Controller):
intra_extension_id = kw.get('intra_extension_id', None)
sub_meta_rule_dict = dict()
sub_meta_rule_dict['name'] = kw.get('sub_meta_rule_name', None)
- sub_meta_rule_dict['algorithm'] = kw.get('sub_meta_rule_algorithm', None)
- sub_meta_rule_dict['subject_categories'] = kw.get('sub_meta_rule_subject_categories', None)
- sub_meta_rule_dict['object_categories'] = kw.get('sub_meta_rule_object_categories', None)
- sub_meta_rule_dict['action_categories'] = kw.get('sub_meta_rule_action_categories', None)
- return self.admin_api.add_sub_meta_rule_dict(user_id, intra_extension_id, sub_meta_rule_dict)
+ sub_meta_rule_dict['algorithm'] = kw.get(
+ 'sub_meta_rule_algorithm', None)
+ sub_meta_rule_dict['subject_categories'] = kw.get(
+ 'sub_meta_rule_subject_categories', None)
+ sub_meta_rule_dict['object_categories'] = kw.get(
+ 'sub_meta_rule_object_categories', None)
+ sub_meta_rule_dict['action_categories'] = kw.get(
+ 'sub_meta_rule_action_categories', None)
+ return self.admin_api.add_sub_meta_rule_dict(user_id, intra_extension_id, sub_meta_rule_dict) # noqa: E501
@controller.protected()
def get_sub_meta_rule(self, context, **kw):
user_id = self._get_user_id_from_token(context.get('token_id'))
intra_extension_id = kw.get('intra_extension_id', None)
sub_meta_rule_id = kw.get('sub_meta_rule_id', None)
- return self.admin_api.get_sub_meta_rule_dict(user_id, intra_extension_id, sub_meta_rule_id)
+ return self.admin_api.get_sub_meta_rule_dict(user_id, intra_extension_id, sub_meta_rule_id) # noqa: E501
@controller.protected()
def del_sub_meta_rule(self, context, **kw):
user_id = self._get_user_id_from_token(context.get('token_id'))
intra_extension_id = kw.get('intra_extension_id', None)
sub_meta_rule_id = kw.get('sub_meta_rule_id', None)
- self.admin_api.del_sub_meta_rule(user_id, intra_extension_id, sub_meta_rule_id)
+ self.admin_api.del_sub_meta_rule(
+ user_id,
+ intra_extension_id,
+ sub_meta_rule_id)
@controller.protected()
def set_sub_meta_rule(self, context, **kw):
@@ -731,11 +817,15 @@ class IntraExtensions(controller.V3Controller):
sub_meta_rule_id = kw.get('sub_meta_rule_id', None)
sub_meta_rule_dict = dict()
sub_meta_rule_dict['name'] = kw.get('sub_meta_rule_name', None)
- sub_meta_rule_dict['algorithm'] = kw.get('sub_meta_rule_algorithm', None)
- sub_meta_rule_dict['subject_categories'] = kw.get('sub_meta_rule_subject_categories', None)
- sub_meta_rule_dict['object_categories'] = kw.get('sub_meta_rule_object_categories', None)
- sub_meta_rule_dict['action_categories'] = kw.get('sub_meta_rule_action_categories', None)
- return self.admin_api.set_sub_meta_rule_dict(user_id, intra_extension_id, sub_meta_rule_id, sub_meta_rule_dict)
+ sub_meta_rule_dict['algorithm'] = kw.get(
+ 'sub_meta_rule_algorithm', None)
+ sub_meta_rule_dict['subject_categories'] = kw.get(
+ 'sub_meta_rule_subject_categories', None)
+ sub_meta_rule_dict['object_categories'] = kw.get(
+ 'sub_meta_rule_object_categories', None)
+ sub_meta_rule_dict['action_categories'] = kw.get(
+ 'sub_meta_rule_action_categories', None)
+ return self.admin_api.set_sub_meta_rule_dict(user_id, intra_extension_id, sub_meta_rule_id, sub_meta_rule_dict) # noqa: E501
# Rules functions
@controller.protected()
@@ -743,7 +833,7 @@ class IntraExtensions(controller.V3Controller):
user_id = self._get_user_id_from_token(context.get('token_id'))
intra_extension_id = kw.get('intra_extension_id', None)
sub_meta_rule_id = kw.get('sub_meta_rule_id', None)
- return self.admin_api.get_rules_dict(user_id, intra_extension_id, sub_meta_rule_id)
+ return self.admin_api.get_rules_dict(user_id, intra_extension_id, sub_meta_rule_id) # noqa: E501
@controller.protected()
def add_rule(self, context, **kw):
@@ -754,8 +844,9 @@ class IntraExtensions(controller.V3Controller):
object_category_list = kw.get('object_categories', [])
action_category_list = kw.get('action_categories', [])
enabled_bool = kw.get('enabled', True)
- rule_list = subject_category_list + action_category_list + object_category_list + [enabled_bool, ]
- return self.admin_api.add_rule_dict(user_id, intra_extension_id, sub_meta_rule_id, rule_list)
+ rule_list = subject_category_list + action_category_list + \
+ object_category_list + [enabled_bool, ]
+ return self.admin_api.add_rule_dict(user_id, intra_extension_id, sub_meta_rule_id, rule_list) # noqa: E501
@controller.protected()
def get_rule(self, context, **kw):
@@ -763,7 +854,7 @@ class IntraExtensions(controller.V3Controller):
intra_extension_id = kw.get('intra_extension_id', None)
sub_meta_rule_id = kw.get('sub_meta_rule_id', None)
rule_id = kw.get('rule_id', None)
- return self.admin_api.get_rule_dict(user_id, intra_extension_id, sub_meta_rule_id, rule_id)
+ return self.admin_api.get_rule_dict(user_id, intra_extension_id, sub_meta_rule_id, rule_id) # noqa: E501
@controller.protected()
def del_rule(self, context, **kw):
@@ -771,7 +862,11 @@ class IntraExtensions(controller.V3Controller):
intra_extension_id = kw.get('intra_extension_id', None)
sub_meta_rule_id = kw.get('sub_meta_rule_id', None)
rule_id = kw.get('rule_id', None)
- self.admin_api.del_rule(user_id, intra_extension_id, sub_meta_rule_id, rule_id)
+ self.admin_api.del_rule(
+ user_id,
+ intra_extension_id,
+ sub_meta_rule_id,
+ rule_id)
@controller.protected()
def set_rule(self, context, **kw):
@@ -783,11 +878,12 @@ 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
- return self.admin_api.set_rule_dict(user_id, intra_extension_id, sub_meta_rule_id, rule_id, rule_list)
+ rule_list = subject_category_list + \
+ action_category_list + object_category_list
+ return self.admin_api.set_rule_dict(user_id, intra_extension_id, sub_meta_rule_id, rule_id, rule_list) # noqa: E501
-@dependency.requires('authz_api')
+@dependency.requires('authz_api') # noqa: F405
class InterExtensions(controller.V3Controller):
def __init__(self):
@@ -795,7 +891,8 @@ class InterExtensions(controller.V3Controller):
def _get_user_from_token(self, token_id):
response = self.token_provider_api.validate_token(token_id)
- token_ref = token_model.KeystoneToken(token_id=token_id, token_data=response)
+ token_ref = token_model.KeystoneToken(
+ token_id=token_id, token_data=response)
return token_ref['user']
# @controller.protected()
@@ -824,10 +921,11 @@ class InterExtensions(controller.V3Controller):
# user = self._get_user_from_token(context.get('token_id'))
# if 'inter_extension_id' not in kw:
# raise exception.Error
- # return self.interextension_api.delete_inter_extension(kw['inter_extension_id'])
+ # return
+ # self.interextension_api.delete_inter_extension(kw['inter_extension_id'])
-@dependency.requires('moonlog_api', 'authz_api')
+@dependency.requires('moonlog_api', 'authz_api') # noqa: F405
class Logs(controller.V3Controller):
def __init__(self):
@@ -835,7 +933,8 @@ class Logs(controller.V3Controller):
def _get_user_id_from_token(self, token_id):
response = self.token_provider_api.validate_token(token_id)
- token_ref = token_model.KeystoneToken(token_id=token_id, token_data=response)
+ token_ref = token_model.KeystoneToken(
+ token_id=token_id, token_data=response)
return token_ref['user']
@controller.protected()
@@ -845,7 +944,7 @@ class Logs(controller.V3Controller):
return self.moonlog_api.get_logs(user_id, options)
-@dependency.requires('identity_api', "token_provider_api", "resource_api")
+@dependency.requires('identity_api', "token_provider_api", "resource_api") # noqa: F405
class MoonAuth(controller.V3Controller):
def __init__(self):
@@ -889,7 +988,8 @@ class MoonAuth(controller.V3Controller):
else:
message = {
"error": {
- "message": "Unable to find project {}".format(kw['project']),
+ "message":
+ "Unable to find project {}".format(kw['project']),
"code": 200,
"title": "UnScopedToken"
}}
@@ -912,9 +1012,10 @@ class MoonAuth(controller.V3Controller):
'message': message
}
try:
- _result["roles"] = map(lambda x: x['name'], _data["token"]["roles"])
+ _result["roles"] = map(
+ lambda x: x['name'],
+ _data["token"]["roles"])
except KeyError:
pass
return _result
return {"token": None, 'message': req.json()}
-
diff --git a/deploy/adapters/ansible/openstack_mitaka_xenial/roles/moon/files/get_deb_depends.py b/deploy/adapters/ansible/openstack_mitaka_xenial/roles/moon/files/get_deb_depends.py
index 05fc5d46..2707f574 100644
--- a/deploy/adapters/ansible/openstack_mitaka_xenial/roles/moon/files/get_deb_depends.py
+++ b/deploy/adapters/ansible/openstack_mitaka_xenial/roles/moon/files/get_deb_depends.py
@@ -6,7 +6,13 @@ import subprocess
pkts = []
for arg in sys.argv[1:]:
- proc = subprocess.Popen(["dpkg-deb", "--info", arg], stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ proc = subprocess.Popen(
+ ["dpkg-deb",
+ "--info",
+ arg],
+ stdin=None,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
out = proc.stdout.read()
err = proc.stderr.read()
if err:
diff --git a/deploy/adapters/ansible/roles/odl_cluster/files/recover_network.py b/deploy/adapters/ansible/roles/odl_cluster/files/recover_network.py
index 8d48ac1c..0b11b6df 100755
--- a/deploy/adapters/ansible/roles/odl_cluster/files/recover_network.py
+++ b/deploy/adapters/ansible/roles/odl_cluster/files/recover_network.py
@@ -6,21 +6,25 @@ import log as logging
LOG = logging.getLogger("net-recover")
config_path = os.path.join(os.path.dirname(__file__), "network.cfg")
+
def setup_bondings(bond_mappings):
print bond_mappings
+
def add_ovs_port(ovs_br, ifname, uplink, vlan_id=None):
LOG.info("add_ovs_port enter")
cmd = "ovs-vsctl --may-exist add-port %s %s" % (ovs_br, ifname)
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)
+
def setup_ips(ip_settings, sys_intf_mappings):
LOG.info("setup_ips enter")
for intf_info in ip_settings.values():
@@ -31,24 +35,27 @@ 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: E501
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)
LOG.info("setup_ips: cmd=%s" % cmd)
os.system(cmd)
+
def setup_intfs(sys_intf_mappings, uplink_map):
LOG.info("setup_intfs enter")
for intf_name, intf_info in sys_intf_mappings.items():
if intf_info["type"] == "ovs":
add_ovs_port(
- intf_info["interface"],
- intf_name,
- uplink_map[intf_info["interface"]],
- vlan_id=intf_info.get("vlan_tag"))
+ intf_info["interface"],
+ intf_name,
+ uplink_map[intf_info["interface"]],
+ vlan_id=intf_info.get("vlan_tag"))
else:
pass
+
def main(config):
uplink_map = {}
setup_bondings(config["bond_mappings"])
@@ -60,6 +67,7 @@ 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")
config = yaml.load(open(config_path))
main(config)
diff --git a/deploy/adapters/ansible/roles/odl_cluster/files/recover_network_odl_l3.py b/deploy/adapters/ansible/roles/odl_cluster/files/recover_network_odl_l3.py
index 7bef1052..ec7f7c6b 100755
--- a/deploy/adapters/ansible/roles/odl_cluster/files/recover_network_odl_l3.py
+++ b/deploy/adapters/ansible/roles/odl_cluster/files/recover_network_odl_l3.py
@@ -6,25 +6,29 @@ import log as logging
LOG = logging.getLogger("net-recover-odl-l3")
config_path = os.path.join(os.path.dirname(__file__), "network.cfg")
+
def setup_bondings(bond_mappings):
print 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"]
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: E501
cmd += "route del default;"
- 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')
LOG.info("setup_ips_new: cmd=%s" % cmd)
os.system(cmd)
+
def main(config):
- setup_ips_new(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")
config = yaml.load(open(config_path))
main(config)
diff --git a/deploy/adapters/ansible/roles/odl_cluster/files/setup_networks_odl_l3.py b/deploy/adapters/ansible/roles/odl_cluster/files/setup_networks_odl_l3.py
index 22797413..cf8779d4 100644
--- a/deploy/adapters/ansible/roles/odl_cluster/files/setup_networks_odl_l3.py
+++ b/deploy/adapters/ansible/roles/odl_cluster/files/setup_networks_odl_l3.py
@@ -6,33 +6,41 @@ import log as logging
LOG = logging.getLogger("net-init-l3")
config_path = os.path.join(os.path.dirname(__file__), "network.cfg")
+
def setup_bondings(bond_mappings):
print bond_mappings
+
def add_vlan_link(interface, ifname, vlan_id):
LOG.info("add_vlan_link enter")
- cmd = "ip link add link %s name %s type vlan id %s; " % (ifname, interface, vlan_id)
+ cmd = "ip link add link %s name %s type vlan id %s; " % (
+ ifname, interface, vlan_id)
cmd += "ip link set %s up; ip link set %s up" % (interface, ifname)
LOG.info("add_vlan_link: cmd=%s" % cmd)
os.system(cmd)
-#def add_ovs_port(ovs_br, ifname, uplink, vlan_id=None):
+# def add_ovs_port(ovs_br, ifname, uplink, vlan_id=None):
# LOG.info("add_ovs_port enter")
# cmd = "ovs-vsctl --may-exist add-port %s %s" % (ovs_br, ifname)
# 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}'`;" \
# % (ifname, uplink)
# cmd += "ip link set %s up;" % ifname
# LOG.info("add_ovs_port: cmd=%s" % cmd)
# os.system(cmd)
+
def setup_intfs(sys_intf_mappings, uplink_map):
LOG.info("setup_intfs enter")
for intf_name, intf_info in sys_intf_mappings.items():
if intf_info["type"] == "vlan":
- add_vlan_link(intf_name, intf_info["interface"], intf_info["vlan_tag"])
+ add_vlan_link(
+ intf_name,
+ intf_info["interface"],
+ intf_info["vlan_tag"])
# elif intf_info["type"] == "ovs":
# add_ovs_port(
# intf_info["interface"],
@@ -42,6 +50,7 @@ def setup_intfs(sys_intf_mappings, uplink_map):
else:
pass
+
def setup_ips(ip_settings, sys_intf_mappings):
LOG.info("setup_ips enter")
for intf_info in ip_settings.values():
@@ -53,28 +62,34 @@ 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: E501
# 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)
LOG.info("setup_ips: cmd=%s" % cmd)
os.system(cmd)
+
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"]
# 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)
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: E501
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"], intf_name)
+ 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)
os.system(cmd)
+
def main(config):
uplink_map = {}
setup_bondings(config["bond_mappings"])
@@ -86,6 +101,7 @@ 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")
config = yaml.load(open(config_path))
main(config)
diff --git a/deploy/adapters/ansible/roles/open-contrail/files/recover_network_opencontrail.py b/deploy/adapters/ansible/roles/open-contrail/files/recover_network_opencontrail.py
index e829b65c..bd40d0a4 100755
--- a/deploy/adapters/ansible/roles/open-contrail/files/recover_network_opencontrail.py
+++ b/deploy/adapters/ansible/roles/open-contrail/files/recover_network_opencontrail.py
@@ -6,27 +6,34 @@ import log as logging
LOG = logging.getLogger("net-recover-opencontrail")
config_path = os.path.join(os.path.dirname(__file__), "network.cfg")
+
def setup_bondings(bond_mappings):
print 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"]
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: E501
+ # 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')
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"],
+ intf_name)
+ # 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)
os.system(cmd)
def main(config):
- setup_ips_new(config)
+ setup_ips_new(config)
if __name__ == "__main__":
config = yaml.load(open(config_path))
diff --git a/deploy/adapters/ansible/roles/open-contrail/files/setup_networks_opencontrail.py b/deploy/adapters/ansible/roles/open-contrail/files/setup_networks_opencontrail.py
index fd7795af..7544932d 100755
--- a/deploy/adapters/ansible/roles/open-contrail/files/setup_networks_opencontrail.py
+++ b/deploy/adapters/ansible/roles/open-contrail/files/setup_networks_opencontrail.py
@@ -6,33 +6,41 @@ import log as logging
LOG = logging.getLogger("net-init-opencontrail")
config_path = os.path.join(os.path.dirname(__file__), "network.cfg")
+
def setup_bondings(bond_mappings):
print bond_mappings
+
def add_vlan_link(interface, ifname, vlan_id):
LOG.info("add_vlan_link enter")
- cmd = "ip link add link %s name %s type vlan id %s; " % (ifname, interface, vlan_id)
+ cmd = "ip link add link %s name %s type vlan id %s; " % (
+ ifname, interface, vlan_id)
cmd += "ip link set %s up; ip link set %s up" % (interface, ifname)
LOG.info("add_vlan_link: cmd=%s" % cmd)
os.system(cmd)
-#def add_ovs_port(ovs_br, ifname, uplink, vlan_id=None):
+# def add_ovs_port(ovs_br, ifname, uplink, vlan_id=None):
# LOG.info("add_ovs_port enter")
# cmd = "ovs-vsctl --may-exist add-port %s %s" % (ovs_br, ifname)
# 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}'`;" \
# % (ifname, uplink)
# cmd += "ip link set %s up;" % ifname
# LOG.info("add_ovs_port: cmd=%s" % cmd)
# os.system(cmd)
+
def setup_intfs(sys_intf_mappings, uplink_map):
LOG.info("setup_intfs enter")
for intf_name, intf_info in sys_intf_mappings.items():
if intf_info["type"] == "vlan":
- add_vlan_link(intf_name, intf_info["interface"], intf_info["vlan_tag"])
+ add_vlan_link(
+ intf_name,
+ intf_info["interface"],
+ intf_info["vlan_tag"])
# elif intf_info["type"] == "ovs":
# add_ovs_port(
# intf_info["interface"],
@@ -42,6 +50,7 @@ def setup_intfs(sys_intf_mappings, uplink_map):
else:
pass
+
def setup_ips(ip_settings, sys_intf_mappings):
LOG.info("setup_ips enter")
for intf_info in ip_settings.values():
@@ -53,43 +62,52 @@ 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: E501
# 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)
LOG.info("setup_ips: cmd=%s" % cmd)
os.system(cmd)
+
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"]
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: E501
# 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')
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"],
+ intf_name)
+# 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)
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"]
cmd = "route del default;"
- cmd += "ip route add default via %s dev %s" % (config["ip_settings"]["br-prv"]["gw"], "vhost0")
+ cmd += "ip route add default via %s dev %s" % (
+ config["ip_settings"]["br-prv"]["gw"], "vhost0")
LOG.info("setup_default_router: cmd=%s" % cmd)
os.system(cmd)
+
def remove_ovs_kernel_mod(config):
LOG.info("remove_ovs_kernel_mod enter")
cmd = "rmmod vport_vxlan; rmmod openvswitch;"
LOG.info("remove_ovs_kernel_mod: cmd=%s" % cmd)
os.system(cmd)
+
def main(config):
uplink_map = {}
setup_bondings(config["bond_mappings"])
diff --git a/deploy/adapters/ansible/roles/setup-network/files/setup_networks/check_network.py b/deploy/adapters/ansible/roles/setup-network/files/setup_networks/check_network.py
index 72a5db97..a7e3b2fd 100644
--- a/deploy/adapters/ansible/roles/setup-network/files/setup_networks/check_network.py
+++ b/deploy/adapters/ansible/roles/setup-network/files/setup_networks/check_network.py
@@ -6,9 +6,14 @@ import log as logging
LOG = logging.getLogger("net-check")
+
def is_ip_reachable(ip):
cmd = "ping -c 2 %s" % ip
- process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=None, shell=True)
+ process = subprocess.Popen(
+ cmd,
+ stdout=subprocess.PIPE,
+ stderr=None,
+ shell=True)
output = process.communicate()[0]
if " 0% packet loss" in output:
@@ -21,6 +26,7 @@ def is_ip_reachable(ip):
return True
+
def is_host_ips_reachable(settings):
external = settings["br-prv"]["ip"]
external_gw = settings["br-prv"]["gw"]
@@ -28,9 +34,10 @@ def is_host_ips_reachable(settings):
mgmt = settings["mgmt"]["ip"]
return is_ip_reachable(external) \
- and is_ip_reachable(external_gw) \
- and is_ip_reachable(storage) \
- and is_ip_reachable(mgmt)
+ and is_ip_reachable(external_gw) \
+ and is_ip_reachable(storage) \
+ and is_ip_reachable(mgmt)
+
def main(hostname, config):
LOG.info("host is %s", hostname)
@@ -53,4 +60,3 @@ if __name__ == "__main__":
config.pop(hostname, None)
main(hostname, config)
-
diff --git a/deploy/adapters/ansible/roles/setup-network/files/setup_networks/log.py b/deploy/adapters/ansible/roles/setup-network/files/setup_networks/log.py
index fffeb589..a22ff0fe 100644
--- a/deploy/adapters/ansible/roles/setup-network/files/setup_networks/log.py
+++ b/deploy/adapters/ansible/roles/setup-network/files/setup_networks/log.py
@@ -1,12 +1,13 @@
import logging
import os
loggers = {}
-log_dir="/var/log/setup_network"
+log_dir = "/var/log/setup_network"
try:
os.makedirs(log_dir)
except:
pass
+
def getLogger(name):
if name in loggers:
return loggers[name]
@@ -29,7 +30,8 @@ def getLogger(name):
ch.setLevel(logging.ERROR)
# create formatter and add it to the handlers
- formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
+ formatter = logging.Formatter(
+ "%(asctime)s - %(name)s - %(levelname)s - %(message)s")
ch.setFormatter(formatter)
fh.setFormatter(formatter)
diff --git a/deploy/adapters/ansible/roles/setup-network/files/setup_networks/setup_networks.py b/deploy/adapters/ansible/roles/setup-network/files/setup_networks/setup_networks.py
index e58d6c72..a25d7ea9 100644
--- a/deploy/adapters/ansible/roles/setup-network/files/setup_networks/setup_networks.py
+++ b/deploy/adapters/ansible/roles/setup-network/files/setup_networks/setup_networks.py
@@ -6,42 +6,52 @@ import log as logging
LOG = logging.getLogger("net-init")
config_path = os.path.join(os.path.dirname(__file__), "network.cfg")
+
def setup_bondings(bond_mappings):
print bond_mappings
+
def add_vlan_link(interface, ifname, vlan_id):
LOG.info("add_vlan_link enter")
- cmd = "ip link add link %s name %s type vlan id %s; " % (ifname, interface, vlan_id)
+ cmd = "ip link add link %s name %s type vlan id %s; " % (
+ ifname, interface, vlan_id)
cmd += "ip link set %s up; ip link set %s up" % (interface, ifname)
LOG.info("add_vlan_link: cmd=%s" % cmd)
os.system(cmd)
+
def add_ovs_port(ovs_br, ifname, uplink, vlan_id=None):
LOG.info("add_ovs_port enter")
cmd = "ovs-vsctl --may-exist add-port %s %s" % (ovs_br, ifname)
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)
+
def setup_intfs(sys_intf_mappings, uplink_map):
LOG.info("setup_intfs enter")
for intf_name, intf_info in sys_intf_mappings.items():
if intf_info["type"] == "vlan":
- add_vlan_link(intf_name, intf_info["interface"], intf_info["vlan_tag"])
+ add_vlan_link(
+ intf_name,
+ intf_info["interface"],
+ intf_info["vlan_tag"])
elif intf_info["type"] == "ovs":
add_ovs_port(
- intf_info["interface"],
- intf_name,
- uplink_map[intf_info["interface"]],
- vlan_id=intf_info.get("vlan_tag"))
+ intf_info["interface"],
+ intf_name,
+ uplink_map[intf_info["interface"]],
+ vlan_id=intf_info.get("vlan_tag"))
else:
pass
+
def setup_ips(ip_settings, sys_intf_mappings):
LOG.info("setup_ips enter")
for intf_info in ip_settings.values():
@@ -51,13 +61,15 @@ 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: E501
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)
LOG.info("setup_ips: cmd=%s" % cmd)
os.system(cmd)
+
def main(config):
uplink_map = {}
setup_bondings(config["bond_mappings"])
@@ -68,6 +80,7 @@ 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")
config = yaml.load(open(config_path))
main(config)