incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From frankzh...@apache.org
Subject [3/7] git commit: refs/heads/master - CloudStack CLOUDSTACK-774 Supporting kickstart in CloudStack baremetal
Date Thu, 21 Feb 2013 23:44:17 GMT
CloudStack CLOUDSTACK-774
Supporting kickstart in CloudStack baremetal

adding missing scripts back

Conflicts:

	client/pom.xml
	client/tomcatconf/commands.properties.in
	server/src/com/cloud/server/ManagementServerImpl.java


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/55b77c7c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/55b77c7c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/55b77c7c

Branch: refs/heads/master
Commit: 55b77c7c8f16f360666b06afb99d8ca0283b8881
Parents: 1f15c1e
Author: frank <frank.zhang@citrix.com>
Authored: Fri Feb 15 17:09:05 2013 -0800
Committer: frank <frank.zhang@citrix.com>
Committed: Thu Feb 21 15:46:11 2013 -0800

----------------------------------------------------------------------
 client/pom.xml                                     |   14 +-
 client/tomcatconf/commands.properties.in           |    3 +
 client/tomcatconf/componentContext.xml.in          |    3 +
 .../baremetal/manager/AddBaremetalHostCmd.java     |    5 +
 .../cloud/baremetal/manager/BaremetalManager.java  |    3 +-
 .../baremetal/manager/BaremetalManagerImpl.java    |    9 ++
 .../networkservice/AddBaremetalDhcpCmd.java        |    6 +-
 .../networkservice/AddBaremetalPxeCmd.java         |    6 +-
 .../networkservice/BareMetalPingServiceImpl.java   |    6 +
 .../BaremetalKickStartPxeResource.java             |    9 +-
 .../BaremetalKickStartServiceImpl.java             |    5 +
 .../networkservice/BaremetalPxeManagerImpl.java    |   14 +-
 .../networkservice/BaremetalPxeService.java        |    2 +
 .../networkservice/BaremetalUserdataElement.java   |    8 +-
 scripts/network/ping/baremetal_user_data.py        |   87 +++++++++++++++
 scripts/network/ping/prepare_kickstart_bootfile.py |   78 +++++++++++++
 .../ping/prepare_kickstart_kernel_initrd.py        |   54 +++++++++
 .../src/com/cloud/network/NetworkServiceImpl.java  |   17 +++-
 18 files changed, 300 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/55b77c7c/client/pom.xml
----------------------------------------------------------------------
diff --git a/client/pom.xml b/client/pom.xml
index 5f219fe..73866ee 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -273,6 +273,12 @@
             </goals>
             <configuration>
               <target>
+                <exec executable="cp">
+                    <arg value="-r" />
+                    <arg value="${basedir}/../scripts" />
+                    <arg value="${basedir}/target/generated-webapp/WEB-INF/classes/scripts"
/>
+                </exec>
+
                 <copy
                   todir="${basedir}/target/generated-webapp/WEB-INF/">
                   <fileset dir="${basedir}/WEB-INF/">
@@ -285,13 +291,7 @@
                     <include name="resources/**/*" />
                   </fileset>
                 </copy>
-                <copy
-                  todir="${basedir}/target/generated-webapp/WEB-INF/classes/scripts">
-                  <fileset dir="${basedir}/../scripts">
-                  </fileset>
-                </copy>
-                <copy
-                  todir="${basedir}/target/generated-webapp/WEB-INF/classes/vms">
+                <copy todir="${basedir}/target/generated-webapp/WEB-INF/classes/vms">
                   <fileset dir="${basedir}/../services/console-proxy/server/dist">
                     <include name="systemvm.zip" />
                     <include name="systemvm.iso" />

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/55b77c7c/client/tomcatconf/commands.properties.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in
index e1d0fb2..f03e8d5 100644
--- a/client/tomcatconf/commands.properties.in
+++ b/client/tomcatconf/commands.properties.in
@@ -543,3 +543,6 @@ listVMSnapshot=15
 createVMSnapshot=15
 deleteVMSnapshot=15
 revertToSnapshot=15
