Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Add version output as cli arg #90

Merged
merged 1 commit into from
Oct 10, 2024
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 .changelogs/1.0.4/89_add_version_output.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
added:
- Add version output cli arg. [#89]
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ The following options and parameters are currently supported:
| -j | --json | Returns a JSON of the VM movement. | Unset |
| -b | --best-node | Returns the best next node for a VM/CT placement (useful for further usage with Terraform/Ansible). | Unset |
| -m | --maintenance | Sets node(s) to maintenance mode & moves workloads away. | Unset |
| -v | --version | Returns the ProxLB version on stdout. | Unset |

### Balancing
#### General
Expand Down
10 changes: 10 additions & 0 deletions proxlb
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,17 @@ def initialize_args():
argparser.add_argument('-j', '--json', help='Return a JSON of the VM movement.', action='store_true', required=False)
argparser.add_argument('-b', '--best-node', help='Returns the best next node.', action='store_true', required=False)
argparser.add_argument('-m', '--maintenance', help='Sets node to maintenance mode & moves workloads away.', type=str, required=False)
argparser.add_argument('-v', '--version', help='Returns the current ProxLB version.', action='store_true', required=False)
return argparser.parse_args()


def proxlb_output_version():
""" Print ProxLB version information on CLI. """
print(f'{__appname__} version {__version__}\nRequired config version: >= {__config_version__}')
print('ProxLB support: https://github.com/gyptazy/ProxLB\nDeveloper: gyptazy.com')
sys.exit(0)


def initialize_config_path(app_args):
""" Initialize path to ProxLB config file. """
info_prefix = 'Info: [config]:'
Expand Down Expand Up @@ -1495,6 +1503,8 @@ def main():
# Initialize PAS.
initialize_logger('CRITICAL')
app_args = initialize_args()
if app_args.version:
proxlb_output_version()
config_path = initialize_config_path(app_args)
pre_validations(config_path)

Expand Down
Loading