cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kelv...@apache.org
Subject [33/50] [abbrv] git commit: refs/heads/master - Merge latest master into javelin
Date Fri, 01 Feb 2013 23:27:31 GMT
Merge latest master into javelin


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

Branch: refs/heads/master
Commit: 1b2b369ecb5eb7d07abcec35129a232f2b88c829
Parents: 3c75d53 cae89c6
Author: Kelven Yang <kelveny@gmail.com>
Authored: Thu Jan 31 11:34:49 2013 -0800
Committer: Kelven Yang <kelveny@gmail.com>
Committed: Thu Jan 31 11:34:49 2013 -0800

----------------------------------------------------------------------
 LICENSE                                            | 3569 +------------
 NOTICE                                             |  618 +---
 api/src/com/cloud/agent/api/to/FirewallRuleTO.java |   20 +-
 api/src/com/cloud/event/EventTypes.java            |   12 +
 api/src/com/cloud/host/Host.java                   |    2 +
 api/src/com/cloud/network/Network.java             |    6 +-
 api/src/com/cloud/network/NetworkProfile.java      |    4 +
 .../network/element/UserDataServiceProvider.java   |    1 +
 .../cloud/network/firewall/FirewallService.java    |    6 +-
 api/src/com/cloud/vm/UserVmService.java            |   34 +
 .../org/apache/cloudstack/api/ApiConstants.java    |    2 +
 .../org/apache/cloudstack/api/ApiErrorCode.java    |    2 +-
 api/src/org/apache/cloudstack/api/BaseCmd.java     |    8 +-
 .../user/firewall/CreateEgressFirewallRuleCmd.java |  341 ++
 .../user/firewall/CreateFirewallRuleCmd.java       |    4 +-
 .../user/firewall/CreatePortForwardingRuleCmd.java |    2 +-
 .../user/firewall/DeleteEgressFirewallRuleCmd.java |  120 +
 .../user/firewall/ListEgressFirewallRulesCmd.java  |   89 +
 .../user/firewall/ListFirewallRulesCmd.java        |    4 +
 .../loadbalancer/CreateLoadBalancerRuleCmd.java    |    2 +-
 .../user/nat/CreateIpForwardingRuleCmd.java        |    2 +-
 .../api/command/user/vm/AddNicToVMCmd.java         |  121 +
 .../api/command/user/vm/DeployVMCmd.java           |    3 +-
 .../api/command/user/vm/RemoveNicFromVMCmd.java    |  115 +
 .../api/command/user/vm/ResetVMSSHKeyCmd.java      |  151 +
 .../command/user/vm/UpdateDefaultNicForVMCmd.java  |  115 +
 .../api/command/user/vm/UpgradeVMCmd.java          |    3 +-
 .../cloudstack/api/response/FirewallResponse.java  |    7 +
 .../cloudstack/api/response/NicResponse.java       |    6 +
 .../WEB-INF/classes/resources/messages.properties  |    1 +
 client/tomcatconf/commands.properties.in           |   11 +
 client/tomcatconf/server-ssl.xml.in                |    1 -
 .../virtualnetwork/VirtualRoutingResource.java     |    9 +
 .../resource/NfsSecondaryStorageResource.java      |    3 +-
 docs/en-US/about-security-groups.xml               |    7 +-
 docs/en-US/admin-alerts.xml                        |    3 +-
 docs/en-US/hypervisor-host-install-libvirt.xml     |    2 +-
 docs/en-US/network-rate.xml                        |  144 +
 docs/en-US/offerings.xml                           |    1 +
 docs/en-US/security-groups-advanced-zones.xml      |   52 +
 docs/en-US/security-groups.xml                     |    6 +-
 docs/en-US/snapshot-throttling.xml                 |   45 +
 docs/en-US/using-sshkeys.xml                       |    7 +
 docs/en-US/vmware-install.xml                      |  550 ++-
 docs/en-US/working-with-snapshots.xml              |    5 +-
 packaging/centos63/cloud-agent.rc                  |    2 +-
 packaging/centos63/cloud-usage.rc                  |  138 +
 packaging/centos63/cloud.spec                      |   24 +-
 .../debian/config/etc/iptables/iptables-router     |    4 +-
 .../debian/config/opt/cloud/bin/ipassoc.sh         |    6 +-
 .../debian/config/root/firewallRule_egress.sh      |  171 +
 .../cloudstack/ratelimit/ApiRateLimitTest.java     |    5 +-
 plugins/hypervisors/baremetal/pom.xml              |   37 +
 .../resources/security_group_agent/cs-sgagent      |   67 +
 .../security_group_agent/__init__.py               |   18 +
 .../security_group_agent/cs_sg_agent.py            |  237 +
 .../security_group_agent/sglib.py                  |  226 +
 .../security_group_agent/xmlobject.py              |   97 +
 .../resources/security_group_agent/setup.py        |   44 +
 .../cloud/baremetal/database/BaremetalCmdbDao.java |   25 +
 .../baremetal/database/BaremetalCmdbDaoImpl.java   |   32 +
 .../cloud/baremetal/database/BaremetalCmdbVO.java  |  104 +
 .../cloud/baremetal/database/BaremetalDhcpDao.java |   25 +
 .../baremetal/database/BaremetalDhcpDaoImpl.java   |   45 +
 .../cloud/baremetal/database/BaremetalDhcpVO.java  |  118 +
 .../cloud/baremetal/database/BaremetalPxeDao.java  |   26 +
 .../baremetal/database/BaremetalPxeDaoImpl.java    |   41 +
 .../cloud/baremetal/database/BaremetalPxeVO.java   |  115 +
 .../baremetal/manager/AddBaremetalHostCmd.java     |   41 +
 .../baremetal/manager/BareMetalDiscoverer.java     |  280 +
 .../com/cloud/baremetal/manager/BareMetalGuru.java |   87 +
 .../manager/BareMetalTemplateAdapter.java          |  217 +
 .../cloud/baremetal/manager/BaremetalManager.java  |   28 +
 .../baremetal/manager/BaremetalManagerImpl.java    |  113 +
 .../networkservice/AddBaremetalDhcpCmd.java        |  150 +
 .../AddBaremetalKickStartPxeCmd.java               |   36 +
 .../networkservice/AddBaremetalPxeCmd.java         |  145 +
 .../AddBaremetalPxePingServerCmd.java              |   80 +
 .../networkservice/BareMetalPingServiceImpl.java   |  300 +
 .../networkservice/BareMetalPxeServiceBase.java    |   47 +
 .../networkservice/BareMetalResourceBase.java      |  618 +++
 .../networkservice/BaremetaNetworkGuru.java        |  173 +
 .../networkservice/BaremetalDhcpElement.java       |  178 +
 .../networkservice/BaremetalDhcpManager.java       |   58 +
 .../networkservice/BaremetalDhcpManagerImpl.java   |  324 ++
 .../networkservice/BaremetalDhcpResourceBase.java  |  175 +
 .../networkservice/BaremetalDhcpResponse.java      |   71 +
 .../networkservice/BaremetalDhcpdResource.java     |  139 +
 .../networkservice/BaremetalDnsmasqResource.java   |  129 +
 .../BaremetalKickStartPxeResource.java             |  201 +
 .../BaremetalKickStartServiceImpl.java             |  238 +
 .../networkservice/BaremetalPingPxeResource.java   |  260 +
 .../networkservice/BaremetalPxeElement.java        |  178 +
 .../BaremetalPxeKickStartResponse.java             |   37 +
 .../networkservice/BaremetalPxeManager.java        |   65 +
 .../networkservice/BaremetalPxeManagerImpl.java    |  242 +
 .../networkservice/BaremetalPxePingResponse.java   |   59 +
 .../networkservice/BaremetalPxeResourceBase.java   |  158 +
 .../networkservice/BaremetalPxeResponse.java       |   71 +
 .../networkservice/BaremetalPxeService.java        |   61 +
 .../networkservice/BaremetalUserdataElement.java   |  175 +
 .../networkservice/ListBaremetalDhcpCmd.java       |  103 +
 .../ListBaremetalPxePingServersCmd.java            |   93 +
 .../PrepareKickstartPxeServerCommand.java          |   74 +
 .../networkservice/SecurityGroupHttpClient.java    |   38 +
 .../kvm/resource/LibvirtComputingResource.java     |    2 +-
 .../hypervisor/vmware/resource/VmwareResource.java |   27 +-
 .../xen/resource/CitrixResourceBase.java           |   10 +-
 .../element/JuniperSRXExternalFirewallElement.java |    1 +
 plugins/pom.xml                                    |    2 +
 scripts/network/domr/call_firewall.sh              |   21 +-
 server/src/com/cloud/api/ApiResponseHelper.java    |    5 +
 server/src/com/cloud/api/ApiServlet.java           |   14 +-
 .../cloud/api/response/ApiResponseSerializer.java  |    6 +-
 server/src/com/cloud/configuration/Config.java     |    8 +-
 server/src/com/cloud/network/NetworkManager.java   |    4 +-
 .../src/com/cloud/network/NetworkManagerImpl.java  |   69 +-
 server/src/com/cloud/network/NetworkModelImpl.java |    3 +
 .../com/cloud/network/dao/FirewallRulesDao.java    |    1 +
 .../cloud/network/dao/FirewallRulesDaoImpl.java    |   21 +-
 .../network/element/CloudZonesNetworkElement.java  |    6 +
 .../network/element/VirtualRouterElement.java      |   22 +-
 .../network/firewall/FirewallManagerImpl.java      |  134 +-
 .../network/lb/LoadBalancingRulesManagerImpl.java  |    7 +-
 .../router/VirtualNetworkApplianceManager.java     |    3 +
 .../router/VirtualNetworkApplianceManagerImpl.java |   65 +-
 .../com/cloud/network/rules/FirewallManager.java   |    6 +-
 .../com/cloud/network/rules/FirewallRuleVO.java    |    7 +-
 .../com/cloud/network/rules/RulesManagerImpl.java  |    4 +-
 .../network/vpn/RemoteAccessVpnManagerImpl.java    |    4 +-
 .../src/com/cloud/server/ManagementServerImpl.java |    3 +-
 .../src/com/cloud/upgrade/dao/Upgrade40to41.java   |  113 +-
 server/src/com/cloud/user/DomainManagerImpl.java   |    2 +
 server/src/com/cloud/vm/UserVmManagerImpl.java     |  433 ++-
 server/src/com/cloud/vm/VirtualMachineManager.java |    9 +
 .../com/cloud/vm/VirtualMachineManagerImpl.java    |   82 +-
 .../com/cloud/network/MockFirewallManagerImpl.java |   79 +-
 .../com/cloud/network/MockNetworkManagerImpl.java  |   11 +-
 .../test/com/cloud/vm/MockUserVmManagerImpl.java   |   31 +
 .../cloud/vm/MockVirtualMachineManagerImpl.java    |    9 +
 .../test/com/cloud/vpc/MockNetworkManagerImpl.java |   15 +-
 .../vpc/MockVpcVirtualNetworkApplianceManager.java |    5 +
 test/integration/smoke/test_nic.py                 |  351 ++
 tools/cli/cloudmonkey/cloudmonkey.py               |   95 +-
 tools/cli/cloudmonkey/common.py                    |   46 +-
 tools/cli/cloudmonkey/lexer.py                     |  121 +
 tools/cli/setup.py                                 |    2 +-
 tools/marvin/marvin/integration/lib/base.py        |   23 +-
 tools/whisker/LICENSE                              | 4254 +++++++++++++++
 tools/whisker/NOTICE                               |  689 +++
 tools/whisker/descriptor-for-packaging.xml         | 2952 ++++++++++
 tools/whisker/descriptor.xml                       |  299 +-
 ui/css/cloudstack3.css                             |    6 +-
 ui/dictionary.jsp                                  |    1 +
 ui/scripts/instanceWizard.js                       |    6 +-
 ui/scripts/network.js                              |    4 +-
 ui/scripts/system.js                               |    6 +-
 ui/scripts/ui-custom/instanceWizard.js             |    8 +-
 ui/scripts/ui-custom/recurringSnapshots.js         |    3 +-
 usage/pom.xml                                      |   68 +
 160 files changed, 18452 insertions(+), 4991 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1b2b369e/api/src/com/cloud/agent/api/to/FirewallRuleTO.java
