Bug 8208 - bare metal provisioning

Successfully add start entry into LinMin PXE server
This commit is contained in:
Frank 2011-02-25 21:08:13 -08:00
parent a9728998ff
commit cd676f481d
5 changed files with 50 additions and 4 deletions

View File

@ -251,4 +251,7 @@ restartNetwork=com.cloud.api.commands.RestartNetworkCmd;15
registerSSHKeyPair=com.cloud.api.commands.RegisterSSHKeyPairCmd;15
createSSHKeyPair=com.cloud.api.commands.CreateSSHKeyPairCmd;15
deleteSSHKeyPair=com.cloud.api.commands.DeleteSSHKeyPairCmd;15
listSSHKeyPairs=com.cloud.api.commands.ListSSHKeyPairsCmd;15
listSSHKeyPairs=com.cloud.api.commands.ListSSHKeyPairsCmd;15
### PXE server commands
AddPxeServer=com.cloud.api.AddPxeServerCmd;1

View File

@ -80,7 +80,44 @@ def ping(args):
else:
return 0
call_table = {"ping":ping}
def boot_dev(args):
hostname = args.get("hostname")
usrname = args.get("usrname")
password = args.get("password")
dev = args.get("dev")
if hostname == None:
print "No hostname"
return 1
if dev == None:
print "No boot device specified"
return 1
o = ipmitool("-H", hostname, "-U", usrname, "-P", password, "chassis", "bootdev", dev)
if o.ret:
print o.stderr
return 1
else:
return 0
def reboot(args):
hostname = args.get("hostname")
usrname = args.get("usrname")
password = args.get("password")
if hostname == None:
print "No hostname"
return 1
o = ipmitool("-H", hostname, "-U", usrname, "-P", password, "chassis", "power", "reset")
if o.ret:
print o.stderr
return 1
else:
return 0
call_table = {"ping":ping, "boot_dev":boot_dev, "reboot":reboot}
def dispatch(args):
cmd = args[1]
params = args[2:]

View File

@ -8,6 +8,7 @@ import java.io.StringReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.HashMap;
import java.util.Map;
import javax.naming.ConfigurationException;
@ -25,6 +26,7 @@ import com.cloud.agent.IAgentControl;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.Command;
import com.cloud.agent.api.PingCommand;
import com.cloud.agent.api.PingRoutingCommand;
import com.cloud.agent.api.ReadyAnswer;
import com.cloud.agent.api.ReadyCommand;
import com.cloud.agent.api.StartupCommand;
@ -36,6 +38,7 @@ import com.cloud.host.Host.Type;
import com.cloud.resource.ServerResource;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.ssh.SSHCmdHelper;
import com.cloud.vm.VirtualMachine.State;
public class LinMinPxeServerResource implements ServerResource {
private static final Logger s_logger = Logger.getLogger(LinMinPxeServerResource.class);
@ -164,8 +167,8 @@ public class LinMinPxeServerResource implements ServerResource {
@Override
public PingCommand getCurrentStatus(long id) {
// TODO Auto-generated method stub
return null;
//TODO: check server
return new PingRoutingCommand(getType(), id, new HashMap<String, State>());
}
protected ReadyAnswer execute(ReadyCommand cmd) {

View File

@ -42,6 +42,7 @@ import com.cloud.user.AccountVO;
import com.cloud.utils.Pair;
import com.cloud.vm.Nic;
import com.cloud.vm.NicProfile;
import com.cloud.vm.NicVO;
import com.cloud.vm.ReservationContext;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine;

View File

@ -407,6 +407,8 @@ public class BareMetalVmManagerImpl extends UserVmManagerImpl implements BareMet
throw new CloudRuntimeException("Pepare PXE server failed");
}
profile.addBootArgs("PxeBoot");
return true;
}