Skip to content

Commit

Permalink
Merge branch 'master' of github.com:a10networks/acos-client into stab…
Browse files Browse the repository at this point in the history
…le/stein
  • Loading branch information
ytsai-a10 committed Jun 2, 2021
2 parents 050bd67 + 2ebfd2a commit b6b2ccc
Show file tree
Hide file tree
Showing 15 changed files with 150 additions and 61 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ $ tox
## Issues and Inquiries
For all issues, please send an email to [email protected]

For general inquiries, please send an email to [email protected]


## Helpful links

Expand Down
8 changes: 8 additions & 0 deletions acos_client/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,11 @@ class KeyParsingFailed(ACOSException):

class FeatureNotSupported(ACOSException):
pass


class ACOSSystemNotReady(ACOSException):
pass


class ACOSSystemIsBusy(ACOSException):
pass
26 changes: 13 additions & 13 deletions acos_client/tests/unit/v30/test_bladeparam.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,21 @@ def _build_ipv6gateway(self, ip_address, priority_cost=1):
def test_blade_get(self):
self.target.get(0)
self.client.http.request.assert_called_with("GET", self.url_prefix.format(0), {}, mock.ANY,
axapi_args=None, max_retries=None, timeout=None)
axapi_args=None, max_retries=None, timeout=mock.ANY)

def test_blade_create(self):
self.target.create(4)
self.client.http.request.assert_called_with(
"POST", self.url_prefix.format(4),
self._expected_payload(), mock.ANY,
axapi_args=None, max_retries=None, timeout=None)
axapi_args=None, max_retries=None, timeout=mock.ANY)

def test_blade_create_priority(self):
self.target.create(4, 122)
self.client.http.request.assert_called_with(
"POST", self.url_prefix.format(4),
self._expected_payload(122), mock.ANY,
axapi_args=None, max_retries=None, timeout=None)
axapi_args=None, max_retries=None, timeout=mock.ANY)

def test_blade_create_interface(self):
interface = self._build_interface()
Expand All @@ -107,7 +107,7 @@ def test_blade_create_interface(self):
self.client.http.request.assert_called_with(
"POST", self.url_prefix.format(4),
self._expected_payload(interface=interface), mock.ANY,
axapi_args=None, max_retries=None, timeout=None)
axapi_args=None, max_retries=None, timeout=mock.ANY)

def test_blade_create_gateway(self):
gateway = self._build_ipv4gateway('1.1.1.1')
Expand All @@ -117,7 +117,7 @@ def test_blade_create_gateway(self):
self.client.http.request.assert_called_with(
"POST", self.url_prefix.format(4),
self._expected_payload(gateway=gateway), mock.ANY,
axapi_args=None, max_retries=None, timeout=None)
axapi_args=None, max_retries=None, timeout=mock.ANY)

def test_blade_create_gateway_ipv6(self):
gateway = self._build_ipv6gateway('1.1.1.1')
Expand All @@ -127,7 +127,7 @@ def test_blade_create_gateway_ipv6(self):
self.client.http.request.assert_called_with(
"POST", self.url_prefix.format(4),
self._expected_payload(gateway=gateway), mock.ANY,
axapi_args=None, max_retries=None, timeout=None)
axapi_args=None, max_retries=None, timeout=mock.ANY)

def test_blade_create_interface_gateway(self):
interface = self._build_interface()
Expand All @@ -139,21 +139,21 @@ def test_blade_create_interface_gateway(self):
self.client.http.request.assert_called_with(
"POST", self.url_prefix.format(4),
self._expected_payload(interface=interface, gateway=gateway), mock.ANY,
axapi_args=None, max_retries=None, timeout=None)
axapi_args=None, max_retries=None, timeout=mock.ANY)

def test_blade_update(self):
self.target.update(4)
self.client.http.request.assert_called_with(
"PUT", self.url_prefix.format(4),
self._expected_payload(), mock.ANY,
axapi_args=None, max_retries=None, timeout=None)
axapi_args=None, max_retries=None, timeout=mock.ANY)

def test_blade_update_priority(self):
self.target.update(4, 122)
self.client.http.request.assert_called_with(
"PUT", self.url_prefix.format(4),
self._expected_payload(122), mock.ANY,
axapi_args=None, max_retries=None, timeout=None)
axapi_args=None, max_retries=None, timeout=mock.ANY)

