initial file upload

This commit is contained in:
Joseph James -T (josjames - ADVANTIS GLOBAL SERVICES INC at Cisco)
2016-04-13 11:22:39 -07:00
commit 6d43c59fb5
61 changed files with 5416 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
<?php
$cisco_aaa_authentication_login_commands = array(
'name' => array ('name', array('default', )),
'ascii authentication' => array ('ascii_authentication', array('true', 'false', 'default', )),
'chap' => array ('chap', array()),
'error display' => array ('error_display', array()),
'mschap' => array ('mschap', array()),
'mschapv2' => array ('mschapv2', array()),
);
?>

View File

@@ -0,0 +1,8 @@
<?php
$cisco_aaa_authorization_login_cfg_svc_commands = array(
'ensure' => array ('ensure', array('absent', 'present', )),
'name' => array ('name', array('console', 'default', )),
'groups' => array ('groups', array('default', '<string>', )),
'method' => array ('method', array('local', 'unselected', 'default', )),
);
?>

View File

@@ -0,0 +1,8 @@
<?php
$cisco_aaa_authorization_login_exec_svc_commands = array(
'ensure' => array ('ensure', array('absent', 'present', )),
'name' => array ('name', array('console', 'default', )),
'groups' => array ('groups', array('default', '<string>', )),
'method' => array ('method', array('local', 'unselected', 'default', )),
);
?>

View File

@@ -0,0 +1,10 @@
<?php
$cisco_aaa_group_tacacs_commands = array(
'ensure' => array ('ensure', array('absent', 'present', )),
'group' => array ('group', array('<string>', )),
'deadtime' => array ('deadtime', array('default', '<integer>', )),
'server hosts' => array ('server_hosts', array('default', '<string>', )),
'source interface' => array ('source_interface', array('default', '<string>', )),
'vrf name' => array ('vrf_name', array('default', '<string>', )),
);
?>

View File

@@ -0,0 +1,9 @@
<?php
$cisco_acl_commands = array(
'ensure' => array ('ensure', array('absent', 'present', )),
'afi' => array ('afi', array()),
'acl name' => array ('acl_name', array('<string>', )),
'stats per entry' => array ('stats_per_entry', array('true', 'false', 'default', )),
'fragments' => array ('fragments', array('permitall', 'denyall', )),
);
?>

View File

@@ -0,0 +1,43 @@
<?php
$cisco_bgp_commands = array(
'ensure' => array ('ensure', array('absent', 'present', )),
'asn' => array ('asn', array('<string>', '<integer>', )),
'vrf' => array ('vrf', array('present', 'default', '<string>', )),
'route distinguisher' => array ('route_distinguisher', array('auto', 'default', '<string>', )),
'router id' => array ('router_id', array('default', '<string>', )),
'cluster id' => array ('cluster_id', array('default', '<string>', )),
'confederation id' => array ('confederation_id', array('default', '<string>', )),
'confederation peers' => array ('confederation_peers', array('default', '<string>', )),
'disable policy batching' => array ('disable_policy_batching', array('true', 'false', 'default', )),
'disable policy batching ip' => array ('disable_policy_batching_ipv4', array('default', '<string>', )),
'disable policy batching ipv6' => array ('disable_policy_batching_ipv6', array('default', '<string>', )),
'enforce first as' => array ('enforce_first_as', array('true', 'false', 'default', )),
'event history cli' => array ('event_history_cli', array('sizemedium', 'false', 'sizedisable', 'true', 'sizesmall', 'default', 'sizelarge', )),
'event history detail' => array ('event_history_detail', array('sizemedium', 'false', 'sizedisable', 'true', 'sizesmall', 'default', 'sizelarge', )),
'event history events' => array ('event_history_events', array('sizemedium', 'false', 'sizedisable', 'true', 'sizesmall', 'default', 'sizelarge', )),
'event history periodic' => array ('event_history_periodic', array('sizemedium', 'false', 'sizedisable', 'true', 'sizesmall', 'default', 'sizelarge', )),
'fast external fallover' => array ('fast_external_fallover', array('true', 'false', 'default', )),
'flush routes' => array ('flush_routes', array('true', 'false', 'default', )),
'isolate' => array ('isolate', array('true', 'false', 'default', )),
'maxas limit' => array ('maxas_limit', array('default', '<integer>', )),
'neighbor down fib accelerate' => array ('neighbor_down_fib_accelerate', array('true', 'false', 'default', )),
'shutdown' => array ('shutdown', array('true', 'false', 'default', )),
'supress fib pending' => array ('supress_fib_pending', array('true', 'false', 'default', )),
'log neighbor changes' => array ('log_neighbor_changes', array('true', 'false', 'default', )),
'bestpath always compare med' => array ('bestpath_always_compare_med', array('true', 'false', 'default', )),
'bestpath aspath multipath relax' => array ('bestpath_aspath_multipath_relax', array('true', 'false', 'default', )),
'bestpath compare routerid' => array ('bestpath_compare_routerid', array('true', 'false', 'default', )),
'bestpath cost community ignore' => array ('bestpath_cost_community_ignore', array('true', 'false', 'default', )),
'bestpath med confed' => array ('bestpath_med_confed', array('true', 'false', 'default', )),
'bestpath med missing as worst' => array ('bestpath_med_missing_as_worst', array('true', 'false', 'default', )),
'bestpath med non deterministic' => array ('bestpath_med_non_deterministic', array('true', 'false', 'default', )),
'timer bestpath limit' => array ('timer_bestpath_limit', array('default', '<integer>', )),
'timer bestpath limit always' => array ('timer_bestpath_limit_always', array('true', 'false', 'default', )),
'graceful restart' => array ('graceful_restart', array('true', 'false', 'default', )),
'graceful restart helper' => array ('graceful_restart_helper', array('true', 'false', 'default', )),
'graceful restart timers restart' => array ('graceful_restart_timers_restart', array('default', '<integer>', )),
'graceful restart timers stalepath time' => array ('graceful_restart_timers_stalepath_time', array('default', '<integer>', )),
'timer bgp keepalive' => array ('timer_bgp_keepalive', array('default', '<integer>', )),
'timer bgp hold' => array ('timer_bgp_hold', array('default', '<integer>', )),
);
?>

View File

@@ -0,0 +1,36 @@
<?php
$cisco_bgp_af_commands = array(
'ensure' => array ('ensure', array('absent', 'present', )),
'asn' => array ('asn', array('<string>', '<integer>', )),
'vrf' => array ('vrf', array('present', 'default', '<string>', )),
'afi' => array ('afi', array()),
'safi' => array ('safi', array()),
'additional paths install' => array ('additional_paths_install', array('true', 'false', 'default', )),
'additional paths receive' => array ('additional_paths_receive', array('true', 'false', 'default', )),
'additional paths selection' => array ('additional_paths_selection', array('<string>', )),
'additional paths send' => array ('additional_paths_send', array('true', 'false', 'default', )),
'advertise l2vpn evpn' => array ('advertise_l2vpn_evpn', array('true', 'false', )),
'client to client' => array ('client_to_client', array('true', 'false', )),
'dampen igp metric' => array ('dampen_igp_metric', array('default', '<integer>', )),
'dampening state' => array ('dampening_state', array('true', 'false', 'default', )),
'dampening half time' => array ('dampening_half_time', array('default', '<integer>', )),
'dampening max suppress time' => array ('dampening_max_suppress_time', array('default', '<integer>', )),
'dampening reuse time' => array ('dampening_reuse_time', array('default', '<integer>', )),
'dampening routemap' => array ('dampening_routemap', array('<string>', )),
'dampening suppress time' => array ('dampening_suppress_time', array('default', '<integer>', )),
'default information originate' => array ('default_information_originate', array('true', 'false', )),
'default metric' => array ('default_metric', array('default', '<integer>', )),
'distance ebgp' => array ('distance_ebgp', array('default', '<integer>', )),
'distance ibgp' => array ('distance_ibgp', array('default', '<integer>', )),
'distance local' => array ('distance_local', array('default', '<integer>', )),
'inject map' => array ('inject_map', array('<string>', )),
'maximum paths' => array ('maximum_paths', array('default', '<integer>', )),
'maximum paths ibgp' => array ('maximum_paths_ibgp', array('default', '<integer>', )),
'networks' => array ('networks', array('<string>', )),
'next hop route map' => array ('next_hop_route_map', array('<string>', )),
'redistribute' => array ('redistribute', array('<string>', )),
'suppress inactive' => array ('suppress_inactive', array('true', 'false', 'default', )),
'table map' => array ('table_map', array('<string>', )),
'table map filter' => array ('table_map_filter', array('true', 'false', 'default', )),
);
?>

