API functionality for Relay to another VLAN


Is there API functionality for Relay to another VLAN in MaaS. Is it so please share.

You might be looking for PUT /MAAS/api/2.0/fabrics/{fabric_id}/vlans/{vid}/ in https://maas.io/docs/api ?

yes, but we are facing errors
curl -X PUT “XXXXXX/MAAS/api/2.0/fabrics/7/vlans/5002/”

VLAN tag (VID) out of range (0-4094; 0 for untagged.)

can you post here the request you are making?

curl -X PUT “http://XXXXXXXX:8080/MAAS/api/2.0/fabrics/7/vlans/5002/”
-H “Authorization: OAuth oauth_version="1.0", oauth_signature_method="PLAINTEXT", oauth_consumer_key="xxxxxxx", oauth_token="xxxxxxxx", oauth_signature="&xxxxxxxx", oauth_nonce="$(uuidgen)", oauth_timestamp="$(date +%s)"”
-H “Accept: application/json”
-H “Content-Type: application/x-www-form-urlencoded”
-d “name=MaaS-mgmt.untagged&description=Updated VLAN description&dhcp_on=true”

the path parameter to identify the vlan is the vid, not the id. You should use http://XXXXXXXX:8080/MAAS/api/2.0/fabrics/7/vlans/<VID>/

Yeah, now we tried with correct vid. We are getting below error. Since it is untagged we are using vid as 0
[“dhcp can only be turned on when a primary rack controller is set.”], “name”: [“Enter a valid value.”]}p

As the error is suggesting, you have to populate the primary_rack as well

Can u give any ref for that

Sure, see my link above and look at the PUT /MAAS/api/2.0/fabrics/{fabric_id}/vlans/{vid}/: Update VLAN documentation. There is a primary_rack field that you have to populate

We have populated the primary rack field and tried … We getting the same issue

{“primary_rack”: [“Select a valid choice. fytw7y is not one of the available choices.”], “all”: [“dhcp can only be turned on when a primary rack controller is set.”], “name”: [“Enter a valid value.”]}

maas admin rack-controller read fytw7y ?

