示例#1
0
 def ftp_download(self, remote_url, filepath):
     url_obj = Url.get_url_obj(remote_url)
     command_template = CommandTemplate("get {src_location} {dst_location}",
                                        error_map=OrderedDict([]))
     return self._run_ftp_template(
         url_obj,
         command_template,
         src_location=url_obj.get_ftp_path(),
         dst_location=filepath,
     )
示例#2
0
 def scp_download(self, remote_url, filepath):
     url_obj = Url.get_url_obj(remote_url)
     command_template = CommandTemplate(
         "scp -P {scp_port} {src_location} {dst_location}")
     return self._run_scp_template(
         url_obj,
         command_template,
         scp_port=url_obj.port or "22",
         src_location=url_obj.get_scp_endpoint(),
         dst_location=filepath,
     )
示例#3
0
 def ftp_upload(self, filepath, remote_url):
     url_obj = Url.get_url_obj(remote_url)
     command_template = CommandTemplate(
         "put {src_location} {dst_location}",
         error_map=OrderedDict([(r"Could not create file",
                                 "FTP: Could not create file.")]),
     )
     return self._run_ftp_template(
         url_obj,
         command_template,
         src_location=filepath,
         dst_location=url_obj.get_ftp_path(),
     )
示例#4
0
from collections import OrderedDict

from cloudshell.cli.command_template.command_template import CommandTemplate

SET_REMOTE_FIRMWARE_FILE = CommandTemplate("file-name {remote_url}")

SET_REMOTE_FIRMWARE_USER = CommandTemplate("username {user}")

SET_REMOTE_FIRMWARE_PASSWORD = CommandTemplate("password {password}")

SET_REMOTE_FIRMWARE_NO_USER = CommandTemplate("no username")

SET_REMOTE_FIRMWARE_NO_PASSWORD = CommandTemplate("no password")

START_SW_UPGRADE = CommandTemplate("start")

SHOW_SW_UPGRADE_INFO = CommandTemplate("do show system sw-upgrade")

SET_REMOTE_FIRMWARE_BOOT_BANK = CommandTemplate("boot-bank {boot_bank}")

SYSTEM_REBOOT = CommandTemplate(
    "do system reboot",
    action_map=OrderedDict([(
        r"[Rr]eboot.*[yes]",
        lambda session, logger: session.send_line("yes", logger),
    )]),
)
示例#5
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

from cloudshell.cli.command_template.command_template import CommandTemplate

SHOW_IP_ADDR = CommandTemplate("show ip address | inc {ip_address}")
SHOW_SNMP_COMMUNITY = CommandTemplate(
    "more system:running-config | inc snmp-server host .* community")
ENABLE_SNMP_SERVER = CommandTemplate("snmp-server enable")
ENABLE_SNMP = CommandTemplate(
    "snmp-server host {iface_name} {hostname} poll community {snmp_community} version 2c"
)
DISABLE_SNMP = CommandTemplate(
    "no snmp-server host {iface_name} {hostname} poll community {snmp_community} version 2c"
)
示例#6
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

from cloudshell.cli.command_template.command_template import CommandTemplate

SYSTEM_SOFTWARE = CommandTemplate("show system software")
SYSTEM_INFO = CommandTemplate("show sys-id")
SLOT_INFO = CommandTemplate("show slot-id {slot_id}")
GET_CONN = CommandTemplate("show con {slot_id} all")
#!/usr/bin/python
# -*- coding: utf-8 -*-

from cloudshell.cli.command_template.command_template import CommandTemplate

BOOT_SYSTEM_FILE = CommandTemplate(
    "boot system flash bootflash:{firmware_file_name}")

CONFIG_REG = CommandTemplate("config-reg 0x2102")

SHOW_RUNNING = CommandTemplate("do show running-config | include boot")

SHOW_VERSION = CommandTemplate("show version")
#!/usr/bin/python
# -*- coding: utf-8 -*-

from collections import OrderedDict

from cloudshell.cli.command_template.command_template import CommandTemplate

ACTION_MAP = OrderedDict()
ERROR_MAP = OrderedDict([(r'[Ee]rror:', 'Command error')])