View File

@@ -0,0 +1,27 @@
<?php
$cisco_bgp_neighbor_commands = array(
'ensure' => array ('ensure', array('absent', 'present', )),
'asn' => array ('asn', array('<string>', '<integer>', )),
'vrf' => array ('vrf', array('present', 'default', '<string>', )),
'neighbor' => array ('neighbor', array('<string>', )),
'description' => array ('description', array('<string>', )),
'connected check' => array ('connected_check', array('true', 'false', )),
'capability negotiation' => array ('capability_negotiation', array('true', 'false', )),
'dynamic capability' => array ('dynamic_capability', array('true', 'false', )),
'ebgp multihop' => array ('ebgp_multihop', array('default', '<integer>', )),
'local as' => array ('local_as', array('default', '<string>', '<integer>', )),
'log neighbor changes' => array ('log_neighbor_changes', array('disable', 'enable', 'inherit', )),
'low memory exempt' => array ('low_memory_exempt', array('true', 'false', 'default', )),
'maximum peers' => array ('maximum_peers', array('default', 'ipprefix', )),
'password' => array ('password', array('<string>', )),
'password type' => array ('password_type', array('3des', 'cleartext', 'default', 'ciscotype7', 'defaultwhich', )),
'remote as' => array ('remote_as', array('default', '<string>', '<integer>', )),
'remove private as' => array ('remove_private_as', array('replaceas', 'all', 'disable', 'enable', '<integer>', )),
'shutdown' => array ('shutdown', array('true', 'false', )),
'suppress 4 byte as' => array ('suppress_4_byte_as', array('true', 'false', 'default', )),
'timers keepalive' => array ('timers_keepalive', array('default', '<integer>', )),
'timers holdtime' => array ('timers_holdtime', array('default', '<integer>', )),
'transport passive only' => array ('transport_passive_only', array('true', 'false', 'default', 'ip', )),
'update source' => array ('update_source', array('<string>', )),
);
?>

View File

@@ -0,0 +1,38 @@
<?php
$cisco_bgp_neighbor_af_commands = array(
'ensure' => array ('ensure', array('absent', 'present', )),
'asn' => array ('asn', array('<string>', '<integer>', )),
'vrf' => array ('vrf', array('present', 'default', '<string>', )),
'neighbor' => array ('neighbor', array('<string>', )),
'afi' => array ('afi', array('<string>', )),
'safi' => array ('safi', array('<string>', )),
'advertise map exist' => array ('advertise_map_exist', array('myexistmap', 'default', '<string>', 'myadvertisemap', )),
'advertise map non exist' => array ('advertise_map_non_exist', array('mynonexistmap', 'default', '<string>', 'myadvertisemap', )),
'allowas in' => array ('allowas_in', array('true', 'false', '<integer>', )),
'allowas in max' => array ('allowas_in_max', array('default', '<integer>', )),
'as override' => array ('as_override', array('true', 'false', 'default', )),
'additional paths receive' => array ('additional_paths_receive', array()),
'additional paths send' => array ('additional_paths_send', array()),
'default originate' => array ('default_originate', array('true', 'false', 'default', )),
'default originate route map' => array ('default_originate_route_map', array('default', '<string>', )),
'filter list in' => array ('filter_list_in', array('default', '<string>', )),
'filter list out' => array ('filter_list_out', array('default', '<string>', )),
'max prefix limit' => array ('max_prefix_limit', array('default', '<integer>', )),
'max prefix interval' => array ('max_prefix_interval', array('default', '<integer>', )),
'max prefix threshold' => array ('max_prefix_threshold', array('default', '<integer>', )),
'max prefix warning' => array ('max_prefix_warning', array('true', 'false', 'default', )),
'next hop self' => array ('next_hop_self', array('true', 'false', 'default', )),
'next hop third party' => array ('next_hop_third_party', array('true', 'false', 'default', )),
'prefix list in' => array ('prefix_list_in', array('default', '<string>', )),
'prefix list out' => array ('prefix_list_out', array('default', '<string>', )),
'route map in' => array ('route_map_in', array('default', '<string>', )),
'route map out' => array ('route_map_out', array('default', '<string>', )),
'route reflector client' => array ('route_reflector_client', array('true', 'false', 'default', )),
'send community' => array ('send_community', array('extended', 'standard', 'default', 'none', 'both', )),
'soft reconfiguration in' => array ('soft_reconfiguration_in', array()),
'soo' => array ('soo', array('default', '<string>', )),
'suppress inactive' => array ('suppress_inactive', array('true', 'false', 'default', )),
'unsuppress map' => array ('unsuppress_map', array('default', '<string>', )),
'weight' => array ('weight', array('default', '<integer>', )),
);
?>

View File

@@ -0,0 +1,5 @@
<?php
$cisco_command_config_commands = array(
'command' => array ('command', array('<string>', )),
);
?>

View File

@@ -0,0 +1,37 @@
<?php
$cisco_interface_commands = array(
'ensure' => array ('ensure', array('absent', 'present', )),
'interface' => array ('interface', array('<string>', )),
'channel group' => array ('channel_group', array('default', )),
'description' => array ('description', array('default', '<string>', )),
'duplex' => array ('duplex', array('auto', 'full', )),
'speed' => array ('speed', array('auto', )),
'shutdown' => array ('shutdown', array('andndefault', 'true', 'false', 'default', )),
'switchport mode' => array ('switchport_mode', array('disabled', 'fexfabric', 'default', 'tunnel', 'access', 'trunk', )),
'ip acl in' => array ('ipv4_acl_in', array('default', '<string>', )),
'ip acl out' => array ('ipv4_acl_out', array('default', '<string>', )),
'ipv6 acl in' => array ('ipv6_acl_in', array('default', '<string>', )),
'ipv6 acl out' => array ('ipv6_acl_out', array('default', '<string>', )),
'access vlan' => array ('access_vlan', array('default', 'keywordndefault', '<integer>', )),
'encapsulation dot1q' => array ('encapsulation_dot1q', array('default', '<integer>', )),
'mtu' => array ('mtu', array('<integer>', )),
'switchport autostate exclude' => array ('switchport_autostate_exclude', array('true', 'false', 'default', )),
'switchport trunk allowed vlan' => array ('switchport_trunk_allowed_vlan', array('default', '<string>', )),
'switchport trunk native vlan' => array ('switchport_trunk_native_vlan', array('default', '<integer>', )),
'switchport vtp' => array ('switchport_vtp', array('true', 'false', 'default', 'falsenand', )),
'negotiate auto' => array ('negotiate_auto', array('true', 'false', 'default', 'truenfalse', )),
'ip pim sparse mode' => array ('ipv4_pim_sparse_mode', array('true', 'false', 'default', )),
'ip proxy arp' => array ('ipv4_proxy_arp', array('true', 'false', 'default', )),
'ip redirects' => array ('ipv4_redirects', array('true', 'false', 'default', )),
'ip address' => array ('ipv4_address', array('default', '<string>', )),
'ip netmask length' => array ('ipv4_netmask_length', array('default', '<integer>', )),
'ip address secondary' => array ('ipv4_address_secondary', array('default', '<string>', )),
'ip netmask length secondary' => array ('ipv4_netmask_length_secondary', array('default', '<integer>', )),
'ip arp timeout' => array ('ipv4_arp_timeout', array('default', '<string>', '<integer>', )),
'vlan mapping' => array ('vlan_mapping', array('default', '<string>', )),
'vlan mapping enable' => array ('vlan_mapping_enable', array('true', 'false', 'default', )),
'vrf' => array ('vrf', array('default', '<string>', )),
'svi autostate' => array ('svi_autostate', array('true', 'false', 'default', 'truenfalse', )),
'svi management' => array ('svi_management', array('true', 'false', 'default', )),
);
?>

