QualiSystems / shell-networking-standard

Repository for standards for use by CloudShell Shells.
Apache License 2.0
0 stars 2 forks source link

shellfoundry health check needs updates #26

Open ericrqs opened 8 years ago

ericrqs commented 8 years ago

This is what you get today:

def health_check(self, cancellation_context):
    """
    Checks if the device is up and connectable
    :return: None
    :exception Exception: Raises an error if cannot connect
    """
  1. The context parameter is missing
  2. The return value should be "Health check on resource ___ passed." and not None
  3. The template should include sample code for setting the live status which is part of the standard:

from cloudshell.api.cloudshell_api import CloudShellAPISession

    api = CloudShellAPISession(context.connectivity.server_address,
                               token_id=context.connectivity.admin_auth_token,
                               port=context.connectivity.cloudshell_api_port)

    rv = 'Health check on resource %s passed' % context.resource.fullname
    api.SetResourceLiveStatus(context.resource.fullname,  'Online', rv)
    return rv
ericrqs commented 8 years ago

also

rv = 'Health check on resource %s failed' % context.resource.fullname api.SetResourceLiveStatus(context.resource.fullname, 'Error', rv)