1: public void testSelfIp(String[] args)
2: {
3: try
4: {
5: iControl.Interfaces interfaces = new iControl.Interfaces();
6: interfaces.initialize(args[0], args[1], args[2]);
7:
8: // Get list of existing SelfIPs
9: iControl.Objects.Networking.SelfIP [] selfips =
10: iControl.Objects.Networking.SelfIP.getList(interfaces);
11: System.out.println("Existing SelfIP List");
12: System.out.println("--------------------");
13: for(int i=0; i<selfips.length; i++)
14: {
15: selfips[i].syncProperties();
16:
17: System.out.println("[" + selfips[i].getUnitId() + "] " +
18: selfips[i].getAddress() + "/" + selfips[i].getNetmask() +
19: ", VLAN='" + selfips[i].getVLAN() +
20: "', FSTATE='" + selfips[i].getFloatingState() + "'" );
21: }
22:
23: // Create SelfIP
24: System.out.println("Creating SelfIP 20.20.20.1...");
25: iControl.Objects.Networking.SelfIP.create(interfaces, "20.20.20.1",
26: "external1", "255.255.255.0", 0, iControl.CommonEnabledState.STATE_DISABLED);
27: System.out.println("SelfIP 20.20.20.1 successfully created...");
28:
29: iControl.Objects.Networking.SelfIP selfip2 =
30: new iControl.Objects.Networking.SelfIP(interfaces, "20.20.20.1");
31:
32: selfip2.syncProperties();
33: System.out.println("[" + selfip2.getUnitId() + "] " +
34: selfip2.getAddress() + "/" + selfip2.getNetmask() +
35: ", VLAN='" + selfip2.getVLAN() +
36: "', FSTATE='" + selfip2.getFloatingState() + "'" );
37:
38: // Get list of existing SelfIPs
39: selfips = iControl.Objects.Networking.SelfIP.getList(interfaces);
40: System.out.println("Existing SelfIP List");
41: System.out.println("--------------------");
42: for(int i=0; i<selfips.length; i++)
43: {
44: selfips[i].syncProperties();
45:
46: System.out.println("[" + selfips[i].getUnitId() + "] " +
47: selfips[i].getAddress() + "/" + selfips[i].getNetmask() +
48: ", VLAN='" + selfips[i].getVLAN() +
49: "', FSTATE='" + selfips[i].getFloatingState() + "'" );
50: }
51:
52: // Remove SelfIP
53: System.out.println("Removing SelfIP 20.20.20.1...");
54: selfip2.remove();
55: System.out.println("SelfIP 20.20.20.1 successfully removed...");
56:
57: // Get list of existing SelfIPs
58: selfips = iControl.Objects.Networking.SelfIP.getList(interfaces);
59: System.out.println("Existing SelfIP List");
60: System.out.println("--------------------");
61: for(int i=0; i<selfips.length; i++)
62: {
63: selfips[i].syncProperties();
64:
65: System.out.println("[" + selfips[i].getUnitId() + "] " +
66: selfips[i].getAddress() + "/" + selfips[i].getNetmask() +
67: ", VLAN='" + selfips[i].getVLAN() +
68: "', FSTATE='" + selfips[i].getFloatingState() + "'" );
69: }
70:
71: }
72: catch(Exception ex)
73: {
74: ex.printStackTrace(System.out);
75: }
76: }