Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
heyglen committed May 19, 2016
1 parent da1589a commit 2888fbc
Show file tree
Hide file tree
Showing 12 changed files with 124 additions and 47 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# sublime-network
# Sublime Network

Sublime Text 3 network configuration syntax highlighting and completions.

Network configuration syntax highlighting, completions and snippets for Sublime Text.
Sublime Text 2 is not supported.

Supports:
* Cisco ACE
Expand Down
6 changes: 0 additions & 6 deletions Symbol List - Interfaces.YAML-tmPreferences

This file was deleted.

44 changes: 31 additions & 13 deletions cisco-asa.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ contexts:
push:
- meta_content_scope: text.network.cisco.configure_terminal
- include: aaa
- include: acl
- include: snmp
- include: vlan
- include: logging
Expand All @@ -159,6 +158,7 @@ contexts:
- include: ip_route
- include: password
- include: interface
- include: access_list
- include: reverse_path
- include: access_group
- include: object_group
Expand Down Expand Up @@ -435,24 +435,42 @@ contexts:
6: support.constant # range
7: constant.numeric # target range
acl:
- include: acl_cached_log_flows
- include: acl_remark
- include: acl_icmp
- include: acl_ip
access_list:
- include: access_list_cached_log_flows
- include: access_list_remark
- include: access_list_icmp
- include: access_list_ip
- include: building_access_list

acl_remark:
building_access_list:
- match: >
(?x)
(access-list)\s+
([^;\s]+)\s+(remark)(\s+.*)?
([^;\s]+)\s+(?:(line)\s+(\d+)\s+)?(extended)\s+(?:(permit)|(deny))\s+.*
captures:
0: asa.acl_entry
1: support.constant # access-list
2: string.unquoted # access-list name
3: support.constant # remark
4: comment.unquoted # remark string
3: support.constant # line
4: constant.numeric # line number
5: support.constant # extended
6: entity.other.attribute-name # permit
7: keyword.other # deny
access_list_remark:
- match: >
(?x)
(access-list)\s+
([^;\s]+)\s+(?:(line)\s+(\d+)\s+)?(remark)(\s+.*)?
captures:
1: support.constant # access-list
2: string.unquoted # access-list name
3: support.constant # line
4: constant.numeric # line number
5: support.constant # remark
6: comment.unquoted # remark string
acl_cached_log_flows:
access_list_cached_log_flows:
- match: >
(?x)
access-list\s+cached\s+(\S+)\s+log\s+flows:\s+
Expand All @@ -466,7 +484,7 @@ contexts:
0: comment.unquoted
pop: true
acl_ip:
access_list_ip:
- match: |
(?x)
(access-list)\s+
Expand Down Expand Up @@ -573,7 +591,7 @@ contexts:
51: comment.unquoted # ace hash
52: comment.unquoted # hitcount
acl_icmp:
access_list_icmp:
- match: |
(?x)
(access-list)\s+
Expand Down
15 changes: 15 additions & 0 deletions cisco/asa/asa.access_list.sublime-completions
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"scope": "(text.network.cisco.asa & text.network.cisco.configure_terminal) & asa.acl_entry",
"completions": [
"inactive",
{
"trigger": "object-group\tname",
"contents": "object-group ${1:USERNAME} "
},
{
"trigger": "host\tip",
"contents": "host ${1:127.0.0.1} "
},
]
}

24 changes: 14 additions & 10 deletions cisco/asa/asa.configure_terminal.sublime-completions
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"scope": "(text.network.cisco.asa & text.network.cisco.configure_terminal) & -(text.network.cisco.asa. )",
"scope": "(text.network.cisco.asa & text.network.cisco.configure_terminal) & -(asa.acl_entry)",
"completions": [
{
"trigger": "username\tpassword",
Expand Down Expand Up @@ -47,7 +47,7 @@
},
{
"trigger": "context\tcontext",
"contents": "context ${1:NAME}\n\t$0\nexit"
"contents": "context ${1:NAME}\n $0\nexit"
},
{
"trigger": "ssh\ttimeout",
Expand Down Expand Up @@ -111,7 +111,7 @@
},
{
"trigger": "object\thost",
"contents": "object network obj-${1:ip-address}_32\n\thost ${1:ip-address}\nexit"
"contents": "object network obj-${1:ip-address}_32\n host ${1:ip-address}\nexit"
},
{
"trigger": "password\tencryption aes",
Expand All @@ -123,7 +123,7 @@
},
{
"trigger": "object\tnat",
"contents": "object network obj-${1:private-ip}_32\n\thost ${1:private-ip}\n\texit\nobject network obj-${2:public-ip}_32\nhost ${2:public-ip}\n\texit\n\tobject network obj-${1:private-ip}_32\n\tnat static obj-${2:public-ip}_32\n\texit"
"contents": "object network obj-${1:private-ip}_32\n host ${1:private-ip}\n exit\nobject network obj-${2:public-ip}_32\nhost ${2:public-ip}\n exit\n object network obj-${1:private-ip}_32\n nat static obj-${2:public-ip}_32\n exit"
},
{
"trigger": "access-group\tin",
Expand All @@ -135,27 +135,31 @@
},
{
"trigger": "object\thost",
"contents": "object network obj-${1:ip-address}_32\n\t$0\n exit"
"contents": "object network obj-${1:ip-address}_32\n $0\n exit"
},
{
"trigger": "object-group\tfqdn",
"contents": "object network fqdn-${1:server.domain.root}\n\t$0\n exit"
"contents": "object network fqdn-${1:server.domain.root}\n $0\n exit"
},
{
"trigger": "object-group\tnetwork",
"contents": "object-group network ${1:name}\n\t$0\n exit"
"contents": "object-group network ${1:name}\n $0\n exit"
},
{
"trigger": "object-group\tservice",
"contents": "object-group service ${1:name}\n $0\n exit"
},
{
"trigger": "object-group\ttcp-udp",
"contents": "object-group service ${1:name} tcp-udp\n\t$0\n exit"
"contents": "object-group service ${1:name} tcp-udp\n $0\n exit"
},
{
"trigger": "object-group\ttcp",
"contents": "object-group service ${1:name} tcp\n\t$0\n exit"
"contents": "object-group service ${1:name} tcp\n $0\n exit"
},
{
"trigger": "object-group\tudp",
"contents": "object-group service ${1:name} udp\n\t$0\n exit"
"contents": "object-group service ${1:name} udp\n $0\n exit"
},

]
Expand Down
47 changes: 47 additions & 0 deletions docs/configuration_modes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
## Configuration Modes

