def run(
    ctx,
    host,
    cmd,
    console=None,
    timeout=None,
    exit_prompt=None,
    mgmt_ip=False,
    ip_address=None,
    port=None,
):
    cmd = " ".join(cmd)
    command_prompts = None

    if exit_prompt:
        command_prompts = {"exit": exit_prompt}
        cmd = cmd + "\nexit"

    d = ttypes.Device(
        hostname=host,
        username=ctx.obj.user,
        password=ctx.obj.passwd,
        console=console or "",
        mgmt_ip=mgmt_ip or False,
        ip_address=ip_address,
        command_prompts=command_prompts,
        session_data=ttypes.SessionData(
            extra_options={"port": port}) if port else None,
    )

    res = ctx.obj.run(cmd, d, timeout)
    print(res)
Exemple #2
0
def run(ctx, host, cmd, console=None, timeout=None, exit_prompt=None,
        mgmt_ip=False, ip_address=None,
        ):
    cmd = ' '.join(cmd)
    command_prompts = None

    if exit_prompt:
        command_prompts = {'exit': exit_prompt}
        cmd = cmd + '\nexit'

    d = ttypes.Device(hostname=host,
                      username=ctx.obj.user,
                      password=ctx.obj.passwd,
                      console=console or '',
                      mgmt_ip=mgmt_ip or False,
                      ip_address=ip_address,
                      command_prompts=command_prompts)

    res = ctx.obj.run(cmd, d, timeout)
    print(res)
Exemple #3
0
 def _create_device(self, name):
     return ttypes.Device(hostname=name, username=self.user, password=self.passwd)