Package com.cloud.resource

Examples of com.cloud.resource.AgentResourceBase


    @DB
    public Map<AgentResourceBase, Map<String, String>> createServerResources(Map<String, Object> params) {

        Map<String, String> args = new HashMap<String, String>();
        Map<AgentResourceBase, Map<String, String>> newResources = new HashMap<AgentResourceBase, Map<String, String>>();
        AgentResourceBase agentResource;
        long cpuCore = Long.parseLong((String)params.get("cpucore"));
        long cpuSpeed = Long.parseLong((String)params.get("cpuspeed"));
        long memory = Long.parseLong((String)params.get("memory"));
        long localStorageSize = Long.parseLong((String)params.get("localstorage"));
        synchronized (this) {
            long dataCenterId = Long.parseLong((String)params.get("zone"));
            long podId = Long.parseLong((String)params.get("pod"));
            long clusterId = Long.parseLong((String)params.get("cluster"));
            long cidrSize = getPodCidr(podId, dataCenterId).second();

            int agentId = getNextAgentId(cidrSize);
            String ipAddress = getIpAddress(agentId, dataCenterId, podId);
            String macAddress = getMacAddress(dataCenterId, podId, clusterId, agentId);
            MockHostVO mockHost = new MockHostVO();
            mockHost.setDataCenterId(dataCenterId);
            mockHost.setPodId(podId);
            mockHost.setClusterId(clusterId);
            mockHost.setCapabilities("hvm");
            mockHost.setCpuCount(cpuCore);
            mockHost.setCpuSpeed(cpuSpeed);
            mockHost.setMemorySize(memory);
            String guid = UUID.randomUUID().toString();
            mockHost.setGuid(guid);
            mockHost.setName("SimulatedAgent." + guid);
            mockHost.setPrivateIpAddress(ipAddress);
            mockHost.setPublicIpAddress(ipAddress);
            mockHost.setStorageIpAddress(ipAddress);
            mockHost.setPrivateMacAddress(macAddress);
            mockHost.setPublicMacAddress(macAddress);
            mockHost.setStorageMacAddress(macAddress);
            mockHost.setVersion(this.getClass().getPackage().getImplementationVersion());
            mockHost.setResource("com.cloud.agent.AgentRoutingResource");

            TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
            try {
                txn.start();
                mockHost = _mockHostDao.persist(mockHost);
                txn.commit();
            } catch (Exception ex) {
                txn.rollback();
                s_logger.error("Error while configuring mock agent " + ex.getMessage());
                throw new CloudRuntimeException("Error configuring agent", ex);
            } finally {
                txn.close();
                txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
                txn.close();
            }

            _storageMgr.getLocalStorage(guid, localStorageSize);

            agentResource = new AgentRoutingResource();
            if (agentResource != null) {
                try {
                    params.put("guid", mockHost.getGuid());
                    agentResource.start();
                    agentResource.configure(mockHost.getName(), params);

                    newResources.put(agentResource, args);
                } catch (ConfigurationException e) {
                    s_logger.error("error while configuring server resource" + e.getMessage());
                }
View Full Code Here


                    txn.start();
                    MockHost host = _mockHostDao.findByVmId(this.vmId);
                    if (host != null) {
                        String guid = host.getGuid();
                        if (guid != null) {
                            AgentResourceBase res = _resources.get(guid);
                            if (res != null) {
                                res.stop();
                                _resources.remove(guid);
                            }
                        }
                    }
                    txn.commit();
View Full Code Here

    @DB
    public Map<AgentResourceBase, Map<String, String>> createServerResources(Map<String, Object> params) {

        Map<String, String> args = new HashMap<String, String>();
        Map<AgentResourceBase, Map<String, String>> newResources = new HashMap<AgentResourceBase, Map<String, String>>();
        AgentResourceBase agentResource;
        long cpuCore = Long.parseLong((String) params.get("cpucore"));
        long cpuSpeed = Long.parseLong((String) params.get("cpuspeed"));
        long memory = Long.parseLong((String) params.get("memory"));
        long localStorageSize = Long.parseLong((String) params.get("localstorage"));
        synchronized (this) {
            long dataCenterId = Long.parseLong((String) params.get("zone"));
            long podId = Long.parseLong((String) params.get("pod"));
            long clusterId = Long.parseLong((String) params.get("cluster"));
            long cidrSize = getPodCidr(podId, dataCenterId).second();

            int agentId = getNextAgentId(cidrSize);
            String ipAddress = getIpAddress(agentId, dataCenterId, podId);
            String macAddress = getMacAddress(dataCenterId, podId, clusterId, agentId);
            MockHostVO mockHost = new MockHostVO();
            mockHost.setDataCenterId(dataCenterId);
            mockHost.setPodId(podId);
            mockHost.setClusterId(clusterId);
            mockHost.setCapabilities("hvm");
            mockHost.setCpuCount(cpuCore);
            mockHost.setCpuSpeed(cpuSpeed);
            mockHost.setMemorySize(memory);
            String guid = UUID.randomUUID().toString();
            mockHost.setGuid(guid);
            mockHost.setName("SimulatedAgent." + guid);
            mockHost.setPrivateIpAddress(ipAddress);
            mockHost.setPublicIpAddress(ipAddress);
            mockHost.setStorageIpAddress(ipAddress);
            mockHost.setPrivateMacAddress(macAddress);
            mockHost.setPublicMacAddress(macAddress);
            mockHost.setStorageMacAddress(macAddress);
            mockHost.setVersion(this.getClass().getPackage().getImplementationVersion());
            mockHost.setResource("com.cloud.agent.AgentRoutingResource");

            Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
            try {
                txn.start();
                mockHost = _mockHostDao.persist(mockHost);
                txn.commit();
            } catch (Exception ex) {
                txn.rollback();
                s_logger.error("Error while configuring mock agent " + ex.getMessage());
                throw new CloudRuntimeException("Error configuring agent", ex);
            } finally {
                txn.close();
                txn = Transaction.open(Transaction.CLOUD_DB);
                txn.close();
            }

            _storageMgr.getLocalStorage(guid, localStorageSize);

            agentResource = new AgentRoutingResource();
            if (agentResource != null) {
                try {
                    params.put("guid", mockHost.getGuid());
                    agentResource.start();
                    agentResource.configure(mockHost.getName(), params);

                    newResources.put(agentResource, args);
                } catch (ConfigurationException e) {
                    s_logger.error("error while configuring server resource" + e.getMessage());
                }
View Full Code Here

                    txn.start();
                    MockHost host = _mockHostDao.findByVmId(this.vmId);
                    if (host != null) {
                        String guid = host.getGuid();
                        if (guid != null) {
                            AgentResourceBase res = _resources.get(guid);
                            if (res != null) {
                                res.stop();
                                _resources.remove(guid);
                            }
                        }
                    }
                    txn.commit();
View Full Code Here

  @DB
  public Map<AgentResourceBase, Map<String, String>> createServerResources(Map<String, Object> params) {

    Map<String, String> args = new HashMap<String, String>();
    Map<AgentResourceBase, Map<String, String>> newResources = new HashMap<AgentResourceBase, Map<String, String>>();
    AgentResourceBase agentResource;
    long cpuCore = Long.parseLong((String) params.get("cpucore"));
    long cpuSpeed = Long.parseLong((String) params.get("cpuspeed"));
    long memory = Long.parseLong((String) params.get("memory"));
    long localStorageSize = Long.parseLong((String) params.get("localstorage"));
    synchronized (this) {
      long dataCenterId = Long.parseLong((String) params.get("zone"));
      long podId = Long.parseLong((String) params.get("pod"));
      long clusterId = Long.parseLong((String) params.get("cluster"));
      long cidrSize = getPodCidr(podId, dataCenterId).second();

      int agentId = getNextAgentId(cidrSize);
      String ipAddress = getIpAddress(agentId, dataCenterId, podId);
      String macAddress = getMacAddress(dataCenterId, podId, clusterId, agentId);
      MockHostVO mockHost = new MockHostVO();
      mockHost.setDataCenterId(dataCenterId);
      mockHost.setPodId(podId);
      mockHost.setClusterId(clusterId);
      mockHost.setCapabilities("hvm");
      mockHost.setCpuCount(cpuCore);
      mockHost.setCpuSpeed(cpuSpeed);
      mockHost.setMemorySize(memory);
      String guid = UUID.randomUUID().toString();
      mockHost.setGuid(guid);
      mockHost.setName("SimulatedAgent." + guid);
      mockHost.setPrivateIpAddress(ipAddress);
      mockHost.setPublicIpAddress(ipAddress);
      mockHost.setStorageIpAddress(ipAddress);
      mockHost.setPrivateMacAddress(macAddress);
      mockHost.setPublicMacAddress(macAddress);
      mockHost.setStorageMacAddress(macAddress);
      mockHost.setVersion(this.getClass().getPackage().getImplementationVersion());
      mockHost.setResource("com.cloud.agent.AgentRoutingResource");

      Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
      try {
        txn.start();
        mockHost = _mockHostDao.persist(mockHost);
        txn.commit();
      } catch (Exception ex) {
        txn.rollback();
        s_logger.error("Error while configuring mock agent " + ex.getMessage());
        throw new CloudRuntimeException("Error configuring agent", ex);
      } finally {
        txn.close();
                txn = Transaction.open(Transaction.CLOUD_DB);
                txn.close();
      }

      _storageMgr.getLocalStorage(guid, localStorageSize);

      agentResource = new AgentRoutingResource();
      if (agentResource != null) {
        try {
          params.put("guid", mockHost.getGuid());
          agentResource.start();
          agentResource.configure(mockHost.getName(), params);

          newResources.put(agentResource, args);
        } catch (ConfigurationException e) {
          s_logger.error("error while configuring server resource" + e.getMessage());
        }
View Full Code Here

          txn.start();
          MockHost host = _mockHostDao.findByVmId(this.vmId);
          if (host != null) {
            String guid = host.getGuid();
            if (guid != null) {
              AgentResourceBase res = _resources.get(guid);
              if (res != null) {
                res.stop();
                _resources.remove(guid);
              }
            }
          }
          txn.commit();
View Full Code Here

    @DB
    public Map<AgentResourceBase, Map<String, String>> createServerResources(Map<String, Object> params) {

        Map<String, String> args = new HashMap<String, String>();
        Map<AgentResourceBase, Map<String, String>> newResources = new HashMap<AgentResourceBase, Map<String, String>>();
        AgentResourceBase agentResource;
        long cpuCore = Long.parseLong((String) params.get("cpucore"));
        long cpuSpeed = Long.parseLong((String) params.get("cpuspeed"));
        long memory = Long.parseLong((String) params.get("memory"));
        long localStorageSize = Long.parseLong((String) params.get("localstorage"));
        synchronized (this) {
            long dataCenterId = Long.parseLong((String) params.get("zone"));
            long podId = Long.parseLong((String) params.get("pod"));
            long clusterId = Long.parseLong((String) params.get("cluster"));
            long cidrSize = getPodCidr(podId, dataCenterId).second();

            int agentId = getNextAgentId(cidrSize);
            String ipAddress = getIpAddress(agentId, dataCenterId, podId);
            String macAddress = getMacAddress(dataCenterId, podId, clusterId, agentId);
            MockHostVO mockHost = new MockHostVO();
            mockHost.setDataCenterId(dataCenterId);
            mockHost.setPodId(podId);
            mockHost.setClusterId(clusterId);
            mockHost.setCapabilities("hvm");
            mockHost.setCpuCount(cpuCore);
            mockHost.setCpuSpeed(cpuSpeed);
            mockHost.setMemorySize(memory);
            String guid = UUID.randomUUID().toString();
            mockHost.setGuid(guid);
            mockHost.setName("SimulatedAgent." + guid);
            mockHost.setPrivateIpAddress(ipAddress);
            mockHost.setPublicIpAddress(ipAddress);
            mockHost.setStorageIpAddress(ipAddress);
            mockHost.setPrivateMacAddress(macAddress);
            mockHost.setPublicMacAddress(macAddress);
            mockHost.setStorageMacAddress(macAddress);
            mockHost.setVersion(this.getClass().getPackage().getImplementationVersion());
            mockHost.setResource("com.cloud.agent.AgentRoutingResource");

            TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
            try {
                txn.start();
                mockHost = _mockHostDao.persist(mockHost);
                txn.commit();
            } catch (Exception ex) {
                txn.rollback();
                s_logger.error("Error while configuring mock agent " + ex.getMessage());
                throw new CloudRuntimeException("Error configuring agent", ex);
            } finally {
                txn.close();
                txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
                txn.close();
            }

            _storageMgr.getLocalStorage(guid, localStorageSize);

            agentResource = new AgentRoutingResource();
            if (agentResource != null) {
                try {
                    params.put("guid", mockHost.getGuid());
                    agentResource.start();
                    agentResource.configure(mockHost.getName(), params);

                    newResources.put(agentResource, args);
                } catch (ConfigurationException e) {
                    s_logger.error("error while configuring server resource" + e.getMessage());
                }
View Full Code Here

                    txn.start();
                    MockHost host = _mockHostDao.findByVmId(this.vmId);
                    if (host != null) {
                        String guid = host.getGuid();
                        if (guid != null) {
                            AgentResourceBase res = _resources.get(guid);
                            if (res != null) {
                                res.stop();
                                _resources.remove(guid);
                            }
                        }
                    }
                    txn.commit();
View Full Code Here

TOP

Related Classes of com.cloud.resource.AgentResourceBase

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.