View File

@@ -0,0 +1,25 @@
<?php
$cisco_interface_commands = array(
'command_string' => '$ciscopuppet::l3_interface_cfg_data::l3_interface_instances.each |$interface, $value| {',
'ensure' => array('ensure', array('present', 'absent')),
'interface' => array('interface', array('<string>')),
'description' => array('description', array('<string>', 'default')),
'shutdown' => array('shutdown', array('true', 'false', 'default')),
'switchport mode' => array('switchport_mode', array('disabled', 'access', 'tunnel', 'fex_fabric', 'trunk', 'default')),
'access vlan' => array('access_vlan', array('<integer>', 'default')),
'encapsulation dot1q' => array('encapsulation_dot1q', array('<integer>', 'default')),
'mtu' => array('mtu', array('<integer>')),
'switchport autostate exclude' => array('switchport_autostate_exclude', array('true', 'false', 'default')),
'switchport trunk allowed vlan' => array('switchport_trunk_allowed_vlan', array('<string>', 'default')),
'switchport trunk native vlan' => array('switchport_trunk_native_vlan', array('<integer>', 'default')),
'switchport vtp' => array('switchport_vtp', array('true', 'false', 'default')),
'negotiate auto' => array('negotiate_auto', array('true', 'false', 'default')),
'ip proxy arp' => array('ipv4_proxy_arp', array('true', 'false', 'default')),
'ip redirects' => array('ipv4_redirects', array('true', 'false', 'default')),
'ip address' => array('ipv4_address', array('<string>', 'default')),
'ip netmask length' => array('ipv4_netmask_length', array('<integer>', 'default')),
'vrf' => array('vrf', array('<string>', 'default')),
'svi autostate' => array('svi_autostate', array('true', 'false', 'default')),
'svi management' => array('svi_management', array('true', 'false', 'default')),
);
?>

View File

@@ -0,0 +1,17 @@
<?php
$cisco_interface_ospf_commands = array(
'ensure' => array ('ensure', array('absent', 'present', 'arenpresent', )),
'interface' => array ('interface', array('<string>', )),
'ospf' => array ('ospf', array('<string>', )),
'cost' => array ('cost', array('<integer>', )),
'hello interval' => array ('hello_interval', array('default', '<integer>', )),
'dead interval' => array ('dead_interval', array('default', '<integer>', )),
'passive interface' => array ('passive_interface', array('true', 'false', )),
'message digest' => array ('message_digest', array('true', 'false', )),
'message digest key id' => array ('message_digest_key_id', array('<integer>', )),
'message digest algorithm type' => array ('message_digest_algorithm_type', array('default', 'md5', )),
'message digest encryption type' => array ('message_digest_encryption_type', array('andndefault', '3des', 'cleartext', 'default', 'ciscotype7', )),
'message digest password' => array ('message_digest_password', array('<string>', )),
'area' => array ('area', array('<string>', '<integer>', )),
);
?>

View File

@@ -0,0 +1,11 @@
<?php
$cisco_interface_portchannel_commands = array(
'ensure' => array ('ensure', array('absent', 'present', )),
'lacp graceful convergence' => array ('lacp_graceful_convergence', array('true', 'false', 'default', )),
'lacp max bundle' => array ('lacp_max_bundle', array('default', '<integer>', )),
'lacp min links' => array ('lacp_min_links', array('default', '<integer>', )),
'lacp suspend individual' => array ('lacp_suspend_individual', array('true', 'false', 'default', )),
'port hash distribution' => array ('port_hash_distribution', array('adaptive', 'fixed', 'default', '<integer>', )),
'port load defer' => array ('port_load_defer', array('true', 'false', 'default', '<integer>', )),
);
?>

View File

@@ -0,0 +1,9 @@
<?php
$cisco_interface_service_vni_commands = array(
'ensure' => array ('ensure', array('absent', 'present', )),
'interface' => array ('interface', array('<string>', )),
'sid' => array ('sid', array('<integer>', )),
'encapsulation profile vni' => array ('encapsulation_profile_vni', array('default', '<string>', )),
'shutdown' => array ('shutdown', array('true', 'false', 'default', )),
);
?>

View File

@@ -0,0 +1,6 @@
<?php
$cisco_ospf_commands = array(
'ensure' => array ('ensure', array('absent', 'present', 'presentnand', )),
'ospf' => array ('ospf', array('<string>', )),
);
?>

View File

@@ -0,0 +1,17 @@
<?php
$cisco_ospf_vrf_commands = array(
'ensure' => array ('ensure', array('absent', 'present', )),
'vrf' => array ('vrf', array('present', 'default', '<string>', )),
'ospf' => array ('ospf', array('<string>', )),
'router id' => array ('router_id', array('default', '<string>', )),
'default metric' => array ('default_metric', array('default', 'keywordndefault', '<integer>', )),
'log adjacency' => array ('log_adjacency', array('none', 'default', 'detail', 'log', )),
'timer throttle lsa start' => array ('timer_throttle_lsa_start', array('default', '<integer>', )),
'timer throttle lsa hold' => array ('timer_throttle_lsa_hold', array('default', '<integer>', )),
'timer throttle lsa max' => array ('timer_throttle_lsa_max', array('default', '<integer>', )),
'timer throttle spf start' => array ('timer_throttle_spf_start', array('default', '<integer>', )),
'timer throttle spf hold' => array ('timer_throttle_spf_hold', array('default', '<integer>', )),
'timer throttle spf max' => array ('timer_throttle_spf_max', array('default', '<integer>', )),
'auto cost' => array ('auto_cost', array('default', '<integer>', )),
);
?>

View File

@@ -0,0 +1,14 @@
<?php
$cisco_portchannel_global_commands = array(
'asymmetric' => array ('asymmetric', array('true', 'false', 'default', '<integer>', )),
'bundle hash' => array ('bundle_hash', array('mac', 'iponly', 'ipvlan', 'port', 'l4port', 'ipgre', 'ip', 'ipl4portvlan', 'default', 'ipl4port', '<integer>', 'portonly', )),
'bundle select' => array ('bundle_select', array('dst', 'src', 'srcdst', 'default', )),
'concatenation' => array ('concatenation', array('true', 'false', 'default', '<integer>', )),
'hash distribution' => array ('hash_distribution', array('adaptive', 'fixed', 'default', '<integer>', )),
'hash poly' => array ('hash_poly', array('CRC10b', 'CRC10a', 'CRC10c', 'default', 'CRC10d', '<integer>', )),
'load defer' => array ('load_defer', array('default', '<integer>', )),
'resilient' => array ('resilient', array('true', 'false', 'default', '<integer>', )),
'rotate' => array ('rotate', array('default', '<integer>', )),
'symmetry' => array ('symmetry', array('true', 'false', 'default', '<integer>', )),
);
?>

View File

@@ -0,0 +1,8 @@
<?php
$cisco_snmp_community_commands = array(
'ensure' => array ('ensure', array('absent', 'present', )),
'community' => array ('community', array('<string>', )),
'group' => array ('group', array('default', '<string>', )),
'acl' => array ('acl', array('default', '<string>', )),
);
?>

View File

@@ -0,0 +1,6 @@
<?php
$cisco_snmp_group_commands = array(
'ensure' => array ('ensure', array('absent', 'present', )),
'group' => array ('group', array('<string>', )),
);
?>

View File

@@ -0,0 +1,12 @@
<?php
$cisco_snmp_server_commands = array(
'name' => array ('name', array('default', )),
'location' => array ('location', array('default', '<string>', )),
'contact' => array ('contact', array('default', '<string>', 'keywordndefault', )),
'aaa user cache timeout' => array ('aaa_user_cache_timeout', array('default', '<integer>', )),
'packet size' => array ('packet_size', array('default', '<integer>', )),
'global enforce priv' => array ('global_enforce_priv', array('true', 'false', 'default', 'truenfalse', )),
'protocol' => array ('protocol', array('true', 'false', 'default', )),
'tcp session auth' => array ('tcp_session_auth', array('true', 'false', 'default', )),
);
?>

View File

