###############
# MDU TEMPLATE
###############
#
# This template will create a configuration based on a typical
# basic MDU configuration.
#  
# It is broken up into Pre-Auth/Guest and Post-Auth authentication mechisms
# for onboarding new accounts and admitting authorized accounts via multiple 
# pre-shared key.
#
###############

#IMPORTANT: Please change these values to to match the target system
<%

wan_interface ||= 'igb0'
lan_interface ||= 'igb3'

%>
###############
# Template begins
###############

# Generate Policies
Policy:
- name: Management
- name: Post-Auth Landing
- name: Premium
- name: Free
- name: Business
- name: Basic
- name: Pre-Auth / Guests
- name: Default
  _delete: true
  
# Subnet Filter to block traffic between VLANs/Subnets
SubnetsFilter:
- name: Block Subnets
  policies:
  - Basic
  - Business
  - Free
  - Post-Auth Landing
  - Pre-Auth / Guests
  - Premium

# Enable LLDP on LAN and WAN Interfaces
LadvdOption:
- name: default
  active: true
  auto_enable_protocols: true
  listen_only: false
  interfaces:
  - <%= lan_interface %>
  - <%= wan_interface %>

# Create Pre-Auth/Guest and Post-Auth VLANs and apply to LAN interface
Vlan:
- name: Pre-Auth / Guests
  interface: <%= lan_interface %>
  tag: 1100
  autoincrement_ratio: 8
  autoincrement_mode: address
- name: Post-Auth / Accounts
  interface: <%= lan_interface %>
  tag: 1108
  autoincrement_ratio: 1
  autoincrement_mode: address
  
# Apply IP addresses to VLANs  
Address:
- name: Pre-Auth / Guests
  vlan: Pre-Auth / Guests
  span: 1
  autoincrement: 64
  cidr: 10.0.0.1/30
- name: Post-Auth / Accounts
  vlan: Post-Auth / Accounts
  span: 1
  autoincrement: 110
  cidr: 10.0.1.1/24
  
# Create DHCP Pools for subnets
DhcpPool:
- name: Pre-Auth / Guests
  start_ip: 10.0.0.2
  end_ip: 10.0.0.254
  start_reserved: 0
  end_reserved: 0
  router_host_nth: 0
- name: Post-Auth / Accounts
  start_ip: 10.0.1.2
  end_ip: 10.0.110.254
  start_reserved: 0
  end_reserved: 0
  router_host_nth: 0
  
# Create IP Groups for subnets
IpGroup:
- name: Pre-Auth / Guests
  priority: 5
  addresses:
  - Pre-Auth / Guests
  policy: Pre-Auth / Guests
- name: Post-Auth / Accounts
  priority: 2
  addresses:
  - Post-Auth / Accounts
  policy: Post-Auth Landing
  
# Create Radius Server
RadiusServerOption:
- name: Default
  active: true
  auth_port: 1812
  acct_port: 1813
  secret: lJCCtI9qMfDe_6R1OLGdXg
  radsec_port: 2083
  debug_level: normal
  min_tls_version: '1.2'
  max_tls_version: '1.2'
  policies:
  - Management
  
# Create Radius realms for Pre-Auth/Guest and Post-Auth WLANs
RadiusServer:
- name: Pre-Auth / Guests
  reuse_vlans: true
  vta_timeout_minutes: 60
  ## VLAN assignment for onboarding/guest network will be per-device
  vlan_sharing: device
  unlimited_vlans_per_csid_mac: true
  rank: 2
  realm_admission_logic: or
  radius_server_attributes:
  - Tunnel-Type
  - Tunnel-Medium-Type
  - Tunnel-Private-Group-Id
  - Ruckus-DPSK
  vlans:
  - Pre-Auth / Guests
  radius_attribute_patterns:
  - id: 1
    radius_attribute: Called-Station-Id
    pattern: Start Here
    priority: 0
    logic: OR
- name: Post-Auth / Accounts
  reuse_vlans: false
  vta_timeout_minutes: 60
  ## VLAN assignment for Tenant/Post-Auth will be per-account
  vlan_sharing: account
  unlimited_vlans_per_csid_mac: true
  rank: 0
  realm_admission_logic: or
  radius_server_attributes:
  - Tunnel-Type
  - Tunnel-Medium-Type
  - Tunnel-Private-Group-Id
  - Ruckus-DPSK
  vlans:
  - Post-Auth / Accounts
  policies:
  - Premium
  - Free
  - Business
  - Basic
  
# Create Account Groups based on plans 
AccountGroup:
- name: Free
  policy: Free
  priority: 4
- name: Basic
  policy: Basic
  priority: 4
- name: Premium
  policy: Premium
  priority: 4
- name: Business
  policy: Business
  priority: 4
  