----------------------------------------------------------------------
diff --cc api/src/com/cloud/agent/api/to/FirewallRuleTO.java
index b0a1108,38de8d0..7f77936
--- a/api/src/com/cloud/agent/api/to/FirewallRuleTO.java
+++ b/api/src/com/cloud/agent/api/to/FirewallRuleTO.java
@@@ -94,7 -94,24 +95,24 @@@ public class FirewallRuleTO implements 
      public FirewallRuleTO(FirewallRule rule, String srcIp) {
          this(rule.getId(),null, srcIp, rule.getProtocol(), rule.getSourcePortStart(), rule.getSourcePortEnd(), rule.getState()==State.Revoke, rule.getState()==State.Active, rule.getPurpose(),rule.getSourceCidrList(),rule.getIcmpType(),rule.getIcmpCode());
      }
 -    
 +
+     public FirewallRuleTO(FirewallRule rule, String srcVlanTag, String srcIp, FirewallRule.Purpose purpose) {
+         this(rule.getId(),srcVlanTag, srcIp, rule.getProtocol(), rule.getSourcePortStart(), rule.getSourcePortEnd(), rule.getState()==State.Revoke, rule.getState()==State.Active, purpose,rule.getSourceCidrList(),rule.getIcmpType(),rule.getIcmpCode());
+     }
+ 
+     public FirewallRuleTO(FirewallRule rule, String srcVlanTag, String srcIp, FirewallRule.Purpose purpose, FirewallRule.TrafficType trafficType) {
+         this(rule.getId(),srcVlanTag, srcIp, rule.getProtocol(), rule.getSourcePortStart(), rule.getSourcePortEnd(), rule.getState()==State.Revoke, rule.getState()==State.Active, purpose,rule.getSourceCidrList(),rule.getIcmpType(),rule.getIcmpCode());
+         this.trafficType = trafficType;
+     }
+ 
+     public FirewallRuleTO(FirewallRule rule, String srcVlanTag, String srcIp, FirewallRule.Purpose purpose, boolean revokeState, boolean alreadyAdded) {
+         this(rule.getId(),srcVlanTag, srcIp, rule.getProtocol(), rule.getSourcePortStart(), rule.getSourcePortEnd(), revokeState, alreadyAdded, purpose,rule.getSourceCidrList(),rule.getIcmpType(),rule.getIcmpCode());
+     }
+ 
+     public FirewallRule.TrafficType getTrafficType(){
+         return trafficType;
+     }
+ 
      public long getId() {
          return id;
      }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1b2b369e/api/src/com/cloud/host/Host.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1b2b369e/api/src/com/cloud/network/Network.java
----------------------------------------------------------------------
diff --cc api/src/com/cloud/network/Network.java
index ea6285c,413b6d9..df7a3da
--- a/api/src/com/cloud/network/Network.java
+++ b/api/src/com/cloud/network/Network.java
@@@ -48,8 -47,8 +48,8 @@@ public interface Network extends Contro
          public static final Service Dhcp = new Service("Dhcp");
          public static final Service Dns = new Service("Dns", Capability.AllowDnsSuffixModification);
          public static final Service Gateway = new Service("Gateway");
 -        public static final Service Firewall = new Service("Firewall", Capability.SupportedProtocols, 
 +        public static final Service Firewall = new Service("Firewall", Capability.SupportedProtocols,
-                 Capability.MultipleIps, Capability.TrafficStatistics);
+                 Capability.MultipleIps, Capability.TrafficStatistics, Capability.SupportedTrafficDirection, Capability.SupportedEgressProtocols);
          public static final Service Lb = new Service("Lb", Capability.SupportedLBAlgorithms, Capability.SupportedLBIsolation,
                  Capability.SupportedProtocols, Capability.TrafficStatistics, Capability.LoadBalancingSupportedIps,
                  Capability.SupportedStickinessMethods, Capability.ElasticLb);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1b2b369e/api/src/com/cloud/network/NetworkProfile.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1b2b369e/api/src/com/cloud/network/firewall/FirewallService.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1b2b369e/api/src/com/cloud/vm/UserVmService.java
----------------------------------------------------------------------
diff --cc api/src/com/cloud/vm/UserVmService.java
index af8c9f8,768ea95..fd9b0fc
--- a/api/src/com/cloud/vm/UserVmService.java
+++ b/api/src/com/cloud/vm/UserVmService.java
@@@ -22,20 -22,20 +22,24 @@@ import java.util.Map
  import javax.naming.InsufficientResourcesException;
  
  import org.apache.cloudstack.api.command.admin.vm.AssignVMCmd;
 +import org.apache.cloudstack.api.command.admin.vm.RecoverVMCmd;
  import org.apache.cloudstack.api.command.user.template.CreateTemplateCmd;
 -import org.apache.cloudstack.api.command.user.vm.*;
 -import org.apache.cloudstack.api.command.user.volume.AttachVolumeCmd;
 -import org.apache.cloudstack.api.command.user.vmgroup.CreateVMGroupCmd;
 -import org.apache.cloudstack.api.command.user.vmgroup.DeleteVMGroupCmd;
++import org.apache.cloudstack.api.command.user.vm.AddNicToVMCmd;
  import org.apache.cloudstack.api.command.user.vm.DeployVMCmd;
  import org.apache.cloudstack.api.command.user.vm.DestroyVMCmd;
 -import org.apache.cloudstack.api.command.user.volume.DetachVolumeCmd;
  import org.apache.cloudstack.api.command.user.vm.RebootVMCmd;
 -import org.apache.cloudstack.api.command.admin.vm.RecoverVMCmd;
++import org.apache.cloudstack.api.command.user.vm.RemoveNicFromVMCmd;
  import org.apache.cloudstack.api.command.user.vm.ResetVMPasswordCmd;