@@ -0,0 +1,13 @@
<?php
$cisco_snmp_user_commands = array(
'ensure' => array ('ensure', array('absent', 'present', )),
'user' => array ('user', array('<string>', )),
'engine id' => array ('engine_id', array('<string>', )),
'groups' => array ('groups', array('<string>', )),
'auth protocol' => array ('auth_protocol', array('shanand', 'md5', 'none', )),
'auth password' => array ('auth_password', array('<string>', )),
'priv protocol' => array ('priv_protocol', array('des', 'andnnone', 'aes128', )),
'priv password' => array ('priv_password', array('<string>', )),
'localized key' => array ('localized_key', array('true', 'false', )),
);
?>

View File

@@ -0,0 +1,11 @@
<?php
$cisco_tacacs_server_commands = array(
'name' => array ('name', array('default', )),
'timeout' => array ('timeout', array('default', '<integer>', )),
'directed request' => array ('directed_request', array('true', 'false', )),
'deadtime' => array ('deadtime', array('default', '<integer>', )),
'encryption type' => array ('encryption_type', array('clear', 'encrypted', 'default', 'none', )),
'encryption password' => array ('encryption_password', array('default', '<string>', )),
'source interface' => array ('source_interface', array('default', '<string>', )),
);
?>

View File

@@ -0,0 +1,10 @@
<?php
$cisco_tacacs_server_host_commands = array(
'ensure' => array ('ensure', array('absent', 'present', )),
'host' => array ('host', array('<string>', )),
'port' => array ('port', array('default', '<integer>', )),
'timeout' => array ('timeout', array('default', '<integer>', )),
'encryption type' => array ('encryption_type', array('clear', 'default', 'encryptednnone', )),
'encryption password' => array ('encryption_password', array('<string>', )),
);
?>

View File

@@ -0,0 +1,7 @@
<?php
$cisco_vdc_commands = array(
'name' => array ('name', array('default', '<string>', )),
'ensure' => array ('ensure', array('absent', 'present', )),
'limit resource module type' => array ('limit_resource_module_type', array('default', '<string>', )),
);
?>

View File

@@ -0,0 +1,9 @@
<?php
$cisco_vlan_commands = array(
'vlan' => array ('vlan', array('<integer>', )),
'ensure' => array ('ensure', array('absent', 'present', )),
'vlan name' => array ('vlan_name', array('default', '<string>', )),
'state' => array ('state', array('suspend', 'active', 'default', )),
'shutdown' => array ('shutdown', array('true', 'false', 'default', )),
);
?>

View File

@@ -0,0 +1,7 @@
<?php
$cisco_vni_commands = array(
'ensure' => array ('ensure', array('absent', 'present', )),
'name' => array ('name', array('<integer>', )),
'mapped vlan' => array ('mapped_vlan', array()),
);
?>

View File

@@ -0,0 +1,10 @@
<?php
$cisco_vrf_commands = array(
'ensure' => array ('ensure', array('absent', 'present', 'default', )),
'name' => array ('name', array('<string>', )),
'description' => array ('description', array('<string>', )),
'route distinguisher' => array ('route_distinguisher', array('auto', 'default', '<string>', )),
'shutdown' => array ('shutdown', array('true', 'false', )),
'vni' => array ('vni', array('default', '<integer>', )),
);
?>

View File

@@ -0,0 +1,14 @@
<?php
$cisco_vrf_af_commands = array(
'ensure' => array ('ensure', array('absent', 'present', 'default', )),
'name' => array ('name', array('<string>', )),
'afi' => array ('afi', array('ipv4', 'ipv6', )),
'safi' => array ('safi', array('<integer>', )),
'route target both auto' => array ('route target both auto', array('true', 'false', 'default', )),
'route target both auto evpn' => array ('route target both auto evpn', array('true', 'false', 'default', )),
'route target import' => array ('route_target_import', array('default', '<string>', )),
'route target import evpn' => array ('route_target_import_evpn', array('default', '<string>', )),
'route target export' => array ('route_target_export', array('default', '<string>', )),
'route target export evpn' => array ('route_target_export_evpn', array('default', '<string>', )),
);
?>

View File

@@ -0,0 +1,10 @@
<?php
$cisco_vtp_commands = array(
'ensure' => array ('ensure', array('absent', 'present', )),
'name' => array ('name', array('default', )),
'domain' => array ('domain', array('<string>', )),
'version' => array ('version', array('default', '<integer>', )),
'file name' => array ('file_name', array('default', '<string>', )),
'password' => array ('password', array('default', '<string>', )),
);
?>

View File

@@ -0,0 +1,11 @@
<?php
$cisco_vxlan_global_commands = array(
'ensure' => array ('ensure', array('absent', 'present', )),
'name' => array ('name', array('default', )),
'anycast gateway mac' => array ('anycast_gateway_mac', array()),
'dup host ip addr detection host moves' => array ('dup_host_ip_addr_detection_host_moves', array('default', '<integer>', )),
'dup host ip addr detection timeout' => array ('dup_host_ip_addr_detection_timeout', array('default', '<integer>', )),
'dup host mac detection host moves' => array ('dup_host_mac_detection_host_moves', array('default', '<integer>', )),
'dup host mac detection timeout' => array ('dup_host_mac_detection_timeout', array('default', '<integer>', )),
);
?>

View File

@@ -0,0 +1,9 @@
<?php
$cisco_vxlan_vtep_commands = array(
'ensure' => array ('ensure', array('absent', 'present', )),
'description' => array ('description', array('default', '<string>', )),
'host reachability' => array ('host_reachability', array('flood', 'evpn', 'default', )),
'shutdown' => array ('shutdown', array('true', 'false', 'default', )),
'source interface' => array ('source_interface', array('default', '<string>', )),
);
?>

View File

@@ -0,0 +1,6 @@
<?php
$domain_name_commands = array(
'ensure' => array ('ensure', array('absent', 'present', )),
'name' => array ('name', array('<string>', )),
);
?>

View File

@@ -0,0 +1,6 @@
<?php
$name_server_commands = array(
'ensure' => array ('ensure', array('absent', 'present', )),
'name' => array ('name', array('<string>', )),
);
?>

View File

@@ -0,0 +1,9 @@
<?php
$network_dns_commands = array(
'ensure' => array ('ensure', array('absent', 'present', )),
'name' => array ('name', array('<string>', )),
'domain' => array ('domain', array('<string>', )),
'search' => array ('search', array('<string>', )),
'servers' => array ('servers', array('<string>', )),
);
?>

View File

@@ -0,0 +1,9 @@
<?php
$network_interface_commands = array(
'name' => array ('name', array('<string>', )),
'description' => array ('description', array('default', '<string>', )),
'duplex' => array ('duplex', array('auto', 'full', )),
'speed' => array ('speed', array('auto', )),
'mtu' => array ('mtu', array('<integer>', )),
);
?>

View File

@@ -0,0 +1,8 @@
<?php
$network_snmp_commands = array(
'name' => array ('name', array('<string>', )),
'enable' => array ('enable', array('true', 'false', )),
'contact' => array ('contact', array('<string>', )),
'location' => array ('location', array('<string>', )),
);
?>

View File

@@ -0,0 +1,10 @@
<?php
$network_trunk_commands = array(
'name' => array ('name', array('<string>', )),
'encapsulation' => array ('encapsulation', array('isl', 'negotiate', 'dot1q', 'none', )),
'mode' => array ('mode', array('dynamicauto', 'access', 'dynamicdesirable', 'trunk', )),
'untagged vlan' => array ('untagged_vlan', array()),
'tagged vlans' => array ('tagged_vlans', array('<string>', )),
'pruned vlans' => array ('pruned_vlans', array('<string>', '<integer>', )),
);
?>

View File

@@ -0,0 +1,6 @@
<?php
$ntp_config_commands = array(
'name' => array ('name', array('<string>', )),
'source interface' => array ('source_interface', array('<string>', )),
);
?>

View File

@@ -0,0 +1,6 @@
<?php
$ntp_server_commands = array(
'ensure' => array ('ensure', array('absent', 'present', )),
'name' => array ('name', array('<string>', )),
);
?>

6
includes/Type_radius.php Normal file
View File

