""" From the named address-space, look up the entry, if it exists in the database, validate the 'origin' is either null, or 'cli', otherwise provide a warning about this particular address-space (along with the originator name) """ external_origin = address_space_origin_external(data) if external_origin: command.sdnsh.warning( 'address-space %s may not be intended for cli update, ' 'origin/creator "%s" ' % (data['name'], external_origin)) command.add_action('address-space-warn-external-config', address_space_warn_external_config, {'kwargs': { 'data': '$data', }}) def address_space_confirm_external_delete(data): """ From the named address-space, look up the entry, if it exists in the database, validate the 'origin' is either null, or 'cli', otherwise provide a warning about this particular address-space (along with the originator name) """ external_origin = address_space_origin_external(data) if external_origin: confirm = command.action_registry['confirm'][0] # XXX accessor? confirm('address-space %s may not be intended for cli delete, '
from midw import local_interfaces_firewall_open def snmp_validate_firewall(data): intfs = local_interfaces_firewall_open(['udp', 'tcp'], 161) if len(intfs) == 0: # by issueing a warning, running-config doesn't display the # error during replay. command.sdnsh.warning( 'SNMP server port not open on any controller-node ' 'interface. Use firewall rule configuration to open ' 'SNMP UDP port 161') command.add_action('snmp-validate-firewall', snmp_validate_firewall, {'kwargs': { 'data': '$data', }}) # # -------------------------------------------------------------------------------- # SNMP command descriptions # # [no] snmp-server enable # [no] snmp-server community <string> # [no] snmp-server location <string> # [no] snmp-server contact <string> # SNMP_SERVER_COMMAND_DESCRIPTION = { 'name': 'snmp-server', 'mode':
) }, { 'field' : 'detail', 'type' : 'enum', 'values' : ('details','brief'), 'optional' : True, } ) } def display_schema(data): return command.sdnsh.sdndb.schema_detail(data['path']) command.add_action('display-schema', display_schema, {'kwargs' : { 'data' : '$data' } } ) INTERNAL_SHOW_SCHEMA_COMMAND_DESCRIPTION = { 'name' : 'show', 'mode' : 'config-internal', 'feature' : 'experimental', 'no-supported' : False, 'short-help' : 'Show controller devices', 'action' : 'display-schema', 'args' : ( 'schema', { 'field' : 'path', 'type' : 'string', }, ),
ips = row['ip-address'] if len(ips) > 2: row['ip-address'] = ips[0] + ',' + ips[1] + '+(%s)' % (len(ips) - 2) else: row['ip-address'] = ','.join(ips) if 'attachment-point' in row: aps = row['attachment-point'] row['attachment-point'] = aps[0] if len(aps) > 1: row['attachment-point'] += '+(%s)' % (len(aps) - 1) # remove unused tables from table_names bigdb_show.remove_tables(del_idx) command.add_action('host-compose', host_compose, ) # use the defined column header from a specific attribute def column_header(path, default = None): return command.column_header(path, default) host_show_mac_action = ( { 'proc' : 'show-compose', 'path' : 'core/device', 'style' : 'table', 'label' : 'host', }, { 'proc' : 'host-compose',
if not'src-tenant' in data: data['src-tenant']=tenant data['src-vns']= data['src-tenant'] + '|' + data ['src-vns'] if 'dst-vns' in data: if not 'dst-tenant' in data: data['dst-tenant']=tenant data['dst-vns']= data['dst-tenant'] + '|' + data ['dst-vns'] if 'vns-connected' in data: data['vns-connected']=tenant+'|'+data['vns-connected'] if 'router-connected-tenant' in data: if tenant !='system' and data['router-connected-tenant']!='system': command.sdnsh.warning('Tenant router interface can only connected to system tenant router\n') data['router-connected']= data['router-connected-tenant'] +'|'+ data['router-connected'] del data['router-connected-tenant'] command.add_action('virtualrouter-warn-external-config', virtualrouter_warn_external_config, {'kwargs': {'data' : '$data',}}) command.add_action('virtualrouter-preprocess', virtualrouter_preprocess, {'kwargs': {'data' : '$data',}}) command.add_action('verify-router-intf-ip', verify_router_intf_ip, {'kwargs': {'data' : '$data',}}) command.add_action('verify-router-gw-ip', verify_router_gw_ip, {'kwargs': {'data' : '$data',}}) def complete_virtualrouter_preprocess(data): obj_id = command.sdnsh.get_current_mode_obj() if '|' in obj_id: parts=obj_id.split('|') data['tenant']=parts[0] data['virtual-router']=parts[0]+'|' + parts[1] else:
'help': 'Enter Internal CLI debugging mode', 'short-help': 'Enter CLI internal debugging mode', 'doc': 'internal|internal', 'doc-example': 'internal|internal-example', 'command-type': 'config-submode', 'submode-name': 'config-internal', 'args': (), } def display_schema(data): return command.bigsh.bigdb.schema_detail(data['path']) command.add_action('display-schema', display_schema, {'kwargs': { 'data': '$data' }}) INTERNAL_SHOW_SCHEMA_COMMAND_DESCRIPTION = { 'name': 'show', 'mode': 'config-internal', 'feature': 'experimental', 'no-supported': False, 'short-help': 'Show controller devices', 'action': 'display-schema', 'args': ( 'schema', { 'field': 'path', 'type': 'string', },
del data['vnsname'] if 'vns' in data and data['vns']=='all': if scoped=='True': data['scoped']=False del data['tenant'] if 'vrname' in data: if (obj_type!='virtualrouter'): data['virtual-router']=data['tenant'] +'|'+data['vrname'] if 'vriname' in data: if (obj_type!='virtualrouter-interface'): data['virtual-router-interface']=data['tenant'] +'|'+data['vrname'] +'|' + data['vriname'] if 'vrgwname' in data: if (obj_type!='virtualrouter-gwpool'): data['virtual-router-gwpool']=data['tenant'] +'|'+data['vrname'] +'|' + data['vrgwname'] """ command.add_action('tenant-show-preprocess', tenant_show_preprocess, {'kwargs': {'obj_type': '$obj-type', 'data' : '$data', 'scoped' : '$scoped',}}) command.add_action('tenant-warn-external-config', tenant_warn_external_config, {'kwargs': {'data' : '$data',}}) def complete_tenant_preprocess(data): if 'name' in data: data['tenant'] =data['name'] command.add_completion('complete-tenant-preprocess', complete_tenant_preprocess, {'kwargs': {'data': '$data', }}) #
# Licensed under the Eclipse Public License, Version 1.0 (the # "License"); you may not use this file except in compliance with the # License. You may obtain a copy of the License at # # http://www.eclipse.org/legal/epl-v10.html # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # implied. See the License for the specific language governing # permissions and limitations under the License. # import command import fmtcnv ''' def address_space_origin_external (data): """ Return origin-name when the address space wasn't created by the cli, return None otherwise. """ pk = command.mi.pk('address-space') if not pk in data: return; address_space = command.sdnsh.get_table_from_store('address-space', pk, data[pk]) if len(address_space) == 0: return None local = ['cli', 'rest']
'user subdirectory:' + user_directory) else: # the mkdir seems to honor umask. os.chmod(user_directory, dir_modes) # hush_login = os.path.join(user_directory, '.hushlogin') if not os.path.exists(hush_login): fno = os.open(hush_login, os.O_WRONLY | os.O_CREAT, 0600) os.close(fno) command.add_action('aaa-user-directory', aaa_user_directory, { 'kwargs' : { 'data' : '$data', 'no_command' : '$is-no-command',}}) USER_SUBMODE_COMMAND_DESCRIPTION = { 'name' : 'user', 'path' : 'core/aaa/local-user', 'mode' : 'config*', 'short-help' : 'Enter configuration submode for user accounts', 'command-type' : 'config-submode', 'submode-name' : 'config-local-user', 'short-help' : 'Enter user submode, configure user details', 'rbac-group' : 'admin', 'show-this' : 'show user %(user-name)s', 'item-name' : 'user-name', 'rc-order' : 7000000,
row['ip-address'] = ips[0] + ',' + ips[1] + '+(%s)' % ( len(ips) - 2) else: row['ip-address'] = ','.join(ips) if 'attachment-point' in row: aps = row['attachment-point'] row['attachment-point'] = aps[0] if len(aps) > 1: row['attachment-point'] += '+(%s)' % (len(aps) - 1) # remove unused tables from table_names bigdb_show.remove_tables(del_idx) command.add_action( 'host-compose', host_compose, ) # use the defined column header from a specific attribute def column_header(path, default=None): return command.column_header(path, default) host_show_mac_action = ( { 'proc': 'show-compose', 'path': 'core/device', 'style': 'table', 'label': 'host', },
from midw import local_interfaces_firewall_open def snmp_validate_firewall(data): intfs = local_interfaces_firewall_open(["udp", "tcp"], 161) if len(intfs) == 0: # by issueing a warning, running-config doesn't display the # error during replay. command.sdnsh.warning( "SNMP server port not open on any controller-node " "interface. Use firewall rule configuration to open " "SNMP UDP port 161" ) command.add_action("snmp-validate-firewall", snmp_validate_firewall, {"kwargs": {"data": "$data"}}) # # -------------------------------------------------------------------------------- # SNMP command descriptions # # [no] snmp-server enable # [no] snmp-server community <string> # [no] snmp-server location <string> # [no] snmp-server contact <string> # SNMP_SERVER_COMMAND_DESCRIPTION = { "name": "snmp-server", "mode": "config*", "short-help": "SMNP configuration, enable server, configure parameters",
if 'vns' in data and data['vns']=='all': if scoped=='True': data['scoped']=False del data['tenant'] if 'vrname' in data: if (obj_type!='virtualrouter'): data['virtual-router']=data['tenant'] +'|'+data['vrname'] if 'vriname' in data: if (obj_type!='virtualrouter-interface'): data['virtual-router-interface']=data['tenant'] +'|'+data['vrname'] +'|' + data['vriname'] if 'vrgwname' in data: if (obj_type!='virtualrouter-gwpool'): data['virtual-router-gwpool']=data['tenant'] +'|'+data['vrname'] +'|' + data['vrgwname'] command.add_action('tenant-show-preprocess', tenant_show_preprocess, {'kwargs': {'obj_type': '$obj-type', 'data' : '$data', 'scoped' : '$scoped',}}) command.add_action('tenant-warn-external-config', tenant_warn_external_config, {'kwargs': {'data' : '$data',}}) def complete_tenant_preprocess(data): if 'name' in data: data['tenant'] =data['name'] command.add_completion('complete-tenant-preprocess', complete_tenant_preprocess, {'kwargs': {'data': '$data', }}) # # ---------------------------------------------------------------------- # tenant submode commands #
def address_space_warn_external_config (data): """ From the named address-space, look up the entry, if it exists in the database, validate the 'origin' is either null, or 'cli', otherwise provide a warning about this particular address-space (along with the originator name) """ external_origin = address_space_origin_external(data) if external_origin: command.sdnsh.warning( 'address-space %s may not be intended for cli update, ' 'origin/creator "%s" ' % (data['name'], external_origin)) command.add_action('address-space-warn-external-config', address_space_warn_external_config, {'kwargs': {'data' : '$data',}}) def address_space_confirm_external_delete (data): """ From the named address-space, look up the entry, if it exists in the database, validate the 'origin' is either null, or 'cli', otherwise provide a warning about this particular address-space (along with the originator name) """ external_origin = address_space_origin_external(data) if external_origin: confirm = command.action_registry['confirm'][0] # XXX accessor? confirm('address-space %s may not be intended for cli delete, ' 'origin/creator "%s"\nEnter y or yes to continue delete: '