Forum Discussion

ilya_f_132450's avatar
ilya_f_132450
Icon for Nimbostratus rankNimbostratus
Aug 28, 2013

Error “01020020:3: The text string cannot be converted to an IP address.” when trying to create Virtual Server with C#.

Hello! I am very new to F5 API, actually first I day I tring it. I cannot create Virtual Server. I found few posts related to the same error, but they are connected either to PowerShell or other languages, not C. I even tried to do definition.address = IPAddress.Parse("10.1.1.1").ToString(); to ensure that IP Address string is 100% correct (at least from .Net point of view), but without a luck…

 

Here is sample code:

 

Interfaces m_interfaces = new Interfaces(); m_interfaces.initialize("MyF5", "admin", "admin");

 

CommonVirtualServerDefinition definition = new CommonVirtualServerDefinition(); definition.address = "10.1.1.1"; definition.port = 443; definition.name = "test2"; definition.protocol = CommonProtocolType.PROTOCOL_ANY; CommonVirtualServerDefinition[] definitions = {definition};

 

string[] wildmasks = {"*"};

 

LocalLBVirtualServerVirtualServerResource vsResource = new LocalLBVirtualServerVirtualServerResource(); vsResource.default_pool_name = "test2";

 

LocalLBVirtualServerVirtualServerResource[] vsResources = {vsResource}; LocalLBVirtualServerVirtualServerProfile vsProfile = new LocalLBVirtualServerVirtualServerProfile(); vsProfile.profile_name="http";

 

LocalLBVirtualServerVirtualServerProfile[] vsProfiles = {vsProfile}; LocalLBVirtualServerVirtualServerProfile[][] vsProfiles2 = {vsProfiles};

 

m_interfaces.LocalLBVirtualServer.create(definitions, wildmasks, vsResources, vsProfiles2 );

 

Thank you, Ilya.

 

4 Replies

  • I'm thinking that the error may have come from using a wildcard in the wildmasks array. I believe you have to use dot notation for the wildmask (in your case 255.255.255.255 for a value). Most likely the code is trying to do a internal call to inet_addr("*") returning that error.

     

    Here's a sample I wrote a while back in PowerShell (similar to the C code you'd be writing) that does a VirtualServer create.

     

    https://devcentral.f5.com/wiki/iControl.PsProvisionVEForLocalDev.ashx

     

    Hope this helps...

     

    -Joe

     

  • Thank you very much, Joe!

     

    This makes perfect sense. To be honest I did not realize that wildmasks is array of IP subnet masks and put “*” just to try and see… Thank you, now, with {"255.255.255.255"} it works. One more change I was needed to make is set definition.protocol = CommonProtocolType.PROTOCOL_TCP, instead of PROTOCOL_ANY.

     

    By the way is there any .NET API documentation, more detailed than what I can see object browser?

     

    Thank you once again :) Ilya.