@@ -0,0 +1,6 @@
<?php
$radius_commands = array(
'name' => array ('name', array('<string>', )),
'enable' => array ('enable', array('true', 'false', )),
);
?>

View File

@@ -0,0 +1,9 @@
<?php
$radius_global_commands = array(
'name' => array ('name', array('<string>', )),
'timeout' => array ('timeout', array('<integer>', )),
'retransmit count' => array ('retransmit_count', array('<integer>', )),
'key' => array ('key', array('<string>', )),
'key format' => array ('key_format', array('<integer>', )),
);
?>

View File

@@ -0,0 +1,14 @@
<?php
$radius_server_commands = array(
'ensure' => array ('ensure', array('absent', 'present', )),
'name' => array ('name', array('<string>', )),
'auth port' => array ('auth_port', array('<integer>', )),
'acct port' => array ('acct_port', array('<integer>', )),
'timeout' => array ('timeout', array('<integer>', )),
'retransmit count' => array ('retransmit_count', array('<integer>', )),
'accouting only' => array ('accouting_only', array('true', 'false', )),
'authentication only' => array ('authentication_only', array('true', 'false', )),
'key' => array ('key', array('<string>', )),
'key format' => array ('key_format', array('<integer>', )),
);
?>

View File

@@ -0,0 +1,6 @@
<?php
$search_domain_commands = array(
'ensure' => array ('ensure', array('absent', 'present', )),
'name' => array ('name', array('<string>', )),
);
?>

View File

@@ -0,0 +1,7 @@
<?php
$snmp_community_commands = array(
'ensure' => array ('ensure', array('absent', 'present', )),
'group' => array ('group', array('default', '<string>', )),
'acl' => array ('acl', array('default', '<string>', )),
);
?>

View File

@@ -0,0 +1,5 @@
<?php
$snmp_notification_commands = array(
'enable' => array ('enable', array('true', 'false', )),
);
?>

View File

@@ -0,0 +1,13 @@
<?php
$snmp_notification_receiver_commands = array(
'ensure' => array ('ensure', array('absent', 'present', )),
'name' => array ('name', array('<string>', )),
'port' => array ('port', array('<integer>', )),
'username' => array ('username', array('<string>', )),
'version' => array ('version', array('v2', 'v1', 'v3', )),
'type' => array ('type', array('informs', 'traps', )),
'security' => array ('security', array('auto', 'noauth', 'priv', )),
'vrf' => array ('vrf', array('<string>', )),
'source interface' => array ('source_interface', array('<string>', )),
);
?>

View File

@@ -0,0 +1,13 @@
<?php
$snmp_user_commands = array(
'ensure' => array ('ensure', array('absent', 'present', )),
'name' => array ('name', array('<string>', )),
'engine id' => array ('engine_id', array('<string>', )),
'roles' => array ('roles', array('<string>', )),
'auth' => array ('auth', array('md5', 'sha', )),
'password' => array ('password', array('<string>', )),
'privacy' => array ('privacy', array('des', 'aes128', )),
'private key' => array ('private_key', array('<string>', )),
'localized key' => array ('localized_key', array('true', 'false', )),
);
?>

View File

@@ -0,0 +1,8 @@
<?php
$syslog_server_commands = array(
'ensure' => array ('ensure', array('absent', 'present', )),
'name' => array ('name', array('<string>', )),
'serverity level' => array ('serverity_level', array('<integer>', )),
'vrf' => array ('vrf', array('<string>', )),
);
?>

View File

@@ -0,0 +1,6 @@
<?php
$syslog_setting_commands = array(
'name' => array ('name', array('<string>', )),
'time stamp units' => array ('time_stamp_units', array('milliseconds', 'seconds', )),
);
?>

5
includes/Type_tacacs.php Normal file
View File

@@ -0,0 +1,5 @@
<?php
$tacacs_commands = array(
'enable' => array ('enable', array('true', 'false', )),
);
?>

View File

@@ -0,0 +1,8 @@
<?php
$tacacs_global_commands = array(
'enable' => array ('enable', array('true', 'false', )),
'key' => array ('key', array()),
'key format' => array ('key_format', array('<integer>', )),
'timeout' => array ('timeout', array('<integer>', )),
);
?>

View File

@@ -0,0 +1,10 @@
<?php
$tacacs_server_commands = array(
'ensure' => array ('ensure', array('absent', 'present', )),
'key' => array ('key', array()),
'key format' => array ('key_format', array('<integer>', )),
'name' => array ('name', array('<string>', )),
'port' => array ('port', array('<integer>', )),
'timeout' => array ('timeout', array('<integer>', )),
);
?>

View File

@@ -0,0 +1,5 @@
<?php
$tacacs_server_group_commands = array(
'servers' => array ('servers', array('<string>', )),
);
?>

426
index.php Normal file
View File

