Skip to content

Commit 1d93cb1

Browse files
committed
Fixes #381 also addreses some of the files listed in #378
f5\bigip\cm__init__.py f5\bigip\sys\config.py
1 parent 6ccc3cb commit 1d93cb1

3 files changed

Lines changed: 9 additions & 11 deletions

File tree

f5/bigip/resource.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,8 @@ def __init__(self, container):
349349
:param container: instance is an attribute of a ResourceBase container
350350
"""
351351
super(ResourceBase, self).__init__(container)
352+
# Commands you can run on a resource or collection, we define it here
353+
self._meta_data['allowed_commands'] = []
352354

353355
def _update(self, **kwargs):
354356
"""wrapped with update, override that in a subclass to customize"""
@@ -592,8 +594,7 @@ def __init__(self, container):
592594
self._meta_data['exclusive_attributes'] = []
593595
# You can't set these attributes, only 'read' them.
594596
self._meta_data['read_only_attributes'] = []
595-
# Commands you can run on a resource
596-
self._meta_data['allowed_commands'] = []
597+
597598

598599
def _activate_URI(self, selfLinkuri):
599600
"""Call this with a selfLink, after it's returned in _create or _load.

f5/bigip/tm/cm/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,4 @@ def __init__(self, cm):
4545
Devices, Device_Groups, Traffic_Groups, Trust_Domains,
4646
Sync_Status, Add_To_Trust, Remove_From_Trust,
4747
]
48+
self._meta_data['allowed_commands'].append('run')

f5/bigip/tm/sys/config.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,19 @@
2525
REST Kind
2626
``tm:sys:config:*``
2727
"""
28-
28+
from f5.bigip.mixins import CommandExecutionMixin
2929
from f5.bigip.mixins import UnnamedResourceMixin
3030
from f5.bigip.resource import ResourceBase
3131

3232

33-
class Config(UnnamedResourceMixin, ResourceBase):
33+
class Config(UnnamedResourceMixin, ResourceBase,
34+
CommandExecutionMixin):
3435
def __init__(self, sys):
3536
super(Config, self).__init__(sys)
3637
self._meta_data['allowed_lazy_attributes'] = []
3738
self._meta_data['attribute_registry'] = {}
39+
self._meta_data['allowed_commands'].append('save',
40+
'load')
3841

3942
def update(self, **kwargs):
4043
'''Update is not supported for Config
@@ -45,10 +48,3 @@ def update(self, **kwargs):
4548
"%s does not support the update method" % self.__class__.__name__
4649
)
4750

48-
def save(self):
49-
'''Save the configuration on the device. '''
50-
payload = {'command': 'save'}
51-
session = self._meta_data['bigip']._meta_data['icr_session']
52-
uri = self._meta_data['uri']
53-
response = session.post(uri, json=payload)
54-
self._local_update(response.json())

0 commit comments

Comments
 (0)