aboutsummaryrefslogtreecommitdiffstats
path: root/deploy
diff options
context:
space:
mode:
authorJustin chi <chigang@huawei.com>2016-11-11 02:15:30 +0000
committerGerrit Code Review <gerrit@opnfv.org>2016-11-11 02:15:30 +0000
commit17328cc3f88131cfdfb0fe0833336a583a191f97 (patch)
tree858fc8a56cfe0ce2e28e61dd8d56ef519ba8dcf9 /deploy
parent9dc55a9dc191d61e35d34042afd310626cb32538 (diff)
parent404fcf8f737f405da7fd2e61441dd20a57d63935 (diff)
Merge "autopep8 make py files more standard"
Diffstat (limited to 'deploy')
-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.py29
-rw-r--r--deploy/adapters/ansible/openstack_mitaka_xenial/roles/moon/files/controllers.py382
-rw-r--r--deploy/adapters/ansible/openstack_mitaka_xenial/roles/moon/files/get_deb_depends.py7
-rw-r--r--deploy/adapters/ansible/openstack_newton_xenial/roles/moon/files/controllers.py382
-rw-r--r--deploy/adapters/ansible/openstack_newton_xenial/roles/moon/files/get_deb_depends.py7
-rwxr-xr-xdeploy/adapters/ansible/openstack_osp9/roles/onos_cluster/files/setup_networks/log.py6
-rwxr-xr-xdeploy/adapters/ansible/openstack_osp9/roles/onos_cluster/files/setup_networks/setup_networks.py29
-rwxr-xr-xdeploy/adapters/ansible/roles/odl_cluster/files/recover_network.py20
-rwxr-xr-xdeploy/adapters/ansible/roles/odl_cluster/files/recover_network_odl_l3.py10
-rw-r--r--deploy/adapters/ansible/roles/odl_cluster/files/setup_networks_odl_l3.py23
-rwxr-xr-xdeploy/adapters/ansible/roles/open-contrail/files/recover_network_opencontrail.py7
-rwxr-xr-xdeploy/adapters/ansible/roles/open-contrail/files/setup_networks_opencontrail.py26
-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.py29
-rw-r--r--deploy/client.py346
-rw-r--r--deploy/config_parse.py38
-rw-r--r--deploy/log.py6
-rw-r--r--deploy/rename_nics.py18
-rw-r--r--deploy/reset_compute.py23
-rw-r--r--deploy/restful.py1
-rw-r--r--deploy/setup_vnic.py13
-rwxr-xr-xdeploy/status_callback.py24
24 files changed, 952 insertions, 502 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..cdd4ae0d 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,16 +6,20 @@ 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)
@@ -23,25 +27,30 @@ def add_ovs_port(ovs_br, ifname, uplink, vlan_id=None):
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)
+ % (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 +60,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)
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"])
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..8171e238 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
@@ -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,7 +44,8 @@ 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)
@dependency.requires('tenant_api', 'resource_api')
@@ -54,7 +56,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 +65,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"):
tenants = self.resource_api.list_projects()
for tenant in tenants:
if tenant_id and tenant_id == tenant['id']:
@@ -80,7 +84,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 +93,8 @@ 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,12 @@ 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)
@controller.protected()
def get_tenant(self, context, **kw):
@@ -116,16 +125,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)
@@ -147,9 +159,11 @@ class Authz_v3(controller.V3Controller):
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)
except Exception as e:
return {'authz': False, 'comment': unicode(e)}
@@ -164,7 +178,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 +195,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)
@controller.protected()
def del_intra_extension(self, context, **kw):
@@ -219,8 +251,10 @@ 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)
@controller.protected()
def load_root_intra_extension(self, context, **kw):
@@ -231,7 +265,8 @@ 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)
@controller.protected()
def add_subject_category(self, context, **kw):
@@ -239,22 +274,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)
@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)
@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 +302,17 @@ 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)
@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)
@controller.protected()
def add_object_category(self, context, **kw):
@@ -278,22 +320,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)
@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)
@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 +348,17 @@ 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)
@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)
@controller.protected()
def add_action_category(self, context, **kw):
@@ -317,22 +366,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)
@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)
@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 +394,10 @@ 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)
# Perimeter functions
@controller.protected()
@@ -360,14 +415,16 @@ 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)
@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)
@controller.protected()
def del_subject(self, context, **kw):
@@ -384,7 +441,8 @@ 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)
@controller.protected()
def get_objects(self, context, **kw):
@@ -399,14 +457,16 @@ 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)
@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)
@controller.protected()
def del_object(self, context, **kw):
@@ -423,7 +483,8 @@ 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)
@controller.protected()
def get_actions(self, context, **kw):
@@ -438,14 +499,16 @@ 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)
@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)
@controller.protected()
def del_action(self, context, **kw):
@@ -462,7 +525,8 @@ 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)
# Scope functions
@controller.protected()
@@ -470,7 +534,8 @@ 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)
@controller.protected()
def add_subject_scope(self, context, **kw):
@@ -479,8 +544,10 @@ 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)
@controller.protected()
def get_subject_scope(self, context, **kw):
@@ -488,7 +555,8 @@ 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)
@controller.protected()
def del_subject_scope(self, context, **kw):
@@ -496,7 +564,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 +578,18 @@ 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)
@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)
@controller.protected()
def add_object_scope(self, context, **kw):
@@ -523,8 +598,10 @@ 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)
@controller.protected()
def get_object_scope(self, context, **kw):
@@ -532,7 +609,8 @@ 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)
@controller.protected()
def del_object_scope(self, context, **kw):
@@ -540,7 +618,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 +632,18 @@ 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)
@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)
@controller.protected()
def add_action_scope(self, context, **kw):
@@ -567,8 +652,10 @@ 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)
@controller.protected()
def get_action_scope(self, context, **kw):
@@ -576,7 +663,8 @@ 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)
@controller.protected()
def del_action_scope(self, context, **kw):
@@ -584,7 +672,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 +686,10 @@ 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)
# Assignment functions
@@ -606,7 +700,8 @@ 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)
@controller.protected()
def get_subject_assignment(self, context, **kw):
@@ -614,7 +709,8 @@ 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)
@controller.protected()
def del_subject_assignment(self, context, **kw):
@@ -623,7 +719,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 +733,8 @@ 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)
@controller.protected()
def get_object_assignment(self, context, **kw):
@@ -640,7 +742,8 @@ 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)
@controller.protected()
def del_object_assignment(self, context, **kw):
@@ -649,7 +752,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 +766,8 @@ 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)
@controller.protected()
def get_action_assignment(self, context, **kw):
@@ -666,7 +775,8 @@ 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)
@controller.protected()
def del_action_assignment(self, context, **kw):
@@ -675,7 +785,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 +798,23 @@ 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)
@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)
@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)
@controller.protected()
def add_sub_meta_rule(self, context, **kw):
@@ -704,25 +822,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)
@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)
@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 +856,16 @@ 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)
# Rules functions
@controller.protected()
@@ -743,7 +873,8 @@ 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)
@controller.protected()
def add_rule(self, context, **kw):
@@ -754,8 +885,10 @@ 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)
@controller.protected()
def get_rule(self, context, **kw):
@@ -763,7 +896,8 @@ 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)
@controller.protected()
def del_rule(self, context, **kw):
@@ -771,7 +905,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):
@@ -784,7 +922,8 @@ class IntraExtensions(controller.V3Controller):
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)
+ return self.admin_api.set_rule_dict(
+ user_id, intra_extension_id, sub_meta_rule_id, rule_id, rule_list)
@dependency.requires('authz_api')
@@ -795,7 +934,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,7 +964,8 @@ 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')
@@ -835,7 +976,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()
@@ -912,9 +1054,9 @@ 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..d510bcf4 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,12 @@ 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/openstack_newton_xenial/roles/moon/files/controllers.py b/deploy/adapters/ansible/openstack_newton_xenial/roles/moon/files/controllers.py
index 6da5b423..8171e238 100644
--- a/deploy/adapters/ansible/openstack_newton_xenial/roles/moon/files/controllers.py
+++ b/deploy/adapters/ansible/openstack_newton_xenial/roles/moon/files/controllers.py
@@ -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,7 +44,8 @@ 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)
@dependency.requires('tenant_api', 'resource_api')
@@ -54,7 +56,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 +65,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"):
tenants = self.resource_api.list_projects()
for tenant in tenants:
if tenant_id and tenant_id == tenant['id']:
@@ -80,7 +84,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 +93,8 @@ 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,12 @@ 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)
@controller.protected()
def get_tenant(self, context, **kw):
@@ -116,16 +125,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)
@@ -147,9 +159,11 @@ class Authz_v3(controller.V3Controller):
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)
except Exception as e:
return {'authz': False, 'comment': unicode(e)}
@@ -164,7 +178,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 +195,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)
@controller.protected()
def del_intra_extension(self, context, **kw):
@@ -219,8 +251,10 @@ 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)
@controller.protected()
def load_root_intra_extension(self, context, **kw):
@@ -231,7 +265,8 @@ 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)
@controller.protected()
def add_subject_category(self, context, **kw):
@@ -239,22 +274,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)
@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)
@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 +302,17 @@ 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)
@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)
@controller.protected()
def add_object_category(self, context, **kw):
@@ -278,22 +320,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)
@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)
@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 +348,17 @@ 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)
@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)
@controller.protected()
def add_action_category(self, context, **kw):
@@ -317,22 +366,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)
@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)
@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 +394,10 @@ 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)
# Perimeter functions
@controller.protected()
@@ -360,14 +415,16 @@ 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)
@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)
@controller.protected()
def del_subject(self, context, **kw):
@@ -384,7 +441,8 @@ 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)
@controller.protected()
def get_objects(self, context, **kw):
@@ -399,14 +457,16 @@ 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)
@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)
@controller.protected()
def del_object(self, context, **kw):
@@ -423,7 +483,8 @@ 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)
@controller.protected()
def get_actions(self, context, **kw):
@@ -438,14 +499,16 @@ 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)
@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)
@controller.protected()
def del_action(self, context, **kw):
@@ -462,7 +525,8 @@ 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)
# Scope functions
@controller.protected()
@@ -470,7 +534,8 @@ 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)
@controller.protected()
def add_subject_scope(self, context, **kw):
@@ -479,8 +544,10 @@ 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)
@controller.protected()
def get_subject_scope(self, context, **kw):
@@ -488,7 +555,8 @@ 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)
@controller.protected()
def del_subject_scope(self, context, **kw):
@@ -496,7 +564,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 +578,18 @@ 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)
@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)
@controller.protected()
def add_object_scope(self, context, **kw):
@@ -523,8 +598,10 @@ 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)
@controller.protected()
def get_object_scope(self, context, **kw):
@@ -532,7 +609,8 @@ 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)
@controller.protected()
def del_object_scope(self, context, **kw):
@@ -540,7 +618,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 +632,18 @@ 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)
@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)
@controller.protected()
def add_action_scope(self, context, **kw):
@@ -567,8 +652,10 @@ 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)
@controller.protected()
def get_action_scope(self, context, **kw):
@@ -576,7 +663,8 @@ 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)
@controller.protected()
def del_action_scope(self, context, **kw):
@@ -584,7 +672,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 +686,10 @@ 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)
# Assignment functions
@@ -606,7 +700,8 @@ 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)
@controller.protected()
def get_subject_assignment(self, context, **kw):
@@ -614,7 +709,8 @@ 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)
@controller.protected()
def del_subject_assignment(self, context, **kw):
@@ -623,7 +719,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 +733,8 @@ 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)
@controller.protected()
def get_object_assignment(self, context, **kw):
@@ -640,7 +742,8 @@ 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)
@controller.protected()
def del_object_assignment(self, context, **kw):
@@ -649,7 +752,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 +766,8 @@ 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)
@controller.protected()
def get_action_assignment(self, context, **kw):
@@ -666,7 +775,8 @@ 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)
@controller.protected()
def del_action_assignment(self, context, **kw):
@@ -675,7 +785,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 +798,23 @@ 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)
@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)
@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)
@controller.protected()
def add_sub_meta_rule(self, context, **kw):
@@ -704,25 +822,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)
@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)
@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 +856,16 @@ 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)
# Rules functions
@controller.protected()
@@ -743,7 +873,8 @@ 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)
@controller.protected()
def add_rule(self, context, **kw):
@@ -754,8 +885,10 @@ 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)
@controller.protected()
def get_rule(self, context, **kw):
@@ -763,7 +896,8 @@ 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)
@controller.protected()
def del_rule(self, context, **kw):
@@ -771,7 +905,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):
@@ -784,7 +922,8 @@ class IntraExtensions(controller.V3Controller):
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)
+ return self.admin_api.set_rule_dict(
+ user_id, intra_extension_id, sub_meta_rule_id, rule_id, rule_list)
@dependency.requires('authz_api')
@@ -795,7 +934,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,7 +964,8 @@ 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')
@@ -835,7 +976,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()
@@ -912,9 +1054,9 @@ 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_newton_xenial/roles/moon/files/get_deb_depends.py b/deploy/adapters/ansible/openstack_newton_xenial/roles/moon/files/get_deb_depends.py
index 05fc5d46..d510bcf4 100644
--- a/deploy/adapters/ansible/openstack_newton_xenial/roles/moon/files/get_deb_depends.py
+++ b/deploy/adapters/ansible/openstack_newton_xenial/roles/moon/files/get_deb_depends.py
@@ -6,7 +6,12 @@ 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/openstack_osp9/roles/onos_cluster/files/setup_networks/log.py b/deploy/adapters/ansible/openstack_osp9/roles/onos_cluster/files/setup_networks/log.py
index fffeb589..a22ff0fe 100755
--- a/deploy/adapters/ansible/openstack_osp9/roles/onos_cluster/files/setup_networks/log.py
+++ b/deploy/adapters/ansible/openstack_osp9/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_osp9/roles/onos_cluster/files/setup_networks/setup_networks.py b/deploy/adapters/ansible/openstack_osp9/roles/onos_cluster/files/setup_networks/setup_networks.py
index e58d6c72..cdd4ae0d 100755
--- a/deploy/adapters/ansible/openstack_osp9/roles/onos_cluster/files/setup_networks/setup_networks.py
+++ b/deploy/adapters/ansible/openstack_osp9/roles/onos_cluster/files/setup_networks/setup_networks.py
@@ -6,16 +6,20 @@ 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)
@@ -23,25 +27,30 @@ def add_ovs_port(ovs_br, ifname, uplink, vlan_id=None):
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)
+ % (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 +60,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)
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"])
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..2d793880 100755
--- a/deploy/adapters/ansible/roles/odl_cluster/files/recover_network.py
+++ b/deploy/adapters/ansible/roles/odl_cluster/files/recover_network.py
@@ -6,9 +6,11 @@ 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)
@@ -16,11 +18,12 @@ def add_ovs_port(ovs_br, ifname, uplink, vlan_id=None):
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)
+ % (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 +34,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)
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"])
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..48b4d48c 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,23 +6,27 @@ 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')
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")
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..08e3fbf1 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,17 +6,20 @@ 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:
@@ -28,11 +31,15 @@ def add_vlan_link(interface, ifname, vlan_id):
# 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 +49,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,13 +61,14 @@ 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)
# if "gw" in intf_info:
# cmd += "route del default;"
# 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"])
@@ -68,13 +77,15 @@ def setup_ips_new(config):
# % (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')
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')
LOG.info("setup_ips_new: cmd=%s" % cmd)
os.system(cmd)
+
def main(config):
uplink_map = {}
setup_bondings(config["bond_mappings"])
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..e3b1fe89 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,9 +6,11 @@ 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"])
@@ -19,14 +21,15 @@ def setup_ips_new(config):
#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"], 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..e57d7109 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,17 +6,20 @@ 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:
@@ -28,11 +31,15 @@ def add_vlan_link(interface, ifname, vlan_id):
# 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 +49,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,13 +61,14 @@ 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)
# if "gw" in intf_info:
# cmd += "route del default;"
# 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"])
@@ -70,26 +79,31 @@ def setup_ips_new(config):
# 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"], 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..cdd4ae0d 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,16 +6,20 @@ 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)
@@ -23,25 +27,30 @@ def add_ovs_port(ovs_br, ifname, uplink, vlan_id=None):
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)
+ % (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 +60,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)
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"])
diff --git a/deploy/client.py b/deploy/client.py
index f6a07a77..e380da0a 100644
--- a/deploy/client.py
+++ b/deploy/client.py
@@ -38,9 +38,11 @@ LOG = logging.getLogger(__name__)
from oslo_config import cfg
CONF = cfg.CONF
+
def byteify(input):
if isinstance(input, dict):
- return dict([(byteify(key),byteify(value)) for key,value in input.iteritems()])
+ return dict([(byteify(key), byteify(value))
+ for key, value in input.iteritems()])
elif isinstance(input, list):
return [byteify(element) for element in input]
elif isinstance(input, unicode):
@@ -50,209 +52,211 @@ def byteify(input):
opts = [
cfg.StrOpt('expansion',
- help='is this an expansion?',
- default='false'),
+ help='is this an expansion?',
+ default='false'),
cfg.StrOpt('compass_server',
- help='compass server url',
- default='http://127.0.0.1/api'),
+ help='compass server url',
+ default='http://127.0.0.1/api'),
cfg.StrOpt('compass_user_email',
- help='compass user email',
- default='admin@huawei.com'),
+ help='compass user email',
+ default='admin@huawei.com'),
cfg.StrOpt('compass_user_password',
- help='compass user password',
- default='admin'),
+ help='compass user password',
+ default='admin'),
cfg.StrOpt('switch_ips',
- help='comma seperated switch ips',
- default=''),
+ help='comma seperated switch ips',
+ default=''),
cfg.StrOpt('switch_credential',
- help='comma separated <credential key>=<credential value>',
- default='version=2c,community=public'),
+ help='comma separated <credential key>=<credential value>',
+ default='version=2c,community=public'),
cfg.IntOpt('switch_max_retries',
- help='max retries of poll switch',
- default=10),
+ help='max retries of poll switch',
+ default=10),
cfg.IntOpt('switch_retry_interval',
- help='interval to repoll switch',
- default=10),
+ help='interval to repoll switch',
+ default=10),
cfg.BoolOpt('poll_switches',
help='if the client polls switches',
default=True),
cfg.StrOpt('machines',
- help='comma separated mac addresses of machines',
- default=''),
+ help='comma separated mac addresses of machines',
+ default=''),
cfg.StrOpt('subnets',
- help='comma seperated subnets',
- default=''),
+ help='comma seperated subnets',
+ default=''),
cfg.StrOpt('adapter_name',
- help='adapter name',
- default=''),
+ help='adapter name',
+ default=''),
cfg.StrOpt('adapter_os_pattern',
- help='adapter os name',
- default=r'^(?i)centos.*'),
+ help='adapter os name',
+ default=r'^(?i)centos.*'),
cfg.StrOpt('adapter_target_system_pattern',
- help='adapter target system name',
- default='^openstack$'),
+ help='adapter target system name',
+ default='^openstack$'),
cfg.StrOpt('adapter_flavor_pattern',
- help='adapter flavor name',
- default='allinone'),
+ help='adapter flavor name',
+ default='allinone'),
cfg.StrOpt('cluster_name',
- help='cluster name',
- default='cluster1'),
+ help='cluster name',
+ default='cluster1'),
cfg.StrOpt('language',
- help='language',
- default='EN'),
+ help='language',
+ default='EN'),
cfg.StrOpt('timezone',
- help='timezone',
- default='GMT'),
+ help='timezone',
+ default='GMT'),
cfg.StrOpt('http_proxy',
- help='http proxy',
- default=''),
+ help='http proxy',
+ default=''),
cfg.StrOpt('https_proxy',
- help='https proxy',
- default=''),
+ help='https proxy',
+ default=''),
cfg.StrOpt('no_proxy',
- help='no proxy',
- default=''),
+ help='no proxy',
+ default=''),
cfg.StrOpt('ntp_server',
- help='ntp server',
- default=''),
+ help='ntp server',
+ default=''),
cfg.StrOpt('dns_servers',
- help='dns servers',
- default=''),
+ help='dns servers',
+ default=''),
cfg.StrOpt('domain',
- help='domain',
- default=''),
+ help='domain',
+ default=''),
cfg.StrOpt('search_path',
- help='search path',
- default=''),
+ help='search path',
+ default=''),
cfg.StrOpt('local_repo_url',
- help='local repo url',
- default=''),
+ help='local repo url',
+ default=''),
cfg.StrOpt('default_gateway',
- help='default gateway',
- default=''),
+ help='default gateway',
+ default=''),
cfg.StrOpt('server_credential',
- help=(
- 'server credential formatted as '
- '<username>=<password>'
- ),
- default='root=root'),
+ help=(
+ 'server credential formatted as '
+ '<username>=<password>'
+ ),
+ default='root=root'),
cfg.StrOpt('os_config_json_file',
- help='json formatted os config file',
- default=''),
+ help='json formatted os config file',
+ default=''),
cfg.StrOpt('service_credentials',
- help=(
- 'comma seperated service credentials formatted as '
- '<servicename>:<username>=<password>,...'
- ),
- default=''),
+ help=(
+ 'comma seperated service credentials formatted as '
+ '<servicename>:<username>=<password>,...'
+ ),
+ default=''),
cfg.StrOpt('console_credentials',
- help=(
- 'comma seperated console credential formated as '
- '<consolename>:<username>=<password>'
- ),
- default=''),
+ help=(
+ 'comma seperated console credential formated as '
+ '<consolename>:<username>=<password>'
+ ),
+ default=''),
cfg.StrOpt('hostnames',
- help='comma seperated hostname',
- default=''),
+ help='comma seperated hostname',
+ default=''),
cfg.StrOpt('host_networks',
- help=(
- 'semicomma seperated host name and its networks '
- '<hostname>:<interface_name>=<ip>|<is_mgmt>|<is_promiscuous>,...'
- ),
- default=''),
+ help=(
+ 'semicomma seperated host name and its networks '
+ '<hostname>:<interface_name>=<ip>|<is_mgmt>|<is_promiscuous>,...'
+ ),
+ default=''),
cfg.StrOpt('partitions',
- help=(
- 'comma seperated partitions '
- '<partition name>=<partition_value>'
- ),
- default='tmp:percentage=10%,var:percentage=30%,home:percentage=30%'),
+ help=(
+ 'comma seperated partitions '
+ '<partition name>=<partition_value>'
+ ),
+ default='tmp:percentage=10%,var:percentage=30%,home:percentage=30%'),
cfg.StrOpt('network_mapping',
- help=(
- 'comma seperated network mapping '
- '<network_type>=<interface_name>'
- ),
- default=''),
+ help=(
+ 'comma seperated network mapping '
+ '<network_type>=<interface_name>'
+ ),
+ default=''),
cfg.StrOpt('package_config_json_file',
- help='json formatted os config file',
- default=''),
+ help='json formatted os config file',
+ default=''),
cfg.StrOpt('host_roles',
- help=(
- 'semicomma separated host roles '
- '<hostname>=<comma separated roles>'
- ),
- default=''),
+ help=(
+ 'semicomma separated host roles '
+ '<hostname>=<comma separated roles>'
+ ),
+ default=''),
cfg.StrOpt('default_roles',
- help=(
- 'comma seperated default roles '
- '<rolename>'
- ),
- default=''),
+ help=(
+ 'comma seperated default roles '
+ '<rolename>'
+ ),
+ default=''),
cfg.IntOpt('action_timeout',
- help='action timeout in seconds',
- default=60),
+ help='action timeout in seconds',
+ default=60),
cfg.IntOpt('deployment_timeout',
- help='deployment timeout in minutes',
- default=60),
+ help='deployment timeout in minutes',
+ default=60),
cfg.IntOpt('progress_update_check_interval',
- help='progress update status check interval in seconds',
- default=60),
+ help='progress update status check interval in seconds',
+ default=60),
cfg.StrOpt('dashboard_url',
- help='dashboard url',
- default=''),
+ help='dashboard url',
+ default=''),
cfg.StrOpt('dashboard_link_pattern',
- help='dashboard link pattern',
- default=r'(?m)(http://\d+\.\d+\.\d+\.\d+:5000/v2\.0)'),
+ help='dashboard link pattern',
+ default=r'(?m)(http://\d+\.\d+\.\d+\.\d+:5000/v2\.0)'),
cfg.StrOpt('cluster_vip',
- help='cluster ip address',
- default=''),
+ help='cluster ip address',
+ default=''),
cfg.StrOpt('enable_secgroup',
- help='enable security group',
- default='true'),
+ help='enable security group',
+ default='true'),
cfg.StrOpt('enable_vpnaas',
- help='enable vpn as service',
- default='true'),
+ help='enable vpn as service',
+ default='true'),
cfg.StrOpt('enable_fwaas',
- help='enable firewall as service',
- default='true'),
+ help='enable firewall as service',
+ default='true'),
cfg.StrOpt('network_cfg',
- help='netowrk config file',
- default=''),
+ help='netowrk config file',
+ default=''),
cfg.StrOpt('neutron_cfg',
- help='netowrk config file',
- default=''),
+ help='netowrk config file',
+ default=''),
cfg.StrOpt('cluster_pub_vip',
- help='cluster ip address',
- default=''),
+ help='cluster ip address',
+ default=''),
cfg.StrOpt('cluster_prv_vip',
- help='cluster ip address',
- default=''),
+ help='cluster ip address',
+ default=''),
cfg.StrOpt('repo_name',
- help='repo name',
- default=''),
+ help='repo name',
+ default=''),
cfg.StrOpt('deploy_type',
- help='deploy type',
- default='virtual'),
+ help='deploy type',
+ default='virtual'),
cfg.StrOpt('deploy_flag',
- help='deploy flag',
- default='deploy'),
+ help='deploy flag',
+ default='deploy'),
cfg.StrOpt('rsa_file',
- help='ssh rsa key file',
- default=''),
+ help='ssh rsa key file',
+ default=''),
cfg.StrOpt('odl_l3_agent',
- help='odl l3 agent enable flag',
- default='Disable'),
+ help='odl l3 agent enable flag',
+ default='Disable'),
cfg.StrOpt('moon',
- help='moon enable flag',
- default='Disable'),
+ help='moon enable flag',
+ default='Disable'),
cfg.StrOpt('onos_sfc',
- help='onos_sfc enable flag',
- default='Disable'),
+ help='onos_sfc enable flag',
+ default='Disable'),
]
CONF.register_cli_opts(opts)
+
def is_role_unassigned(role):
return role
+
def _load_config(config_filename):
if not config_filename:
return {}
@@ -262,6 +266,7 @@ def _load_config(config_filename):
class CompassClient(object):
+
def __init__(self):
LOG.info("xh: compass_server=%s" % CONF.compass_server)
self.client = Client(CONF.compass_server)
@@ -309,7 +314,10 @@ class CompassClient(object):
]))
machines_db = [str(m["mac"]) for m in resp]
- LOG.info('machines in db: %s\n to add: %s', machines_db, machines_to_add)
+ LOG.info(
+ 'machines in db: %s\n to add: %s',
+ machines_db,
+ machines_to_add)
if not set(machines_to_add).issubset(set(machines_db)):
raise RuntimeError('unidentify machine to add')
@@ -378,7 +386,7 @@ class CompassClient(object):
if CONF.expansion == "false":
status, resp = self.client.add_subnet(subnet)
LOG.info('add subnet %s status %s response %s',
- subnet, status, resp)
+ subnet, status, resp)
if not self.is_ok(status):
raise RuntimeError('failed to add subnet %s' % subnet)
subnet_mapping[resp['subnet']] = resp['id']
@@ -401,7 +409,7 @@ class CompassClient(object):
raise RuntimeError("add cluster failed")
LOG.info('add cluster %s status: %s resp:%s',
- cluster_name, status,resp)
+ cluster_name, status, resp)
if isinstance(resp, list):
cluster = resp[0]
@@ -442,7 +450,7 @@ class CompassClient(object):
{'machines': machines_dict})
LOG.info('add machines %s to cluster %s status: %s, resp: %s',
- machines_dict, cluster_id, status, resp)
+ machines_dict, cluster_id, status, resp)
if not self.is_ok(status):
raise RuntimeError("add host to cluster failed")
@@ -585,8 +593,8 @@ class CompassClient(object):
'set os config %s to cluster %s status: %s, resp: %s',
os_config, cluster_id, status, resp)
if not self.is_ok(status):
- raise RuntimeError('failed to set os config %s to cluster %s' \
- % (os_config, cluster_id))
+ raise RuntimeError('failed to set os config %s to cluster %s'
+ % (os_config, cluster_id))
def set_host_networking(self):
"""set cluster hosts networking."""
@@ -741,11 +749,14 @@ class CompassClient(object):
package_config["ha_proxy"]["vip"] = CONF.cluster_vip
package_config['enable_secgroup'] = (CONF.enable_secgroup == "true")
- 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"
- package_config['moon'] = "Enable" if CONF.moon == "Enable" else "Disable"
- package_config['onos_sfc'] = "Enable" if CONF.onos_sfc == "Enable" else "Disable"
+ 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"
+ package_config[
+ 'moon'] = "Enable" if CONF.moon == "Enable" else "Disable"
+ package_config[
+ 'onos_sfc'] = "Enable" if CONF.onos_sfc == "Enable" else "Disable"
status, resp = self.client.update_cluster_config(
cluster_id, package_config=package_config)
@@ -785,20 +796,21 @@ 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()) \
+ unassigned_hostnames = list(set(self.host_mapping.keys())
- set(self.host_roles.keys()))
- unassigned_roles = [ role for role, status in self.role_mapping.items()
- if is_role_unassigned(status)]
+ unassigned_roles = [role for role, status in self.role_mapping.items()
+ if is_role_unassigned(status)]
assert(len(unassigned_hostnames) >= len(unassigned_roles))
- for hostname, role in map(None, unassigned_hostnames, unassigned_roles):
+ for hostname, role in map(
+ None, unassigned_hostnames, unassigned_roles):
host_id = self.host_mapping[hostname]
self.set_host_roles(cluster_id, host_id, [role])
self.host_roles[hostname] = [role]
- unassigned_hostnames = list(set(self.host_mapping.keys()) \
+ unassigned_hostnames = list(set(self.host_mapping.keys())
- set(self.host_roles.keys()))
if not unassigned_hostnames:
@@ -830,7 +842,7 @@ class CompassClient(object):
cluster_id, host_ids, status, response
)
- #TODO, what this doning?
+ # TODO, what this doning?
if not self.is_ok(status):
raise RuntimeError("review cluster host failed")
@@ -860,7 +872,8 @@ class CompassClient(object):
def get_cluster_state(self, cluster_id):
for _ in range(10):
try:
- status, cluster_state = self.client.get_cluster_state(cluster_id)
+ status, cluster_state = self.client.get_cluster_state(
+ cluster_id)
if self.is_ok(status):
break
except:
@@ -884,21 +897,21 @@ class CompassClient(object):
elif cluster_state['state'] == 'SUCCESSFUL':
LOG.info(
- 'get cluster %s state status %s: %s, successful',
- cluster_id, status, cluster_state
+ 'get cluster %s state status %s: %s, successful',
+ cluster_id, status, cluster_state
)
break
elif cluster_state['state'] == 'ERROR':
raise RuntimeError(
- 'get cluster %s state status %s: %s, error',
- (cluster_id, status, cluster_state)
+ 'get cluster %s state status %s: %s, error',
+ (cluster_id, status, cluster_state)
)
time.sleep(5)
if current_time() >= deployment_timeout:
- LOG.info("current_time=%s, deployment_timeout=%s" \
- % (current_time(), deployment_timeout))
+ LOG.info("current_time=%s, deployment_timeout=%s"
+ % (current_time(), deployment_timeout))
LOG.info("cobbler status:")
os.system("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
-i %s root@192.168.200.2 \
@@ -939,8 +952,11 @@ def print_ansible_log():
'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")
+ os.system(
+ "ps aux|grep -v grep|grep -E 'ssh.+root@192.168.200.2'|awk '{print $2}'|xargs kill -9")
+
def deploy():
if CONF.expansion == "false":
@@ -994,6 +1010,7 @@ def deploy():
threading.Thread(target=print_ansible_log).start()
client.get_installing_progress(cluster_id)
+
def redeploy():
client = CompassClient()
@@ -1004,6 +1021,7 @@ def redeploy():
client.get_installing_progress(cluster_id)
client.check_dashboard_links(cluster_id)
+
def main():
if CONF.deploy_flag == "redeploy":
redeploy()
diff --git a/deploy/config_parse.py b/deploy/config_parse.py
index ba677ade..1c384c34 100644
--- a/deploy/config_parse.py
+++ b/deploy/config_parse.py
@@ -3,10 +3,12 @@ import yaml
import sys
from Cheetah.Template import Template
+
def init(file):
with open(file) as fd:
return yaml.load(fd)
+
def decorator(func):
def wrapter(s, seq):
host_list = s.get('hosts', [])
@@ -14,7 +16,7 @@ def decorator(func):
for host in host_list:
s = func(s, seq, host)
if not s:
- continue
+ continue
result.append(s)
if len(result) == 0:
return ""
@@ -22,18 +24,22 @@ def decorator(func):
return "\"" + seq.join(result) + "\""
return wrapter
+
@decorator
def hostnames(s, seq, host=None):
return host.get('name', '')
+
@decorator
def hostroles(s, seq, host=None):
return "%s=%s" % (host.get('name', ''), ','.join(host.get('roles', [])))
+
@decorator
def hostmacs(s, seq, host=None):
return host.get('mac', '')
+
def export_dha_file(s, dha_file, conf_dir, ofile):
env = {}
env.update(s)
@@ -54,18 +60,27 @@ def export_dha_file(s, dha_file, conf_dir, ofile):
for k, v in env.items():
os.system("echo 'export %s=${%s:-%s}' >> %s" % (k, k, v, ofile))
+
def export_reset_file(s, tmpl_dir, output_dir, output_file):
tmpl_file_name = s.get('POWER_TOOL', '')
if not tmpl_file_name:
return
- tmpl = Template(file=os.path.join(tmpl_dir,'power', tmpl_file_name + '.tmpl'), searchList=s)
+ tmpl = Template(
+ file=os.path.join(
+ tmpl_dir,
+ 'power',
+ tmpl_file_name +
+ '.tmpl'),
+ searchList=s)
reset_file_name = os.path.join(output_dir, tmpl_file_name + '.sh')
with open(reset_file_name, 'w') as f:
f.write(tmpl.respond())
- os.system("echo 'export POWER_MANAGE=%s' >> %s" % (reset_file_name, output_file))
+ os.system(
+ "echo 'export POWER_MANAGE=%s' >> %s" %
+ (reset_file_name, output_file))
if __name__ == "__main__":
if len(sys.argv) != 6:
@@ -80,8 +95,19 @@ if __name__ == "__main__":
data = init(dha_file)
- export_dha_file(data, dha_file, conf_dir, os.path.join(output_dir, output_file))
- export_reset_file(data, tmpl_dir, output_dir, os.path.join(output_dir, output_file))
+ export_dha_file(
+ data,
+ dha_file,
+ conf_dir,
+ os.path.join(
+ output_dir,
+ output_file))
+ export_reset_file(
+ data,
+ tmpl_dir,
+ output_dir,
+ os.path.join(
+ output_dir,
+ output_file))
sys.exit(0)
-
diff --git a/deploy/log.py b/deploy/log.py
index 1c20f37e..909d9377 100644
--- a/deploy/log.py
+++ b/deploy/log.py
@@ -1,6 +1,8 @@
import logging
import os
loggers = {}
+
+
def getLogger(name):
if name in loggers:
return loggers[name]
@@ -23,7 +25,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)
@@ -33,4 +36,3 @@ def getLogger(name):
loggers[name] = logger
return logger
-
diff --git a/deploy/rename_nics.py b/deploy/rename_nics.py
index dcec51df..99eed3c2 100644
--- a/deploy/rename_nics.py
+++ b/deploy/rename_nics.py
@@ -2,10 +2,12 @@ import os
import sys
import yaml
+
def exec_cmd(cmd):
print cmd
os.system(cmd)
+
def rename_nics(dha_info, rsa_file, compass_ip, os_version):
for host in dha_info['hosts']:
host_name = host['name']
@@ -18,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'"
+ % (rsa_file, compass_ip, host_name, nic_name, mac))
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'"
+ % (rsa_file, compass_ip, host_name, nic_name, mac))
exec_cmd("ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null \
-i %s root@%s \
@@ -32,4 +34,10 @@ def rename_nics(dha_info, rsa_file, compass_ip, os_version):
if __name__ == "__main__":
assert(len(sys.argv) == 5)
- rename_nics(yaml.load(open(sys.argv[1])), sys.argv[2], sys.argv[3], sys.argv[4])
+ rename_nics(
+ yaml.load(
+ open(
+ sys.argv[1])),
+ sys.argv[2],
+ sys.argv[3],
+ sys.argv[4])
diff --git a/deploy/reset_compute.py b/deploy/reset_compute.py
index 717e8833..d47f462f 100644
--- a/deploy/reset_compute.py
+++ b/deploy/reset_compute.py
@@ -2,15 +2,17 @@ import os
import sys
import yaml
+
def exec_cmd(cmd):
print cmd
os.system(cmd)
+
def reset_baremetal(dha_info):
print "reset_baremetal"
hosts_info = yaml.load(open(dha_info))
- #print hosts_info
+ # print hosts_info
ipmiUserDf = hosts_info.get('ipmiUser', 'root')
ipmiPassDf = hosts_info.get('ipmiPass', 'Huawei@123')
@@ -18,8 +20,8 @@ def reset_baremetal(dha_info):
print ipmiPassDf
hosts_list = hosts_info.get('hosts', [])
- #print hosts_list
-
+ # print hosts_list
+
for host in hosts_list:
print host
if ('compute' in host['roles']):
@@ -29,7 +31,9 @@ def reset_baremetal(dha_info):
print ipmiUser
print ipmiPass
print ipmiIp
- exec_cmd("ipmitool -I lanplus -H %s -U %s -P %s chassis power reset >/dev/null" % (ipmiIp, ipmiUser, ipmiPass))
+ exec_cmd(
+ "ipmitool -I lanplus -H %s -U %s -P %s chassis power reset >/dev/null" %
+ (ipmiIp, ipmiUser, ipmiPass))
def reset_virtual(dha_info):
@@ -45,15 +49,14 @@ def reset_virtual(dha_info):
if ('compute' in host['roles']):
name = host['name']
exec_cmd("virsh destroy %s" % name)
- exec_cmd("virsh start %s" % name)
+ exec_cmd("virsh start %s" % name)
if __name__ == "__main__":
- deploy_type=sys.argv[1]
- dha_info=sys.argv[2]
+ deploy_type = sys.argv[1]
+ dha_info = sys.argv[2]
print deploy_type
print dha_info
- if (deploy_type == 'baremetal') :
+ if (deploy_type == 'baremetal'):
reset_baremetal(dha_info)
- elif (deploy_type == 'virtual') :
+ elif (deploy_type == 'virtual'):
reset_virtual(dha_info)
-
diff --git a/deploy/restful.py b/deploy/restful.py
index 44e461c4..324d159a 100644
--- a/deploy/restful.py
+++ b/deploy/restful.py
@@ -19,6 +19,7 @@ import json
import logging
import requests
+
class Client(object):
"""compass restful api wrapper"""
diff --git a/deploy/setup_vnic.py b/deploy/setup_vnic.py
index 8e14765f..e7ab0cc0 100644
--- a/deploy/setup_vnic.py
+++ b/deploy/setup_vnic.py
@@ -5,15 +5,20 @@ import yaml
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")
+ os.system(
+ "sudo ovs-vsctl --may-exist add-port br-external mgmt_vnic -- set Interface mgmt_vnic type=internal")
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"]:
if sys_intf["name"] == "mgmt" and sys_intf.get("vlan_tag"):
- os.system("sudo ovs-vsctl set port mgmt_vnic tag=%s" % sys_intf["vlan_tag"])
+ os.system(
+ "sudo ovs-vsctl set port mgmt_vnic tag=%s" %
+ sys_intf["vlan_tag"])
for net_info in network_config["ip_settings"]:
if net_info["name"] == "mgmt":
- mgmt_ip_range_end= net_info["ip_ranges"][0][1]
+ mgmt_ip_range_end = net_info["ip_ranges"][0][1]
mgmt_netmask = net_info["cidr"].split('/')[1]
- os.system(r"sudo ip addr add %s/%s dev mgmt_vnic" % (mgmt_ip_range_end, mgmt_netmask))
+ os.system(
+ r"sudo ip addr add %s/%s dev mgmt_vnic" %
+ (mgmt_ip_range_end, mgmt_netmask))
diff --git a/deploy/status_callback.py b/deploy/status_callback.py
index e430326b..d4712ef7 100755
--- a/deploy/status_callback.py
+++ b/deploy/status_callback.py
@@ -3,14 +3,16 @@ import json
import sys
import logging
+
def task_error(host, data):
logging.info("task_error: host=%s,data=%s" % (host, data))
- if type(data) == dict:
+ if isinstance(data, dict):
invocation = data.pop('invocation', {})
notify_host("localhost", host, "failed")
+
class CallbackModule(object):
"""
logs playbook results, per host, in /var/log/ansible/hosts
@@ -58,7 +60,8 @@ class CallbackModule(object):
def playbook_on_task_start(self, name, is_conditional):
pass
- def playbook_on_vars_prompt(self, varname, private=True, prompt=None, encrypt=None, confirm=False, salt_size=None, salt=None, default=None):
+ def playbook_on_vars_prompt(self, varname, private=True, prompt=None,
+ encrypt=None, confirm=False, salt_size=None, salt=None, default=None):
pass
def playbook_on_setup(self):
@@ -101,7 +104,10 @@ class CallbackModule(object):
def raise_for_status(resp):
if resp.status < 200 or resp.status > 300:
- raise RuntimeError("%s, %s, %s" % (resp.status, resp.reason, resp.read()))
+ raise RuntimeError(
+ "%s, %s, %s" %
+ (resp.status, resp.reason, resp.read()))
+
def auth(conn):
credential = {}
@@ -116,6 +122,7 @@ def auth(conn):
raise_for_status(resp)
return json.loads(resp.read())["token"]
+
def notify_host(compass_host, host, status):
if status == "succ":
body = {"ready": True}
@@ -125,8 +132,8 @@ def notify_host(compass_host, host, status):
host = host.strip("host")
url = "/api/clusterhosts/%s/state" % host
else:
- logging.error("notify_host: host %s with status %s is not supported" \
- % (host, status))
+ logging.error("notify_host: host %s with status %s is not supported"
+ % (host, status))
return
headers = {"Content-type": "application/json",
@@ -135,12 +142,15 @@ def notify_host(compass_host, host, status):
conn = httplib.HTTPConnection(compass_host, 80)
token = auth(conn)
headers["X-Auth-Token"] = token
- logging.info("host=%s,url=%s,body=%s,headers=%s" % (compass_host,url,json.dumps(body),headers))
+ logging.info("host=%s,url=%s,body=%s,headers=%s" %
+ (compass_host, url, json.dumps(body), headers))
conn.request("POST", url, json.dumps(body), headers)
resp = conn.getresponse()
try:
raise_for_status(resp)
- logging.info("notify host status success!!! status=%s, body=%s" % (resp.status, resp.read()))
+ logging.info(
+ "notify host status success!!! status=%s, body=%s" %
+ (resp.status, resp.read()))
except Exception as e:
logging.error("http request failed %s" % str(e))
raise