@@ -0,0 +1,426 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<!--Author: Joe James, Cisco Systems, Feb-2016 -->
<!--Description: Parses Nexus configuration code and generates from it a Puppet/Ruby manifest -->
<img src="img/logo.png" /><br /><br />
<LINK href="css/style.css" rel="stylesheet" type="text/css">
</head><body>
<?php
/*********************************************************************************************
# Variable definitions:
# given a config file,
# interface Ethernet3/12
# access vlan 24
# no ip redirects
# will be converted to
# type_name='interface'; type='cisco_interface'; value='Ethernet3/12';
# cmd_name='access vlan'; cmd='access_vlan'; value=24;
# cmd_name='ip redirects'; cmd='ipv4_redirects'; value=false;
#
# note that type lines must not be indented, and non-type lines must be indented with at least one space or tab
*********************************************************************************************/
# import cisco_interface Type data
include("includes/Type_cisco_interface.php");
function show_form($in_string) {
echo '<h4>Input Configuration:</h4>';
echo '<form action="index.php" method="POST">';
echo '<textarea name="in_string" ROWS=10 COLS=80>' . $in_string . '</textarea><br />';
echo '<input type="submit" name="submit" value="Convert" />';
echo '</form>';
}
function print_results() {
global $manifests;
global $instances;
global $unrecognized;
echo '<h4>Puppet Manifest:</h4><p class="code"><br />';
foreach ($manifests as $key => $value) {
echo $value . '&nbsp&nbsp}<br />}<br />';
}
echo '</p>';
echo '<h4>Instances:</h4><p class="code"><br />';
foreach ($instances as $key => $value) {
echo $value . '}<br />';
}
echo '</p>';
if ($unrecognized != "") {
echo ('<h4>Unrecognized Lines:</h4><p>' . $unrecognized);
}
}
function is_empty($line) {
if (strlen(trim($line)) == 0) return true;
else return false;
}
# actually, this function only checks if line is indented
# if so, returns true, returns false if not indented
function is_type($line) {
if (ltrim($line) == $line) return true;
else return false;
}
# test increasingly shorter command strings to find type
# returns longest match of the tokenized_line in all_types
# returns empty string if no match found
function get_type_name($tokenized_line, $all_types) {
$type_name = "";
for ($i = count($tokenized_line); $i >= 0; $i--) {
$type_name = join(" ", array_slice($tokenized_line, 0, $i));
if (array_key_exists($type_name, $all_types)) {
return $type_name;
}
}
if (strlen(join(" ", $tokenized_line)) > 2)
return "command config";
return "";
}
# read in Types list from Types text file
function get_all_types() {
$all_types = array();
$file = fopen("types.txt","r");
while(! feof($file)) {
$line = fgets($file);
if (strlen($line) > 2) {
$tokens = explode(";", $line);
$all_types[trim($tokens[0])] = array(trim($tokens[1]), trim($tokens[2]), trim($tokens[3]));
}
}
fclose($file);
return $all_types;
}
# get list of all type_names in the query
function get_type_names_in_query($lines, $all_types) {
$type_name = "";
$type_names_in_query = array();
foreach ($lines as $line) {
if (is_empty($line)) { continue; }
# line is a type
else {
$tokenized_line = array_map('trim', explode(" ", $line));
$type_name = get_type_name($tokenized_line, $all_types);
if ($type_name != "") {
$type_names_in_query[] = $type_name;
}
}
}
return $type_names_in_query;
}
# get list of all types in the query
function get_types_in_query($lines, $all_types) {
$type_name = "";
$types_in_query = array();
foreach ($lines as $line) {
if (is_empty($line)) { continue; }
# line is a type
else {
$tokenized_line = array_map('trim', explode(" ", $line));
$type_name = get_type_name($tokenized_line, $all_types);
if ($type_name != "") {
$types_in_query[] = $all_types[$type_name][0];
}
}
}
return $types_in_query;
}
# get number of INDENTs for a given line
# assumes INDENTs are composed of &nbsp characters
function get_indents($line) {
$num_spaces = strlen($line) - strlen(ltrim($line, ' '));
$num_indents = $num_spaces / (strlen(INDENT) / 5);
// echo ($line . $num_indents);
return $num_indents;
}
function append_cmd_config_instance($type, $lines, $line_number, $cmd_config_mode, $indents) {
global $instances;
global $cmd_config_count;
global $line_num;
# a line inside an unrecognized type
if ($type == 'cisco_command_config') {
if (array_key_exists('cisco_command_config', $instances)) {
for ($i = 0; $i < $indents; $i++) {
$instances['cisco_command_config'] .= INDENT;
}
$instances['cisco_command_config'] .= $lines[$line_number] . '<br />';
}
else {
$instances['cisco_command_config'] = INDENT . ltrim($lines[$line_number]) . '<br />';
}
}
# unrecognized parameter inside a recognized type => add to cmd_config
else {
if ($cmd_config_count == 0 && ! $cmd_config_mode) {
$instances['cisco_command_config'] = '$cisco_command_config_instances = {<br />';
}
if (! $cmd_config_mode) {
$instances['cisco_command_config'] .= INDENT . '"command' . $cmd_config_count . '"=>{<br>' . $lines[$line_num-1] . '<br />';
}
for ($i = 0; $i < $indents; $i++) {
$instances['cisco_command_config'] .= INDENT;
}
$instances['cisco_command_config'] .= ltrim($lines[$line_number]) . '<br />';
}
}
function convert($in_string) {
global $manifests;
global $instances;
global $unrecognized;
global $line_num;
global $cmd_config_count;
# read in all Types, get input query and convert to list of lines, get list of types in the query
$all_types = get_all_types();
$lines = explode("\n", $in_string);
$types_in_query = get_types_in_query($lines, $all_types);
// $type_names_in_query = get_type_names_in_query($lines, $all_types);
// var_dump($types_in_query);
// var_dump($all_types);
# import Type files only for types in query
echo 'Types: ';
foreach (glob("includes/*.php") as $filename) {
$mytype = substr(substr($filename, 14), 0, -4);
if (in_array($mytype, $types_in_query)) { # only need to include Type files that are part of the query
include $filename;
echo $mytype . ', ';
}
}
foreach ($lines as $line) {
$type = "";
$type_name = "";
$value = "";
$line_num += 1;
$indents = get_indents($line);
if (is_empty($line)) { continue; }
# line is a type (ie. has no indent, so Should be a type)
elseif (is_type($line)) {
$tokenized_line = array_map('trim', explode(" ", $line));
$type_name = get_type_name($tokenized_line, $all_types);
if ($type_name == "") {
$unrecognized .= '<span class="line_num">' . $line_num . '</span>&nbsp&nbsp&nbsp' . trim($line) . '<br />';
continue;
}
$type = $all_types[$type_name][0];
// echo "|".$type . "-- " . $line . "|";
if (strlen($type) == 0) { # should never reach this since unrecognized types use command_config type
$unrecognized .= '<span class="line_num">' . $line_num . '</span>&nbsp&nbsp&nbsp' . trim($line) . '<br />';
continue;
}
// if (count($tokenized_line) > 1) { $value = $tokenized_line[1]; }
if (count($tokenized_line) > 1) { $value = trim(ltrim($line, $type_name)); }
if ($type == 'cisco_command_config') {
$value = 'command' . $cmd_config_count;
$cmd_config_count += 1;
}
if (array_key_exists($type, $manifests)) {
// $manifests[$type] .= '&nbsp&nbsp}<br />&nbsp&nbsp' . $type . ' { $' . ltrim(ltrim($type, 'cisco'), '_') . '":<br />';
$instances[$type] .= '&nbsp&nbsp"' . $value . '"=>{';
}
elseif ($type != 'cisco_command_config') {
$manifests[$type] = $all_types[$type_name][1] . '<br />&nbsp&nbsp' . $type . ' { $' . ltrim(ltrim($type, 'cisco'), '_') . ':<br />';
$instances[$type] = $all_types[$type_name][2] . '<br />&nbsp&nbsp"' . $value . '"=>{';
}
# command_config type
elseif ($cmd_config_count == 1) {
$instances[$type] = $all_types[$type_name][2] . '&nbsp&nbsp"' . $value . '"=>{<br />';
}
else {
$instances[$type] .= '&nbsp&nbsp"' . $value . '"=>{<br />';
}
if ($type == 'cisco_command_config') { $instances[$type] .= $line . '<br />'; }
# call parse_type() function to parse indented lines
$type_commands = $type . "_commands";
parse_type($lines, $line_num, $type, $$type_commands);
$instances[$type] .= '},<br />';
}
}
}
# after a Type is found, parse_type parses all the sub-commands inside the Type (ie. indented lines)
function parse_type($lines, $line_num, $type, $type_commands) {
global $manifests;
global $instances;
global $unrecognized;
global $cmd_config_count;
$line_number = $line_num;
$cmd_config_mode = false;
if ($line_number < count($lines)) {
$line = $lines[$line_number];
$indents = get_indents($line);
while (! is_type($line) && $line_number < count($lines)) {
$line = trim($line);
$tokenized_line = array_map('trim', explode(" ", $line));
# find cmd_name
$cmd = "";
$cmd_name = "";
$index = 0;
if ($tokenized_line[0] != "no") {
for ($j = count($tokenized_line); $j > 0; $j--) {
$command = join(" ", array_slice($tokenized_line, 0, $j));
if (array_key_exists($command, $type_commands)) {
$cmd_name = $command;
$cmd = $type_commands[$cmd_name][0];
$index = $j;
break;
}
}
if ($cmd_name != "") {
if ($index < count($tokenized_line)) {
# join remaining tokens in tokenized_line into value
$value = join(" ", array_slice($tokenized_line, $index, count($tokenized_line)));
$values = $type_commands[$cmd_name][1];
# check if value is a valid option
if (is_numeric($value) && strpos($value, '.') === false) {
if (in_array('<integer>', $values)) {
$value2 = '{$value[' . $cmd . ']}';
if (strpos($manifests[$type], $cmd) == false)
$manifests[$type] .= INDENT . INDENT . $cmd . " => " . $value2 . ",<br />";
$instances[$type] .= $cmd . '=>"' . $value . '",';
}
}
elseif (in_array($value, $values)) {
$value2 = '{$value[' . $cmd . ']}';
if (strpos($manifests[$type], $cmd) == false)
$manifests[$type] .= INDENT . INDENT . $cmd . " => " . $value2 . ",<br />";
$instances[$type] .= $cmd . '=>"' . $value . '",';
}
elseif (in_array('<string>', $values)) {
$slash_index = strpos($value, '/');
if ($cmd != "ipv4_address" or $slash_index === false) {
$value2 = '{$value[' . $cmd . ']}';
if (strpos($manifests[$type], $cmd) == false)
$manifests[$type] .= INDENT . INDENT . $cmd . " => " . $value2 . ",<br />";
$instances[$type] .= $cmd . '=>"' . $value . '",';
}
# split ipv4 address and ipv4 mask into 2 commands
else {
$ipv4_addr = substr($value, 0, $slash_index);
$ipv4_mask = substr($value, $slash_index+1);
$value2 = '{$value[' . $cmd . ']}';
if (strpos($manifests[$type], $cmd) == false)
$manifests[$type] .= INDENT . INDENT . $cmd . " => " . $value2 . ",<br />";
$instances[$type] .= $cmd . '=>"' . $ipv4_addr . '",';
$value2 = '{$value[ipv4_netmask_length]}';
if (strpos($manifests[$type], $cmd) == false)
$manifests[$type] .= INDENT . INDENT . "ipv4_netmask_length" . " => " . $value2 . ",<br />";
$instances[$type] .= 'ipv4_netmask_length' . '=>"' . $ipv4_mask . '",';
}
}
# value not found - invalid line
else {
$unrecognized .= '<span class="line_num">' . $line_number . '</span>&nbsp&nbsp&nbsp' . trim($line) . '<br />';
append_cmd_config_instance($type, $lines, $line_number, $cmd_config_mode, $indents);
$cmd_config_mode = true;
}
}
# error - no parameters given
else {
$unrecognized .= '<span class="line_num">' . $line_number . '</span>&nbsp&nbsp&nbsp' . trim($line) . '<br />';
append_cmd_config_instance($type, $lines, $line_number, $cmd_config_mode, $indents);
$cmd_config_mode = true;
}
}
else {
if (trim($line) != "") {
$unrecognized .= '<span class="line_num">' . $line_number . '</span>&nbsp&nbsp&nbsp' . trim($line) . '<br />';
append_cmd_config_instance($type, $lines, $line_number, $cmd_config_mode, $indents);
$cmd_config_mode = true;
}
}
}
# handle 'no' keyword
else {
for ($j = count($tokenized_line); $j > 1; $j--) {
$command = join(" ", array_slice($tokenized_line, 1, $j));
if (array_key_exists($command, $type_commands)) {
$cmd_name = $command;
break;
}
}
if ($cmd_name != "") {
$value2 = '{$value[' . $cmd_name . ']}';
$value = '"false"';
if (strpos($manifests[$type], $type_commands[$cmd_name][0]) == false)
$manifests[$type] .= "&nbsp&nbsp&nbsp&nbsp" . $type_commands[$cmd_name][0] . " => " . $value2 . ",<br />";
$instances[$type] .= $type_commands[$cmd_name][0] . '=>' . $value . ',';
}
else {
$unrecognized .= '<span class="line_num">' . $line_number . '</span>&nbsp&nbsp&nbsp' . trim($line) . '<br />';
append_cmd_config_instance($type, $lines, $line_number, $cmd_config_mode, $indents);
$cmd_config_mode = true;
}
}
$line_number += 1;
if ($line_number < count($lines)) {
$line = $lines[$line_number];
$indents = get_indents($line);
}
}
# close current command_config command
if ($cmd_config_mode && trim($line) != '') {
$instances['cisco_command_config'] .= '},<br />';
$cmd_config_count += 1;
}
}
}
$in_string = "";
if(isset($_POST['submit'])) {
define('INDENT', '&nbsp&nbsp');
$in_string = $_POST['in_string'];
show_form($in_string);
$manifests = array();
$instances = array();
$unrecognized = "";
$line_num = 0;
$cmd_config_count = 0;
convert($in_string);
// echo (count($manifests));
print_results();
}
else {
show_form($in_string);
}
?>
</body></html>

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,21 @@
import string
def get_values(s):
values = list()
slist = s.split(" ")
for word in slist:
if "\'" in word:
values.append(''.join(c for c in word if c not in string.punctuation))
if '[' in word and ']' in word:
brackets = word.split('|')
for item in brackets:
val = (''.join(c for c in item if c not in string.punctuation))
if val.isdigit():
values.append('<integer>')
else:
values.append(val)
print (values)
st = "My dog is \'brown\' and my cat is \'yellow\'. Valid values [big|small|medium] and [0-7]."
get_values(st)

