Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions netfoundry/ctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,8 @@ def demo(cli):
name=network_name,
size=cli.config.demo.size,
version=cli.config.demo.product_version,
provider=cli.config.demo.provider,
location=cli.config.demo.regions[0], # Use first region for network location
)
network, network_group = use_network(
cli,
Expand Down
2 changes: 2 additions & 0 deletions netfoundry/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ def importlib_load_entry_point(spec, group, name):

globals().setdefault('load_entry_point', importlib_load_entry_point)


def main():
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
_args = [sys.argv[0], 'demo'] + sys.argv[1:]
sys.argv = _args
sys.exit(load_entry_point('netfoundry', 'console_scripts', 'nfctl')())


if __name__ == '__main__':
main()
2 changes: 1 addition & 1 deletion netfoundry/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import time

from packaging.version import parse
from requests.exceptions import JSONDecodeError
from json import JSONDecodeError

from netfoundry.exceptions import NetworkBoundaryViolation, UnknownResourceType

Expand Down
2 changes: 1 addition & 1 deletion netfoundry/network_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def create_network(self, name: str, network_group_id: str = None, location: str
elif param == 'productVersion':
if version:
self.logger.debug("clobbering param 'version' with kwarg 'productVersion'")
version == value
version = value
else:
self.logger.warn(f"ignoring unexpected keyword argument '{param}'")

Expand Down
2 changes: 1 addition & 1 deletion netfoundry/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def __init__(self,
if self.organizations_by_label.get(organization_label):
self.describe = self.get_organization(id=self.organizations_by_label[organization_label])
else:
raise RuntimeError(f"failed to find org label {organization_label} in the list of orgs {', '.join(self.organizations_by_label.keys())}")
raise RuntimeError(f"failed to find org label {organization_label} in the list of {len(self.organizations_by_label)} available organizations")
else:
self.describe = self.get_organization(id=self.caller['organizationId'])

Expand Down
10 changes: 7 additions & 3 deletions netfoundry/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,12 @@ def find_generic_resources(setup: object, url: str, headers: dict = dict(), embe
)
response.raise_for_status()
resource_page = response.json()

# Handle non-paginated endpoints that return direct lists
if isinstance(resource_page, list):
yield resource_page
return

if isinstance(resource_page, dict) and resource_page.get('page'):
try:
total_pages = resource_page['page']['totalPages']
Expand Down Expand Up @@ -515,8 +521,6 @@ def find_generic_resources(setup: object, url: str, headers: dict = dict(), embe
# then yield subsequent pages, if applicable
if get_all_pages and total_pages > 1: # get_all_pages is False if param 'page' or 'size' to stop recursion and get a single page
next_range_lower, next_range_upper = params['page'] + 1, total_pages
if resource_type.name == 'network-groups':
next_range_upper += 1 # network-groups pages are 1-based and so +1 upper limit
for next_page in range(next_range_lower, next_range_upper):
params['page'] = next_page
try:
Expand Down Expand Up @@ -902,7 +906,7 @@ def decorated(ref):
RETRY_STRATEGY = Retry(
total=5,
status_forcelist=[403, 404, 413, 429, 503], # The API responds 403 and 404 for not-yet-existing executions for some async operations
method_whitelist=["HEAD", "GET", "PUT", "DELETE", "OPTIONS", "TRACE"],
allowed_methods=["HEAD", "GET", "PUT", "DELETE", "OPTIONS", "TRACE"],
backoff_factor=1
)
DEFAULT_TIMEOUT = 31 # seconds, Gateway Service waits 30s before responding with an error code e.g. 503 and
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ install_requires =
pygments >= 2.11
pyjwt >= 2.3
pyyaml >= 5.4
requests >= 2.27, < 2.30
requests >= 2.30
tabulate >= 0.8
requests-cache >= 0.9.4
setup_requires =
Expand Down
Loading