You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ed...@apache.org on 2012/06/21 19:07:53 UTC

git commit: CS-15281: Removal of third party dependencies in Citrix code base.

Updated Branches:
  refs/heads/master 3412ce734 -> e7995d09d


 CS-15281: Removal of third party dependencies in Citrix code base.

[Problem]
CloudStack uses a significant amount of third party software.  As part of the move to ASF there is a certain set of licenses that are compatible with ASF policy.  We need to make sure that every dependency we have is in that set. If it's not we have to remove it.

[Solution]
First set: Removing JnetPcap.

[Reviewers]
Edison Su, David Nalley

[Testing]
    [Test Cases]
     Executed ANT build-all sucessfully after removing JnetPcap and its respective dependencies.

    [Platform]
     Fedora release

Signed-off-by: Pradeep <pr...@citrix.com>


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

Branch: refs/heads/master
Commit: e7995d09dce78434cce530b0428bcf69f00ff066
Parents: 3412ce7
Author: Edison Su <su...@gmail.com>
Authored: Thu Jun 21 10:03:37 2012 -0700
Committer: Edison Su <su...@gmail.com>
Committed: Thu Jun 21 10:03:37 2012 -0700

----------------------------------------------------------------------
 .../src/com/cloud/agent/dhcp/DhcpPacketParser.java |  272 ------------
 .../src/com/cloud/agent/dhcp/DhcpSnooperImpl.java  |  324 ---------------
 .../computing/CloudZonesComputingResource.java     |  293 -------------
 .../storage/template/HttpTemplateDownloader.java   |    1 -
 4 files changed, 0 insertions(+), 890 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e7995d09/agent/src/com/cloud/agent/dhcp/DhcpPacketParser.java