Machine-readable output follows:
{
“other_test_status_name”: “Unknown”,
“swap_size”: null,
“osystem”: “ubuntu”,
“node_type_name”: “Region and rack controller”,
“zone”: {
“name”: “default”,
“description”: “”,
“id”: 1,
“resource_uri”: “/MAAS/api/2.0/zones/default/”
},
“power_type”: “”,
“cpu_speed”: 0,
“other_test_status”: -1,
“hardware_info”: {
“system_vendor”: “VMware, Inc.”,
“system_product”: “VMware20,1”,
“system_family”: “Unknown”,
“system_version”: “Unknown”,
“system_sku”: “Unknown”,
“system_serial”: “VMware-42 35 c5 5c 14 4f 8a ec-72 4c f6 cd f8 15 fb da”,
“cpu_model”: “Intel(R) Xeon(R) Gold 6442Y”,
“mainboard_vendor”: “Intel Corporation”,
“mainboard_product”: “440BX Desktop Reference Platform”,
“mainboard_serial”: “Unknown”,
“mainboard_version”: “Unknown”,
“mainboard_firmware_vendor”: “VMware, Inc.”,
“mainboard_firmware_date”: “08/19/2024”,
“mainboard_firmware_version”: “VMW201.00V.24224532.B64.2408191502”,
“chassis_vendor”: “No Enclosure”,
“chassis_type”: “Other”,
“chassis_serial”: “Unknown”,
“chassis_version”: “N/A”
},
“interface_test_status_name”: “Unknown”,
“memory_test_status_name”: “Unknown”,
“commissioning_status_name”: “Passed”,
“cpu_test_status”: -1,
“current_testing_result_id”: null,
“interface_set”: [
{
“name”: “ens33”,
“link_speed”: 10000,
“discovered”: null,
“effective_mtu”: 1500,
“links”: [
{
“id”: 1,
“mode”: “static”,
“ip_address”: “”,
“subnet”: {
“name”: “”,
“description”: “”,
“vlan”: {
“vid”: 0,
“mtu”: 1500,
“dhcp_on”: true,
“external_dhcp”: null,
“relay_vlan”: null,
“fabric_id”: 0,
“space”: “undefined”,
“name”: “untagged”,
“primary_rack”: “fytw7y”,
“secondary_rack”: null,
“fabric”: “MaaS-mgmt”,
“id”: 5001,
“resource_uri”: “/MAAS/api/2.0/vlans/5001/”
},
“cidr”: “”,
“rdns_mode”: 2,
“gateway_ip”: “<gateway_ip>”,
“dns_servers”: ,
“allow_dns”: true,
“allow_proxy”: true,
“active_discovery”: false,
“managed”: true,
“disabled_boot_architectures”: ,
“space”: “undefined”,
“id”: 1,
“resource_uri”: “/MAAS/api/2.0/subnets/1/”
}
}
],
“sriov_max_vf”: 0,
“params”: {},
“numa_node”: 0,
“mac_address”: “mac”,
“enabled”: true,
“product”: null,
“tags”: ,
“vendor”: null,
“type”: “physical”,
“link_connected”: true,
“system_id”: “fytw7y”,
“parents”: ,
“interface_speed”: 10000,
“firmware_version”: null,
“children”: ,
“vlan”: {
“vid”: 0,
“mtu”: 1500,
“dhcp_on”: true,
“external_dhcp”: null,
“relay_vlan”: null,
“fabric_id”: 0,
“space”: “undefined”,
“name”: “untagged”,
“primary_rack”: “fytw7y”,
“secondary_rack”: null,
“fabric”: “MaaS-mgmt”,
“id”: 5001,
“resource_uri”: “/MAAS/api/2.0/vlans/5001/”
},
“id”: 1,
“resource_uri”: “/MAAS/api/2.0/nodes/fytw7y/interfaces/1/”
}
],
“architecture”: “amd64/generic”,
“ip_addresses”: [
“maasip”
],
“memory_test_status”: -1,
“cpu_count”: 8,
“version”: “3.6.0-17541-g.561fe1a3e”,
“fqdn”: “ch2aiesxmaas.maas”,
“node_type”: 4,
“testing_status_name”: “Unknown”,
“cpu_test_status_name”: “Unknown”,
“commissioning_status”: 2,
“storage_test_status_name”: “Unknown”,
“network_test_status_name”: “Unknown”,
“hostname”: “ch2aiesxmaas”,
“domain”: {
“authoritative”: true,
“ttl”: null,
“name”: “maas”,
“resource_record_count”: 0,
“id”: 0,
“is_default”: true,
“resource_uri”: “/MAAS/api/2.0/domains/0/”
},
“system_id”: “fytw7y”,
“testing_status”: -1,
“hardware_uuid”: “uuid”,
“network_test_status”: -1,
“power_state”: “unknown”,
“tag_names”: [
“virtual”
],
“distro_series”: “noble”,
“memory”: 16384,
“status_action”: “”,
“current_commissioning_result_id”: 1,
“current_installation_result_id”: null,
“storage_test_status”: -1,
“interface_test_status”: -1,
“service_set”: [
{
“name”: “proxy”,
“status”: “running”,
“status_info”: “”
},
{
“name”: “ntp_region”,
“status”: “running”,
“status_info”: “”
},
{
“name”: “bind9”,
“status”: “running”,
“status_info”: “”
},
{
“name”: “temporal”,
“status”: “running”,
“status_info”: “”
},
{
“name”: “regiond”,
“status”: “running”,
“status_info”: “”
},
{
“name”: “reverse_proxy”,
“status”: “running”,
“status_info”: “”
},
{
“name”: “syslog_region”,
“status”: “running”,
“status_info”: “”
},
{
“name”: “temporal-worker”,
“status”: “running”,
“status_info”: “”
},
{
“name”: “dns_rack”,
“status”: “unknown”,
“status_info”: “managed by the region”
},
{
“name”: “dhcpd6”,
“status”: “off”,
“status_info”: “”
},
{
“name”: “proxy_rack”,
“status”: “unknown”,
“status_info”: “managed by the region”
},
{
“name”: “dhcpd”,
“status”: “running”,
“status_info”: “”
},
{
“name”: “tftp”,
“status”: “running”,
“status_info”: “”
},
{
“name”: “http”,
“status”: “running”,
“status_info”: “”
},
{
“name”: “ntp_rack”,
“status”: “unknown”,
“status_info”: “managed by the region”
},
{
“name”: “rackd”,
“status”: “running”,
“status_info”: “”
},
{
“name”: “syslog_rack”,
“status”: “unknown”,
“status_info”: “managed by the region”
},
{
“name”: “agent”,
“status”: “running”,
“status_info”: “”
}
],
“description”: “”,
“resource_uri”: “/MAAS/api/2.0/rackcontrollers/fytw7y/”

Can you post here the full request that you are making?

curl -X PUT “http://xxxxxxxx:8080/MAAS/api/2.0/fabrics/0/vlans//” -H “Authorization: OAuth oauth_version="1.0", oauth_signature_method="PLAINTEXT",
oauth_consumer_key="xxxxxxxxxxxxxx", oauth_token="",
oauth_signature="&xxxxxxxxxxxxxxxxxxx", oauth_nonce="$(uuidgen)", oauth_timestamp="$(date +%s)"”
-H “Accept: application/json” -H “Content-Type: application/x-www-form-urlencoded”
-d “type=dynamic&start_ip=xxxxxxxxx&end_ip=xxxxxxxxx&subnet=xxxxxxxxxx&name=MaaS-mgmt.untagged&description=Updated VLAN description&dhcp_on=true&primary_rack=fytw7y”

what’s the vid of the vlan you are modifying?

This does not make sense. Please look at the documentation.

Tried the below as per documentation.

Basically what we are trying is to configure DHCP for the VLAN created and Relay the vlan to management vlan .

curl -X PUT “http://xxxxxxx:8080/MAAS/api/2.0/fabrics/0/vlans/1046/” -H “Authorization: OAuth oauth_version="1.0", oauth_signature_method="PLAINTEXT", oauth_consumer_key="xxxxxx", oauth_token="xxxxxx", oauth_signature="&xxxxx", oauth_nonce="$(uuidgen)", oauth_timestamp="$(date +%s)"” -H “Accept: application/json” -H “Content-Type: application/x-www-form-urlencoded” -d “name=MaaS-mgmt.untagged&description=Updated VLAN description&dhcp_on=true&primary_rack=fytw7y&relay_vlan=0”
{“primary_rack”: [“Select a valid choice. fytw7y is not one of the available choices.”], “relay_vlan”: [“Select a valid choice. That choice is not one of the available choices.”], “all”: [“dhcp can only be turned on when a primary rack controller is set.”], “name”: [“Enter a valid value.”]}

where fabric id = 0,
vlan vid - 1046,
relayvlan vid = 0
primary_rack system name = fytw7y

If you want to enable dhcp relay on a vlan then you must not use dhcp_on and primary_rack. You should just use relay_vlan to tell MAAS that you have configured your switches to do the relay on a specific vlan that has dhcp_on and the primary_rack set, i.e. MAAS is serving dhcp on that vlan.

1 Like

thanks it worked for the usecase