cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [17/50] git commit: updated refs/heads/saml2 to 09da909
Date Sat, 16 Aug 2014 10:55:48 GMT
Don't depend on static paths especially if we are already checking that
location using the getResource call.

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

Branch: refs/heads/saml2
Commit: 328599ae0b2582d641e51c2922ecad2972e1f03a
Parents: ae4d498
Author: Hugo Trippaers <htrippaers@schubergphilis.com>
Authored: Wed Aug 13 09:02:04 2014 +0200
Committer: Hugo Trippaers <htrippaers@schubergphilis.com>
Committed: Wed Aug 13 09:02:04 2014 +0200

----------------------------------------------------------------------
 .../BaremetalKickStartServiceImpl.java          | 64 +++++++++-----------
 1 file changed, 27 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/328599ae/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 f7d82d3..bd363f6 100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java
@@ -18,6 +18,25 @@
 // Automatically generated by addcopyright.py at 01/29/2013
 package com.cloud.baremetal.networkservice;
 
+import java.io.File;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.AddBaremetalKickStartPxeCmd;
+import org.apache.cloudstack.api.AddBaremetalPxeCmd;
+import org.apache.cloudstack.api.ListBaremetalPxeServersCmd;
+import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
+
 import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.baremetal.IpmISetBootDevCommand;
 import com.cloud.agent.api.baremetal.IpmISetBootDevCommand.BootDev;
@@ -60,23 +79,6 @@ import com.cloud.vm.ReservationContext;
 import com.cloud.vm.VirtualMachineProfile;
 import com.cloud.vm.dao.DomainRouterDao;
 import com.cloud.vm.dao.NicDao;
-import org.apache.cloudstack.api.AddBaremetalKickStartPxeCmd;
-import org.apache.cloudstack.api.AddBaremetalPxeCmd;
-import org.apache.cloudstack.api.ListBaremetalPxeServersCmd;
-import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
-import org.apache.log4j.Logger;
-import org.springframework.web.util.UriComponentsBuilder;
-
-import javax.ejb.Local;
-import javax.inject.Inject;
-import java.io.File;
-import java.net.URI;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
 
 @Local(value = BaremetalPxeService.class)
 public class BaremetalKickStartServiceImpl extends BareMetalPxeServiceBase implements BaremetalPxeService
{
@@ -163,12 +165,9 @@ public class BaremetalKickStartServiceImpl extends BareMetalPxeServiceBase
imple
         if (url != null) {
             keyFile = new File(url.getPath());
         }
-        if (keyFile == null || !keyFile.exists()) {
-            keyFile = new File("/usr/share/cloudstack-common/scripts/vm/systemvm/id_rsa.cloud");
-        }
-        assert (keyFile != null);
-        if (!keyFile.exists()) {
-            s_logger.error("Unable to locate id_rsa.cloud in your setup at " + keyFile.toString());
+        if (keyFile == null || !keyFile.canRead()) {
+            s_logger.error("Unable to locate id_rsa.cloud");
+            return null;
         }
         return keyFile;
     }
@@ -204,15 +203,6 @@ public class BaremetalKickStartServiceImpl extends BareMetalPxeServiceBase
imple
         return true;
     }
 
-    private URI buildUrl(String mgmtIp, String subPath) {
-        UriComponentsBuilder ub = UriComponentsBuilder.newInstance();
-        ub.scheme("http");
-        ub.scheme(mgmtIp);
-        ub.port(10086);
-        ub.path(subPath);
-        return ub.build().toUri();
-    }
-
     private boolean preparePxeInAdvancedZone(VirtualMachineProfile profile, NicProfile nic,
Network network, DeployDestination dest, ReservationContext context) throws Exception {
         DomainRouterVO vr = getVirtualRouter(network);
         List<NicVO> nics = _nicDao.listByVmId(vr.getId());
@@ -232,7 +222,7 @@ public class BaremetalKickStartServiceImpl extends BareMetalPxeServiceBase
imple
         Pair<Boolean, String> 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(),
                         String.format("01-%s", nic.getMacAddress().replaceAll(":", "-")),
tuple.get(0))
-        );
+                );
         if (!ret.first()) {
             throw new CloudRuntimeException(String.format("failed preparing PXE in virtual
router[id:%s], because %s", vr.getId(), ret.second()));
         }
@@ -241,7 +231,7 @@ public class BaremetalKickStartServiceImpl extends BareMetalPxeServiceBase
imple
         String internalServerIp = "10.223.110.231";
         ret = SshHelper.sshExecute(mgmtNic.getIp4Address(), 3922, "root", getSystemVMKeyFile(),
null,
                 String.format("/usr/bin/baremetal_snat.sh %s %s", mgmtNic.getIp4Address(),
internalServerIp)
-        );
+                );
         if (!ret.first()) {
             throw new CloudRuntimeException(String.format("failed preparing PXE in virtual
router[id:%s], because %s", vr.getId(), ret.second()));
         }
@@ -299,13 +289,13 @@ public class BaremetalKickStartServiceImpl extends BareMetalPxeServiceBase
imple
         zoneId = pNetwork.getDataCenterId();
 
         PhysicalNetworkServiceProviderVO ntwkSvcProvider =
-            _physicalNetworkServiceProviderDao.findByServiceProvider(pNetwork.getId(), BaremetalPxeManager.BAREMETAL_PXE_SERVICE_PROVIDER.getName());
+                _physicalNetworkServiceProviderDao.findByServiceProvider(pNetwork.getId(),
BaremetalPxeManager.BAREMETAL_PXE_SERVICE_PROVIDER.getName());
         if (ntwkSvcProvider == null) {
             throw new CloudRuntimeException("Network Service Provider: " + BaremetalPxeManager.BAREMETAL_PXE_SERVICE_PROVIDER.getName()
+
-                " is not enabled in the physical network: " + cmd.getPhysicalNetworkId()
+ "to add this device");
+                    " is not enabled in the physical network: " + cmd.getPhysicalNetworkId()
+ "to add this device");
         } else if (ntwkSvcProvider.getState() == PhysicalNetworkServiceProvider.State.Shutdown)
{
             throw new CloudRuntimeException("Network Service Provider: " + ntwkSvcProvider.getProviderName()
+ " is in shutdown state in the physical network: " +
-                cmd.getPhysicalNetworkId() + "to add this device");
+                    cmd.getPhysicalNetworkId() + "to add this device");
         }
 
         List<HostVO> pxes = _resourceMgr.listAllHostsInOneZoneByType(Host.Type.BaremetalPxe,
zoneId);


Mime
View raw message