The syntax and snippets are aware of the current configuration mode of your configuration.

The side effect of this is that in order for them to work, you must explicitly enter and exit configuration modes.

You exit out of configuration modes using `exit` just as you would in the cli.

The default configuration mode is *enable*.

### Example

**Incorrect**
```
hostname router01
```

Since you can only set the hostname in `configure terminal` mode.

**Correct**
```
configure terminal
hostname router01
exit
```

You must exit out of all configuration modes:

**Incorrect**
```
configure terminal
interface eth1
description blah blah blah
hostname switch01
exit
```
In this example the interface configuration mode was never exited out of so the configuration mode command `hostname switch01` is not valid

**Correct**
```
configure terminal
interface Ethernet1
description blah blah blah
exit
hostname switch01
exit
```
3 changes: 3 additions & 0 deletions messages/0.1.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# v0.1.0

- [Configuration Mode Support](docs/configuration_mode.md)
7 changes: 0 additions & 7 deletions sublime-network.sublime-settings

This file was deleted.

2 changes: 1 addition & 1 deletion tests/syntax_test_cisco_ace.cisco-ace
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

config-register 0x1

boot system image:xxx
boot system image:image_name
write memory all
show running-config
reload
Expand Down
12 changes: 7 additions & 5 deletions tests/syntax_test_cisco_asa.cisco-asa
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ object network obj-www.fqdn.com

access-list cached ACL log flows: total 6443, denied 0 (deny-flow-max 4096)
alert-interval 300
access-list dmz03_acl remark this is a remark
access-list acl-name remark this is a remark
access-list acl-name line 0 remark this is a remark
access-list acl-name; 42 elements; name hash: 0xbe299002
access-list acl-name line 42 extended permit tcp host 2.2.2.2 host 3.3.3.3 eq www
access-list acl-name line 42 extended permit tcp host 2.2.2.2 host 3.3.3.3 eq https
Expand All @@ -105,7 +106,8 @@ access-list acl-name extended permit tcp object-group group1 host 1.1.1.1 eq sql
access-list acl-name line 42 extended deny icmp any host 1.1.1.1
access-list acl-name line 42 extended deny icmp any host 1.1.1.1 timestamp-request
access-list acl-name line 42 extended deny icmp any host 1.1.1.1 traceroute

access-list acl-name line 42 extended permit
access-list acl-name line 42 extended deny
access-list acl-name line 42 extended permit object-group services object-group network-src object-group network-dst
access-list acl-name line 42 extended permit tcp any host 2.2.2.2 eq domain log informational interval 300 disable 0x2e7027d7
access-list acl-name line 42 extended permit tcp any host 2.2.2.2 eq domain log informational interval 300 disable default 0x2e7027d7
Expand All @@ -115,8 +117,8 @@ access-list acl-name line 42 extended permit tcp any host 2.2.2.2 eq domain log
access-list acl-name line 42 extended permit icmp host 2.2.2.2 host 1.1.1.1 echo log informational interval 300
access-list acl-name line 42 extended permit tcp host 1.1.1.1 object-group group-3 eq 2059 inactive (hitcnt=0)
access-list acl-name line 42 extended permit 41 host 1.1.1.1 host 2.2.2.2
access-list dmz03_acl extended deny ip any4 any4
access-list dmz03_acl extended deny ip any6 any6
access-list acl-name extended deny ip any4 any4
access-list acl-name extended deny ip any6 any6

access-group acl-name in interface outside

Expand All @@ -141,7 +143,7 @@ logging buffered informational
logging trap informational
logging asdm informational
logging device-id string firewall
logging host mgmt 1.2.3.4
logging host outside 1.2.3.4

username root password secret encrypted privilege 15

Expand Down
6 changes: 3 additions & 3 deletions tests/syntax_test_cisco_nxos.cisco-nxos
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ line vty 0 4
transport input ssh
exit

route-map rm-bck-to-service-segment permit 13990
match ip address ac-bck-to-stfm004-inside-328
set vrf stfm004-inside-328
route-map route_map_name permit 13990
match ip address acl_name
set vrf vrf_name
exit
File renamed without changes.

0 comments on commit 2888fbc

Please sign in to comment.