+ import org.apache.cloudstack.api.command.user.vm.ResetVMSSHKeyCmd;
  import org.apache.cloudstack.api.command.user.vm.RestoreVMCmd;
 +import org.apache.cloudstack.api.command.user.vm.StartVMCmd;
++import org.apache.cloudstack.api.command.user.vm.UpdateDefaultNicForVMCmd;
 +import org.apache.cloudstack.api.command.user.vm.UpdateVMCmd;
  import org.apache.cloudstack.api.command.user.vm.UpgradeVMCmd;
 +import org.apache.cloudstack.api.command.user.vmgroup.CreateVMGroupCmd;
 +import org.apache.cloudstack.api.command.user.vmgroup.DeleteVMGroupCmd;
 +import org.apache.cloudstack.api.command.user.volume.AttachVolumeCmd;
 +import org.apache.cloudstack.api.command.user.volume.DetachVolumeCmd;
  
  import com.cloud.dc.DataCenter;
  import com.cloud.exception.ConcurrentOperationException;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1b2b369e/api/src/org/apache/cloudstack/api/ApiConstants.java
----------------------------------------------------------------------
diff --cc api/src/org/apache/cloudstack/api/ApiConstants.java
index 4b80cb0,d242830..b80514d
mode 100644,100755..100755
--- a/api/src/org/apache/cloudstack/api/ApiConstants.java
+++ b/api/src/org/apache/cloudstack/api/ApiConstants.java

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1b2b369e/api/src/org/apache/cloudstack/api/BaseCmd.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1b2b369e/api/src/org/apache/cloudstack/api/command/user/firewall/CreateFirewallRuleCmd.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1b2b369e/api/src/org/apache/cloudstack/api/command/user/firewall/CreatePortForwardingRuleCmd.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1b2b369e/api/src/org/apache/cloudstack/api/command/user/firewall/ListFirewallRulesCmd.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1b2b369e/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1b2b369e/api/src/org/apache/cloudstack/api/command/user/nat/CreateIpForwardingRuleCmd.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1b2b369e/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1b2b369e/api/src/org/apache/cloudstack/api/command/user/vm/UpgradeVMCmd.java
----------------------------------------------------------------------
diff --cc api/src/org/apache/cloudstack/api/command/user/vm/UpgradeVMCmd.java
index 1efade8,0ab9a33..6719b8f
--- a/api/src/org/apache/cloudstack/api/command/user/vm/UpgradeVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vm/UpgradeVMCmd.java
@@@ -16,16 -16,13 +16,17 @@@
  // under the License.
  package org.apache.cloudstack.api.command.user.vm;
  
 -import org.apache.cloudstack.api.*;
 -import org.apache.log4j.Logger;
 -
  import org.apache.cloudstack.api.APICommand;
 -
 +import org.apache.cloudstack.api.ApiConstants;
 +import org.apache.cloudstack.api.ApiErrorCode;
 +import org.apache.cloudstack.api.BaseCmd;
 +import org.apache.cloudstack.api.Parameter;
 +import org.apache.cloudstack.api.ServerApiException;
 +import org.apache.cloudstack.api.response.DiskOfferingResponse;
+ import org.apache.cloudstack.api.response.ServiceOfferingResponse;
  import org.apache.cloudstack.api.response.UserVmResponse;
 +import org.apache.log4j.Logger;
 +
  import com.cloud.exception.InvalidParameterValueException;
  import com.cloud.offering.ServiceOffering;
  import com.cloud.user.Account;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1b2b369e/api/src/org/apache/cloudstack/api/response/FirewallResponse.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1b2b369e/api/src/org/apache/cloudstack/api/response/NicResponse.java
----------------------------------------------------------------------
diff --cc api/src/org/apache/cloudstack/api/response/NicResponse.java
index bfc488d,7e200ae..25131d2
--- a/api/src/org/apache/cloudstack/api/response/NicResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/NicResponse.java
@@@ -17,12 -17,14 +17,18 @@@
  package org.apache.cloudstack.api.response;
  
  import org.apache.cloudstack.api.ApiConstants;
 +import org.apache.cloudstack.api.BaseResponse;
 +
 +import com.cloud.serializer.Param;
 +import com.google.gson.annotations.SerializedName;
+ import com.cloud.vm.Nic;
+ import com.cloud.serializer.Param;
+ import com.google.gson.annotations.SerializedName;
+ import org.apache.cloudstack.api.BaseResponse;
+ import org.apache.cloudstack.api.EntityReference;
  
  @SuppressWarnings("unused")
