Forum Discussion

dr_tamfr_dhp_19's avatar
dr_tamfr_dhp_19
Icon for Nimbostratus rankNimbostratus
Nov 12, 2015

Possible to specify FQDN for new node address via iControl and Powershell?

Product : Virtual BigIP LTM ProductVersion : 11.6.0 PackageVersion : Build 5.13.429 - Thu Jul 23 16:58:10 PDT 2015 PackageEdition : Engineering Hotfix HF5

 

Hi,

 

Working on an automated solution. I am able to successfully create new nodes using iControl SnapIn and PS. However, the API only allows me to use IP addresses when creating the nodes, and not a fqdn (when I try it throws invalidargument exception). The author of the snapin also says an IP address is required.

 

Here is a snippet of the powershell code I use:

 

 This provides all of the cmdlets we need
Add-PSSnapin iControlSnapin

Initialize-F5.iControl -Hostname $LTMName -Username $LTMUserName -Password $LTMPassword

(Get-F5.iControl).LocalLBNodeAddressV2.create(@($NodeName),@($NodeAddress),@(0))

I thought about changing it after it is created, but the API documentation states "...A set_address method is not supported." Any idea on how to accomplish this via iControl? Will I be forced to use a different solution?

 

Thanks, pimy

 

7 Replies

  • R_Marc's avatar
    R_Marc
    Icon for Nimbostratus rankNimbostratus

    I can't speak for PS or snapins (whatever that is) but this worked for me:

    cat test_fqdn.json | python -m json.tool; curl -sk -u admin:$PASS -H "Content-Type: application/json" -X POST https://bigip1/mgmt/tm/ltm/pool/ -d@test_fqdn.json | python -m json.tool
    
    JSON file:
    {
        "members": [
            {
                "fqdn": {
                    "autopopulate": "enabled",
                    "tmName": "KSCUCPL01.mydomain.com"
                },
                "name": "KSCUCPL01.mydomain.com:4443",
                "priorityGroup": 100
            }
        ],
        "name": "test-fqdn-pool"
    }
    
    Result:
    {
        "allowNat": "yes",
        "allowSnat": "yes",
        "fullPath": "test-fqdn-pool",
        "generation": 43,
        "ignorePersistedWeight": "disabled",
        "ipTosToClient": "pass-through",
        "ipTosToServer": "pass-through",
        "kind": "tm:ltm:pool:poolstate",
        "linkQosToClient": "pass-through",
        "linkQosToServer": "pass-through",
        "loadBalancingMode": "round-robin",
        "membersReference": {
            "isSubcollection": true,
            "link": "https://localhost/mgmt/tm/ltm/pool/~Common~test-fqdn-pool/members?ver=11.6.0"
        },
        "minActiveMembers": 0,
        "minUpMembers": 0,
        "minUpMembersAction": "failover",
        "minUpMembersChecking": "disabled",
        "name": "test-fqdn-pool",
        "queueDepthLimit": 0,
        "queueOnConnectionLimit": "disabled",
        "queueTimeLimit": 0,
        "reselectTries": 0,
        "selfLink": "https://localhost/mgmt/tm/ltm/pool/test-fqdn-pool?ver=11.6.0",
        "serviceDownAction": "none",
        "slowRampTime": 10
    }
    
    
  • Awesome. Thank you R Marc! I did not realize you could also create nodes via the new Pool screen.

     

    Your example is using the iControl REST API, correct? If so, I need to do more research on that. It seems that is the future for remote LTM management.

     

    Btw, I tested your example and it worked.

     

    I then checked the iControl API to see if it allows you to also create new nodes via a new pool. It does, via the Pool interface, and more specifically, the create and create_v2 methods.

     

    So I tried using the New-Pool cmdlet in the F5-LTM module I am using, and it pukes. Complains about the IP address. My guess is that is it using the create method, which requires an IP Address. The create_V2 method allows either an IP address or Virtual Address. I tested using the iControl Snapin and the Get-F5.iControl cmdlet and it worked!

     

    Here is a snippet of what I used.

     

    $object = New-Object -TypeName iControl.CommonAddressPort $object.address = 'myhost.mydomain.com' $object.port = 443

     

    (Get-F5.iControl).LocalLBPool.create_v2(@('mypool'),@('LB_METHOD_ROUND_ROBIN'),@($object))

     

    Cheers, pimy

     

    • R_Marc_77962's avatar
      R_Marc_77962
      Icon for Nimbostratus rankNimbostratus
      It is via the restAPI yes. Can't really help with the PS. I don't do windows ;).
  • Still me, just with a different account.

     

    Spoke too soon. Seems like my approach sets FQDN Auto Populate to false on the node. I will dig through the API to see if I can figure out how to set that to True either at the time of creation, or after the fact.

     

    Cheers, pimy

     

  • I've been retesting this, and my approach with the iControl API does not work unless the node already exists (or you use an IP address). When I was testing, I was just deleting the pool beforehand, but I forgot to delete the node.

    When I retested from scratch, I got this error:

    Exception calling "create_v2" with "3" argument(s): "Exception caught in
    LocalLB::urn:iControl:LocalLB/Pool::create_v2()
    Exception: Common::OperationFailed
        primary_error_code   : 16908342 (0x01020036)
        secondary_error_code : 0
        error_string         : 01020036:3: The requested node
    (/Common/myhost.mydomain.com) was not found."
    At line:1 char:80
    + (Get-F5.iControl).LocalLBPool.create_v2(@('mypool'),@('LB_METHOD_ROUND_ROBIN'),
    @($ ...
    +
      ~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : SoapHeaderException
    

    I am dropping this and focusing purely on the iCR approach.

    Thanks, pimy

  • Based on the answer posted by R Marc, I've created a function in PowerShell that creates pools with new FQDN nodes.

    Function Create-Pools
    {
        <
        .SYNOPSIS
        Creates a new pool with a new FQDN node
        >
        [CmdletBinding(HelpURI="https://devcentral.f5.com/questions/possible-to-specify-fqdn-for-new-node-address-via-icontrol-and-powershell")]
        param([Parameter(Mandatory=$true)][string]$poolName,
              [Parameter(Mandatory=$true)][string]$NodeFqdn,
              [Parameter(Mandatory=$true)][string]$port,
              [Parameter(Mandatory=$true)][System.Net.WebClient]$webclient,
              [Parameter(Mandatory=$true)][string]$F5Host)
    
        $webclient.headers.Add("Content-Type: application/json") 
    
        $json='{
            "members": [
                {
                    "fqdn": {
                        "autopopulate": "enabled",
                        "tmName": "'+$NodeFqdn+'"
                    },
                    "name": "'+$NodeFqdn+':'+$port+'",
                    "priorityGroup": 0
                }
            ],
            "name": "'+$poolName+'"
        }'
        $webclient.UploadString("https://$F5Host/mgmt/tm/ltm/pool","POST",$json)
    }
    

    Here's some sample usage:

     Construct the webclient object
    $webclient = New-Object System.Net.WebClient
    $creds = New-Object System.Net.NetworkCredential($username,$password)
    $webclient.Credentials = $creds
    Create-Pools -poolName "MyPoolName" -NodeFqdn "webserver.test.com" -port 80 -webclient $webclient -F5Host "MyF5Server"
    
  • I don't believe the SOAP interfaces supports FQDN's for nodes. I'll have to do some testing but it's not supported for sure with create. You may have to look into the REST interface for node. Info for that endpoint can be found at: https://clouddocs.f5.com/api/icontrol-rest/APIRef_tm_ltm_node.html

     

    Not a lot of REST samples out there yet, but you should be able to test it out with the REST interface's GUI on the BIGIP. Navigate to and you should be able to drill down into the node object for the creation parameters.

     

    -Joe