CHASSIS_TABLE = CommandTemplate('show table chassis dump', ACTION_MAP,
                                ERROR_MAP)
SLOT_TABLE = CommandTemplate('show table slot dump', ACTION_MAP, ERROR_MAP)
PORT_TABLE = CommandTemplate('show table port dump', ACTION_MAP, ERROR_MAP)
PROTOCOL_TABLE = CommandTemplate('show table protocol dump', ACTION_MAP,
                                 ERROR_MAP)
from cloudshell.cli.command_template.command_template import CommandTemplate

SAVE_CONFIGURATION_DATATYPE = CommandTemplate('transfer upload datatype {0}', [r'.+'],
                                              ['Wrong configuration type'])
SAVE_CONFIGURATION_MODE = CommandTemplate('transfer upload mode {0}', [r'.+'],
                                          ['Wrong upload mode'])
SAVE_CONFIGURATION_SERVERIP = CommandTemplate('transfer upload serverip {0}', [r'.+'],
                                              ['Wrong upload serverip'])
SAVE_CONFIGURATION_PORT = CommandTemplate('transfer upload port {0}', [r'.+'],
                                          ['Wrong upload port'])
SAVE_CONFIGURATION_USER = CommandTemplate('transfer upload username {0}', [r'.+'], ['Wrong upload username'])
SAVE_CONFIGURATION_PASSWORD = CommandTemplate('transfer upload password {0}', [r'.+'], ['Wrong upload password'])
SAVE_CONFIGURATION_PATH = CommandTemplate('transfer upload path {0}', [r'.+'],
                                          ['Wrong upload path'])
SAVE_CONFIGURATION_FILENAME = CommandTemplate('transfer upload filename {0}', [r'.+'],
                                              ['Wrong upload filename'])
SAVE_CONFIGURATION_START = CommandTemplate('transfer upload start')

RESTORE_CONFIGURATION_DATATYPE = CommandTemplate('transfer download datatype {0}', [r'.+'], ['Wrong download datatype'])
RESTORE_CONFIGURATION_MODE = CommandTemplate('transfer download mode {0}', [r'.+'], ['Wrong download mode'])
RESTORE_CONFIGURATION_SERVERIP = CommandTemplate('transfer download serverip {0}', [r'.+'],
                                                 ['Wrong download server address'])
RESTORE_CONFIGURATION_PORT = CommandTemplate('transfer download port {0}', [r'.+'], ['Wrong download server port'])
RESTORE_CONFIGURATION_USER = CommandTemplate('transfer download username {0}', [r'.+'], ['Wrong download username'])
RESTORE_CONFIGURATION_PASSWORD = CommandTemplate('transfer download password {0}', [r'.+'], ['Wrong download password'])

RESTORE_CONFIGURATION_PATH = CommandTemplate('transfer download path {0}', [r'.+'], ['Wrong download path'])
RESTORE_CONFIGURATION_FILENAME = CommandTemplate('transfer download filename {0}', [r'.+'], ['Wrong download filename'])
RESTORE_CONFIGURATION_START = CommandTemplate('transfer download start')
RESTORE_CONFIGURATION_SAVE_TO_NVRAM = CommandTemplate('save config')
示例#10
0
from collections import OrderedDict

from cloudshell.cli.command_template.command_template import CommandTemplate

ACTION_MAP = OrderedDict()
ERROR_MAP = OrderedDict([(r'[Ee]rror:', 'Command error')])

SWITCH_INFO = CommandTemplate(
    'switch "{switch_name}" switch-info-show format model,chassis-serial parsable-delim ":"',
    ACTION_MAP, ERROR_MAP)
SWITCH_SETUP = CommandTemplate('switch-setup-show format switch-name',
                               ACTION_MAP, ERROR_MAP)
SOFTWARE_VERSION = CommandTemplate('software-show', ACTION_MAP, ERROR_MAP)
PORT_SHOW = CommandTemplate(
    'switch "{switch_name}" port-config-show format port,speed,autoneg parsable-delim ":"',
    ACTION_MAP, ERROR_MAP)
PHYS_PORT_SHOW = CommandTemplate(
    'switch "{switch_name}" bezel-portmap-show format port,bezel-intf parsable-delim ":"',
    ACTION_MAP, ERROR_MAP)