+ @EntityReference(value=Nic.class)
  public class NicResponse extends BaseResponse {
  
      @SerializedName("id") @Param(description="the ID of the nic")

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1b2b369e/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
----------------------------------------------------------------------
diff --cc core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
index 6afaaea,05107e7..5354d89
--- a/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
+++ b/core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
@@@ -75,8 -76,8 +76,9 @@@ import com.cloud.agent.api.to.StaticNat
  import com.cloud.exception.InternalErrorException;
  import com.cloud.network.HAProxyConfigurator;
  import com.cloud.network.LoadBalancerConfigurator;
+ import com.cloud.network.rules.FirewallRule;
  import com.cloud.utils.NumbersUtil;
 +import com.cloud.utils.component.ComponentLifecycle;
  import com.cloud.utils.component.Manager;
  import com.cloud.utils.net.NetUtils;
  import com.cloud.utils.script.OutputInterpreter;
@@@ -219,7 -223,11 +224,11 @@@ public class VirtualRoutingResource imp
          final Script command = new Script(_firewallPath, _timeout, s_logger);
          command.add(routerIp);
          command.add("-F");
 -
 +        
+         if (trafficType == FirewallRule.TrafficType.Egress){
+             command.add("-E");
+         }
+ 
          StringBuilder sb = new StringBuilder();
          String[] fwRules = rules[0];
          if (fwRules.length > 0) {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1b2b369e/core/src/com/cloud/storage/resource/NfsSecondaryStorageResource.java
----------------------------------------------------------------------
diff --cc core/src/com/cloud/storage/resource/NfsSecondaryStorageResource.java
index 974a2db,a634c68..e65cbe1
--- a/core/src/com/cloud/storage/resource/NfsSecondaryStorageResource.java
+++ b/core/src/com/cloud/storage/resource/NfsSecondaryStorageResource.java
@@@ -394,23 -395,24 +394,24 @@@ SecondaryStorageResource 
              final String bucket = s3.getBucketName();
              putDirectory(s3, bucket, _storage.getFile(templatePath),
                      new FilenameFilter() {
 -                        @Override
 -                        public boolean accept(final File directory,
 -                                final String fileName) {
 +                @Override
 +                public boolean accept(final File directory,
 +                        final String fileName) {
-                     return !fileName.startsWith(".");
+                             File fileToUpload = new File(directory.getAbsolutePath() + "/" + fileName);
+                             return !fileName.startsWith(".") && !fileToUpload.isDirectory();
 -                        }
 -                    }, new ObjectNamingStrategy() {
 -                        @Override
 -                        public String determineKey(final File file) {
 -                            s_logger.debug(String
 -                                    .format("Determining key using account id %1$s and template id %2$s",
 -                                            accountId, templateId));
 -                            return join(
 -                                    asList(determineS3TemplateDirectory(
 -                                            accountId, templateId), file
 -                                            .getName()), S3Utils.SEPARATOR);
 -                        }
 -                    });
 +                }
 +            }, new ObjectNamingStrategy() {
 +                @Override
 +                public String determineKey(final File file) {
 +                    s_logger.debug(String
 +                            .format("Determining key using account id %1$s and template id %2$s",
 +                                    accountId, templateId));
 +                    return join(
 +                            asList(determineS3TemplateDirectory(
 +                                    accountId, templateId), file
 +                                    .getName()), S3Utils.SEPARATOR);
 +                }
 +            });
  
              return new Answer(
                      cmd,

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1b2b369e/docs/en-US/security-groups.xml
----------------------------------------------------------------------
diff --cc docs/en-US/security-groups.xml
index b6eecc3,00dbf5e..42f5319
--- a/docs/en-US/security-groups.xml
+++ b/docs/en-US/security-groups.xml
@@@ -23,15 -23,10 +23,11 @@@
  -->
  
  <section id="security-groups">
- <<<<<<< HEAD
-     <title>Using Security Groups to Control Traffic to VMs</title>
-     <xi:include href="about-security-groups.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
- =======
      <title>Security Groups</title>
      <xi:include href="about-security-groups.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
 +    <xi:include href="add-security-group.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
- >>>>>>> master
+     <xi:include href="security-groups-advanced-zones.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
      <xi:include href="enable-security-groups.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
 -    <xi:include href="add-security-group.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
 +    <xi:include href="add-security-group.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />    
      <xi:include href="add-ingress-egress-rules.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
  </section>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1b2b369e/docs/en-US/working-with-snapshots.xml
----------------------------------------------------------------------
diff --cc docs/en-US/working-with-snapshots.xml
index 82456dd,e7e4517..a381707
--- a/docs/en-US/working-with-snapshots.xml
+++ b/docs/en-US/working-with-snapshots.xml
@@@ -26,10 -27,7 +26,7 @@@
      <para>(Supported for the following hypervisors: <emphasis role="bold">XenServer</emphasis>, <emphasis role="bold">VMware vSphere</emphasis>, and <emphasis role="bold">KVM</emphasis>)</para>
      <para>&PRODUCT; supports snapshots of disk volumes. Snapshots are a point-in-time capture of virtual machine disks. Memory and CPU states are not captured. <!-- If you are using the Oracle VM hypervisor, you can not take snapshots, since OVM does not support them. --></para>
      <para>Snapshots may be taken for volumes, including both root and data disks. The administrator places a limit on the number of stored snapshots per user. Users can create new volumes from the snapshot for recovery of particular files and they can create templates from snapshots to boot from a restored disk.</para>
 -    <para>Users can create snapshots manually or by setting up automatic recurring snapshot policies. Users can also create disk volumes from snapshots, which may be attached to a VM like any other disk volume. Snapshots of both root disks and data disks are supported. However, &PRODUCT; does not currently support booting a VM from a recovered root disk. A disk recovered from snapshot of a root disk is treated as a regular data disk; the data on recovered disk can be accessed by attaching the disk to a VM.</para>
 -    <para>A completed snapshot is copied from primary storage to secondary storage, where it is stored until deleted or purged by newer snapshot.</para>
 +	<para>Users can create snapshots manually or by setting up automatic recurring snapshot policies. Users can also create disk volumes from snapshots, which may be attached to a VM like any other disk volume. Snapshots of both root disks and data disks are supported. However, &PRODUCT; does not currently support booting a VM from a recovered root disk. A disk recovered from snapshot of a root disk is treated as a regular data disk; the data on recovered disk can be accessed by attaching the disk to a VM.</para>
 +	<para>A completed snapshot is copied from primary storage to secondary storage, where it is stored until deleted or purged by newer snapshot.</para>
- 	<xi:include href="automatic-snapshot-creation-retention.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
- 	<xi:include href="incremental-snapshots-backup.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
- 	<xi:include href="volume-status.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
- 	<xi:include href="snapshot-restore.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+     <xi:include href="snapshot-throttling.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
  </section>

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1b2b369e/plugins/hypervisors/baremetal/src/com/cloud/baremetal/database/BaremetalCmdbDaoImpl.java
----------------------------------------------------------------------
diff --cc plugins/hypervisors/baremetal/src/com/cloud/baremetal/database/BaremetalCmdbDaoImpl.java
index 0000000,fcc95ef..5a882f1
mode 000000,100755..100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/database/BaremetalCmdbDaoImpl.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/database/BaremetalCmdbDaoImpl.java
@@@ -1,0 -1,29 +1,32 @@@
+ // 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.
+ // 
+ // Automatically generated by addcopyright.py at 01/29/2013
+ package com.cloud.baremetal.database;
+ 
+ import javax.ejb.Local;
++
++import org.springframework.stereotype.Component;
+ 
+ import com.cloud.utils.db.DB;
+ import com.cloud.utils.db.GenericDaoBase;
++@Component
+ @Local(value = {BaremetalCmdbDao.class})
+ @DB(txn = false)
+ public class BaremetalCmdbDaoImpl extends GenericDaoBase<BaremetalCmdbVO, Long> implements BaremetalCmdbDao {
+ 
+ }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1b2b369e/plugins/hypervisors/baremetal/src/com/cloud/baremetal/database/BaremetalDhcpDaoImpl.java
----------------------------------------------------------------------
diff --cc plugins/hypervisors/baremetal/src/com/cloud/baremetal/database/BaremetalDhcpDaoImpl.java
index 0000000,3d9c6de..8123ee0
mode 000000,100644..100644
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/database/BaremetalDhcpDaoImpl.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/database/BaremetalDhcpDaoImpl.java
@@@ -1,0 -1,42 +1,45 @@@
+ // 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.
+ // 
+ // Automatically generated by addcopyright.py at 01/29/2013
+ package com.cloud.baremetal.database;
+ 
+ import java.util.List;
+ import java.util.Map;
+ 
+ import javax.ejb.Local;
+ import javax.naming.ConfigurationException;
+ 
++import org.springframework.stereotype.Component;
++
+ import com.cloud.utils.db.DB;
+ import com.cloud.utils.db.Filter;
+ import com.cloud.utils.db.GenericDaoBase;
+ import com.cloud.utils.db.GenericSearchBuilder;
+ import com.cloud.utils.db.SearchBuilder;
+ import com.cloud.utils.db.SearchCriteria;
+ import com.cloud.utils.db.SearchCriteria2;
+ 
++@Component
+ @Local(value=BaremetalDhcpDao.class)
+ @DB(txn=false)
+ public class BaremetalDhcpDaoImpl extends GenericDaoBase<BaremetalDhcpVO, Long> implements BaremetalDhcpDao {
+ 
+     public BaremetalDhcpDaoImpl() {
+     }
+     
+ }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1b2b369e/plugins/hypervisors/baremetal/src/com/cloud/baremetal/database/BaremetalPxeDaoImpl.java
----------------------------------------------------------------------
diff --cc plugins/hypervisors/baremetal/src/com/cloud/baremetal/database/BaremetalPxeDaoImpl.java
index 0000000,c47d6b2..acd7f13
mode 000000,100644..100644
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/database/BaremetalPxeDaoImpl.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/database/BaremetalPxeDaoImpl.java
@@@ -1,0 -1,38 +1,41 @@@
+ // 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.
+ // 
+ // Automatically generated by addcopyright.py at 01/29/2013
+ package com.cloud.baremetal.database;
+ 
+ import java.util.List;
+ import java.util.Map;
+ 
+ import javax.ejb.Local;
+ import javax.naming.ConfigurationException;
+ 
++import org.springframework.stereotype.Component;
++
+ import com.cloud.utils.db.DB;
+ import com.cloud.utils.db.Filter;
+ import com.cloud.utils.db.GenericDaoBase;
+ import com.cloud.utils.db.GenericSearchBuilder;
+ import com.cloud.utils.db.SearchBuilder;
+ import com.cloud.utils.db.SearchCriteria;
+ import com.cloud.utils.db.SearchCriteria2;
+ 
++@Component
+ @Local(value = {BaremetalPxeDao.class})
+ @DB(txn = false)
+ public class BaremetalPxeDaoImpl extends GenericDaoBase<BaremetalPxeVO, Long> implements BaremetalPxeDao {
+ }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1b2b369e/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BareMetalDiscoverer.java
----------------------------------------------------------------------
diff --cc plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BareMetalDiscoverer.java
index 0000000,64eeaea..9b0a510
mode 000000,100755..100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BareMetalDiscoverer.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BareMetalDiscoverer.java
@@@ -1,0 -1,280 +1,280 @@@
+ // 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.
+ // 
+ // Automatically generated by addcopyright.py at 01/29/2013
+ // Apache License, Version 2.0 (the "License"); you may not use this
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ // 
+ // Automatically generated by addcopyright.py at 04/03/2012
+ package com.cloud.baremetal.manager;
+ 
+ import java.net.InetAddress;
+ import java.net.URI;
+ import java.util.HashMap;
+ import java.util.List;
+ import java.util.Map;
+ import java.util.UUID;
+ 
+ import javax.ejb.Local;
++import javax.inject.Inject;
+ import javax.naming.ConfigurationException;
+ 
+ import org.apache.cloudstack.api.ApiConstants;
+ import org.apache.log4j.Logger;
+ 
+ import com.cloud.agent.api.StartupCommand;
+ import com.cloud.agent.api.StartupRoutingCommand;
+ import com.cloud.baremetal.networkservice.BareMetalResourceBase;
+ import com.cloud.configuration.Config;
+ import com.cloud.configuration.dao.ConfigurationDao;
+ import com.cloud.dc.ClusterVO;
+ import com.cloud.dc.DataCenterVO;
+ import com.cloud.dc.dao.ClusterDao;
+ import com.cloud.dc.dao.DataCenterDao;
+ import com.cloud.exception.DiscoveryException;
+ import com.cloud.host.Host;
+ import com.cloud.host.HostVO;
+ import com.cloud.host.dao.HostDao;
+ import com.cloud.hypervisor.Hypervisor;
+ import com.cloud.hypervisor.Hypervisor.HypervisorType;
+ import com.cloud.network.Network;
+ import com.cloud.resource.Discoverer;
+ import com.cloud.resource.DiscovererBase;
+ import com.cloud.resource.ResourceManager;
+ import com.cloud.resource.ResourceStateAdapter;
+ import com.cloud.resource.ServerResource;
+ import com.cloud.resource.UnableDeleteHostException;
 -import com.cloud.utils.component.Inject;
+ import com.cloud.utils.exception.CloudRuntimeException;
+ 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.State;
+ import com.cloud.vm.dao.VMInstanceDao;
+ 
+ @Local(value=Discoverer.class)
+ public class BareMetalDiscoverer extends DiscovererBase implements Discoverer, ResourceStateAdapter {
+ 	protected static final Logger s_logger = Logger.getLogger(BareMetalDiscoverer.class);
+ 	@Inject protected ClusterDao _clusterDao;
+ 	@Inject protected HostDao _hostDao;
+ 	@Inject protected DataCenterDao _dcDao;
+     @Inject protected VMInstanceDao _vmDao = null;
+     @Inject protected ResourceManager _resourceMgr;
+     @Inject protected ConfigurationDao _configDao;
+ 	
+     @Override
+     public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
+     	_resourceMgr.registerResourceStateAdapter(this.getClass().getSimpleName(), this);
+     	return super.configure(name, params);
+     }
+     
+     @Override
+     public boolean stop() {
+     	_resourceMgr.unregisterResourceStateAdapter(this.getClass().getSimpleName());
+         return super.stop();
+     }
+     
+ 	@Override
+ 	public Map<? extends ServerResource, Map<String, String>> find(long dcId, Long podId, Long clusterId, URI url, String username, String password, List<String> hostTags)
+ 			throws DiscoveryException {
+ 	    
+ 	    String discoverName = _params.get(ApiConstants.BAREMETAL_DISCOVER_NAME);
+ 	    if (!this.getClass().getName().equals(discoverName)) {
+ 	        return null;
+ 	    }
+ 	    
+ 		Map<BareMetalResourceBase, Map<String, String>> resources = new HashMap<BareMetalResourceBase, Map<String, String>>();
+ 		Map<String, String> details = new HashMap<String, String>();
+ 		        
+ 		if (!url.getScheme().equals("http")) {
+ 			String msg = "urlString is not http so we're not taking care of the discovery for this: " + url;
+ 			s_logger.debug(msg);
+ 			return null;
+ 		}
+ 		if (clusterId == null) {
+ 			String msg = "must specify cluster Id when add host";
+ 			s_logger.debug(msg);
+ 			throw new RuntimeException(msg);
+ 		}
+ 
+ 		if (podId == null) {
+ 			String msg = "must specify pod Id when add host";
+ 			s_logger.debug(msg);
+ 			throw new RuntimeException(msg);
+ 		}
+ 		
+ 		ClusterVO cluster = _clusterDao.findById(clusterId);
+ 		if (cluster == null || (cluster.getHypervisorType() != HypervisorType.BareMetal)) {
+ 			if (s_logger.isInfoEnabled())
+ 				s_logger.info("invalid cluster id or cluster is not for Bare Metal hosts");
+ 			return null;
+ 		}
+ 		
+ 		DataCenterVO zone = _dcDao.findById(dcId);
+ 		if (zone == null) {
+ 			throw new RuntimeException("Cannot find zone " + dcId);
+ 		}
+ 
+ 		try {
+ 			String hostname = url.getHost();
+ 			InetAddress ia = InetAddress.getByName(hostname);
+ 			String ipmiIp = ia.getHostAddress();
+ 			String guid = UUID.nameUUIDFromBytes(ipmiIp.getBytes()).toString();
+ 			
+ 			String injectScript = "scripts/util/ipmi.py";
+ 			String scriptPath = Script.findScript("", injectScript);
+ 			if (scriptPath == null) {
+ 				throw new CloudRuntimeException("Unable to find key ipmi script "
+ 						+ injectScript);
+ 			}
+ 
+ 			final Script2 command = new Script2(scriptPath, s_logger);
+ 			command.add("ping");
+ 			command.add("hostname="+ipmiIp);
+ 			command.add("usrname="+username);
+ 			command.add("password="+password, ParamType.PASSWORD);
+ 			final String result = command.execute();
+ 			if (result != null) {
+ 				s_logger.warn(String.format("Can not set up ipmi connection(ip=%1$s, username=%2$s, password=%3$s, args) because %4$s", ipmiIp, username, "******", result));
+ 				return null;
+ 			}
+ 			
+ 			ClusterVO clu = _clusterDao.findById(clusterId);
+ 			if (clu.getGuid() == null) {
+ 				clu.setGuid(UUID.randomUUID().toString());
+ 				_clusterDao.update(clusterId, clu);
+ 			}
+ 			
+ 			Map<String, Object> params = new HashMap<String, Object>();
+ 			params.putAll(_params);
+ 			params.put("zone", Long.toString(dcId));
+ 			params.put("pod", Long.toString(podId));
+ 			params.put("cluster",  Long.toString(clusterId));
+ 			params.put("guid", guid); 
+ 			params.put(ApiConstants.PRIVATE_IP, ipmiIp);
+ 			params.put(ApiConstants.USERNAME, username);
+ 			params.put(ApiConstants.PASSWORD, password);
+ 			
+ 			String resourceClassName = _configDao.getValue(Config.ExternalBaremetalResourceClassName.key());
+ 			BareMetalResourceBase resource = null;
+ 			if (resourceClassName != null) {
+ 			    Class<?> clazz = Class.forName(resourceClassName);
+ 			    resource = (BareMetalResourceBase) clazz.newInstance();
+ 			    String externalUrl = _configDao.getValue(Config.ExternalBaremetalSystemUrl.key());
+ 			    if (externalUrl == null) {
+ 			        throw new IllegalArgumentException(String.format("You must specify ExternalBaremetalSystemUrl in global config page as ExternalBaremetalResourceClassName is not null"));
+ 			    }
+ 			    details.put(BaremetalManager.ExternalBaremetalSystemUrl, externalUrl);
+ 			} else {
+ 			    resource = new BareMetalResourceBase();
+ 			}
+ 			resource.configure("Bare Metal Agent", params);
+ 			
+ 			String memCapacity = (String)params.get(ApiConstants.MEMORY);
+ 			String cpuCapacity = (String)params.get(ApiConstants.CPU_SPEED);
+ 			String cpuNum = (String)params.get(ApiConstants.CPU_NUMBER);
+ 			String mac = (String)params.get(ApiConstants.HOST_MAC);
+ 			if (hostTags != null && hostTags.size() != 0) {
+ 			    details.put("hostTag", hostTags.get(0));
+ 			}
+ 			details.put(ApiConstants.MEMORY, memCapacity);
+ 			details.put(ApiConstants.CPU_SPEED, cpuCapacity);
+ 			details.put(ApiConstants.CPU_NUMBER, cpuNum);
+ 			details.put(ApiConstants.HOST_MAC, mac);
+ 			details.put(ApiConstants.USERNAME, username);
+ 			details.put(ApiConstants.PASSWORD, password);
+ 			details.put(ApiConstants.PRIVATE_IP, ipmiIp);
+ 			String vmIp = (String)params.get(ApiConstants.IP_ADDRESS);
+ 			if (vmIp != null) {
+ 			    details.put(ApiConstants.IP_ADDRESS, vmIp);
+ 			}
+ 			String isEchoScAgent = _configDao.getValue(Config.EnableBaremetalSecurityGroupAgentEcho.key());
+ 			details.put(BaremetalManager.EchoSecurityGroupAgent, isEchoScAgent);
+ 
+ 			resources.put(resource, details);
+ 			resource.start();
+ 			
+ 			zone.setGatewayProvider(Network.Provider.ExternalGateWay.getName());
+ 			zone.setDnsProvider(Network.Provider.ExternalDhcpServer.getName());
+ 			zone.setDhcpProvider(Network.Provider.ExternalDhcpServer.getName());	
+ 			_dcDao.update(zone.getId(), zone);
+ 			
+ 			s_logger.debug(String.format("Discover Bare Metal host successfully(ip=%1$s, username=%2$s, password=%3%s," +
+ 					"cpuNum=%4$s, cpuCapacity-%5$s, memCapacity=%6$s)", ipmiIp, username, "******", cpuNum, cpuCapacity, memCapacity));
+ 			return resources;
+ 		} catch (Exception e) {
+ 			s_logger.warn("Can not set up bare metal agent", e);
+ 		}
+ 
+ 		return null;
+ 	}
+ 
+ 	@Override
+ 	public void postDiscovery(List<HostVO> hosts, long msId)
+ 			throws DiscoveryException {
+ 	}
+ 
+ 	@Override
+ 	public boolean matchHypervisor(String hypervisor) {
+ 		return hypervisor.equalsIgnoreCase(Hypervisor.HypervisorType.BareMetal.toString());
+ 	}
+ 
+ 	@Override
+ 	public HypervisorType getHypervisorType() {
+ 		return Hypervisor.HypervisorType.BareMetal;
+ 	}
+ 
+ 	@Override
+     public HostVO createHostVOForConnectedAgent(HostVO host, StartupCommand[] cmd) {
+ 	    // TODO Auto-generated method stub
+ 	    return null;
+     }
+ 
+ 	@Override
+     public HostVO createHostVOForDirectConnectAgent(HostVO host, StartupCommand[] startup, ServerResource resource, Map<String, String> details,
+             List<String> hostTags) {
+ 		StartupCommand firstCmd = startup[0];
+ 		if (!(firstCmd instanceof StartupRoutingCommand)) {
+ 			return null;
+ 		}
+ 
+ 		StartupRoutingCommand ssCmd = ((StartupRoutingCommand) firstCmd);
+ 		if (ssCmd.getHypervisorType() != HypervisorType.BareMetal) {
+ 			return null;
+ 		}
+ 		
+ 		return _resourceMgr.fillRoutingHostVO(host, ssCmd, HypervisorType.BareMetal, details, hostTags);
+     }
+ 
+ 	@Override
+     public DeleteHostAnswer deleteHost(HostVO host, boolean isForced, boolean isForceDeleteStorage) throws UnableDeleteHostException {
+ 		if (host.getType() != Host.Type.Routing || host.getHypervisorType() != HypervisorType.BareMetal) {
+             return null;
+         }
+         
+         List<VMInstanceVO> deadVms = _vmDao.listByLastHostId(host.getId());
+         for (VMInstanceVO vm : deadVms) {
+             if (vm.getState() == State.Running || vm.getHostId() != null) {
+                 throw new CloudRuntimeException("VM " + vm.getId() + "is still running on host " + host.getId());
+             }
+             _vmDao.remove(vm.getId());
+         }
+         
+         return new DeleteHostAnswer(true);
+     }
+ 
+ }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1b2b369e/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BareMetalGuru.java
----------------------------------------------------------------------
diff --cc plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BareMetalGuru.java
index 0000000,b8a0af3..03ba3fa
mode 000000,100755..100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BareMetalGuru.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BareMetalGuru.java
@@@ -1,0 -1,87 +1,87 @@@
+ // 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.
+ // 
+ // Automatically generated by addcopyright.py at 01/29/2013
+ // Apache License, Version 2.0 (the "License"); you may not use this
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ // 
+ // Automatically generated by addcopyright.py at 04/03/2012
+ package com.cloud.baremetal.manager;
+ 
+ import java.util.HashMap;
+ import java.util.Map;
+ 
+ import javax.ejb.Local;
++import javax.inject.Inject;
+ 
+ import org.apache.log4j.Logger;
+ 
+ import com.cloud.agent.api.to.VirtualMachineTO;
+ import com.cloud.host.dao.HostDao;
+ import com.cloud.hypervisor.Hypervisor.HypervisorType;
+ import com.cloud.hypervisor.HypervisorGuru;
+ import com.cloud.hypervisor.HypervisorGuruBase;
+ import com.cloud.storage.GuestOSVO;
+ import com.cloud.storage.dao.GuestOSDao;
 -import com.cloud.utils.component.Inject;
