Jul-26-2018, 12:56 PM
Hi,
I am using a f5-common-python library which I installed with pip.
There is a 'asm' directory which has this content:
To be able to work with violations, I need to update the __init__.py by importing Violations_s and adding Violations_s to self._meta_data['allowed_lazy_attributes'], so the __init__.py then looks like this:
Can I write the Violations_s definition in my own script and then also update self._meta_data['allowed_lazy_attributes'] in the __init__.py file directly from my script?
Thanks.
Martin
I am using a f5-common-python library which I installed with pip.
There is a 'asm' directory which has this content:
Output:~/.local/lib/python3.6/site-packages/f5/bigip/tm/asm$
attack_types.py
file_transfer.py
__init__.py
policies
policy_templates.py
__pycache__
signature_sets.py
signatures.py
signature_statuses.py
signature_systems.py
signature_update.py
tasks.pyThe __init__.py looks like this:from f5.bigip.resource import OrganizingCollection
from f5.bigip.tm.asm.attack_types import Attack_Types_s
from f5.bigip.tm.asm.file_transfer import File_Transfer
from f5.bigip.tm.asm.policies import Policies_s
from f5.bigip.tm.asm.policy_templates import Policy_Templates_s
from f5.bigip.tm.asm.signature_sets import Signature_Sets_s
from f5.bigip.tm.asm.signature_statuses import Signature_Statuses_s
from f5.bigip.tm.asm.signature_systems import Signature_Systems_s
from f5.bigip.tm.asm.signature_update import Signature_Update
from f5.bigip.tm.asm.signatures import Signatures_s
from f5.bigip.tm.asm.tasks import Tasks
class Asm(OrganizingCollection):
def __init__(self, tm):
super(Asm, self).__init__(tm)
self._meta_data['allowed_lazy_attributes'] = [
Attack_Types_s,
File_Transfer,
Policies_s,
Policy_Templates_s,
Signature_Sets_s,
Signature_Statuses_s,
Signature_Systems_s,
Signature_Update,
Signatures_s,
Tasks,
]I want to add functionality to this library by adding a new file called violations.py into the 'asm' directory.To be able to work with violations, I need to update the __init__.py by importing Violations_s and adding Violations_s to self._meta_data['allowed_lazy_attributes'], so the __init__.py then looks like this:
from f5.bigip.resource import OrganizingCollection
from f5.bigip.tm.asm.attack_types import Attack_Types_s
from f5.bigip.tm.asm.file_transfer import File_Transfer
from f5.bigip.tm.asm.policies import Policies_s
from f5.bigip.tm.asm.policy_templates import Policy_Templates_s
from f5.bigip.tm.asm.signature_sets import Signature_Sets_s
from f5.bigip.tm.asm.signature_statuses import Signature_Statuses_s
from f5.bigip.tm.asm.signature_systems import Signature_Systems_s
from f5.bigip.tm.asm.signature_update import Signature_Update
from f5.bigip.tm.asm.signatures import Signatures_s
from f5.bigip.tm.asm.tasks import Tasks
from f5.bigip.tm.asm.violations import Violations_s
class Asm(OrganizingCollection):
def __init__(self, tm):
super(Asm, self).__init__(tm)
self._meta_data['allowed_lazy_attributes'] = [
Attack_Types_s,
File_Transfer,
Policies_s,
Policy_Templates_s,
Signature_Sets_s,
Signature_Statuses_s,
Signature_Systems_s,
Signature_Update,
Signatures_s,
Tasks,
Violations_s,
]Is it somehow possible in python to make these changes directly in my own script, so that I don't need to touch and change the default distribution files under ~/.local/lib/python3.6/site-packages/ ?Can I write the Violations_s definition in my own script and then also update self._meta_data['allowed_lazy_attributes'] in the __init__.py file directly from my script?
Thanks.
Martin
