Forum Discussion
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
- ilya_f_132450
Nimbostratus
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.
All of the API documentation is in the iControl wiki at https://devcentral.f5.com/wiki/iControl.APIReference.ashx.
We designed the API reference to be language agnostic so we can support all the client libraries out there. But, it should be understandable from a .Net perspective.
-Joe
- ilya_f_132450
Nimbostratus
Thanks a lot!
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com