+ import com.cloud.vm.VMInstanceVO;
+ import com.cloud.vm.VirtualMachine;
+ import com.cloud.vm.VirtualMachineProfile;
+ import com.cloud.vm.dao.VMInstanceDao;
+ 
+ @Local(value=HypervisorGuru.class)
+ public class BareMetalGuru extends HypervisorGuruBase implements HypervisorGuru {
+ 	private static final Logger s_logger = Logger.getLogger(BareMetalGuru.class);
+ 	@Inject GuestOSDao _guestOsDao;
+ 	@Inject HostDao _hostDao;
+ 	@Inject VMInstanceDao _vmDao;
+ 	
+ 	protected BareMetalGuru() {
+ 		super();
+ 	}
+ 	
+ 	@Override
+ 	public HypervisorType getHypervisorType() {
+ 		return HypervisorType.BareMetal;
+ 	}
+ 
+ 	@Override
+ 	public <T extends VirtualMachine> VirtualMachineTO implement(VirtualMachineProfile<T> vm) {
+ 		VirtualMachineTO to = toVirtualMachineTO(vm);
+ 
+ 		VMInstanceVO vo = _vmDao.findById(vm.getId());
+         if (vo.getLastHostId() == null) {
+             to.setBootArgs(BaremetalManager.DO_PXE);
+         }
+         
+         Map<String, String> details = new HashMap<String, String>();
+         details.put("template", vm.getTemplate().getUrl());
+         to.setDetails(details);
+         
+ 		// Determine the VM's OS description
+ 		GuestOSVO guestOS = _guestOsDao.findById(vm.getVirtualMachine().getGuestOSId());
+ 		to.setOs(guestOS.getDisplayName());
+ 
+ 		return to;
+ 	}
+ 	
+ 	@Override
+     public boolean trackVmHostChange() {
+     	return false;
+     }
+ }
+ 
+ 	

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1b2b369e/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BareMetalTemplateAdapter.java
----------------------------------------------------------------------
diff --cc plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BareMetalTemplateAdapter.java
index 0000000,15e63b9..ba5e811
mode 000000,100755..100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BareMetalTemplateAdapter.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BareMetalTemplateAdapter.java
@@@ -1,0 -1,217 +1,217 @@@
+ // 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.
+ // 
+ // Automatically generated by addcopyright.py at 01/29/2013
+ // Apache License, Version 2.0 (the "License"); you may not use this
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ // 
+ // Automatically generated by addcopyright.py at 04/03/2012
+ package com.cloud.baremetal.manager;
+ 
+ import java.util.Date;
+ import java.util.List;
+ 
+ import javax.ejb.Local;
++import javax.inject.Inject;
+ 
+ import org.apache.cloudstack.api.command.user.iso.DeleteIsoCmd;
+ import org.apache.cloudstack.api.command.user.iso.RegisterIsoCmd;
+ import org.apache.cloudstack.api.command.user.template.RegisterTemplateCmd;
+ import org.apache.log4j.Logger;
+ 
+ import com.cloud.configuration.Resource.ResourceType;
+ import com.cloud.dc.DataCenterVO;
+ import com.cloud.event.EventTypes;
+ import com.cloud.event.UsageEventVO;
+ import com.cloud.exception.ResourceAllocationException;
+ import com.cloud.host.Host;
+ import com.cloud.host.HostVO;
+ import com.cloud.host.dao.HostDao;
+ import com.cloud.resource.ResourceManager;
++import com.cloud.storage.TemplateProfile;
+ import com.cloud.storage.VMTemplateHostVO;
+ import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
+ import com.cloud.storage.VMTemplateVO;
+ import com.cloud.storage.VMTemplateZoneVO;
+ import com.cloud.template.TemplateAdapter;
+ import com.cloud.template.TemplateAdapterBase;
 -import com.cloud.template.TemplateProfile;
