use of iControl.NetworkingVLANMemberEntry in project cloudstack by apache.
the class F5BigIpResource method addGuestVlan.
private void addGuestVlan(long vlanTag, String vlanSelfIp, String vlanNetmask, boolean inline) throws ExecutionException {
try {
String vlanName = genVlanName(vlanTag);
List<String> allVlans = getStrippedVlans();
if (!allVlans.contains(vlanName)) {
String[] vlanNames = genStringArray(vlanName);
long[] vlanTags = genLongArray(vlanTag);
CommonEnabledState[] commonEnabledState = { CommonEnabledState.STATE_DISABLED };
// Create the interface name
NetworkingVLANMemberEntry[][] vlanMemberEntries = { { new NetworkingVLANMemberEntry() } };
vlanMemberEntries[0][0].setMember_type(NetworkingMemberType.MEMBER_INTERFACE);
vlanMemberEntries[0][0].setTag_state(NetworkingMemberTagType.MEMBER_TAGGED);
vlanMemberEntries[0][0].setMember_name(_privateInterface);
s_logger.debug("Creating a guest VLAN with tag " + vlanTag);
_vlanApi.create(vlanNames, vlanTags, vlanMemberEntries, commonEnabledState, new long[] { 10L }, new String[] { "00:00:00:00:00:00" });
s_logger.debug("vlanName " + vlanName);
s_logger.debug("getStrippedVlans " + getStrippedVlans());
if (!getStrippedVlans().contains(vlanName)) {
throw new ExecutionException("Failed to create vlan with tag " + vlanTag);
}
}
if (inline) {
List<Long> allRouteDomains = getRouteDomains();
if (!allRouteDomains.contains(vlanTag)) {
long[] routeDomainIds = genLongArray(vlanTag);
String[][] vlanNames = new String[][] { genStringArray(genVlanName(vlanTag)) };
s_logger.debug("Creating route domain " + vlanTag);
_routeDomainApi.create(routeDomainIds, vlanNames);
if (!getRouteDomains().contains(vlanTag)) {
throw new ExecutionException("Failed to create route domain " + vlanTag);
}
}
}
List<String> allSelfIps = getSelfIps();
if (!allSelfIps.contains(vlanSelfIp)) {
String[] selfIpsToCreate = genStringArray(vlanSelfIp);
String[] vlans = genStringArray(vlanName);
String[] netmasks = genStringArray(vlanNetmask);
long[] unitIds = genLongArray(0L);
CommonEnabledState[] enabledStates = new CommonEnabledState[] { CommonEnabledState.STATE_DISABLED };
s_logger.debug("Creating self IP " + vlanSelfIp);
_selfIpApi.create(selfIpsToCreate, vlans, netmasks, unitIds, enabledStates);
if (!getSelfIps().contains(vlanSelfIp)) {
throw new ExecutionException("Failed to create self IP " + vlanSelfIp);
}
}
} catch (RemoteException e) {
s_logger.error(e);
throw new ExecutionException(e.getMessage());
}
}
Aggregations