Forum Discussion

jnunham_332885's avatar
jnunham_332885
Icon for Altostratus rankAltostratus
Sep 08, 2017

Syntax of Get-F5.iControl.NetworkingVLAN.Begincreate_v2

Hello,

 

I'm trying to write a PowerShell script that will be used to automate the deployment of our F5 LTMs. I want to be able to use this script to lay down a base template instead of having to click through the interface every time I'm setting up a new one. So far my script is able to set the FQDN of the F5 using this code:

 

$iControl = Get-[F5.iControl](//F5.iControl)

$FQDN = Read-Host -Prompt 'Enter the FQDN for the LTM'

$iControl.SystemInet.set_hostname($FQDN)

So I'm trying to use $iControl.NetworkingVLAN.Begincreate_v2(). I'm not sure how to specify the VLAN I want to create, the interfaces, etc. with this command. If anyone is familiar with using iControl to do this, can they please share some code examples or point me to an article that goes in to more depth on how to use the Begincreate method?

 

Thanks!

 

  • I didn't realize it at the time, but there is an article that explains how to use this:

     

    https://devcentral.f5.com/codeshare?sid=183

     

    Here is the code that works if this can help anyone else in the future! I needed to create VLANs that were both tagged and untagged, so I just made 2 functions for each. I'm only listing the tagged VLAN function here, but if you want to make an untagged one then just change the value of member.tag_state to UNTAGGED instead of TAGGED.

     

    function Create-Tagged-VLAN()
    
    {
      param([string]$name,
        [long]$id,
        [string]$member_name);
    
    $vlans = (, $name);
      $vlan_ids = (, $id);
      $member = New-Object -TypeName iControl.NetworkingVLANMemberEntry;
      $member.member_name = $member_name
      $member.member_type = "MEMBER_INTERFACE";
      $member.tag_state = "MEMBER_Tagged"
      $memberA = (, $member);
      $memberAofA = (, $memberA);
      $failsafe_states = (, "STATE_DISABLED");
      $timeouts = (, 1500);
      $mac_masquerade = (, "");
    
    $iControl.NetworkingVLAN.create(
        $vlans,
        $vlan_ids,
        $memberAofA,
        $failsafe_states,
        $timeouts,
        $mac_masquerade);
    }
    
    Create-Tagged-VLAN -name "VLAN-500" -id 500 -member_name "1.4";
  • I didn't realize it at the time, but there is an article that explains how to use this:

     

    https://devcentral.f5.com/codeshare?sid=183

     

    Here is the code that works if this can help anyone else in the future! I needed to create VLANs that were both tagged and untagged, so I just made 2 functions for each. I'm only listing the tagged VLAN function here, but if you want to make an untagged one then just change the value of member.tag_state to UNTAGGED instead of TAGGED.

     

    function Create-Tagged-VLAN()
    
    {
      param([string]$name,
        [long]$id,
        [string]$member_name);
    
    $vlans = (, $name);
      $vlan_ids = (, $id);
      $member = New-Object -TypeName iControl.NetworkingVLANMemberEntry;
      $member.member_name = $member_name
      $member.member_type = "MEMBER_INTERFACE";
      $member.tag_state = "MEMBER_Tagged"
      $memberA = (, $member);
      $memberAofA = (, $memberA);
      $failsafe_states = (, "STATE_DISABLED");
      $timeouts = (, 1500);
      $mac_masquerade = (, "");
    
    $iControl.NetworkingVLAN.create(
        $vlans,
        $vlan_ids,
        $memberAofA,
        $failsafe_states,
        $timeouts,
        $mac_masquerade);
    }
    
    Create-Tagged-VLAN -name "VLAN-500" -id 500 -member_name "1.4";