## π₯π₯π₯Breaking Changesπ₯π₯π₯
This release of centralcli is a major refactor, and introduces a number of potentially breaking changes if you are using it as a library (importing it into another script), or if you've built scripts that use the CLI (i.e. a bash script that uses cencli).
- π Files have been moved / reorganized / broken up
- β¨ Significant new features:
- Add support for doing inventory/subscription calls direct to GreenLake.
- Cache subscription info, use GLP API to update inventory and subscription cache.
- β
The bulk of this update is work to add tests and get coverage to > 90% (91% currently). This effort flushed out a number of bugs also fixed in this release.
## Resolved Bugs
- π©Ή Fix minor issue with invalid flag detection in `update config`
- π©Ή Exit when duplicates found in import files. Handling duplicates had bug due to use of set and set not maintaining order
- π©Ή Fix missing cache object in CacheGuest
- π©Ή Fix some filtering logic in `kick client`
- π©Ή Fix validation for monitor_only being updated on group w/ switches already allowed.
- π©Ή Fix detection of ap and gw together for upgrade which is valid.
- π©Ή Fix flaw in multiple incompatible devices detection
- π©Ή Minor fix in template matching logic in `update template`
- π©Ή Fix potential for markup error when msg passed to logger includes [/...
- π©Ή Fix bug where cols and rows flipped in TTY object
- π©Ή Fix group logic in `show firmware compliance` + other code formatting
- π©Ή Fix corner-case in get_device_firmware_details ... offline AP could have empty list for data["aps"]
- π©Ή Fix corner-case issue... Would only apply if cert completion was attempted after a cert had been added via cencli and show certs had not been run.
- π©Ή Fix `update webhook` not honoring `--yes` option
- π©Ή Fix completion in `remove`
- π©Ή Handle null fields in get_site_identifier querries
- π©Ή Fix mpsk reset option in cloudauth_update_namedmpsk.
- π©Ή Fix rate limit output when combining multiple named_mpsk calls
- π©Ή Fix potential for IndexError during fuzz match if dev_type is specified in get_dev_identifier, and none of that type exist
- π©Ή Minor fix for cache update after clone group
- π Fix potential for TyperError due to services (subscription) being a list from inventory.
- π Fix issue with cache update after cert delete
- π Fix bug in kick client (if client is not connected per current cache)
- π Fix bug when using `show alerts` with `--label` flag
- π Fix batch verify subscription validation
- π Fix --mo-cx flag in update group
- π Fix potential for exception if all calls to get_named_mpsk fail in `refresh_mpsk_db()`
- π Fix bug in `show devices/aps/gateways... <device iden> --inv` where invalid paramerter name was used for dev_type causing Exception.
- π Fix errant match in get_guest_identifier when qry_str is all text... match would then match any guests that lack a phone.
- π Fix bug in upgrade device if not version is provided (recommended version)
- π Fix bug where kick by --ssid was not actually honoring the SSID part (was kicking all users from the AP)
- π Fix UnboundLocalError on multi-match with conductor_only option (now swack) in get_dev_identifier
- π Fix bug in assign subscription when anything other than the id is used to identify the dev and the dev is not in monitoring DB yet.
- π Fix reboot request logic in batch_update_aps / _reboot_after_changes
- π Fix missing APNetworkRole when group ap is added as allowed device type in `update_group_properties()`
- π Fix update for group that currently does not have aps in allowed_types
- π Fix bug in update_per_ap_settings
- π Fix bug in caas.send_cmds when site keyword is used. Was looking up group identifier not site.
- π Fix serial number by text file validation in `_get_import_file()`
- π Fix upload_certificate for pkcs12 and DER cert types
- π Fix _verify_device_type ... make @staticmethod
- π Fix validation of device_type in `move_devices_to_site()`
- π Fix -a|--all flag in show audit logs
- π Fix honoring of enabled/disabled and role flags when no ssid is specified.
- π Fix bug in guest completion when incomplete is empty str
- π Fix ability to update variables for device that has not checked into central yet
- π Fix `cencli show inventory` when dev_type switch is specified
- π Fix `--up` | `--down` flags for `show swarms`
- π Fix bug in interface cleaner for stacks
- π Fix `--up` | `--down` flags for `show swarms`
- π Fix setup_batch_import_file() for tests. Was not creating yaml/csv files correctly.
- π Fix lldp neighbors for VSF stacks, which was using wrong function/API endpoint
- π Fix bug in TTY object
- π Fix exception was being returned not raised
- π Fix bug where loop evaluating process pid could never give up in `stop hook-proxy`
- π Fix handling of multiple groups in `update cp-cert`. WorkAround bug in typer.
- πβͺ Fix regression bug related to clients with null last_connected_time
- π Fix bug in template_completion when COMP_WORD is an empty str
- π Fix url query string issue in batch assign subscriptions
- π Fix response when validation fails in update_group_properties
- π Fix markup mismatch issue in clone group (when upgrading to aos10, which doesn't work anyway)
- π Fix upgrade when --at is used to specify upgrade at later time
- π Fix exception when min_width=None is passed into render.display_results
- π Fix convert template
- π Fix `batch assign` when `--tags` option is not provided
- π Fix imports, move custom exception import out of if TYPE_CHECKING block.
- π Fix CacheInvMonDevice summary_text
- π Fix `--dev-type` filter output (make it work) in `show subscriptions`
- π Fix retry logic for clients in cache.get_client_identifier()
- π Fix Config.wss_key was referencing the webhook token not the wss key
- π Fix `show branch health` make (restore) site argument optional
- π Fix cache file moves for mocked tests
- π Fix bug when sending duration parmeter to `send_command_to_device`
- π Fix incorrect argument name during inventory db update
- π Fix bug if `-S|--swarm` option used in `show wids` commands
- π Fix incorrect base_url passed into GreenLakeAPI during instantiation
- π Fix potential for an IndexError when attempting fuzzy match (typo check), could happen if the cache being querried was empty.
- π Fix bug in batch_delete_sites
- π Fix ImportSite model deal with potential for NoneType as state (geo-loc)
- π½οΈ Fix output adjustment when API returns 404 when compliance policy is not set. API used to return reason "Not Found" now returns "ERROR" so we just key off 404
## Commands/Options Updates / New Commands/Features
- π§ configuration schema changed. β¨ Command `cencli convert config` available to update legacy schema
- β¨ Add `show bssids`
- β¨ Add `delete variables`
- β¨ Add `export redsky-bssids`
- β¨ Add `ts mesh` to run mesh / bridge related troubleshooting commands on APs
- πΈ Filter logs by device when --swarm option is used for a non-ap (`show logs --dev <not ap> --swarm`). `--swarm` is not just ignored in this scenario.
- πΈ return appropriate exit code when API calls fail or there is a partial failure.
- πΈ --sort in `show guests` now supports completion and has valid values in help text.
- β¨ Add logic to ignore group field for batch_add_devices if "retain_config" is in the import and set to True.
> retain_config is valid for batch move not batch add, batch add doesn't support retain_config
- β¨ auto detect cert format based on extension if no cert format is provided in `cencli add cert`
- β¨ `show config` for switch in template group uses diff API endpoint.
- β¨ Add `cencli show cloud-auth authentication` and `cencli show cloud-auth sessions`
- β°οΈ Remove `auto` as valid arg in `assign license`. No longer needed as `cencli enable/disable` was added to replace.
- π© `-s` flag for swarm is now `-S` so it does not conflict with `-s` for start in commands supporting time range.
- β¨ Add `unassign subscription` (GLP)
- πΈ Add missing confirmation prompt in batch archive
- β¨ Allow filtering of inventory output by `--key` (subscription key)
- β¨ Add `--location` flag for show clients. To see location from floor plan API
- π β»οΈ `show clients --denylisted --dev ...` moved to it's own command `show denylisted <DEVICE>`
- β¨ show device (ap, gateways, switches, switches, all, etc.) now support filtering by version or excluding a version.
- β¨ `upgrade device` now supports multiple devices.
- β¨ Add `cencli ts clear ...`
- β¨ `cencli assign subscription` (GLP) ... Implement query method that returns object with fields from both inv and dev cache.
## centralcli API changes (Library changes)
- β¨ Add ability for only template to be provided in utils.generate_template. Add logic to search parent dir of template_file for var_file matching same name (with yaml/json suffix)
- β‘οΈ fix auto device type based on filters in get_clients.
- β¨ utils.summarize_list can now flatten a list of lists
- β¨ β»οΈ get_sub_identifier now supports match by sub key (moved to it's own function)
- β¨ add `validate_wss_key` (websocket)
## Cache / database changes
- ποΈ Ensure inventory services (subscription) field is stored as a str not a list with 1 str
- ποΈ Improve cache update after site update.
- ποΈ normalize phone numbers stored in guest cache... always remove leading +
- ποΈ Add cache update after cert add,
- ποΈ Handle lack of id in Inventory cache
This can happen after adding devices, as we update the cache with what we know from the import, but don't do a cache update.
## Other / developer improvements
- π§βπ» β¨ Add `cencli dev` commands (hidden)
- β¨ π§βπ» Add dev commands to flip between v1 and v2 config (for testing)
- β¨ Add support for displaying or tailing pytest log
- π π remove all uses of requests.request (aiohttp form-data workaround).
Previously used as work-around due to not being able to sort out how to format form-data for aiohttp. Still using requests to prepare the payload (prepared request).
- β‘οΈ only check inv cache if doing inv operations in batch_delete_devices
- β
raise typer.Exit if handle_multi_match is called during pytest run
handle_multi_match requires a tty, tests / fixtures should be such that it never hits, but it's possible if things are not cleaned up properly in a hung or aborted test run.
- π₯ render.display_results exit_on_fail now defaults to True
- π cache.Cache.get_dev_identifier rename params swack/conductor_only to
swack_only: Only return matches that are VC or Conductor. (Used to be swack)
swack: When multiple matches only return VC or Conductor. Still returns standalone/non-vc matches if single match. (used to be conductor_only)
- π§βπ» Add `dev help-text` to verify formatting of summary / help text for all object types in cache.
- π Numerous tweaks to log output
- π€‘ Implement mocking to run large scale automated tests with mocked responses.
- β Add pytest-cov as dev dependency to track test coverage
- π© π§βπ» Add hidden global `--mock` flag.
> `--mock` is stripped before instantiating CLI so it will not impact any commands. It's only useful for `cencli show cache` it sets the env var PYTEST_VERSION resulting the mock cache being used for `cencli show cache` commands.