def test_blade_update_interface(self):
interface = self._build_interface()
Expand All @@ -163,7 +163,7 @@ def test_blade_update_interface(self):
self.client.http.request.assert_called_with(
"PUT", self.url_prefix.format(4),
self._expected_payload(interface=interface), mock.ANY,
axapi_args=None, max_retries=None, timeout=None)
axapi_args=None, max_retries=None, timeout=mock.ANY)

def test_blade_update_gateway(self):
gateway = self._build_ipv4gateway('1.1.1.1')
Expand All @@ -173,7 +173,7 @@ def test_blade_update_gateway(self):
self.client.http.request.assert_called_with(
"PUT", self.url_prefix.format(4),
self._expected_payload(gateway=gateway), mock.ANY,
axapi_args=None, max_retries=None, timeout=None)
axapi_args=None, max_retries=None, timeout=mock.ANY)

def test_blade_update_gateway_ipv6(self):
gateway = self._build_ipv6gateway('1.1.1.1')
Expand All @@ -183,7 +183,7 @@ def test_blade_update_gateway_ipv6(self):
self.client.http.request.assert_called_with(
"PUT", self.url_prefix.format(4),
self._expected_payload(gateway=gateway), mock.ANY,
axapi_args=None, max_retries=None, timeout=None)
axapi_args=None, max_retries=None, timeout=mock.ANY)

def test_blade_update_interface_gateway(self):
interface = self._build_interface()
Expand All @@ -195,4 +195,4 @@ def test_blade_update_interface_gateway(self):
self.client.http.request.assert_called_with(
"PUT", self.url_prefix.format(4),
self._expected_payload(interface=interface, gateway=gateway), mock.ANY,
axapi_args=None, max_retries=None, timeout=None)
axapi_args=None, max_retries=None, timeout=mock.ANY)
10 changes: 5 additions & 5 deletions acos_client/tests/unit/v30/test_dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_primary_ipv4(self):

self.client.http.request.assert_called_with("POST", self.url_prefix + 'primary',
expected_payload, mock.ANY, axapi_args=None,
max_retries=None, timeout=None)
max_retries=None, timeout=mock.ANY)

def test_primary_ipv6(self):
expected = '0:0:0:0:0:FFFF:129.144.52.38'
Expand All @@ -48,7 +48,7 @@ def test_primary_ipv6(self):

self.client.http.request.assert_called_with("POST", self.url_prefix + 'primary',
expected_payload, mock.ANY, axapi_args=None,
max_retries=None, timeout=None)
max_retries=None, timeout=mock.ANY)

def test_secondary_ipv4(self):
expected = '192.0.2.5'
Expand All @@ -58,7 +58,7 @@ def test_secondary_ipv4(self):

self.client.http.request.assert_called_with("POST", self.url_prefix + 'secondary',
expected_payload, mock.ANY, axapi_args=None,
max_retries=None, timeout=None)
max_retries=None, timeout=mock.ANY)

def test_secondary_ipv6(self):
expected = '0:0:0:0:0:FFFF:129.144.52.39'
Expand All @@ -68,7 +68,7 @@ def test_secondary_ipv6(self):

self.client.http.request.assert_called_with("POST", self.url_prefix + 'secondary',
expected_payload, mock.ANY, axapi_args=None,
max_retries=None, timeout=None)
max_retries=None, timeout=mock.ANY)

def test_suffix(self):
expected = 'example.com'
Expand All @@ -78,4 +78,4 @@ def test_suffix(self):

self.client.http.request.assert_called_with("POST", self.url_prefix + 'suffix',
expected_payload, mock.ANY, axapi_args=None,
max_retries=None, timeout=None)
max_retries=None, timeout=mock.ANY)
16 changes: 8 additions & 8 deletions acos_client/tests/unit/v30/test_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ def setUp(self):
def test_interface_get_list(self):
self.target.get_list()
self.client.http.request.assert_called_with("GET", self.url_prefix, {}, mock.ANY, axapi_args=None,
max_retries=None, timeout=None)
max_retries=None, timeout=mock.ANY)

def test_interface_get(self):
self.target.get()
self.client.http.request.assert_called_with("GET", self.url_prefix, {}, mock.ANY, axapi_args=None,
max_retries=None, timeout=None)
max_retries=None, timeout=mock.ANY)

def _test_interface_create_dhcp(self, dhcp=True):
expected = 1 if dhcp else 0
Expand All @@ -47,7 +47,7 @@ def _test_interface_create_dhcp(self, dhcp=True):
self.target.create(ifnum, dhcp=dhcp)
self.client.http.request.assert_called_with("POST", self.url_prefix, # URL + ifnum expected
expected_payload, mock.ANY, axapi_args=None,
max_retries=None, timeout=None)
max_retries=None, timeout=mock.ANY)