+ import com.cloud.user.Account;
 -import com.cloud.utils.component.Inject;
+ import com.cloud.utils.db.DB;
+ import com.cloud.utils.exception.CloudRuntimeException;
+ 
+ @Local(value=TemplateAdapter.class)
+ public class BareMetalTemplateAdapter extends TemplateAdapterBase implements TemplateAdapter {
+ 	private final static Logger s_logger = Logger.getLogger(BareMetalTemplateAdapter.class);
+ 	@Inject HostDao _hostDao;
+ 	@Inject ResourceManager _resourceMgr;
+ 	
+ 	@Override
+ 	public TemplateProfile prepare(RegisterTemplateCmd cmd) throws ResourceAllocationException {
+ 		TemplateProfile profile = super.prepare(cmd);
+ 		
+ 		if (profile.getZoneId() == null || profile.getZoneId() == -1) {
+ 			List<DataCenterVO> dcs = _dcDao.listAllIncludingRemoved();
+ 			for (DataCenterVO dc : dcs) {
+ 				List<HostVO> pxeServers = _resourceMgr.listAllHostsInOneZoneByType(Host.Type.BaremetalPxe, dc.getId());
+ 				if (pxeServers.size() == 0) {
+ 					throw new CloudRuntimeException("Please add PXE server before adding baremetal template in zone " + dc.getName());
+ 				}
+ 			}
+ 		} else {
+ 			List<HostVO> pxeServers = _resourceMgr.listAllHostsInOneZoneByType(Host.Type.BaremetalPxe, profile.getZoneId());
+ 			if (pxeServers.size() == 0) {
+ 				throw new CloudRuntimeException("Please add PXE server before adding baremetal template in zone " + profile.getZoneId());
+ 			}
+ 		}
+ 		
+ 		return profile;
+ 	}
+ 	
+ 	@Override
+ 	public TemplateProfile prepare(RegisterIsoCmd cmd) throws ResourceAllocationException {
+ 		throw new CloudRuntimeException("Baremetal doesn't support ISO template");
+ 	}
+ 	
+ 	private void templateCreateUsage(VMTemplateVO template, HostVO host) {
+ 		if (template.getAccountId() != Account.ACCOUNT_ID_SYSTEM) {
+ 			UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_TEMPLATE_CREATE, template.getAccountId(), host.getDataCenterId(),
+ 					template.getId(), template.getName(), null, template.getSourceTemplateId(), 0L);
+ 			_usageEventDao.persist(usageEvent);
+ 		}
+ 	}
+ 	
+ 	@Override
+ 	public VMTemplateVO create(TemplateProfile profile) {
+ 		VMTemplateVO template = persistTemplate(profile);
+ 		Long zoneId = profile.getZoneId();
+ 		
+ 		/* There is no secondary storage vm for baremetal, we use pxe server id.
+ 		 * Tempalte is not bound to pxeserver right now, and we assume the pxeserver
+ 		 * cannot be removed once it was added. so we use host id of first found pxe
+ 		 * server as reference in template_host_ref.
+ 		 * This maybe a FIXME in future.
+ 		 */
+ 		VMTemplateHostVO vmTemplateHost = null;
+ 		if (zoneId == null || zoneId == -1) {
+ 			List<DataCenterVO> dcs = _dcDao.listAllIncludingRemoved();
+ 			for (DataCenterVO dc : dcs) {
+ 				HostVO pxe = _resourceMgr.listAllHostsInOneZoneByType(Host.Type.BaremetalPxe, dc.getId()).get(0);
+ 
+ 				vmTemplateHost = _tmpltHostDao.findByHostTemplate(dc.getId(), template.getId());
+ 				if (vmTemplateHost == null) {
+ 					vmTemplateHost = new VMTemplateHostVO(pxe.getId(), template.getId(), new Date(), 100,
+ 							Status.DOWNLOADED, null, null, null, null, template.getUrl());
+ 					_tmpltHostDao.persist(vmTemplateHost);
+ 					templateCreateUsage(template, pxe);
+ 				}
+ 			}
+ 		} else {
+ 			HostVO pxe = _resourceMgr.listAllHostsInOneZoneByType(Host.Type.BaremetalPxe, zoneId).get(0);
+ 			vmTemplateHost = new VMTemplateHostVO(pxe.getId(), template.getId(), new Date(), 100,
+ 					Status.DOWNLOADED, null, null, null, null, template.getUrl());
+ 			_tmpltHostDao.persist(vmTemplateHost);
+ 			templateCreateUsage(template, pxe);
+ 		}
+ 		
+ 		_resourceLimitMgr.incrementResourceCount(profile.getAccountId(), ResourceType.template);
+ 		return template;
+ 	}
+ 
+ 	public TemplateProfile prepareDelete(DeleteIsoCmd cmd) {
+ 		throw new CloudRuntimeException("Baremetal doesn't support ISO, how the delete get here???");
+ 	}
+ 	
+ 	@Override @DB
+ 	public boolean delete(TemplateProfile profile) {
+ 		VMTemplateVO template = profile.getTemplate();
+     	Long templateId = template.getId();
+     	boolean success = true;
+     	String zoneName;
+     	boolean isAllZone;
+     	
+     	if (!template.isCrossZones() && profile.getZoneId() != null) {
+     		isAllZone = false;
+     		zoneName = profile.getZoneId().toString();
+     	} else {
+     		zoneName = "all zones";
+     		isAllZone = true;
+     	}
+     	
+     	s_logger.debug("Attempting to mark template host refs for template: " + template.getName() + " as destroyed in zone: " + zoneName);
+     	Account account = _accountDao.findByIdIncludingRemoved(template.getAccountId());
+     	String eventType = EventTypes.EVENT_TEMPLATE_DELETE;
+     	List<VMTemplateHostVO> templateHostVOs = _tmpltHostDao.listByTemplateId(templateId);
+     	
+ 		for (VMTemplateHostVO vo : templateHostVOs) {
+ 			VMTemplateHostVO lock = null;
+ 			try {
+ 				HostVO pxeServer = _hostDao.findById(vo.getHostId());
+ 				if (!isAllZone && pxeServer.getDataCenterId() != profile.getZoneId()) {
+ 					continue;
+ 				}
+ 
+ 				lock = _tmpltHostDao.acquireInLockTable(vo.getId());
+ 				if (lock == null) {
+ 					s_logger.debug("Failed to acquire lock when deleting templateHostVO with ID: " + vo.getId());
+ 					success = false;
+ 					break;
+ 				}
+ 
+ 				vo.setDestroyed(true);
+ 				_tmpltHostDao.update(vo.getId(), vo);
+ 				VMTemplateZoneVO templateZone = _tmpltZoneDao.findByZoneTemplate(pxeServer.getDataCenterId(), templateId);
+ 				if (templateZone != null) {
+ 					_tmpltZoneDao.remove(templateZone.getId());
+ 				}
+ 
+ 				UsageEventVO usageEvent = new UsageEventVO(eventType, account.getId(), pxeServer.getDataCenterId(), templateId, null);
+ 				_usageEventDao.persist(usageEvent);
+ 			} finally {
+ 				if (lock != null) {
+ 					_tmpltHostDao.releaseFromLockTable(lock.getId());
+ 				}
+ 			}
+ 		}
+     	
+     	s_logger.debug("Successfully marked template host refs for template: " + template.getName() + " as destroyed in zone: " + zoneName);
+ 	
+     	// If there are no more non-destroyed template host entries for this template, delete it
+ 		if (success && (_tmpltHostDao.listByTemplateId(templateId).size() == 0)) {
+ 			long accountId = template.getAccountId();
+ 			
+ 			VMTemplateVO lock = _tmpltDao.acquireInLockTable(templateId);
+ 
+ 			try {
+ 				if (lock == null) {
+ 					s_logger.debug("Failed to acquire lock when deleting template with ID: " + templateId);
+ 					success = false;
+ 				} else if (_tmpltDao.remove(templateId)) {
+ 					// Decrement the number of templates
+ 				    _resourceLimitMgr.decrementResourceCount(accountId, ResourceType.template);
+ 				}
+ 
+ 			} finally {
+ 				if (lock != null) {
+ 					_tmpltDao.releaseFromLockTable(lock.getId());
+ 				}
+ 			}
+ 			s_logger.debug("Removed template: " + template.getName() + " because all of its template host refs were marked as destroyed.");
+ 		}
+ 		
+     	return success;
+ 	}
+ }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1b2b369e/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManagerImpl.java
----------------------------------------------------------------------
diff --cc plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManagerImpl.java
index 0000000,5388864..b07a6bb
mode 000000,100755..100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManagerImpl.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManagerImpl.java
@@@ -1,0 -1,112 +1,113 @@@
+ // 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.
+ // 
+ // Automatically generated by addcopyright.py at 01/29/2013
+ package com.cloud.baremetal.manager;
+ 
+ import java.util.Map;
+ 
+ import javax.ejb.Local;
++import javax.inject.Inject;
+ import javax.naming.ConfigurationException;
+ 
+ import org.apache.log4j.Logger;
+ 
+ import com.cloud.agent.api.StopAnswer;
+ import com.cloud.agent.manager.Commands;
+ import com.cloud.deploy.DeployDestination;
+ import com.cloud.exception.ResourceUnavailableException;
+ import com.cloud.host.HostVO;
+ import com.cloud.host.dao.HostDao;
+ import com.cloud.hypervisor.Hypervisor.HypervisorType;
 -import com.cloud.utils.component.Inject;
