Search in sources :

Example 36 with ExecutionResult

use of com.cloud.utils.ExecutionResult in project cloudstack by apache.

the class Ovm3VirtualRoutingResourceTest method createFileInVRFailTest.

@Test
public void createFileInVRFailTest() {
    ConnectionTest con = new ConnectionTest();
    virtualrouting.setConnection(con);
    ExecutionResult result = virtualrouting.createFileInVR(domrIp, "/tmp", "test", "1 2 3");
    results.basicBooleanTest(result.isSuccess(), false);
}
Also used : ExecutionResult(com.cloud.utils.ExecutionResult) ConnectionTest(com.cloud.hypervisor.ovm3.objects.ConnectionTest) Test(org.junit.Test) ConnectionTest(com.cloud.hypervisor.ovm3.objects.ConnectionTest) CloudStackPluginTest(com.cloud.hypervisor.ovm3.objects.CloudStackPluginTest) LinuxTest(com.cloud.hypervisor.ovm3.objects.LinuxTest) NetworkTest(com.cloud.hypervisor.ovm3.objects.NetworkTest) XenTest(com.cloud.hypervisor.ovm3.objects.XenTest) Ovm3SupportTest(com.cloud.hypervisor.ovm3.support.Ovm3SupportTest) XmlTestResultTest(com.cloud.hypervisor.ovm3.objects.XmlTestResultTest) Ovm3ConfigurationTest(com.cloud.hypervisor.ovm3.resources.helpers.Ovm3ConfigurationTest)

Example 37 with ExecutionResult

use of com.cloud.utils.ExecutionResult in project cloudstack by apache.

the class Ovm3VirtualRoutingResourceTest method createFileInVRTest.

@Test
public void createFileInVRTest() {
    con = support.prepConnectionResults();
    virtualrouting.setConnection(con);
    ExecutionResult result = virtualrouting.createFileInVR(domrIp, "/tmp", "test", "1 2 3");
    results.basicBooleanTest(result.isSuccess());
}
Also used : ExecutionResult(com.cloud.utils.ExecutionResult) Test(org.junit.Test) ConnectionTest(com.cloud.hypervisor.ovm3.objects.ConnectionTest) CloudStackPluginTest(com.cloud.hypervisor.ovm3.objects.CloudStackPluginTest) LinuxTest(com.cloud.hypervisor.ovm3.objects.LinuxTest) NetworkTest(com.cloud.hypervisor.ovm3.objects.NetworkTest) XenTest(com.cloud.hypervisor.ovm3.objects.XenTest) Ovm3SupportTest(com.cloud.hypervisor.ovm3.support.Ovm3SupportTest) XmlTestResultTest(com.cloud.hypervisor.ovm3.objects.XmlTestResultTest) Ovm3ConfigurationTest(com.cloud.hypervisor.ovm3.resources.helpers.Ovm3ConfigurationTest)

Example 38 with ExecutionResult

use of com.cloud.utils.ExecutionResult in project cloudstack by apache.

the class LibvirtComputingResource method prepareNetworkElementCommand.