def test_interface_create_dhcp_negative(self):
self._test_interface_create_dhcp(False)
Expand All @@ -61,14 +61,14 @@ def test_interface_create_ipaddress(self):
ip_netmask = "255.255.255.0"
self.target.create(ifnum, dhcp=False, ip_address=ip_address, ip_netmask=ip_netmask)
self.client.http.request.assert_called_with("POST", self.url_prefix, mock.ANY, mock.ANY,
axapi_args=None, max_retries=None, timeout=None)
axapi_args=None, max_retries=None, timeout=mock.ANY)

def test_interface_delete(self):
ifnum = 1
self.target.delete(1)
self.client.http.request.assert_called_with("DELETE", self.url_prefix + str(ifnum),
mock.ANY, mock.ANY, axapi_args=None, max_retries=None,
timeout=None)
timeout=mock.ANY)

def test_interface_update(self):
ifnum = 1
Expand All @@ -79,7 +79,7 @@ def test_interface_update(self):

self.client.http.request.assert_called_with("POST", self.url_prefix + str(ifnum),
mock.ANY, mock.ANY, axapi_args=None, max_retries=None,
timeout=None)
timeout=mock.ANY)

def test_interface_enable_positive(self):
ifnum = 1
Expand All @@ -94,7 +94,7 @@ def test_interface_enable_positive(self):

self.client.http.request.assert_called_with("POST", self.url_prefix + str(ifnum),
mock.ANY, mock.ANY, axapi_args=None, max_retries=None,
timeout=None)
timeout=mock.ANY)

def test_interface_enable_negative(self):
ifnum = 1
Expand All @@ -110,7 +110,7 @@ def test_interface_enable_negative(self):

self.client.http.request.assert_called_with("POST", self.url_prefix + str(ifnum),
mock.ANY, mock.ANY, axapi_args=None, max_retries=None,
timeout=None)
timeout=mock.ANY)


class TestEthernetInterface(TestInterface):
Expand Down
12 changes: 6 additions & 6 deletions acos_client/tests/unit/v30/test_slb_aflex.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ def test_aflex_create(self, mocked_get):
self.assertEqual(len(responses.calls), 2)
self.assertEqual(responses.calls[1].request.method, responses.POST)
self.assertEqual(responses.calls[1].request.url, CREATE_URL)
self.assertIn(filename, responses.calls[1].request.body.decode('UTF-8'))
self.assertIn(action, responses.calls[1].request.body.decode('UTF-8'))
self.assertIn(filename, responses.calls[1].request.body.decode("utf-8"))
self.assertIn(action, responses.calls[1].request.body.decode("utf-8"))

@mock.patch('acos_client.v30.slb.aflex_policy.AFlexPolicy.get')
@responses.activate
Expand All @@ -76,8 +76,8 @@ def test_aflex_update(self, mocked_get):
self.assertEqual(len(responses.calls), 2)
self.assertEqual(responses.calls[1].request.method, responses.POST)
self.assertEqual(responses.calls[1].request.url, CREATE_URL)
self.assertIn(filename, responses.calls[1].request.body.decode('UTF-8'))
self.assertIn(action, responses.calls[1].request.body.decode('UTF-8'))
self.assertIn(filename, responses.calls[1].request.body.decode("utf-8"))
self.assertIn(action, responses.calls[1].request.body.decode("utf-8"))

@mock.patch('acos_client.v30.slb.aflex_policy.AFlexPolicy.get')
@responses.activate
Expand All @@ -93,5 +93,5 @@ def test_aflex_delete(self, mocked_get):
self.assertEqual(len(responses.calls), 2)
self.assertEqual(responses.calls[1].request.method, responses.POST)
self.assertEqual(responses.calls[1].request.url, CREATE_URL)
self.assertIn(filename, responses.calls[1].request.body.decode('UTF-8'))
self.assertIn('delete', responses.calls[1].request.body.decode('UTF-8'))
self.assertIn(filename, responses.calls[1].request.body.decode("utf-8"))
self.assertIn('delete', responses.calls[1].request.body.decode("utf-8"))
20 changes: 10 additions & 10 deletions acos_client/tests/unit/v30/test_vlan.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ def setUp(self):
def test_interface_get_list(self):
self.target.get_list()
self.client.http.request.assert_called_with("GET", self.url_prefix, {}, mock.ANY,
axapi_args=None, max_retries=None, timeout=None)
axapi_args=None, max_retries=None, timeout=mock.ANY)

