Reply
Accepted Solution

Problem on record:host ipv4addr, with _object_parameters (Powershell)

[ Edited ]
kenger
Techie
Posts: 2
2859     0

Hi

 

I want to create a new host, and assign it a IP in a scope that has the ext attribute VLAN_NAME == APP_LAN, but I cant get it to work.

 

I found this example, that I cant get to work in powershell:

POST /wapi/v1.2/record:host
 Content-Type: application/json

    { "name":"wapi.test.org",
      "ipv4addrs":[
            ipv4addr" : {
                "_function" : 'next_available_ip' ,
                "_object_field" : 'value' ,
                "_object" : 'network'
                "_object_parameters" : {
                    "*VLAN_NAME" : "APP_LAN"
                },
                "_parameters" : {
                   "num" : 1,
                   "exclude" : [ '192.168.12.50' , '192.168.12.51' ],
                }
            }
        ]
    }

I tried converting it, but no matter what I try, I get a 400 Bad request

There are also someting that i'm not sure is right, ex:

'192.168.12.51' ],  <- the last ,.. is that correct?

 

My powershell version looks like this:

 

$data = '{ "name":"server188","configure_for_dns": false,
      "ipv4addrs":[
            "ipv4addr": {
                "_function" : "next_available_ip" ,
                "_object_field" : "value" ,
                "_object" : "network",
                "_object_parameters" : {
                    "*VLAN_NAME" : "APP_LAN"
                },
                "_parameters" : {
                   "num" : 1,
                   "exclude" : [ "192.168.12.55" ]
                }
            }
        ]
    }'
$uri = "$baseUri/record:host"
Invoke-RestMethod -Uri $uri -Method POST -Credential $cred -ContentType "application/json" -Body $data -Verbose

anyone got a clue?

 

Thanks.

kenger

Highlighted

Re: Problem on record:host ipv4addr, with _object_parameters (Powershell)

kenger
Techie
Posts: 2
2859     0

I got it Smiley Happy, solution:

 

{
    "name": "Server666","configure_for_dns": false,
    "ipv4addrs": [
        {
            "ipv4addr": {
                "_object_function": "next_available_ip",
                "_object": "network",
                "_object_parameters": {"*Region": "APP_LAN"},
                "_result_field": "ips",
                "_parameters": {
                    "num": 1
                }
            }
        }
    ]
}
Showing results for 
Search instead for 
Do you mean 

Recommended for You