----------------------------------------------------------------------
diff --git a/agent/src/com/cloud/agent/dhcp/DhcpPacketParser.java b/agent/src/com/cloud/agent/dhcp/DhcpPacketParser.java
deleted file mode 100644
index c25d390..0000000
--- a/agent/src/com/cloud/agent/dhcp/DhcpPacketParser.java
+++ /dev/null
@@ -1,272 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.agent.dhcp;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Formatter;
-
-import org.apache.log4j.Logger;
-import org.jnetpcap.packet.JMemoryPacket;
-import org.jnetpcap.packet.JPacket;
-import org.jnetpcap.packet.PcapPacket;
-import org.jnetpcap.protocol.lan.Ethernet;
-import org.jnetpcap.protocol.lan.IEEE802dot1q;
-import org.jnetpcap.protocol.network.Ip4;
-import org.jnetpcap.protocol.tcpip.Udp;
-
-import com.cloud.agent.dhcp.DhcpSnooperImpl.DHCPState;
-
-public class DhcpPacketParser implements Runnable {
-	private static final Logger s_logger = Logger
-			.getLogger(DhcpPacketParser.class);
-
-	private enum DHCPPACKET {
-		OP(0), HTYPE(1), HLEN(2), HOPS(3), XID(4), SECS(8), FLAGS(10), CIADDR(
-				12), YIADDR(16), SIDADDR(20), GIADDR(24), CHADDR(28), SNAME(44), FILE(
-				108), MAGIC(236), OPTIONS(240);
-		int offset;
-
-		DHCPPACKET(int i) {
-			offset = i;
-		}
-
-		int getValue() {
-			return offset;
-		}
-	}
-
-	private enum DHCPOPTIONTYPE {
-		PAD(0), MESSAGETYPE(53), REQUESTEDIP(50), END(255);
-		int type;
-
-		DHCPOPTIONTYPE(int i) {
-			type = i;
-		}
-
-		int getValue() {
-			return type;
-		}
-	}
-
-	private enum DHCPMSGTYPE {
-		DHCPDISCOVER(1), DHCPOFFER(2), DHCPREQUEST(3), DHCPDECLINE(4), DHCPACK(
-				5), DHCPNAK(6), DHCPRELEASE(7), DHCPINFORM(8);
-		int _type;
-
-		DHCPMSGTYPE(int type) {
-			_type = type;
-		}
-
-		int getValue() {
-			return _type;
-		}
-
-		public static DHCPMSGTYPE valueOf(int type) {
-			for (DHCPMSGTYPE t : values()) {
-				if (type == t.getValue()) {
-					return t;
-				}
-			}
-			return null;
-		}
-	}
-
-	private class DHCPMSG {
-		DHCPMSGTYPE msgType;
-		byte[] caddr;
-		byte[] yaddr;
-		byte[] chaddr;
-		byte[] requestedIP;
-
-		public DHCPMSG() {
-			caddr = new byte[4];
-			yaddr = new byte[4];
-			chaddr = new byte[6];
-		}
-	}
-
-	private PcapPacket _buffer;
-	private int _offset;
-	private int _len;
-	private DhcpSnooperImpl _manager;
-
-	public DhcpPacketParser(PcapPacket buffer, int offset, int len,
-			DhcpSnooperImpl manager) {
-		_buffer = buffer;
-		_offset = offset;
-		_len = len;
-		_manager = manager;
-	}
-
-	private int getPos(int pos) {
-		return _offset + pos;
-	}
-
-	private byte getByte(int offset) {
-		return _buffer.getByte(getPos(offset));
-	}
-
-	private void getByteArray(int offset, byte[] array) {
-		_buffer.getByteArray(getPos(offset), array);
-	}
-
-	private long getUInt(int offset) {
-		return _buffer.getUInt(getPos(offset));
-	}
-
-	private DHCPMSG getDhcpMsg() {
-		long magic = getUInt(DHCPPACKET.MAGIC.getValue());
-		if (magic != 0x63538263) {
-			return null;
-		}
-
-		DHCPMSG msg = new DHCPMSG();
-
-		int pos = DHCPPACKET.OPTIONS.getValue();
-		while (pos <= _len) {
-			int type = (int) getByte(pos++) & 0xff;
-
-			if (type == DHCPOPTIONTYPE.END.getValue()) {
-				break;
-			}
-			if (type == DHCPOPTIONTYPE.PAD.getValue()) {
-				continue;
-			}
-			int len = 0;
-			if (pos <= _len) {
-				len = ((int) getByte(pos++)) & 0xff;
-			}
-
-			if (type == DHCPOPTIONTYPE.MESSAGETYPE.getValue()
-					|| type == DHCPOPTIONTYPE.REQUESTEDIP.getValue()) {
-				/* Read data only if needed */
-				byte[] data = null;
-				if ((len + pos) <= _len) {
-					data = new byte[len];
-					getByteArray(pos, data);
-				}
-
-				if (type == DHCPOPTIONTYPE.MESSAGETYPE.getValue()) {
-					msg.msgType = DHCPMSGTYPE.valueOf((int) data[0]);
-				} else if (type == DHCPOPTIONTYPE.REQUESTEDIP.getValue()) {
-					msg.requestedIP = data;
-				}
-			}
-
-			pos += len;
-		}
-
-		if (msg.msgType == DHCPMSGTYPE.DHCPREQUEST) {
-			getByteArray(DHCPPACKET.CHADDR.getValue(), msg.chaddr);
-			getByteArray(DHCPPACKET.CIADDR.getValue(), msg.caddr);
-		} else if (msg.msgType == DHCPMSGTYPE.DHCPACK) {
-			getByteArray(DHCPPACKET.YIADDR.getValue(), msg.yaddr);
-		}
-		return msg;
-	}
-
-	private String formatMacAddress(byte[] mac) {
-		StringBuffer sb = new StringBuffer();
-		Formatter formatter = new Formatter(sb);
-		for (int i = 0; i < mac.length; i++) {
-			formatter.format("%02X%s", mac[i], (i < mac.length - 1) ? ":" : "");
-		}
-		return sb.toString();
-	}
-
-	private String getDestMacAddress() {
-		Ethernet ether = new Ethernet();
-		if (_buffer.hasHeader(ether)) {
-			byte[] destMac = ether.destination();
-			return formatMacAddress(destMac);
-		}
-		return null;
-	}
-
-	private InetAddress getDHCPServerIP() {
-		Ip4 ip = new Ip4();
-		if (_buffer.hasHeader(ip)) {
-			try {
-				return InetAddress.getByAddress(ip.source());
-			} catch (UnknownHostException e) {
-				s_logger.debug("Failed to get dhcp server ip address: "
-						+ e.toString());
-			}
-		}
-		return null;
-	}
-
-	@Override
-	public void run() {
-		DHCPMSG msg = getDhcpMsg();
-
-		if (msg == null) {
-			return;
-		}
-
-		if (msg.msgType == DHCPMSGTYPE.DHCPACK) {
-			InetAddress ip = null;
-			try {
-				ip = InetAddress.getByAddress(msg.yaddr);
-				String macAddr = getDestMacAddress();
-				_manager.setIPAddr(macAddr, ip, DHCPState.DHCPACKED,
-						getDHCPServerIP());
-			} catch (UnknownHostException e) {
-
-			}
-		} else if (msg.msgType == DHCPMSGTYPE.DHCPREQUEST) {
-			InetAddress ip = null;
-			if (msg.requestedIP != null) {
-				try {
-					ip = InetAddress.getByAddress(msg.requestedIP);
-				} catch (UnknownHostException e) {
-				}
-			}
-			if (ip == null) {
-				try {
-					ip = InetAddress.getByAddress(msg.caddr);
-				} catch (UnknownHostException e) {
-				}
-			}
-
-			if (ip != null) {
-				String macAddr = formatMacAddress(msg.chaddr);
-				_manager.setIPAddr(macAddr, ip, DHCPState.DHCPREQUESTED, null);
-			}
-		}
-
-	}
-
-	private void test() {
-		JPacket packet = new JMemoryPacket(
-				Ethernet.ID,
-				"      06fa 8800 00b3 0656 d200 0027 8100 001a 0800 4500 0156 64bf 0000 4011 f3f2 ac1a 6412 ac1a 649e 0043 0044 0001 0000 0001");
-		Ethernet eth = new Ethernet();
-		if (packet.hasHeader(eth)) {
-			System.out.print(" ether:" + eth);
-		}
-		IEEE802dot1q vlan = new IEEE802dot1q();
-		if (packet.hasHeader(vlan)) {
-			System.out.print(" vlan: " + vlan);
-		}
-
-		if (packet.hasHeader(Udp.ID)) {
-			System.out.print("has udp");
-		}
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e7995d09/agent/src/com/cloud/agent/dhcp/DhcpSnooperImpl.java
----------------------------------------------------------------------
diff --git a/agent/src/com/cloud/agent/dhcp/DhcpSnooperImpl.java b/agent/src/com/cloud/agent/dhcp/DhcpSnooperImpl.java
deleted file mode 100644
index 7195a7e..0000000
--- a/agent/src/com/cloud/agent/dhcp/DhcpSnooperImpl.java
+++ /dev/null
@@ -1,324 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.agent.dhcp;
-
-import java.net.InetAddress;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-
-import javax.ejb.Local;
-import javax.naming.ConfigurationException;
-
-import org.apache.log4j.Logger;
-import org.jnetpcap.Pcap;
-import org.jnetpcap.PcapBpfProgram;
-import org.jnetpcap.PcapIf;
-import org.jnetpcap.packet.PcapPacket;
-import org.jnetpcap.packet.PcapPacketHandler;
-import org.jnetpcap.protocol.tcpip.Udp;
-
-import com.cloud.utils.Pair;
-import com.cloud.utils.concurrency.NamedThreadFactory;
-
-@Local(value = { DhcpSnooper.class })
-public class DhcpSnooperImpl implements DhcpSnooper {
-	private static final Logger s_logger = Logger
-			.getLogger(DhcpSnooperImpl.class);
-
-	public enum DHCPState {
-		DHCPACKED, DHCPREQUESTED, DHCPRESET;
-	}
-
-	public class IPAddr {
-		String _vmName;
-		InetAddress _ip;
-		DHCPState _state;
-
-		public IPAddr(InetAddress ip, DHCPState state, String vmName) {
-			_ip = ip;
-			_state = state;
-			_vmName = vmName;
-		}
-	}
-
-	protected ExecutorService _executor;
-	protected Map<String, IPAddr> _macIpMap;
-	protected Map<InetAddress, String> _ipMacMap;
-	private DhcpServer _server;
-	protected long _timeout = 1200000;
-	protected InetAddress _dhcpServerIp;
-
-	public DhcpSnooperImpl(String bridge, long timeout) {
-
-		_timeout = timeout;
-		_executor = new ThreadPoolExecutor(10, 10 * 10, 1, TimeUnit.DAYS,
-				new LinkedBlockingQueue<Runnable>(), new NamedThreadFactory(
-						"DhcpListener"));
-		_macIpMap = new ConcurrentHashMap<String, IPAddr>();
-		_ipMacMap = new ConcurrentHashMap<InetAddress, String>();
-		_server = new DhcpServer(this, bridge);
-		_server.start();
-	}
-
-	@Override
-	public InetAddress getIPAddr(String macAddr, String vmName) {
-		String macAddrLowerCase = macAddr.toLowerCase();
-		IPAddr addr = _macIpMap.get(macAddrLowerCase);
-		if (addr == null) {
-			addr = new IPAddr(null, DHCPState.DHCPRESET, vmName);
-			_macIpMap.put(macAddrLowerCase, addr);
-		} else {
-			addr._state = DHCPState.DHCPRESET;
-		}
-
-		synchronized (addr) {
-			try {
-				addr.wait(_timeout);
-			} catch (InterruptedException e) {
-			}
-			if (addr._state == DHCPState.DHCPACKED) {
-				addr._state = DHCPState.DHCPRESET;
-				return addr._ip;
-			}
-		}
-
-		return null;
-	}
-
-	public InetAddress getDhcpServerIP() {
-		return _dhcpServerIp;
-	}
-
-	@Override
-	public void cleanup(String macAddr, String vmName) {
-		try {
-			if (macAddr == null) {
-				return;
-			}
-			_macIpMap.remove(macAddr);
-			_ipMacMap.values().remove(macAddr);
-		} catch (Exception e) {
-			s_logger.debug("Failed to cleanup: " + e.toString());
-		}
-	}
-
-	@Override
-	public Map<String, InetAddress> syncIpAddr() {
-		Collection<IPAddr> ips = _macIpMap.values();
-		HashMap<String, InetAddress> vmIpMap = new HashMap<String, InetAddress>();
-		for (IPAddr ip : ips) {
-			if (ip._state == DHCPState.DHCPACKED) {
-				vmIpMap.put(ip._vmName, ip._ip);
-			}
-		}
-		return vmIpMap;
-	}
-
-	@Override
-	public void initializeMacTable(List<Pair<String, String>> macVmNameList) {
-		for (Pair<String, String> macVmname : macVmNameList) {
-			IPAddr ipAdrr = new IPAddr(null, DHCPState.DHCPRESET,
-					macVmname.second());
-			_macIpMap.put(macVmname.first(), ipAdrr);
-		}
-	}
-
-	protected void setIPAddr(String macAddr, InetAddress ip, DHCPState state,
-			InetAddress dhcpServerIp) {
-		String macAddrLowerCase = macAddr.toLowerCase();
-		if (state == DHCPState.DHCPREQUESTED) {
-			IPAddr ipAddr = _macIpMap.get(macAddrLowerCase);
-			if (ipAddr == null) {
-				return;
-			}
-
-			_ipMacMap.put(ip, macAddr);
-		} else if (state == DHCPState.DHCPACKED) {
-			_dhcpServerIp = dhcpServerIp;
-			String destMac = macAddrLowerCase;
-			if (macAddrLowerCase.equalsIgnoreCase("ff:ff:ff:ff:ff:ff")) {
-				destMac = _ipMacMap.get(ip);
-				if (destMac == null) {
-					return;
-				}
-			}
-
-			IPAddr addr = _macIpMap.get(destMac);
-			if (addr != null) {
-				addr._ip = ip;
-				addr._state = state;
-				synchronized (addr) {
-					addr.notify();
-				}
-			}
-		}
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see com.cloud.agent.dhcp.DhcpSnooper#stop()
-	 */
-	@Override
-	public boolean stop() {
-		_executor.shutdown();
-		_server.StopServer();
-		return true;
-	}
-
-	private class DhcpServer extends Thread {
-		private DhcpSnooperImpl _manager;
-		private String _bridge;
-		private Pcap _pcapedDev;
-		private boolean _loop;
-
-		public DhcpServer(DhcpSnooperImpl mgt, String bridge) {
-			_manager = mgt;
-			_bridge = bridge;
-			_loop = true;
-		}
-
-		public void StopServer() {
-			_loop = false;
-			_pcapedDev.breakloop();
-			_pcapedDev.close();
-		}
-
-		private Pcap initializePcap() {
-			try {
-				List<PcapIf> alldevs = new ArrayList<PcapIf>();
-				StringBuilder errBuf = new StringBuilder();
-				int r = Pcap.findAllDevs(alldevs, errBuf);
-				if (r == Pcap.NOT_OK || alldevs.isEmpty()) {
-					return null;
-				}
-
-				PcapIf dev = null;
-				for (PcapIf device : alldevs) {
-					if (device.getName().equalsIgnoreCase(_bridge)) {
-						dev = device;
-						break;
-					}
-				}
-
-				if (dev == null) {
-					s_logger.debug("Pcap: Can't find device: " + _bridge
-							+ " to listen on");
-					return null;
-				}
-
-				int snaplen = 64 * 1024;
-				int flags = Pcap.MODE_PROMISCUOUS;
-				int timeout = 10 * 1000;
-				Pcap pcap = Pcap.openLive(dev.getName(), snaplen, flags,
-						timeout, errBuf);
-				if (pcap == null) {
-					s_logger.debug("Pcap: Can't open " + _bridge);
-					return null;
-				}
-
-				PcapBpfProgram program = new PcapBpfProgram();
-				String expr = "dst port 68 or 67";
-				int optimize = 0;
-				int netmask = 0xFFFFFF00;
-				if (pcap.compile(program, expr, optimize, netmask) != Pcap.OK) {
-					s_logger.debug("Pcap: can't compile BPF");
-					return null;
-				}
-
-				if (pcap.setFilter(program) != Pcap.OK) {
-					s_logger.debug("Pcap: Can't set filter");
-					return null;
-				}
-				return pcap;
-			} catch (Exception e) {
-				s_logger.debug("Failed to initialized: " + e.toString());
-			}
-			return null;
-		}
-
-		public void run() {
-			while (_loop) {
-				try {
-					_pcapedDev = initializePcap();
-					if (_pcapedDev == null) {
-						return;
-					}
-
-					PcapPacketHandler<String> jpacketHandler = new PcapPacketHandler<String>() {
-						public void nextPacket(PcapPacket packet, String user) {
-							Udp u = new Udp();
-							if (packet.hasHeader(u)) {
-								int offset = u.getOffset() + u.getLength();
-								_executor.execute(new DhcpPacketParser(packet,
-										offset, u.length() - u.getLength(),
-										_manager));
-							}
-						}
-					};
-					s_logger.debug("Starting DHCP snooping on " + _bridge);
-					int retValue = _pcapedDev.loop(-1, jpacketHandler,
-							"pcapPacketHandler");
-					if (retValue == -1) {
-						s_logger.debug("Pcap: failed to set loop handler");
-					} else if (retValue == -2 && !_loop) {
-						s_logger.debug("Pcap: terminated");
-						return;
-					}
-					_pcapedDev.close();
-				} catch (Exception e) {
-					s_logger.debug("Pcap error:" + e.toString());
-				}
-			}
-		}
-	}
-
-	static public void main(String args[]) {
-		s_logger.addAppender(new org.apache.log4j.ConsoleAppender(
-				new org.apache.log4j.PatternLayout(), "System.out"));
-		final DhcpSnooperImpl manager = new DhcpSnooperImpl("cloudbr0", 10000);
-		s_logger.debug(manager.getIPAddr("02:00:4c:66:00:03", "i-2-5-VM"));
-		manager.stop();
-
-	}
-
-	@Override
-	public boolean configure(String name, Map<String, Object> params)
-			throws ConfigurationException {
-		// TODO configure timeout here
-		return true;
-	}
-
-	@Override
-	public boolean start() {
-		return true;
-	}
-
-	@Override
-	public String getName() {
-		return "DhcpSnooperImpl";
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e7995d09/agent/src/com/cloud/agent/resource/computing/CloudZonesComputingResource.java
----------------------------------------------------------------------
diff --git a/agent/src/com/cloud/agent/resource/computing/CloudZonesComputingResource.java b/agent/src/com/cloud/agent/resource/computing/CloudZonesComputingResource.java
deleted file mode 100644
index 37bfc50..0000000
--- a/agent/src/com/cloud/agent/resource/computing/CloudZonesComputingResource.java
+++ /dev/null
@@ -1,293 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.agent.resource.computing;
-
-import java.net.InetAddress;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.naming.ConfigurationException;
-
-import org.apache.log4j.Logger;
-import org.libvirt.Connect;
-import org.libvirt.Domain;
-import org.libvirt.LibvirtException;
-
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.Command;
-import com.cloud.agent.api.StartAnswer;
-import com.cloud.agent.api.StartCommand;
-
-import com.cloud.agent.api.StopAnswer;
-import com.cloud.agent.api.StopCommand;
-
-import com.cloud.agent.api.routing.SavePasswordCommand;
-import com.cloud.agent.api.routing.VmDataCommand;
-import com.cloud.agent.api.to.NicTO;
-import com.cloud.agent.api.to.VirtualMachineTO;
-import com.cloud.agent.dhcp.DhcpSnooper;
-import com.cloud.agent.dhcp.DhcpSnooperImpl;
-
-import com.cloud.agent.resource.computing.LibvirtComputingResource;
-import com.cloud.agent.resource.computing.LibvirtConnection;
-import com.cloud.agent.resource.computing.LibvirtVMDef;
-import com.cloud.agent.resource.computing.LibvirtVMDef.DiskDef;
-import com.cloud.agent.resource.computing.LibvirtVMDef.InterfaceDef;
-import com.cloud.agent.vmdata.JettyVmDataServer;
-import com.cloud.agent.vmdata.VmDataServer;
-
-import com.cloud.network.Networks.TrafficType;
-import com.cloud.utils.Pair;
-import com.cloud.vm.VirtualMachine;
-import com.cloud.vm.VirtualMachine.State;
-
-/**
- * Logic specific to the Cloudzones feature
- * 
- * }
- **/
-
-public class CloudZonesComputingResource extends LibvirtComputingResource {
-	private static final Logger s_logger = Logger
-			.getLogger(CloudZonesComputingResource.class);
-	protected DhcpSnooper _dhcpSnooper;
-	String _parent;
-	long _dhcpTimeout;
-	protected String _hostIp;
-	protected String _hostMacAddress;
-	protected VmDataServer _vmDataServer = new JettyVmDataServer();
-
-	private void setupDhcpManager(Connect conn, String bridgeName) {
-
-		_dhcpSnooper = new DhcpSnooperImpl(bridgeName, _dhcpTimeout);
-
-		List<Pair<String, String>> macs = new ArrayList<Pair<String, String>>();
-		try {
-			int[] domainIds = conn.listDomains();
-			for (int i = 0; i < domainIds.length; i++) {
-				Domain vm = conn.domainLookupByID(domainIds[i]);
-				if (vm.getName().startsWith("i-")) {
-					List<InterfaceDef> nics = getInterfaces(conn, vm.getName());
-					InterfaceDef nic = nics.get(0);
-					macs.add(new Pair<String, String>(nic.getMacAddress(), vm
-							.getName()));
-				}
-			}
-		} catch (LibvirtException e) {
-			s_logger.debug("Failed to get MACs: " + e.toString());
-		}
-
-		_dhcpSnooper.initializeMacTable(macs);
-	}
-
-	@Override
-	public boolean configure(String name, Map<String, Object> params)
-			throws ConfigurationException {
-		boolean success = super.configure(name, params);
-		if (!success) {
-			return false;
-		}
-
-		_parent = (String) params.get("mount.path");
-
-		try {
-			_dhcpTimeout = Long.parseLong((String) params.get("dhcp.timeout"));
-		} catch (Exception e) {
-			_dhcpTimeout = 1200000;
-		}
-
-		_hostIp = (String) params.get("host.ip");
-		_hostMacAddress = (String) params.get("host.mac.address");
-
-		try {
-			Connect conn;
-			conn = LibvirtConnection.getConnection();
-			setupDhcpManager(conn, _guestBridgeName);
-		} catch (LibvirtException e) {
-			s_logger.debug("Failed to get libvirt connection:" + e.toString());
-			return false;
-		}
-
-		_dhcpSnooper.configure(name, params);
-		_vmDataServer.configure(name, params);
-
-		return true;
-	}
-
-	@Override
-	protected synchronized StartAnswer execute(StartCommand cmd) {
-		VirtualMachineTO vmSpec = cmd.getVirtualMachine();
-		String vmName = vmSpec.getName();
-		LibvirtVMDef vm = null;
-
-		State state = State.Stopped;
-		Connect conn = null;
-		try {
-			conn = LibvirtConnection.getConnection();
-			synchronized (_vms) {
-				_vms.put(vmName, State.Starting);
-			}
-
-			vm = createVMFromSpec(vmSpec);
-
-			createVbd(conn, vmSpec, vmName, vm);
-
-			createVifs(conn, vmSpec, vm);
-
-			s_logger.debug("starting " + vmName + ": " + vm.toString());
-			startDomain(conn, vmName, vm.toString());
-
-			NicTO[] nics = vmSpec.getNics();
-			for (NicTO nic : nics) {
-				if (nic.isSecurityGroupEnabled()) {
-					if (vmSpec.getType() != VirtualMachine.Type.User) {
-						default_network_rules_for_systemvm(conn, vmName);
-					} else {
-						nic.setIp(null);
-						default_network_rules(conn, vmName, nic, vmSpec.getId());
-					}
-				}
-			}
-
-			// Attach each data volume to the VM, if there is a deferred
-			// attached disk
-			for (DiskDef disk : vm.getDevices().getDisks()) {
-				if (disk.isAttachDeferred()) {
-					attachOrDetachDevice(conn, true, vmName, disk.toString());
-				}
-			}
-
-			if (vmSpec.getType() == VirtualMachine.Type.User) {
-				for (NicTO nic : nics) {
-					if (nic.getType() == TrafficType.Guest) {
-						InetAddress ipAddr = _dhcpSnooper.getIPAddr(
-								nic.getMac(), vmName);
-						if (ipAddr == null) {
-							s_logger.debug("Failed to get guest DHCP ip, stop it");
-							StopCommand stpCmd = new StopCommand(vmName);
-							execute(stpCmd);
-							return new StartAnswer(cmd,
-									"Failed to get guest DHCP ip, stop it");
-						}
-						s_logger.debug(ipAddr);
-						nic.setIp(ipAddr.getHostAddress());
-
-						post_default_network_rules(conn, vmName, nic,
-								vmSpec.getId(), _dhcpSnooper.getDhcpServerIP(),
-								_hostIp, _hostMacAddress);
-						_vmDataServer.handleVmStarted(cmd.getVirtualMachine());
-					}
-				}
-			}
-
-			state = State.Running;
-			return new StartAnswer(cmd);
-		} catch (Exception e) {
-			s_logger.warn("Exception ", e);
-			if (conn != null) {
-				handleVmStartFailure(conn, vmName, vm);
-			}
-			return new StartAnswer(cmd, e.getMessage());
-		} finally {
-			synchronized (_vms) {
-				if (state != State.Stopped) {
-					_vms.put(vmName, state);
-				} else {
-					_vms.remove(vmName);
-				}
-			}
-		}
-	}
-
-	protected Answer execute(StopCommand cmd) {
-		final String vmName = cmd.getVmName();
-
-		Long bytesReceived = new Long(0);
-		Long bytesSent = new Long(0);
-
-		State state = null;
-		synchronized (_vms) {
-			state = _vms.get(vmName);
-			_vms.put(vmName, State.Stopping);
-		}
-		try {
-			Connect conn = LibvirtConnection.getConnection();
-
-			try {
-				Domain dm = conn.domainLookupByUUID(UUID
-						.nameUUIDFromBytes(vmName.getBytes()));
-			} catch (LibvirtException e) {
-				state = State.Stopped;
-				return new StopAnswer(cmd, null, 0, bytesSent, bytesReceived);
-			}
-
-			String macAddress = null;
-			if (vmName.startsWith("i-")) {
-				List<InterfaceDef> nics = getInterfaces(conn, vmName);
-				if (!nics.isEmpty()) {
-					macAddress = nics.get(0).getMacAddress();
-				}
-			}
-
-			destroy_network_rules_for_vm(conn, vmName);
-			String result = stopVM(conn, vmName, defineOps.UNDEFINE_VM);
-
-			try {
-				cleanupVnet(conn, cmd.getVnet());
-				_dhcpSnooper.cleanup(macAddress, vmName);
-				_vmDataServer.handleVmStopped(cmd.getVmName());
-			} catch (Exception e) {
-
-			}
-
-			state = State.Stopped;
-			return new StopAnswer(cmd, result, 0, bytesSent, bytesReceived);
-		} catch (LibvirtException e) {
-			return new StopAnswer(cmd, e.getMessage());
-		} finally {
-			synchronized (_vms) {
-				if (state != null) {
-					_vms.put(vmName, state);
-				} else {
-					_vms.remove(vmName);
-				}
-			}
-		}
-	}
-
-	@Override
-	public Answer executeRequest(Command cmd) {
-		if (cmd instanceof VmDataCommand) {
-			return execute((VmDataCommand) cmd);
-		} else if (cmd instanceof SavePasswordCommand) {
-			return execute((SavePasswordCommand) cmd);
-		}
-		return super.executeRequest(cmd);
-	}
-
-	protected Answer execute(final VmDataCommand cmd) {
-		return _vmDataServer.handleVmDataCommand(cmd);
-	}
-
-	protected Answer execute(final SavePasswordCommand cmd) {
-		return new Answer(cmd);
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/e7995d09/core/src/com/cloud/storage/template/HttpTemplateDownloader.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/storage/template/HttpTemplateDownloader.java b/core/src/com/cloud/storage/template/HttpTemplateDownloader.java
index fd5acc9..2fe18f5 100644
--- a/core/src/com/cloud/storage/template/HttpTemplateDownloader.java
+++ b/core/src/com/cloud/storage/template/HttpTemplateDownloader.java
@@ -39,7 +39,6 @@ import org.apache.commons.httpclient.auth.AuthScope;
 import org.apache.commons.httpclient.methods.GetMethod;
 import org.apache.commons.httpclient.params.HttpMethodParams;
 import org.apache.log4j.Logger;
-import org.jnetpcap.util.resolver.Resolver.ResolverType;
 
 import com.cloud.agent.api.storage.DownloadCommand.Proxy;
 import com.cloud.agent.api.storage.DownloadCommand.ResourceType;