ASSOCIATIONS = CommandTemplate(
    'port-association-show format master-ports,slave-ports,bidir, parsable-delim ":"',
    ACTION_MAP, ERROR_MAP)
FABRIC_NODES_SHOW = CommandTemplate(
    'fabric-node-show fab-name "{fabric_name}" format fab-name,name,in-band-ip parsable-delim ":"',
    ACTION_MAP, ERROR_MAP)
VLE_SHOW = CommandTemplate(
    'vle-show format name,node-1,node-2,node-1-port,node-2-port, parsable-delim ":"',
    ACTION_MAP, ERROR_MAP)
示例#11
0
from cloudshell.cli.command_template.command_template import CommandTemplate

CREATE_VLAN_INTERFACE = CommandTemplate('config interface create {0} {1}', [r'.+', r'.+'],
                                        ['Wrong interface name', 'Wrong vlan id'])
CONFIGURE_INTERFACE_PORT = CommandTemplate('config interface port {0} {1}', [r'.+', r'.+'],
                                           ['Wrong interface name', 'Wrong port name'])
DELETE_INTERFACE = CommandTemplate('config interface delete {0}', [r'.+'], ['Wrong interface name'])
INTERFACE_SUMMARY = CommandTemplate('show interface summary')
示例#12
0
from collections import OrderedDict

from cloudshell.cli.command_template.command_template import CommandTemplate

ERROR_MAP = OrderedDict([("[Ee]rror:",
                          "An error occurred while executing a CLI command")])

EXPORT_CONFIG_FILE_ANONYMOUS = CommandTemplate(
    "system config-files export local-file {config_file} remote-url {remote_url}",
    action_map=OrderedDict([(r"[Ee]rror:.*[Aa]access [Dd]enied",
                             "Failed uploading file: Access denied")]),
    error_map=ERROR_MAP,
)

EXPORT_CONFIG_FILE = CommandTemplate(
    "system config-files export local-file {config_file} remote-url {remote_url} "
    "username {user} password {password}",
    action_map=OrderedDict([(r"[Ee]rror:.*[Aa]access [Dd]enied",
                             "Failed uploading file: Access denied")]),
    error_map=ERROR_MAP,
)

IMPORT_CONFIG_FILE_ANONYMOUS = CommandTemplate(
    "system config-files import local-file {config_file} remote-url {remote_url}",
    error_map=ERROR_MAP,
    action_map=OrderedDict([(
        r"[Aa]lready [Ee]xists.*[Oo]verride.*[Yy]/[Nn]",
        lambda session, logger: session.send_line("y", logger),
    )]),
)
示例#13
0
from cloudshell.cli.command_template.command_template import CommandTemplate

ACTION_MAP = OrderedDict({
    "[\[\(][Yy]es/[Nn]o[\)\]]|\[confirm\]":
    lambda session: session.send_line("yes"),
    "[\[\(][Yy]/[Nn][\)\]]":
    lambda session: session.send_line("y")
})
ERROR_MAP = OrderedDict({
    "[Ii]nvalid\s*([Ii]nput|[Cc]ommand)|[Cc]ommand rejected":
    Exception("SWITCHPORT_MODE", "Failed to switch port mode"),
})

VLAN_SUB_IFACE = CommandTemplate(
    ("encapsulation dot1q {vlan_id} "
     "[, untagged{untagged}] [second-dot1q any{qnq}]"))

CONFIGURE_VLAN = CommandTemplate(
    "vlan {vlan_id}",
    error_map=OrderedDict({"%.*\.": Exception("CONFIGURE_VLAN", "Error")}),
)

SWITCHPORT_ALLOW_VLAN = CommandTemplate(
    ("switchport [trunk allowed{port_mode_trunk}] "
     "[access{port_mode_access}] vlan {vlan_range}"),
    ACTION_MAP,
    ERROR_MAP,
)

