diff --git a/api/src/com/cloud/event/EventTypes.java b/api/src/com/cloud/event/EventTypes.java index 3a1d58a66a6..7477152b706 100755 --- a/api/src/com/cloud/event/EventTypes.java +++ b/api/src/com/cloud/event/EventTypes.java @@ -454,7 +454,6 @@ public class EventTypes { public static final String EVENT_BAREMETAL_PXE_SERVER_ADD = "PHYSICAL.PXE.ADD"; public static final String EVENT_BAREMETAL_PXE_SERVER_DELETE = "PHYSICAL.PXE.DELETE"; public static final String EVENT_BAREMETAL_RCT_ADD = "BAREMETAL.RCT.ADD"; - public static final String EVENT_BAREMETAL_PROVISION_DONE = "BAREMETAL.PROVISION.DONE"; public static final String EVENT_AFFINITY_GROUP_CREATE = "AG.CREATE"; public static final String EVENT_AFFINITY_GROUP_DELETE = "AG.DELETE"; diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManager.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManager.java index 629153a2b38..5db29d2fd69 100755 --- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManager.java +++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManager.java @@ -20,12 +20,9 @@ package com.cloud.baremetal.manager; import com.cloud.utils.component.Manager; import com.cloud.utils.component.PluggableService; -import org.apache.cloudstack.api.BaremetalProvisionDoneNotificationCmd; public interface BaremetalManager extends Manager, PluggableService { public static final String EchoSecurityGroupAgent = "EchoSecurityGroupAgent"; public static final String ExternalBaremetalSystemUrl = "ExternalBaremetalSystemUrl"; public static final String DO_PXE = "doPxe"; - - void notifyProvisionDone(BaremetalProvisionDoneNotificationCmd cmd); } diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManagerImpl.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManagerImpl.java index d4a75dc7732..f6a41133e3a 100755 --- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManagerImpl.java +++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManagerImpl.java @@ -26,12 +26,6 @@ import javax.ejb.Local; import javax.inject.Inject; import javax.naming.ConfigurationException; -import com.cloud.utils.db.QueryBuilder; -import com.cloud.utils.db.SearchCriteria; -import com.cloud.utils.exception.CloudRuntimeException; -import com.cloud.vm.VMInstanceVO; -import com.cloud.vm.dao.VMInstanceDao; -import org.apache.cloudstack.api.BaremetalProvisionDoneNotificationCmd; import org.apache.log4j.Logger; import org.apache.cloudstack.api.AddBaremetalHostCmd; @@ -51,8 +45,6 @@ public class BaremetalManagerImpl extends ManagerBase implements BaremetalManage @Inject protected HostDao _hostDao; - @Inject - protected VMInstanceDao vmDao; @Override public boolean configure(String name, Map params) throws ConfigurationException { @@ -115,40 +107,6 @@ public class BaremetalManagerImpl extends ManagerBase implements BaremetalManage public List> getCommands() { List> cmds = new ArrayList>(); cmds.add(AddBaremetalHostCmd.class); - cmds.add(BaremetalProvisionDoneNotificationCmd.class); return cmds; } - - @Override - public void notifyProvisionDone(BaremetalProvisionDoneNotificationCmd cmd) { - QueryBuilder hq = QueryBuilder.create(HostVO.class); - hq.and(hq.entity().getPrivateMacAddress(), SearchCriteria.Op.EQ, cmd.getMac()); - HostVO host = hq.find(); - if (host == null) { - throw new CloudRuntimeException(String.format("cannot find host[mac:%s]", cmd.getMac())); - } - - _hostDao.loadDetails(host); - String vmName = host.getDetail("vmName"); - if (vmName == null) { - throw new CloudRuntimeException(String.format("cannot find any baremetal instance running on host[mac:%s]", cmd.getMac())); - } - - QueryBuilder vmq = QueryBuilder.create(VMInstanceVO.class); - vmq.and(vmq.entity().getInstanceName(), SearchCriteria.Op.EQ, vmName); - VMInstanceVO vm = vmq.find(); - - if (vm == null) { - throw new CloudRuntimeException(String.format("cannot find baremetal instance[name:%s]", vmName)); - } - - if (State.Starting != vm.getState()) { - throw new CloudRuntimeException(String.format("baremetal instance[name:%s, state:%s] is not in state of Starting", vmName, vm.getState())); - } - - vm.setState(State.Running); - vmDao.update(vm.getId(), vm); - s_logger.debug(String.format("received baremetal provision done notification for vm[id:%s name:%s] running on host[mac:%s, ip:%s]", - vm.getId(), vm.getInstanceName(), host.getPrivateMacAddress(), host.getPrivateIpAddress())); - } } diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java index 6a54527a860..fedfb8bd9f6 100755 --- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java +++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java @@ -61,15 +61,12 @@ import com.cloud.hypervisor.Hypervisor; import com.cloud.resource.ServerResource; import com.cloud.utils.Pair; import com.cloud.utils.component.ManagerBase; -import com.cloud.utils.db.QueryBuilder; -import com.cloud.utils.db.SearchCriteria; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.script.OutputInterpreter; import com.cloud.utils.script.Script; import com.cloud.utils.script.Script2; import com.cloud.utils.script.Script2.ParamType; import com.cloud.vm.VMInstanceVO; -import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachine.PowerState; import com.cloud.vm.dao.VMInstanceDao; import org.apache.cloudstack.api.ApiConstants; @@ -112,8 +109,6 @@ public class BareMetalResourceBase extends ManagerBase implements ServerResource protected Script2 _bootOrRebootCommand; protected String _vmName; protected int ipmiRetryTimes = 5; - protected boolean provisionDoneNotificationOn = false; - protected int isProvisionDoneNotificationTimeout = 1800; protected ConfigurationDao configDao; protected VMInstanceDao vmDao; @@ -188,13 +183,6 @@ public class BareMetalResourceBase extends ManagerBase implements ServerResource s_logger.debug(e.getMessage(), e); } - try { - provisionDoneNotificationOn = Boolean.valueOf(configDao.getValue(Config.BaremetalProvisionDoneNotificationEnabled.key())); - isProvisionDoneNotificationTimeout = Integer.valueOf(configDao.getValue(Config.BaremetalProvisionDoneNotificationTimeout.key())); - } catch (Exception e) { - s_logger.debug(e.getMessage(), e); - } - String injectScript = "scripts/util/ipmi.py"; String scriptPath = Script.findScript("", injectScript); if (scriptPath == null) { @@ -591,39 +579,6 @@ public class BareMetalResourceBase extends ManagerBase implements ServerResource } } - if (provisionDoneNotificationOn) { - QueryBuilder q = QueryBuilder.create(VMInstanceVO.class); - q.and(q.entity().getInstanceName(), SearchCriteria.Op.EQ, vm.getName()); - VMInstanceVO vmvo = q.find(); - - if (vmvo.getLastHostId() == null) { - // this is new created vm - long timeout = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(isProvisionDoneNotificationTimeout); - while (timeout > System.currentTimeMillis()) { - try { - TimeUnit.SECONDS.sleep(5); - } catch (InterruptedException e) { - s_logger.warn(e.getMessage(), e); - } - - q = QueryBuilder.create(VMInstanceVO.class); - q.and(q.entity().getInstanceName(), SearchCriteria.Op.EQ, vm.getName()); - vmvo = q.find(); - if (vmvo == null) { - return new StartAnswer(cmd, String.format("cannot find vm[name:%s] while waiting for baremtal provision done notification", vm.getName())); - } - - if (VirtualMachine.State.Running == vmvo.getState()) { - return new StartAnswer(cmd); - } - - s_logger.debug(String.format("still wait for baremetal provision done notification for vm[name:%s], current vm state is %s", vmvo.getInstanceName(), vmvo.getState())); - } - - return new StartAnswer(cmd, String.format("timeout after %s seconds, no baremetal provision done notification received. vm[name:%s] failed to start", isProvisionDoneNotificationTimeout, vm.getName())); - } - } - s_logger.debug("Start bare metal vm " + vm.getName() + "successfully"); _vmName = vm.getName(); return new StartAnswer(cmd); diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java index 58a05088f25..bd363f698aa 100755 --- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java +++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java @@ -30,7 +30,6 @@ import java.util.Map; import javax.ejb.Local; import javax.inject.Inject; -import com.cloud.configuration.Config; import org.apache.log4j.Logger; import org.apache.cloudstack.api.AddBaremetalKickStartPxeCmd; @@ -219,11 +218,6 @@ public class BaremetalKickStartServiceImpl extends BareMetalPxeServiceBase imple throw new CloudRuntimeException(String.format("cannot find management nic on virtual router[id:%s]", vr.getId())); } - String internalServerIp = _configDao.getValue(Config.BaremetalInternalStorageServer.key()); - if (internalServerIp == null) { - throw new CloudRuntimeException(String.format("please specify 'baremetal.internal.storage.server.ip', which is the http server/nfs server storing kickstart files and ISO files, in global setting")); - } - List tuple = parseKickstartUrl(profile); Pair ret = SshHelper.sshExecute(mgmtNic.getIp4Address(), 3922, "root", getSystemVMKeyFile(), null, String.format("/usr/bin/prepare_pxe.sh %s %s %s %s %s", tuple.get(1), tuple.get(2), profile.getTemplate().getUuid(), diff --git a/plugins/hypervisors/baremetal/src/org/apache/cloudstack/api/BaremetalProvisionDoneNotificationCmd.java b/plugins/hypervisors/baremetal/src/org/apache/cloudstack/api/BaremetalProvisionDoneNotificationCmd.java deleted file mode 100755 index 9cb4b57bbaf..00000000000 --- a/plugins/hypervisors/baremetal/src/org/apache/cloudstack/api/BaremetalProvisionDoneNotificationCmd.java +++ /dev/null @@ -1,87 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// -package org.apache.cloudstack.api; - -import com.cloud.baremetal.manager.BaremetalManager; -import com.cloud.event.EventTypes; -import com.cloud.exception.ConcurrentOperationException; -import com.cloud.exception.InsufficientCapacityException; -import com.cloud.exception.NetworkRuleConflictException; -import com.cloud.exception.ResourceAllocationException; -import com.cloud.exception.ResourceUnavailableException; -import org.apache.cloudstack.acl.RoleType; -import org.apache.cloudstack.api.response.SuccessResponse; -import org.apache.cloudstack.context.CallContext; - -import javax.inject.Inject; -import org.apache.log4j.Logger; - -/** - * Created by frank on 9/17/14. - */ -@APICommand(name = "notifyBaremetalProvisionDone", description = "Notify provision has been done on a host. This api is for baremetal virtual router service, not for end user", responseObject = SuccessResponse.class, - requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, authorized = {RoleType.User}) -public class BaremetalProvisionDoneNotificationCmd extends BaseAsyncCmd { - public static final Logger s_logger = Logger.getLogger(BaremetalProvisionDoneNotificationCmd.class); - private static final String s_name = "baremetalprovisiondone"; - - @Inject - private BaremetalManager bmMgr; - - @Parameter(name="mac", required = true, description = "mac of the nic used for provision") - private String mac; - - @Override - public String getEventType() { - return EventTypes.EVENT_BAREMETAL_PROVISION_DONE; - } - - @Override - public String getEventDescription() { - return "notify management server that baremetal provision has been done on a host"; - } - - @Override - public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException { - try { - bmMgr.notifyProvisionDone(this); - this.setResponseObject(new SuccessResponse(getCommandName())); - } catch (Exception e) { - s_logger.warn(String.format("unable to notify baremetal provision done[mac:%s]", mac), e); - throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage()); - } - } - - public String getMac() { - return mac; - } - - public void setMac(String mac) { - this.mac = mac; - } - - @Override - public String getCommandName() { - return s_name; - } - - @Override - public long getEntityOwnerId() { - return CallContext.current().getCallingAccount().getId(); - } -} diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java index 9309e3aba3c..1f15d39f81e 100755 --- a/server/src/com/cloud/configuration/Config.java +++ b/server/src/com/cloud/configuration/Config.java @@ -1849,6 +1849,22 @@ public enum Config { "The maximum number of retrying times to search for an available IPv6 address in the table", null), + BaremetalEnableCompleteNotification( + "Advanced", + ManagementServer.class, + Boolean.class, + "baremetal.provision.done.notification", + "false", + "Enable provision done notification through virtual router", + null), + BaremetalPeerHypervisorType( + "Advanced", + ManagementServer.class, + String.class, + "baremetal.peer.hypervisor.type", + "Vmware", + "Hypervisor[Xenserver/KVM/VMWare] used to spring up virtual router for baremetal instances. The cluster having this hypervisor type must be in the same zone with baremetal cluster", + null), BaremetalInternalStorageServer( "Advanced", ManagementServer.class, @@ -1857,30 +1873,6 @@ public enum Config { null, "the ip address of server that stores kickstart file, kernel, initrd, ISO for advanced networking baremetal provisioning", null), - BaremetalProvisionDoneNotificationEnabled( - "Advanced", - ManagementServer.class, - Boolean.class, - "baremetal.provision.done.notification.enabled", - "true", - "whether to enable baremetal provison done notification", - null), - BaremetalProvisionDoneNotificationTimeout( - "Advanced", - ManagementServer.class, - Integer.class, - "baremetal.provision.done.notification.timeout", - "1800", - "the max time to wait before treating a baremetal provision as failure if no provision done notification is not received, in secs", - null), - BaremetalProvisionDoneNotificationPort( - "Advanced", - ManagementServer.class, - Integer.class, - "baremetal.provision.done.notification.port", - "8080", - "the port that listens baremetal provision done notification. Should be the same to port management server listening on for now. Please change it to management server port if it's not default 8080", - null), ExternalBaremetalSystemUrl( "Advanced", ManagementServer.class, diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java index 898aec9a6a5..c95867e04b9 100755 --- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java +++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java @@ -2323,7 +2323,7 @@ VirtualMachineGuru, Listener, Configurable, StateListener acntq = QueryBuilder.create(UserVO.class); acntq.and(acntq.entity().getUsername(), SearchCriteria.Op.EQ, "baremetal-system-account"); UserVO user = acntq.find(); @@ -2332,8 +2332,6 @@ VirtualMachineGuru, Listener, Configurable, StateListener