protected ExecutionResult prepareNetworkElementCommand(final IpAssocVpcCommand cmd) {
    Connect conn;
    final String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
    try {
        conn = LibvirtConnection.getConnectionByVmName(routerName);
        final IpAddressTO[] ips = cmd.getIpAddresses();
        Integer devNum = 0;
        final Map<String, Integer> broadcastUriToNicNum = new HashMap<String, Integer>();
        final List<InterfaceDef> pluggedNics = getInterfaces(conn, routerName);
        for (final InterfaceDef pluggedNic : pluggedNics) {
            final String pluggedVlan = pluggedNic.getBrName();
            if (pluggedVlan.equalsIgnoreCase(_linkLocalBridgeName)) {
                broadcastUriToNicNum.put("LinkLocal", devNum);
            } else if (pluggedVlan.equalsIgnoreCase(_publicBridgeName) || pluggedVlan.equalsIgnoreCase(_privBridgeName) || pluggedVlan.equalsIgnoreCase(_guestBridgeName)) {
                broadcastUriToNicNum.put(BroadcastDomainType.Vlan.toUri(Vlan.UNTAGGED).toString(), devNum);
            } else {
                broadcastUriToNicNum.put(getBroadcastUriFromBridge(pluggedVlan), devNum);
            }
            devNum++;
        }
        for (final IpAddressTO ip : ips) {
            ip.setNicDevId(broadcastUriToNicNum.get(ip.getBroadcastUri()));
        }
        return new ExecutionResult(true, null);
    } catch (final LibvirtException e) {
        s_logger.error("Ip Assoc failure on applying one ip due to exception:  ", e);
        return new ExecutionResult(false, e.getMessage());
    }
}
Also used : InterfaceDef(com.cloud.hypervisor.kvm.resource.LibvirtVMDef.InterfaceDef) IpAddressTO(com.cloud.agent.api.to.IpAddressTO) LibvirtException(org.libvirt.LibvirtException) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Connect(org.libvirt.Connect) ExecutionResult(com.cloud.utils.ExecutionResult)

Example 39 with ExecutionResult

use of com.cloud.utils.ExecutionResult in project cloudstack by apache.

the class CitrixResourceBase method prepareNetworkElementCommand.

protected ExecutionResult prepareNetworkElementCommand(final SetNetworkACLCommand cmd) {
    final Connection conn = getConnection();
    final String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
    try {
        final VM router = getVM(conn, routerName);
        final NicTO nic = cmd.getNic();
        if (nic != null) {
            final VIF vif = getVifByMac(conn, router, nic.getMac());
            if (vif == null) {
                final String msg = "Prepare SetNetworkACL failed due to VIF is null for : " + nic.getMac() + " with routername: " + routerName;
                s_logger.error(msg);
                return new ExecutionResult(false, msg);
            }
            nic.setDeviceId(Integer.parseInt(vif.getDevice(conn)));
        } else {
            final String msg = "Prepare SetNetworkACL failed due to nic is null for : " + routerName;
            s_logger.error(msg);
            return new ExecutionResult(false, msg);
        }
    } catch (final Exception e) {
        final String msg = "Prepare SetNetworkACL failed due to " + e.toString();
        s_logger.error(msg, e);
        return new ExecutionResult(false, msg);
    }
    return new ExecutionResult(true, null);
}
Also used : VIF(com.xensource.xenapi.VIF) VM(com.xensource.xenapi.VM) Connection(com.xensource.xenapi.Connection) URLConnection(java.net.URLConnection) ExecutionResult(com.cloud.utils.ExecutionResult) XenAPIException(com.xensource.xenapi.Types.XenAPIException) XmlRpcException(org.apache.xmlrpc.XmlRpcException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) TimeoutException(java.util.concurrent.TimeoutException) SAXException(org.xml.sax.SAXException) InternalErrorException(com.cloud.exception.InternalErrorException) ConfigurationException(javax.naming.ConfigurationException) MalformedURLException(java.net.MalformedURLException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) NicTO(com.cloud.agent.api.to.NicTO)

Example 40 with ExecutionResult

use of com.cloud.utils.ExecutionResult in project cloudstack by apache.