def test_interface_get(self):
self.target.get(self.vlan_id)
self.client.http.request.assert_called_with(
"GET", '{0}/{1}'.format(self.url_prefix, self.vlan_id), {}, mock.ANY,
axapi_args=None, max_retries=None, timeout=None
axapi_args=None, max_retries=None, timeout=mock.ANY
)

def test_vlan_create_shared(self):
Expand All @@ -51,7 +51,7 @@ def test_vlan_create_shared(self):
ep = self.expected_payload
ep['vlan']['shared-vlan'] = True
self.client.http.request.assert_called_with("POST", self.url_prefix, ep, mock.ANY,
axapi_args=None, max_retries=None, timeout=None)
axapi_args=None, max_retries=None, timeout=mock.ANY)

def test_vlan_create_untagged_eths(self):
untagged_eths = [{'untagged-ethernet-start': 2, 'untagged-ethernet-end': 2}]
Expand All @@ -62,7 +62,7 @@ def test_vlan_create_untagged_eths(self):
ep = self.expected_payload
ep['vlan']['untagged-eth-list'] = untagged_eths
self.client.http.request.assert_called_with("POST", self.url_prefix, ep, mock.ANY,
axapi_args=None, max_retries=None, timeout=None)
axapi_args=None, max_retries=None, timeout=mock.ANY)

def test_vlan_create_untagged_trunks(self):
untagged_trunks = [{'untagged-trunk-start': 2, 'untagged-trunk-end': 2}]
Expand All @@ -74,7 +74,7 @@ def test_vlan_create_untagged_trunks(self):
ep = self.expected_payload
ep['vlan']['untagged-trunk-list'] = untagged_trunks
self.client.http.request.assert_called_with("POST", self.url_prefix, ep, mock.ANY,
axapi_args=None, max_retries=None, timeout=None)
axapi_args=None, max_retries=None, timeout=mock.ANY)

def test_vlan_create_tagged_eths(self):
tagged_eths = [{'tagged-ethernet-start': 2, 'tagged-ethernet-end': 2}]
Expand All @@ -85,7 +85,7 @@ def test_vlan_create_tagged_eths(self):
ep = self.expected_payload
ep['vlan']['tagged-eth-list'] = tagged_eths
self.client.http.request.assert_called_with("POST", self.url_prefix, ep, mock.ANY,
axapi_args=None, max_retries=None, timeout=None)
axapi_args=None, max_retries=None, timeout=mock.ANY)

def test_vlan_create_tagged_trunks(self):
tagged_trunks = [{'tagged-trunk-start': 2, 'tagged-trunk-end': 2}]
Expand All @@ -96,7 +96,7 @@ def test_vlan_create_tagged_trunks(self):
ep = self.expected_payload
ep['vlan']['tagged-trunk-list'] = tagged_trunks
self.client.http.request.assert_called_with("POST", self.url_prefix, ep, mock.ANY,
axapi_args=None, max_retries=None, timeout=None)
axapi_args=None, max_retries=None, timeout=mock.ANY)

def test_vlan_create_ve(self):
self.target.create(self.vlan_id, shared_vlan=False, untagged_eths=[], untagged_trunks=[],
Expand All @@ -105,7 +105,7 @@ def test_vlan_create_ve(self):
ep = self.expected_payload
ep['vlan']['ve'] = 1
self.client.http.request.assert_called_with("POST", self.url_prefix, ep, mock.ANY,
axapi_args=None, max_retries=None, timeout=None)
axapi_args=None, max_retries=None, timeout=mock.ANY)

def test_vlan_create_lif(self):
self.target.create(self.vlan_id, shared_vlan=False, untagged_eths=[], untagged_trunks=[],
Expand All @@ -114,11 +114,11 @@ def test_vlan_create_lif(self):
ep = self.expected_payload
ep['vlan']['untagged-lif'] = 6
self.client.http.request.assert_called_with("POST", self.url_prefix, ep, mock.ANY,
axapi_args=None, max_retries=None, timeout=None)
axapi_args=None, max_retries=None, timeout=mock.ANY)

def test_vlan_delete(self):
self.target.delete(self.vlan_id)
self.client.http.request.assert_called_with(
"DELETE", '{0}/{1}'.format(self.url_prefix, self.vlan_id), mock.ANY, mock.ANY,
axapi_args=None, max_retries=None, timeout=None
axapi_args=None, max_retries=None, timeout=mock.ANY
)
Loading

0 comments on commit b6b2ccc

Please sign in to comment.