173
type_parsing/parse_types.py Normal file
View File

@@ -0,0 +1,173 @@
import string
from bs4 import BeautifulSoup
def get_type(tag):
soup = BeautifulSoup(tag, 'html.parser')
h3 = soup.find_all('h3')
return h3.text #tag[i].text[:5] == "Type:":
def get_bstypes(soup):
h3 = (soup.find_all('h3'))
bstypes = dict()
for tag in h3:
if tag.text[:6] == 'Type: ':
bstypes[tag.text[6:]] = tag
return bstypes
def get_types(soup):
h3 = (soup.find_all('h3'))
types = list()
for tag in h3:
if tag.text[:6] == 'Type: ':
types.append(tag.text[6:])
h5 = (soup.find_all('h5'))
params = list()
for tag in h5:
params.append(tag.text[:])
h6 = (soup.find_all('h6'))
for tag in h6:
params.append(tag.text[:])
# print (tag.text[:])
p = (soup.find_all('p'))
values = list()
for tag in p:
if "Valid " in tag.text[:]:
values.append(tag.text[:])
print ("TYPES\n", types)
print ("PARAMS\n", params)
print ("VALUES\n", values)
return types, params, values
def get_name(type):
name = type
if name[:6] == 'Type: ':
name = type[6:]
if name[:6] == 'cisco_':
name = name[6:]
name = name.replace("_", " ")
name = name.replace("ipv4", "ip")
return name
# takes a string like "Valid values are ..."
# and adds all valid values to a list, then returns that list
def get_valid_values(s):
values = list()
if 'integer' in s or 'Integer' in s:
values.append('<integer>')
if 'number' in s or 'Number' in s:
values.append('<integer>')
if 'port' in s or 'Port' in s:
values.append('<integer>')
if 'string' in s or 'String' in s:
values.append('<string>')
if 'interface' in s or 'Interface' in s:
values.append('<string>')
if 'array' in s or 'Array' in s:
values.append('<string>')
if 'true' in s or 'True' in s:
values.append('true')
if 'false' in s or 'False' in s:
values.append('false')
if 'present' in s or 'Present' in s:
values.append('present')
if 'absent' in s or 'Absent' in s:
values.append('absent')
if 'default' in s or 'Default' in s:
values.append('default')
s = s.replace('\n', ' ') # for some reason this does not seem to work. still get a few odd results from linebreaks.
slist = s.split(" ")
for word in slist:
# check for \'value\'
if "\'" in word:
values.append(''.join(c for c in word if c not in string.punctuation))
# check for [value1|value2|value3]
if '[' in word and ']' in word:
brackets = word.split('|')
for item in brackets:
val = (''.join(c for c in item if c not in string.punctuation))
if val.isdigit():
values.append('<integer>')
else:
values.append(val)
values = list(set(values))
return values
def main():
# first have to fix encoding problems with the html page
with open("cisco_puppet_module_webpage.txt", 'r') as myfile:
data = myfile.read()# .replace('&#x2713;', '*')
data = str(data.encode('ascii', 'ignore'))
with open("cisco_puppet_module_webpage2.txt", 'w') as outfile:
outfile.write(data)
html_doc = open ("cisco_puppet_module_webpage2.txt")
soup = BeautifulSoup(html_doc, 'html.parser')
bstypes = get_bstypes(soup)
tags = soup.find_all()
for i in range(len(tags)):
tag = str(tags[i])
if tags[i] in bstypes.values():
type = tags[i].text
type_name = get_name(type)
print(type_name, ' -> ', type[6:])
out_filename = 'Type_' + type[6:] + '.php'
with open ('..\\includes\\' + out_filename, 'w') as fout:
fout.write('<?php\n')
fout.write('$' + type[6:] + '_commands = array(\n')
j = i + 1
tag = str(tags[j])
param = ''
while '<h3>' not in tag:
if ('<h5>' in tag or '<h6>' in tag) and '<code>' in tag:
param = tags[j].text
if not param[0].isupper() and param != "":
fout.write("'" + get_name(param) + "' => array ('" + param + "', array(")
print(' ', get_name(param), ' -> ', param)
if '<p>' in tag and param != "":
valid_values = tags[j].text
if "Valid" in valid_values:
valid_values = "Valid" + valid_values.split("Valid")[1]
valid_values_list = get_valid_values(valid_values)
for valid_value in valid_values_list:
fout.write("'" + valid_value + "', ")
print(' ', valid_values_list)
if param != "":
fout.write(")),\n")
param = ''
j += 1
if j >= len(tags):
break
tag = str(tags[j])
fout.write(");\n?>")
main()
'''
for i in range(len(tags)):
try:
print (tags[i])
except:
print ("ERROR CODE J001")
# if "Type: " in tags[i]:
# type = tag[i].text
# print (tags[i])
'''

