private ExecutionResult prepareNetworkElementCommand(IpAssocCommand cmd) { return prepNetBoth(cmd .getAccessDetail(NetworkElementCommand.ROUTER_NAME), cmd.getIpAddresses(), "IpAssocCommand"); }
public IpAssocAnswer(IpAssocCommand cmd, String[] results) { boolean finalResult = true; for (String result : results) { if (result.equals(errorResult)) { finalResult = false; break; } } this.result = finalResult; this.details = null; assert (cmd.getIpAddresses().length == results.length) : "Shouldn't the results match the commands?"; this.results = results; }
final IpAssocCommand cmd = new IpAssocCommand(ipsToSend); cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, _routerControlHelper.getRouterControlIp(router.getId())); cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, _routerControlHelper.getRouterIpInNetwork(associatedWithNetworkId, router.getId())); cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName()); final DataCenterVO dcVo = _dcDao.findById(router.getDataCenterId()); cmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, dcVo.getNetworkType().toString()); cmd.setAccessDetail(NetworkElementCommand.NETWORK_PUB_LAST_IP, "true"); } else { cmd.setAccessDetail(NetworkElementCommand.NETWORK_PUB_LAST_IP, "false");
IpAddressTO[] ips = new IpAddressTO[1]; ips[0] = ip; IpAssocCommand cmd = new IpAssocCommand(ips); Answer answer = _agentMgr.easySend(externalLoadBalancer.getId(), cmd);
private synchronized Answer execute(IpAssocCommand cmd, int numRetries) { String[] results = new String[cmd.getIpAddresses().length]; int i = 0; IpAddressTO[] ips = cmd.getIpAddresses(); for (IpAddressTO ip : ips) { results[i++] = ip.getPublicIp() + " - success"; } return new IpAssocAnswer(cmd, results); }
IpAddressTO[] ips = new IpAddressTO[1]; ips[0] = ip; IpAssocCommand cmd = new IpAssocCommand(ips); cmd.setAccessDetail(NetworkElementCommand.GUEST_NETWORK_GATEWAY, guestVlanGateway); cmd.setAccessDetail(NetworkElementCommand.GUEST_NETWORK_CIDR, guestVlanCidr); cmd.setAccessDetail(NetworkElementCommand.GUEST_VLAN_TAG, String.valueOf(guestVlanTag)); Answer answer = _agentMgr.easySend(externalFirewall.getId(), cmd);
protected Answer execute(final IpAssocCommand cmd) { if (s_logger.isInfoEnabled()) { s_logger.info("Executing resource IPAssocCommand: " + s_gson.toJson(cmd)); } int i = 0; final String[] results = new String[cmd.getIpAddresses().length]; try { final IpAddressTO[] ips = cmd.getIpAddresses(); final String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME); final String controlIp = getRouterSshControlIp(cmd); for (final IpAddressTO ip : ips) { assignPublicIpAddress(routerName, controlIp, ip.getPublicIp(), ip.isAdd(), ip.isFirstIP(), ip.isSourceNat(), ip.getBroadcastUri(), ip.getVlanGateway(), ip.getVlanNetmask(), ip.getVifMacAddress()); results[i++] = ip.getPublicIp() + " - success"; } for (; i < cmd.getIpAddresses().length; i++) { results[i++] = IpAssocAnswer.errorResult; } } catch (final Throwable e) { s_logger.error("Unexpected exception: " + e.toString() + " will shortcut rest of IPAssoc commands", e); for (; i < cmd.getIpAddresses().length; i++) { results[i++] = IpAssocAnswer.errorResult; } } return new IpAssocAnswer(cmd, results); }
@Override public List<ConfigItem> generateConfig(final NetworkElementCommand cmd) { final IpAssocCommand command = (IpAssocCommand) cmd; final List<IpAddress> ips = new LinkedList<IpAddress>(); for (final IpAddressTO ip : command.getIpAddresses()) { final IpAddress ipAddress = new IpAddress(ip.getPublicIp(), ip.isSourceNat(), ip.isAdd(), ip.isOneToOneNat(), ip.isFirstIP(), ip.getVlanGateway(), ip.getVlanNetmask(), ip.getVifMacAddress(), ip.getNicDevId(), ip.isNewNic(), ip.getTrafficType().toString()); ips.add(ipAddress); } final IpAssociation ipAssociation = new IpAssociation(ips.toArray(new IpAddress[ips.size()])); return generateConfigItems(ipAssociation); }
private Answer execute(IpAssocCommand cmd, int numRetries) { String[] results = new String[cmd.getIpAddresses().length]; int i = 0; try { IpAddressTO ip; if (cmd.getIpAddresses().length != 1) { throw new ExecutionException("Received an invalid number of guest IPs to associate."); } else { ip = cmd.getIpAddresses()[0]; long guestVlanTag = Long.parseLong(cmd.getAccessDetail(NetworkElementCommand.GUEST_VLAN_TAG)); String guestVlanGateway = cmd.getAccessDetail(NetworkElementCommand.GUEST_NETWORK_GATEWAY); String cidr = cmd.getAccessDetail(NetworkElementCommand.GUEST_NETWORK_CIDR); long cidrSize = NetUtils.cidrToLong(cidr)[1]; String guestVlanSubnet = NetUtils.getCidrSubNet(guestVlanGateway, cidrSize);
final String[] results = new String[cmd.getIpAddresses().length]; int i = 0; try { final IpAddressTO[] ips = cmd.getIpAddresses(); for (final IpAddressTO ip : ips) { final long guestVlanTag = Long.parseLong(ip.getBroadcastUri());
protected ExecutionResult cleanupNetworkElementCommand(final IpAssocCommand cmd) { final String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME); final String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); final String lastIp = cmd.getAccessDetail(NetworkElementCommand.NETWORK_PUB_LAST_IP); Connect conn; final IpAddressTO[] ips = cmd.getIpAddresses(); int nicNum = 0; for (final IpAddressTO ip : ips) {
public ExecutionResult prepareNetworkElementCommand(final IpAssocCommand cmd) { final String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME); final String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); Connect conn; try { final IpAddressTO[] ips = cmd.getIpAddresses(); int nicNum = 0; for (final IpAddressTO ip : ips) {
private ExecutionResult prepareNetworkElementCommand(final IpAssocCommand cmd) { try { final IpAddressTO[] ips = cmd.getIpAddresses(); final String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME); final String controlIp = getRouterSshControlIp(cmd);
protected ExecutionResult cleanupNetworkElementCommand(final IpAssocCommand cmd) { final Connection conn = getConnection(); final String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME); final String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); final String lastIp = cmd.getAccessDetail(NetworkElementCommand.NETWORK_PUB_LAST_IP); final IpAddressTO[] ips = cmd.getIpAddresses(); for (final IpAddressTO ip : ips) {
protected ExecutionResult prepareNetworkElementCommand(final IpAssocCommand cmd) { final Connection conn = getConnection(); final String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME); final String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP); final IpAddressTO[] ips = cmd.getIpAddresses(); for (final IpAddressTO ip : ips) {