cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2596
Views
1
Helpful
2
Replies

Create VLAN using API on MX

mikefredrik
Level 1
Level 1

Hi
I've noticed that when I use the API to create VLANs on the MX there might be an error in the API.
I use the createNetworkApplianceVlan with the following parameters: (some are comming from a few input statment and will later be part of a data flow between different systems)

network_id, id_,
name='test60',
subnet='60.30.20.0/24',
applianceIp='60.30.20.1',
ipv6={'enabled': True,},
dhcpHandling='Run a DHCP server',
dhcpLeaseTime ='1 hour',
dnsNameservers='opendns'
The two thing that is not reflected in the dashboard is Leasetime and DNS name server, the dashboard use the default upstream DNS and 1 day leasetime, not really what I want, event tried the swagewr on the meraki.io page to make sure I didn't have any type that will cause the API to use defaults.
My current workaround is to then run the
updateNetworkApplianceVlan with the following input:
network_id, vlan_id,
name=vlan_name, <This is from an input string
dhcpLeaseTime='1 hour',
dnsNameservers='opendns'
Now the DHCP settings reflect what I want
As always it could be error code 40 (problem 40 cm from the keyboard) but also something else.
Ideas / Input appriciated
//Mikael
1 Accepted Solution

Accepted Solutions

The main problem here is that creating an endpoint often doesn't accept the same parameters as updating the endpoint.

I always use the same approach as you with generating the VLAN and then setting all needed parameters:

print("Step "+next(step)+":     Create VLAN User-LAN ... ")
   response = dashboard.appliance.createNetworkApplianceVlan(
      network_hq_id, 1000, name='User-LAN',
      subnet='10.1.0.0/24', 
      applianceIp='10.1.0.254'
   )
print("Step "+next(step)+":     Update VLAN User-LAN DHCP ... ")
   response = dashboard.appliance.updateNetworkApplianceVlan(
      network_hq_id, 1000,
      dhcpHandling='Run a DHCP server', 
      dhcpLeaseTime='1 day', 
      dhcpBootOptionsEnabled=False, 
      reservedIpRanges=[{'start': '10.1.0.128', 'end': '10.1.0.254', 'comment': 'Reserved'}], 
      dnsNameservers='opendns', 
      dhcpOptions=[{'code': '18', 'type': 'text', 'value': 'company.intern'},
                {'code': '42', 'type': 'IP', 'value': '192.53.103.101'}]
   )
--
If you found this post helpful, please give it Kudos. If my answer solves your problem, please click Accept as Solution so others can benefit from it.

View solution in original post

2 Replies 2

The main problem here is that creating an endpoint often doesn't accept the same parameters as updating the endpoint.

I always use the same approach as you with generating the VLAN and then setting all needed parameters:

print("Step "+next(step)+":     Create VLAN User-LAN ... ")
   response = dashboard.appliance.createNetworkApplianceVlan(
      network_hq_id, 1000, name='User-LAN',
      subnet='10.1.0.0/24', 
      applianceIp='10.1.0.254'
   )
print("Step "+next(step)+":     Update VLAN User-LAN DHCP ... ")
   response = dashboard.appliance.updateNetworkApplianceVlan(
      network_hq_id, 1000,
      dhcpHandling='Run a DHCP server', 
      dhcpLeaseTime='1 day', 
      dhcpBootOptionsEnabled=False, 
      reservedIpRanges=[{'start': '10.1.0.128', 'end': '10.1.0.254', 'comment': 'Reserved'}], 
      dnsNameservers='opendns', 
      dhcpOptions=[{'code': '18', 'type': 'text', 'value': 'company.intern'},
                {'code': '42', 'type': 'IP', 'value': '192.53.103.101'}]
   )
--
If you found this post helpful, please give it Kudos. If my answer solves your problem, please click Accept as Solution so others can benefit from it.

mikefredrik
Level 1
Level 1

Yes that will be the workflow
Little annoying that when you read the schema definition most of the parameters are defined/explained.
I used the same in my code basically just like you, create the basic and then update with specifics