-
Notifications
You must be signed in to change notification settings - Fork 13
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 #44 from MarkGodwin/feature/rename_client
New features for Clients and Omada controllers
- Loading branch information
Showing
11 changed files
with
305 additions
and
55 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build" | |
|
||
[project] | ||
name = "tplink_omada_client" | ||
version = "1.3.12" | ||
version = "1.3.13" | ||
authors = [ | ||
{ name="Mark Godwin", email="[email protected]" }, | ||
] | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
"""Implementation for 'set-certificate' command""" | ||
|
||
from argparse import ArgumentParser | ||
import getpass | ||
|
||
from tplink_omada_client.definitions import GatewayPortMode, PoEMode | ||
|
||
from .config import get_target_config, to_omada_connection | ||
from .util import get_target_argument | ||
|
||
async def command_certificate(args) -> int: | ||
"""Executes 'set-certificate' command""" | ||
controller = get_target_argument(args) | ||
config = get_target_config(controller) | ||
|
||
if args['password']: | ||
password = args['password'] | ||
else: | ||
password = getpass.getpass() | ||
|
||
async with to_omada_connection(config) as client: | ||
await client.set_certificate(args["cert-file"], password) | ||
|
||
print("Certificate uploaded successfully, and enabled. Please reboot the controller to apply the changes.") | ||
return 0 | ||
|
||
def arg_parser(subparsers) -> None: | ||
"""Configures arguments parser for 'set-certificate' command""" | ||
parser: ArgumentParser = subparsers.add_parser( | ||
"set-certificate", | ||
help="Sets a new certificate for the Omada controller." | ||
) | ||
parser.set_defaults(func=command_certificate) | ||
|
||
parser.add_argument( | ||
"cert-file", | ||
help="The certificate file to upload. Must be in PKCS12 PFX format." | ||
) | ||
|
||
parser.add_argument('-p', '--password', help="The password for the certificate", required=False) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"""Implementation for 'reboot' command""" | ||
|
||
from argparse import ArgumentParser | ||
import getpass | ||
|
||
from tplink_omada_client.definitions import GatewayPortMode, PoEMode | ||
|
||
from .config import get_target_config, to_omada_connection | ||
from .util import get_target_argument | ||
|
||
async def command_reboot(args) -> int: | ||
"""Executes 'reboot' command""" | ||
controller = get_target_argument(args) | ||
config = get_target_config(controller) | ||
|
||
async with to_omada_connection(config) as client: | ||
reboot_time = await client.reboot() | ||
|
||
print(f"Controller is rebooting, and should be back up in approximately {reboot_time} seconds.") | ||
return 0 | ||
|
||
def arg_parser(subparsers) -> None: | ||
"""Configures arguments parser for 'gateway' command""" | ||
parser: ArgumentParser = subparsers.add_parser( | ||
"reboot", | ||
help="Reboot the Omada Controller" | ||
) | ||
parser.set_defaults(func=command_reboot) | ||
|
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
Oops, something went wrong.