++import com.cloud.utils.component.ManagerBase;
+ import com.cloud.utils.fsm.StateListener;
+ import com.cloud.vm.ReservationContext;
+ import com.cloud.vm.UserVmVO;
+ import com.cloud.vm.VirtualMachine;
+ import com.cloud.vm.VirtualMachineGuru;
+ import com.cloud.vm.VirtualMachineManager;
+ import com.cloud.vm.VirtualMachineName;
+ import com.cloud.vm.VirtualMachine.Event;
+ import com.cloud.vm.VirtualMachine.State;
+ import com.cloud.vm.dao.UserVmDao;
+ import com.cloud.vm.VirtualMachineProfile;
+ 
+ @Local(value = {BaremetalManager.class})
 -public class BaremetalManagerImpl implements BaremetalManager,  StateListener<State, VirtualMachine.Event, VirtualMachine> {
++public class BaremetalManagerImpl extends ManagerBase implements BaremetalManager,  StateListener<State, VirtualMachine.Event, VirtualMachine> {
+ 	private static final Logger s_logger = Logger.getLogger(BaremetalManagerImpl.class);
+ 	
+ 	@Inject
+ 	protected HostDao _hostDao;
+ 	
+ 	@Override
+ 	public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
+ 		VirtualMachine.State.getStateMachine().registerListener(this);
+ 		return true;
+ 	}
+ 
+ 	@Override
+ 	public boolean start() {
+ 		return true;
+ 	}
+ 
+ 	@Override
+ 	public boolean stop() {
+ 		return true;
+ 	}
+ 
+ 	@Override
+ 	public String getName() {
+ 		return "Baremetal Manager";
+ 	}
+ 
+ 	@Override
+     public boolean preStateTransitionEvent(State oldState, Event event, State newState, VirtualMachine vo, boolean status, Object opaque) {
+ 	    return false;
+     }
+ 
+ 	@Override
+     public boolean postStateTransitionEvent(State oldState, Event event, State newState, VirtualMachine vo, boolean status, Object opaque) {
+ 		if (newState != State.Starting && newState != State.Error && newState != State.Expunging) {
+ 			return true;
+ 		}
+ 		
+ 		if (vo.getHypervisorType() != HypervisorType.BareMetal) {
+ 		    return true;
+ 		}
+ 		
+ 		HostVO host = _hostDao.findById(vo.getHostId());
+ 		if (host == null) {
+ 			s_logger.debug("Skip oldState " + oldState + " to " + "newState " + newState + " transimtion");
+ 			return true;
+ 		}
+ 		_hostDao.loadDetails(host);
+ 		
+ 		if (newState == State.Starting) {
+ 			host.setDetail("vmName", vo.getInstanceName());
+ 			s_logger.debug("Add vmName " + host.getDetail("vmName") + " to host " + host.getId() + " details");
+ 		} else {
+ 			if (host.getDetail("vmName") != null && host.getDetail("vmName").equalsIgnoreCase(vo.getInstanceName())) {
+ 				s_logger.debug("Remove vmName " + host.getDetail("vmName") + " from host " + host.getId() + " details");
+ 				host.getDetails().remove("vmName");
+ 			}
+ 		}
+ 		_hostDao.saveDetails(host);
+ 		
+ 		
+ 		return true;
+     }
+ }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1b2b369e/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/AddBaremetalDhcpCmd.java
----------------------------------------------------------------------
diff --cc plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/AddBaremetalDhcpCmd.java
index 0000000,6a26fe2..8a3d4d7
mode 000000,100755..100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/AddBaremetalDhcpCmd.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/AddBaremetalDhcpCmd.java
@@@ -1,0 -1,149 +1,150 @@@
+ // 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.
+ // 
+ // Automatically generated by addcopyright.py at 01/29/2013
+ package com.cloud.baremetal.networkservice;
+ 
++import javax.inject.Inject;
++
+ import org.apache.cloudstack.api.ApiConstants;
+ 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.Parameter;
 -import org.apache.cloudstack.api.PlugService;
