f5devcentral / f5-cli

F5 CLI
Apache License 2.0
12 stars 1 forks source link

extention package verify --component * leads to error #3

Open vbojko opened 4 years ago

vbojko commented 4 years ago

when I run this command in docker:latest container it leads to error message


bash-5.0# f5 bigip extension package verify --component as3 Traceback (most recent call last): File "/usr/local/bin/f5", line 8, in sys.exit(cli()) File "/usr/local/lib/python3.7/site-packages/click/core.py", line 764, in call return self.main(args, kwargs) File "/usr/local/lib/python3.7/site-packages/click/core.py", line 717, in main rv = self.invoke(ctx) File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1137, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1137, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1137, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/local/lib/python3.7/site-packages/click/core.py", line 956, in invoke return ctx.invoke(self.callback, ctx.params) File "/usr/local/lib/python3.7/site-packages/click/core.py", line 555, in invoke return callback(args, kwargs) File "/usr/local/lib/python3.7/site-packages/click/decorators.py", line 64, in new_func return ctx.invoke(f, obj, *args, *kwargs) File "/usr/local/lib/python3.7/site-packages/click/core.py", line 555, in invoke return callback(args, kwargs) File "/usr/local/lib/python3.7/site-packages/f5cli/commands/cmd_bigip/init.py", line 52, in package management_kwargs = dict(port=auth['port'], user=auth['user'], password=auth['password']) KeyError: 'user'

shyawnkarim commented 4 years ago

I just tried this command and it worked after following the steps on this page. Are these the steps that you followed as well?

kreynoldsf5 commented 4 years ago
bash-5.0# f5 config auth create --authentication-provider bigip --name bigip --host 192.168.0.245 --port 8443 --set-default
{
    "message": "Authentication configured successfully"
}
bash-5.0# f5 bigip extension package verify --component as3
Traceback (most recent call last):
  File "/usr/local/bin/f5", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/f5cli/commands/cmd_bigip/__init__.py", line 52, in package
    management_kwargs = dict(port=auth['port'], user=auth['user'], password=auth['password'])
KeyError: 'user'
bash-5.0# f5 config auth create --authentication-provider bigip --name bigip --host 192.168.0.245 --port 8443 --set-default
{
    "message": "Authentication configured successfully"
}
bash-5.0# f5 bigip extension as3 verify
Traceback (most recent call last):
  File "/usr/local/bin/f5", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/f5cli/commands/cmd_bigip/__init__.py", line 66, in command_as3
    get_mgmt_client(),
  File "/usr/local/lib/python3.7/site-packages/f5cli/commands/cmd_bigip/__init__.py", line 209, in get_mgmt_client
    user=auth['user'],
KeyError: 'user'
bash-5.0#

To summarize, there should be an error handler for this condition. This specific condition is not having a user at the time the cli attempts to get_mgmt_client() (according to the AuthConfigurationClient class the user could come from an auth object or from cli args).

def get_mgmt_client():
    """ Get Management Client """

    auth_client = AuthConfigurationClient()
    auth = auth_client.read_auth(constants.AUTHENTICATION_PROVIDERS['BIGIP'])

    management_kwargs = dict(
        port=auth['port'],
        user=auth['user'],
        password=auth['password']
    )
    return ManagementClient(auth['host'], **management_kwargs)

The problem statement should be expanded to including an error handler for cases where any value from the management_kwargs dict is missing.

shyawnkarim commented 4 years ago

Thanks for reporting this issue. I have created a ticket for this enhancement, internal ID AUTOSDK-304.