VMware {code} Community
naangilsunder
Contributor
Contributor

Unable to NAT IP Address

HI,

I use .Net SDK to NAT IP address to network but I get the "HTTP method not allowed" error.

Code

                 var network = org.GetNetworkRefByName("myNetworkName");
                var adminorg = AdminOrgNetwork.GetOrgNetworkByReference(vClient, network);
               
                var natrules = new NatRuleType[1];
                var natrule = new NatRuleType();
                var natOneToOneBasicRuleType = new NatOneToOneBasicRuleType();
                natOneToOneBasicRuleType.ExternalIP = "************";
                natOneToOneBasicRuleType.InternalIP = "192.168.0.100";
                natOneToOneBasicRuleType.MappingMode = NatMappingModeType.manual;
                natrule.Item = natOneToOneBasicRuleType;
                natrules[0] = natrule;
               
                var narservice = new NatServiceType { IsEnabled = true, NatRule = natrules, NatType = NatTypeType.ipTranslation };
                adminorg.GetConfiguration().Features.NatService = narservice;
               
                adminorg.UpdateOrgNetwork(adminorg.Resource);///I Get the error here

Please help

Reply
0 Kudos
2 Replies
rkamal
VMware Employee
VMware Employee

Hi,

  
Your code,
    var network = org.GetNetworkRefByName("myNetworkName");

The org object is from the Organization helper class. It should be of the AdminOrganization helper class.

This below code throws the error you posted,

          ReferenceType orgRef = client.getOrgRefByName("cloudOrg");           Organization org = Organization.getOrganizationByReference(client, orgRef);           ReferenceType orgNetworkRef = org.getNetworkRefByName("DirectOrgNetwork");           AdminOrgNetwork adminOrgNetwork = AdminOrgNetwork.getOrgNetworkByReference(client, orgNetworkRef);           adminOrgNetwork.updateOrgNetwork(adminOrgNetwork.getResource());

It should be something like this,

          ReferenceType adminOrgRef = client.getVcloudAdmin().getAdminOrgRefByName("cloudOrg");           AdminOrganization adminOrg = AdminOrganization.getAdminOrgByReference(client, adminOrgRef);           ReferenceType orgNetworkRef = adminOrg.getAdminOrgNetworkRefByName("DirectOrgNetwork");           AdminOrgNetwork adminOrgNetwork = AdminOrgNetwork.getOrgNetworkByReference(client, orgNetworkRef);           adminOrgNetwork.updateOrgNetwork(adminOrgNetwork.getResource());

Regards,

Rajesh Kamal.

Reply
0 Kudos
abhishek2408
Contributor
Contributor

Thanks... This was useful !!

Reply
0 Kudos