+ import org.apache.cloudstack.api.ServerApiException;
+ import org.apache.log4j.Logger;
+ 
+ import com.cloud.baremetal.database.BaremetalDhcpVO;
+ 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 com.cloud.user.UserContext;
+ 
+ public class AddBaremetalDhcpCmd extends BaseAsyncCmd {
+     private static final String s_name = "addexternaldhcpresponse";
+     public static final Logger s_logger = Logger.getLogger(AddBaremetalDhcpCmd.class);
+     
 -    @PlugService BaremetalDhcpManager mgr;
++    @Inject BaremetalDhcpManager mgr;
+     
+     /////////////////////////////////////////////////////
+     //////////////// API parameters /////////////////////
+     /////////////////////////////////////////////////////
+     @Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.LONG, required=true, description="the Physical Network ID")
+     private Long physicalNetworkId;
+     
+     @Parameter(name=ApiConstants.POD_ID, type=CommandType.LONG, required = true, description="Pod Id")
+     private Long podId;
+     
+     @Parameter(name=ApiConstants.DHCP_SERVER_TYPE, type=CommandType.STRING, required = true, description="Type of dhcp device")
+     private String dhcpType;
+     
+     @Parameter(name=ApiConstants.URL, type=CommandType.STRING, required = true, description="URL of the external dhcp appliance.")
+     private String url;
+ 
+     @Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, required = true, description="Credentials to reach external dhcp device")
+     private String username;
+     
+     @Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, required = true, description="Credentials to reach external dhcp device")
+     private String password;
+     
+     @Override
+     public String getEventType() {
+         return EventTypes.EVENT_BAREMETAL_DHCP_SERVER_ADD;
+     }
+ 
+     @Override
+     public String getEventDescription() {
+         return "Adding an external DHCP server";
+     }
+ 
+     @Override
+     public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
+             ResourceAllocationException, NetworkRuleConflictException {
+         try {
+             BaremetalDhcpVO vo = mgr.addDchpServer(this);
+             BaremetalDhcpResponse response = mgr.generateApiResponse(vo);
+             response.setObjectName(s_name);
+             response.setResponseName(getCommandName());
+             this.setResponseObject(response);
+         } catch (Exception e) {
+             s_logger.warn("Unable to add external dhcp server with url: " + getUrl(), e);
+             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
+         }
+     }
+ 
+     @Override
+     public String getCommandName() {
+         return s_name;
+     }
+ 
+     @Override
+     public long getEntityOwnerId() {
+         return UserContext.current().getCaller().getId();
+     }
+ 
+     public Long getPodId() {
+         return podId;
+     }
+ 
+     public void setPodId(Long podId) {
+         this.podId = podId;
+     }
+ 
+     public String getDhcpType() {
+         return dhcpType;
+     }
+ 
+     public void setDhcpType(String dhcpType) {
+         this.dhcpType = dhcpType;
+     }
+ 
+     public String getUrl() {
+         return url;
+     }
+ 
+     public void setUrl(String url) {
+         this.url = url;
+     }
+ 
+     public String getUsername() {
+         return username;
+     }
+ 
+     public void setUsername(String username) {
+         this.username = username;
+     }
+ 
+     public String getPassword() {
+         return password;
+     }
+ 
+     public void setPassword(String password) {
+         this.password = password;
+     }
+ 
+     public Long getPhysicalNetworkId() {
+         return physicalNetworkId;
+     }
+ 
+     public void setPhysicalNetworkId(Long physicalNetworkId) {
+         this.physicalNetworkId = physicalNetworkId;
+     }
+ }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1b2b369e/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/AddBaremetalPxeCmd.java
----------------------------------------------------------------------
diff --cc plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/AddBaremetalPxeCmd.java
index 0000000,a1d72a3..cd8da4a
mode 000000,100755..100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/AddBaremetalPxeCmd.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/AddBaremetalPxeCmd.java
@@@ -1,0 -1,144 +1,145 @@@
+ // 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.
+ // 
+ // Automatically generated by addcopyright.py at 01/29/2013
+ package com.cloud.baremetal.networkservice;
+ 
++import javax.inject.Inject;
++
+ import org.apache.cloudstack.api.ApiConstants;
+ 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.Parameter;
 -import org.apache.cloudstack.api.PlugService;
+ import org.apache.cloudstack.api.ServerApiException;
+ import org.apache.log4j.Logger;
+ 
+ import com.cloud.baremetal.database.BaremetalPxeVO;
+ 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 com.cloud.user.UserContext;
+ 
+ public class AddBaremetalPxeCmd extends BaseAsyncCmd {
+     private static final String s_name = "addexternalpxeresponse";
+     public static final Logger s_logger = Logger.getLogger(AddBaremetalPxeCmd.class);
+     
 -    @PlugService BaremetalPxeManager pxeMgr;
++    @Inject BaremetalPxeManager pxeMgr;
+     /////////////////////////////////////////////////////
+     //////////////// API parameters /////////////////////
+     /////////////////////////////////////////////////////
+     @Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.LONG, required=true, description="the Physical Network ID")
+     private Long physicalNetworkId;
+     
+     @Parameter(name=ApiConstants.POD_ID, type=CommandType.LONG, description="Pod Id")
+     private Long podId;
+     
+     @Parameter(name=ApiConstants.URL, type=CommandType.STRING, required = true, description="URL of the external pxe device")
+     private String url;
+ 
+     @Parameter(name=ApiConstants.PXE_SERVER_TYPE, type=CommandType.STRING, required = true, description="type of pxe device")
+     private String deviceType;
+     
+     @Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, required = true, description="Credentials to reach external pxe device")
+     private String username;
+     
+     @Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, required = true, description="Credentials to reach external pxe device")
+     private String password;
+     
+     @Override
+     public String getEventType() {
+         return EventTypes.EVENT_BAREMETAL_PXE_SERVER_ADD;
+     }
+ 
+     @Override
+     public String getEventDescription() {
+         return "Adding an external pxe server";
+     }
+ 
+     @Override
+     public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
+             ResourceAllocationException, NetworkRuleConflictException {
+         try {
+             BaremetalPxeVO vo = pxeMgr.addPxeServer(this);
+         } catch (Exception e) {
+             s_logger.warn("Unable to add external pxe server with url: " + getUrl(), e);
+             throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage()); 
+         }
+     }
+ 
+     @Override
+     public String getCommandName() {
+         return s_name;
+     }
+ 
+     @Override
+     public long getEntityOwnerId() {
+         return UserContext.current().getCaller().getId();
+     }
+ 
+     public Long getPhysicalNetworkId() {
+         return physicalNetworkId;
+     }
+ 
+     public void setPhysicalNetworkId(Long physicalNetworkId) {
+         this.physicalNetworkId = physicalNetworkId;
+     }
+ 
+     public Long getPodId() {
+         return podId;
+     }
+ 
+     public void setPodId(Long podId) {
+         this.podId = podId;
+     }
+ 
+     public String getUrl() {
+         return url;
+     }
+ 
+     public void setUrl(String url) {
+         this.url = url;
+     }
+ 
+     public String getUsername() {
+         return username;
+     }
+ 
+     public void setUsername(String username) {
+         this.username = username;
+     }
+ 
+     public String getPassword() {
+         return password;
+     }
+ 
+     public void setPassword(String password) {
+         this.password = password;
+     }
+ 
+     public String getDeviceType() {
+         return deviceType;
+     }
+ 
+     public void setDeviceType(String deviceType) {
+         this.deviceType = deviceType;
+     }
+ }


Mime
View raw message