+
+#### Baremetal commands
+addBaremetalHost=1

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/55b77c7c/client/tomcatconf/componentContext.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/componentContext.xml.in b/client/tomcatconf/componentContext.xml.in
index 23f8f2b..8169796 100644
--- a/client/tomcatconf/componentContext.xml.in
+++ b/client/tomcatconf/componentContext.xml.in
@@ -74,6 +74,9 @@
   <bean id="BareMetalPxe" class="com.cloud.baremetal.networkservice.BaremetalPxeElement">
       <property name="name" value="BareMetalPxe"/>
   </bean>
+  <bean id="BareMetalUserdata" class="com.cloud.baremetal.networkservice.BaremetalUserdataElement">
+      <property name="name" value="BareMetalUserdata"/>
+  </bean>
   <bean id="SecurityGroupProvider" class="com.cloud.network.element.SecurityGroupElement">
     <property name="name" value="SecurityGroupProvider"/>
   </bean>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/55b77c7c/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/AddBaremetalHostCmd.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/AddBaremetalHostCmd.java
b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/AddBaremetalHostCmd.java
index f778a4f..f07b212 100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/AddBaremetalHostCmd.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/AddBaremetalHostCmd.java
@@ -30,7 +30,12 @@ public class AddBaremetalHostCmd extends AddHostCmd {
     private String vmIpAddress;
 
     public AddBaremetalHostCmd() {
+    }
+    
+    @Override
+    public void execute(){
         this.getFullUrlParams().put(ApiConstants.BAREMETAL_DISCOVER_NAME, BareMetalDiscoverer.class.getName());
+        super.execute();
     }
     
     public String getVmIpAddress() {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/55b77c7c/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManager.java
----------------------------------------------------------------------
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 1599050..6467c94 100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManager.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManager.java
@@ -20,8 +20,9 @@ package com.cloud.baremetal.manager;
 
 import com.cloud.network.Network.Provider;
 import com.cloud.utils.component.Manager;
+import com.cloud.utils.component.PluggableService;
 
-public interface BaremetalManager extends Manager {
+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";

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/55b77c7c/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManagerImpl.java
----------------------------------------------------------------------
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 b07a6bb..b41d6ca 100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManagerImpl.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManagerImpl.java
@@ -18,6 +18,8 @@
 // Automatically generated by addcopyright.py at 01/29/2013
 package com.cloud.baremetal.manager;
 
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
 
 import javax.ejb.Local;
@@ -110,4 +112,11 @@ public class BaremetalManagerImpl extends ManagerBase implements BaremetalManage
 		
 		return true;
     }
+
+    @Override
+    public List<Class<?>> getCommands() {
+        List<Class<?>> cmds = new ArrayList<Class<?>>();
+        cmds.add(AddBaremetalHostCmd.class);
+        return cmds;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/55b77c7c/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/AddBaremetalDhcpCmd.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/AddBaremetalDhcpCmd.java
b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/AddBaremetalDhcpCmd.java
index d9d8bec..c749832 100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/AddBaremetalDhcpCmd.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/AddBaremetalDhcpCmd.java
@@ -26,6 +26,8 @@ import org.apache.cloudstack.api.ApiErrorCode;
 import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.BaseCmd;
 import org.apache.cloudstack.api.BaseCmd.CommandType;
+import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
+import org.apache.cloudstack.api.response.PodResponse;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.log4j.Logger;
@@ -48,10 +50,10 @@ public class AddBaremetalDhcpCmd extends BaseAsyncCmd {
     /////////////////////////////////////////////////////
     //////////////// API parameters /////////////////////
     /////////////////////////////////////////////////////
-    @Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.LONG, required=true,
description="the Physical Network ID")
+    @Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.UUID, entityType=PhysicalNetworkResponse.class,
required=true, description="the Physical Network ID")
     private Long physicalNetworkId;
     
-    @Parameter(name=ApiConstants.POD_ID, type=CommandType.LONG, required = true, description="Pod
Id")
+    @Parameter(name=ApiConstants.POD_ID, type=CommandType.UUID, entityType=PodResponse.class,
required = true, description="Pod Id")
     private Long podId;
     
     @Parameter(name=ApiConstants.DHCP_SERVER_TYPE, type=CommandType.STRING, required = true,
description="Type of dhcp device")

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/55b77c7c/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/AddBaremetalPxeCmd.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/AddBaremetalPxeCmd.java
b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/AddBaremetalPxeCmd.java
index 54a9c02..63e1147 100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/AddBaremetalPxeCmd.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/AddBaremetalPxeCmd.java
@@ -26,6 +26,8 @@ import org.apache.cloudstack.api.ApiErrorCode;
 import org.apache.cloudstack.api.BaseAsyncCmd;
 import org.apache.cloudstack.api.BaseCmd;
 import org.apache.cloudstack.api.BaseCmd.CommandType;
+import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
+import org.apache.cloudstack.api.response.PodResponse;
 import org.apache.cloudstack.api.Parameter;
 import org.apache.cloudstack.api.ServerApiException;
 import org.apache.log4j.Logger;
@@ -46,10 +48,10 @@ public class AddBaremetalPxeCmd extends BaseAsyncCmd {
     /////////////////////////////////////////////////////
     //////////////// API parameters /////////////////////
     /////////////////////////////////////////////////////
-    @Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.LONG, required=true,
description="the Physical Network ID")
+    @Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.UUID, entityType=PhysicalNetworkResponse.class,
required=true, description="the Physical Network ID")
     private Long physicalNetworkId;
     
-    @Parameter(name=ApiConstants.POD_ID, type=CommandType.LONG, description="Pod Id")
+    @Parameter(name=ApiConstants.POD_ID, type=CommandType.UUID, entityType=PodResponse.class,
description="Pod Id")
     private Long podId;
     
     @Parameter(name=ApiConstants.URL, type=CommandType.STRING, required = true, description="URL
of the external pxe device")

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/55b77c7c/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalPingServiceImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalPingServiceImpl.java
b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalPingServiceImpl.java
index 3e21750..d6b96a8 100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalPingServiceImpl.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalPingServiceImpl.java
@@ -297,4 +297,10 @@ public class BareMetalPingServiceImpl extends BareMetalPxeServiceBase
implements
         }
         return responses;
     }
+
+
+    @Override
+    public String getPxeServiceType() {
+        return BaremetalPxeManager.BaremetalPxeType.PING.toString();
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/55b77c7c/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartPxeResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartPxeResource.java
b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartPxeResource.java
index 938b3ac..2b9b140 100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartPxeResource.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartPxeResource.java
@@ -32,6 +32,7 @@ import com.cloud.agent.api.Command;
 import com.cloud.agent.api.PingCommand;
 import com.cloud.agent.api.PingRoutingCommand;
 import com.cloud.agent.api.routing.VmDataCommand;
+import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.utils.script.Script;
 import com.cloud.utils.ssh.SSHCmdHelper;
 import com.cloud.vm.VirtualMachine.State;
@@ -70,27 +71,27 @@ public class BaremetalKickStartPxeResource extends BaremetalPxeResourceBase
{
             String prepareScript = "scripts/network/ping/prepare_kickstart_bootfile.py";
             String prepareScriptPath = Script.findScript("", prepareScript);
             if (prepareScriptPath == null) {
-                throw new ConfigurationException("Can not find prepare_kickstart_bootfile.py
at " + prepareScriptPath);
+                throw new ConfigurationException("Can not find prepare_kickstart_bootfile.py
at " + prepareScript);
             }
             scp.put(prepareScriptPath, "/usr/bin/", "0755");
 
             String cpScript = "scripts/network/ping/prepare_kickstart_kernel_initrd.py";
             String cpScriptPath = Script.findScript("", cpScript);
             if (cpScriptPath == null) {
-                throw new ConfigurationException("Can not find prepare_kickstart_kernel_initrd.py
at " + cpScriptPath);
+                throw new ConfigurationException("Can not find prepare_kickstart_kernel_initrd.py
at " + cpScript);
             }
             scp.put(cpScriptPath, "/usr/bin/", "0755");
             
             String userDataScript = "scripts/network/ping/baremetal_user_data.py";
             String userDataScriptPath = Script.findScript("", userDataScript);
             if (userDataScriptPath == null) {
-                throw new ConfigurationException("Can not find baremetal_user_data.py at
" + userDataScriptPath);
+                throw new ConfigurationException("Can not find baremetal_user_data.py at
" + userDataScript);
             }
             scp.put(userDataScriptPath, "/usr/bin/", "0755");
 
             return true;
         } catch (Exception e) {
-            throw new ConfigurationException(e.getMessage());
+            throw new CloudRuntimeException(e);
         } finally {
             if (sshConnection != null) {
                 sshConnection.close();

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/55b77c7c/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java
----------------------------------------------------------------------
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 617893f..ba5fb0d 100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java
@@ -233,6 +233,11 @@ public class BaremetalKickStartServiceImpl extends BareMetalPxeServiceBase
imple
             responses.add(getApiResponse(vo));
         }
         return responses;
+    }
+
+    @Override
+    public String getPxeServiceType() {
+        return BaremetalPxeManager.BaremetalPxeType.KICK_START.toString();
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/55b77c7c/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPxeManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPxeManagerImpl.java
b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPxeManagerImpl.java
index 35cbaee..6288f91 100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPxeManagerImpl.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPxeManagerImpl.java
@@ -54,7 +54,6 @@ import com.cloud.resource.UnableDeleteHostException;
 import com.cloud.service.dao.ServiceOfferingDao;
 import com.cloud.uservm.UserVm;
 import com.cloud.utils.StringUtils;
-import com.cloud.utils.component.AdapterBase;
 import com.cloud.utils.component.ManagerBase;
 import com.cloud.utils.db.SearchCriteria.Op;
 import com.cloud.utils.db.SearchCriteria2;
@@ -107,12 +106,13 @@ public class BaremetalPxeManagerImpl extends ManagerBase implements
BaremetalPxe
 	}
 
 	protected BaremetalPxeService getServiceByType(String type) {
-		BaremetalPxeService _service;
-		_service = AdapterBase.getAdapterByName(_services, type);
-		if (_service == null) {
-			throw new CloudRuntimeException("Cannot find PXE service for " + type);
-		}
-		return _service;
+		for (BaremetalPxeService service : _services) {
+		    if (service.getPxeServiceType().equals(type)) {
+		        return service;
+		    }
+		}
+		
+		throw new CloudRuntimeException("Cannot find PXE service for " + type);
 	}
 	
 	@Override

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/55b77c7c/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPxeService.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPxeService.java
b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPxeService.java
old mode 100644
new mode 100755
index 8504f82..9fd560f
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPxeService.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPxeService.java
@@ -46,6 +46,8 @@ public interface BaremetalPxeService extends Adapter {
 	
 	List<BaremetalPxeResponse> listPxeServers(ListBaremetalPxePingServersCmd cmd);
 	
+	String getPxeServiceType();
+	
 	public static final String PXE_PARAM_TYPE = "type";
 	public static final String PXE_PARAM_ZONE = "zone";
 	public static final String PXE_PARAM_POD = "pod";

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/55b77c7c/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalUserdataElement.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalUserdataElement.java
b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalUserdataElement.java
index ae58254..3d9f581 100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalUserdataElement.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalUserdataElement.java
@@ -149,7 +149,7 @@ public class BaremetalUserdataElement extends AdapterBase implements NetworkElem
     @Override
     public boolean canEnableIndividualServices() {
         // TODO Auto-generated method stub
-        return false;
+        return true;
     }
 
 
@@ -162,14 +162,12 @@ public class BaremetalUserdataElement extends AdapterBase implements
NetworkElem
 
     @Override
     public boolean destroy(Network network, ReservationContext context) throws ConcurrentOperationException,
ResourceUnavailableException {
-        // TODO Auto-generated method stub
-        return false;
+        return true;
     }
 
     @Override
     public boolean verifyServicesCombination(Set<Service> services) {
-        // TODO Auto-generated method stub
-        return false;
+        return true;
     }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/55b77c7c/scripts/network/ping/baremetal_user_data.py
----------------------------------------------------------------------
diff --git a/scripts/network/ping/baremetal_user_data.py b/scripts/network/ping/baremetal_user_data.py
new file mode 100755
index 0000000..dd4a8f7
--- /dev/null
+++ b/scripts/network/ping/baremetal_user_data.py
@@ -0,0 +1,87 @@
+'''
+Created on Jul 2, 2012
+
+@author: frank
+'''
+import sys
+import os
+import os.path
+import base64
+
+HTML_ROOT = "/var/www/html/"
+
+def writeIfNotHere(fileName, texts):
+    if not os.path.exists(fileName):
+        entries = []
+    else:
+        f = open(fileName, 'r')
+        entries = f.readlines()
+        f.close()
+
+    texts = [ "%s\n" % t for t in texts ]
+    need = False
+    for t in texts:
+        if not t in entries:
+            entries.append(t)
+            need = True
+            
+    if need: 
+        f = open(fileName, 'w')
+        f.write(''.join(entries))
+        f.close()
+    
+def createRedirectEntry(vmIp, folder, filename):
+    entry = "RewriteRule ^%s$  ../%s/%%{REMOTE_ADDR}/%s [L,NC,QSA]" % (filename, folder,
filename)
+    htaccessFolder="/var/www/html/latest"
+    htaccessFile=os.path.join(htaccessFolder, ".htaccess")
+    if not os.path.exists(htaccessFolder):
+        os.makedirs(htaccessFolder)
+    writeIfNotHere(htaccessFile, ["Options +FollowSymLinks", "RewriteEngine On", entry])
+        
+    htaccessFolder = os.path.join("/var/www/html/", folder, vmIp)
+    if not os.path.exists(htaccessFolder):
+        os.makedirs(htaccessFolder)
+    htaccessFile=os.path.join(htaccessFolder, ".htaccess")
+    entry="Options -Indexes\nOrder Deny,Allow\nDeny from all\nAllow from %s" % vmIp
+    f = open(htaccessFile, 'w')
+    f.write(entry)
+    f.close()
+    
+    if folder in ['metadata', 'meta-data']:
+        entry1="RewriteRule ^meta-data/(.+)$  ../%s/%%{REMOTE_ADDR}/$1 [L,NC,QSA]" % folder
+        htaccessFolder="/var/www/html/latest"
+        htaccessFile=os.path.join(htaccessFolder, ".htaccess")
+        entry2="RewriteRule ^meta-data/$  ../%s/%%{REMOTE_ADDR}/meta-data [L,NC,QSA]" % folder
+        writeIfNotHere(htaccessFile, [entry1, entry2])
+        
+
+def addUserData(vmIp, folder, fileName, contents):
+        
+    baseFolder = os.path.join(HTML_ROOT, folder, vmIp)
+    if not os.path.exists(baseFolder):
+        os.makedirs(baseFolder)
+        
+    createRedirectEntry(vmIp, folder, fileName)
+    
+    datafileName = os.path.join(HTML_ROOT, folder, vmIp, fileName)
+    metaManifest = os.path.join(HTML_ROOT, folder, vmIp, "meta-data")
+    if folder == "userdata":
+        if contents != "none":
+            contents = base64.urlsafe_b64decode(contents)
+        else:
+            contents = ""
+            
+    f = open(datafileName, 'w')
+    f.write(contents) 
+    f.close()
+    
+    if folder == "metadata" or folder == "meta-data":
+        writeIfNotHere(metaManifest, fileName)
+
+if __name__ == '__main__':
+    string = sys.argv[1]
+    allEntires = string.split(";")
+    for entry in allEntires:
+        (vmIp, folder, fileName, contents) = entry.split(',', 3)
+        addUserData(vmIp, folder, fileName, contents)
+    sys.exit(0)    

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/55b77c7c/scripts/network/ping/prepare_kickstart_bootfile.py
----------------------------------------------------------------------
diff --git a/scripts/network/ping/prepare_kickstart_bootfile.py b/scripts/network/ping/prepare_kickstart_bootfile.py
new file mode 100755
index 0000000..4378293
--- /dev/null
+++ b/scripts/network/ping/prepare_kickstart_bootfile.py
@@ -0,0 +1,78 @@
+#!/usr/bin/python
+# Copyright 2012 Citrix Systems, Inc. Licensed under the
+# Apache License, Version 2.0 (the "License"); you may not use this
+# file except in compliance with the License.  Citrix Systems, Inc.
+# reserves all rights not expressly granted by 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.
+# 
+# Automatically generated by addcopyright.py at 04/03/2012
+
+
+
+ 
+
+# Usage: prepare_tftp_bootfile.py tftp_dir mac cifs_server share directory image_to_restore
cifs_username cifs_password
+import os, sys
+from sys import exit
+from os import makedirs
+from os.path import exists, join
+
+fmt1 = '''DEFAULT default
+PROMPT 1
+TIMEOUT 26
+DISPLAY boot.msg
+LABEL default
+KERNEL %s
+APPEND ramdisk_size=66000 initrd=%s ksdevice=%s ks=%s 
+'''
+fmt2 = '''DEFAULT default
+PROMPT 1
+TIMEOUT 26
+DISPLAY boot.msg
+LABEL default
+KERNEL %s
+APPEND ramdisk_size=66000 initrd=%s ks=%s
+'''
+
+tftp_dir = ''
+mac = ''
+kernel = ''
+initrd = ''
+ks_file = ''
+ks_device = ''
+
+def prepare():
+    try:
+        pxelinux = join(tftp_dir, "pxelinux.cfg")
+        if exists(pxelinux) == False:
+            makedirs(pxelinux)
+
+        cfg_name = "01-" + mac.replace(':','-').lower()
+        cfg_path = join(pxelinux, cfg_name)
+        f = open(cfg_path, "w")
+        if ks_device == '':
+            stuff = fmt2 % (kernel, initrd, ks_file)
+        else:
+            stuff = fmt1 % (kernel, initrd, ks_device, ks_file)
+        f.write(stuff)
+        f.close()
+        return 0
+    except Exception, e:
+        print e
+        return 1
+
+
+if __name__ == "__main__":
+    if len(sys.argv) < 7:
+        print "Usage: prepare_kickstart_bootfile.py tftp_dir mac kernel initrd ks_file ks_device"
+        exit(1)
+
+    (tftp_dir, mac, kernel, initrd, ks_file, ks_device) = sys.argv[1:]
+    
+    ret = prepare()
+    exit(ret)

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/55b77c7c/scripts/network/ping/prepare_kickstart_kernel_initrd.py
----------------------------------------------------------------------
diff --git a/scripts/network/ping/prepare_kickstart_kernel_initrd.py b/scripts/network/ping/prepare_kickstart_kernel_initrd.py
new file mode 100755
index 0000000..52ae02c
--- /dev/null
+++ b/scripts/network/ping/prepare_kickstart_kernel_initrd.py
@@ -0,0 +1,54 @@
+#!/usr/bin/python
+
+import sys
+import tempfile
+import os.path
+import os
+
+iso_folder = ''
+copy_to = ''
+
+def cmd(cmdstr, err=True):
+    if os.system(cmdstr) != 0 and err:
+        raise Exception("Failed to run shell command: %s" % cmdstr)
+    
+def prepare():
+    try:
+        kernel = os.path.join(copy_to, "vmlinuz")
+        initrd = os.path.join(copy_to, "initrd.img")
+        if os.path.exists(kernel) and os.path.exists(initrd):
+            print "Having template(%s) prepared already, skip copying" % copy_to
+            return 0
+        else:
+            if not os.path.exists(copy_to):
+                os.makedirs(copy_to)
+
+        mnt_path = tempfile.mkdtemp()
+        try:
+            mnt = "mount %s %s" % (iso_folder, mnt_path)
+            cmd(mnt)
+            
+            kernel = os.path.join(mnt_path, "vmlinuz")
+            initrd = os.path.join(mnt_path, "initrd.img")
+            cp = "cp -f %s %s/" % (kernel, copy_to)
+            cmd(cp)
+            cp = "cp -f %s %s/" % (initrd, copy_to)
+            cmd(cp)
+        finally:
+            umnt = "umount %s" % mnt_path
+            cmd(umnt, False)
+            rm = "rm -r %s" % mnt_path
+            cmd(rm, False)
+        return 0
+    except Exception, e:
+        print e
+        return 1
+    
+if __name__ == "__main__":
+    if len(sys.argv) < 3:
+        print "Usage: prepare_kickstart_kerneal_initrd.py path_to_kernel_initrd_iso path_kernel_initrd_copy_to"
+	sys.exit(1)
+    
+    (iso_folder, copy_to) = sys.argv[1:]
+    sys.exit(prepare())
+    

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/55b77c7c/scripts/util/ipmi.py
----------------------------------------------------------------------
diff --git a/scripts/util/ipmi.py b/scripts/util/ipmi.py
old mode 100644
new mode 100755

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/55b77c7c/server/src/com/cloud/network/NetworkServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkServiceImpl.java b/server/src/com/cloud/network/NetworkServiceImpl.java
index 37b4903..d4150d5 100755
--- a/server/src/com/cloud/network/NetworkServiceImpl.java
+++ b/server/src/com/cloud/network/NetworkServiceImpl.java
@@ -1937,7 +1937,10 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService
{
             addDefaultSecurityGroupProviderToPhysicalNetwork(pNetwork.getId());
             
             // add VPCVirtualRouter as the defualt network service provider
-            addDefaultVpcVirtualRouterToPhysicalNetwork(pNetwork.getId());
+            addDefaultVpcVirtualRouterToPhysicalNetwork(pNetwork.getId());
+            
+            // add baremetal pxe/dhcp provider to the physical network
+            addDefaultBaremetalProvidersToPhysicalNetwork(pNetwork.getId());
 
             txn.commit();
             return pNetwork;
@@ -2745,6 +2748,18 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService
{
         element.addElement(nsp.getId(), VirtualRouterProviderType.VirtualRouter);
 
         return nsp;
+    }
+    
+    
+    private PhysicalNetworkServiceProvider addDefaultBaremetalProvidersToPhysicalNetwork(long
physicalNetworkId) {
+        PhysicalNetworkVO pvo = _physicalNetworkDao.findById(physicalNetworkId);
+        DataCenterVO dvo = _dcDao.findById(pvo.getDataCenterId());
+        if (dvo.getNetworkType() == NetworkType.Basic) {
+            addProviderToPhysicalNetwork(physicalNetworkId, "BaremetalDhcpProvider", null,
null);
+            addProviderToPhysicalNetwork(physicalNetworkId, "BaremetalPxeProvider", null,
null);
+            addProviderToPhysicalNetwork(physicalNetworkId, "BaremetaUserdataProvider", null,
null);
+        }
+        return null;
     }
     
     protected PhysicalNetworkServiceProvider addDefaultVpcVirtualRouterToPhysicalNetwork(long
physicalNetworkId) {


Mime
View raw message