Search in sources :

Example 6 with IpAssocAnswer

use of com.cloud.agent.api.routing.IpAssocAnswer in project cloudstack by apache.

the class PaloAltoResourceTest method implementGuestNetwork.

@Test
public void implementGuestNetwork() throws ConfigurationException, ExecutionException {
    if (_context.containsKey("enable_console_output") && _context.get("enable_console_output").equals("true")) {
        System.out.println("\nTEST: implementGuestNetwork");
        System.out.println("---------------------------------------------------");
    }
    _resource.configure("PaloAltoResource", _resourceParams);
    IpAddressTO ip = new IpAddressTO(Long.valueOf("1"), "192.168.80.102", true, false, true, "untagged", null, null, null, 100, false);
    IpAddressTO[] ips = new IpAddressTO[1];
    ips[0] = ip;
    IpAssocCommand cmd = new IpAssocCommand(ips);
    cmd.setAccessDetail(NetworkElementCommand.GUEST_NETWORK_GATEWAY, "10.3.96.1");
    cmd.setAccessDetail(NetworkElementCommand.GUEST_NETWORK_CIDR, "10.3.96.1/20");
    cmd.setAccessDetail(NetworkElementCommand.GUEST_VLAN_TAG, "3954");
    IpAssocAnswer answer = (IpAssocAnswer) _resource.executeRequest(cmd);
    assertTrue(answer.getResult());
}
Also used : IpAssocAnswer(com.cloud.agent.api.routing.IpAssocAnswer) IpAddressTO(com.cloud.agent.api.to.IpAddressTO) IpAssocCommand(com.cloud.agent.api.routing.IpAssocCommand) Test(org.junit.Test)

Example 7 with IpAssocAnswer

use of com.cloud.agent.api.routing.IpAssocAnswer in project cloudstack by apache.

the class PaloAltoResourceTest method shutdownGuestNetwork.

@Test
public void shutdownGuestNetwork() throws ConfigurationException, ExecutionException {
    if (_context.containsKey("enable_console_output") && _context.get("enable_console_output").equals("true")) {
        System.out.println("\nTEST: shutdownGuestNetwork");
        System.out.println("---------------------------------------------------");
    }
    _context.put("has_public_interface", "true");
    _context.put("has_private_interface", "true");
    _context.put("has_src_nat_rule", "true");
    _context.put("has_isolation_fw_rule", "true");
    _resource.setMockContext(_context);
    _resource.configure("PaloAltoResource", _resourceParams);
    IpAddressTO ip = new IpAddressTO(Long.valueOf("1"), "192.168.80.102", false, false, true, "untagged", null, null, null, 100, false);
    IpAddressTO[] ips = new IpAddressTO[1];
    ips[0] = ip;
    IpAssocCommand cmd = new IpAssocCommand(ips);
    cmd.setAccessDetail(NetworkElementCommand.GUEST_NETWORK_GATEWAY, "10.3.96.1");
    cmd.setAccessDetail(NetworkElementCommand.GUEST_NETWORK_CIDR, "10.3.96.1/20");
    cmd.setAccessDetail(NetworkElementCommand.GUEST_VLAN_TAG, "3954");
    IpAssocAnswer answer = (IpAssocAnswer) _resource.executeRequest(cmd);
    assertTrue(answer.getResult());
}
Also used : IpAssocAnswer(com.cloud.agent.api.routing.IpAssocAnswer) IpAddressTO(com.cloud.agent.api.to.IpAddressTO) IpAssocCommand(com.cloud.agent.api.routing.IpAssocCommand) Test(org.junit.Test)

Example 8 with IpAssocAnswer

use of com.cloud.agent.api.routing.IpAssocAnswer in project cloudstack by apache.

the class MockNetworkManagerImpl method ipAssoc.

@Override
public IpAssocAnswer ipAssoc(IpAssocVpcCommand cmd) {
    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);
}
Also used : IpAssocAnswer(com.cloud.agent.api.routing.IpAssocAnswer) IpAddressTO(com.cloud.agent.api.to.IpAddressTO)

Example 9 with IpAssocAnswer

use of com.cloud.agent.api.routing.IpAssocAnswer in project cloudstack by apache.

the class NetscalerResource method execute.

private synchronized Answer execute(final IpAssocCommand cmd, final int numRetries) {
    if (_isSdx) {
        return Answer.createUnsupportedCommandAnswer(cmd);
    }
    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());
            final String vlanSelfIp = ip.getVlanGateway();
            final String vlanNetmask = ip.getVlanNetmask();
            if (ip.isAdd()) {
                // Add a new guest VLAN and its subnet and bind it to private interface
                addGuestVlanAndSubnet(guestVlanTag, vlanSelfIp, vlanNetmask, true);
            } else {
                // Check and delete guest VLAN with this tag, self IP, and netmask
                deleteGuestVlan(guestVlanTag, vlanSelfIp, vlanNetmask);
            }
            saveConfiguration();
            results[i++] = ip.getPublicIp() + " - success";
            final String action = ip.isAdd() ? "associate" : "remove";
            if (s_logger.isDebugEnabled()) {
                s_logger.debug("Netscaler load balancer " + _ip + " successfully executed IPAssocCommand to " + action + " IP " + ip);
            }
        }
    } catch (final ExecutionException e) {
        s_logger.error("Netscaler loadbalancer " + _ip + " failed to execute IPAssocCommand due to " + e.getMessage());
        if (shouldRetry(numRetries)) {
            return retry(cmd, numRetries);
        } else {
            results[i++] = IpAssocAnswer.errorResult;
        }
    }
    return new IpAssocAnswer(cmd, results);
}
Also used : IpAssocAnswer(com.cloud.agent.api.routing.IpAssocAnswer) IpAddressTO(com.cloud.agent.api.to.IpAddressTO) ExecutionException(com.cloud.utils.exception.ExecutionException)

Aggregations

IpAssocAnswer (com.cloud.agent.api.routing.IpAssocAnswer)9 IpAddressTO (com.cloud.agent.api.to.IpAddressTO)9 ExecutionException (com.cloud.utils.exception.ExecutionException)4 IpAssocCommand (com.cloud.agent.api.routing.IpAssocCommand)2 IOException (java.io.IOException)2 ConfigurationException (javax.naming.ConfigurationException)2 Test (org.junit.Test)2 InterfaceDef (com.cloud.agent.resource.computing.LibvirtVMDef.InterfaceDef)1 InternalErrorException (com.cloud.exception.InternalErrorException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 SocketTimeoutException (java.net.SocketTimeoutException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 XPathExpressionException (javax.xml.xpath.XPathExpressionException)1 Connect (org.libvirt.Connect)1 LibvirtException (org.libvirt.LibvirtException)1