Package com.cloud.simulator

Examples of com.cloud.simulator.MockHostVO


            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


            String resource = null;
            if (vmType.equalsIgnoreCase("secstorage")) {
                resource = "com.cloud.agent.AgentStorageResource";
            }
            MockHostVO mockHost = new MockHostVO();
            mockHost.setDataCenterId(this.dcId);
            mockHost.setPodId(this.podId);
            mockHost.setCpuCount(DEFAULT_HOST_CPU_CORES);
            mockHost.setCpuSpeed(DEFAULT_HOST_SPEED_MHZ);
            mockHost.setMemorySize(DEFAULT_HOST_MEM_SIZE);
            mockHost.setGuid(this.guid);
            mockHost.setName(name);
            mockHost.setPrivateIpAddress(this.privateIpAddress);
            mockHost.setPublicIpAddress(this.privateIpAddress);
            mockHost.setStorageIpAddress(this.privateIpAddress);
            mockHost.setPrivateMacAddress(this.privateMacAddress);
            mockHost.setPublicMacAddress(this.privateMacAddress);
            mockHost.setStorageMacAddress(this.privateMacAddress);
            mockHost.setVersion(this.getClass().getPackage().getImplementationVersion());
            mockHost.setResource(resource);
            mockHost.setVmId(vmId);
            Transaction simtxn = Transaction.open(Transaction.SIMULATOR_DB);
            try {
                simtxn.start();
                mockHost = _mockHostDao.persist(mockHost);
                simtxn.commit();
            } catch (Exception ex) {
                simtxn.rollback();
                throw new CloudRuntimeException("Unable to persist host " + mockHost.getGuid() + " due to "
                        + ex.getMessage(), ex);
            } finally {
                simtxn.close();
                simtxn = Transaction.open(Transaction.CLOUD_DB);
                simtxn.close();
View Full Code Here

            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

            String resource = null;
            if (vmType.equalsIgnoreCase("secstorage")) {
                resource = "com.cloud.agent.AgentStorageResource";
            }
            MockHostVO mockHost = new MockHostVO();
            mockHost.setDataCenterId(this.dcId);
            mockHost.setPodId(this.podId);
            mockHost.setCpuCount(DEFAULT_HOST_CPU_CORES);
            mockHost.setCpuSpeed(DEFAULT_HOST_SPEED_MHZ);
            mockHost.setMemorySize(DEFAULT_HOST_MEM_SIZE);
            mockHost.setGuid(this.guid);
            mockHost.setName(name);
            mockHost.setPrivateIpAddress(this.privateIpAddress);
            mockHost.setPublicIpAddress(this.privateIpAddress);
            mockHost.setStorageIpAddress(this.privateIpAddress);
            mockHost.setPrivateMacAddress(this.privateMacAddress);
            mockHost.setPublicMacAddress(this.privateMacAddress);
            mockHost.setStorageMacAddress(this.privateMacAddress);
            mockHost.setVersion(this.getClass().getPackage().getImplementationVersion());
            mockHost.setResource(resource);
            mockHost.setVmId(vmId);
            TransactionLegacy simtxn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
            try {
                simtxn.start();
                mockHost = _mockHostDao.persist(mockHost);
                simtxn.commit();
            } catch (Exception ex) {
                simtxn.rollback();
                throw new CloudRuntimeException("Unable to persist host " + mockHost.getGuid() + " due to " + ex.getMessage(), ex);
            } finally {
                simtxn.close();
                simtxn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
                simtxn.close();
            }
View Full Code Here

            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

            String resource = null;
            if (vmType.equalsIgnoreCase("secstorage")) {
                resource = "com.cloud.agent.AgentStorageResource";
            }
            MockHostVO mockHost = new MockHostVO();
            mockHost.setDataCenterId(this.dcId);
            mockHost.setPodId(this.podId);
            mockHost.setCpuCount(DEFAULT_HOST_CPU_CORES);
            mockHost.setCpuSpeed(DEFAULT_HOST_SPEED_MHZ);
            mockHost.setMemorySize(DEFAULT_HOST_MEM_SIZE);
            mockHost.setGuid(this.guid);
            mockHost.setName(name);
            mockHost.setPrivateIpAddress(this.privateIpAddress);
            mockHost.setPublicIpAddress(this.privateIpAddress);
            mockHost.setStorageIpAddress(this.privateIpAddress);
            mockHost.setPrivateMacAddress(this.privateMacAddress);
            mockHost.setPublicMacAddress(this.privateMacAddress);
            mockHost.setStorageMacAddress(this.privateMacAddress);
            mockHost.setVersion(this.getClass().getPackage().getImplementationVersion());
            mockHost.setResource(resource);
            mockHost.setVmId(vmId);
            Transaction simtxn = Transaction.open(Transaction.SIMULATOR_DB);
            try {
                simtxn.start();
                mockHost = _mockHostDao.persist(mockHost);
                simtxn.commit();
            } catch (Exception ex) {
                simtxn.rollback();
                throw new CloudRuntimeException("Unable to persist host " + mockHost.getGuid() + " due to "
                        + ex.getMessage(), ex);
            } finally {
                simtxn.close();
                simtxn = Transaction.open(Transaction.CLOUD_DB);
                simtxn.close();
            }

            if (vmType.equalsIgnoreCase("secstorage")) {
                AgentStorageResource storageResource = new AgentStorageResource();
                try {
                    Map<String, Object> params = new HashMap<String, Object>();
                    Map<String, String> details = new HashMap<String, String>();
                    params.put("guid", this.guid);
                    details.put("guid", this.guid);
                    storageResource.configure("secondaryStorage", params);
                    storageResource.start();
                    // on the simulator the ssvm is as good as a direct
                    // agent
                    _resourceMgr.addHost(mockHost.getDataCenterId(), storageResource, Host.Type.SecondaryStorageVM,
                            details);
                    _resources.put(this.guid, storageResource);
                } catch (ConfigurationException e) {
                    s_logger.debug("Failed to load secondary storage resource: " + e.toString());
                    return;
View Full Code Here

      String resource = null;
      if (vmType.equalsIgnoreCase("secstorage")) {
        resource = "com.cloud.agent.AgentStorageResource";
      }
      MockHostVO mockHost = new MockHostVO();
      mockHost.setDataCenterId(this.dcId);
      mockHost.setPodId(this.podId);
      mockHost.setCpuCount(DEFAULT_HOST_CPU_CORES);
      mockHost.setCpuSpeed(DEFAULT_HOST_SPEED_MHZ);
      mockHost.setMemorySize(DEFAULT_HOST_MEM_SIZE);
      mockHost.setGuid(this.guid);
      mockHost.setName(name);
      mockHost.setPrivateIpAddress(this.privateIpAddress);
      mockHost.setPublicIpAddress(this.privateIpAddress);
      mockHost.setStorageIpAddress(this.privateIpAddress);
      mockHost.setPrivateMacAddress(this.privateMacAddress);
      mockHost.setPublicMacAddress(this.privateMacAddress);
      mockHost.setStorageMacAddress(this.privateMacAddress);
      mockHost.setVersion(this.getClass().getPackage().getImplementationVersion());
      mockHost.setResource(resource);
      mockHost.setVmId(vmId);
      Transaction simtxn = Transaction.open(Transaction.SIMULATOR_DB);
      try {
        simtxn.start();
        mockHost = _mockHostDao.persist(mockHost);
        simtxn.commit();
      } catch (Exception ex) {
        simtxn.rollback();
        throw new CloudRuntimeException("Unable to persist host " + mockHost.getGuid() + " due to "
            + ex.getMessage(), ex);
      } finally {
        simtxn.close();
                simtxn = Transaction.open(Transaction.CLOUD_DB);
                simtxn.close();
      }

      if (vmType.equalsIgnoreCase("secstorage")) {
        AgentStorageResource storageResource = new AgentStorageResource();
        try {
          Map<String, Object> params = new HashMap<String, Object>();
          Map<String, String> details = new HashMap<String, String>();
          params.put("guid", this.guid);
          details.put("guid", this.guid);
          storageResource.configure("secondaryStorage", params);
          storageResource.start();
          // on the simulator the ssvm is as good as a direct
          // agent
          _resourceMgr.addHost(mockHost.getDataCenterId(), storageResource, Host.Type.SecondaryStorageVM,
              details);
          _resources.put(this.guid, storageResource);
        } catch (ConfigurationException e) {
          s_logger.debug("Failed to load secondary storage resource: " + e.toString());
          return;
View Full Code Here

      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

            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

            String resource = null;
            if (vmType.equalsIgnoreCase("secstorage")) {
                resource = "com.cloud.agent.AgentStorageResource";
            }
            MockHostVO mockHost = new MockHostVO();
            mockHost.setDataCenterId(this.dcId);
            mockHost.setPodId(this.podId);
            mockHost.setCpuCount(DEFAULT_HOST_CPU_CORES);
            mockHost.setCpuSpeed(DEFAULT_HOST_SPEED_MHZ);
            mockHost.setMemorySize(DEFAULT_HOST_MEM_SIZE);
            mockHost.setGuid(this.guid);
            mockHost.setName(name);
            mockHost.setPrivateIpAddress(this.privateIpAddress);
            mockHost.setPublicIpAddress(this.privateIpAddress);
            mockHost.setStorageIpAddress(this.privateIpAddress);
            mockHost.setPrivateMacAddress(this.privateMacAddress);
            mockHost.setPublicMacAddress(this.privateMacAddress);
            mockHost.setStorageMacAddress(this.privateMacAddress);
            mockHost.setVersion(this.getClass().getPackage().getImplementationVersion());
            mockHost.setResource(resource);
            mockHost.setVmId(vmId);
            TransactionLegacy simtxn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
            try {
                simtxn.start();
                mockHost = _mockHostDao.persist(mockHost);
                simtxn.commit();
            } catch (Exception ex) {
                simtxn.rollback();
                throw new CloudRuntimeException("Unable to persist host " + mockHost.getGuid() + " due to "
                        + ex.getMessage(), ex);
            } finally {
                simtxn.close();
                simtxn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
                simtxn.close();
View Full Code Here

TOP

Related Classes of com.cloud.simulator.MockHostVO

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.