-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #237 from simon-begin/add-vlan-load-interval
Add load-interval support on interface vlan
- Loading branch information
Showing
20 changed files
with
332 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
netman/api/doc_config/api_samples/put_switch_hostname_vlans_vlanid_load_interval.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
tests/adapters/compliance_tests/set_vlan_load_interval_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Copyright 2019 Internap. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
|
||
from hamcrest import assert_that, is_, contains_string | ||
|
||
from netman.core.objects.exceptions import BadLoadIntervalNumber, UnknownVlan | ||
from tests import has_message | ||
from tests.adapters.compliance_test_case import ComplianceTestCase | ||
|
||
|
||
class SetVlanLoadIntervalTest(ComplianceTestCase): | ||
_dev_sample = "arista_http" | ||
|
||
def test_sets_load_interval_for_the_vlan(self): | ||
self.client.add_vlan(1000) | ||
|
||
self.client.set_vlan_load_interval(1000, 30) | ||
|
||
vlan = self.client.get_vlan(1000) | ||
assert_that(vlan.load_interval, is_(30)) | ||
|
||
def test_fails_if_the_value_is_not_within_the_supported_range(self): | ||
self.client.add_vlan(1000) | ||
|
||
with self.assertRaises(BadLoadIntervalNumber) as expect: | ||
self.client.set_vlan_load_interval(1000, 800) | ||
|
||
assert_that(str(expect.exception), contains_string("Load interval number is invalid")) | ||
|
||
def test_fails_if_the_vlan_does_not_exist(self): | ||
with self.assertRaises(UnknownVlan) as expect: | ||
self.client.set_vlan_load_interval(1000, 30) | ||
|
||
assert_that(expect.exception, has_message("Vlan 1000 not found")) | ||
|
||
def tearDown(self): | ||
self.janitor.remove_vlan(1000) | ||
super(SetVlanLoadIntervalTest, self).tearDown() |
43 changes: 43 additions & 0 deletions
43
tests/adapters/compliance_tests/unset_vlan_load_interval_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Copyright 2019 Internap. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
|
||
from hamcrest import assert_that, is_ | ||
|
||
from netman.core.objects.exceptions import UnknownVlan | ||
from tests import has_message | ||
from tests.adapters.compliance_test_case import ComplianceTestCase | ||
|
||
|
||
class UnsetVlanLoadIntervalTest(ComplianceTestCase): | ||
_dev_sample = "arista_http" | ||
|
||
def test_unset_load_interval_from_the_vlan(self): | ||
self.client.add_vlan(1000) | ||
self.try_to.set_vlan_load_interval(1000, 30) | ||
|
||
self.client.unset_vlan_load_interval(1000) | ||
vlan = self.client.get_vlan(1000) | ||
|
||
assert_that(vlan.load_interval, is_(None)) | ||
|
||
def test_fails_if_the_vlan_does_not_exist(self): | ||
with self.assertRaises(UnknownVlan) as expect: | ||
self.client.unset_vlan_load_interval(1000) | ||
|
||
assert_that(expect.exception, has_message("Vlan 1000 not found")) | ||
|
||
def tearDown(self): | ||
self.janitor.remove_vlan(1000) | ||
super(UnsetVlanLoadIntervalTest, self).tearDown() |
Oops, something went wrong.