the class CitrixResourceBase method prepareNetworkElementCommand.

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);
    try {
        final IpAddressTO[] ips = cmd.getIpAddresses();
        for (final IpAddressTO ip : ips) {
            final VM router = getVM(conn, routerName);
            final NicTO nic = new NicTO();
            nic.setMac(ip.getVifMacAddress());
            nic.setType(ip.getTrafficType());
            if (ip.getBroadcastUri() == null) {
                nic.setBroadcastType(BroadcastDomainType.Native);
            } else {
                final URI uri = BroadcastDomainType.fromString(ip.getBroadcastUri());
                nic.setBroadcastType(BroadcastDomainType.getSchemeValue(uri));
                nic.setBroadcastUri(uri);
            }
            nic.setDeviceId(0);
            nic.setNetworkRateMbps(ip.getNetworkRate());
            nic.setName(ip.getNetworkName());
            final Network network = getNetwork(conn, nic);
            // Determine the correct VIF on DomR to associate/disassociate
            // the
            // IP address with
            VIF correctVif = getCorrectVif(conn, router, network);
            // If we are associating an IP address and DomR doesn't have a
            // VIF
            // for the specified vlan ID, we need to add a VIF
            // If we are disassociating the last IP address in the VLAN, we
            // need
            // to remove a VIF
            boolean addVif = false;
            if (ip.isAdd() && correctVif == null) {
                addVif = true;
            }
            if (addVif) {
                // Add a new VIF to DomR
                final String vifDeviceNum = getLowestAvailableVIFDeviceNum(conn, router);
                if (vifDeviceNum == null) {
                    throw new InternalErrorException("There were no more available slots for a new VIF on router: " + router.getNameLabel(conn));
                }
                nic.setDeviceId(Integer.parseInt(vifDeviceNum));
                correctVif = createVif(conn, routerName, router, null, nic);
                correctVif.plug(conn);
                // Add iptables rule for network usage
                networkUsage(conn, routerIp, "addVif", "eth" + correctVif.getDevice(conn));
            }
            if (ip.isAdd() && correctVif == null) {
                throw new InternalErrorException("Failed to find DomR VIF to associate/disassociate IP with.");
            }
            if (correctVif != null) {
                ip.setNicDevId(Integer.valueOf(correctVif.getDevice(conn)));
                ip.setNewNic(addVif);
            }
        }
    } catch (final InternalErrorException e) {
        s_logger.error("Ip Assoc failure on applying one ip due to exception:  ", e);
        return new ExecutionResult(false, e.getMessage());
    } catch (final Exception e) {
        return new ExecutionResult(false, e.getMessage());
    }
    return new ExecutionResult(true, null);
}
Also used : IpAddressTO(com.cloud.agent.api.to.IpAddressTO) Connection(com.xensource.xenapi.Connection) URLConnection(java.net.URLConnection) ExecutionResult(com.cloud.utils.ExecutionResult) InternalErrorException(com.cloud.exception.InternalErrorException) URI(java.net.URI) XenAPIException(com.xensource.xenapi.Types.XenAPIException) XmlRpcException(org.apache.xmlrpc.XmlRpcException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) TimeoutException(java.util.concurrent.TimeoutException) SAXException(org.xml.sax.SAXException) InternalErrorException(com.cloud.exception.InternalErrorException) ConfigurationException(javax.naming.ConfigurationException) MalformedURLException(java.net.MalformedURLException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) VIF(com.xensource.xenapi.VIF) VM(com.xensource.xenapi.VM) Network(com.xensource.xenapi.Network) NicTO(com.cloud.agent.api.to.NicTO)

Aggregations

ExecutionResult (com.cloud.utils.ExecutionResult)50 InternalErrorException (com.cloud.exception.InternalErrorException)23 IOException (java.io.IOException)20 ConfigurationException (javax.naming.ConfigurationException)20 IpAddressTO (com.cloud.agent.api.to.IpAddressTO)16 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)16 URISyntaxException (java.net.URISyntaxException)13 NicTO (com.cloud.agent.api.to.NicTO)11 ConnectException (java.net.ConnectException)11 RemoteException (java.rmi.RemoteException)11 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)9 SAXException (org.xml.sax.SAXException)9 XenAPIException (com.xensource.xenapi.Types.XenAPIException)8 MalformedURLException (java.net.MalformedURLException)8 TimeoutException (java.util.concurrent.TimeoutException)8 XmlRpcException (org.apache.xmlrpc.XmlRpcException)8 CloudException (com.cloud.exception.CloudException)7 Connection (com.xensource.xenapi.Connection)7 UnsupportedEncodingException (java.io.UnsupportedEncodingException)7 URI (java.net.URI)7