Search in sources :

Example 1 with XcpOssResource

use of com.cloud.hypervisor.xenserver.resource.XcpOssResource in project cloudstack by apache.

the class DirectAgentManagerSimpleImpl method loadResource.

protected void loadResource(Long hostId) {
    HostVO host = hostDao.findById(hostId);
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("guid", host.getGuid());
    params.put("ipaddress", host.getPrivateIpAddress());
    params.put("username", "root");
    params.put("password", "password");
    params.put("zone", String.valueOf(host.getDataCenterId()));
    params.put("pod", String.valueOf(host.getPodId()));
    ServerResource resource = null;
    if (host.getHypervisorType() == HypervisorType.XenServer) {
        resource = new XcpOssResource();
        try {
            resource.configure(host.getName(), params);
        } catch (ConfigurationException e) {
            logger.debug("Failed to load resource:" + e.toString());
        }
    } else if (host.getHypervisorType() == HypervisorType.KVM) {
        resource = new LibvirtComputingResource();
        try {
            params.put("public.network.device", "cloudbr0");
            params.put("private.network.device", "cloudbr0");
            resource.configure(host.getName(), params);
        } catch (ConfigurationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    } else if (host.getHypervisorType() == HypervisorType.VMware) {
        ClusterVO cluster = clusterDao.findById(host.getClusterId());
        String url = clusterDetailsDao.findDetail(cluster.getId(), "url").getValue();
        URI uri;
        try {
            uri = new URI(url);
            String userName = clusterDetailsDao.findDetail(cluster.getId(), "username").getValue();
            String password = clusterDetailsDao.findDetail(cluster.getId(), "password").getValue();
            VmwareServerDiscoverer discover = new VmwareServerDiscoverer();
            Map<? extends ServerResource, Map<String, String>> resources = discover.find(host.getDataCenterId(), host.getPodId(), host.getClusterId(), uri, userName, password, null);
            for (Map.Entry<? extends ServerResource, Map<String, String>> entry : resources.entrySet()) {
                resource = entry.getKey();
            }
            if (resource == null) {
                throw new CloudRuntimeException("can't find resource");
            }
        } catch (DiscoveryException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (URISyntaxException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    hostResourcesMap.put(hostId, resource);
    HostEnvironment env = new HostEnvironment();
    SetupCommand cmd = new SetupCommand(env);
    cmd.setNeedSetup(true);
    resource.executeRequest(cmd);
}
Also used : ClusterVO(com.cloud.dc.ClusterVO) HashMap(java.util.HashMap) ServerResource(com.cloud.resource.ServerResource) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) VmwareServerDiscoverer(com.cloud.hypervisor.vmware.VmwareServerDiscoverer) HostEnvironment(com.cloud.host.HostEnvironment) SetupCommand(com.cloud.agent.api.SetupCommand) HostVO(com.cloud.host.HostVO) XcpOssResource(com.cloud.hypervisor.xenserver.resource.XcpOssResource) ConfigurationException(javax.naming.ConfigurationException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) LibvirtComputingResource(com.cloud.hypervisor.kvm.resource.LibvirtComputingResource) HashMap(java.util.HashMap) Map(java.util.Map) DiscoveryException(com.cloud.exception.DiscoveryException)

Example 2 with XcpOssResource

use of com.cloud.hypervisor.xenserver.resource.XcpOssResource in project cloudstack by apache.

the class XcpServerDiscoverer method createServerResource.

protected CitrixResourceBase createServerResource(String prodBrand, String prodVersion, String prodVersionTextShort, String hotfix) {
    // Xen Cloud Platform group of hypervisors
    if (prodBrand.equals("XCP") && (prodVersion.equals("1.0.0") || prodVersion.equals("1.1.0") || prodVersion.equals("5.6.100") || prodVersion.startsWith("1.4") || prodVersion.startsWith("1.6"))) {
        return new XcpServerResource();
    } else // Citrix Xenserver group of hypervisors
    if (prodBrand.equals("XenServer") && prodVersion.equals("5.6.0"))
        return new XenServer56Resource();
    else if (prodBrand.equals("XenServer") && prodVersion.equals("6.0.0"))
        return new XenServer600Resource();
    else if (prodBrand.equals("XenServer") && prodVersion.equals("6.0.2"))
        return new XenServer600Resource();
    else if (prodBrand.equals("XenServer") && prodVersion.equals("6.1.0"))
        return new XenServer610Resource();
    else if (prodBrand.equals("XenServer") && prodVersion.equals("6.2.0")) {
        if (hotfix != null && hotfix.equals(XenserverConfigs.XSHotFix62ESP1004)) {
            return new Xenserver625Resource();
        } else if (hotfix != null && hotfix.equals(XenserverConfigs.XSHotFix62ESP1)) {
            return new XenServer620SP1Resource();
        } else {
            return new XenServer620Resource();
        }
    } else if (prodBrand.equals("XenServer") && prodVersion.equals("5.6.100")) {
        if ("5.6 SP2".equals(prodVersionTextShort.trim())) {
            return new XenServer56SP2Resource();
        } else if ("5.6 FP1".equals(prodVersionTextShort.trim())) {
            return new XenServer56FP1Resource();
        }
    } else if (prodBrand.equals("XCP_Kronos")) {
        return new XcpOssResource();
    } else if (prodBrand.equals("XenServer")) {
        final String[] items = prodVersion.split("\\.");
        if ((Integer.parseInt(items[0]) > 6) || (Integer.parseInt(items[0]) == 6 && Integer.parseInt(items[1]) >= 4)) {
            s_logger.warn("defaulting to xenserver650 resource for product brand: " + prodBrand + " with product " + "version: " + prodVersion);
            //default to xenserver650 resource.
            return new XenServer650Resource();
        }
    }
    String msg = "Only support XCP 1.0.0, 1.1.0, 1.4.x, 1.5 beta, 1.6.x; XenServer 5.6,  XenServer 5.6 FP1, XenServer 5.6 SP2, Xenserver 6.0, 6.0.2, 6.1.0, 6.2.0, >6.4.0 but this one is " + prodBrand + " " + prodVersion;
    s_logger.warn(msg);
    throw new RuntimeException(msg);
}
Also used : XenServer56FP1Resource(com.cloud.hypervisor.xenserver.resource.XenServer56FP1Resource) XenServer600Resource(com.cloud.hypervisor.xenserver.resource.XenServer600Resource) XenServer650Resource(com.cloud.hypervisor.xenserver.resource.XenServer650Resource) XenServer620Resource(com.cloud.hypervisor.xenserver.resource.XenServer620Resource) XenServer56Resource(com.cloud.hypervisor.xenserver.resource.XenServer56Resource) Xenserver625Resource(com.cloud.hypervisor.xenserver.resource.Xenserver625Resource) XenServer56SP2Resource(com.cloud.hypervisor.xenserver.resource.XenServer56SP2Resource) XcpOssResource(com.cloud.hypervisor.xenserver.resource.XcpOssResource) XcpServerResource(com.cloud.hypervisor.xenserver.resource.XcpServerResource) XenServer610Resource(com.cloud.hypervisor.xenserver.resource.XenServer610Resource) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) XenServer620SP1Resource(com.cloud.hypervisor.xenserver.resource.XenServer620SP1Resource)

Aggregations

XcpOssResource (com.cloud.hypervisor.xenserver.resource.XcpOssResource)2 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 SetupCommand (com.cloud.agent.api.SetupCommand)1 ClusterVO (com.cloud.dc.ClusterVO)1 DiscoveryException (com.cloud.exception.DiscoveryException)1 HostEnvironment (com.cloud.host.HostEnvironment)1 HostVO (com.cloud.host.HostVO)1 LibvirtComputingResource (com.cloud.hypervisor.kvm.resource.LibvirtComputingResource)1 VmwareServerDiscoverer (com.cloud.hypervisor.vmware.VmwareServerDiscoverer)1 XcpServerResource (com.cloud.hypervisor.xenserver.resource.XcpServerResource)1 XenServer56FP1Resource (com.cloud.hypervisor.xenserver.resource.XenServer56FP1Resource)1 XenServer56Resource (com.cloud.hypervisor.xenserver.resource.XenServer56Resource)1 XenServer56SP2Resource (com.cloud.hypervisor.xenserver.resource.XenServer56SP2Resource)1 XenServer600Resource (com.cloud.hypervisor.xenserver.resource.XenServer600Resource)1 XenServer610Resource (com.cloud.hypervisor.xenserver.resource.XenServer610Resource)1 XenServer620Resource (com.cloud.hypervisor.xenserver.resource.XenServer620Resource)1 XenServer620SP1Resource (com.cloud.hypervisor.xenserver.resource.XenServer620SP1Resource)1 XenServer650Resource (com.cloud.hypervisor.xenserver.resource.XenServer650Resource)1 Xenserver625Resource (com.cloud.hypervisor.xenserver.resource.Xenserver625Resource)1 ServerResource (com.cloud.resource.ServerResource)1