Orchestrator Function: Add a Firewall Rule to an Edge

by Simon Sparks · 5 September 2013

To use this function add it to the class library file named vCloudService.ts

GitHub Repository: https://github.com/SimonSparksUK/Orchestrator

Filename: vCloudService.ts

Description: Orchestrator Function to Create a Firewall Rule on an Edge

Function VclFirewallRuleCreate

publicVclFirewallRuleCreate(objVclGateway:VclGateway,blnVclFirewallRuleProtocolAny:boolean,blnVclFirewallRuleProtocolTcp:boolean,blnVclFirewallRuleProtocolUdp:boolean,blnVclFirewallRuleProtocolIcmp:boolean,strVclFirewallRuleProtocolOther:string,intPort:number,strPolicy:string,strDescription:string,strIcmpSubType:string,strDestinationPortRange:string,strDestinationIp:string,objVclVmSelectionDestination:VclVmSelection,intSourcePort:number,strSourcePortRange:string,strSourceIp:string,objVclVmSelectionSource:VclVmSelection,strDirection:string,blnMatchOnTranslate:boolean):void{
objVclGateway.updateInternalState();

letobjVclFirewallRuleProtocols:VclFirewallRuleProtocols=newVclFirewallRuleProtocols();
objVclFirewallRuleProtocols.any=blnVclFirewallRuleProtocolAny;
objVclFirewallRuleProtocols.tcp=blnVclFirewallRuleProtocolTcp;
objVclFirewallRuleProtocols.udp=blnVclFirewallRuleProtocolUdp;
objVclFirewallRuleProtocols.icmp=blnVclFirewallRuleProtocolIcmp;
objVclFirewallRuleProtocols.other=strVclFirewallRuleProtocolOther;

letobjVclFirewallRule:VclFirewallRule=newVclFirewallRule();
objVclFirewallRule.isEnabled=true;
objVclFirewallRule.enableLogging=false;
objVclFirewallRule.port=intPort;
objVclFirewallRule.policy=strPolicy;
objVclFirewallRule.description=strDescription;
objVclFirewallRule.protocols=objVclFirewallRuleProtocols;
objVclFirewallRule.icmpSubType=strIcmpSubType;
objVclFirewallRule.destinationPortRange=strDestinationPortRange;
objVclFirewallRule.destinationIp=strDestinationIp;
objVclFirewallRule.destinationVm=objVclVmSelectionDestination;
objVclFirewallRule.sourcePort=intSourcePort;
objVclFirewallRule.sourcePortRange=strSourcePortRange;
objVclFirewallRule.sourceIp=strSourceIp;
objVclFirewallRule.sourceVm=objVclVmSelectionSource;
objVclFirewallRule.direction=strDirection;
objVclFirewallRule.matchOnTranslate=blnMatchOnTranslate;

letobjVclGatewayConfiguration:VclGatewayConfiguration=objVclGateway.configuration;

letobjVclGatewayFeatures:VclGatewayFeatures=objVclGatewayConfiguration.edgeGatewayServiceConfiguration;

letobjVclAbstractObjectSet:VclAbstractObjectSet=objVclGatewayFeatures.networkService;

letarrVclFirewallService:VclFirewallService[]=objVclAbstractObjectSet.find(newVclFirewallService());

letobjVclFirewallService:VclFirewallService=arrVclFirewallService[0];

objVclFirewallService.firewallRule.add(objVclFirewallRule);

letobjVclTask:VclTask=objVclGateway.update();

this.WaitForVclTask(objVclTask,1);
}

Discover more from Cloud Build Tools

Subscribe to get the latest posts sent to your email.

You may also like