VMware Cloud Community
redsand007
Enthusiast
Enthusiast

VcHostFirewallRuleDirection Object Creation

I am trying to create a new ESXi host firewall rule and am trying to define a VcHostFirewallRuleDirection object by using the following:

var firewallRuleDirection = new VcHostFirewallRuleDirection();

I receive the following error: 

 Unable to create object : VcHostFirewallRuleDirection : com.vmware.vim.binding.vim.host.Ruleset$Rule$Direction

Seems pretty simple, but it's def. not correct for some reason.  What would be the correct syntax to create this?

5 Replies
iiliev
VMware Employee
VMware Employee

VcHostFirewallRuleDirection is not a normal scripting object but an enumeration, so you should not try to initialize it using new, but instead directly access the enumeration value(s).

Something like the following should work:

var firewallRuleDirectionInbound = VcHostFirewallRuleDirection.inbound;

var firewallRuleDirectionOutbound = VcHostFirewallRuleDirection.outbound;

redsand007
Enthusiast
Enthusiast

aaahhhh ok I see the difference now.  Thanks again sir!
Reply
0 Kudos
redsand007
Enthusiast
Enthusiast

As a follow up, now that I have this new VcHostFirewallRule object array where do I apply (Vc:HostSystem.configManager?) & method (VcHostFirewallRuleset?) to add the new rule?
Reply
0 Kudos
lurims
Enthusiast
Enthusiast

I have to create a bunch of rules for the ESXi hosts.  Could not see any examples.  Could you give some examples here on how to create new rules?  I am able to see the list of rules those are present but not sure how to create new ones and apply them.  Here some example rules I am looking to create

Allow - SSH Server - <IPs, and Network Addresses>

Deny - SSH client - <Any>

Reply
0 Kudos
qc4vmware
Virtuoso
Virtuoso

Ilian is not a sir Smiley Wink
Reply
0 Kudos