Skip to content

Commit

Permalink
Merge pull request F5Networks#1134 from wojtek0806/add_reboot_to_volume
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtek0806 authored May 16, 2017
2 parents 3924130 + 90be4d3 commit c69eed9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
22 changes: 22 additions & 0 deletions f5/bigip/tm/sys/software/test/unit/test_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@


from f5.bigip.tm.sys.software.volume import Volume
from f5.bigip.tm.sys.software.volume import Volumes
from f5.sdk_exception import InvalidCommand
from f5.sdk_exception import MissingRequiredCommandParameter
from f5.sdk_exception import UnsupportedOperation


Expand All @@ -27,6 +30,12 @@ def FakeVolume():
return Volume(fake_software)


@pytest.fixture
def FakeVolumes():
fake_software = mock.MagicMock()
return Volumes(fake_software)


def test_create_raises(FakeVolume):
with pytest.raises(UnsupportedOperation) as EIO:
FakeVolume.create()
Expand All @@ -43,3 +52,16 @@ def test_modify_raises(FakeVolume):
with pytest.raises(UnsupportedOperation) as EIO:
FakeVolume.modify()
assert EIO.value.message == "Volume does not support the modify method."


def test_no_command_param_raises(FakeVolumes):
with pytest.raises(MissingRequiredCommandParameter) as EIO:
FakeVolumes.exec_cmd('reboot')
assert EIO.value.message == "Missing required params: ['volume']"


def test_invalid_command_raises(FakeVolumes):
with pytest.raises(InvalidCommand) as EIO:
FakeVolumes.exec_cmd('foobar')
assert EIO.value.message == "The command value foobar does not exist" \
"Valid commands are ['reboot']"
5 changes: 4 additions & 1 deletion f5/bigip/tm/sys/software/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,21 @@
``tm:sys:software:volume*``
"""

from f5.bigip.mixins import CommandExecutionMixin
from f5.bigip.resource import Collection
from f5.bigip.resource import Resource
from f5.sdk_exception import UnsupportedOperation


class Volumes(Collection):
class Volumes(Collection, CommandExecutionMixin):
"""BIG-IP® system software Volume collection."""
def __init__(self, software):
super(Volumes, self).__init__(software)
self._meta_data['allowed_lazy_attributes'] = [Volume]
self._meta_data['attribute_registry'] = \
{'tm:sys:software:volume:volumestate': Volume}
self._meta_data['allowed_commands'].append('reboot')
self._meta_data['required_command_parameters'].update(('volume',))


class Volume(Resource):
Expand Down

0 comments on commit c69eed9

Please sign in to comment.