# Create Shared Credential Group for guest users
SharedCredentialGroup:
- name: Free
  policy: Free
  priority: 6
  credential: free
  min_mac_login_period: 1440
  usage_minutes: 60
  unlimited_usage_mb_up: true
  unlimited_usage_mb_down: true
  unlimited_simultaneous_sessions: true
  starts_at: !ruby/object:ActiveSupport::TimeWithZone
    utc: 2022-10-11 05:00:00.000000000 Z
    zone: &1 !ruby/object:ActiveSupport::TimeZone
      name: America/Chicago
    time: 2022-10-11 00:00:00.000000000 Z
  ends_at: !ruby/object:ActiveSupport::TimeWithZone
    utc: 2032-10-31 05:00:00.000000000 Z
    zone: *1
    time: 2032-10-31 00:00:00.000000000 Z
  state: active
  mon: true
  tues: true
  wed: true
  thurs: true
  fri: true
  sat: true
  sun: true
  recurring_method: none
  
# Create Captive Portal for Splash and Landing
CaptivePortal:
- name: Default Splash
  portal_name: default
  background_automatic_login: mac
  portal_automatic_login: mac_or_cookie
  password_reset_method: secret_question
  role_attribute: none
  shared_credential_groups:
  - Free
  wan_targets:
  - Certificate Validation Hosts
  - PayPal
  policies:
  - Pre-Auth / Guests
LandingPortal:
- name: Default Landing
  portal_name: default
  unlimited_session_minutes: true
  idle_minutes: 20
  session_grace_minutes: 15
  portal_automatic_login: mac_or_cookie
  background_automatic_login: mac
  policies:
  - Premium
  - Free
  - Basic
  - Business
- name: Post-Auth Landing
  portal_name: default
  unlimited_session_minutes: true
  idle_minutes: 20
  session_grace_minutes: 15
  portal_automatic_login: mac_or_cookie
  background_automatic_login: mac
  policies:
  - Post-Auth Landing
  
# Survey question to gather information for Guest users
SurveyQuestion:
- question: Email Address
  question_type: email
  required: true
  position: 1
  captive_portals:
  - Default Splash
  landing_portals:
  - Default Landing
  - Post-Auth Landing
  
# Create Billing merchants
Merchant:
- name: Authorize.Net
  gateway: AuthorizeNet
  store_payment_methods: true
  login: 74J3dDPgf
  password: 9z8ze9L8CYu2Y85K
  signature: 15437467B191351CCB81F9AD6B6A275FF398F3A98314776107995720B1F1CB6F75D9FB275FA3A403EC0B9BE79BAA36C67492FFED73EF2E911379305C671DA2A3
  dup_timeout_seconds: 60
- name: Paypal
  login: tcb@rgnets.com
  integration: Paypal
  dup_timeout_seconds: 60
  
# Create Plans
TimePlan:
- name: Unlimited
  price: 0.0
  unlimited_usage_minutes: true
QuotaPlan:
- name: 5GB / 2GB
  price: 0.0
  usage_mb_up: 2048
  usage_mb_down: 5120
- name: 15GB / 7 GB
  price: 0.0
  usage_mb_up: 7168
  usage_mb_down: 15360
- name: 50GB / 25GB
  price: 0.0
  usage_mb_up: 25600
  usage_mb_down: 51200
- name: Unlimited
  price: 0.0
  unlimited_usage_mb_up: true
  unlimited_usage_mb_down: true
UsagePlan:
- name: One Day Free 5GB
  account_group: Free
  currency: USD
  recurring_method: none
  variable_recurring_day: true
  automatic_login: true
  time_plan: Unlimited
  quota_plan: 5GB / 2GB
  usage_lifetime_time: 1
  recurring_retry_grace_minutes: 1440
  recurring_fail_limit: 5
  lock_devices: true
  max_sessions: 3
  unlimited_devices: true
  usage_lifetime_time_unit: days
  max_dedicated_ips: 0
  pms_guest_match_operator: OR
  recurring_lifetime_time_unit: months
  unlimited_recurring_lifetime: true
  validation_method: none
  validation_grace_minutes: 0
  max_party_devices: 0
  captive_portals:
  - Default Splash
  landing_portals:
  - Default Landing
  merchants:
  - Paypal
- name: One Month Basic 50GB
  account_group: Basic
  currency: USD
  recurring_method: monthly
  variable_recurring_day: true
  automatic_login: true
  time_plan: Unlimited
  quota_plan: 50GB / 25GB
  usage_lifetime_time: 1
  recurring_retry_grace_minutes: 1440
  recurring_fail_limit: 5
  lock_devices: true
  max_sessions: 3
  unlimited_devices: true
  usage_lifetime_time_unit: months
  max_dedicated_ips: 0
  pms_guest_match_operator: OR
  recurring_lifetime_time_unit: months
  unlimited_recurring_lifetime: true
  validation_method: none
  validation_grace_minutes: 0
  max_party_devices: 0
  base_price: 25.0
  captive_portals:
  - Default Splash
  landing_portals:
  - Default Landing
  merchants:
  - Authorize.Net