SWITCHPORT_MODE = CommandTemplate("switchport [mode {port_mode}]", ACTION_MAP,
示例#14
0
#!/usr/bin/python
# -*- coding: utf-8 -*-

from cloudshell.cli.command_template.command_template import CommandTemplate

CHANGE_PATH = CommandTemplate("cd {path}")
MAKE_DIRECTORY = CommandTemplate("mkdir -p {path}")
FILE_INFO = CommandTemplate("file {file_path}")
UNTAR_GZ_PACKAGE = CommandTemplate(
    "tar -xvzf {trex_package} | sed -e 's@/.*@@' | uniq")
UNTAR_PACKAGE = CommandTemplate(
    "tar -xvf {trex_package} | sed -e 's@/.*@@' | uniq")
CHECK_PATH_EXISTENCE = CommandTemplate("ls {path}")
CREATE_SIM_LINK = CommandTemplate("ln -s {source_path} {link_name}")
MOVE_FILE = CommandTemplate("mv -f {source_path} {dest_path}")
DOWNLOAD_FILE = CommandTemplate("wget -O {file_name} {url}")
示例#15
0
 def test_prepare_command(self):
     self.assertEqual(
         CommandTemplate("text[ text1 {arg1}]").prepare_command(), "text")
     self.assertEqual(
         CommandTemplate("text[ text1{arg1}]").prepare_command(), "text")
     self.assertEqual(
         CommandTemplate("text [text1 {arg1}]").prepare_command(), "text")
     self.assertEqual(
         CommandTemplate("text [text1{arg1}]").prepare_command(), "text")
     self.assertEqual(
         CommandTemplate("text[ text1 {arg1}]").prepare_command(
             arg1="test1"),
         "text text1 test1",
     )
     self.assertEqual(
         CommandTemplate("text[ text1{arg1}]").prepare_command(
             arg1="test1"),
         "text text1test1",
     )
     self.assertEqual(
         CommandTemplate("text [text1 {arg1}]").prepare_command(
             arg1="test1"),
         "text text1 test1",
     )
     self.assertEqual(
         CommandTemplate("text [text1{arg1}]").prepare_command(
             arg1="test1"),
         "text text1test1",
     )
     self.assertEqual(
         CommandTemplate(
             "text[ text1 {arg1}][ text2 {arg2}]").prepare_command(),
         "text",
     )
     self.assertEqual(
         CommandTemplate(
             "text [text1 {arg1}][ text2 {arg2}]").prepare_command(),
         "text",
     )
     self.assertEqual(
         CommandTemplate(
             "text[ text1 {arg1}] [text2 {arg2}]").prepare_command(),
         "text",
     )
     self.assertEqual(
         CommandTemplate("text[ text1 {arg1}][ text2 {arg2}]").
         prepare_command(arg1="test1"),
         "text text1 test1",
     )
     self.assertEqual(
         CommandTemplate("text [text1 {arg1}] [text2 {arg2}]").
         prepare_command(arg1="test1"),
         "text text1 test1",
     )
     self.assertEqual(
         CommandTemplate("text[ text1 {arg1}][ text2 {arg2}]").
         prepare_command(arg2="test2"),
         "text text2 test2",
     )
     self.assertEqual(
         CommandTemplate(
             "text[ text1 {arg1}][ text2 {arg2}]").prepare_command(
                 arg1="test1", arg2="test2"),
         "text text1 test1 text2 test2",
     )
     self.assertEqual(
         CommandTemplate(
             "text [text1 {arg1}] [text2 {arg2}]").prepare_command(
                 arg1="test1", arg2="test2"),
         "text text1 test1 text2 test2",
     )
示例#16
0
from cloudshell.cli.command_template.command_template import CommandTemplate

ENABLE_SNMP = CommandTemplate("v2c true")

SET_READ_COMMUNITY = CommandTemplate("read-community {snmp_community}")

SET_WRITE_COMMUNITY = CommandTemplate("write-community {snmp_community}")

DISABLE_SNMP = CommandTemplate("v2c false")

UNSET_READ_COMMUNITY = CommandTemplate("no read-community {snmp_community}")

UNSET_WRITE_COMMUNITY = CommandTemplate("no write-community {snmp_community}")
from cloudshell.cli.command_template.command_template import CommandTemplate
from cloudshell.cumulus.linux.command_templates import ERROR_MAP

# todo: move to SystemActions
SHUTDOWN = CommandTemplate("shutdown -h now", error_map=ERROR_MAP)
from cloudshell.cli.command_template.command_template import CommandTemplate

SET_STATUS_ENABLE = CommandTemplate('set status enable')

# SNMP V2
SHOW_V2_CONF = CommandTemplate('show system snmp community')

SET_COMMUNITY_NAME = CommandTemplate('set name {community}')
SET_V2C_STATUS_ENABLE = CommandTemplate('set query-v2c-status enable')

DELETE_SNMP_COMMUNITY = CommandTemplate('delete {community_id}')

# SNMP V3
SHOW_V3_CONF = CommandTemplate('show system snmp user')

# no-auth-no-priv | auth-no-priv | auth-priv
SET_SECURITY_LEVEL = CommandTemplate('set security-level {security_level}')
SET_AUTH_PROTO = CommandTemplate('set auth-proto {auth_type}')  # md5 | sha
SET_AUTH_PWD = CommandTemplate('set auth-pwd {password}')
# aes | des | aes256 | aes256cisco
SET_PRIV_PROTO = CommandTemplate('set priv-proto {priv_type}')
SET_PRIV_PWD = CommandTemplate('set priv-pwd {priv_key}')

DELETE_SNMP_USER = CommandTemplate('delete {user}')
示例#19
0
from cloudshell.cli.command_template.command_template import CommandTemplate

from cloudshell.checkpoint.gaia.command_templates.error_map import (
    BASIC_ERRORS,
    PASSWORD_ERROR_MAP,
)

SNMP_ERROR_MAP = OrderedDict([
    (
        "does not accept community strings",
        "SNMP v3-Only does not accept community strings.",
    ),
])
ERROR_MAP = OrderedDict(chain(BASIC_ERRORS.items(), SNMP_ERROR_MAP.items()))
ENABLE_SNMP_AGENT = CommandTemplate("set snmp agent on", error_map=ERROR_MAP)
DISABLE_SNMP_AGENT = CommandTemplate("set snmp agent off", error_map=ERROR_MAP)
SET_SNMP_VERSION = CommandTemplate("set snmp agent-version {snmp_version}",
                                   error_map=ERROR_MAP)
SET_RO_SNMP_COMMUNITY = CommandTemplate("set snmp community {name} read-only",
                                        error_map=ERROR_MAP)
SET_RW_SNMP_COMMUNITY = CommandTemplate("set snmp community {name} read-write",
                                        error_map=ERROR_MAP)

SNMP_PASSWORD_ERROR_MAP = OrderedDict(
    chain(BASIC_ERRORS.items(), PASSWORD_ERROR_MAP.items()))

SET_V3_SNMP_USER_NO_PRIV = CommandTemplate(
    "add snmp usm user {user} security-level authNoPriv auth-pass-phrase {password} "
    "authentication-protocol {auth_protocol}",
    error_map=SNMP_PASSWORD_ERROR_MAP,
示例#20
0
from cloudshell.cli.command_template.command_template import CommandTemplate

ADD_ACCESS_VLAN_FILTER = CommandTemplate(
    "filters add name {name} vlan-set-outer {vlan} "
    "input-ports {port} action redirect output-ports all")

ADD_TRUNK_VLAN_FILTER = CommandTemplate(
    "filters add name {name} l2-vlan {vlan_range} "
    "input-ports {port} action redirect output-ports all")
from collections import OrderedDict

from cloudshell.cli.command_template.command_template import CommandTemplate

ACTION_MAP = OrderedDict()
ERROR_MAP = OrderedDict([(r'[Ee]rror:', 'Command error')])

CONNECT = CommandTemplate('connection create {src_port} to {dst_port}',
                          ACTION_MAP, ERROR_MAP)
DISCONNECT = CommandTemplate(
    'connection disconnect {src_port} from {dst_port}', ACTION_MAP, ERROR_MAP)
CONNECTIONS = CommandTemplate('connection show connected', ACTION_MAP,
                              ERROR_MAP)
from cloudshell.cli.command_template.command_template import CommandTemplate
from cloudshell.cumulus.linux.command_templates import ERROR_MAP

COMMIT = CommandTemplate('net commit', error_map=ERROR_MAP)

ABORT = CommandTemplate('net abort', error_map=ERROR_MAP)
示例#23
0
from collections import OrderedDict

from cloudshell.cli.command_template.command_template import CommandTemplate

BOOT_SYSTEM_FILE = CommandTemplate("boot system flash:{firmware_file_name}")
SHOW_BOOT = CommandTemplate("show boot")

ACTION_MAP = OrderedDict()
ERROR_MAP = OrderedDict([(r'[Ee]rror:', 'Command error')])

SHOW_SNMP_COMMUNITY = CommandTemplate('show snmp community', action_map=ACTION_MAP, error_map=ERROR_MAP)
ENABLE_SNMP = CommandTemplate('snmp-server community {snmp_community} ro', action_map=ACTION_MAP, error_map=ERROR_MAP)
DISABLE_SNMP = CommandTemplate('no snmp-server community {snmp_community}', action_map=ACTION_MAP, error_map=ERROR_MAP)

import re

from cloudshell.cli.command_template.command_template import CommandTemplate

BACKUP_CONF = CommandTemplate(
    'execute backup config '
    '[flash{flash} {file_name}]'  # file system
    '[ftp{ftp} {file_path} {host}][:{port}][ {user}][ {password}]'
    '[tftp{tftp} {file_path} {host}]',
    error_map={
        r'fail': 'Fail to backup config',
        r'^((?!(OK|done)).)*$': 'Fail to copy a file',
    })

RESTORE_CONF = CommandTemplate(
    'execute restore config '
    '[flash{flash} {revision_id}]'  # file system
    '[ftp{ftp} {file_path} {host}][:{port}][ {user}][ {password}]'
    '[tftp{tftp} {file_path} {host}]',
    action_map={
        re.escape('(y/n)'):
        lambda session, logger: session.send_line('y', logger),
    },
    error_map={
        r'fail': 'Fail to restore config',
    })

SHOW_REVISIONS = CommandTemplate('execute revision list config')

LOAD_FIRMWARE = CommandTemplate(
    'execute restore image '
示例#25
0
from cloudshell.cli.command_template.command_template import CommandTemplate

ACTION_MAP = OrderedDict({
    r"[\[\(][Yy]es/[Nn]o[\)\]]|\[confirm\]":
    lambda session: session.send_line("yes"),
    r"[\[\(][Yy]/[Nn][\)\]]":
    lambda session: session.send_line("y"),
})
ERROR_MAP = OrderedDict({
    r"[Ii]nvalid\s*([Ii]nput|[Cc]ommand)|[Cc]ommand rejected":
    Exception("SWITCHPORT_MODE", "Failed to switch port mode")
})

VLAN_SUB_IFACE = CommandTemplate(
    command="encapsulation dot1q {vlan_id} [, untagged{untagged}] "
    "[second-dot1q any{qnq}]")

CONFIGURE_VLAN = CommandTemplate("vlan {vlan_id}",
                                 error_map=OrderedDict(
                                     {r"%.*\.": "Unable to create vlan"}))

SWITCHPORT_ALLOW_VLAN = CommandTemplate(
    "switchport [trunk allowed{port_mode_trunk}] [access{port_mode_access}] "
    "vlan {vlan_range}",
    action_map=ACTION_MAP,
    error_map=ERROR_MAP,
)

SWITCHPORT_MODE = CommandTemplate("switchport [mode {port_mode}]",
                                  action_map=ACTION_MAP,
示例#26
0
# !/usr/bin/python
# -*- coding: utf-8 -*-

from collections import OrderedDict
from cloudshell.cli.command_template.command_template import CommandTemplate

COPY = CommandTemplate('copy [/noconfirm {noconfirm}] {src} {dst}',
                       action_map=OrderedDict({
                           r'\[confirm\]': lambda session, logger: session.send_line('', logger),
                           r'\(y/n\)': lambda session, logger: session.send_line('y', logger),
                           r'[Oo]verwrit+e': lambda session, logger: session.send_line('y', logger),
                           r'\([Yy]es/[Nn]o\)': lambda session, logger: session.send_line('yes', logger)}))

DEL = CommandTemplate('del {target}', action_map=OrderedDict(
    {'[confirm]': lambda session, logger: session.send_line('', logger),
     '\?': lambda session, logger: session.send_line('', logger)}))

CONFIGURE_REPLACE = CommandTemplate('configure replace {path}',
                                    action_map=OrderedDict({
                                        '[\[\(][Yy]es/[Nn]o[\)\]]|\[confirm\]': lambda session,
                                                                                       logger: session.send_line('yes',
                                                                                                                 logger),
                                        '\(y\/n\)': lambda session, logger: session.send_line('y', logger),
                                        '[\[\(][Nn]o[\)\]]': lambda session, logger: session.send_line('y', logger),
                                        '[\[\(][Yy]es[\)\]]': lambda session, logger: session.send_line('y', logger),
                                        '[\[\(][Yy]/[Nn][\)\]]': lambda session, logger: session.send_line('y', logger),
                                        'overwrit+e': lambda session, logger: session.send_line('yes', logger)}),
                                    error_map=OrderedDict({
                                        "[Rr]ollback\s*[Dd]one|(?<=%).*(not.*|in)valid.*(?=\n)":
                                            Exception("Configure_Replace",
                                                      "Configure replace completed with error"),
示例#27
0
from cloudshell.cli.command_template.command_template import CommandTemplate

SHOW_PORTS = CommandTemplate("show ports")
SHOW_SYSTEM_DETAILS = CommandTemplate("show system details")
示例#28
0
from collections import OrderedDict

from cloudshell.cli.command_template.command_template import CommandTemplate

ERROR_MAP = OrderedDict({
    r"[Ss]yntax\s*[Ee]rror":
    "Failed to initialize snmp. "
    "Please check Logs for details."
})

ENABLE_SNMP_ACCESS = CommandTemplate(
    "modify sys snmp allowed-addresses add {{ 0.0.0.0/0 }}",
    error_map=ERROR_MAP)
DISABLE_SNMP_ACCESS = CommandTemplate(
    "modify sys snmp allowed-addresses delete {{ 0.0.0.0/0 }}",
    error_map=ERROR_MAP)
SHOW_SNMP_ACCESS = CommandTemplate("list sys snmp allowed-addresses",
                                   error_map=ERROR_MAP)

CREATE_SNMP_COMMUNITY = CommandTemplate(
    "modify /sys snmp communities add {{ {snmp_community} {{ access {read_access} "
    "community-name {snmp_community}}} }}",
    error_map=ERROR_MAP,
)
REMOVE_SNMP_COMMUNITY = CommandTemplate(
    "modify /sys snmp communities delete {{ {snmp_community} }}",
    error_map=ERROR_MAP)
SHOW_SNMP_COMMUNITY = CommandTemplate(
    "list /sys snmp communities | grep  community-name", error_map=ERROR_MAP)

ADD_SNMP_USER = CommandTemplate(
from collections import OrderedDict

from cloudshell.cli.command_template.command_template import CommandTemplate


ACTION_MAP = OrderedDict({
    "[\[\(][Yy]es/[Nn]o[\)\]]|\[confirm\]":
        lambda session: session.send_line("yes"),
    "[\[\(][Yy]/[Nn][\)\]]":
        lambda session: session.send_line("y"),
})
ERROR_MAP = OrderedDict({
    "[Ii]nvalid\s*([Ii]nput|[Cc]ommand)|[Cc]ommand rejected":
        Exception("Interface Commands", "Failed to send command"),
})

CONFIGURE_INTERFACE = CommandTemplate(
    "interface {port_name} [l2transport{l2transport}]", ACTION_MAP, ERROR_MAP)

REMOVE_INTERFACE = CommandTemplate("no interface {port_name}")

NO_SHUTDOWN = CommandTemplate("no shutdown")

SHOW_RUNNING = CommandTemplate("do show running-config [interface {port_name}]")

SHUTDOWN = CommandTemplate("shutdown")

STATE_ACTIVE = CommandTemplate("state active")
示例#30
0
from cloudshell.cli.command_template.command_template import CommandTemplate

ABORT = CommandTemplate("abort")

COMMIT = CommandTemplate("commit",
                         error_map={"[Aa]borted:": "Unable to commit changes"})