Package com.cloud.vm

Examples of com.cloud.vm.SecondaryStorageVmVO


        }
    }

    @Override
    public boolean rebootSecStorageVm(long secStorageVmId) {
        final SecondaryStorageVmVO secStorageVm = _secStorageVmDao.findById(secStorageVmId);

        if (secStorageVm == null || secStorageVm.getState() == State.Destroyed) {
            return false;
        }

        if (secStorageVm.getState() == State.Running && secStorageVm.getHostId() != null) {
            final RebootCommand cmd = new RebootCommand(secStorageVm.getInstanceName());
            final Answer answer = _agentMgr.easySend(secStorageVm.getHostId(), cmd);

            if (answer != null && answer.getResult()) {
                if (s_logger.isDebugEnabled()) {
                    s_logger.debug("Successfully reboot secondary storage vm " + secStorageVm.getHostName());
                }

                SubscriptionMgr.getInstance().notifySubscribers(ALERT_SUBJECT, this,
                        new SecStorageVmAlertEventArgs(SecStorageVmAlertEventArgs.SSVM_REBOOTED, secStorageVm.getDataCenterId(), secStorageVm.getId(), secStorageVm, null));

                return true;
            } else {
                String msg = "Rebooting Secondary Storage VM failed - " + secStorageVm.getHostName();
                if (s_logger.isDebugEnabled()) {
                    s_logger.debug(msg);
                }
                return false;
            }
View Full Code Here


    public void onSSVMAlert(Object sender, SecStorageVmAlertEventArgs args) {
      if(s_logger.isDebugEnabled())
        s_logger.debug("received secondary storage vm alert");
     
      DataCenterVO dc = _dcDao.findById(args.getZoneId());
       SecondaryStorageVmVO secStorageVm = args.getSecStorageVm();
      if(secStorageVm == null)
        secStorageVm = _ssvmDao.findById(args.getSecStorageVmId());
     
      switch(args.getType()) {
      case SecStorageVmAlertEventArgs.SSVM_CREATED :
          if(s_logger.isDebugEnabled())
            s_logger.debug("New secondary storage vm created, zone: " + dc.getName() + ", secStorageVm: " +
              secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress() + ", private IP: " +
              secStorageVm.getPrivateIpAddress());
      break;
       
      case SecStorageVmAlertEventArgs.SSVM_UP :
          if(s_logger.isDebugEnabled())
            s_logger.debug("Secondary Storage Vm is up, zone: " + dc.getName() + ", secStorageVm: " +
              secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress() + ", private IP: " +
              secStorageVm.getPrivateIpAddress());
       
      _alertMgr.sendAlert(
        AlertManager.ALERT_TYPE_SSVM,
        args.getZoneId(),
        secStorageVm.getPodIdToDeployIn(),
        "Secondary Storage Vm up in zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress()
           + ", private IP: " + (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()),
         "Secondary Storage Vm up (zone " + dc.getName() + ")"  
      );
      break;
       
      case SecStorageVmAlertEventArgs.SSVM_DOWN :
          if(s_logger.isDebugEnabled())
            s_logger.debug("Secondary Storage Vm is down, zone: " + dc.getName() + ", secStorageVm: " +
              secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress() + ", private IP: " +
              (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()));
       
      _alertMgr.sendAlert(
        AlertManager.ALERT_TYPE_SSVM,
        args.getZoneId(),
        secStorageVm.getPodIdToDeployIn(),
        "Secondary Storage Vm down in zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress()
           + ", private IP: " + (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()),
         "Secondary Storage Vm down (zone " + dc.getName() + ")"  
      );
      break;
       
      case SecStorageVmAlertEventArgs.SSVM_REBOOTED :
          if(s_logger.isDebugEnabled())
            s_logger.debug("Secondary Storage Vm is rebooted, zone: " + dc.getName() + ", secStorageVm: " +
              secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress() + ", private IP: " +
              (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()));
       
      _alertMgr.sendAlert(
        AlertManager.ALERT_TYPE_SSVM,
        args.getZoneId(),
        secStorageVm.getPodIdToDeployIn(),
        "Secondary Storage Vm rebooted in zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress()
           + ", private IP: " + (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()),
         "Secondary Storage Vm rebooted (zone " + dc.getName() + ")"  
      );
      break;
     
      case SecStorageVmAlertEventArgs.SSVM_CREATE_FAILURE :
          if(s_logger.isDebugEnabled())
            s_logger.debug("Secondary Storage Vm creation failure, zone: " + dc.getName() + ", secStorageVm: " +
              secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress() + ", private IP: " +
              (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()));
       
      _alertMgr.sendAlert(
        AlertManager.ALERT_TYPE_SSVM,
        args.getZoneId(),
        secStorageVm.getPodIdToDeployIn(),
        "Secondary Storage Vm creation failure. zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress()
           + ", private IP: " + (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress())
           + ", error details: " + args.getMessage(),
         "Secondary Storage Vm creation failure (zone " + dc.getName() + ")"
      );
        break;
       
      case SecStorageVmAlertEventArgs.SSVM_START_FAILURE :
          if(s_logger.isDebugEnabled())
            s_logger.debug("Secondary Storage Vm startup failure, zone: " + dc.getName() + ", secStorageVm: " +
              secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress() + ", private IP: " +
              (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()));
       
      _alertMgr.sendAlert(
        AlertManager.ALERT_TYPE_SSVM,
        args.getZoneId(),
        secStorageVm.getPodIdToDeployIn(),
        "Secondary Storage Vm startup failure. zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress()
           + ", private IP: " + (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress())
           + ", error details: " + args.getMessage(),
         "Secondary Storage Vm startup failure (zone " + dc.getName() + ")"  
      );
        break;
     
      case SecStorageVmAlertEventArgs.SSVM_FIREWALL_ALERT :
          if(s_logger.isDebugEnabled())
            s_logger.debug("Secondary Storage Vm firewall alert, zone: " + dc.getName() + ", secStorageVm: " +
              secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress() + ", private IP: " +
              (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()));
       
      _alertMgr.sendAlert(
        AlertManager.ALERT_TYPE_SSVM,
        args.getZoneId(),
        secStorageVm.getPodIdToDeployIn(),
        "Failed to open secondary storage vm firewall port. zone: " + dc.getName() + ", secStorageVm: " + secStorageVm.getHostName()
          + ", public IP: " + secStorageVm.getPublicIpAddress()
          + ", private IP: " + (secStorageVm.getPrivateIpAddress() == null ? "N/A" : secStorageVm.getPrivateIpAddress()),
        "Secondary Storage Vm alert (zone " + dc.getName() + ")" 
      );
        break;
     
      case SecStorageVmAlertEventArgs.SSVM_STORAGE_ALERT :
          if(s_logger.isDebugEnabled())
            s_logger.debug("Secondary Storage Vm storage alert, zone: " + dc.getName() + ", secStorageVm: " +
              secStorageVm.getHostName() + ", public IP: " + secStorageVm.getPublicIpAddress() + ", private IP: " +
              secStorageVm.getPrivateIpAddress() + ", message: " + args.getMessage());
       
      _alertMgr.sendAlert(
        AlertManager.ALERT_TYPE_STORAGE_MISC,
        args.getZoneId(),
        secStorageVm.getPodIdToDeployIn(),
        "Secondary Storage Vm storage issue. zone: " + dc.getName() + ", message: " + args.getMessage(),
        "Secondary Storage Vm alert (zone " + dc.getName() + ")"
      );
        break;
      }
View Full Code Here

  public Pair<HostVO, SecondaryStorageVmVO> assignSecStorageVm(long zoneId, Command cmd) {
   
    // TODO, need performance optimization
    List<Long> vms = _secStorageVmDao.listRunningSecStorageOrderByLoad(null, zoneId);
    for(Long vmId : vms) {
      SecondaryStorageVmVO secStorageVm = _secStorageVmDao.findById(vmId);
      HostVO host;
      host = _resourceMgr.findHostByName(secStorageVm.getHostName());
      if(host != null && host.getStatus() == Status.Up)
        return new Pair<HostVO, SecondaryStorageVmVO>(host, secStorageVm);
    }
   
    return null;
View Full Code Here

        }
    }

    @Override
    public boolean destroySecStorageVm(long vmId) {
        SecondaryStorageVmVO ssvm = _secStorageVmDao.findById(vmId);

        try {
            boolean result = _itMgr.expunge(ssvm, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
            if (result) {
                HostVO host = _hostDao.findByTypeNameAndZoneId(ssvm.getDataCenterId(), ssvm.getHostName(),
                        Host.Type.SecondaryStorageVM);
                if (host != null) {
                    s_logger.debug("Removing host entry for ssvm id=" + vmId);
                    result = result && _hostDao.remove(host.getId());
                }
View Full Code Here

    }

    @Override
    public boolean finalizeVirtualMachineProfile(VirtualMachineProfile<SecondaryStorageVmVO> profile, DeployDestination dest, ReservationContext context) {

        SecondaryStorageVmVO vm = profile.getVirtualMachine();
        Map<String, String> details = _vmDetailsDao.findDetails(vm.getId());
        vm.setDetails(details);

        DataStore secStore = this._dataStoreMgr.getImageStore(dest.getDataCenter().getId());
        assert (secStore != null);

        StringBuilder buf = profile.getBootArgsBuilder();
View Full Code Here

    @Override
    public boolean finalizeDeployment(Commands cmds, VirtualMachineProfile<SecondaryStorageVmVO> profile, DeployDestination dest, ReservationContext context) {

        finalizeCommandsOnStart(cmds, profile);

        SecondaryStorageVmVO secVm = profile.getVirtualMachine();
        DataCenter dc = dest.getDataCenter();
        List<NicProfile> nics = profile.getNics();
        for (NicProfile nic : nics) {
            if ((nic.getTrafficType() == TrafficType.Public && dc.getNetworkType() == NetworkType.Advanced)
                    || (nic.getTrafficType() == TrafficType.Guest && (dc.getNetworkType() == NetworkType.Basic || dc.isSecurityGroupEnabled()))) {
                secVm.setPublicIpAddress(nic.getIp4Address());
                secVm.setPublicNetmask(nic.getNetmask());
                secVm.setPublicMacAddress(nic.getMacAddress());
            } else if (nic.getTrafficType() == TrafficType.Management) {
                secVm.setPrivateIpAddress(nic.getIp4Address());
                secVm.setPrivateMacAddress(nic.getMacAddress());
            }
        }
        _secStorageVmDao.update(secVm.getId(), secVm);
        return true;
    }
View Full Code Here

        try {
            //get system ip and create static nat rule for the vm in case of basic networking with EIP/ELB
            _rulesMgr.getSystemIpAndEnableStaticNatForVm(profile.getVirtualMachine(), false);
            IPAddressVO ipaddr = _ipAddressDao.findByAssociatedVmId(profile.getVirtualMachine().getId());
            if (ipaddr != null && ipaddr.getSystem()) {
                SecondaryStorageVmVO secVm = profile.getVirtualMachine();
                // override SSVM guest IP with EIP, so that download url's with be prepared with EIP
                secVm.setPublicIpAddress(ipaddr.getAddress().addr());
                _secStorageVmDao.update(secVm.getId(), secVm);
            }
        } catch (Exception ex) {
            s_logger.warn("Failed to get system ip and enable static nat for the vm " + profile.getVirtualMachine() + " due to exception ", ex);
            return false;
        }
View Full Code Here

        return _secStorageVmDao.findById(instanceId);
    }

    @ActionEvent(eventType = EventTypes.EVENT_SSVM_DESTROY, eventDescription = "destroying secondary storage Vm", async = true)
    public SecondaryStorageVmVO destroySecondaryStorageVm(long instanceId) {
        SecondaryStorageVmVO secStorageVm = _secStorageVmDao.findById(instanceId);
        if (_secStorageVmMgr.destroySecStorageVm(instanceId)) {
            return secStorageVm;
        }
        return null;
    }
View Full Code Here

                throw new CloudRuntimeException(errorString);
            }

            List<SecondaryStorageVmVO> ssVms = _secStorageVmDao.getSecStorageVmListInStates(SecondaryStorageVm.Role.templateProcessor, dataCenterId, State.Running);
          if (ssVms.size() > 0) {
                SecondaryStorageVmVO ssVm = ssVms.get(0);
                if (ssVm.getPublicIpAddress() == null) {
                    errorString = "A running secondary storage vm has a null public ip?";
                    s_logger.error(errorString);
                    throw new CloudRuntimeException(errorString);
                }
                //Construct actual URL locally now that the symlink exists at SSVM
                String extractURL = generateCopyUrl(ssVm.getPublicIpAddress(), uuid);
                UploadVO vo = _uploadDao.createForUpdate();
                vo.setLastUpdated(new Date());
                vo.setUploadUrl(extractURL);
                vo.setUploadState(Status.DOWNLOAD_URL_CREATED);
                _uploadDao.update(uploadId, vo);
View Full Code Here

   
    @Override
    public boolean remove(Long id) {
        Transaction txn = Transaction.currentTxn();
        txn.start();
        SecondaryStorageVmVO proxy = createForUpdate();
        proxy.setPublicIpAddress(null);
        proxy.setPrivateIpAddress(null);
       
        UpdateBuilder ub = getUpdateBuilder(proxy);
        ub.set(proxy, "state", State.Destroyed);
        ub.set(proxy, "privateIpAddress", null);
        update(id, ub, proxy);
View Full Code Here

TOP

Related Classes of com.cloud.vm.SecondaryStorageVmVO

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.