- name: One Month Business Class
  account_group: Business
  currency: USD
  recurring_method: monthly
  variable_recurring_day: true
  automatic_login: true
  time_plan: Unlimited
  quota_plan: Unlimited
  usage_lifetime_time: 1
  recurring_retry_grace_minutes: 1440
  recurring_fail_limit: 5
  lock_devices: true
  unlimited_devices: true
  unlimited_sessions: true
  usage_lifetime_time_unit: months
  max_dedicated_ips: 0
  pms_guest_match_operator: OR
  recurring_lifetime_time_unit: months
  unlimited_recurring_lifetime: true
  validation_method: none
  validation_grace_minutes: 0
  max_party_devices: 0
  base_price: 150.0
  captive_portals:
  - Default Splash
  landing_portals:
  - Default Landing
  merchants:
  - Authorize.Net
- name: On Demand 50GB
  account_group: Premium
  currency: USD
  recurring_method: on-demand
  automatic_login: true
  time_plan: Unlimited
  quota_plan: 50GB / 25GB
  unlimited_usage_lifetime: true
  recurring_retry_grace_minutes: 1440
  recurring_fail_limit: 5
  lock_devices: true
  unlimited_devices: true
  unlimited_sessions: true
  usage_lifetime_time_unit: months
  max_dedicated_ips: 0
  pms_guest_match_operator: OR
  recurring_lifetime_time_unit: months
  unlimited_recurring_lifetime: true
  validation_method: none
  validation_grace_minutes: 0
  max_party_devices: 0
  base_price: 25.0
  captive_portals:
  - Default Splash
  landing_portals:
  - Default Landing
  merchants:
  - Authorize.Net
- name: One Day 15GB
  account_group: Basic
  currency: USD
  recurring_method: none
  variable_recurring_day: true
  automatic_login: true
  time_plan: Unlimited
  quota_plan: 15GB / 7 GB
  usage_lifetime_time: 1
  recurring_retry_grace_minutes: 1440
  recurring_fail_limit: 5
  lock_devices: true
  max_sessions: 3
  unlimited_devices: true
  usage_lifetime_time_unit: days
  max_dedicated_ips: 0
  pms_guest_match_operator: OR
  recurring_lifetime_time_unit: months
  unlimited_recurring_lifetime: true
  validation_method: none
  validation_grace_minutes: 0
  max_party_devices: 0
  base_price: 10.0
  captive_portals:
  - Default Splash
  landing_portals:
  - Default Landing
  merchants:
  - Paypal
  
# Create Traffic Shaping rules
BandwidthQueue:
- name: Infrastructure
  upload_bw: 100
  upload_bw_unit: "%"
  download_bw: 100
  download_bw_unit: "%"
  priority: 0
  rt_upload_bw_unit: Mbps
  rt_download_bw_unit: Mbps
  burst_upload_bw_unit: Mbps
  burst_download_bw_unit: Mbps
  sharing: group
  disable_auto_ip_queues: true
  policies:
  - Management
- name: 3x1 Mbps with burst
  upload_bw: 1
  upload_bw_unit: Mbps
  download_bw: 3
  download_bw_unit: Mbps
  priority: 0
  rt_upload_bw_unit: Mbps
  rt_download_bw_unit: Mbps
  burst_upload_bw: 2
  burst_upload_bw_unit: Mbps
  burst_download_bw: 10
  burst_download_bw_unit: Mbps
  burst_ms: 5000
  sharing: ip
  policies:
  - Free
- name: 20x2 Mbps per account
  upload_bw: 2
  upload_bw_unit: Mbps
  download_bw: 20
  download_bw_unit: Mbps
  priority: 0
  rt_upload_bw_unit: Mbps
  rt_download_bw_unit: Mbps
  burst_upload_bw_unit: Mbps
  burst_download_bw_unit: Mbps
  sharing: account
  policies:
  - Basic
- name: 50x2 Mbps with guarantee
  upload_bw: 2
  upload_bw_unit: Mbps
  download_bw: 50
  download_bw_unit: Mbps
  priority: 0
  rt_upload_bw: 1
  rt_upload_bw_unit: Mbps
  rt_download_bw: 10
  rt_download_bw_unit: Mbps
  burst_upload_bw_unit: Mbps
  burst_download_bw_unit: Mbps
  sharing: account
  policies:
  - Business
- name: 50x2 Mbps per account
  upload_bw: 2
  upload_bw_unit: Mbps
  download_bw: 50
  download_bw_unit: Mbps
  priority: 0
  rt_upload_bw_unit: Mbps
  rt_download_bw_unit: Mbps
  burst_upload_bw_unit: Mbps
  burst_download_bw_unit: Mbps
  sharing: account
  policies:
  - Premium
- name: 100%
  upload_bw: 100
  upload_bw_unit: "%"
  download_bw: 100
  download_bw_unit: "%"
  priority: 0
  rt_upload_bw_unit: Kbps
  rt_download_bw_unit: Kbps
  burst_upload_bw_unit: Kbps
  burst_download_bw_unit: Kbps
  sharing: ip
  policies:
  - Post-Auth Landing
  - Pre-Auth / Guests
  
Squid:
- name: Cache
  _delete: true
  
########
# Template ends
########