public void GetNetworkSecurityRuleTest()
{
string name = TesterName;
string description = null;
var os = new OpenStackMember(UserName, Password, TenantName, TenantId);
var group = os.CreateNetworkSecurityGroup(name, description);
Assert.IsNotNull(group);
try
{
string direction = "ingress"; // "ingress" or "egress"
string etherType = "IPv4"; // "IPv4" or "IPv6"
string portRangeMin = null;
string portRangeMax = null;
string protocol = null;
string remoteGroupId = null;
string remoteIpPrefix = null;
var rule = os.CreateNetworkSecurityGroupRule(group.Id, direction, etherType, portRangeMin, portRangeMax, protocol, remoteGroupId, remoteIpPrefix);
Assert.IsNotNull(rule);
rule = os.GetNetworkSecurityGroupRule(rule.Id);
Trace.WriteLine(string.Format("rule id : {0}", rule.Id));
Trace.WriteLine(string.Format("rule EtherType : {0}", rule.EtherType));
Trace.WriteLine(string.Format("rule PortRangeMin : {0}", rule.PortRangeMin));
Trace.WriteLine(string.Format("rule PortRangeMax : {0}", rule.PortRangeMax));
Trace.WriteLine(string.Format("rule Protocol : {0}", rule.Protocol));
Trace.WriteLine(string.Format("rule RemoteIpPrefix : {0}", rule.RemoteIpPrefix));
Trace.WriteLine(string.Format("rule SecurityGroupId : {0}", rule.SecurityGroupId));
Trace.WriteLine(string.Format("rule RemoteGroupId : {0}", rule.RemoteGroupId));
Assert.IsTrue(os.DeleteNetworkSecurityGroupRule(rule.Id));
}
finally
{
Assert.IsTrue(os.DeleteNetworkSecurityGroup(group.Id));
}
}