View File

@@ -0,0 +1,168 @@
import string
from bs4 import BeautifulSoup
def get_type(tag):
soup = BeautifulSoup(tag, 'html.parser')
h3 = soup.find_all('h3')
return h3.text #tag[i].text[:5] == "Type:":
def get_bstypes(soup):
h3 = (soup.find_all('h3'))
bstypes = dict()
for tag in h3:
if tag.text[:6] == 'Type: ':
bstypes[tag.text[6:]] = tag
return bstypes
def get_types(soup):
h3 = (soup.find_all('h3'))
types = list()
for tag in h3:
if tag.text[:6] == 'Type: ':
types.append(tag.text[6:])
h5 = (soup.find_all('h5'))
params = list()
for tag in h5:
params.append(tag.text[:])
h6 = (soup.find_all('h6'))
for tag in h6:
params.append(tag.text[:])
# print (tag.text[:])
p = (soup.find_all('p'))
values = list()
for tag in p:
if "Valid " in tag.text[:]:
values.append(tag.text[:])
print ("TYPES\n", types)
print ("PARAMS\n", params)
print ("VALUES\n", values)
return types, params, values
def get_name(type):
name = type
if name[:6] == 'Type: ':
name = type[6:]
if name[:6] == 'cisco_':
name = name[6:]
name = name.replace("_", " ")
return name
# takes a string like "Valid values are ..."
# and adds all valid values to a list, then returns that list
def get_valid_values(s):
values = list()
if 'integer' in s or 'Integer' in s:
values.append('<integer>')
if 'number' in s or 'Number' in s:
values.append('<integer>')
if 'port' in s or 'Port' in s:
values.append('<integer>')
if 'string' in s or 'String' in s:
values.append('<string>')
if 'interface' in s or 'Interface' in s:
values.append('<string>')
if 'array' in s or 'Array' in s:
values.append('<string>')
if 'true' in s or 'True' in s:
values.append('true')
if 'false' in s or 'False' in s:
values.append('false')
if 'present' in s or 'Present' in s:
values.append('present')
if 'absent' in s or 'Absent' in s:
values.append('absent')
if 'default' in s or 'Default' in s:
values.append('default')
s = s.replace('\n', ' ') # for some reason this does not seem to work. still get a few odd results from linebreaks.
slist = s.split(" ")
for word in slist:
# check for \'value\'
if "\'" in word:
values.append(''.join(c for c in word if c not in string.punctuation))
# check for [value1|value2|value3]
if '[' in word and ']' in word:
brackets = word.split('|')
for item in brackets:
val = (''.join(c for c in item if c not in string.punctuation))
if val.isdigit():
values.append('<integer>')
else:
values.append(val)
values = list(set(values))
return values
def main():
# first have to fix encoding problems with the html page
with open("cisco_puppet_module_webpage.txt", 'r') as myfile:
data = myfile.read()# .replace('&#x2713;', '*')
data = str(data.encode('ascii', 'ignore'))
with open("cisco_puppet_module_webpage2.txt", 'w') as outfile:
outfile.write(data)
html_doc = open ("cisco_puppet_module_webpage2.txt")
soup = BeautifulSoup(html_doc, 'html.parser')
bstypes = get_bstypes(soup)
tags = soup.find_all()
for i in range(len(tags)):
tag = str(tags[i])
if tags[i] in bstypes.values():
type = tags[i].text
type_name = get_name(type)
print(type_name, ' -> ', type[6:])
out_filename = 'Type_' + type[6:] + '.php'
with open ('..\\includes\\' + out_filename, 'w') as fout:
fout.write('<?php\n')
fout.write('$' + type[6:] + '_commands = array(\n')
i += 1
tag = str(tags[i])
while '<h3>' not in tag:
if '<h5>' in tag or '<h6>' in tag:
param = tags[i].text
if not param[0].isupper():
fout.write("'" + get_name(param) + "' => array ('" + param + "', array(")
print(' ', get_name(param), ' -> ', param)
if '<p>' in tag:
valid_values = tags[i].text
if "Valid" in valid_values:
valid_values = "Valid" + valid_values.split("Valid")[1]
valid_values_list = get_valid_values(valid_values)
for valid_value in valid_values_list:
fout.write("'" + valid_value + "', ")
print(' ', valid_values_list)
if len(valid_values_list) > 0:
fout.write(")),\n")
i += 1
if i >= len(tags):
break
tag = str(tags[i])
fout.write(");\n?>")
main()
'''
for i in range(len(tags)):
try:
print (tags[i])
except:
print ("ERROR CODE J001")
# if "Type: " in tags[i]:
# type = tag[i].text
# print (tags[i])
'''

34
types.txt Normal file
View File

@@ -0,0 +1,34 @@
aaa authentication login;cisco_aaa_authentication_login;$ciscopuppet::aaa_authentication_login_data::aaa_authentication_login_instances.each |$aaa_authentication_login, $value| {;$aaa_authentication_login_instances = {
aaa authorization login cfg svc;cisco_aaa_authorization_login_cfg_svc;add description;$cisco_aaa_authorization_login_cfg_svc_instances = {
aaa authorization login exec svc;cisco_aaa_authorization_login_exec_svc;add description;$cisco_aaa_authorization_login_exec_svc_instances = {
aaa group tacacs;cisco_aaa_group_tacacs;add description;$cisco_aaa_group_tacacs_instances = {
acl;cisco_acl;add description;$cisco_acl_instances = {
bgp;cisco_bgp;$ciscopuppet::bgp_cfg_data::bgp_instances.each |$bgp, $value| {;$cisco_bgp_instances = {
bgp address-family;cisco_bgp_af;add description;$cisco_bgp_af_instances = {
bgp neighbor;cisco_bgp_neighbor;add description;$cisco_bgp_neighbor_instances = {
bgp neighbor address-family;cisco_bgp_neighbor_af;add description;$cisco_bgp_neighbor_af_instances = {
command config;cisco_command_config;$ciscopuppet::command_config_data::command_config_instances.each |$command, $value| {;$cisco_command_config_instances = {
interface;cisco_interface;$ciscopuppet::l3_interface_cfg_data::l3_interface_instances.each |$interface, $value| {;$l3_interface_instances = {
interface ospf;cisco_interface_ospf;add description;$cisco_interface_ospf_instances = {
interface portchannel;cisco_interface_portchannel;add description;$cisco_interface_portchannel_instances = {
interface service vni;cisco_interface_service_vni;add description;$cisco_interface_service_vni_instances = {
ospf;cisco_ospf;add description;$cisco_ospf_instances = {
ospf vrf;cisco_ospf_vrf;add description;$cisco_ospf_vrf_instances = {
portchannel global;cisco_portchannel_global;add description;$cisco_portchannel_global_instances = {
snmp community;cisco_snmp_community;add description;$cisco_snmp_community_instances = {
snmp group;cisco_snmp_group;add description;$cisco_snmp_group_instances = {
snmp server;cisco_snmp_server;add description;$cisco_snmp_server_instances = {
snmp user;cisco_snmp_user;add description;$cisco_snmp_user_instances = {
tacacs server;cisco_tacacs_server;add description;$cisco_tacacs_server_instances = {
tacacs server host;cisco_tacacs_server_host;add description;$cisco_tacacs_server_host_instances = {
vdc;cisco_vdc;add description;$cisco_vdc_instances = {
vlan;cisco_vlan;add description;$cisco_vlan_instances = {
vni;cisco_vni;add description;$cisco_vni_instances = {
vrf;cisco_vrf;add description;$cisco_vrf_instances = {
vrf address-family;cisco_vrf_af;add description;$cisco_vrf_af_instances = {
vtp;cisco_vtp;add description;$cisco_vtp_instances = {
vxlan global;cisco_vxlan_global;add description;$cisco_vxlan_global_instances = {
vxlan vtep;cisco_vxlan_vtep;add description;$cisco_vxlan_vtep_instances = {
interface nve;cisco_vxlan_vtep;add description;$cisco_vxlan_vtep_instances = {
router bgp;cisco_bgp;$ciscopuppet::bgp_cfg_data::bgp_instances.each |$bgp, $value| {;$cisco_bgp_instances = {