mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
updated regions branch with changes from master
This commit is contained in:
commit
4fcf64dd74
@ -50,7 +50,9 @@ wait_for_network() {
|
|||||||
i=1
|
i=1
|
||||||
while [ $i -lt 10 ]
|
while [ $i -lt 10 ]
|
||||||
do
|
do
|
||||||
if ip addr show cloudbr0 |grep -w inet > /dev/null 2>&1; then
|
# Under Ubuntu and Debian libvirt by default creates a bridge called virbr0.
|
||||||
|
# That's why we want more then 3 lines back from brctl, so that there is a manually created bridge
|
||||||
|
if [ "$(brctl show|wc -l)" -gt 2 ]; then
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
sleep 1
|
sleep 1
|
||||||
@ -75,8 +77,7 @@ start() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#FIXME: wait for network
|
wait_for_network
|
||||||
wait_for_network
|
|
||||||
|
|
||||||
if start-stop-daemon --start --quiet \
|
if start-stop-daemon --start --quiet \
|
||||||
--pidfile "$PIDFILE" \
|
--pidfile "$PIDFILE" \
|
||||||
|
|||||||
@ -245,9 +245,9 @@ public class Agent implements HandlerFactory, IAgentControl {
|
|||||||
|
|
||||||
_connection.start();
|
_connection.start();
|
||||||
while (!_connection.isStartup()) {
|
while (!_connection.isStartup()) {
|
||||||
_shell.getBackoffAlgorithm().waitBeforeRetry();
|
_shell.getBackoffAlgorithm().waitBeforeRetry();
|
||||||
_connection = new NioClient("Agent", _shell.getHost(), _shell.getPort(), _shell.getWorkers(), this);
|
_connection = new NioClient("Agent", _shell.getHost(), _shell.getPort(), _shell.getWorkers(), this);
|
||||||
_connection.start();
|
_connection.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -495,7 +495,7 @@ public class Agent implements HandlerFactory, IAgentControl {
|
|||||||
_reconnectAllowed = false;
|
_reconnectAllowed = false;
|
||||||
answer = new Answer(cmd, true, null);
|
answer = new Answer(cmd, true, null);
|
||||||
} else if (cmd instanceof MaintainCommand) {
|
} else if (cmd instanceof MaintainCommand) {
|
||||||
s_logger.debug("Received maintainCommand" );
|
s_logger.debug("Received maintainCommand" );
|
||||||
cancelTasks();
|
cancelTasks();
|
||||||
_reconnectAllowed = false;
|
_reconnectAllowed = false;
|
||||||
answer = new MaintainAnswer((MaintainCommand)cmd);
|
answer = new MaintainAnswer((MaintainCommand)cmd);
|
||||||
@ -820,17 +820,17 @@ public class Agent implements HandlerFactory, IAgentControl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public class AgentRequestHandler extends Task {
|
public class AgentRequestHandler extends Task {
|
||||||
public AgentRequestHandler(Task.Type type, Link link, Request req) {
|
public AgentRequestHandler(Task.Type type, Link link, Request req) {
|
||||||
super(type, link, req);
|
super(type, link, req);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doTask(Task task) throws Exception {
|
protected void doTask(Task task) throws Exception {
|
||||||
Request req = (Request)this.get();
|
Request req = (Request)this.get();
|
||||||
if (!(req instanceof Response)) {
|
if (!(req instanceof Response)) {
|
||||||
processRequest(req, task.getLink());
|
processRequest(req, task.getLink());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ServerHandler extends Task {
|
public class ServerHandler extends Task {
|
||||||
@ -853,12 +853,12 @@ public class Agent implements HandlerFactory, IAgentControl {
|
|||||||
try {
|
try {
|
||||||
request = Request.parse(task.getData());
|
request = Request.parse(task.getData());
|
||||||
if (request instanceof Response) {
|
if (request instanceof Response) {
|
||||||
//It's for pinganswer etc, should be processed immediately.
|
//It's for pinganswer etc, should be processed immediately.
|
||||||
processResponse((Response) request, task.getLink());
|
processResponse((Response) request, task.getLink());
|
||||||
} else {
|
} else {
|
||||||
//put the requests from mgt server into another thread pool, as the request may take a longer time to finish. Don't block the NIO main thread pool
|
//put the requests from mgt server into another thread pool, as the request may take a longer time to finish. Don't block the NIO main thread pool
|
||||||
//processRequest(request, task.getLink());
|
//processRequest(request, task.getLink());
|
||||||
_executor.execute(new AgentRequestHandler(this.getType(), this.getLink(), request));
|
_executor.execute(new AgentRequestHandler(this.getType(), this.getLink(), request));
|
||||||
}
|
}
|
||||||
} catch (final ClassNotFoundException e) {
|
} catch (final ClassNotFoundException e) {
|
||||||
s_logger.error("Unable to find this request ");
|
s_logger.error("Unable to find this request ");
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -22,35 +22,35 @@ import java.util.Properties;
|
|||||||
import com.cloud.utils.backoff.BackoffAlgorithm;
|
import com.cloud.utils.backoff.BackoffAlgorithm;
|
||||||
|
|
||||||
public interface IAgentShell {
|
public interface IAgentShell {
|
||||||
public Map<String, Object> getCmdLineProperties();
|
public Map<String, Object> getCmdLineProperties();
|
||||||
|
|
||||||
public Properties getProperties();
|
public Properties getProperties();
|
||||||
|
|
||||||
public String getPersistentProperty(String prefix, String name);
|
public String getPersistentProperty(String prefix, String name);
|
||||||
|
|
||||||
public void setPersistentProperty(String prefix, String name, String value);
|
public void setPersistentProperty(String prefix, String name, String value);
|
||||||
|
|
||||||
public String getHost();
|
public String getHost();
|
||||||
|
|
||||||
public String getPrivateIp();
|
public String getPrivateIp();
|
||||||
|
|
||||||
public int getPort();
|
public int getPort();
|
||||||
|
|
||||||
public int getWorkers();
|
public int getWorkers();
|
||||||
|
|
||||||
public int getProxyPort();
|
public int getProxyPort();
|
||||||
|
|
||||||
public String getGuid();
|
public String getGuid();
|
||||||
|
|
||||||
public String getZone();
|
public String getZone();
|
||||||
|
|
||||||
public String getPod();
|
public String getPod();
|
||||||
|
|
||||||
public BackoffAlgorithm getBackoffAlgorithm();
|
public BackoffAlgorithm getBackoffAlgorithm();
|
||||||
|
|
||||||
public int getPingRetries();
|
public int getPingRetries();
|
||||||
|
|
||||||
public void upgradeAgent(final String url);
|
public void upgradeAgent(final String url);
|
||||||
|
|
||||||
public String getVersion();
|
public String getVersion();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,50 +27,50 @@ import com.cloud.utils.component.PluggableService;
|
|||||||
import com.cloud.utils.db.GenericDao;
|
import com.cloud.utils.db.GenericDao;
|
||||||
|
|
||||||
public class AgentComponentLibraryBase extends ComponentLibraryBase {
|
public class AgentComponentLibraryBase extends ComponentLibraryBase {
|
||||||
@Override
|
@Override
|
||||||
public Map<String, ComponentInfo<GenericDao<?, ?>>> getDaos() {
|
public Map<String, ComponentInfo<GenericDao<?, ?>>> getDaos() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, ComponentInfo<Manager>> getManagers() {
|
public Map<String, ComponentInfo<Manager>> getManagers() {
|
||||||
if (_managers.size() == 0) {
|
if (_managers.size() == 0) {
|
||||||
populateManagers();
|
populateManagers();
|
||||||
}
|
}
|
||||||
return _managers;
|
return _managers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, List<ComponentInfo<Adapter>>> getAdapters() {
|
public Map<String, List<ComponentInfo<Adapter>>> getAdapters() {
|
||||||
if (_adapters.size() == 0) {
|
if (_adapters.size() == 0) {
|
||||||
populateAdapters();
|
populateAdapters();
|
||||||
}
|
}
|
||||||
return _adapters;
|
return _adapters;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<Class<?>, Class<?>> getFactories() {
|
public Map<Class<?>, Class<?>> getFactories() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void populateManagers() {
|
protected void populateManagers() {
|
||||||
// addManager("StackMaidManager", StackMaidManagerImpl.class);
|
// addManager("StackMaidManager", StackMaidManagerImpl.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void populateAdapters() {
|
protected void populateAdapters() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void populateServices() {
|
protected void populateServices() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, ComponentInfo<PluggableService>> getPluggableServices() {
|
public Map<String, ComponentInfo<PluggableService>> getPluggableServices() {
|
||||||
if (_pluggableServices.size() == 0) {
|
if (_pluggableServices.size() == 0) {
|
||||||
populateServices();
|
populateServices();
|
||||||
}
|
}
|
||||||
return _pluggableServices;
|
return _pluggableServices;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,7 +22,7 @@ import com.cloud.utils.component.Manager;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface StorageComponent extends Manager {
|
public interface StorageComponent extends Manager {
|
||||||
String get(String key);
|
String get(String key);
|
||||||
|
|
||||||
void persist(String key, String value);
|
void persist(String key, String value);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,92 +39,92 @@ import com.cloud.utils.PropertiesUtil;
|
|||||||
**/
|
**/
|
||||||
@Local(value = { StorageComponent.class })
|
@Local(value = { StorageComponent.class })
|
||||||
public class PropertiesStorage implements StorageComponent {
|
public class PropertiesStorage implements StorageComponent {
|
||||||
private static final Logger s_logger = Logger
|
private static final Logger s_logger = Logger
|
||||||
.getLogger(PropertiesStorage.class);
|
.getLogger(PropertiesStorage.class);
|
||||||
Properties _properties = new Properties();
|
Properties _properties = new Properties();
|
||||||
File _file;
|
File _file;
|
||||||
String _name;
|
String _name;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized String get(String key) {
|
public synchronized String get(String key) {
|
||||||
return _properties.getProperty(key);
|
return _properties.getProperty(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void persist(String key, String value) {
|
public synchronized void persist(String key, String value) {
|
||||||
_properties.setProperty(key, value);
|
_properties.setProperty(key, value);
|
||||||
FileOutputStream output = null;
|
FileOutputStream output = null;
|
||||||
try {
|
try {
|
||||||
output = new FileOutputStream(_file);
|
output = new FileOutputStream(_file);
|
||||||
_properties.store(output, _name);
|
_properties.store(output, _name);
|
||||||
output.flush();
|
output.flush();
|
||||||
output.close();
|
output.close();
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
s_logger.error("Who deleted the file? ", e);
|
s_logger.error("Who deleted the file? ", e);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
s_logger.error("Uh-oh: ", e);
|
s_logger.error("Uh-oh: ", e);
|
||||||
} finally {
|
} finally {
|
||||||
if (output != null) {
|
if (output != null) {
|
||||||
try {
|
try {
|
||||||
output.close();
|
output.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
// ignore.
|
// ignore.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean configure(String name, Map<String, Object> params) {
|
public boolean configure(String name, Map<String, Object> params) {
|
||||||
_name = name;
|
_name = name;
|
||||||
String path = (String) params.get("path");
|
String path = (String) params.get("path");
|
||||||
if (path == null) {
|
if (path == null) {
|
||||||
path = "agent.properties";
|
path = "agent.properties";
|
||||||
}
|
}
|
||||||
|
|
||||||
File file = PropertiesUtil.findConfigFile(path);
|
File file = PropertiesUtil.findConfigFile(path);
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
file = new File(path);
|
file = new File(path);
|
||||||
try {
|
try {
|
||||||
if (!file.createNewFile()) {
|
if (!file.createNewFile()) {
|
||||||
s_logger.error("Unable to create _file: "
|
s_logger.error("Unable to create _file: "
|
||||||
+ file.getAbsolutePath());
|
+ file.getAbsolutePath());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
s_logger.error(
|
s_logger.error(
|
||||||
"Unable to create _file: " + file.getAbsolutePath(), e);
|
"Unable to create _file: " + file.getAbsolutePath(), e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
_properties.load(new FileInputStream(file));
|
_properties.load(new FileInputStream(file));
|
||||||
_file = file;
|
_file = file;
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
s_logger.error("How did we get here? ", e);
|
s_logger.error("How did we get here? ", e);
|
||||||
return false;
|
return false;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
s_logger.error("IOException: ", e);
|
s_logger.error("IOException: ", e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean start() {
|
public boolean start() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stop() {
|
public boolean stop() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -31,36 +31,36 @@ import org.apache.log4j.Logger;
|
|||||||
import com.cloud.utils.concurrency.NamedThreadFactory;
|
import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||||
|
|
||||||
public class DhcpProtocolParserServer extends Thread {
|
public class DhcpProtocolParserServer extends Thread {
|
||||||
private static final Logger s_logger = Logger
|
private static final Logger s_logger = Logger
|
||||||
.getLogger(DhcpProtocolParserServer.class);;
|
.getLogger(DhcpProtocolParserServer.class);;
|
||||||
protected ExecutorService _executor;
|
protected ExecutorService _executor;
|
||||||
private int dhcpServerPort = 67;
|
private int dhcpServerPort = 67;
|
||||||
private int bufferSize = 300;
|
private int bufferSize = 300;
|
||||||
protected boolean _running = false;
|
protected boolean _running = false;
|
||||||
|
|
||||||
public DhcpProtocolParserServer(int workers) {
|
public DhcpProtocolParserServer(int workers) {
|
||||||
_executor = new ThreadPoolExecutor(workers, 10 * workers, 1,
|
_executor = new ThreadPoolExecutor(workers, 10 * workers, 1,
|
||||||
TimeUnit.DAYS, new LinkedBlockingQueue<Runnable>(),
|
TimeUnit.DAYS, new LinkedBlockingQueue<Runnable>(),
|
||||||
new NamedThreadFactory("DhcpListener"));
|
new NamedThreadFactory("DhcpListener"));
|
||||||
_running = true;
|
_running = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
while (_running) {
|
while (_running) {
|
||||||
try {
|
try {
|
||||||
DatagramSocket dhcpSocket = new DatagramSocket(dhcpServerPort,
|
DatagramSocket dhcpSocket = new DatagramSocket(dhcpServerPort,
|
||||||
InetAddress.getByAddress(new byte[] { 0, 0, 0, 0 }));
|
InetAddress.getByAddress(new byte[] { 0, 0, 0, 0 }));
|
||||||
dhcpSocket.setBroadcast(true);
|
dhcpSocket.setBroadcast(true);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
byte[] buf = new byte[bufferSize];
|
byte[] buf = new byte[bufferSize];
|
||||||
DatagramPacket dgp = new DatagramPacket(buf, buf.length);
|
DatagramPacket dgp = new DatagramPacket(buf, buf.length);
|
||||||
dhcpSocket.receive(dgp);
|
dhcpSocket.receive(dgp);
|
||||||
// _executor.execute(new DhcpPacketParser(buf));
|
// _executor.execute(new DhcpPacketParser(buf));
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
s_logger.debug(e.getMessage());
|
s_logger.debug(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,16 +25,16 @@ import com.cloud.utils.component.Adapter;
|
|||||||
|
|
||||||
public interface DhcpSnooper extends Adapter {
|
public interface DhcpSnooper extends Adapter {
|
||||||
|
|
||||||
public InetAddress getIPAddr(String macAddr, String vmName);
|
public InetAddress getIPAddr(String macAddr, String vmName);
|
||||||
|
|
||||||
public InetAddress getDhcpServerIP();
|
public InetAddress getDhcpServerIP();
|
||||||
|
|
||||||
public void cleanup(String macAddr, String vmName);
|
public void cleanup(String macAddr, String vmName);
|
||||||
|
|
||||||
public Map<String, InetAddress> syncIpAddr();
|
public Map<String, InetAddress> syncIpAddr();
|
||||||
|
|
||||||
public boolean stop();
|
public boolean stop();
|
||||||
|
|
||||||
public void initializeMacTable(List<Pair<String, String>> macVmNameList);
|
public void initializeMacTable(List<Pair<String, String>> macVmNameList);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -39,104 +39,104 @@ import com.cloud.utils.net.NetUtils;
|
|||||||
|
|
||||||
@Local(value = { DhcpSnooper.class })
|
@Local(value = { DhcpSnooper.class })
|
||||||
public class FakeDhcpSnooper implements DhcpSnooper {
|
public class FakeDhcpSnooper implements DhcpSnooper {
|
||||||
private static final Logger s_logger = Logger
|
private static final Logger s_logger = Logger
|
||||||
.getLogger(FakeDhcpSnooper.class);
|
.getLogger(FakeDhcpSnooper.class);
|
||||||
private Queue<String> _ipAddresses = new ConcurrentLinkedQueue<String>();
|
private Queue<String> _ipAddresses = new ConcurrentLinkedQueue<String>();
|
||||||
private Map<String, String> _macIpMap = new ConcurrentHashMap<String, String>();
|
private Map<String, String> _macIpMap = new ConcurrentHashMap<String, String>();
|
||||||
private Map<String, InetAddress> _vmIpMap = new ConcurrentHashMap<String, InetAddress>();
|
private Map<String, InetAddress> _vmIpMap = new ConcurrentHashMap<String, InetAddress>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean configure(String name, Map<String, Object> params)
|
public boolean configure(String name, Map<String, Object> params)
|
||||||
throws ConfigurationException {
|
throws ConfigurationException {
|
||||||
String guestIpRange = (String) params.get("guest.ip.range");
|
String guestIpRange = (String) params.get("guest.ip.range");
|
||||||
if (guestIpRange != null) {
|
if (guestIpRange != null) {
|
||||||
String[] guestIps = guestIpRange.split("-");
|
String[] guestIps = guestIpRange.split("-");
|
||||||
if (guestIps.length == 2) {
|
if (guestIps.length == 2) {
|
||||||
long start = NetUtils.ip2Long(guestIps[0]);
|
long start = NetUtils.ip2Long(guestIps[0]);
|
||||||
long end = NetUtils.ip2Long(guestIps[1]);
|
long end = NetUtils.ip2Long(guestIps[1]);
|
||||||
while (start <= end) {
|
while (start <= end) {
|
||||||
_ipAddresses.offer(NetUtils.long2Ip(start++));
|
_ipAddresses.offer(NetUtils.long2Ip(start++));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean start() {
|
public boolean start() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "FakeDhcpSnooper";
|
return "FakeDhcpSnooper";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InetAddress getIPAddr(String macAddr, String vmName) {
|
public InetAddress getIPAddr(String macAddr, String vmName) {
|
||||||
String ipAddr = _ipAddresses.poll();
|
String ipAddr = _ipAddresses.poll();
|
||||||
if (ipAddr == null) {
|
if (ipAddr == null) {
|
||||||
s_logger.warn("No ip addresses left in queue");
|
s_logger.warn("No ip addresses left in queue");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
InetAddress inetAddr = InetAddress.getByName(ipAddr);
|
InetAddress inetAddr = InetAddress.getByName(ipAddr);
|
||||||
_macIpMap.put(macAddr.toLowerCase(), ipAddr);
|
_macIpMap.put(macAddr.toLowerCase(), ipAddr);
|
||||||
_vmIpMap.put(vmName, inetAddr);
|
_vmIpMap.put(vmName, inetAddr);
|
||||||
s_logger.info("Got ip address " + ipAddr + " for vm " + vmName
|
s_logger.info("Got ip address " + ipAddr + " for vm " + vmName
|
||||||
+ " mac=" + macAddr.toLowerCase());
|
+ " mac=" + macAddr.toLowerCase());
|
||||||
return inetAddr;
|
return inetAddr;
|
||||||
} catch (UnknownHostException e) {
|
} catch (UnknownHostException e) {
|
||||||
s_logger.warn("Failed to get InetAddress for " + ipAddr);
|
s_logger.warn("Failed to get InetAddress for " + ipAddr);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cleanup(String macAddr, String vmName) {
|
public void cleanup(String macAddr, String vmName) {
|
||||||
try {
|
try {
|
||||||
if (macAddr == null) {
|
if (macAddr == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
InetAddress inetAddr = _vmIpMap.remove(vmName);
|
InetAddress inetAddr = _vmIpMap.remove(vmName);
|
||||||
String ipAddr = inetAddr.getHostName();
|
String ipAddr = inetAddr.getHostName();
|
||||||
for (Map.Entry<String, String> entry : _macIpMap.entrySet()) {
|
for (Map.Entry<String, String> entry : _macIpMap.entrySet()) {
|
||||||
if (entry.getValue().equalsIgnoreCase(ipAddr)) {
|
if (entry.getValue().equalsIgnoreCase(ipAddr)) {
|
||||||
macAddr = entry.getKey();
|
macAddr = entry.getKey();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ipAddr = _macIpMap.remove(macAddr);
|
ipAddr = _macIpMap.remove(macAddr);
|
||||||
|
|
||||||
s_logger.info("Cleaning up for mac address: " + macAddr + " ip="
|
s_logger.info("Cleaning up for mac address: " + macAddr + " ip="
|
||||||
+ ipAddr + " inetAddr=" + inetAddr);
|
+ ipAddr + " inetAddr=" + inetAddr);
|
||||||
if (ipAddr != null) {
|
if (ipAddr != null) {
|
||||||
_ipAddresses.offer(ipAddr);
|
_ipAddresses.offer(ipAddr);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
s_logger.debug("Failed to cleanup: " + e.toString());
|
s_logger.debug("Failed to cleanup: " + e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, InetAddress> syncIpAddr() {
|
public Map<String, InetAddress> syncIpAddr() {
|
||||||
return _vmIpMap;
|
return _vmIpMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stop() {
|
public boolean stop() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initializeMacTable(List<Pair<String, String>> macVmNameList) {
|
public void initializeMacTable(List<Pair<String, String>> macVmNameList) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InetAddress getDhcpServerIP() {
|
public InetAddress getDhcpServerIP() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,61 +21,61 @@ import com.cloud.vm.VirtualMachine.State;
|
|||||||
// As storage is mapped from storage device, can virtually treat that VM here does
|
// As storage is mapped from storage device, can virtually treat that VM here does
|
||||||
public class MockVm {
|
public class MockVm {
|
||||||
|
|
||||||
private String vmName;
|
private String vmName;
|
||||||
private State state = State.Stopped;
|
private State state = State.Stopped;
|
||||||
|
|
||||||
private long ramSize; // unit of Mbytes
|
private long ramSize; // unit of Mbytes
|
||||||
private int cpuCount;
|
private int cpuCount;
|
||||||
private int utilization; // in percentage
|
private int utilization; // in percentage
|
||||||
private int vncPort; // 0-based allocation, real port number needs to be
|
private int vncPort; // 0-based allocation, real port number needs to be
|
||||||
// applied with base
|
// applied with base
|
||||||
|
|
||||||
public MockVm() {
|
public MockVm() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public MockVm(String vmName, State state, long ramSize, int cpuCount,
|
public MockVm(String vmName, State state, long ramSize, int cpuCount,
|
||||||
int utilization, int vncPort) {
|
int utilization, int vncPort) {
|
||||||
this.vmName = vmName;
|
this.vmName = vmName;
|
||||||
this.state = state;
|
this.state = state;
|
||||||
this.ramSize = ramSize;
|
this.ramSize = ramSize;
|
||||||
this.cpuCount = cpuCount;
|
this.cpuCount = cpuCount;
|
||||||
this.utilization = utilization;
|
this.utilization = utilization;
|
||||||
this.vncPort = vncPort;
|
this.vncPort = vncPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return vmName;
|
return vmName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public State getState() {
|
public State getState() {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setState(State state) {
|
public void setState(State state) {
|
||||||
this.state = state;
|
this.state = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getRamSize() {
|
public long getRamSize() {
|
||||||
return ramSize;
|
return ramSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCpuCount() {
|
public int getCpuCount() {
|
||||||
return cpuCount;
|
return cpuCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getUtilization() {
|
public int getUtilization() {
|
||||||
return utilization;
|
return utilization;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getVncPort() {
|
public int getVncPort() {
|
||||||
return vncPort;
|
return vncPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
long i = 10;
|
long i = 10;
|
||||||
Long l = null;
|
Long l = null;
|
||||||
if (i == l) {
|
if (i == l) {
|
||||||
System.out.print("fdfd");
|
System.out.print("fdfd");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,295 +29,295 @@ import com.cloud.utils.exception.CloudRuntimeException;
|
|||||||
import com.cloud.vm.VirtualMachine.State;
|
import com.cloud.vm.VirtualMachine.State;
|
||||||
|
|
||||||
public class MockVmMgr implements VmMgr {
|
public class MockVmMgr implements VmMgr {
|
||||||
private static final Logger s_logger = Logger.getLogger(MockVmMgr.class);
|
private static final Logger s_logger = Logger.getLogger(MockVmMgr.class);
|
||||||
|
|
||||||
private static final int DEFAULT_DOM0_MEM_MB = 128;
|
private static final int DEFAULT_DOM0_MEM_MB = 128;
|
||||||
private static final Random randSeed = new Random();
|
private static final Random randSeed = new Random();
|
||||||
|
|
||||||
private final Map<String, MockVm> vms = new HashMap<String, MockVm>();
|
private final Map<String, MockVm> vms = new HashMap<String, MockVm>();
|
||||||
private long vncPortMap = 0;
|
private long vncPortMap = 0;
|
||||||
|
|
||||||
private Map<String, Object> _params = null;
|
private Map<String, Object> _params = null;
|
||||||
|
|
||||||
public MockVmMgr() {
|
public MockVmMgr() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<String> getCurrentVMs() {
|
public Set<String> getCurrentVMs() {
|
||||||
HashSet<String> vmNameSet = new HashSet<String>();
|
HashSet<String> vmNameSet = new HashSet<String>();
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
for (String vmName : vms.keySet())
|
for (String vmName : vms.keySet())
|
||||||
vmNameSet.add(vmName);
|
vmNameSet.add(vmName);
|
||||||
}
|
}
|
||||||
return vmNameSet;
|
return vmNameSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String startVM(String vmName, String vnetId, String gateway,
|
public String startVM(String vmName, String vnetId, String gateway,
|
||||||
String dns, String privateIP, String privateMac,
|
String dns, String privateIP, String privateMac,
|
||||||
String privateMask, String publicIP, String publicMac,
|
String privateMask, String publicIP, String publicMac,
|
||||||
String publicMask, int cpuCount, int cpuUtilization, long ramSize,
|
String publicMask, int cpuCount, int cpuUtilization, long ramSize,
|
||||||
String localPath, String vncPassword) {
|
String localPath, String vncPassword) {
|
||||||
|
|
||||||
if (s_logger.isInfoEnabled()) {
|
if (s_logger.isInfoEnabled()) {
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
sb.append("Start VM. name: " + vmName + ", vnet: " + vnetId
|
sb.append("Start VM. name: " + vmName + ", vnet: " + vnetId
|
||||||
+ ", dns: " + dns);
|
+ ", dns: " + dns);
|
||||||
sb.append(", privateIP: " + privateIP + ", privateMac: "
|
sb.append(", privateIP: " + privateIP + ", privateMac: "
|
||||||
+ privateMac + ", privateMask: " + privateMask);
|
+ privateMac + ", privateMask: " + privateMask);
|
||||||
sb.append(", publicIP: " + publicIP + ", publicMac: " + publicMac
|
sb.append(", publicIP: " + publicIP + ", publicMac: " + publicMac
|
||||||
+ ", publicMask: " + publicMask);
|
+ ", publicMask: " + publicMask);
|
||||||
sb.append(", cpu count: " + cpuCount + ", cpuUtilization: "
|
sb.append(", cpu count: " + cpuCount + ", cpuUtilization: "
|
||||||
+ cpuUtilization + ", ram : " + ramSize);
|
+ cpuUtilization + ", ram : " + ramSize);
|
||||||
sb.append(", localPath: " + localPath);
|
sb.append(", localPath: " + localPath);
|
||||||
s_logger.info(sb.toString());
|
s_logger.info(sb.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
MockVm vm = vms.get(vmName);
|
MockVm vm = vms.get(vmName);
|
||||||
if (vm == null) {
|
if (vm == null) {
|
||||||
if (ramSize > getHostFreeMemory())
|
if (ramSize > getHostFreeMemory())
|
||||||
return "Out of memory";
|
return "Out of memory";
|
||||||
|
|
||||||
int vncPort = allocVncPort();
|
int vncPort = allocVncPort();
|
||||||
if (vncPort < 0)
|
if (vncPort < 0)
|
||||||
return "Unable to allocate VNC port";
|
return "Unable to allocate VNC port";
|
||||||
|
|
||||||
vm = new MockVm(vmName, State.Running, ramSize, cpuCount,
|
vm = new MockVm(vmName, State.Running, ramSize, cpuCount,
|
||||||
cpuUtilization, vncPort);
|
cpuUtilization, vncPort);
|
||||||
vms.put(vmName, vm);
|
vms.put(vmName, vm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String stopVM(String vmName, boolean force) {
|
public String stopVM(String vmName, boolean force) {
|
||||||
if (s_logger.isInfoEnabled())
|
if (s_logger.isInfoEnabled())
|
||||||
s_logger.info("Stop VM. name: " + vmName);
|
s_logger.info("Stop VM. name: " + vmName);
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
MockVm vm = vms.get(vmName);
|
MockVm vm = vms.get(vmName);
|
||||||
if (vm != null) {
|
if (vm != null) {
|
||||||
vm.setState(State.Stopped);
|
vm.setState(State.Stopped);
|
||||||
freeVncPort(vm.getVncPort());
|
freeVncPort(vm.getVncPort());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String rebootVM(String vmName) {
|
public String rebootVM(String vmName) {
|
||||||
if (s_logger.isInfoEnabled())
|
if (s_logger.isInfoEnabled())
|
||||||
s_logger.info("Reboot VM. name: " + vmName);
|
s_logger.info("Reboot VM. name: " + vmName);
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
MockVm vm = vms.get(vmName);
|
MockVm vm = vms.get(vmName);
|
||||||
if (vm != null)
|
if (vm != null)
|
||||||
vm.setState(State.Running);
|
vm.setState(State.Running);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean migrate(String vmName, String params) {
|
public boolean migrate(String vmName, String params) {
|
||||||
if (s_logger.isInfoEnabled())
|
if (s_logger.isInfoEnabled())
|
||||||
s_logger.info("Migrate VM. name: " + vmName);
|
s_logger.info("Migrate VM. name: " + vmName);
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
MockVm vm = vms.get(vmName);
|
MockVm vm = vms.get(vmName);
|
||||||
if (vm != null) {
|
if (vm != null) {
|
||||||
vm.setState(State.Stopped);
|
vm.setState(State.Stopped);
|
||||||
freeVncPort(vm.getVncPort());
|
freeVncPort(vm.getVncPort());
|
||||||
|
|
||||||
vms.remove(vmName);
|
vms.remove(vmName);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MockVm getVm(String vmName) {
|
public MockVm getVm(String vmName) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
MockVm vm = vms.get(vmName);
|
MockVm vm = vms.get(vmName);
|
||||||
return vm;
|
return vm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public State checkVmState(String vmName) {
|
public State checkVmState(String vmName) {
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
MockVm vm = vms.get(vmName);
|
MockVm vm = vms.get(vmName);
|
||||||
if (vm != null)
|
if (vm != null)
|
||||||
return vm.getState();
|
return vm.getState();
|
||||||
}
|
}
|
||||||
return State.Unknown;
|
return State.Unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, State> getVmStates() {
|
public Map<String, State> getVmStates() {
|
||||||
Map<String, State> states = new HashMap<String, State>();
|
Map<String, State> states = new HashMap<String, State>();
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
for (MockVm vm : vms.values()) {
|
for (MockVm vm : vms.values()) {
|
||||||
states.put(vm.getName(), vm.getState());
|
states.put(vm.getName(), vm.getState());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return states;
|
return states;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cleanupVM(String vmName, String local, String vnet) {
|
public void cleanupVM(String vmName, String local, String vnet) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
MockVm vm = vms.get(vmName);
|
MockVm vm = vms.get(vmName);
|
||||||
if (vm != null) {
|
if (vm != null) {
|
||||||
freeVncPort(vm.getVncPort());
|
freeVncPort(vm.getVncPort());
|
||||||
}
|
}
|
||||||
vms.remove(vmName);
|
vms.remove(vmName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getHostCpuUtilization() {
|
public double getHostCpuUtilization() {
|
||||||
return 0.0d;
|
return 0.0d;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getHostCpuCount() {
|
public int getHostCpuCount() {
|
||||||
|
|
||||||
return getConfiguredProperty("cpus", 4);
|
return getConfiguredProperty("cpus", 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getHostCpuSpeed() {
|
public long getHostCpuSpeed() {
|
||||||
return getConfiguredProperty("cpuspeed", 4000L);
|
return getConfiguredProperty("cpuspeed", 4000L);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getHostTotalMemory() { // total memory in bytes
|
public long getHostTotalMemory() { // total memory in bytes
|
||||||
return getConfiguredProperty("memory", 16000L);
|
return getConfiguredProperty("memory", 16000L);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getHostFreeMemory() { // free memory in bytes
|
public long getHostFreeMemory() { // free memory in bytes
|
||||||
long memSize = getHostTotalMemory();
|
long memSize = getHostTotalMemory();
|
||||||
memSize -= getHostDom0Memory();
|
memSize -= getHostDom0Memory();
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
for (MockVm vm : vms.values()) {
|
for (MockVm vm : vms.values()) {
|
||||||
if (vm.getState() != State.Stopped)
|
if (vm.getState() != State.Stopped)
|
||||||
memSize -= vm.getRamSize();
|
memSize -= vm.getRamSize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return memSize;
|
return memSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getHostDom0Memory() { // memory size in bytes
|
public long getHostDom0Memory() { // memory size in bytes
|
||||||
return DEFAULT_DOM0_MEM_MB * 1024 * 1024L;
|
return DEFAULT_DOM0_MEM_MB * 1024 * 1024L;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String cleanupVnet(String vnetId) {
|
public String cleanupVnet(String vnetId) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer getVncPort(String name) {
|
public Integer getVncPort(String name) {
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
MockVm vm = vms.get(name);
|
MockVm vm = vms.get(name);
|
||||||
if (vm != null)
|
if (vm != null)
|
||||||
return vm.getVncPort();
|
return vm.getVncPort();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Integer(-1);
|
return new Integer(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int allocVncPort() {
|
public int allocVncPort() {
|
||||||
for (int i = 0; i < 64; i++) {
|
for (int i = 0; i < 64; i++) {
|
||||||
if (((1L << i) & vncPortMap) == 0) {
|
if (((1L << i) & vncPortMap) == 0) {
|
||||||
vncPortMap |= (1L << i);
|
vncPortMap |= (1L << i);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void freeVncPort(int port) {
|
public void freeVncPort(int port) {
|
||||||
vncPortMap &= ~(1L << port);
|
vncPortMap &= ~(1L << port);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MockVm createVmFromSpec(VirtualMachineTO vmSpec) {
|
public MockVm createVmFromSpec(VirtualMachineTO vmSpec) {
|
||||||
String vmName = vmSpec.getName();
|
String vmName = vmSpec.getName();
|
||||||
long ramSize = vmSpec.getMinRam();
|
long ramSize = vmSpec.getMinRam();
|
||||||
int utilizationPercent = randSeed.nextInt() % 100;
|
int utilizationPercent = randSeed.nextInt() % 100;
|
||||||
MockVm vm = null;
|
MockVm vm = null;
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
vm = vms.get(vmName);
|
vm = vms.get(vmName);
|
||||||
if (vm == null) {
|
if (vm == null) {
|
||||||
if (ramSize > getHostFreeMemory()) {
|
if (ramSize > getHostFreeMemory()) {
|
||||||
s_logger.debug("host is out of memory");
|
s_logger.debug("host is out of memory");
|
||||||
throw new CloudRuntimeException("Host is out of Memory");
|
throw new CloudRuntimeException("Host is out of Memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
int vncPort = allocVncPort();
|
int vncPort = allocVncPort();
|
||||||
if (vncPort < 0) {
|
if (vncPort < 0) {
|
||||||
s_logger.debug("Unable to allocate VNC port");
|
s_logger.debug("Unable to allocate VNC port");
|
||||||
throw new CloudRuntimeException(
|
throw new CloudRuntimeException(
|
||||||
"Unable to allocate vnc port");
|
"Unable to allocate vnc port");
|
||||||
}
|
}
|
||||||
|
|
||||||
vm = new MockVm(vmName, State.Running, ramSize,
|
vm = new MockVm(vmName, State.Running, ramSize,
|
||||||
vmSpec.getCpus(), utilizationPercent, vncPort);
|
vmSpec.getCpus(), utilizationPercent, vncPort);
|
||||||
vms.put(vmName, vm);
|
vms.put(vmName, vm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return vm;
|
return vm;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createVbd(VirtualMachineTO vmSpec, String vmName, MockVm vm) {
|
public void createVbd(VirtualMachineTO vmSpec, String vmName, MockVm vm) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createVif(VirtualMachineTO vmSpec, String vmName, MockVm vm) {
|
public void createVif(VirtualMachineTO vmSpec, String vmName, MockVm vm) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configure(Map<String, Object> params) {
|
public void configure(Map<String, Object> params) {
|
||||||
_params = params;
|
_params = params;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Long getConfiguredProperty(String key, Long defaultValue) {
|
protected Long getConfiguredProperty(String key, Long defaultValue) {
|
||||||
String val = (String) _params.get(key);
|
String val = (String) _params.get(key);
|
||||||
|
|
||||||
if (val != null) {
|
if (val != null) {
|
||||||
Long result = Long.parseLong(val);
|
Long result = Long.parseLong(val);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Integer getConfiguredProperty(String key, Integer defaultValue) {
|
protected Integer getConfiguredProperty(String key, Integer defaultValue) {
|
||||||
String val = (String) _params.get(key);
|
String val = (String) _params.get(key);
|
||||||
|
|
||||||
if (val != null) {
|
if (val != null) {
|
||||||
Integer result = Integer.parseInt(val);
|
Integer result = Integer.parseInt(val);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,49 +23,49 @@ import com.cloud.agent.api.to.VirtualMachineTO;
|
|||||||
import com.cloud.vm.VirtualMachine.State;
|
import com.cloud.vm.VirtualMachine.State;
|
||||||
|
|
||||||
public interface VmMgr {
|
public interface VmMgr {
|
||||||
public Set<String> getCurrentVMs();
|
public Set<String> getCurrentVMs();
|
||||||
|
|
||||||
public String startVM(String vmName, String vnetId, String gateway,
|
public String startVM(String vmName, String vnetId, String gateway,
|
||||||
String dns, String privateIP, String privateMac,
|
String dns, String privateIP, String privateMac,
|
||||||
String privateMask, String publicIP, String publicMac,
|
String privateMask, String publicIP, String publicMac,
|
||||||
String publicMask, int cpuCount, int cpuUtilization, long ramSize,
|
String publicMask, int cpuCount, int cpuUtilization, long ramSize,
|
||||||
String localPath, String vncPassword);
|
String localPath, String vncPassword);
|
||||||
|
|
||||||
public String stopVM(String vmName, boolean force);
|
public String stopVM(String vmName, boolean force);
|
||||||
|
|
||||||
public String rebootVM(String vmName);
|
public String rebootVM(String vmName);
|
||||||
|
|
||||||
public void cleanupVM(String vmName, String local, String vnet);
|
public void cleanupVM(String vmName, String local, String vnet);
|
||||||
|
|
||||||
public boolean migrate(String vmName, String params);
|
public boolean migrate(String vmName, String params);
|
||||||
|
|
||||||
public MockVm getVm(String vmName);
|
public MockVm getVm(String vmName);
|
||||||
|
|
||||||
public State checkVmState(String vmName);
|
public State checkVmState(String vmName);
|
||||||
|
|
||||||
public Map<String, State> getVmStates();
|
public Map<String, State> getVmStates();
|
||||||
|
|
||||||
public Integer getVncPort(String name);
|
public Integer getVncPort(String name);
|
||||||
|
|
||||||
public String cleanupVnet(String vnetId);
|
public String cleanupVnet(String vnetId);
|
||||||
|
|
||||||
public double getHostCpuUtilization();
|
public double getHostCpuUtilization();
|
||||||
|
|
||||||
public int getHostCpuCount();
|
public int getHostCpuCount();
|
||||||
|
|
||||||
public long getHostCpuSpeed();
|
public long getHostCpuSpeed();
|
||||||
|
|
||||||
public long getHostTotalMemory();
|
public long getHostTotalMemory();
|
||||||
|
|
||||||
public long getHostFreeMemory();
|
public long getHostFreeMemory();
|
||||||
|
|
||||||
public long getHostDom0Memory();
|
public long getHostDom0Memory();
|
||||||
|
|
||||||
public MockVm createVmFromSpec(VirtualMachineTO vmSpec);
|
public MockVm createVmFromSpec(VirtualMachineTO vmSpec);
|
||||||
|
|
||||||
public void createVbd(VirtualMachineTO vmSpec, String vmName, MockVm vm);
|
public void createVbd(VirtualMachineTO vmSpec, String vmName, MockVm vm);
|
||||||
|
|
||||||
public void createVif(VirtualMachineTO vmSpec, String vmName, MockVm vm);
|
public void createVif(VirtualMachineTO vmSpec, String vmName, MockVm vm);
|
||||||
|
|
||||||
public void configure(Map<String, Object> params);
|
public void configure(Map<String, Object> params);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,183 +45,183 @@ import com.cloud.storage.Storage.StoragePoolType;
|
|||||||
|
|
||||||
@Local(value = { ServerResource.class })
|
@Local(value = { ServerResource.class })
|
||||||
public class DummyResource implements ServerResource {
|
public class DummyResource implements ServerResource {
|
||||||
String _name;
|
String _name;
|
||||||
Host.Type _type;
|
Host.Type _type;
|
||||||
boolean _negative;
|
boolean _negative;
|
||||||
IAgentControl _agentControl;
|
IAgentControl _agentControl;
|
||||||
private Map<String, Object> _params;
|
private Map<String, Object> _params;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disconnected() {
|
public void disconnected() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Answer executeRequest(Command cmd) {
|
public Answer executeRequest(Command cmd) {
|
||||||
if (cmd instanceof CheckNetworkCommand) {
|
if (cmd instanceof CheckNetworkCommand) {
|
||||||
return new CheckNetworkAnswer((CheckNetworkCommand) cmd, true, null);
|
return new CheckNetworkAnswer((CheckNetworkCommand) cmd, true, null);
|
||||||
}
|
}
|
||||||
System.out.println("Received Command: " + cmd.toString());
|
System.out.println("Received Command: " + cmd.toString());
|
||||||
Answer answer = new Answer(cmd, !_negative, "response");
|
Answer answer = new Answer(cmd, !_negative, "response");
|
||||||
System.out.println("Replying with: " + answer.toString());
|
System.out.println("Replying with: " + answer.toString());
|
||||||
return answer;
|
return answer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PingCommand getCurrentStatus(long id) {
|
public PingCommand getCurrentStatus(long id) {
|
||||||
return new PingCommand(_type, id);
|
return new PingCommand(_type, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
return _type;
|
return _type;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getConfiguredProperty(String key, String defaultValue) {
|
protected String getConfiguredProperty(String key, String defaultValue) {
|
||||||
String val = (String) _params.get(key);
|
String val = (String) _params.get(key);
|
||||||
return val == null ? defaultValue : val;
|
return val == null ? defaultValue : val;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Long getConfiguredProperty(String key, Long defaultValue) {
|
protected Long getConfiguredProperty(String key, Long defaultValue) {
|
||||||
String val = (String) _params.get(key);
|
String val = (String) _params.get(key);
|
||||||
|
|
||||||
if (val != null) {
|
if (val != null) {
|
||||||
Long result = Long.parseLong(val);
|
Long result = Long.parseLong(val);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<Object> getHostInfo() {
|
protected List<Object> getHostInfo() {
|
||||||
final ArrayList<Object> info = new ArrayList<Object>();
|
final ArrayList<Object> info = new ArrayList<Object>();
|
||||||
long speed = getConfiguredProperty("cpuspeed", 4000L);
|
long speed = getConfiguredProperty("cpuspeed", 4000L);
|
||||||
long cpus = getConfiguredProperty("cpus", 4L);
|
long cpus = getConfiguredProperty("cpus", 4L);
|
||||||
long ram = getConfiguredProperty("memory", 16000L * 1024L * 1024L);
|
long ram = getConfiguredProperty("memory", 16000L * 1024L * 1024L);
|
||||||
long dom0ram = Math.min(ram / 10, 768 * 1024 * 1024L);
|
long dom0ram = Math.min(ram / 10, 768 * 1024 * 1024L);
|
||||||
|
|
||||||
String cap = getConfiguredProperty("capabilities", "hvm");
|
String cap = getConfiguredProperty("capabilities", "hvm");
|
||||||
info.add((int) cpus);
|
info.add((int) cpus);
|
||||||
info.add(speed);
|
info.add(speed);
|
||||||
info.add(ram);
|
info.add(ram);
|
||||||
info.add(cap);
|
info.add(cap);
|
||||||
info.add(dom0ram);
|
info.add(dom0ram);
|
||||||
return info;
|
return info;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fillNetworkInformation(final StartupCommand cmd) {
|
protected void fillNetworkInformation(final StartupCommand cmd) {
|
||||||
|
|
||||||
cmd.setPrivateIpAddress((String) getConfiguredProperty(
|
cmd.setPrivateIpAddress((String) getConfiguredProperty(
|
||||||
"private.ip.address", "127.0.0.1"));
|
"private.ip.address", "127.0.0.1"));
|
||||||
cmd.setPrivateMacAddress((String) getConfiguredProperty(
|
cmd.setPrivateMacAddress((String) getConfiguredProperty(
|
||||||
"private.mac.address", "8A:D2:54:3F:7C:C3"));
|
"private.mac.address", "8A:D2:54:3F:7C:C3"));
|
||||||
cmd.setPrivateNetmask((String) getConfiguredProperty(
|
cmd.setPrivateNetmask((String) getConfiguredProperty(
|
||||||
"private.ip.netmask", "255.255.255.0"));
|
"private.ip.netmask", "255.255.255.0"));
|
||||||
|
|
||||||
cmd.setStorageIpAddress((String) getConfiguredProperty(
|
cmd.setStorageIpAddress((String) getConfiguredProperty(
|
||||||
"private.ip.address", "127.0.0.1"));
|
"private.ip.address", "127.0.0.1"));
|
||||||
cmd.setStorageMacAddress((String) getConfiguredProperty(
|
cmd.setStorageMacAddress((String) getConfiguredProperty(
|
||||||
"private.mac.address", "8A:D2:54:3F:7C:C3"));
|
"private.mac.address", "8A:D2:54:3F:7C:C3"));
|
||||||
cmd.setStorageNetmask((String) getConfiguredProperty(
|
cmd.setStorageNetmask((String) getConfiguredProperty(
|
||||||
"private.ip.netmask", "255.255.255.0"));
|
"private.ip.netmask", "255.255.255.0"));
|
||||||
cmd.setGatewayIpAddress((String) getConfiguredProperty(
|
cmd.setGatewayIpAddress((String) getConfiguredProperty(
|
||||||
"gateway.ip.address", "127.0.0.1"));
|
"gateway.ip.address", "127.0.0.1"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, String> getVersionStrings() {
|
private Map<String, String> getVersionStrings() {
|
||||||
Map<String, String> result = new HashMap<String, String>();
|
Map<String, String> result = new HashMap<String, String>();
|
||||||
String hostOs = (String) _params.get("Host.OS");
|
String hostOs = (String) _params.get("Host.OS");
|
||||||
String hostOsVer = (String) _params.get("Host.OS.Version");
|
String hostOsVer = (String) _params.get("Host.OS.Version");
|
||||||
String hostOsKernVer = (String) _params.get("Host.OS.Kernel.Version");
|
String hostOsKernVer = (String) _params.get("Host.OS.Kernel.Version");
|
||||||
result.put("Host.OS", hostOs == null ? "Fedora" : hostOs);
|
result.put("Host.OS", hostOs == null ? "Fedora" : hostOs);
|
||||||
result.put("Host.OS.Version", hostOsVer == null ? "14" : hostOsVer);
|
result.put("Host.OS.Version", hostOsVer == null ? "14" : hostOsVer);
|
||||||
result.put("Host.OS.Kernel.Version",
|
result.put("Host.OS.Kernel.Version",
|
||||||
hostOsKernVer == null ? "2.6.35.6-45.fc14.x86_64"
|
hostOsKernVer == null ? "2.6.35.6-45.fc14.x86_64"
|
||||||
: hostOsKernVer);
|
: hostOsKernVer);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected StoragePoolInfo initializeLocalStorage() {
|
protected StoragePoolInfo initializeLocalStorage() {
|
||||||
String hostIp = (String) getConfiguredProperty("private.ip.address",
|
String hostIp = (String) getConfiguredProperty("private.ip.address",
|
||||||
"127.0.0.1");
|
"127.0.0.1");
|
||||||
String localStoragePath = (String) getConfiguredProperty(
|
String localStoragePath = (String) getConfiguredProperty(
|
||||||
"local.storage.path", "/mnt");
|
"local.storage.path", "/mnt");
|
||||||
String lh = hostIp + localStoragePath;
|
String lh = hostIp + localStoragePath;
|
||||||
String uuid = UUID.nameUUIDFromBytes(lh.getBytes()).toString();
|
String uuid = UUID.nameUUIDFromBytes(lh.getBytes()).toString();
|
||||||
|
|
||||||
String capacity = (String) getConfiguredProperty(
|
String capacity = (String) getConfiguredProperty(
|
||||||
"local.storage.capacity", "1000000000");
|
"local.storage.capacity", "1000000000");
|
||||||
String available = (String) getConfiguredProperty(
|
String available = (String) getConfiguredProperty(
|
||||||
"local.storage.avail", "10000000");
|
"local.storage.avail", "10000000");
|
||||||
|
|
||||||
return new StoragePoolInfo(uuid, hostIp, localStoragePath,
|
return new StoragePoolInfo(uuid, hostIp, localStoragePath,
|
||||||
localStoragePath, StoragePoolType.Filesystem,
|
localStoragePath, StoragePoolType.Filesystem,
|
||||||
Long.parseLong(capacity), Long.parseLong(available));
|
Long.parseLong(capacity), Long.parseLong(available));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StartupCommand[] initialize() {
|
public StartupCommand[] initialize() {
|
||||||
Map<String, VmState> changes = null;
|
Map<String, VmState> changes = null;
|
||||||
|
|
||||||
final List<Object> info = getHostInfo();
|
final List<Object> info = getHostInfo();
|
||||||
|
|
||||||
final StartupRoutingCommand cmd = new StartupRoutingCommand(
|
final StartupRoutingCommand cmd = new StartupRoutingCommand(
|
||||||
(Integer) info.get(0), (Long) info.get(1), (Long) info.get(2),
|
(Integer) info.get(0), (Long) info.get(1), (Long) info.get(2),
|
||||||
(Long) info.get(4), (String) info.get(3), HypervisorType.KVM,
|
(Long) info.get(4), (String) info.get(3), HypervisorType.KVM,
|
||||||
RouterPrivateIpStrategy.HostLocal, changes);
|
RouterPrivateIpStrategy.HostLocal, changes);
|
||||||
fillNetworkInformation(cmd);
|
fillNetworkInformation(cmd);
|
||||||
cmd.getHostDetails().putAll(getVersionStrings());
|
cmd.getHostDetails().putAll(getVersionStrings());
|
||||||
cmd.setCluster(getConfiguredProperty("cluster", "1"));
|
cmd.setCluster(getConfiguredProperty("cluster", "1"));
|
||||||
StoragePoolInfo pi = initializeLocalStorage();
|
StoragePoolInfo pi = initializeLocalStorage();
|
||||||
StartupStorageCommand sscmd = new StartupStorageCommand();
|
StartupStorageCommand sscmd = new StartupStorageCommand();
|
||||||
sscmd.setPoolInfo(pi);
|
sscmd.setPoolInfo(pi);
|
||||||
sscmd.setGuid(pi.getUuid());
|
sscmd.setGuid(pi.getUuid());
|
||||||
sscmd.setDataCenter((String) _params.get("zone"));
|
sscmd.setDataCenter((String) _params.get("zone"));
|
||||||
sscmd.setResourceType(Storage.StorageResourceType.STORAGE_POOL);
|
sscmd.setResourceType(Storage.StorageResourceType.STORAGE_POOL);
|
||||||
|
|
||||||
return new StartupCommand[] { cmd, sscmd };
|
return new StartupCommand[] { cmd, sscmd };
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean configure(String name, Map<String, Object> params) {
|
public boolean configure(String name, Map<String, Object> params) {
|
||||||
_name = name;
|
_name = name;
|
||||||
|
|
||||||
String value = (String) params.get("type");
|
String value = (String) params.get("type");
|
||||||
_type = Host.Type.valueOf(value);
|
_type = Host.Type.valueOf(value);
|
||||||
|
|
||||||
value = (String) params.get("negative.reply");
|
value = (String) params.get("negative.reply");
|
||||||
_negative = Boolean.parseBoolean(value);
|
_negative = Boolean.parseBoolean(value);
|
||||||
setParams(params);
|
setParams(params);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParams(Map<String, Object> _params) {
|
public void setParams(Map<String, Object> _params) {
|
||||||
this._params = _params;
|
this._params = _params;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean start() {
|
public boolean start() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stop() {
|
public boolean stop() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IAgentControl getAgentControl() {
|
public IAgentControl getAgentControl() {
|
||||||
return _agentControl;
|
return _agentControl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAgentControl(IAgentControl agentControl) {
|
public void setAgentControl(IAgentControl agentControl) {
|
||||||
_agentControl = agentControl;
|
_agentControl = agentControl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
@ -22,148 +22,148 @@ import java.util.Map;
|
|||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
public class KVMGuestOsMapper {
|
public class KVMGuestOsMapper {
|
||||||
private static final Logger s_logger = Logger
|
private static final Logger s_logger = Logger
|
||||||
.getLogger(KVMGuestOsMapper.class);
|
.getLogger(KVMGuestOsMapper.class);
|
||||||
private static Map<String, String> s_mapper = new HashMap<String, String>();
|
private static Map<String, String> s_mapper = new HashMap<String, String>();
|
||||||
static {
|
static {
|
||||||
s_mapper.put("CentOS 4.5 (32-bit)", "CentOS 4.5");
|
s_mapper.put("CentOS 4.5 (32-bit)", "CentOS 4.5");
|
||||||
s_mapper.put("CentOS 4.6 (32-bit)", "CentOS 4.6");
|
s_mapper.put("CentOS 4.6 (32-bit)", "CentOS 4.6");
|
||||||
s_mapper.put("CentOS 4.7 (32-bit)", "CentOS 4.7");
|
s_mapper.put("CentOS 4.7 (32-bit)", "CentOS 4.7");
|
||||||
s_mapper.put("CentOS 4.8 (32-bit)", "CentOS 4.8");
|
s_mapper.put("CentOS 4.8 (32-bit)", "CentOS 4.8");
|
||||||
s_mapper.put("CentOS 5.0 (32-bit)", "CentOS 5.0");
|
s_mapper.put("CentOS 5.0 (32-bit)", "CentOS 5.0");
|
||||||
s_mapper.put("CentOS 5.0 (64-bit)", "CentOS 5.0");
|
s_mapper.put("CentOS 5.0 (64-bit)", "CentOS 5.0");
|
||||||
s_mapper.put("CentOS 5.1 (32-bit)", "CentOS 5.1");
|
s_mapper.put("CentOS 5.1 (32-bit)", "CentOS 5.1");
|
||||||
s_mapper.put("CentOS 5.1 (64-bit)", "CentOS 5.1");
|
s_mapper.put("CentOS 5.1 (64-bit)", "CentOS 5.1");
|
||||||
s_mapper.put("CentOS 5.2 (32-bit)", "CentOS 5.2");
|
s_mapper.put("CentOS 5.2 (32-bit)", "CentOS 5.2");
|
||||||
s_mapper.put("CentOS 5.2 (64-bit)", "CentOS 5.2");
|
s_mapper.put("CentOS 5.2 (64-bit)", "CentOS 5.2");
|
||||||
s_mapper.put("CentOS 5.3 (32-bit)", "CentOS 5.3");
|
s_mapper.put("CentOS 5.3 (32-bit)", "CentOS 5.3");
|
||||||
s_mapper.put("CentOS 5.3 (64-bit)", "CentOS 5.3");
|
s_mapper.put("CentOS 5.3 (64-bit)", "CentOS 5.3");
|
||||||
s_mapper.put("CentOS 5.4 (32-bit)", "CentOS 5.4");
|
s_mapper.put("CentOS 5.4 (32-bit)", "CentOS 5.4");
|
||||||
s_mapper.put("CentOS 5.4 (64-bit)", "CentOS 5.4");
|
s_mapper.put("CentOS 5.4 (64-bit)", "CentOS 5.4");
|
||||||
s_mapper.put("CentOS 5.5 (32-bit)", "CentOS 5.5");
|
s_mapper.put("CentOS 5.5 (32-bit)", "CentOS 5.5");
|
||||||
s_mapper.put("CentOS 5.5 (64-bit)", "CentOS 5.5");
|
s_mapper.put("CentOS 5.5 (64-bit)", "CentOS 5.5");
|
||||||
s_mapper.put("Red Hat Enterprise Linux 2", "Red Hat Enterprise Linux 2");
|
s_mapper.put("Red Hat Enterprise Linux 2", "Red Hat Enterprise Linux 2");
|
||||||
s_mapper.put("Red Hat Enterprise Linux 3 (32-bit)",
|
s_mapper.put("Red Hat Enterprise Linux 3 (32-bit)",
|
||||||
"Red Hat Enterprise Linux 3");
|
"Red Hat Enterprise Linux 3");
|
||||||
s_mapper.put("Red Hat Enterprise Linux 3 (64-bit)",
|
s_mapper.put("Red Hat Enterprise Linux 3 (64-bit)",
|
||||||
"Red Hat Enterprise Linux 3");
|
"Red Hat Enterprise Linux 3");
|
||||||
s_mapper.put("Red Hat Enterprise Linux 4(64-bit)",
|
s_mapper.put("Red Hat Enterprise Linux 4(64-bit)",
|
||||||
"Red Hat Enterprise Linux 4");
|
"Red Hat Enterprise Linux 4");
|
||||||
s_mapper.put("Red Hat Enterprise Linux 4.5 (32-bit)",
|
s_mapper.put("Red Hat Enterprise Linux 4.5 (32-bit)",
|
||||||
"Red Hat Enterprise Linux 4.5");
|
"Red Hat Enterprise Linux 4.5");
|
||||||
s_mapper.put("Red Hat Enterprise Linux 4.6 (32-bit)",
|
s_mapper.put("Red Hat Enterprise Linux 4.6 (32-bit)",
|
||||||
"Red Hat Enterprise Linux 4.6");
|
"Red Hat Enterprise Linux 4.6");
|
||||||
s_mapper.put("Red Hat Enterprise Linux 4.7 (32-bit)",
|
s_mapper.put("Red Hat Enterprise Linux 4.7 (32-bit)",
|
||||||
"Red Hat Enterprise Linux 4.7");
|
"Red Hat Enterprise Linux 4.7");
|
||||||
s_mapper.put("Red Hat Enterprise Linux 4.8 (32-bit)",
|
s_mapper.put("Red Hat Enterprise Linux 4.8 (32-bit)",
|
||||||
"Red Hat Enterprise Linux 4.8");
|
"Red Hat Enterprise Linux 4.8");
|
||||||
s_mapper.put("Red Hat Enterprise Linux 5.0 (32-bit)",
|
s_mapper.put("Red Hat Enterprise Linux 5.0 (32-bit)",
|
||||||
"Red Hat Enterprise Linux 5.0");
|
"Red Hat Enterprise Linux 5.0");
|
||||||
s_mapper.put("Red Hat Enterprise Linux 5.0 (64-bit)",
|
s_mapper.put("Red Hat Enterprise Linux 5.0 (64-bit)",
|
||||||
"Red Hat Enterprise Linux 5.0");
|
"Red Hat Enterprise Linux 5.0");
|
||||||
s_mapper.put("Red Hat Enterprise Linux 5.1 (32-bit)",
|
s_mapper.put("Red Hat Enterprise Linux 5.1 (32-bit)",
|
||||||
"Red Hat Enterprise Linux 5.1");
|
"Red Hat Enterprise Linux 5.1");
|
||||||
s_mapper.put("Red Hat Enterprise Linux 5.1 (32-bit)",
|
s_mapper.put("Red Hat Enterprise Linux 5.1 (32-bit)",
|
||||||
"Red Hat Enterprise Linux 5.1");
|
"Red Hat Enterprise Linux 5.1");
|
||||||
s_mapper.put("Red Hat Enterprise Linux 5.2 (32-bit)",
|
s_mapper.put("Red Hat Enterprise Linux 5.2 (32-bit)",
|
||||||
"Red Hat Enterprise Linux 5.2");
|
"Red Hat Enterprise Linux 5.2");
|
||||||
s_mapper.put("Red Hat Enterprise Linux 5.2 (64-bit)",
|
s_mapper.put("Red Hat Enterprise Linux 5.2 (64-bit)",
|
||||||
"Red Hat Enterprise Linux 5.2");
|
"Red Hat Enterprise Linux 5.2");
|
||||||
s_mapper.put("Red Hat Enterprise Linux 5.3 (32-bit)",
|
s_mapper.put("Red Hat Enterprise Linux 5.3 (32-bit)",
|
||||||
"Red Hat Enterprise Linux 5.3");
|
"Red Hat Enterprise Linux 5.3");
|
||||||
s_mapper.put("Red Hat Enterprise Linux 5.3 (64-bit)",
|
s_mapper.put("Red Hat Enterprise Linux 5.3 (64-bit)",
|
||||||
"Red Hat Enterprise Linux 5.3");
|
"Red Hat Enterprise Linux 5.3");
|
||||||
s_mapper.put("Red Hat Enterprise Linux 5.4 (32-bit)",
|
s_mapper.put("Red Hat Enterprise Linux 5.4 (32-bit)",
|
||||||
"Red Hat Enterprise Linux 5.4");
|
"Red Hat Enterprise Linux 5.4");
|
||||||
s_mapper.put("Red Hat Enterprise Linux 5.4 (64-bit)",
|
s_mapper.put("Red Hat Enterprise Linux 5.4 (64-bit)",
|
||||||
"Red Hat Enterprise Linux 5.4");
|
"Red Hat Enterprise Linux 5.4");
|
||||||
s_mapper.put("Red Hat Enterprise Linux 5.5 (32-bit)",
|
s_mapper.put("Red Hat Enterprise Linux 5.5 (32-bit)",
|
||||||
"Red Hat Enterprise Linux 5.5");
|
"Red Hat Enterprise Linux 5.5");
|
||||||
s_mapper.put("Red Hat Enterprise Linux 5.5 (64-bit)",
|
s_mapper.put("Red Hat Enterprise Linux 5.5 (64-bit)",
|
||||||
"Red Hat Enterprise Linux 5.5");
|
"Red Hat Enterprise Linux 5.5");
|
||||||
s_mapper.put("Red Hat Enterprise Linux 6.0 (32-bit)",
|
s_mapper.put("Red Hat Enterprise Linux 6.0 (32-bit)",
|
||||||
"Red Hat Enterprise Linux 6.0");
|
"Red Hat Enterprise Linux 6.0");
|
||||||
s_mapper.put("Red Hat Enterprise Linux 6.0 (64-bit)",
|
s_mapper.put("Red Hat Enterprise Linux 6.0 (64-bit)",
|
||||||
"Red Hat Enterprise Linux 6.0");
|
"Red Hat Enterprise Linux 6.0");
|
||||||
s_mapper.put("Fedora 13", "Fedora 13");
|
s_mapper.put("Fedora 13", "Fedora 13");
|
||||||
s_mapper.put("Fedora 12", "Fedora 12");
|
s_mapper.put("Fedora 12", "Fedora 12");
|
||||||
s_mapper.put("Fedora 11", "Fedora 11");
|
s_mapper.put("Fedora 11", "Fedora 11");
|
||||||
s_mapper.put("Fedora 10", "Fedora 10");
|
s_mapper.put("Fedora 10", "Fedora 10");
|
||||||
s_mapper.put("Fedora 9", "Fedora 9");
|
s_mapper.put("Fedora 9", "Fedora 9");
|
||||||
s_mapper.put("Fedora 8", "Fedora 8");
|
s_mapper.put("Fedora 8", "Fedora 8");
|
||||||
s_mapper.put("Ubuntu 10.04 (32-bit)", "Ubuntu 10.04");
|
s_mapper.put("Ubuntu 10.04 (32-bit)", "Ubuntu 10.04");
|
||||||
s_mapper.put("Ubuntu 10.04 (64-bit)", "Ubuntu 10.04");
|
s_mapper.put("Ubuntu 10.04 (64-bit)", "Ubuntu 10.04");
|
||||||
s_mapper.put("Ubuntu 10.10 (32-bit)", "Ubuntu 10.10");
|
s_mapper.put("Ubuntu 10.10 (32-bit)", "Ubuntu 10.10");
|
||||||
s_mapper.put("Ubuntu 10.10 (64-bit)", "Ubuntu 10.10");
|
s_mapper.put("Ubuntu 10.10 (64-bit)", "Ubuntu 10.10");
|
||||||
s_mapper.put("Ubuntu 9.10 (32-bit)", "Ubuntu 9.10");
|
s_mapper.put("Ubuntu 9.10 (32-bit)", "Ubuntu 9.10");
|
||||||
s_mapper.put("Ubuntu 9.10 (64-bit)", "Ubuntu 9.10");
|
s_mapper.put("Ubuntu 9.10 (64-bit)", "Ubuntu 9.10");
|
||||||
s_mapper.put("Ubuntu 9.04 (32-bit)", "Ubuntu 9.04");
|
s_mapper.put("Ubuntu 9.04 (32-bit)", "Ubuntu 9.04");
|
||||||
s_mapper.put("Ubuntu 9.04 (64-bit)", "Ubuntu 9.04");
|
s_mapper.put("Ubuntu 9.04 (64-bit)", "Ubuntu 9.04");
|
||||||
s_mapper.put("Ubuntu 8.10 (32-bit)", "Ubuntu 8.10");
|
s_mapper.put("Ubuntu 8.10 (32-bit)", "Ubuntu 8.10");
|
||||||
s_mapper.put("Ubuntu 8.10 (64-bit)", "Ubuntu 8.10");
|
s_mapper.put("Ubuntu 8.10 (64-bit)", "Ubuntu 8.10");
|
||||||
s_mapper.put("Ubuntu 8.04 (32-bit)", "Other Linux");
|
s_mapper.put("Ubuntu 8.04 (32-bit)", "Other Linux");
|
||||||
s_mapper.put("Ubuntu 8.04 (64-bit)", "Other Linux");
|
s_mapper.put("Ubuntu 8.04 (64-bit)", "Other Linux");
|
||||||
s_mapper.put("Debian GNU/Linux 5(32-bit)", "Debian GNU/Linux 5");
|
s_mapper.put("Debian GNU/Linux 5(32-bit)", "Debian GNU/Linux 5");
|
||||||
s_mapper.put("Debian GNU/Linux 5(64-bit)", "Debian GNU/Linux 5");
|
s_mapper.put("Debian GNU/Linux 5(64-bit)", "Debian GNU/Linux 5");
|
||||||
s_mapper.put("Debian GNU/Linux 4(32-bit)", "Debian GNU/Linux 4");
|
s_mapper.put("Debian GNU/Linux 4(32-bit)", "Debian GNU/Linux 4");
|
||||||
s_mapper.put("Debian GNU/Linux 4(64-bit)", "Debian GNU/Linux 4");
|
s_mapper.put("Debian GNU/Linux 4(64-bit)", "Debian GNU/Linux 4");
|
||||||
s_mapper.put("Debian GNU/Linux 6(64-bit)", "Debian GNU/Linux 6");
|
s_mapper.put("Debian GNU/Linux 6(64-bit)", "Debian GNU/Linux 6");
|
||||||
s_mapper.put("Debian GNU/Linux 6(32-bit)", "Debian GNU/Linux 6");
|
s_mapper.put("Debian GNU/Linux 6(32-bit)", "Debian GNU/Linux 6");
|
||||||
s_mapper.put("Other 2.6x Linux (32-bit)", "Other 2.6x Linux");
|
s_mapper.put("Other 2.6x Linux (32-bit)", "Other 2.6x Linux");
|
||||||
s_mapper.put("Other 2.6x Linux (64-bit)", "Other 2.6x Linux");
|
s_mapper.put("Other 2.6x Linux (64-bit)", "Other 2.6x Linux");
|
||||||
s_mapper.put("Other Linux (32-bit)", "Other Linux");
|
s_mapper.put("Other Linux (32-bit)", "Other Linux");
|
||||||
s_mapper.put("Other Linux (64-bit)", "Other Linux");
|
s_mapper.put("Other Linux (64-bit)", "Other Linux");
|
||||||
s_mapper.put("Other Ubuntu (32-bit)", "Other Linux");
|
s_mapper.put("Other Ubuntu (32-bit)", "Other Linux");
|
||||||
s_mapper.put("Other Ubuntu (64-bit)", "Other Linux");
|
s_mapper.put("Other Ubuntu (64-bit)", "Other Linux");
|
||||||
s_mapper.put("Asianux 3(32-bit)", "Other Linux");
|
s_mapper.put("Asianux 3(32-bit)", "Other Linux");
|
||||||
s_mapper.put("Asianux 3(64-bit)", "Other Linux");
|
s_mapper.put("Asianux 3(64-bit)", "Other Linux");
|
||||||
s_mapper.put("Windows 7 (32-bit)", "Windows 7");
|
s_mapper.put("Windows 7 (32-bit)", "Windows 7");
|
||||||
s_mapper.put("Windows 7 (64-bit)", "Windows 7");
|
s_mapper.put("Windows 7 (64-bit)", "Windows 7");
|
||||||
s_mapper.put("Windows Server 2003 Enterprise Edition(32-bit)",
|
s_mapper.put("Windows Server 2003 Enterprise Edition(32-bit)",
|
||||||
"Windows Server 2003");
|
"Windows Server 2003");
|
||||||
s_mapper.put("Windows Server 2003 Enterprise Edition(64-bit)",
|
s_mapper.put("Windows Server 2003 Enterprise Edition(64-bit)",
|
||||||
"Windows Server 2003");
|
"Windows Server 2003");
|
||||||
s_mapper.put("Windows Server 2003 DataCenter Edition(32-bit)",
|
s_mapper.put("Windows Server 2003 DataCenter Edition(32-bit)",
|
||||||
"Windows Server 2003");
|
"Windows Server 2003");
|
||||||
s_mapper.put("Windows Server 2003 DataCenter Edition(64-bit)",
|
s_mapper.put("Windows Server 2003 DataCenter Edition(64-bit)",
|
||||||
"Windows Server 2003");
|
"Windows Server 2003");
|
||||||
s_mapper.put("Windows Server 2003 Standard Edition(32-bit)",
|
s_mapper.put("Windows Server 2003 Standard Edition(32-bit)",
|
||||||
"Windows Server 2003");
|
"Windows Server 2003");
|
||||||
s_mapper.put("Windows Server 2003 Standard Edition(64-bit)",
|
s_mapper.put("Windows Server 2003 Standard Edition(64-bit)",
|
||||||
"Windows Server 2003");
|
"Windows Server 2003");
|
||||||
s_mapper.put("Windows Server 2003 Web Edition", "Windows Server 2003");
|
s_mapper.put("Windows Server 2003 Web Edition", "Windows Server 2003");
|
||||||
s_mapper.put("Microsoft Small Bussiness Server 2003",
|
s_mapper.put("Microsoft Small Bussiness Server 2003",
|
||||||
"Windows Server 2003");
|
"Windows Server 2003");
|
||||||
s_mapper.put("Windows Server 2008 (32-bit)", "Windows Server 2008");
|
s_mapper.put("Windows Server 2008 (32-bit)", "Windows Server 2008");
|
||||||
s_mapper.put("Windows Server 2008 (64-bit)", "Windows Server 2008");
|
s_mapper.put("Windows Server 2008 (64-bit)", "Windows Server 2008");
|
||||||
s_mapper.put("Windows Server 2008 R2 (64-bit)", "Windows Server 2008");
|
s_mapper.put("Windows Server 2008 R2 (64-bit)", "Windows Server 2008");
|
||||||
s_mapper.put("Windows 2000 Server SP4 (32-bit)", "Windows 2000");
|
s_mapper.put("Windows 2000 Server SP4 (32-bit)", "Windows 2000");
|
||||||
s_mapper.put("Windows 2000 Server", "Windows 2000");
|
s_mapper.put("Windows 2000 Server", "Windows 2000");
|
||||||
s_mapper.put("Windows 2000 Advanced Server", "Windows 2000");
|
s_mapper.put("Windows 2000 Advanced Server", "Windows 2000");
|
||||||
s_mapper.put("Windows 2000 Professional", "Windows 2000");
|
s_mapper.put("Windows 2000 Professional", "Windows 2000");
|
||||||
s_mapper.put("Windows Vista (32-bit)", "Windows Vista");
|
s_mapper.put("Windows Vista (32-bit)", "Windows Vista");
|
||||||
s_mapper.put("Windows Vista (64-bit)", "Windows Vista");
|
s_mapper.put("Windows Vista (64-bit)", "Windows Vista");
|
||||||
s_mapper.put("Windows XP SP2 (32-bit)", "Windows XP");
|
s_mapper.put("Windows XP SP2 (32-bit)", "Windows XP");
|
||||||
s_mapper.put("Windows XP SP3 (32-bit)", "Windows XP");
|
s_mapper.put("Windows XP SP3 (32-bit)", "Windows XP");
|
||||||
s_mapper.put("Windows XP (32-bit)", "Windows XP");
|
s_mapper.put("Windows XP (32-bit)", "Windows XP");
|
||||||
s_mapper.put("Windows XP (64-bit)", "Windows XP");
|
s_mapper.put("Windows XP (64-bit)", "Windows XP");
|
||||||
s_mapper.put("Windows 98", "Windows 98");
|
s_mapper.put("Windows 98", "Windows 98");
|
||||||
s_mapper.put("Windows 95", "Windows 95");
|
s_mapper.put("Windows 95", "Windows 95");
|
||||||
s_mapper.put("Windows NT 4", "Windows NT");
|
s_mapper.put("Windows NT 4", "Windows NT");
|
||||||
s_mapper.put("Windows 3.1", "Windows 3.1");
|
s_mapper.put("Windows 3.1", "Windows 3.1");
|
||||||
s_mapper.put("Windows PV", "Other PV");
|
s_mapper.put("Windows PV", "Other PV");
|
||||||
s_mapper.put("Other PV (32-bit)", "Other PV");
|
s_mapper.put("Other PV (32-bit)", "Other PV");
|
||||||
s_mapper.put("Other PV (64-bit)", "Other PV");
|
s_mapper.put("Other PV (64-bit)", "Other PV");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getGuestOsName(String guestOsName) {
|
public static String getGuestOsName(String guestOsName) {
|
||||||
String guestOS = s_mapper.get(guestOsName);
|
String guestOS = s_mapper.get(guestOsName);
|
||||||
if (guestOS == null) {
|
if (guestOS == null) {
|
||||||
s_logger.debug("Can't find the mapping of guest os: " + guestOsName);
|
s_logger.debug("Can't find the mapping of guest os: " + guestOsName);
|
||||||
return "Other";
|
return "Other";
|
||||||
} else {
|
} else {
|
||||||
return guestOS;
|
return guestOS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,187 +34,187 @@ import com.cloud.utils.script.OutputInterpreter.AllLinesParser;
|
|||||||
import com.cloud.utils.script.Script;
|
import com.cloud.utils.script.Script;
|
||||||
|
|
||||||
public class KVMHABase {
|
public class KVMHABase {
|
||||||
private long _timeout = 60000; /* 1 minutes */
|
private long _timeout = 60000; /* 1 minutes */
|
||||||
protected static String _heartBeatPath;
|
protected static String _heartBeatPath;
|
||||||
protected long _heartBeatUpdateTimeout = 60000;
|
protected long _heartBeatUpdateTimeout = 60000;
|
||||||
protected long _heartBeatUpdateFreq = 60000;
|
protected long _heartBeatUpdateFreq = 60000;
|
||||||
protected long _heartBeatUpdateMaxRetry = 3;
|
protected long _heartBeatUpdateMaxRetry = 3;
|
||||||
|
|
||||||
public static enum PoolType {
|
public static enum PoolType {
|
||||||
PrimaryStorage, SecondaryStorage
|
PrimaryStorage, SecondaryStorage
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class NfsStoragePool {
|
public static class NfsStoragePool {
|
||||||
String _poolUUID;
|
String _poolUUID;
|
||||||
String _poolIp;
|
String _poolIp;
|
||||||
String _poolMountSourcePath;
|
String _poolMountSourcePath;
|
||||||
String _mountDestPath;
|
String _mountDestPath;
|
||||||
PoolType _type;
|
PoolType _type;
|
||||||
|
|
||||||
public NfsStoragePool(String poolUUID, String poolIp,
|
public NfsStoragePool(String poolUUID, String poolIp,
|
||||||
String poolSourcePath, String mountDestPath, PoolType type) {
|
String poolSourcePath, String mountDestPath, PoolType type) {
|
||||||
this._poolUUID = poolUUID;
|
this._poolUUID = poolUUID;
|
||||||
this._poolIp = poolIp;
|
this._poolIp = poolIp;
|
||||||
this._poolMountSourcePath = poolSourcePath;
|
this._poolMountSourcePath = poolSourcePath;
|
||||||
this._mountDestPath = mountDestPath;
|
this._mountDestPath = mountDestPath;
|
||||||
this._type = type;
|
this._type = type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String checkingMountPoint(NfsStoragePool pool, String poolName) {
|
protected String checkingMountPoint(NfsStoragePool pool, String poolName) {
|
||||||
String mountSource = pool._poolIp + ":" + pool._poolMountSourcePath;
|
String mountSource = pool._poolIp + ":" + pool._poolMountSourcePath;
|
||||||
String mountPaths = Script
|
String mountPaths = Script
|
||||||
.runSimpleBashScript("cat /proc/mounts | grep " + mountSource);
|
.runSimpleBashScript("cat /proc/mounts | grep " + mountSource);
|
||||||
String destPath = pool._mountDestPath;
|
String destPath = pool._mountDestPath;
|
||||||
|
|
||||||
if (mountPaths != null) {
|
if (mountPaths != null) {
|
||||||
String token[] = mountPaths.split(" ");
|
String token[] = mountPaths.split(" ");
|
||||||
String mountType = token[2];
|
String mountType = token[2];
|
||||||
String mountDestPath = token[1];
|
String mountDestPath = token[1];
|
||||||
if (mountType.equalsIgnoreCase("nfs")) {
|
if (mountType.equalsIgnoreCase("nfs")) {
|
||||||
if (poolName != null && !mountDestPath.startsWith(destPath)) {
|
if (poolName != null && !mountDestPath.startsWith(destPath)) {
|
||||||
/* we need to mount it under poolName */
|
/* we need to mount it under poolName */
|
||||||
Script mount = new Script("/bin/bash", 60000);
|
Script mount = new Script("/bin/bash", 60000);
|
||||||
mount.add("-c");
|
mount.add("-c");
|
||||||
mount.add("mount " + mountSource + " " + destPath);
|
mount.add("mount " + mountSource + " " + destPath);
|
||||||
String result = mount.execute();
|
String result = mount.execute();
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
destPath = null;
|
destPath = null;
|
||||||
}
|
}
|
||||||
destroyVMs(destPath);
|
destroyVMs(destPath);
|
||||||
} else if (poolName == null) {
|
} else if (poolName == null) {
|
||||||
destPath = mountDestPath;
|
destPath = mountDestPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Can't find the mount point? */
|
/* Can't find the mount point? */
|
||||||
/* we need to mount it under poolName */
|
/* we need to mount it under poolName */
|
||||||
if (poolName != null) {
|
if (poolName != null) {
|
||||||
Script mount = new Script("/bin/bash", 60000);
|
Script mount = new Script("/bin/bash", 60000);
|
||||||
mount.add("-c");
|
mount.add("-c");
|
||||||
mount.add("mount " + mountSource + " " + destPath);
|
mount.add("mount " + mountSource + " " + destPath);
|
||||||
String result = mount.execute();
|
String result = mount.execute();
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
destPath = null;
|
destPath = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
destroyVMs(destPath);
|
destroyVMs(destPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return destPath;
|
return destPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getMountPoint(NfsStoragePool storagePool) {
|
protected String getMountPoint(NfsStoragePool storagePool) {
|
||||||
|
|
||||||
StoragePool pool = null;
|
StoragePool pool = null;
|
||||||
String poolName = null;
|
String poolName = null;
|
||||||
try {
|
try {
|
||||||
pool = LibvirtConnection.getConnection()
|
pool = LibvirtConnection.getConnection()
|
||||||
.storagePoolLookupByUUIDString(storagePool._poolUUID);
|
.storagePoolLookupByUUIDString(storagePool._poolUUID);
|
||||||
if (pool != null) {
|
if (pool != null) {
|
||||||
StoragePoolInfo spi = pool.getInfo();
|
StoragePoolInfo spi = pool.getInfo();
|
||||||
if (spi.state != StoragePoolState.VIR_STORAGE_POOL_RUNNING) {
|
if (spi.state != StoragePoolState.VIR_STORAGE_POOL_RUNNING) {
|
||||||
pool.create(0);
|
pool.create(0);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* Sometimes, the mount point is lost, even libvirt thinks
|
* Sometimes, the mount point is lost, even libvirt thinks
|
||||||
* the storage pool still running
|
* the storage pool still running
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
poolName = pool.getName();
|
poolName = pool.getName();
|
||||||
} catch (LibvirtException e) {
|
} catch (LibvirtException e) {
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
if (pool != null) {
|
if (pool != null) {
|
||||||
pool.free();
|
pool.free();
|
||||||
}
|
}
|
||||||
} catch (LibvirtException e) {
|
} catch (LibvirtException e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return checkingMountPoint(storagePool, poolName);
|
return checkingMountPoint(storagePool, poolName);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void destroyVMs(String mountPath) {
|
protected void destroyVMs(String mountPath) {
|
||||||
/* if there are VMs using disks under this mount path, destroy them */
|
/* if there are VMs using disks under this mount path, destroy them */
|
||||||
Script cmd = new Script("/bin/bash", _timeout);
|
Script cmd = new Script("/bin/bash", _timeout);
|
||||||
cmd.add("-c");
|
cmd.add("-c");
|
||||||
cmd.add("ps axu|grep qemu|grep " + mountPath + "* |awk '{print $2}'");
|
cmd.add("ps axu|grep qemu|grep " + mountPath + "* |awk '{print $2}'");
|
||||||
AllLinesParser parser = new OutputInterpreter.AllLinesParser();
|
AllLinesParser parser = new OutputInterpreter.AllLinesParser();
|
||||||
String result = cmd.execute(parser);
|
String result = cmd.execute(parser);
|
||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String pids[] = parser.getLines().split("\n");
|
String pids[] = parser.getLines().split("\n");
|
||||||
for (String pid : pids) {
|
for (String pid : pids) {
|
||||||
Script.runSimpleBashScript("kill -9 " + pid);
|
Script.runSimpleBashScript("kill -9 " + pid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getHBFile(String mountPoint, String hostIP) {
|
protected String getHBFile(String mountPoint, String hostIP) {
|
||||||
return mountPoint + File.separator + "KVMHA" + File.separator + "hb-"
|
return mountPoint + File.separator + "KVMHA" + File.separator + "hb-"
|
||||||
+ hostIP;
|
+ hostIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getHBFolder(String mountPoint) {
|
protected String getHBFolder(String mountPoint) {
|
||||||
return mountPoint + File.separator + "KVMHA" + File.separator;
|
return mountPoint + File.separator + "KVMHA" + File.separator;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String runScriptRetry(String cmdString,
|
protected String runScriptRetry(String cmdString,
|
||||||
OutputInterpreter interpreter) {
|
OutputInterpreter interpreter) {
|
||||||
String result = null;
|
String result = null;
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
Script cmd = new Script("/bin/bash", _timeout);
|
Script cmd = new Script("/bin/bash", _timeout);
|
||||||
cmd.add("-c");
|
cmd.add("-c");
|
||||||
cmd.add(cmdString);
|
cmd.add(cmdString);
|
||||||
if (interpreter != null)
|
if (interpreter != null)
|
||||||
result = cmd.execute(interpreter);
|
result = cmd.execute(interpreter);
|
||||||
else {
|
else {
|
||||||
result = cmd.execute();
|
result = cmd.execute();
|
||||||
}
|
}
|
||||||
if (result == Script.ERR_TIMEOUT) {
|
if (result == Script.ERR_TIMEOUT) {
|
||||||
continue;
|
continue;
|
||||||
} else if (result == null) {
|
} else if (result == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
NfsStoragePool pool = new KVMHAMonitor.NfsStoragePool(null, null, null,
|
NfsStoragePool pool = new KVMHAMonitor.NfsStoragePool(null, null, null,
|
||||||
null, PoolType.PrimaryStorage);
|
null, PoolType.PrimaryStorage);
|
||||||
|
|
||||||
KVMHAMonitor haWritter = new KVMHAMonitor(pool, "192.168.1.163", null);
|
KVMHAMonitor haWritter = new KVMHAMonitor(pool, "192.168.1.163", null);
|
||||||
Thread ha = new Thread(haWritter);
|
Thread ha = new Thread(haWritter);
|
||||||
ha.start();
|
ha.start();
|
||||||
|
|
||||||
KVMHAChecker haChecker = new KVMHAChecker(haWritter.getStoragePools(),
|
KVMHAChecker haChecker = new KVMHAChecker(haWritter.getStoragePools(),
|
||||||
"192.168.1.163");
|
"192.168.1.163");
|
||||||
|
|
||||||
ExecutorService exe = Executors.newFixedThreadPool(1);
|
ExecutorService exe = Executors.newFixedThreadPool(1);
|
||||||
Future<Boolean> future = exe.submit((Callable<Boolean>) haChecker);
|
Future<Boolean> future = exe.submit((Callable<Boolean>) haChecker);
|
||||||
try {
|
try {
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
System.out.println(future.get());
|
System.out.println(future.get());
|
||||||
future = exe.submit((Callable<Boolean>) haChecker);
|
future = exe.submit((Callable<Boolean>) haChecker);
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,59 +27,59 @@ import com.cloud.utils.script.OutputInterpreter;
|
|||||||
import com.cloud.utils.script.Script;
|
import com.cloud.utils.script.Script;
|
||||||
|
|
||||||
public class KVMHAChecker extends KVMHABase implements Callable<Boolean> {
|
public class KVMHAChecker extends KVMHABase implements Callable<Boolean> {
|
||||||
private static final Logger s_logger = Logger.getLogger(KVMHAChecker.class);
|
private static final Logger s_logger = Logger.getLogger(KVMHAChecker.class);
|
||||||
private List<NfsStoragePool> _pools;
|
private List<NfsStoragePool> _pools;
|
||||||
private String _hostIP;
|
private String _hostIP;
|
||||||
private long _heartBeatCheckerTimeout = 360000; /* 6 minutes */
|
private long _heartBeatCheckerTimeout = 360000; /* 6 minutes */
|
||||||
|
|
||||||
public KVMHAChecker(List<NfsStoragePool> pools, String host) {
|
public KVMHAChecker(List<NfsStoragePool> pools, String host) {
|
||||||
this._pools = pools;
|
this._pools = pools;
|
||||||
this._hostIP = host;
|
this._hostIP = host;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* True means heartbeaing is on going, or we can't get it's status. False
|
* True means heartbeaing is on going, or we can't get it's status. False
|
||||||
* means heartbeating is stopped definitely
|
* means heartbeating is stopped definitely
|
||||||
*/
|
*/
|
||||||
private Boolean checkingHB() {
|
private Boolean checkingHB() {
|
||||||
List<Boolean> results = new ArrayList<Boolean>();
|
List<Boolean> results = new ArrayList<Boolean>();
|
||||||
for (NfsStoragePool pool : _pools) {
|
for (NfsStoragePool pool : _pools) {
|
||||||
|
|
||||||
Script cmd = new Script(_heartBeatPath, _heartBeatCheckerTimeout,
|
Script cmd = new Script(_heartBeatPath, _heartBeatCheckerTimeout,
|
||||||
s_logger);
|
s_logger);
|
||||||
cmd.add("-i", pool._poolIp);
|
cmd.add("-i", pool._poolIp);
|
||||||
cmd.add("-p", pool._poolMountSourcePath);
|
cmd.add("-p", pool._poolMountSourcePath);
|
||||||
cmd.add("-m", pool._mountDestPath);
|
cmd.add("-m", pool._mountDestPath);
|
||||||
cmd.add("-h", _hostIP);
|
cmd.add("-h", _hostIP);
|
||||||
cmd.add("-r");
|
cmd.add("-r");
|
||||||
cmd.add("-t",
|
cmd.add("-t",
|
||||||
String.valueOf((_heartBeatUpdateFreq + _heartBeatUpdateTimeout) / 1000 * 2));
|
String.valueOf((_heartBeatUpdateFreq + _heartBeatUpdateTimeout) / 1000 * 2));
|
||||||
OutputInterpreter.OneLineParser parser = new OutputInterpreter.OneLineParser();
|
OutputInterpreter.OneLineParser parser = new OutputInterpreter.OneLineParser();
|
||||||
String result = cmd.execute(parser);
|
String result = cmd.execute(parser);
|
||||||
s_logger.debug("pool: " + pool._poolIp);
|
s_logger.debug("pool: " + pool._poolIp);
|
||||||
s_logger.debug("reture: " + result);
|
s_logger.debug("reture: " + result);
|
||||||
s_logger.debug("parser: " + parser.getLine());
|
s_logger.debug("parser: " + parser.getLine());
|
||||||
if (result == null && parser.getLine().contains("> DEAD <")) {
|
if (result == null && parser.getLine().contains("> DEAD <")) {
|
||||||
s_logger.debug("read heartbeat failed: " + result);
|
s_logger.debug("read heartbeat failed: " + result);
|
||||||
results.add(false);
|
results.add(false);
|
||||||
} else {
|
} else {
|
||||||
results.add(true);
|
results.add(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Boolean r : results) {
|
for (Boolean r : results) {
|
||||||
if (r) {
|
if (r) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean call() throws Exception {
|
public Boolean call() throws Exception {
|
||||||
// s_logger.addAppender(new org.apache.log4j.ConsoleAppender(new
|
// s_logger.addAppender(new org.apache.log4j.ConsoleAppender(new
|
||||||
// org.apache.log4j.PatternLayout(), "System.out"));
|
// org.apache.log4j.PatternLayout(), "System.out"));
|
||||||
return checkingHB();
|
return checkingHB();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,96 +24,96 @@ import org.apache.log4j.Logger;
|
|||||||
import com.cloud.utils.script.Script;
|
import com.cloud.utils.script.Script;
|
||||||
|
|
||||||
public class KVMHAMonitor extends KVMHABase implements Runnable {
|
public class KVMHAMonitor extends KVMHABase implements Runnable {
|
||||||
private static final Logger s_logger = Logger.getLogger(KVMHAMonitor.class);
|
private static final Logger s_logger = Logger.getLogger(KVMHAMonitor.class);
|
||||||
private Map<String, NfsStoragePool> _storagePool = new ConcurrentHashMap<String, NfsStoragePool>();
|
private Map<String, NfsStoragePool> _storagePool = new ConcurrentHashMap<String, NfsStoragePool>();
|
||||||
|
|
||||||
private String _hostIP; /* private ip address */
|
private String _hostIP; /* private ip address */
|
||||||
|
|
||||||
public KVMHAMonitor(NfsStoragePool pool, String host, String scriptPath) {
|
public KVMHAMonitor(NfsStoragePool pool, String host, String scriptPath) {
|
||||||
if (pool != null) {
|
if (pool != null) {
|
||||||
this._storagePool.put(pool._poolUUID, pool);
|
this._storagePool.put(pool._poolUUID, pool);
|
||||||
}
|
}
|
||||||
this._hostIP = host;
|
this._hostIP = host;
|
||||||
this._heartBeatPath = scriptPath;
|
this._heartBeatPath = scriptPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addStoragePool(NfsStoragePool pool) {
|
public void addStoragePool(NfsStoragePool pool) {
|
||||||
synchronized (_storagePool) {
|
synchronized (_storagePool) {
|
||||||
this._storagePool.put(pool._poolUUID, pool);
|
this._storagePool.put(pool._poolUUID, pool);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeStoragePool(String uuid) {
|
public void removeStoragePool(String uuid) {
|
||||||
synchronized (_storagePool) {
|
synchronized (_storagePool) {
|
||||||
this._storagePool.remove(uuid);
|
this._storagePool.remove(uuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<NfsStoragePool> getStoragePools() {
|
public List<NfsStoragePool> getStoragePools() {
|
||||||
synchronized (_storagePool) {
|
synchronized (_storagePool) {
|
||||||
return new ArrayList<NfsStoragePool>(_storagePool.values());
|
return new ArrayList<NfsStoragePool>(_storagePool.values());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Monitor implements Runnable {
|
private class Monitor implements Runnable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
synchronized (_storagePool) {
|
synchronized (_storagePool) {
|
||||||
for (NfsStoragePool primaryStoragePool : _storagePool.values()) {
|
for (NfsStoragePool primaryStoragePool : _storagePool.values()) {
|
||||||
String result = null;
|
String result = null;
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
Script cmd = new Script(_heartBeatPath,
|
Script cmd = new Script(_heartBeatPath,
|
||||||
_heartBeatUpdateTimeout, s_logger);
|
_heartBeatUpdateTimeout, s_logger);
|
||||||
cmd.add("-i", primaryStoragePool._poolIp);
|
cmd.add("-i", primaryStoragePool._poolIp);
|
||||||
cmd.add("-p", primaryStoragePool._poolMountSourcePath);
|
cmd.add("-p", primaryStoragePool._poolMountSourcePath);
|
||||||
cmd.add("-m", primaryStoragePool._mountDestPath);
|
cmd.add("-m", primaryStoragePool._mountDestPath);
|
||||||
cmd.add("-h", _hostIP);
|
cmd.add("-h", _hostIP);
|
||||||
result = cmd.execute();
|
result = cmd.execute();
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
s_logger.warn("write heartbeat failed: " + result
|
s_logger.warn("write heartbeat failed: " + result
|
||||||
+ ", retry: " + i);
|
+ ", retry: " + i);
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
s_logger.warn("write heartbeat failed: " + result
|
s_logger.warn("write heartbeat failed: " + result
|
||||||
+ "; reboot the host");
|
+ "; reboot the host");
|
||||||
Script cmd = new Script(_heartBeatPath,
|
Script cmd = new Script(_heartBeatPath,
|
||||||
_heartBeatUpdateTimeout, s_logger);
|
_heartBeatUpdateTimeout, s_logger);
|
||||||
cmd.add("-i", primaryStoragePool._poolIp);
|
cmd.add("-i", primaryStoragePool._poolIp);
|
||||||
cmd.add("-p", primaryStoragePool._poolMountSourcePath);
|
cmd.add("-p", primaryStoragePool._poolMountSourcePath);
|
||||||
cmd.add("-m", primaryStoragePool._mountDestPath);
|
cmd.add("-m", primaryStoragePool._mountDestPath);
|
||||||
cmd.add("-c");
|
cmd.add("-c");
|
||||||
result = cmd.execute();
|
result = cmd.execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// s_logger.addAppender(new org.apache.log4j.ConsoleAppender(new
|
// s_logger.addAppender(new org.apache.log4j.ConsoleAppender(new
|
||||||
// org.apache.log4j.PatternLayout(), "System.out"));
|
// org.apache.log4j.PatternLayout(), "System.out"));
|
||||||
while (true) {
|
while (true) {
|
||||||
Thread monitorThread = new Thread(new Monitor());
|
Thread monitorThread = new Thread(new Monitor());
|
||||||
monitorThread.start();
|
monitorThread.start();
|
||||||
try {
|
try {
|
||||||
monitorThread.join();
|
monitorThread.join();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(_heartBeatUpdateFreq);
|
Thread.sleep(_heartBeatUpdateFreq);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,165 +30,165 @@ import org.xml.sax.SAXException;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class LibvirtCapXMLParser extends LibvirtXMLParser {
|
public class LibvirtCapXMLParser extends LibvirtXMLParser {
|
||||||
private boolean _host = false;
|
private boolean _host = false;
|
||||||
private boolean _guest = false;
|
private boolean _guest = false;
|
||||||
private boolean _osType = false;
|
private boolean _osType = false;
|
||||||
private boolean _domainTypeKVM = false;
|
private boolean _domainTypeKVM = false;
|
||||||
private boolean _emulatorFlag = false;
|
private boolean _emulatorFlag = false;
|
||||||
private final StringBuffer _emulator = new StringBuffer();
|
private final StringBuffer _emulator = new StringBuffer();
|
||||||
private final StringBuffer _capXML = new StringBuffer();
|
private final StringBuffer _capXML = new StringBuffer();
|
||||||
private static final Logger s_logger = Logger
|
private static final Logger s_logger = Logger
|
||||||
.getLogger(LibvirtCapXMLParser.class);
|
.getLogger(LibvirtCapXMLParser.class);
|
||||||
private final ArrayList<String> guestOsTypes = new ArrayList<String>();
|
private final ArrayList<String> guestOsTypes = new ArrayList<String>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void endElement(String uri, String localName, String qName)
|
public void endElement(String uri, String localName, String qName)
|
||||||
throws SAXException {
|
throws SAXException {
|
||||||
if (qName.equalsIgnoreCase("host")) {
|
if (qName.equalsIgnoreCase("host")) {
|
||||||
_host = false;
|
_host = false;
|
||||||
} else if (qName.equalsIgnoreCase("os_type")) {
|
} else if (qName.equalsIgnoreCase("os_type")) {
|
||||||
_osType = false;
|
_osType = false;
|
||||||
} else if (qName.equalsIgnoreCase("guest")) {
|
} else if (qName.equalsIgnoreCase("guest")) {
|
||||||
_guest = false;
|
_guest = false;
|
||||||
} else if (qName.equalsIgnoreCase("domain")) {
|
} else if (qName.equalsIgnoreCase("domain")) {
|
||||||
_domainTypeKVM = false;
|
_domainTypeKVM = false;
|
||||||
} else if (qName.equalsIgnoreCase("emulator")) {
|
} else if (qName.equalsIgnoreCase("emulator")) {
|
||||||
_emulatorFlag = false;
|
_emulatorFlag = false;
|
||||||
|
|
||||||
} else if (_host) {
|
} else if (_host) {
|
||||||
_capXML.append("<").append("/").append(qName).append(">");
|
_capXML.append("<").append("/").append(qName).append(">");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void characters(char[] ch, int start, int length)
|
public void characters(char[] ch, int start, int length)
|
||||||
throws SAXException {
|
throws SAXException {
|
||||||
if (_host) {
|
if (_host) {
|
||||||
_capXML.append(ch, start, length);
|
_capXML.append(ch, start, length);
|
||||||
} else if (_osType) {
|
} else if (_osType) {
|
||||||
guestOsTypes.add(new String(ch, start, length));
|
guestOsTypes.add(new String(ch, start, length));
|
||||||
} else if (_emulatorFlag) {
|
} else if (_emulatorFlag) {
|
||||||
_emulator.append(ch, start, length);
|
_emulator.append(ch, start, length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startElement(String uri, String localName, String qName,
|
public void startElement(String uri, String localName, String qName,
|
||||||
Attributes attributes) throws SAXException {
|
Attributes attributes) throws SAXException {
|
||||||
if (qName.equalsIgnoreCase("host")) {
|
if (qName.equalsIgnoreCase("host")) {
|
||||||
_host = true;
|
_host = true;
|
||||||
} else if (qName.equalsIgnoreCase("guest")) {
|
} else if (qName.equalsIgnoreCase("guest")) {
|
||||||
_guest = true;
|
_guest = true;
|
||||||
} else if (qName.equalsIgnoreCase("os_type")) {
|
} else if (qName.equalsIgnoreCase("os_type")) {
|
||||||
if (_guest) {
|
if (_guest) {
|
||||||
_osType = true;
|
_osType = true;
|
||||||
}
|
}
|
||||||
} else if (qName.equalsIgnoreCase("domain")) {
|
} else if (qName.equalsIgnoreCase("domain")) {
|
||||||
for (int i = 0; i < attributes.getLength(); i++) {
|
for (int i = 0; i < attributes.getLength(); i++) {
|
||||||
if (attributes.getQName(i).equalsIgnoreCase("type")
|
if (attributes.getQName(i).equalsIgnoreCase("type")
|
||||||
&& attributes.getValue(i).equalsIgnoreCase("kvm")) {
|
&& attributes.getValue(i).equalsIgnoreCase("kvm")) {
|
||||||
_domainTypeKVM = true;
|
_domainTypeKVM = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (qName.equalsIgnoreCase("emulator") && _domainTypeKVM) {
|
} else if (qName.equalsIgnoreCase("emulator") && _domainTypeKVM) {
|
||||||
_emulatorFlag = true;
|
_emulatorFlag = true;
|
||||||
_emulator.delete(0, _emulator.length());
|
_emulator.delete(0, _emulator.length());
|
||||||
} else if (_host) {
|
} else if (_host) {
|
||||||
_capXML.append("<").append(qName);
|
_capXML.append("<").append(qName);
|
||||||
for (int i = 0; i < attributes.getLength(); i++) {
|
for (int i = 0; i < attributes.getLength(); i++) {
|
||||||
_capXML.append(" ").append(attributes.getQName(i)).append("=")
|
_capXML.append(" ").append(attributes.getQName(i)).append("=")
|
||||||
.append(attributes.getValue(i));
|
.append(attributes.getValue(i));
|
||||||
}
|
}
|
||||||
_capXML.append(">");
|
_capXML.append(">");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String parseCapabilitiesXML(String capXML) {
|
public String parseCapabilitiesXML(String capXML) {
|
||||||
if (!_initialized) {
|
if (!_initialized) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
_sp.parse(new InputSource(new StringReader(capXML)), this);
|
_sp.parse(new InputSource(new StringReader(capXML)), this);
|
||||||
return _capXML.toString();
|
return _capXML.toString();
|
||||||
} catch (SAXException se) {
|
} catch (SAXException se) {
|
||||||
s_logger.warn(se.getMessage());
|
s_logger.warn(se.getMessage());
|
||||||
} catch (IOException ie) {
|
} catch (IOException ie) {
|
||||||
s_logger.error(ie.getMessage());
|
s_logger.error(ie.getMessage());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<String> getGuestOsType() {
|
public ArrayList<String> getGuestOsType() {
|
||||||
return guestOsTypes;
|
return guestOsTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEmulator() {
|
public String getEmulator() {
|
||||||
return _emulator.toString();
|
return _emulator.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
String capXML = "<capabilities>" + " <host>" + " <cpu>"
|
String capXML = "<capabilities>" + " <host>" + " <cpu>"
|
||||||
+ " <arch>x86_64</arch>" + " <model>core2duo</model>"
|
+ " <arch>x86_64</arch>" + " <model>core2duo</model>"
|
||||||
+ " <topology sockets='1' cores='2' threads='1'/>"
|
+ " <topology sockets='1' cores='2' threads='1'/>"
|
||||||
+ " <feature name='lahf_lm'/>"
|
+ " <feature name='lahf_lm'/>"
|
||||||
+ " <feature name='xtpr'/>"
|
+ " <feature name='xtpr'/>"
|
||||||
+ " <feature name='cx16'/>"
|
+ " <feature name='cx16'/>"
|
||||||
+ " <feature name='tm2'/>" + " <feature name='est'/>"
|
+ " <feature name='tm2'/>" + " <feature name='est'/>"
|
||||||
+ " <feature name='vmx'/>"
|
+ " <feature name='vmx'/>"
|
||||||
+ " <feature name='ds_cpl'/>"
|
+ " <feature name='ds_cpl'/>"
|
||||||
+ " <feature name='pbe'/>" + " <feature name='tm'/>"
|
+ " <feature name='pbe'/>" + " <feature name='tm'/>"
|
||||||
+ " <feature name='ht'/>" + " <feature name='ss'/>"
|
+ " <feature name='ht'/>" + " <feature name='ss'/>"
|
||||||
+ " <feature name='acpi'/>" + " <feature name='ds'/>"
|
+ " <feature name='acpi'/>" + " <feature name='ds'/>"
|
||||||
+ " </cpu>" + " <migration_features>" + " <live/>"
|
+ " </cpu>" + " <migration_features>" + " <live/>"
|
||||||
+ " <uri_transports>"
|
+ " <uri_transports>"
|
||||||
+ " <uri_transport>tcp</uri_transport>"
|
+ " <uri_transport>tcp</uri_transport>"
|
||||||
+ " </uri_transports>" + " </migration_features>"
|
+ " </uri_transports>" + " </migration_features>"
|
||||||
+ " <topology>" + " <cells num='1'>"
|
+ " <topology>" + " <cells num='1'>"
|
||||||
+ " <cell id='0'>" + " <cpus num='2'>"
|
+ " <cell id='0'>" + " <cpus num='2'>"
|
||||||
+ " <cpu id='0'/>" + " <cpu id='1'/>"
|
+ " <cpu id='0'/>" + " <cpu id='1'/>"
|
||||||
+ " </cpus>" + " </cell>" + " </cells>"
|
+ " </cpus>" + " </cell>" + " </cells>"
|
||||||
+ " </topology>" + " </host>" + "" + " <guest>"
|
+ " </topology>" + " </host>" + "" + " <guest>"
|
||||||
+ " <os_type>hvm</os_type>" + " <arch name='i686'>"
|
+ " <os_type>hvm</os_type>" + " <arch name='i686'>"
|
||||||
+ " <wordsize>32</wordsize>"
|
+ " <wordsize>32</wordsize>"
|
||||||
+ " <emulator>/usr/bin/qemu</emulator>"
|
+ " <emulator>/usr/bin/qemu</emulator>"
|
||||||
+ " <machine>pc-0.11</machine>"
|
+ " <machine>pc-0.11</machine>"
|
||||||
+ " <machine canonical='pc-0.11'>pc</machine>"
|
+ " <machine canonical='pc-0.11'>pc</machine>"
|
||||||
+ " <machine>pc-0.10</machine>"
|
+ " <machine>pc-0.10</machine>"
|
||||||
+ " <machine>isapc</machine>"
|
+ " <machine>isapc</machine>"
|
||||||
+ " <domain type='qemu'>" + " </domain>"
|
+ " <domain type='qemu'>" + " </domain>"
|
||||||
+ " <domain type='kvm'>"
|
+ " <domain type='kvm'>"
|
||||||
+ " <emulator>/usr/bin/qemu-kvm</emulator>"
|
+ " <emulator>/usr/bin/qemu-kvm</emulator>"
|
||||||
+ " <machine>pc-0.11</machine>"
|
+ " <machine>pc-0.11</machine>"
|
||||||
+ " <machine canonical='pc-0.11'>pc</machine>"
|
+ " <machine canonical='pc-0.11'>pc</machine>"
|
||||||
+ " <machine>pc-0.10</machine>"
|
+ " <machine>pc-0.10</machine>"
|
||||||
+ " <machine>isapc</machine>" + " </domain>"
|
+ " <machine>isapc</machine>" + " </domain>"
|
||||||
+ " </arch>" + " <features>" + " <cpuselection/>"
|
+ " </arch>" + " <features>" + " <cpuselection/>"
|
||||||
+ " <pae/>" + " <nonpae/>"
|
+ " <pae/>" + " <nonpae/>"
|
||||||
+ " <acpi default='on' toggle='yes'/>"
|
+ " <acpi default='on' toggle='yes'/>"
|
||||||
+ " <apic default='on' toggle='no'/>" + " </features>"
|
+ " <apic default='on' toggle='no'/>" + " </features>"
|
||||||
+ " </guest>" + " <guest>" + " <os_type>hvm</os_type>"
|
+ " </guest>" + " <guest>" + " <os_type>hvm</os_type>"
|
||||||
+ " <arch name='x86_64'>" + " <wordsize>64</wordsize>"
|
+ " <arch name='x86_64'>" + " <wordsize>64</wordsize>"
|
||||||
+ " <emulator>/usr/bin/qemu-system-x86_64</emulator>"
|
+ " <emulator>/usr/bin/qemu-system-x86_64</emulator>"
|
||||||
+ " <machine>pc-0.11</machine>"
|
+ " <machine>pc-0.11</machine>"
|
||||||
+ " <machine canonical='pc-0.11'>pc</machine>"
|
+ " <machine canonical='pc-0.11'>pc</machine>"
|
||||||
+ " <machine>pc-0.10</machine>"
|
+ " <machine>pc-0.10</machine>"
|
||||||
+ " <machine>isapc</machine>"
|
+ " <machine>isapc</machine>"
|
||||||
+ " <domain type='qemu'>" + " </domain>"
|
+ " <domain type='qemu'>" + " </domain>"
|
||||||
+ " <domain type='kvm'>"
|
+ " <domain type='kvm'>"
|
||||||
+ " <emulator>/usr/bin/qemu-kvm</emulator>"
|
+ " <emulator>/usr/bin/qemu-kvm</emulator>"
|
||||||
+ " <machine>pc-0.11</machine>"
|
+ " <machine>pc-0.11</machine>"
|
||||||
+ " <machine canonical='pc-0.11'>pc</machine>"
|
+ " <machine canonical='pc-0.11'>pc</machine>"
|
||||||
+ " <machine>pc-0.10</machine>"
|
+ " <machine>pc-0.10</machine>"
|
||||||
+ " <machine>isapc</machine>" + " </domain>"
|
+ " <machine>isapc</machine>" + " </domain>"
|
||||||
+ " </arch>" + " <features>" + " <cpuselection/>"
|
+ " </arch>" + " <features>" + " <cpuselection/>"
|
||||||
+ " <acpi default='on' toggle='yes'/>"
|
+ " <acpi default='on' toggle='yes'/>"
|
||||||
+ " <apic default='on' toggle='no'/>" + " </features>"
|
+ " <apic default='on' toggle='no'/>" + " </features>"
|
||||||
+ " </guest>" + "</capabilities>";
|
+ " </guest>" + "</capabilities>";
|
||||||
|
|
||||||
LibvirtCapXMLParser parser = new LibvirtCapXMLParser();
|
LibvirtCapXMLParser parser = new LibvirtCapXMLParser();
|
||||||
String cap = parser.parseCapabilitiesXML(capXML);
|
String cap = parser.parseCapabilitiesXML(capXML);
|
||||||
System.out.println(parser.getGuestOsType());
|
System.out.println(parser.getGuestOsType());
|
||||||
System.out.println(parser.getEmulator());
|
System.out.println(parser.getEmulator());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -21,28 +21,28 @@ import org.libvirt.Connect;
|
|||||||
import org.libvirt.LibvirtException;
|
import org.libvirt.LibvirtException;
|
||||||
|
|
||||||
public class LibvirtConnection {
|
public class LibvirtConnection {
|
||||||
private static final Logger s_logger = Logger
|
private static final Logger s_logger = Logger
|
||||||
.getLogger(LibvirtConnection.class);
|
.getLogger(LibvirtConnection.class);
|
||||||
static private Connect _connection;
|
static private Connect _connection;
|
||||||
static private String _hypervisorURI;
|
static private String _hypervisorURI;
|
||||||
|
|
||||||
static public Connect getConnection() throws LibvirtException {
|
static public Connect getConnection() throws LibvirtException {
|
||||||
if (_connection == null) {
|
if (_connection == null) {
|
||||||
_connection = new Connect(_hypervisorURI, false);
|
_connection = new Connect(_hypervisorURI, false);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
_connection.getVersion();
|
_connection.getVersion();
|
||||||
} catch (LibvirtException e) {
|
} catch (LibvirtException e) {
|
||||||
s_logger.debug("Connection with libvirtd is broken, due to "
|
s_logger.debug("Connection with libvirtd is broken, due to "
|
||||||
+ e.getMessage());
|
+ e.getMessage());
|
||||||
_connection = new Connect(_hypervisorURI, false);
|
_connection = new Connect(_hypervisorURI, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return _connection;
|
return _connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initialize(String hypervisorURI) {
|
static void initialize(String hypervisorURI) {
|
||||||
_hypervisorURI = hypervisorURI;
|
_hypervisorURI = hypervisorURI;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,209 +45,209 @@ import com.cloud.agent.resource.computing.LibvirtVMDef.InterfaceDef.nicModel;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class LibvirtDomainXMLParser {
|
public class LibvirtDomainXMLParser {
|
||||||
private static final Logger s_logger = Logger
|
private static final Logger s_logger = Logger
|
||||||
.getLogger(LibvirtDomainXMLParser.class);
|
.getLogger(LibvirtDomainXMLParser.class);
|
||||||
private final List<InterfaceDef> interfaces = new ArrayList<InterfaceDef>();
|
private final List<InterfaceDef> interfaces = new ArrayList<InterfaceDef>();
|
||||||
private final List<DiskDef> diskDefs = new ArrayList<DiskDef>();
|
private final List<DiskDef> diskDefs = new ArrayList<DiskDef>();
|
||||||
private Integer vncPort;
|
private Integer vncPort;
|
||||||
private String desc;
|
private String desc;
|
||||||
|
|
||||||
public boolean parseDomainXML(String domXML) {
|
public boolean parseDomainXML(String domXML) {
|
||||||
DocumentBuilder builder;
|
DocumentBuilder builder;
|
||||||
try {
|
try {
|
||||||
builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||||
|
|
||||||
InputSource is = new InputSource();
|
InputSource is = new InputSource();
|
||||||
is.setCharacterStream(new StringReader(domXML));
|
is.setCharacterStream(new StringReader(domXML));
|
||||||
Document doc = builder.parse(is);
|
Document doc = builder.parse(is);
|
||||||
|
|
||||||
Element rootElement = doc.getDocumentElement();
|
Element rootElement = doc.getDocumentElement();
|
||||||
|
|
||||||
desc = getTagValue("description", rootElement);
|
desc = getTagValue("description", rootElement);
|
||||||
|
|
||||||
Element devices = (Element) rootElement.getElementsByTagName(
|
Element devices = (Element) rootElement.getElementsByTagName(
|
||||||
"devices").item(0);
|
"devices").item(0);
|
||||||
NodeList disks = devices.getElementsByTagName("disk");
|
NodeList disks = devices.getElementsByTagName("disk");
|
||||||
for (int i = 0; i < disks.getLength(); i++) {
|
for (int i = 0; i < disks.getLength(); i++) {
|
||||||
Element disk = (Element) disks.item(i);
|
Element disk = (Element) disks.item(i);
|
||||||
String diskFmtType = getAttrValue("driver", "type", disk);
|
String diskFmtType = getAttrValue("driver", "type", disk);
|
||||||
String diskFile = getAttrValue("source", "file", disk);
|
String diskFile = getAttrValue("source", "file", disk);
|
||||||
String diskDev = getAttrValue("source", "dev", disk);
|
String diskDev = getAttrValue("source", "dev", disk);
|
||||||
|
|
||||||
String diskLabel = getAttrValue("target", "dev", disk);
|
String diskLabel = getAttrValue("target", "dev", disk);
|
||||||
String bus = getAttrValue("target", "bus", disk);
|
String bus = getAttrValue("target", "bus", disk);
|
||||||
String type = disk.getAttribute("type");
|
String type = disk.getAttribute("type");
|
||||||
String device = disk.getAttribute("device");
|
String device = disk.getAttribute("device");
|
||||||
|
|
||||||
DiskDef def = new DiskDef();
|
DiskDef def = new DiskDef();
|
||||||
if (type.equalsIgnoreCase("file")) {
|
if (type.equalsIgnoreCase("file")) {
|
||||||
if (device.equalsIgnoreCase("disk")) {
|
if (device.equalsIgnoreCase("disk")) {
|
||||||
DiskDef.diskFmtType fmt = null;
|
DiskDef.diskFmtType fmt = null;
|
||||||
if (diskFmtType != null) {
|
if (diskFmtType != null) {
|
||||||
fmt = DiskDef.diskFmtType.valueOf(diskFmtType
|
fmt = DiskDef.diskFmtType.valueOf(diskFmtType
|
||||||
.toUpperCase());
|
.toUpperCase());
|
||||||
}
|
}
|
||||||
def.defFileBasedDisk(diskFile, diskLabel,
|
def.defFileBasedDisk(diskFile, diskLabel,
|
||||||
DiskDef.diskBus.valueOf(bus.toUpperCase()), fmt);
|
DiskDef.diskBus.valueOf(bus.toUpperCase()), fmt);
|
||||||
} else if (device.equalsIgnoreCase("cdrom")) {
|
} else if (device.equalsIgnoreCase("cdrom")) {
|
||||||
def.defISODisk(diskFile);
|
def.defISODisk(diskFile);
|
||||||
}
|
}
|
||||||
} else if (type.equalsIgnoreCase("block")) {
|
} else if (type.equalsIgnoreCase("block")) {
|
||||||
def.defBlockBasedDisk(diskDev, diskLabel,
|
def.defBlockBasedDisk(diskDev, diskLabel,
|
||||||
DiskDef.diskBus.valueOf(bus.toUpperCase()));
|
DiskDef.diskBus.valueOf(bus.toUpperCase()));
|
||||||
}
|
}
|
||||||
diskDefs.add(def);
|
diskDefs.add(def);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeList nics = devices.getElementsByTagName("interface");
|
NodeList nics = devices.getElementsByTagName("interface");
|
||||||
for (int i = 0; i < nics.getLength(); i++) {
|
for (int i = 0; i < nics.getLength(); i++) {
|
||||||
Element nic = (Element) nics.item(i);
|
Element nic = (Element) nics.item(i);
|
||||||
|
|
||||||
String type = nic.getAttribute("type");
|
String type = nic.getAttribute("type");
|
||||||
String mac = getAttrValue("mac", "address", nic);
|
String mac = getAttrValue("mac", "address", nic);
|
||||||
String dev = getAttrValue("target", "dev", nic);
|
String dev = getAttrValue("target", "dev", nic);
|
||||||
String model = getAttrValue("model", "type", nic);
|
String model = getAttrValue("model", "type", nic);
|
||||||
InterfaceDef def = new InterfaceDef();
|
InterfaceDef def = new InterfaceDef();
|
||||||
|
|
||||||
if (type.equalsIgnoreCase("network")) {
|
if (type.equalsIgnoreCase("network")) {
|
||||||
String network = getAttrValue("source", "network", nic);
|
String network = getAttrValue("source", "network", nic);
|
||||||
def.defPrivateNet(network, dev, mac,
|
def.defPrivateNet(network, dev, mac,
|
||||||
nicModel.valueOf(model.toUpperCase()));
|
nicModel.valueOf(model.toUpperCase()));
|
||||||
} else if (type.equalsIgnoreCase("bridge")) {
|
} else if (type.equalsIgnoreCase("bridge")) {
|
||||||
String bridge = getAttrValue("source", "bridge", nic);
|
String bridge = getAttrValue("source", "bridge", nic);
|
||||||
def.defBridgeNet(bridge, dev, mac,
|
def.defBridgeNet(bridge, dev, mac,
|
||||||
nicModel.valueOf(model.toUpperCase()));
|
nicModel.valueOf(model.toUpperCase()));
|
||||||
}
|
}
|
||||||
interfaces.add(def);
|
interfaces.add(def);
|
||||||
}
|
}
|
||||||
|
|
||||||
Element graphic = (Element) devices
|
Element graphic = (Element) devices
|
||||||
.getElementsByTagName("graphics").item(0);
|
.getElementsByTagName("graphics").item(0);
|
||||||
String port = graphic.getAttribute("port");
|
String port = graphic.getAttribute("port");
|
||||||
if (port != null) {
|
if (port != null) {
|
||||||
try {
|
try {
|
||||||
vncPort = Integer.parseInt(port);
|
vncPort = Integer.parseInt(port);
|
||||||
if (vncPort != -1) {
|
if (vncPort != -1) {
|
||||||
vncPort = vncPort - 5900;
|
vncPort = vncPort - 5900;
|
||||||
} else {
|
} else {
|
||||||
vncPort = null;
|
vncPort = null;
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException nfe) {
|
} catch (NumberFormatException nfe) {
|
||||||
vncPort = null;
|
vncPort = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (ParserConfigurationException e) {
|
} catch (ParserConfigurationException e) {
|
||||||
s_logger.debug(e.toString());
|
s_logger.debug(e.toString());
|
||||||
} catch (SAXException e) {
|
} catch (SAXException e) {
|
||||||
s_logger.debug(e.toString());
|
s_logger.debug(e.toString());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
s_logger.debug(e.toString());
|
s_logger.debug(e.toString());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getTagValue(String tag, Element eElement) {
|
private static String getTagValue(String tag, Element eElement) {
|
||||||
NodeList tagNodeList = eElement.getElementsByTagName(tag);
|
NodeList tagNodeList = eElement.getElementsByTagName(tag);
|
||||||
if (tagNodeList == null || tagNodeList.getLength() == 0) {
|
if (tagNodeList == null || tagNodeList.getLength() == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeList nlList = tagNodeList.item(0).getChildNodes();
|
NodeList nlList = tagNodeList.item(0).getChildNodes();
|
||||||
|
|
||||||
Node nValue = (Node) nlList.item(0);
|
Node nValue = (Node) nlList.item(0);
|
||||||
|
|
||||||
return nValue.getNodeValue();
|
return nValue.getNodeValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getAttrValue(String tag, String attr, Element eElement) {
|
private static String getAttrValue(String tag, String attr, Element eElement) {
|
||||||
NodeList tagNode = eElement.getElementsByTagName(tag);
|
NodeList tagNode = eElement.getElementsByTagName(tag);
|
||||||
if (tagNode.getLength() == 0) {
|
if (tagNode.getLength() == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Element node = (Element) tagNode.item(0);
|
Element node = (Element) tagNode.item(0);
|
||||||
return node.getAttribute(attr);
|
return node.getAttribute(attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getVncPort() {
|
public Integer getVncPort() {
|
||||||
return vncPort;
|
return vncPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<InterfaceDef> getInterfaces() {
|
public List<InterfaceDef> getInterfaces() {
|
||||||
return interfaces;
|
return interfaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DiskDef> getDisks() {
|
public List<DiskDef> getDisks() {
|
||||||
return diskDefs;
|
return diskDefs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public String getDescription() {
|
||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
LibvirtDomainXMLParser parser = new LibvirtDomainXMLParser();
|
LibvirtDomainXMLParser parser = new LibvirtDomainXMLParser();
|
||||||
parser.parseDomainXML("<domain type='kvm' id='12'>"
|
parser.parseDomainXML("<domain type='kvm' id='12'>"
|
||||||
+ "<name>r-6-CV-5002-1</name>"
|
+ "<name>r-6-CV-5002-1</name>"
|
||||||
+ "<uuid>581b5a4b-b496-8d4d-e44e-a7dcbe9df0b5</uuid>"
|
+ "<uuid>581b5a4b-b496-8d4d-e44e-a7dcbe9df0b5</uuid>"
|
||||||
+ "<description>testVM</description>"
|
+ "<description>testVM</description>"
|
||||||
+ "<memory>131072</memory>"
|
+ "<memory>131072</memory>"
|
||||||
+ "<currentMemory>131072</currentMemory>"
|
+ "<currentMemory>131072</currentMemory>"
|
||||||
+ "<vcpu>1</vcpu>"
|
+ "<vcpu>1</vcpu>"
|
||||||
+ "<os>"
|
+ "<os>"
|
||||||
+ "<type arch='i686' machine='pc-0.11'>hvm</type>"
|
+ "<type arch='i686' machine='pc-0.11'>hvm</type>"
|
||||||
+ "<kernel>/var/lib/libvirt/qemu/vmlinuz-2.6.31.6-166.fc12.i686</kernel>"
|
+ "<kernel>/var/lib/libvirt/qemu/vmlinuz-2.6.31.6-166.fc12.i686</kernel>"
|
||||||
+ "<cmdline>ro root=/dev/sda1 acpi=force selinux=0 eth0ip=10.1.1.1 eth0mask=255.255.255.0 eth2ip=192.168.10.152 eth2mask=255.255.255.0 gateway=192.168.10.1 dns1=72.52.126.11 dns2=72.52.126.12 domain=v4.myvm.com</cmdline>"
|
+ "<cmdline>ro root=/dev/sda1 acpi=force selinux=0 eth0ip=10.1.1.1 eth0mask=255.255.255.0 eth2ip=192.168.10.152 eth2mask=255.255.255.0 gateway=192.168.10.1 dns1=72.52.126.11 dns2=72.52.126.12 domain=v4.myvm.com</cmdline>"
|
||||||
+ "<boot dev='hd'/>"
|
+ "<boot dev='hd'/>"
|
||||||
+ "</os>"
|
+ "</os>"
|
||||||
+ "<features>"
|
+ "<features>"
|
||||||
+ "<acpi/>"
|
+ "<acpi/>"
|
||||||
+ "<pae/>"
|
+ "<pae/>"
|
||||||
+ "</features>"
|
+ "</features>"
|
||||||
+ "<clock offset='utc'/>"
|
+ "<clock offset='utc'/>"
|
||||||
+ "<on_poweroff>destroy</on_poweroff>"
|
+ "<on_poweroff>destroy</on_poweroff>"
|
||||||
+ "<on_reboot>restart</on_reboot>"
|
+ "<on_reboot>restart</on_reboot>"
|
||||||
+ "<on_crash>destroy</on_crash>"
|
+ "<on_crash>destroy</on_crash>"
|
||||||
+ "<devices>"
|
+ "<devices>"
|
||||||
+ "<emulator>/usr/bin/qemu-kvm</emulator>"
|
+ "<emulator>/usr/bin/qemu-kvm</emulator>"
|
||||||
+ "<disk type='file' device='disk'>"
|
+ "<disk type='file' device='disk'>"
|
||||||
+ "<driver name='qemu' type='raw'/>"
|
+ "<driver name='qemu' type='raw'/>"
|
||||||
+ "<source file='/mnt/tank//vmops/CV/vm/u000004/r000006/rootdisk'/>"
|
+ "<source file='/mnt/tank//vmops/CV/vm/u000004/r000006/rootdisk'/>"
|
||||||
+ "<target dev='hda' bus='ide'/>" + "</disk>"
|
+ "<target dev='hda' bus='ide'/>" + "</disk>"
|
||||||
+ "<interface type='bridge'>"
|
+ "<interface type='bridge'>"
|
||||||
+ "<mac address='02:00:50:02:00:01'/>"
|
+ "<mac address='02:00:50:02:00:01'/>"
|
||||||
+ "<source bridge='vnbr5002'/>" + "<target dev='vtap5002'/>"
|
+ "<source bridge='vnbr5002'/>" + "<target dev='vtap5002'/>"
|
||||||
+ "<model type='e1000'/>" + "</interface>"
|
+ "<model type='e1000'/>" + "</interface>"
|
||||||
+ "<interface type='network'>"
|
+ "<interface type='network'>"
|
||||||
+ "<mac address='00:16:3e:77:e2:a1'/>"
|
+ "<mac address='00:16:3e:77:e2:a1'/>"
|
||||||
+ "<source network='vmops-private'/>" + "<target dev='vnet3'/>"
|
+ "<source network='vmops-private'/>" + "<target dev='vnet3'/>"
|
||||||
+ "<model type='e1000'/>" + "</interface>"
|
+ "<model type='e1000'/>" + "</interface>"
|
||||||
+ "<interface type='bridge'>"
|
+ "<interface type='bridge'>"
|
||||||
+ "<mac address='06:85:00:00:00:04'/>"
|
+ "<mac address='06:85:00:00:00:04'/>"
|
||||||
+ "<source bridge='br0'/>" + "<target dev='tap5002'/>"
|
+ "<source bridge='br0'/>" + "<target dev='tap5002'/>"
|
||||||
+ "<model type='e1000'/>" + "</interface>"
|
+ "<model type='e1000'/>" + "</interface>"
|
||||||
+ "<input type='mouse' bus='ps2'/>"
|
+ "<input type='mouse' bus='ps2'/>"
|
||||||
+ "<graphics type='vnc' port='6031' autoport='no' listen=''/>"
|
+ "<graphics type='vnc' port='6031' autoport='no' listen=''/>"
|
||||||
+ "<video>" + "<model type='cirrus' vram='9216' heads='1'/>"
|
+ "<video>" + "<model type='cirrus' vram='9216' heads='1'/>"
|
||||||
+ "</video>" + "</devices>" + "</domain>"
|
+ "</video>" + "</devices>" + "</domain>"
|
||||||
|
|
||||||
);
|
);
|
||||||
for (InterfaceDef intf : parser.getInterfaces()) {
|
for (InterfaceDef intf : parser.getInterfaces()) {
|
||||||
System.out.println(intf);
|
System.out.println(intf);
|
||||||
}
|
}
|
||||||
for (DiskDef disk : parser.getDisks()) {
|
for (DiskDef disk : parser.getDisks()) {
|
||||||
System.out.println(disk);
|
System.out.println(disk);
|
||||||
}
|
}
|
||||||
System.out.println(parser.getVncPort());
|
System.out.println(parser.getVncPort());
|
||||||
System.out.println(parser.getDescription());
|
System.out.println(parser.getDescription());
|
||||||
|
|
||||||
List<String> test = new ArrayList<String>(1);
|
List<String> test = new ArrayList<String>(1);
|
||||||
test.add("1");
|
test.add("1");
|
||||||
test.add("2");
|
test.add("2");
|
||||||
if (test.contains("1")) {
|
if (test.contains("1")) {
|
||||||
System.out.print("fdf");
|
System.out.print("fdf");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,174 +20,174 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class LibvirtNetworkDef {
|
public class LibvirtNetworkDef {
|
||||||
enum netType {
|
enum netType {
|
||||||
BRIDGE, NAT, LOCAL
|
BRIDGE, NAT, LOCAL
|
||||||
}
|
}
|
||||||
|
|
||||||
private final String _networkName;
|
private final String _networkName;
|
||||||
private final String _uuid;
|
private final String _uuid;
|
||||||
private netType _networkType;
|
private netType _networkType;
|
||||||
private String _brName;
|
private String _brName;
|
||||||
private boolean _stp;
|
private boolean _stp;
|
||||||
private int _delay;
|
private int _delay;
|
||||||
private String _fwDev;
|
private String _fwDev;
|
||||||
private final String _domainName;
|
private final String _domainName;
|
||||||
private String _brIPAddr;
|
private String _brIPAddr;
|
||||||
private String _brNetMask;
|
private String _brNetMask;
|
||||||
private final List<IPRange> ipranges = new ArrayList<IPRange>();
|
private final List<IPRange> ipranges = new ArrayList<IPRange>();
|
||||||
private final List<dhcpMapping> dhcpMaps = new ArrayList<dhcpMapping>();
|
private final List<dhcpMapping> dhcpMaps = new ArrayList<dhcpMapping>();
|
||||||
|
|
||||||
public static class dhcpMapping {
|
public static class dhcpMapping {
|
||||||
String _mac;
|
String _mac;
|
||||||
String _name;
|
String _name;
|
||||||
String _ip;
|
String _ip;
|
||||||
|
|
||||||
public dhcpMapping(String mac, String name, String ip) {
|
public dhcpMapping(String mac, String name, String ip) {
|
||||||
_mac = mac;
|
_mac = mac;
|
||||||
_name = name;
|
_name = name;
|
||||||
_ip = ip;
|
_ip = ip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class IPRange {
|
public static class IPRange {
|
||||||
String _start;
|
String _start;
|
||||||
String _end;
|
String _end;
|
||||||
|
|
||||||
public IPRange(String start, String end) {
|
public IPRange(String start, String end) {
|
||||||
_start = start;
|
_start = start;
|
||||||
_end = end;
|
_end = end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public LibvirtNetworkDef(String netName, String uuid, String domName) {
|
public LibvirtNetworkDef(String netName, String uuid, String domName) {
|
||||||
_networkName = netName;
|
_networkName = netName;
|
||||||
_uuid = uuid;
|
_uuid = uuid;
|
||||||
_domainName = domName;
|
_domainName = domName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void defNATNetwork(String brName, boolean stp, int delay,
|
public void defNATNetwork(String brName, boolean stp, int delay,
|
||||||
String fwNic, String ipAddr, String netMask) {
|
String fwNic, String ipAddr, String netMask) {
|
||||||
_networkType = netType.NAT;
|
_networkType = netType.NAT;
|
||||||
_brName = brName;
|
_brName = brName;
|
||||||
_stp = stp;
|
_stp = stp;
|
||||||
_delay = delay;
|
_delay = delay;
|
||||||
_fwDev = fwNic;
|
_fwDev = fwNic;
|
||||||
_brIPAddr = ipAddr;
|
_brIPAddr = ipAddr;
|
||||||
_brNetMask = netMask;
|
_brNetMask = netMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void defBrNetwork(String brName, boolean stp, int delay,
|
public void defBrNetwork(String brName, boolean stp, int delay,
|
||||||
String fwNic, String ipAddr, String netMask) {
|
String fwNic, String ipAddr, String netMask) {
|
||||||
_networkType = netType.BRIDGE;
|
_networkType = netType.BRIDGE;
|
||||||
_brName = brName;
|
_brName = brName;
|
||||||
_stp = stp;
|
_stp = stp;
|
||||||
_delay = delay;
|
_delay = delay;
|
||||||
_fwDev = fwNic;
|
_fwDev = fwNic;
|
||||||
_brIPAddr = ipAddr;
|
_brIPAddr = ipAddr;
|
||||||
_brNetMask = netMask;
|
_brNetMask = netMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void defLocalNetwork(String brName, boolean stp, int delay,
|
public void defLocalNetwork(String brName, boolean stp, int delay,
|
||||||
String ipAddr, String netMask) {
|
String ipAddr, String netMask) {
|
||||||
_networkType = netType.LOCAL;
|
_networkType = netType.LOCAL;
|
||||||
_brName = brName;
|
_brName = brName;
|
||||||
_stp = stp;
|
_stp = stp;
|
||||||
_delay = delay;
|
_delay = delay;
|
||||||
_brIPAddr = ipAddr;
|
_brIPAddr = ipAddr;
|
||||||
_brNetMask = netMask;
|
_brNetMask = netMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void adddhcpIPRange(String start, String end) {
|
public void adddhcpIPRange(String start, String end) {
|
||||||
IPRange ipr = new IPRange(start, end);
|
IPRange ipr = new IPRange(start, end);
|
||||||
ipranges.add(ipr);
|
ipranges.add(ipr);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void adddhcpMapping(String mac, String host, String ip) {
|
public void adddhcpMapping(String mac, String host, String ip) {
|
||||||
dhcpMapping map = new dhcpMapping(mac, host, ip);
|
dhcpMapping map = new dhcpMapping(mac, host, ip);
|
||||||
dhcpMaps.add(map);
|
dhcpMaps.add(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder netBuilder = new StringBuilder();
|
StringBuilder netBuilder = new StringBuilder();
|
||||||
netBuilder.append("<network>\n");
|
netBuilder.append("<network>\n");
|
||||||
netBuilder.append("<name>" + _networkName + "</name>\n");
|
netBuilder.append("<name>" + _networkName + "</name>\n");
|
||||||
if (_uuid != null)
|
if (_uuid != null)
|
||||||
netBuilder.append("<uuid>" + _uuid + "</uuid>\n");
|
netBuilder.append("<uuid>" + _uuid + "</uuid>\n");
|
||||||
if (_brName != null) {
|
if (_brName != null) {
|
||||||
netBuilder.append("<bridge name='" + _brName + "'");
|
netBuilder.append("<bridge name='" + _brName + "'");
|
||||||
if (_stp) {
|
if (_stp) {
|
||||||
netBuilder.append(" stp='on'");
|
netBuilder.append(" stp='on'");
|
||||||
} else {
|
} else {
|
||||||
netBuilder.append(" stp='off'");
|
netBuilder.append(" stp='off'");
|
||||||
}
|
}
|
||||||
if (_delay != -1) {
|
if (_delay != -1) {
|
||||||
netBuilder.append(" delay='" + _delay + "'");
|
netBuilder.append(" delay='" + _delay + "'");
|
||||||
}
|
}
|
||||||
netBuilder.append("/>\n");
|
netBuilder.append("/>\n");
|
||||||
}
|
}
|
||||||
if (_domainName != null) {
|
if (_domainName != null) {
|
||||||
netBuilder.append("<domain name='" + _domainName + "'/>\n");
|
netBuilder.append("<domain name='" + _domainName + "'/>\n");
|
||||||
}
|
}
|
||||||
if (_networkType == netType.BRIDGE) {
|
if (_networkType == netType.BRIDGE) {
|
||||||
netBuilder.append("<forward mode='route'");
|
netBuilder.append("<forward mode='route'");
|
||||||
if (_fwDev != null) {
|
if (_fwDev != null) {
|
||||||
netBuilder.append(" dev='" + _fwDev + "'");
|
netBuilder.append(" dev='" + _fwDev + "'");
|
||||||
}
|
}
|
||||||
netBuilder.append("/>\n");
|
netBuilder.append("/>\n");
|
||||||
} else if (_networkType == netType.NAT) {
|
} else if (_networkType == netType.NAT) {
|
||||||
netBuilder.append("<forward mode='nat'");
|
netBuilder.append("<forward mode='nat'");
|
||||||
if (_fwDev != null) {
|
if (_fwDev != null) {
|
||||||
netBuilder.append(" dev='" + _fwDev + "'");
|
netBuilder.append(" dev='" + _fwDev + "'");
|
||||||
}
|
}
|
||||||
netBuilder.append("/>\n");
|
netBuilder.append("/>\n");
|
||||||
}
|
}
|
||||||
if (_brIPAddr != null || _brNetMask != null || !ipranges.isEmpty()
|
if (_brIPAddr != null || _brNetMask != null || !ipranges.isEmpty()
|
||||||
|| !dhcpMaps.isEmpty()) {
|
|| !dhcpMaps.isEmpty()) {
|
||||||
netBuilder.append("<ip");
|
netBuilder.append("<ip");
|
||||||
if (_brIPAddr != null)
|
if (_brIPAddr != null)
|
||||||
netBuilder.append(" address='" + _brIPAddr + "'");
|
netBuilder.append(" address='" + _brIPAddr + "'");
|
||||||
if (_brNetMask != null) {
|
if (_brNetMask != null) {
|
||||||
netBuilder.append(" netmask='" + _brNetMask + "'");
|
netBuilder.append(" netmask='" + _brNetMask + "'");
|
||||||
}
|
}
|
||||||
netBuilder.append(">\n");
|
netBuilder.append(">\n");
|
||||||
|
|
||||||
if (!ipranges.isEmpty() || !dhcpMaps.isEmpty()) {
|
if (!ipranges.isEmpty() || !dhcpMaps.isEmpty()) {
|
||||||
netBuilder.append("<dhcp>\n");
|
netBuilder.append("<dhcp>\n");
|
||||||
for (IPRange ip : ipranges) {
|
for (IPRange ip : ipranges) {
|
||||||
netBuilder.append("<range start='" + ip._start + "'"
|
netBuilder.append("<range start='" + ip._start + "'"
|
||||||
+ " end='" + ip._end + "'/>\n");
|
+ " end='" + ip._end + "'/>\n");
|
||||||
}
|
}
|
||||||
for (dhcpMapping map : dhcpMaps) {
|
for (dhcpMapping map : dhcpMaps) {
|
||||||
netBuilder.append("<host mac='" + map._mac + "' name='"
|
netBuilder.append("<host mac='" + map._mac + "' name='"
|
||||||
+ map._name + "' ip='" + map._ip + "'/>\n");
|
+ map._name + "' ip='" + map._ip + "'/>\n");
|
||||||
}
|
}
|
||||||
netBuilder.append("</dhcp>\n");
|
netBuilder.append("</dhcp>\n");
|
||||||
}
|
}
|
||||||
netBuilder.append("</ip>\n");
|
netBuilder.append("</ip>\n");
|
||||||
}
|
}
|
||||||
netBuilder.append("</network>\n");
|
netBuilder.append("</network>\n");
|
||||||
return netBuilder.toString();
|
return netBuilder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param args
|
* @param args
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
LibvirtNetworkDef net = new LibvirtNetworkDef("cloudPrivate", null,
|
LibvirtNetworkDef net = new LibvirtNetworkDef("cloudPrivate", null,
|
||||||
"cloud.com");
|
"cloud.com");
|
||||||
net.defNATNetwork("cloudbr0", false, 0, null, "192.168.168.1",
|
net.defNATNetwork("cloudbr0", false, 0, null, "192.168.168.1",
|
||||||
"255.255.255.0");
|
"255.255.255.0");
|
||||||
net.adddhcpIPRange("192.168.168.100", "192.168.168.220");
|
net.adddhcpIPRange("192.168.168.100", "192.168.168.220");
|
||||||
net.adddhcpIPRange("192.168.168.10", "192.168.168.50");
|
net.adddhcpIPRange("192.168.168.10", "192.168.168.50");
|
||||||
net.adddhcpMapping("branch0.cloud.com", "00:16:3e:77:e2:ed",
|
net.adddhcpMapping("branch0.cloud.com", "00:16:3e:77:e2:ed",
|
||||||
"192.168.168.100");
|
"192.168.168.100");
|
||||||
net.adddhcpMapping("branch1.cloud.com", "00:16:3e:77:e2:ef",
|
net.adddhcpMapping("branch1.cloud.com", "00:16:3e:77:e2:ef",
|
||||||
"192.168.168.101");
|
"192.168.168.101");
|
||||||
net.adddhcpMapping("branch2.cloud.com", "00:16:3e:77:e2:f0",
|
net.adddhcpMapping("branch2.cloud.com", "00:16:3e:77:e2:f0",
|
||||||
"192.168.168.102");
|
"192.168.168.102");
|
||||||
System.out.println(net.toString());
|
System.out.println(net.toString());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,74 +17,74 @@
|
|||||||
package com.cloud.agent.resource.computing;
|
package com.cloud.agent.resource.computing;
|
||||||
|
|
||||||
public class LibvirtStoragePoolDef {
|
public class LibvirtStoragePoolDef {
|
||||||
public enum poolType {
|
public enum poolType {
|
||||||
ISCSI("iscsi"), NETFS("netfs"), LOGICAL("logical"), DIR("dir");
|
ISCSI("iscsi"), NETFS("netfs"), LOGICAL("logical"), DIR("dir");
|
||||||
String _poolType;
|
String _poolType;
|
||||||
|
|
||||||
poolType(String poolType) {
|
poolType(String poolType) {
|
||||||
_poolType = poolType;
|
_poolType = poolType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return _poolType;
|
return _poolType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private poolType _poolType;
|
private poolType _poolType;
|
||||||
private String _poolName;
|
private String _poolName;
|
||||||
private String _uuid;
|
private String _uuid;
|
||||||
private String _sourceHost;
|
private String _sourceHost;
|
||||||
private String _sourceDir;
|
private String _sourceDir;
|
||||||
private String _targetPath;
|
private String _targetPath;
|
||||||
|
|
||||||
public LibvirtStoragePoolDef(poolType type, String poolName, String uuid,
|
public LibvirtStoragePoolDef(poolType type, String poolName, String uuid,
|
||||||
String host, String dir, String targetPath) {
|
String host, String dir, String targetPath) {
|
||||||
_poolType = type;
|
_poolType = type;
|
||||||
_poolName = poolName;
|
_poolName = poolName;
|
||||||
_uuid = uuid;
|
_uuid = uuid;
|
||||||
_sourceHost = host;
|
_sourceHost = host;
|
||||||
_sourceDir = dir;
|
_sourceDir = dir;
|
||||||
_targetPath = targetPath;
|
_targetPath = targetPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPoolName() {
|
public String getPoolName() {
|
||||||
return _poolName;
|
return _poolName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public poolType getPoolType() {
|
public poolType getPoolType() {
|
||||||
return _poolType;
|
return _poolType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSourceHost() {
|
public String getSourceHost() {
|
||||||
return _sourceHost;
|
return _sourceHost;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSourceDir() {
|
public String getSourceDir() {
|
||||||
return _sourceDir;
|
return _sourceDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTargetPath() {
|
public String getTargetPath() {
|
||||||
return _targetPath;
|
return _targetPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder storagePoolBuilder = new StringBuilder();
|
StringBuilder storagePoolBuilder = new StringBuilder();
|
||||||
storagePoolBuilder.append("<pool type='" + _poolType + "'>\n");
|
storagePoolBuilder.append("<pool type='" + _poolType + "'>\n");
|
||||||
storagePoolBuilder.append("<name>" + _poolName + "</name>\n");
|
storagePoolBuilder.append("<name>" + _poolName + "</name>\n");
|
||||||
if (_uuid != null)
|
if (_uuid != null)
|
||||||
storagePoolBuilder.append("<uuid>" + _uuid + "</uuid>\n");
|
storagePoolBuilder.append("<uuid>" + _uuid + "</uuid>\n");
|
||||||
if (_poolType == poolType.NETFS) {
|
if (_poolType == poolType.NETFS) {
|
||||||
storagePoolBuilder.append("<source>\n");
|
storagePoolBuilder.append("<source>\n");
|
||||||
storagePoolBuilder.append("<host name='" + _sourceHost + "'/>\n");
|
storagePoolBuilder.append("<host name='" + _sourceHost + "'/>\n");
|
||||||
storagePoolBuilder.append("<dir path='" + _sourceDir + "'/>\n");
|
storagePoolBuilder.append("<dir path='" + _sourceDir + "'/>\n");
|
||||||
storagePoolBuilder.append("</source>\n");
|
storagePoolBuilder.append("</source>\n");
|
||||||
}
|
}
|
||||||
storagePoolBuilder.append("<target>\n");
|
storagePoolBuilder.append("<target>\n");
|
||||||
storagePoolBuilder.append("<path>" + _targetPath + "</path>\n");
|
storagePoolBuilder.append("<path>" + _targetPath + "</path>\n");
|
||||||
storagePoolBuilder.append("</target>\n");
|
storagePoolBuilder.append("</target>\n");
|
||||||
storagePoolBuilder.append("</pool>\n");
|
storagePoolBuilder.append("</pool>\n");
|
||||||
return storagePoolBuilder.toString();
|
return storagePoolBuilder.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,81 +29,81 @@ import org.xml.sax.InputSource;
|
|||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
public class LibvirtStoragePoolXMLParser {
|
public class LibvirtStoragePoolXMLParser {
|
||||||
private static final Logger s_logger = Logger
|
private static final Logger s_logger = Logger
|
||||||
.getLogger(LibvirtStoragePoolXMLParser.class);
|
.getLogger(LibvirtStoragePoolXMLParser.class);
|
||||||
|
|
||||||
public LibvirtStoragePoolDef parseStoragePoolXML(String poolXML) {
|
public LibvirtStoragePoolDef parseStoragePoolXML(String poolXML) {
|
||||||
DocumentBuilder builder;
|
DocumentBuilder builder;
|
||||||
try {
|
try {
|
||||||
builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||||
|
|
||||||
InputSource is = new InputSource();
|
InputSource is = new InputSource();
|
||||||
is.setCharacterStream(new StringReader(poolXML));
|
is.setCharacterStream(new StringReader(poolXML));
|
||||||
Document doc = builder.parse(is);
|
Document doc = builder.parse(is);
|
||||||
|
|
||||||
Element rootElement = doc.getDocumentElement();
|
Element rootElement = doc.getDocumentElement();
|
||||||
String type = rootElement.getAttribute("type");
|
String type = rootElement.getAttribute("type");
|
||||||
|
|
||||||
String uuid = getTagValue("uuid", rootElement);
|
String uuid = getTagValue("uuid", rootElement);
|
||||||
|
|
||||||
String poolName = getTagValue("name", rootElement);
|
String poolName = getTagValue("name", rootElement);
|
||||||
|
|
||||||
Element source = (Element) rootElement.getElementsByTagName(
|
Element source = (Element) rootElement.getElementsByTagName(
|
||||||
"source").item(0);
|
"source").item(0);
|
||||||
String host = getAttrValue("host", "name", source);
|
String host = getAttrValue("host", "name", source);
|
||||||
String path = getAttrValue("dir", "path", source);
|
String path = getAttrValue("dir", "path", source);
|
||||||
|
|
||||||
Element target = (Element) rootElement.getElementsByTagName(
|
Element target = (Element) rootElement.getElementsByTagName(
|
||||||
"target").item(0);
|
"target").item(0);
|
||||||
String targetPath = getTagValue("path", target);
|
String targetPath = getTagValue("path", target);
|
||||||
|
|
||||||
return new LibvirtStoragePoolDef(
|
return new LibvirtStoragePoolDef(
|
||||||
LibvirtStoragePoolDef.poolType.valueOf(type.toUpperCase()),
|
LibvirtStoragePoolDef.poolType.valueOf(type.toUpperCase()),
|
||||||
poolName, uuid, host, path, targetPath);
|
poolName, uuid, host, path, targetPath);
|
||||||
} catch (ParserConfigurationException e) {
|
} catch (ParserConfigurationException e) {
|
||||||
s_logger.debug(e.toString());
|
s_logger.debug(e.toString());
|
||||||
} catch (SAXException e) {
|
} catch (SAXException e) {
|
||||||
s_logger.debug(e.toString());
|
s_logger.debug(e.toString());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
s_logger.debug(e.toString());
|
s_logger.debug(e.toString());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getTagValue(String tag, Element eElement) {
|
private static String getTagValue(String tag, Element eElement) {
|
||||||
NodeList nlList = eElement.getElementsByTagName(tag).item(0)
|
NodeList nlList = eElement.getElementsByTagName(tag).item(0)
|
||||||
.getChildNodes();
|
.getChildNodes();
|
||||||
Node nValue = (Node) nlList.item(0);
|
Node nValue = (Node) nlList.item(0);
|
||||||
|
|
||||||
return nValue.getNodeValue();
|
return nValue.getNodeValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getAttrValue(String tag, String attr, Element eElement) {
|
private static String getAttrValue(String tag, String attr, Element eElement) {
|
||||||
NodeList tagNode = eElement.getElementsByTagName(tag);
|
NodeList tagNode = eElement.getElementsByTagName(tag);
|
||||||
if (tagNode.getLength() == 0) {
|
if (tagNode.getLength() == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Element node = (Element) tagNode.item(0);
|
Element node = (Element) tagNode.item(0);
|
||||||
return node.getAttribute(attr);
|
return node.getAttribute(attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
s_logger.addAppender(new org.apache.log4j.ConsoleAppender(
|
s_logger.addAppender(new org.apache.log4j.ConsoleAppender(
|
||||||
new org.apache.log4j.PatternLayout(), "System.out"));
|
new org.apache.log4j.PatternLayout(), "System.out"));
|
||||||
String storagePool = "<pool type='dir'>" + "<name>test</name>"
|
String storagePool = "<pool type='dir'>" + "<name>test</name>"
|
||||||
+ "<uuid>bf723c83-4b95-259c-7089-60776e61a11f</uuid>"
|
+ "<uuid>bf723c83-4b95-259c-7089-60776e61a11f</uuid>"
|
||||||
+ "<capacity>20314165248</capacity>"
|
+ "<capacity>20314165248</capacity>"
|
||||||
+ "<allocation>1955450880</allocation>"
|
+ "<allocation>1955450880</allocation>"
|
||||||
+ "<available>18358714368</available>" + "<source>"
|
+ "<available>18358714368</available>" + "<source>"
|
||||||
+ "<host name='nfs1.lab.vmops.com'/>"
|
+ "<host name='nfs1.lab.vmops.com'/>"
|
||||||
+ "<dir path='/export/home/edison/kvm/primary'/>"
|
+ "<dir path='/export/home/edison/kvm/primary'/>"
|
||||||
+ "<format type='auto'/>" + "</source>" + "<target>"
|
+ "<format type='auto'/>" + "</source>" + "<target>"
|
||||||
+ "<path>/media</path>" + "<permissions>" + "<mode>0700</mode>"
|
+ "<path>/media</path>" + "<permissions>" + "<mode>0700</mode>"
|
||||||
+ "<owner>0</owner>" + "<group>0</group>" + "</permissions>"
|
+ "<owner>0</owner>" + "<group>0</group>" + "</permissions>"
|
||||||
+ "</target>" + "</pool>";
|
+ "</target>" + "</pool>";
|
||||||
|
|
||||||
LibvirtStoragePoolXMLParser parser = new LibvirtStoragePoolXMLParser();
|
LibvirtStoragePoolXMLParser parser = new LibvirtStoragePoolXMLParser();
|
||||||
LibvirtStoragePoolDef pool = parser.parseStoragePoolXML(storagePool);
|
LibvirtStoragePoolDef pool = parser.parseStoragePoolXML(storagePool);
|
||||||
s_logger.debug(pool.toString());
|
s_logger.debug(pool.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,75 +17,75 @@
|
|||||||
package com.cloud.agent.resource.computing;
|
package com.cloud.agent.resource.computing;
|
||||||
|
|
||||||
public class LibvirtStorageVolumeDef {
|
public class LibvirtStorageVolumeDef {
|
||||||
public enum volFormat {
|
public enum volFormat {
|
||||||
RAW("raw"), QCOW2("qcow2"), DIR("dir");
|
RAW("raw"), QCOW2("qcow2"), DIR("dir");
|
||||||
private String _format;
|
private String _format;
|
||||||
|
|
||||||
volFormat(String format) {
|
volFormat(String format) {
|
||||||
_format = format;
|
_format = format;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return _format;
|
return _format;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static volFormat getFormat(String format) {
|
public static volFormat getFormat(String format) {
|
||||||
if (format == null) {
|
if (format == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (format.equalsIgnoreCase("raw")) {
|
if (format.equalsIgnoreCase("raw")) {
|
||||||
return RAW;
|
return RAW;
|
||||||
} else if (format.equalsIgnoreCase("qcow2")) {
|
} else if (format.equalsIgnoreCase("qcow2")) {
|
||||||
return QCOW2;
|
return QCOW2;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String _volName;
|
private String _volName;
|
||||||
private Long _volSize;
|
private Long _volSize;
|
||||||
private volFormat _volFormat;
|
private volFormat _volFormat;
|
||||||
private String _backingPath;
|
private String _backingPath;
|
||||||
private volFormat _backingFormat;
|
private volFormat _backingFormat;
|
||||||
|
|
||||||
public LibvirtStorageVolumeDef(String volName, Long size, volFormat format,
|
public LibvirtStorageVolumeDef(String volName, Long size, volFormat format,
|
||||||
String tmplPath, volFormat tmplFormat) {
|
String tmplPath, volFormat tmplFormat) {
|
||||||
_volName = volName;
|
_volName = volName;
|
||||||
_volSize = size;
|
_volSize = size;
|
||||||
_volFormat = format;
|
_volFormat = format;
|
||||||
_backingPath = tmplPath;
|
_backingPath = tmplPath;
|
||||||
_backingFormat = tmplFormat;
|
_backingFormat = tmplFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
public volFormat getFormat() {
|
public volFormat getFormat() {
|
||||||
return this._volFormat;
|
return this._volFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder storageVolBuilder = new StringBuilder();
|
StringBuilder storageVolBuilder = new StringBuilder();
|
||||||
storageVolBuilder.append("<volume>\n");
|
storageVolBuilder.append("<volume>\n");
|
||||||
storageVolBuilder.append("<name>" + _volName + "</name>\n");
|
storageVolBuilder.append("<name>" + _volName + "</name>\n");
|
||||||
if (_volSize != null) {
|
if (_volSize != null) {
|
||||||
storageVolBuilder
|
storageVolBuilder
|
||||||
.append("<capacity >" + _volSize + "</capacity>\n");
|
.append("<capacity >" + _volSize + "</capacity>\n");
|
||||||
}
|
}
|
||||||
storageVolBuilder.append("<target>\n");
|
storageVolBuilder.append("<target>\n");
|
||||||
storageVolBuilder.append("<format type='" + _volFormat + "'/>\n");
|
storageVolBuilder.append("<format type='" + _volFormat + "'/>\n");
|
||||||
storageVolBuilder.append("<permissions>");
|
storageVolBuilder.append("<permissions>");
|
||||||
storageVolBuilder.append("<mode>0744</mode>");
|
storageVolBuilder.append("<mode>0744</mode>");
|
||||||
storageVolBuilder.append("</permissions>");
|
storageVolBuilder.append("</permissions>");
|
||||||
storageVolBuilder.append("</target>\n");
|
storageVolBuilder.append("</target>\n");
|
||||||
if (_backingPath != null) {
|
if (_backingPath != null) {
|
||||||
storageVolBuilder.append("<backingStore>\n");
|
storageVolBuilder.append("<backingStore>\n");
|
||||||
storageVolBuilder.append("<path>" + _backingPath + "</path>\n");
|
storageVolBuilder.append("<path>" + _backingPath + "</path>\n");
|
||||||
storageVolBuilder.append("<format type='" + _backingFormat
|
storageVolBuilder.append("<format type='" + _backingFormat
|
||||||
+ "'/>\n");
|
+ "'/>\n");
|
||||||
storageVolBuilder.append("</backingStore>\n");
|
storageVolBuilder.append("</backingStore>\n");
|
||||||
}
|
}
|
||||||
storageVolBuilder.append("</volume>\n");
|
storageVolBuilder.append("</volume>\n");
|
||||||
return storageVolBuilder.toString();
|
return storageVolBuilder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,73 +32,73 @@ import org.xml.sax.InputSource;
|
|||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
public class LibvirtStorageVolumeXMLParser {
|
public class LibvirtStorageVolumeXMLParser {
|
||||||
private static final Logger s_logger = Logger
|
private static final Logger s_logger = Logger
|
||||||
.getLogger(LibvirtStorageVolumeXMLParser.class);
|
.getLogger(LibvirtStorageVolumeXMLParser.class);
|
||||||
|
|
||||||
public LibvirtStorageVolumeDef parseStorageVolumeXML(String volXML) {
|
public LibvirtStorageVolumeDef parseStorageVolumeXML(String volXML) {
|
||||||
DocumentBuilder builder;
|
DocumentBuilder builder;
|
||||||
try {
|
try {
|
||||||
builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||||
|
|
||||||
InputSource is = new InputSource();
|
InputSource is = new InputSource();
|
||||||
is.setCharacterStream(new StringReader(volXML));
|
is.setCharacterStream(new StringReader(volXML));
|
||||||
Document doc = builder.parse(is);
|
Document doc = builder.parse(is);
|
||||||
|
|
||||||
Element rootElement = doc.getDocumentElement();
|
Element rootElement = doc.getDocumentElement();
|
||||||
|
|
||||||
String VolName = getTagValue("name", rootElement);
|
String VolName = getTagValue("name", rootElement);
|
||||||
Element target = (Element) rootElement.getElementsByTagName(
|
Element target = (Element) rootElement.getElementsByTagName(
|
||||||
"target").item(0);
|
"target").item(0);
|
||||||
String format = getAttrValue("type", "format", target);
|
String format = getAttrValue("type", "format", target);
|
||||||
Long capacity = Long
|
Long capacity = Long
|
||||||
.parseLong(getTagValue("capacity", rootElement));
|
.parseLong(getTagValue("capacity", rootElement));
|
||||||
return new LibvirtStorageVolumeDef(VolName, capacity,
|
return new LibvirtStorageVolumeDef(VolName, capacity,
|
||||||
LibvirtStorageVolumeDef.volFormat.getFormat(format), null,
|
LibvirtStorageVolumeDef.volFormat.getFormat(format), null,
|
||||||
null);
|
null);
|
||||||
} catch (ParserConfigurationException e) {
|
} catch (ParserConfigurationException e) {
|
||||||
s_logger.debug(e.toString());
|
s_logger.debug(e.toString());
|
||||||
} catch (SAXException e) {
|
} catch (SAXException e) {
|
||||||
s_logger.debug(e.toString());
|
s_logger.debug(e.toString());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
s_logger.debug(e.toString());
|
s_logger.debug(e.toString());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getTagValue(String tag, Element eElement) {
|
private static String getTagValue(String tag, Element eElement) {
|
||||||
NodeList nlList = eElement.getElementsByTagName(tag).item(0)
|
NodeList nlList = eElement.getElementsByTagName(tag).item(0)
|
||||||
.getChildNodes();
|
.getChildNodes();
|
||||||
Node nValue = (Node) nlList.item(0);
|
Node nValue = (Node) nlList.item(0);
|
||||||
|
|
||||||
return nValue.getNodeValue();
|
return nValue.getNodeValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getAttrValue(String tag, String attr, Element eElement) {
|
private static String getAttrValue(String tag, String attr, Element eElement) {
|
||||||
NodeList tagNode = eElement.getElementsByTagName(tag);
|
NodeList tagNode = eElement.getElementsByTagName(tag);
|
||||||
if (tagNode.getLength() == 0) {
|
if (tagNode.getLength() == 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
Element node = (Element) tagNode.item(0);
|
Element node = (Element) tagNode.item(0);
|
||||||
return node.getAttribute(attr);
|
return node.getAttribute(attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
s_logger.addAppender(new org.apache.log4j.ConsoleAppender(
|
s_logger.addAppender(new org.apache.log4j.ConsoleAppender(
|
||||||
new org.apache.log4j.PatternLayout(), "System.out"));
|
new org.apache.log4j.PatternLayout(), "System.out"));
|
||||||
String storagePool = "<pool type='dir'>" + "<name>test</name>"
|
String storagePool = "<pool type='dir'>" + "<name>test</name>"
|
||||||
+ "<uuid>bf723c83-4b95-259c-7089-60776e61a11f</uuid>"
|
+ "<uuid>bf723c83-4b95-259c-7089-60776e61a11f</uuid>"
|
||||||
+ "<capacity>20314165248</capacity>"
|
+ "<capacity>20314165248</capacity>"
|
||||||
+ "<allocation>1955450880</allocation>"
|
+ "<allocation>1955450880</allocation>"
|
||||||
+ "<available>18358714368</available>" + "<source>"
|
+ "<available>18358714368</available>" + "<source>"
|
||||||
+ "<host name='nfs1.lab.vmops.com'/>"
|
+ "<host name='nfs1.lab.vmops.com'/>"
|
||||||
+ "<dir path='/export/home/edison/kvm/primary'/>"
|
+ "<dir path='/export/home/edison/kvm/primary'/>"
|
||||||
+ "<format type='auto'/>" + "</source>" + "<target>"
|
+ "<format type='auto'/>" + "</source>" + "<target>"
|
||||||
+ "<path>/media</path>" + "<permissions>" + "<mode>0700</mode>"
|
+ "<path>/media</path>" + "<permissions>" + "<mode>0700</mode>"
|
||||||
+ "<owner>0</owner>" + "<group>0</group>" + "</permissions>"
|
+ "<owner>0</owner>" + "<group>0</group>" + "</permissions>"
|
||||||
+ "</target>" + "</pool>";
|
+ "</target>" + "</pool>";
|
||||||
|
|
||||||
LibvirtStoragePoolXMLParser parser = new LibvirtStoragePoolXMLParser();
|
LibvirtStoragePoolXMLParser parser = new LibvirtStoragePoolXMLParser();
|
||||||
LibvirtStoragePoolDef pool = parser.parseStoragePoolXML(storagePool);
|
LibvirtStoragePoolDef pool = parser.parseStoragePoolXML(storagePool);
|
||||||
s_logger.debug(pool.toString());
|
s_logger.debug(pool.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -28,45 +28,45 @@ import org.xml.sax.SAXException;
|
|||||||
import org.xml.sax.helpers.DefaultHandler;
|
import org.xml.sax.helpers.DefaultHandler;
|
||||||
|
|
||||||
public class LibvirtXMLParser extends DefaultHandler {
|
public class LibvirtXMLParser extends DefaultHandler {
|
||||||
private static final Logger s_logger = Logger
|
private static final Logger s_logger = Logger
|
||||||
.getLogger(LibvirtXMLParser.class);
|
.getLogger(LibvirtXMLParser.class);
|
||||||
protected static SAXParserFactory s_spf;
|
protected static SAXParserFactory s_spf;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
s_spf = SAXParserFactory.newInstance();
|
s_spf = SAXParserFactory.newInstance();
|
||||||
|
|
||||||
}
|
}
|
||||||
protected SAXParser _sp;
|
protected SAXParser _sp;
|
||||||
protected boolean _initialized = false;
|
protected boolean _initialized = false;
|
||||||
|
|
||||||
public LibvirtXMLParser() {
|
public LibvirtXMLParser() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
_sp = s_spf.newSAXParser();
|
_sp = s_spf.newSAXParser();
|
||||||
_initialized = true;
|
_initialized = true;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean parseDomainXML(String domXML) {
|
public boolean parseDomainXML(String domXML) {
|
||||||
if (!_initialized) {
|
if (!_initialized) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
_sp.parse(new InputSource(new StringReader(domXML)), this);
|
_sp.parse(new InputSource(new StringReader(domXML)), this);
|
||||||
return true;
|
return true;
|
||||||
} catch (SAXException se) {
|
} catch (SAXException se) {
|
||||||
s_logger.warn(se.getMessage());
|
s_logger.warn(se.getMessage());
|
||||||
} catch (IOException ie) {
|
} catch (IOException ie) {
|
||||||
s_logger.error(ie.getMessage());
|
s_logger.error(ie.getMessage());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void characters(char[] ch, int start, int length)
|
public void characters(char[] ch, int start, int length)
|
||||||
throws SAXException {
|
throws SAXException {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,64 +17,64 @@
|
|||||||
package com.cloud.agent.resource.consoleproxy;
|
package com.cloud.agent.resource.consoleproxy;
|
||||||
|
|
||||||
public class ConsoleProxyAuthenticationResult {
|
public class ConsoleProxyAuthenticationResult {
|
||||||
private boolean success;
|
private boolean success;
|
||||||
private boolean isReauthentication;
|
private boolean isReauthentication;
|
||||||
private String host;
|
private String host;
|
||||||
private int port;
|
private int port;
|
||||||
private String tunnelUrl;
|
private String tunnelUrl;
|
||||||
private String tunnelSession;
|
private String tunnelSession;
|
||||||
|
|
||||||
public ConsoleProxyAuthenticationResult() {
|
public ConsoleProxyAuthenticationResult() {
|
||||||
success = false;
|
success = false;
|
||||||
isReauthentication = false;
|
isReauthentication = false;
|
||||||
port = 0;
|
port = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSuccess() {
|
public boolean isSuccess() {
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSuccess(boolean success) {
|
public void setSuccess(boolean success) {
|
||||||
this.success = success;
|
this.success = success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isReauthentication() {
|
public boolean isReauthentication() {
|
||||||
return isReauthentication;
|
return isReauthentication;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReauthentication(boolean isReauthentication) {
|
public void setReauthentication(boolean isReauthentication) {
|
||||||
this.isReauthentication = isReauthentication;
|
this.isReauthentication = isReauthentication;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getHost() {
|
public String getHost() {
|
||||||
return host;
|
return host;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHost(String host) {
|
public void setHost(String host) {
|
||||||
this.host = host;
|
this.host = host;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPort() {
|
public int getPort() {
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPort(int port) {
|
public void setPort(int port) {
|
||||||
this.port = port;
|
this.port = port;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTunnelUrl() {
|
public String getTunnelUrl() {
|
||||||
return tunnelUrl;
|
return tunnelUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTunnelUrl(String tunnelUrl) {
|
public void setTunnelUrl(String tunnelUrl) {
|
||||||
this.tunnelUrl = tunnelUrl;
|
this.tunnelUrl = tunnelUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTunnelSession() {
|
public String getTunnelSession() {
|
||||||
return tunnelSession;
|
return tunnelSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTunnelSession(String tunnelSession) {
|
public void setTunnelSession(String tunnelSession) {
|
||||||
this.tunnelSession = tunnelSession;
|
this.tunnelSession = tunnelSession;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -78,415 +78,415 @@ import com.google.gson.Gson;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ConsoleProxyResource extends ServerResourceBase implements
|
public class ConsoleProxyResource extends ServerResourceBase implements
|
||||||
ServerResource {
|
ServerResource {
|
||||||
static final Logger s_logger = Logger.getLogger(ConsoleProxyResource.class);
|
static final Logger s_logger = Logger.getLogger(ConsoleProxyResource.class);
|
||||||
|
|
||||||
private final Properties _properties = new Properties();
|
private final Properties _properties = new Properties();
|
||||||
private Thread _consoleProxyMain = null;
|
private Thread _consoleProxyMain = null;
|
||||||
|
|
||||||
long _proxyVmId;
|
long _proxyVmId;
|
||||||
int _proxyPort;
|
int _proxyPort;
|
||||||
|
|
||||||
String _localgw;
|
String _localgw;
|
||||||
String _eth1ip;
|
String _eth1ip;
|
||||||
String _eth1mask;
|
String _eth1mask;
|
||||||
String _pubIp;
|
String _pubIp;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Answer executeRequest(final Command cmd) {
|
public Answer executeRequest(final Command cmd) {
|
||||||
if (cmd instanceof CheckConsoleProxyLoadCommand) {
|
if (cmd instanceof CheckConsoleProxyLoadCommand) {
|
||||||
return execute((CheckConsoleProxyLoadCommand) cmd);
|
return execute((CheckConsoleProxyLoadCommand) cmd);
|
||||||
} else if (cmd instanceof WatchConsoleProxyLoadCommand) {
|
} else if (cmd instanceof WatchConsoleProxyLoadCommand) {
|
||||||
return execute((WatchConsoleProxyLoadCommand) cmd);
|
return execute((WatchConsoleProxyLoadCommand) cmd);
|
||||||
} else if (cmd instanceof ReadyCommand) {
|
} else if (cmd instanceof ReadyCommand) {
|
||||||
s_logger.info("Receive ReadyCommand, response with ReadyAnswer");
|
s_logger.info("Receive ReadyCommand, response with ReadyAnswer");
|
||||||
return new ReadyAnswer((ReadyCommand) cmd);
|
return new ReadyAnswer((ReadyCommand) cmd);
|
||||||
} else if (cmd instanceof CheckHealthCommand) {
|
} else if (cmd instanceof CheckHealthCommand) {
|
||||||
return new CheckHealthAnswer((CheckHealthCommand) cmd, true);
|
return new CheckHealthAnswer((CheckHealthCommand) cmd, true);
|
||||||
} else if (cmd instanceof StartConsoleProxyAgentHttpHandlerCommand) {
|
} else if (cmd instanceof StartConsoleProxyAgentHttpHandlerCommand) {
|
||||||
return execute((StartConsoleProxyAgentHttpHandlerCommand) cmd);
|
return execute((StartConsoleProxyAgentHttpHandlerCommand) cmd);
|
||||||
} else {
|
} else {
|
||||||
return Answer.createUnsupportedCommandAnswer(cmd);
|
return Answer.createUnsupportedCommandAnswer(cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Answer execute(StartConsoleProxyAgentHttpHandlerCommand cmd) {
|
private Answer execute(StartConsoleProxyAgentHttpHandlerCommand cmd) {
|
||||||
launchConsoleProxy(cmd.getKeystoreBits(), cmd.getKeystorePassword(), cmd.getEncryptorPassword());
|
launchConsoleProxy(cmd.getKeystoreBits(), cmd.getKeystorePassword(), cmd.getEncryptorPassword());
|
||||||
return new Answer(cmd);
|
return new Answer(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void disableRpFilter() {
|
private void disableRpFilter() {
|
||||||
try {
|
try {
|
||||||
FileWriter fstream = new FileWriter(
|
FileWriter fstream = new FileWriter(
|
||||||
"/proc/sys/net/ipv4/conf/eth2/rp_filter");
|
"/proc/sys/net/ipv4/conf/eth2/rp_filter");
|
||||||
BufferedWriter out = new BufferedWriter(fstream);
|
BufferedWriter out = new BufferedWriter(fstream);
|
||||||
out.write("0");
|
out.write("0");
|
||||||
out.close();
|
out.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
s_logger.warn("Unable to disable rp_filter");
|
s_logger.warn("Unable to disable rp_filter");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean copyCertToDirectory(String certificate, String filePath)
|
private boolean copyCertToDirectory(String certificate, String filePath)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
boolean success;
|
boolean success;
|
||||||
// copy cert to the dir
|
// copy cert to the dir
|
||||||
FileWriter fstream = new FileWriter(filePath);
|
FileWriter fstream = new FileWriter(filePath);
|
||||||
BufferedWriter out = new BufferedWriter(fstream);
|
BufferedWriter out = new BufferedWriter(fstream);
|
||||||
out.write(certificate);
|
out.write(certificate);
|
||||||
// Close the output stream
|
// Close the output stream
|
||||||
out.close();
|
out.close();
|
||||||
success = true;
|
success = true;
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Answer execute(final CheckConsoleProxyLoadCommand cmd) {
|
protected Answer execute(final CheckConsoleProxyLoadCommand cmd) {
|
||||||
return executeProxyLoadScan(cmd, cmd.getProxyVmId(),
|
return executeProxyLoadScan(cmd, cmd.getProxyVmId(),
|
||||||
cmd.getProxyVmName(), cmd.getProxyManagementIp(),
|
cmd.getProxyVmName(), cmd.getProxyManagementIp(),
|
||||||
cmd.getProxyCmdPort());
|
cmd.getProxyCmdPort());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Answer execute(final WatchConsoleProxyLoadCommand cmd) {
|
protected Answer execute(final WatchConsoleProxyLoadCommand cmd) {
|
||||||
return executeProxyLoadScan(cmd, cmd.getProxyVmId(),
|
return executeProxyLoadScan(cmd, cmd.getProxyVmId(),
|
||||||
cmd.getProxyVmName(), cmd.getProxyManagementIp(),
|
cmd.getProxyVmName(), cmd.getProxyManagementIp(),
|
||||||
cmd.getProxyCmdPort());
|
cmd.getProxyCmdPort());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Answer executeProxyLoadScan(final Command cmd,
|
private Answer executeProxyLoadScan(final Command cmd,
|
||||||
final long proxyVmId, final String proxyVmName,
|
final long proxyVmId, final String proxyVmName,
|
||||||
final String proxyManagementIp, final int cmdPort) {
|
final String proxyManagementIp, final int cmdPort) {
|
||||||
String result = null;
|
String result = null;
|
||||||
|
|
||||||
final StringBuffer sb = new StringBuffer();
|
final StringBuffer sb = new StringBuffer();
|
||||||
sb.append("http://").append(proxyManagementIp).append(":" + cmdPort)
|
sb.append("http://").append(proxyManagementIp).append(":" + cmdPort)
|
||||||
.append("/cmd/getstatus");
|
.append("/cmd/getstatus");
|
||||||
|
|
||||||
boolean success = true;
|
boolean success = true;
|
||||||
try {
|
try {
|
||||||
final URL url = new URL(sb.toString());
|
final URL url = new URL(sb.toString());
|
||||||
final URLConnection conn = url.openConnection();
|
final URLConnection conn = url.openConnection();
|
||||||
|
|
||||||
final InputStream is = conn.getInputStream();
|
final InputStream is = conn.getInputStream();
|
||||||
final BufferedReader reader = new BufferedReader(
|
final BufferedReader reader = new BufferedReader(
|
||||||
new InputStreamReader(is));
|
new InputStreamReader(is));
|
||||||
final StringBuilder sb2 = new StringBuilder();
|
final StringBuilder sb2 = new StringBuilder();
|
||||||
String line = null;
|
String line = null;
|
||||||
try {
|
try {
|
||||||
while ((line = reader.readLine()) != null)
|
while ((line = reader.readLine()) != null)
|
||||||
sb2.append(line + "\n");
|
sb2.append(line + "\n");
|
||||||
result = sb2.toString();
|
result = sb2.toString();
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
success = false;
|
success = false;
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
is.close();
|
is.close();
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
s_logger.warn("Exception when closing , console proxy address : "
|
s_logger.warn("Exception when closing , console proxy address : "
|
||||||
+ proxyManagementIp);
|
+ proxyManagementIp);
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
s_logger.warn("Unable to open console proxy command port url, console proxy address : "
|
s_logger.warn("Unable to open console proxy command port url, console proxy address : "
|
||||||
+ proxyManagementIp);
|
+ proxyManagementIp);
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ConsoleProxyLoadAnswer(cmd, proxyVmId, proxyVmName, success,
|
return new ConsoleProxyLoadAnswer(cmd, proxyVmId, proxyVmName, success,
|
||||||
result);
|
result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getDefaultScriptsDir() {
|
protected String getDefaultScriptsDir() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
return Host.Type.ConsoleProxy;
|
return Host.Type.ConsoleProxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized StartupCommand[] initialize() {
|
public synchronized StartupCommand[] initialize() {
|
||||||
final StartupProxyCommand cmd = new StartupProxyCommand();
|
final StartupProxyCommand cmd = new StartupProxyCommand();
|
||||||
fillNetworkInformation(cmd);
|
fillNetworkInformation(cmd);
|
||||||
cmd.setProxyPort(_proxyPort);
|
cmd.setProxyPort(_proxyPort);
|
||||||
cmd.setProxyVmId(_proxyVmId);
|
cmd.setProxyVmId(_proxyVmId);
|
||||||
if (_pubIp != null)
|
if (_pubIp != null)
|
||||||
cmd.setPublicIpAddress(_pubIp);
|
cmd.setPublicIpAddress(_pubIp);
|
||||||
return new StartupCommand[] { cmd };
|
return new StartupCommand[] { cmd };
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disconnected() {
|
public void disconnected() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PingCommand getCurrentStatus(long id) {
|
public PingCommand getCurrentStatus(long id) {
|
||||||
return new PingCommand(Type.ConsoleProxy, id);
|
return new PingCommand(Type.ConsoleProxy, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean configure(String name, Map<String, Object> params)
|
public boolean configure(String name, Map<String, Object> params)
|
||||||
throws ConfigurationException {
|
throws ConfigurationException {
|
||||||
_localgw = (String) params.get("localgw");
|
_localgw = (String) params.get("localgw");
|
||||||
_eth1mask = (String) params.get("eth1mask");
|
_eth1mask = (String) params.get("eth1mask");
|
||||||
_eth1ip = (String) params.get("eth1ip");
|
_eth1ip = (String) params.get("eth1ip");
|
||||||
if (_eth1ip != null) {
|
if (_eth1ip != null) {
|
||||||
params.put("private.network.device", "eth1");
|
params.put("private.network.device", "eth1");
|
||||||
} else {
|
} else {
|
||||||
s_logger.warn("WARNING: eth1ip parameter is not found!");
|
s_logger.warn("WARNING: eth1ip parameter is not found!");
|
||||||
}
|
}
|
||||||
|
|
||||||
String eth2ip = (String) params.get("eth2ip");
|
String eth2ip = (String) params.get("eth2ip");
|
||||||
if (eth2ip != null) {
|
if (eth2ip != null) {
|
||||||
params.put("public.network.device", "eth2");
|
params.put("public.network.device", "eth2");
|
||||||
} else {
|
} else {
|
||||||
s_logger.warn("WARNING: eth2ip parameter is not found!");
|
s_logger.warn("WARNING: eth2ip parameter is not found!");
|
||||||
}
|
}
|
||||||
|
|
||||||
super.configure(name, params);
|
super.configure(name, params);
|
||||||
|
|
||||||
for (Map.Entry<String, Object> entry : params.entrySet()) {
|
for (Map.Entry<String, Object> entry : params.entrySet()) {
|
||||||
_properties.put(entry.getKey(), entry.getValue());
|
_properties.put(entry.getKey(), entry.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
String value = (String) params.get("premium");
|
String value = (String) params.get("premium");
|
||||||
if (value != null && value.equals("premium"))
|
if (value != null && value.equals("premium"))
|
||||||
_proxyPort = 443;
|
_proxyPort = 443;
|
||||||
else {
|
else {
|
||||||
value = (String) params.get("consoleproxy.httpListenPort");
|
value = (String) params.get("consoleproxy.httpListenPort");
|
||||||
_proxyPort = NumbersUtil.parseInt(value, 80);
|
_proxyPort = NumbersUtil.parseInt(value, 80);
|
||||||
}
|
}
|
||||||
|
|
||||||
value = (String) params.get("proxy_vm");
|
value = (String) params.get("proxy_vm");
|
||||||
_proxyVmId = NumbersUtil.parseLong(value, 0);
|
_proxyVmId = NumbersUtil.parseLong(value, 0);
|
||||||
|
|
||||||
if (_localgw != null) {
|
if (_localgw != null) {
|
||||||
String mgmtHost = (String) params.get("host");
|
String mgmtHost = (String) params.get("host");
|
||||||
addRouteToInternalIpOrCidr(_localgw, _eth1ip, _eth1mask, mgmtHost);
|
addRouteToInternalIpOrCidr(_localgw, _eth1ip, _eth1mask, mgmtHost);
|
||||||
|
|
||||||
String internalDns1 = (String) params.get("internaldns1");
|
String internalDns1 = (String) params.get("internaldns1");
|
||||||
if (internalDns1 == null) {
|
if (internalDns1 == null) {
|
||||||
s_logger.warn("No DNS entry found during configuration of NfsSecondaryStorage");
|
s_logger.warn("No DNS entry found during configuration of NfsSecondaryStorage");
|
||||||
} else {
|
} else {
|
||||||
addRouteToInternalIpOrCidr(_localgw, _eth1ip, _eth1mask,
|
addRouteToInternalIpOrCidr(_localgw, _eth1ip, _eth1mask,
|
||||||
internalDns1);
|
internalDns1);
|
||||||
}
|
}
|
||||||
|
|
||||||
String internalDns2 = (String) params.get("internaldns2");
|
String internalDns2 = (String) params.get("internaldns2");
|
||||||
if (internalDns2 != null) {
|
if (internalDns2 != null) {
|
||||||
addRouteToInternalIpOrCidr(_localgw, _eth1ip, _eth1mask,
|
addRouteToInternalIpOrCidr(_localgw, _eth1ip, _eth1mask,
|
||||||
internalDns2);
|
internalDns2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_pubIp = (String) params.get("public.ip");
|
_pubIp = (String) params.get("public.ip");
|
||||||
|
|
||||||
value = (String) params.get("disable_rp_filter");
|
value = (String) params.get("disable_rp_filter");
|
||||||
if (value != null && value.equalsIgnoreCase("true")) {
|
if (value != null && value.equalsIgnoreCase("true")) {
|
||||||
disableRpFilter();
|
disableRpFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s_logger.isInfoEnabled())
|
if (s_logger.isInfoEnabled())
|
||||||
s_logger.info("Receive proxyVmId in ConsoleProxyResource configuration as "
|
s_logger.info("Receive proxyVmId in ConsoleProxyResource configuration as "
|
||||||
+ _proxyVmId);
|
+ _proxyVmId);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addRouteToInternalIpOrCidr(String localgw, String eth1ip,
|
private void addRouteToInternalIpOrCidr(String localgw, String eth1ip,
|
||||||
String eth1mask, String destIpOrCidr) {
|
String eth1mask, String destIpOrCidr) {
|
||||||
s_logger.debug("addRouteToInternalIp: localgw=" + localgw + ", eth1ip="
|
s_logger.debug("addRouteToInternalIp: localgw=" + localgw + ", eth1ip="
|
||||||
+ eth1ip + ", eth1mask=" + eth1mask + ",destIp=" + destIpOrCidr);
|
+ eth1ip + ", eth1mask=" + eth1mask + ",destIp=" + destIpOrCidr);
|
||||||
if (destIpOrCidr == null) {
|
if (destIpOrCidr == null) {
|
||||||
s_logger.debug("addRouteToInternalIp: destIp is null");
|
s_logger.debug("addRouteToInternalIp: destIp is null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!NetUtils.isValidIp(destIpOrCidr)
|
if (!NetUtils.isValidIp(destIpOrCidr)
|
||||||
&& !NetUtils.isValidCIDR(destIpOrCidr)) {
|
&& !NetUtils.isValidCIDR(destIpOrCidr)) {
|
||||||
s_logger.warn(" destIp is not a valid ip address or cidr destIp="
|
s_logger.warn(" destIp is not a valid ip address or cidr destIp="
|
||||||
+ destIpOrCidr);
|
+ destIpOrCidr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
boolean inSameSubnet = false;
|
boolean inSameSubnet = false;
|
||||||
if (NetUtils.isValidIp(destIpOrCidr)) {
|
if (NetUtils.isValidIp(destIpOrCidr)) {
|
||||||
if (eth1ip != null && eth1mask != null) {
|
if (eth1ip != null && eth1mask != null) {
|
||||||
inSameSubnet = NetUtils.sameSubnet(eth1ip, destIpOrCidr,
|
inSameSubnet = NetUtils.sameSubnet(eth1ip, destIpOrCidr,
|
||||||
eth1mask);
|
eth1mask);
|
||||||
} else {
|
} else {
|
||||||
s_logger.warn("addRouteToInternalIp: unable to determine same subnet: _eth1ip="
|
s_logger.warn("addRouteToInternalIp: unable to determine same subnet: _eth1ip="
|
||||||
+ eth1ip
|
+ eth1ip
|
||||||
+ ", dest ip="
|
+ ", dest ip="
|
||||||
+ destIpOrCidr
|
+ destIpOrCidr
|
||||||
+ ", _eth1mask="
|
+ ", _eth1mask="
|
||||||
+ eth1mask);
|
+ eth1mask);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
inSameSubnet = NetUtils.isNetworkAWithinNetworkB(destIpOrCidr,
|
inSameSubnet = NetUtils.isNetworkAWithinNetworkB(destIpOrCidr,
|
||||||
NetUtils.ipAndNetMaskToCidr(eth1ip, eth1mask));
|
NetUtils.ipAndNetMaskToCidr(eth1ip, eth1mask));
|
||||||
}
|
}
|
||||||
if (inSameSubnet) {
|
if (inSameSubnet) {
|
||||||
s_logger.debug("addRouteToInternalIp: dest ip " + destIpOrCidr
|
s_logger.debug("addRouteToInternalIp: dest ip " + destIpOrCidr
|
||||||
+ " is in the same subnet as eth1 ip " + eth1ip);
|
+ " is in the same subnet as eth1 ip " + eth1ip);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Script command = new Script("/bin/bash", s_logger);
|
Script command = new Script("/bin/bash", s_logger);
|
||||||
command.add("-c");
|
command.add("-c");
|
||||||
command.add("ip route delete " + destIpOrCidr);
|
command.add("ip route delete " + destIpOrCidr);
|
||||||
command.execute();
|
command.execute();
|
||||||
command = new Script("/bin/bash", s_logger);
|
command = new Script("/bin/bash", s_logger);
|
||||||
command.add("-c");
|
command.add("-c");
|
||||||
command.add("ip route add " + destIpOrCidr + " via " + localgw);
|
command.add("ip route add " + destIpOrCidr + " via " + localgw);
|
||||||
String result = command.execute();
|
String result = command.execute();
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
s_logger.warn("Error in configuring route to internal ip err="
|
s_logger.warn("Error in configuring route to internal ip err="
|
||||||
+ result);
|
+ result);
|
||||||
} else {
|
} else {
|
||||||
s_logger.debug("addRouteToInternalIp: added route to internal ip="
|
s_logger.debug("addRouteToInternalIp: added route to internal ip="
|
||||||
+ destIpOrCidr + " via " + localgw);
|
+ destIpOrCidr + " via " + localgw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void launchConsoleProxy(final byte[] ksBits, final String ksPassword, final String encryptorPassword) {
|
private void launchConsoleProxy(final byte[] ksBits, final String ksPassword, final String encryptorPassword) {
|
||||||
final Object resource = this;
|
final Object resource = this;
|
||||||
if (_consoleProxyMain == null) {
|
if (_consoleProxyMain == null) {
|
||||||
_consoleProxyMain = new Thread(new Runnable() {
|
_consoleProxyMain = new Thread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
Class<?> consoleProxyClazz = Class.forName("com.cloud.consoleproxy.ConsoleProxy");
|
Class<?> consoleProxyClazz = Class.forName("com.cloud.consoleproxy.ConsoleProxy");
|
||||||
try {
|
try {
|
||||||
Method methodSetup = consoleProxyClazz.getMethod(
|
Method methodSetup = consoleProxyClazz.getMethod(
|
||||||
"setEncryptorPassword", String.class);
|
"setEncryptorPassword", String.class);
|
||||||
methodSetup.invoke(null, encryptorPassword);
|
methodSetup.invoke(null, encryptorPassword);
|
||||||
|
|
||||||
Method method = consoleProxyClazz.getMethod(
|
Method method = consoleProxyClazz.getMethod(
|
||||||
"startWithContext", Properties.class,
|
"startWithContext", Properties.class,
|
||||||
Object.class, byte[].class, String.class);
|
Object.class, byte[].class, String.class);
|
||||||
method.invoke(null, _properties, resource, ksBits,
|
method.invoke(null, _properties, resource, ksBits,
|
||||||
ksPassword);
|
ksPassword);
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
s_logger.error("Unable to launch console proxy due to SecurityException");
|
s_logger.error("Unable to launch console proxy due to SecurityException");
|
||||||
System.exit(ExitStatus.Error.value());
|
System.exit(ExitStatus.Error.value());
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
s_logger.error("Unable to launch console proxy due to NoSuchMethodException");
|
s_logger.error("Unable to launch console proxy due to NoSuchMethodException");
|
||||||
System.exit(ExitStatus.Error.value());
|
System.exit(ExitStatus.Error.value());
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
s_logger.error("Unable to launch console proxy due to IllegalArgumentException");
|
s_logger.error("Unable to launch console proxy due to IllegalArgumentException");
|
||||||
System.exit(ExitStatus.Error.value());
|
System.exit(ExitStatus.Error.value());
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
s_logger.error("Unable to launch console proxy due to IllegalAccessException");
|
s_logger.error("Unable to launch console proxy due to IllegalAccessException");
|
||||||
System.exit(ExitStatus.Error.value());
|
System.exit(ExitStatus.Error.value());
|
||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
s_logger.error("Unable to launch console proxy due to InvocationTargetException");
|
s_logger.error("Unable to launch console proxy due to InvocationTargetException");
|
||||||
System.exit(ExitStatus.Error.value());
|
System.exit(ExitStatus.Error.value());
|
||||||
}
|
}
|
||||||
} catch (final ClassNotFoundException e) {
|
} catch (final ClassNotFoundException e) {
|
||||||
s_logger.error("Unable to launch console proxy due to ClassNotFoundException");
|
s_logger.error("Unable to launch console proxy due to ClassNotFoundException");
|
||||||
System.exit(ExitStatus.Error.value());
|
System.exit(ExitStatus.Error.value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, "Console-Proxy-Main");
|
}, "Console-Proxy-Main");
|
||||||
_consoleProxyMain.setDaemon(true);
|
_consoleProxyMain.setDaemon(true);
|
||||||
_consoleProxyMain.start();
|
_consoleProxyMain.start();
|
||||||
} else {
|
} else {
|
||||||
s_logger.info("com.cloud.consoleproxy.ConsoleProxy is already running");
|
s_logger.info("com.cloud.consoleproxy.ConsoleProxy is already running");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Class<?> consoleProxyClazz = Class.forName("com.cloud.consoleproxy.ConsoleProxy");
|
Class<?> consoleProxyClazz = Class.forName("com.cloud.consoleproxy.ConsoleProxy");
|
||||||
Method methodSetup = consoleProxyClazz.getMethod("setEncryptorPassword", String.class);
|
Method methodSetup = consoleProxyClazz.getMethod("setEncryptorPassword", String.class);
|
||||||
methodSetup.invoke(null, encryptorPassword);
|
methodSetup.invoke(null, encryptorPassword);
|
||||||
} catch (SecurityException e) {
|
} catch (SecurityException e) {
|
||||||
s_logger.error("Unable to launch console proxy due to SecurityException");
|
s_logger.error("Unable to launch console proxy due to SecurityException");
|
||||||
System.exit(ExitStatus.Error.value());
|
System.exit(ExitStatus.Error.value());
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
s_logger.error("Unable to launch console proxy due to NoSuchMethodException");
|
s_logger.error("Unable to launch console proxy due to NoSuchMethodException");
|
||||||
System.exit(ExitStatus.Error.value());
|
System.exit(ExitStatus.Error.value());
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
s_logger.error("Unable to launch console proxy due to IllegalArgumentException");
|
s_logger.error("Unable to launch console proxy due to IllegalArgumentException");
|
||||||
System.exit(ExitStatus.Error.value());
|
System.exit(ExitStatus.Error.value());
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
s_logger.error("Unable to launch console proxy due to IllegalAccessException");
|
s_logger.error("Unable to launch console proxy due to IllegalAccessException");
|
||||||
System.exit(ExitStatus.Error.value());
|
System.exit(ExitStatus.Error.value());
|
||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
s_logger.error("Unable to launch console proxy due to InvocationTargetException");
|
s_logger.error("Unable to launch console proxy due to InvocationTargetException");
|
||||||
System.exit(ExitStatus.Error.value());
|
System.exit(ExitStatus.Error.value());
|
||||||
} catch (final ClassNotFoundException e) {
|
} catch (final ClassNotFoundException e) {
|
||||||
s_logger.error("Unable to launch console proxy due to ClassNotFoundException");
|
s_logger.error("Unable to launch console proxy due to ClassNotFoundException");
|
||||||
System.exit(ExitStatus.Error.value());
|
System.exit(ExitStatus.Error.value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String authenticateConsoleAccess(String host, String port,
|
public String authenticateConsoleAccess(String host, String port,
|
||||||
String vmId, String sid, String ticket, Boolean isReauthentication) {
|
String vmId, String sid, String ticket, Boolean isReauthentication) {
|
||||||
|
|
||||||
ConsoleAccessAuthenticationCommand cmd = new ConsoleAccessAuthenticationCommand(
|
ConsoleAccessAuthenticationCommand cmd = new ConsoleAccessAuthenticationCommand(
|
||||||
host, port, vmId, sid, ticket);
|
host, port, vmId, sid, ticket);
|
||||||
cmd.setReauthenticating(isReauthentication);
|
cmd.setReauthenticating(isReauthentication);
|
||||||
|
|
||||||
ConsoleProxyAuthenticationResult result = new ConsoleProxyAuthenticationResult();
|
ConsoleProxyAuthenticationResult result = new ConsoleProxyAuthenticationResult();
|
||||||
result.setSuccess(false);
|
result.setSuccess(false);
|
||||||
result.setReauthentication(isReauthentication);
|
result.setReauthentication(isReauthentication);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
AgentControlAnswer answer = getAgentControl().sendRequest(cmd, 10000);
|
AgentControlAnswer answer = getAgentControl().sendRequest(cmd, 10000);
|
||||||
|
|
||||||
if (answer != null) {
|
if (answer != null) {
|
||||||
ConsoleAccessAuthenticationAnswer authAnswer = (ConsoleAccessAuthenticationAnswer)answer;
|
ConsoleAccessAuthenticationAnswer authAnswer = (ConsoleAccessAuthenticationAnswer)answer;
|
||||||
result.setSuccess(authAnswer.succeeded());
|
result.setSuccess(authAnswer.succeeded());
|
||||||
result.setHost(authAnswer.getHost());
|
result.setHost(authAnswer.getHost());
|
||||||
result.setPort(authAnswer.getPort());
|
result.setPort(authAnswer.getPort());
|
||||||
result.setTunnelUrl(authAnswer.getTunnelUrl());
|
result.setTunnelUrl(authAnswer.getTunnelUrl());
|
||||||
result.setTunnelSession(authAnswer.getTunnelSession());
|
result.setTunnelSession(authAnswer.getTunnelSession());
|
||||||
} else {
|
} else {
|
||||||
s_logger.error("Authentication failed for vm: " + vmId + " with sid: " + sid);
|
s_logger.error("Authentication failed for vm: " + vmId + " with sid: " + sid);
|
||||||
}
|
}
|
||||||
} catch (AgentControlChannelException e) {
|
} catch (AgentControlChannelException e) {
|
||||||
s_logger.error("Unable to send out console access authentication request due to "
|
s_logger.error("Unable to send out console access authentication request due to "
|
||||||
+ e.getMessage(), e);
|
+ e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Gson().toJson(result);
|
return new Gson().toJson(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reportLoadInfo(String gsonLoadInfo) {
|
public void reportLoadInfo(String gsonLoadInfo) {
|
||||||
ConsoleProxyLoadReportCommand cmd = new ConsoleProxyLoadReportCommand(
|
ConsoleProxyLoadReportCommand cmd = new ConsoleProxyLoadReportCommand(
|
||||||
_proxyVmId, gsonLoadInfo);
|
_proxyVmId, gsonLoadInfo);
|
||||||
try {
|
try {
|
||||||
getAgentControl().postRequest(cmd);
|
getAgentControl().postRequest(cmd);
|
||||||
|
|
||||||
if (s_logger.isDebugEnabled())
|
if (s_logger.isDebugEnabled())
|
||||||
s_logger.debug("Report proxy load info, proxy : " + _proxyVmId
|
s_logger.debug("Report proxy load info, proxy : " + _proxyVmId
|
||||||
+ ", load: " + gsonLoadInfo);
|
+ ", load: " + gsonLoadInfo);
|
||||||
} catch (AgentControlChannelException e) {
|
} catch (AgentControlChannelException e) {
|
||||||
s_logger.error(
|
s_logger.error(
|
||||||
"Unable to send out load info due to " + e.getMessage(), e);
|
"Unable to send out load info due to " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ensureRoute(String address) {
|
public void ensureRoute(String address) {
|
||||||
if (_localgw != null) {
|
if (_localgw != null) {
|
||||||
if (s_logger.isDebugEnabled())
|
if (s_logger.isDebugEnabled())
|
||||||
s_logger.debug("Ensure route for " + address + " via "
|
s_logger.debug("Ensure route for " + address + " via "
|
||||||
+ _localgw);
|
+ _localgw);
|
||||||
|
|
||||||
// this method won't be called in high frequency, serialize access
|
// this method won't be called in high frequency, serialize access
|
||||||
// to script execution
|
// to script execution
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
try {
|
try {
|
||||||
addRouteToInternalIpOrCidr(_localgw, _eth1ip, _eth1mask,
|
addRouteToInternalIpOrCidr(_localgw, _eth1ip, _eth1mask,
|
||||||
address);
|
address);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
s_logger.warn(
|
s_logger.warn(
|
||||||
"Unexpected exception while adding internal route to "
|
"Unexpected exception while adding internal route to "
|
||||||
+ address, e);
|
+ address, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,66 +17,66 @@
|
|||||||
package com.cloud.agent.storage;
|
package com.cloud.agent.storage;
|
||||||
|
|
||||||
public class KVMPhysicalDisk {
|
public class KVMPhysicalDisk {
|
||||||
private String path;
|
private String path;
|
||||||
private String name;
|
private String name;
|
||||||
private KVMStoragePool pool;
|
private KVMStoragePool pool;
|
||||||
|
|
||||||
public static enum PhysicalDiskFormat {
|
public static enum PhysicalDiskFormat {
|
||||||
RAW("raw"), QCOW2("qcow2");
|
RAW("raw"), QCOW2("qcow2");
|
||||||
String format;
|
String format;
|
||||||
|
|
||||||
private PhysicalDiskFormat(String format) {
|
private PhysicalDiskFormat(String format) {
|
||||||
this.format = format;
|
this.format = format;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return this.format;
|
return this.format;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private PhysicalDiskFormat format;
|
private PhysicalDiskFormat format;
|
||||||
private long size;
|
private long size;
|
||||||
private long virtualSize;
|
private long virtualSize;
|
||||||
|
|
||||||
public KVMPhysicalDisk(String path, String name, KVMStoragePool pool) {
|
public KVMPhysicalDisk(String path, String name, KVMStoragePool pool) {
|
||||||
this.path = path;
|
this.path = path;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.pool = pool;
|
this.pool = pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFormat(PhysicalDiskFormat format) {
|
public void setFormat(PhysicalDiskFormat format) {
|
||||||
this.format = format;
|
this.format = format;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PhysicalDiskFormat getFormat() {
|
public PhysicalDiskFormat getFormat() {
|
||||||
return this.format;
|
return this.format;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSize(long size) {
|
public void setSize(long size) {
|
||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getSize() {
|
public long getSize() {
|
||||||
return this.size;
|
return this.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVirtualSize(long size) {
|
public void setVirtualSize(long size) {
|
||||||
this.virtualSize = size;
|
this.virtualSize = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getVirtualSize() {
|
public long getVirtualSize() {
|
||||||
return this.virtualSize;
|
return this.virtualSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPath() {
|
public String getPath() {
|
||||||
return this.path;
|
return this.path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public KVMStoragePool getPool() {
|
public KVMStoragePool getPool() {
|
||||||
return this.pool;
|
return this.pool;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,34 +22,34 @@ import com.cloud.agent.storage.KVMPhysicalDisk.PhysicalDiskFormat;
|
|||||||
import com.cloud.storage.Storage.StoragePoolType;
|
import com.cloud.storage.Storage.StoragePoolType;
|
||||||
|
|
||||||
public interface KVMStoragePool {
|
public interface KVMStoragePool {
|
||||||
public KVMPhysicalDisk createPhysicalDisk(String name,
|
public KVMPhysicalDisk createPhysicalDisk(String name,
|
||||||
PhysicalDiskFormat format, long size);
|
PhysicalDiskFormat format, long size);
|
||||||
|
|
||||||
public KVMPhysicalDisk createPhysicalDisk(String name, long size);
|
public KVMPhysicalDisk createPhysicalDisk(String name, long size);
|
||||||
|
|
||||||
public KVMPhysicalDisk getPhysicalDisk(String volumeUuid);
|
public KVMPhysicalDisk getPhysicalDisk(String volumeUuid);
|
||||||
|
|
||||||
public boolean deletePhysicalDisk(String uuid);
|
public boolean deletePhysicalDisk(String uuid);
|
||||||
|
|
||||||
public List<KVMPhysicalDisk> listPhysicalDisks();
|
public List<KVMPhysicalDisk> listPhysicalDisks();
|
||||||
|
|
||||||
public String getUuid();
|
public String getUuid();
|
||||||
|
|
||||||
public long getCapacity();
|
public long getCapacity();
|
||||||
|
|
||||||
public long getUsed();
|
public long getUsed();
|
||||||
|
|
||||||
public boolean refresh();
|
public boolean refresh();
|
||||||
|
|
||||||
public boolean isExternalSnapshot();
|
public boolean isExternalSnapshot();
|
||||||
|
|
||||||
public String getLocalPath();
|
public String getLocalPath();
|
||||||
|
|
||||||
public StoragePoolType getType();
|
public StoragePoolType getType();
|
||||||
|
|
||||||
public boolean delete();
|
public boolean delete();
|
||||||
|
|
||||||
PhysicalDiskFormat getDefaultFormat();
|
PhysicalDiskFormat getDefaultFormat();
|
||||||
|
|
||||||
public boolean createFolder(String path);
|
public boolean createFolder(String path);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,78 +27,78 @@ import com.cloud.storage.Storage.StoragePoolType;
|
|||||||
import com.cloud.storage.StorageLayer;
|
import com.cloud.storage.StorageLayer;
|
||||||
|
|
||||||
public class KVMStoragePoolManager {
|
public class KVMStoragePoolManager {
|
||||||
private StorageAdaptor _storageAdaptor;
|
private StorageAdaptor _storageAdaptor;
|
||||||
private KVMHAMonitor _haMonitor;
|
private KVMHAMonitor _haMonitor;
|
||||||
private final Map<String, Object> _storagePools = new ConcurrentHashMap<String, Object>();
|
private final Map<String, Object> _storagePools = new ConcurrentHashMap<String, Object>();
|
||||||
|
|
||||||
private void addStoragePool(String uuid) {
|
private void addStoragePool(String uuid) {
|
||||||
synchronized (_storagePools) {
|
synchronized (_storagePools) {
|
||||||
if (!_storagePools.containsKey(uuid)) {
|
if (!_storagePools.containsKey(uuid)) {
|
||||||
_storagePools.put(uuid, new Object());
|
_storagePools.put(uuid, new Object());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public KVMStoragePoolManager(StorageLayer storagelayer, KVMHAMonitor monitor) {
|
public KVMStoragePoolManager(StorageLayer storagelayer, KVMHAMonitor monitor) {
|
||||||
this._storageAdaptor = new LibvirtStorageAdaptor(storagelayer);
|
this._storageAdaptor = new LibvirtStorageAdaptor(storagelayer);
|
||||||
this._haMonitor = monitor;
|
this._haMonitor = monitor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public KVMStoragePool getStoragePool(String uuid) {
|
public KVMStoragePool getStoragePool(String uuid) {
|
||||||
return this._storageAdaptor.getStoragePool(uuid);
|
return this._storageAdaptor.getStoragePool(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public KVMStoragePool getStoragePoolByURI(String uri) {
|
public KVMStoragePool getStoragePoolByURI(String uri) {
|
||||||
return this._storageAdaptor.getStoragePoolByUri(uri);
|
return this._storageAdaptor.getStoragePoolByUri(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
public KVMStoragePool createStoragePool(String name, String host,
|
public KVMStoragePool createStoragePool(String name, String host,
|
||||||
String path, StoragePoolType type) {
|
String path, StoragePoolType type) {
|
||||||
KVMStoragePool pool = this._storageAdaptor.createStoragePool(name,
|
KVMStoragePool pool = this._storageAdaptor.createStoragePool(name,
|
||||||
host, path, type);
|
host, path, type);
|
||||||
if (type == StoragePoolType.NetworkFilesystem) {
|
if (type == StoragePoolType.NetworkFilesystem) {
|
||||||
KVMHABase.NfsStoragePool nfspool = new KVMHABase.NfsStoragePool(
|
KVMHABase.NfsStoragePool nfspool = new KVMHABase.NfsStoragePool(
|
||||||
pool.getUuid(), host, path, pool.getLocalPath(),
|
pool.getUuid(), host, path, pool.getLocalPath(),
|
||||||
PoolType.PrimaryStorage);
|
PoolType.PrimaryStorage);
|
||||||
_haMonitor.addStoragePool(nfspool);
|
_haMonitor.addStoragePool(nfspool);
|
||||||
}
|
}
|
||||||
addStoragePool(pool.getUuid());
|
addStoragePool(pool.getUuid());
|
||||||
return pool;
|
return pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean deleteStoragePool(String uuid) {
|
public boolean deleteStoragePool(String uuid) {
|
||||||
_haMonitor.removeStoragePool(uuid);
|
_haMonitor.removeStoragePool(uuid);
|
||||||
this._storageAdaptor.deleteStoragePool(uuid);
|
this._storageAdaptor.deleteStoragePool(uuid);
|
||||||
_storagePools.remove(uuid);
|
_storagePools.remove(uuid);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public KVMPhysicalDisk createDiskFromTemplate(KVMPhysicalDisk template,
|
public KVMPhysicalDisk createDiskFromTemplate(KVMPhysicalDisk template,
|
||||||
String name, KVMStoragePool destPool) {
|
String name, KVMStoragePool destPool) {
|
||||||
return this._storageAdaptor.createDiskFromTemplate(template, name,
|
return this._storageAdaptor.createDiskFromTemplate(template, name,
|
||||||
KVMPhysicalDisk.PhysicalDiskFormat.QCOW2,
|
KVMPhysicalDisk.PhysicalDiskFormat.QCOW2,
|
||||||
template.getSize(), destPool);
|
template.getSize(), destPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
public KVMPhysicalDisk createTemplateFromDisk(KVMPhysicalDisk disk,
|
public KVMPhysicalDisk createTemplateFromDisk(KVMPhysicalDisk disk,
|
||||||
String name, PhysicalDiskFormat format, long size,
|
String name, PhysicalDiskFormat format, long size,
|
||||||
KVMStoragePool destPool) {
|
KVMStoragePool destPool) {
|
||||||
return this._storageAdaptor.createTemplateFromDisk(disk, name, format,
|
return this._storageAdaptor.createTemplateFromDisk(disk, name, format,
|
||||||
size, destPool);
|
size, destPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
public KVMPhysicalDisk copyPhysicalDisk(KVMPhysicalDisk disk, String name,
|
public KVMPhysicalDisk copyPhysicalDisk(KVMPhysicalDisk disk, String name,
|
||||||
KVMStoragePool destPool) {
|
KVMStoragePool destPool) {
|
||||||
return this._storageAdaptor.copyPhysicalDisk(disk, name, destPool);
|
return this._storageAdaptor.copyPhysicalDisk(disk, name, destPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
public KVMPhysicalDisk createDiskFromSnapshot(KVMPhysicalDisk snapshot,
|
public KVMPhysicalDisk createDiskFromSnapshot(KVMPhysicalDisk snapshot,
|
||||||
String snapshotName, String name, KVMStoragePool destPool) {
|
String snapshotName, String name, KVMStoragePool destPool) {
|
||||||
return this._storageAdaptor.createDiskFromSnapshot(snapshot,
|
return this._storageAdaptor.createDiskFromSnapshot(snapshot,
|
||||||
snapshotName, name, destPool);
|
snapshotName, name, destPool);
|
||||||
}
|
}
|
||||||
|
|
||||||
public KVMPhysicalDisk getPhysicalDiskFromUrl(String url) {
|
public KVMPhysicalDisk getPhysicalDiskFromUrl(String url) {
|
||||||
return this._storageAdaptor.getPhysicalDiskFromURI(url);
|
return this._storageAdaptor.getPhysicalDiskFromURI(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -24,135 +24,135 @@ import com.cloud.agent.storage.KVMPhysicalDisk.PhysicalDiskFormat;
|
|||||||
import com.cloud.storage.Storage.StoragePoolType;
|
import com.cloud.storage.Storage.StoragePoolType;
|
||||||
|
|
||||||
public class LibvirtStoragePool implements KVMStoragePool {
|
public class LibvirtStoragePool implements KVMStoragePool {
|
||||||
protected String uuid;
|
protected String uuid;
|
||||||
protected String uri;
|
protected String uri;
|
||||||
protected long capacity;
|
protected long capacity;
|
||||||
protected long used;
|
protected long used;
|
||||||
protected String name;
|
protected String name;
|
||||||
protected String localPath;
|
protected String localPath;
|
||||||
protected PhysicalDiskFormat defaultFormat;
|
protected PhysicalDiskFormat defaultFormat;
|
||||||
protected StoragePoolType type;
|
protected StoragePoolType type;
|
||||||
protected StorageAdaptor _storageAdaptor;
|
protected StorageAdaptor _storageAdaptor;
|
||||||
protected StoragePool _pool;
|
protected StoragePool _pool;
|
||||||
|
|
||||||
public LibvirtStoragePool(String uuid, String name, StoragePoolType type,
|
public LibvirtStoragePool(String uuid, String name, StoragePoolType type,
|
||||||
StorageAdaptor adaptor, StoragePool pool) {
|
StorageAdaptor adaptor, StoragePool pool) {
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this._storageAdaptor = adaptor;
|
this._storageAdaptor = adaptor;
|
||||||
this.capacity = 0;
|
this.capacity = 0;
|
||||||
this.used = 0;
|
this.used = 0;
|
||||||
this._pool = pool;
|
this._pool = pool;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCapacity(long capacity) {
|
public void setCapacity(long capacity) {
|
||||||
this.capacity = capacity;
|
this.capacity = capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getCapacity() {
|
public long getCapacity() {
|
||||||
return this.capacity;
|
return this.capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUsed(long used) {
|
public void setUsed(long used) {
|
||||||
this.used = used;
|
this.used = used;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getUsed() {
|
public long getUsed() {
|
||||||
return this.used;
|
return this.used;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StoragePoolType getStoragePoolType() {
|
public StoragePoolType getStoragePoolType() {
|
||||||
return this.type;
|
return this.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUuid() {
|
public String getUuid() {
|
||||||
return this.uuid;
|
return this.uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String uri() {
|
public String uri() {
|
||||||
return this.uri;
|
return this.uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PhysicalDiskFormat getDefaultFormat() {
|
public PhysicalDiskFormat getDefaultFormat() {
|
||||||
return PhysicalDiskFormat.QCOW2;
|
return PhysicalDiskFormat.QCOW2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KVMPhysicalDisk createPhysicalDisk(String name,
|
public KVMPhysicalDisk createPhysicalDisk(String name,
|
||||||
PhysicalDiskFormat format, long size) {
|
PhysicalDiskFormat format, long size) {
|
||||||
return this._storageAdaptor
|
return this._storageAdaptor
|
||||||
.createPhysicalDisk(name, this, format, size);
|
.createPhysicalDisk(name, this, format, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KVMPhysicalDisk createPhysicalDisk(String name, long size) {
|
public KVMPhysicalDisk createPhysicalDisk(String name, long size) {
|
||||||
return this._storageAdaptor.createPhysicalDisk(name, this,
|
return this._storageAdaptor.createPhysicalDisk(name, this,
|
||||||
this.getDefaultFormat(), size);
|
this.getDefaultFormat(), size);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KVMPhysicalDisk getPhysicalDisk(String volumeUuid) {
|
public KVMPhysicalDisk getPhysicalDisk(String volumeUuid) {
|
||||||
return this._storageAdaptor.getPhysicalDisk(volumeUuid, this);
|
return this._storageAdaptor.getPhysicalDisk(volumeUuid, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean deletePhysicalDisk(String uuid) {
|
public boolean deletePhysicalDisk(String uuid) {
|
||||||
return this._storageAdaptor.deletePhysicalDisk(uuid, this);
|
return this._storageAdaptor.deletePhysicalDisk(uuid, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<KVMPhysicalDisk> listPhysicalDisks() {
|
public List<KVMPhysicalDisk> listPhysicalDisks() {
|
||||||
return this._storageAdaptor.listPhysicalDisks(this.uuid, this);
|
return this._storageAdaptor.listPhysicalDisks(this.uuid, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean refresh() {
|
public boolean refresh() {
|
||||||
return this._storageAdaptor.refresh(this);
|
return this._storageAdaptor.refresh(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isExternalSnapshot() {
|
public boolean isExternalSnapshot() {
|
||||||
if (this.type == StoragePoolType.Filesystem) {
|
if (this.type == StoragePoolType.Filesystem) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getLocalPath() {
|
public String getLocalPath() {
|
||||||
return this.localPath;
|
return this.localPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLocalPath(String localPath) {
|
public void setLocalPath(String localPath) {
|
||||||
this.localPath = localPath;
|
this.localPath = localPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StoragePoolType getType() {
|
public StoragePoolType getType() {
|
||||||
return this.type;
|
return this.type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StoragePool getPool() {
|
public StoragePool getPool() {
|
||||||
return this._pool;
|
return this._pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean delete() {
|
public boolean delete() {
|
||||||
return this._storageAdaptor.deleteStoragePool(this);
|
return this._storageAdaptor.deleteStoragePool(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean createFolder(String path) {
|
public boolean createFolder(String path) {
|
||||||
return this._storageAdaptor.createFolder(this.uuid, path);
|
return this._storageAdaptor.createFolder(this.uuid, path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,46 +25,46 @@ import com.cloud.storage.Storage.StoragePoolType;
|
|||||||
|
|
||||||
public interface StorageAdaptor {
|
public interface StorageAdaptor {
|
||||||
|
|
||||||
public KVMStoragePool getStoragePool(String uuid);
|
public KVMStoragePool getStoragePool(String uuid);
|
||||||
|
|
||||||
public KVMPhysicalDisk getPhysicalDisk(String volumeUuid,
|
public KVMPhysicalDisk getPhysicalDisk(String volumeUuid,
|
||||||
KVMStoragePool pool);
|
KVMStoragePool pool);
|
||||||
|
|
||||||
public KVMStoragePool createStoragePool(String name, String host,
|
public KVMStoragePool createStoragePool(String name, String host,
|
||||||
String path, StoragePoolType type);
|
String path, StoragePoolType type);
|
||||||
|
|
||||||
public boolean deleteStoragePool(String uuid);
|
public boolean deleteStoragePool(String uuid);
|
||||||
|
|
||||||
public KVMPhysicalDisk createPhysicalDisk(String name, KVMStoragePool pool,
|
public KVMPhysicalDisk createPhysicalDisk(String name, KVMStoragePool pool,
|
||||||
PhysicalDiskFormat format, long size);
|
PhysicalDiskFormat format, long size);
|
||||||
|
|
||||||
public boolean deletePhysicalDisk(String uuid, KVMStoragePool pool);
|
public boolean deletePhysicalDisk(String uuid, KVMStoragePool pool);
|
||||||
|
|
||||||
public KVMPhysicalDisk createDiskFromTemplate(KVMPhysicalDisk template,
|
public KVMPhysicalDisk createDiskFromTemplate(KVMPhysicalDisk template,
|
||||||
String name, PhysicalDiskFormat format, long size,
|
String name, PhysicalDiskFormat format, long size,
|
||||||
KVMStoragePool destPool);
|
KVMStoragePool destPool);
|
||||||
|
|
||||||
public KVMPhysicalDisk createTemplateFromDisk(KVMPhysicalDisk disk,
|
public KVMPhysicalDisk createTemplateFromDisk(KVMPhysicalDisk disk,
|
||||||
String name, PhysicalDiskFormat format, long size,
|
String name, PhysicalDiskFormat format, long size,
|
||||||
KVMStoragePool destPool);
|
KVMStoragePool destPool);
|
||||||
|
|
||||||
public List<KVMPhysicalDisk> listPhysicalDisks(String storagePoolUuid,
|
public List<KVMPhysicalDisk> listPhysicalDisks(String storagePoolUuid,
|
||||||
KVMStoragePool pool);
|
KVMStoragePool pool);
|
||||||
|
|
||||||
public KVMPhysicalDisk copyPhysicalDisk(KVMPhysicalDisk disk, String name,
|
public KVMPhysicalDisk copyPhysicalDisk(KVMPhysicalDisk disk, String name,
|
||||||
KVMStoragePool destPools);
|
KVMStoragePool destPools);
|
||||||
|
|
||||||
public KVMPhysicalDisk createDiskFromSnapshot(KVMPhysicalDisk snapshot,
|
public KVMPhysicalDisk createDiskFromSnapshot(KVMPhysicalDisk snapshot,
|
||||||
String snapshotName, String name, KVMStoragePool destPool);
|
String snapshotName, String name, KVMStoragePool destPool);
|
||||||
|
|
||||||
public KVMStoragePool getStoragePoolByUri(String uri);
|
public KVMStoragePool getStoragePoolByUri(String uri);
|
||||||
|
|
||||||
public KVMPhysicalDisk getPhysicalDiskFromURI(String uri);
|
public KVMPhysicalDisk getPhysicalDiskFromURI(String uri);
|
||||||
|
|
||||||
public boolean refresh(KVMStoragePool pool);
|
public boolean refresh(KVMStoragePool pool);
|
||||||
|
|
||||||
public boolean deleteStoragePool(KVMStoragePool pool);
|
public boolean deleteStoragePool(KVMStoragePool pool);
|
||||||
|
|
||||||
public boolean createFolder(String uuid, String path);
|
public boolean createFolder(String uuid, String path);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,305 +66,305 @@ import com.cloud.utils.script.Script;
|
|||||||
*/
|
*/
|
||||||
@Local(value = { VmDataServer.class })
|
@Local(value = { VmDataServer.class })
|
||||||
public class JettyVmDataServer implements VmDataServer {
|
public class JettyVmDataServer implements VmDataServer {
|
||||||
private static final Logger s_logger = Logger
|
private static final Logger s_logger = Logger
|
||||||
.getLogger(JettyVmDataServer.class);
|
.getLogger(JettyVmDataServer.class);
|
||||||
|
|
||||||
public static final String USER_DATA = "user-data";
|
public static final String USER_DATA = "user-data";
|
||||||
public static final String META_DATA = "meta-data";
|
public static final String META_DATA = "meta-data";
|
||||||
protected String _vmDataDir;
|
protected String _vmDataDir;
|
||||||
protected Server _jetty;
|
protected Server _jetty;
|
||||||
protected String _hostIp;
|
protected String _hostIp;
|
||||||
protected Map<String, String> _ipVmMap = new HashMap<String, String>();
|
protected Map<String, String> _ipVmMap = new HashMap<String, String>();
|
||||||
protected StorageLayer _fs = new JavaStorageLayer();
|
protected StorageLayer _fs = new JavaStorageLayer();
|
||||||
|
|
||||||
public class VmDataServlet extends HttpServlet {
|
public class VmDataServlet extends HttpServlet {
|
||||||
|
|
||||||
private static final long serialVersionUID = -1640031398971742349L;
|
private static final long serialVersionUID = -1640031398971742349L;
|
||||||
|
|
||||||
JettyVmDataServer _vmDataServer;
|
JettyVmDataServer _vmDataServer;
|
||||||
String _dataType; // userdata or meta-data
|
String _dataType; // userdata or meta-data
|
||||||
|
|
||||||
public VmDataServlet(JettyVmDataServer dataServer, String dataType) {
|
public VmDataServlet(JettyVmDataServer dataServer, String dataType) {
|
||||||
this._vmDataServer = dataServer;
|
this._vmDataServer = dataServer;
|
||||||
this._dataType = dataType;
|
this._dataType = dataType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
|
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
|
||||||
throws ServletException, IOException {
|
throws ServletException, IOException {
|
||||||
int port = req.getServerPort();
|
int port = req.getServerPort();
|
||||||
if (port != 80 && port != 8000) {
|
if (port != 80 && port != 8000) {
|
||||||
resp.sendError(HttpServletResponse.SC_NOT_FOUND,
|
resp.sendError(HttpServletResponse.SC_NOT_FOUND,
|
||||||
"Request not understood");
|
"Request not understood");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_dataType.equalsIgnoreCase(USER_DATA)) {
|
if (_dataType.equalsIgnoreCase(USER_DATA)) {
|
||||||
handleUserData(req, resp);
|
handleUserData(req, resp);
|
||||||
} else if (_dataType.equalsIgnoreCase(META_DATA)) {
|
} else if (_dataType.equalsIgnoreCase(META_DATA)) {
|
||||||
handleMetaData(req, resp);
|
handleMetaData(req, resp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void handleUserData(HttpServletRequest req,
|
protected void handleUserData(HttpServletRequest req,
|
||||||
HttpServletResponse resp) throws ServletException, IOException {
|
HttpServletResponse resp) throws ServletException, IOException {
|
||||||
String metadataItem = req.getPathInfo();
|
String metadataItem = req.getPathInfo();
|
||||||
String requester = req.getRemoteAddr();
|
String requester = req.getRemoteAddr();
|
||||||
resp.setContentType("text/html");
|
resp.setContentType("text/html");
|
||||||
resp.setStatus(HttpServletResponse.SC_OK);
|
resp.setStatus(HttpServletResponse.SC_OK);
|
||||||
String data = null;
|
String data = null;
|
||||||
if (metadataItem != null) {
|
if (metadataItem != null) {
|
||||||
String[] path = metadataItem.split("/");
|
String[] path = metadataItem.split("/");
|
||||||
if (path.length > 1) {
|
if (path.length > 1) {
|
||||||
metadataItem = path[1];
|
metadataItem = path[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (metadataItem != null)
|
if (metadataItem != null)
|
||||||
data = _vmDataServer.getVmDataItem(requester, metadataItem);
|
data = _vmDataServer.getVmDataItem(requester, metadataItem);
|
||||||
|
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
resp.getWriter().print(data);
|
resp.getWriter().print(data);
|
||||||
} else {
|
} else {
|
||||||
resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
||||||
resp.sendError(HttpServletResponse.SC_NOT_FOUND,
|
resp.sendError(HttpServletResponse.SC_NOT_FOUND,
|
||||||
"Request not found");
|
"Request not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void handleMetaData(HttpServletRequest req,
|
protected void handleMetaData(HttpServletRequest req,
|
||||||
HttpServletResponse resp) throws ServletException, IOException {
|
HttpServletResponse resp) throws ServletException, IOException {
|
||||||
String metadataItem = req.getPathInfo();
|
String metadataItem = req.getPathInfo();
|
||||||
String requester = req.getRemoteAddr();
|
String requester = req.getRemoteAddr();
|
||||||
resp.setContentType("text/html");
|
resp.setContentType("text/html");
|
||||||
resp.setStatus(HttpServletResponse.SC_OK);
|
resp.setStatus(HttpServletResponse.SC_OK);
|
||||||
String metaData = _vmDataServer.getVmDataItem(requester,
|
String metaData = _vmDataServer.getVmDataItem(requester,
|
||||||
metadataItem);
|
metadataItem);
|
||||||
if (metaData != null) {
|
if (metaData != null) {
|
||||||
resp.getWriter().print(
|
resp.getWriter().print(
|
||||||
_vmDataServer.getVmDataItem(requester, metadataItem));
|
_vmDataServer.getVmDataItem(requester, metadataItem));
|
||||||
} else {
|
} else {
|
||||||
resp.sendError(HttpServletResponse.SC_NOT_FOUND,
|
resp.sendError(HttpServletResponse.SC_NOT_FOUND,
|
||||||
"Request not found");
|
"Request not found");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean configure(String name, Map<String, Object> params)
|
public boolean configure(String name, Map<String, Object> params)
|
||||||
throws ConfigurationException {
|
throws ConfigurationException {
|
||||||
boolean success = true;
|
boolean success = true;
|
||||||
try {
|
try {
|
||||||
int vmDataPort = 80;
|
int vmDataPort = 80;
|
||||||
int fileservingPort = 8000;
|
int fileservingPort = 8000;
|
||||||
_vmDataDir = (String) params.get("vm.data.dir");
|
_vmDataDir = (String) params.get("vm.data.dir");
|
||||||
String port = (String) params.get("vm.data.port");
|
String port = (String) params.get("vm.data.port");
|
||||||
if (port != null) {
|
if (port != null) {
|
||||||
vmDataPort = Integer.parseInt(port);
|
vmDataPort = Integer.parseInt(port);
|
||||||
}
|
}
|
||||||
port = (String) params.get("file.server.port");
|
port = (String) params.get("file.server.port");
|
||||||
if (port != null) {
|
if (port != null) {
|
||||||
fileservingPort = Integer.parseInt(port);
|
fileservingPort = Integer.parseInt(port);
|
||||||
}
|
}
|
||||||
_hostIp = (String) params.get("host.ip");
|
_hostIp = (String) params.get("host.ip");
|
||||||
|
|
||||||
if (_vmDataDir == null) {
|
if (_vmDataDir == null) {
|
||||||
_vmDataDir = "/var/www/html";
|
_vmDataDir = "/var/www/html";
|
||||||
}
|
}
|
||||||
success = _fs.mkdirs(_vmDataDir);
|
success = _fs.mkdirs(_vmDataDir);
|
||||||
success = success && buildIpVmMap();
|
success = success && buildIpVmMap();
|
||||||
if (success) {
|
if (success) {
|
||||||
setupJetty(vmDataPort, fileservingPort);
|
setupJetty(vmDataPort, fileservingPort);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
s_logger.warn("Failed to configure jetty", e);
|
s_logger.warn("Failed to configure jetty", e);
|
||||||
throw new ConfigurationException("Failed to configure jetty!!");
|
throw new ConfigurationException("Failed to configure jetty!!");
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean buildIpVmMap() {
|
protected boolean buildIpVmMap() {
|
||||||
String[] dirs = _fs.listFiles(_vmDataDir);
|
String[] dirs = _fs.listFiles(_vmDataDir);
|
||||||
for (String dir : dirs) {
|
for (String dir : dirs) {
|
||||||
String[] path = dir.split("/");
|
String[] path = dir.split("/");
|
||||||
String vm = path[path.length - 1];
|
String vm = path[path.length - 1];
|
||||||
if (vm.startsWith("i-")) {
|
if (vm.startsWith("i-")) {
|
||||||
String[] dataFiles = _fs.listFiles(dir);
|
String[] dataFiles = _fs.listFiles(dir);
|
||||||
for (String dfile : dataFiles) {
|
for (String dfile : dataFiles) {
|
||||||
String path2[] = dfile.split("/");
|
String path2[] = dfile.split("/");
|
||||||
String ipv4file = path2[path2.length - 1];
|
String ipv4file = path2[path2.length - 1];
|
||||||
if (ipv4file.equalsIgnoreCase("local-ipv4")) {
|
if (ipv4file.equalsIgnoreCase("local-ipv4")) {
|
||||||
try {
|
try {
|
||||||
BufferedReader input = new BufferedReader(
|
BufferedReader input = new BufferedReader(
|
||||||
new FileReader(dfile));
|
new FileReader(dfile));
|
||||||
String line = null;
|
String line = null;
|
||||||
while ((line = input.readLine()) != null) {
|
while ((line = input.readLine()) != null) {
|
||||||
if (NetUtils.isValidIp(line)) {
|
if (NetUtils.isValidIp(line)) {
|
||||||
_ipVmMap.put(line, vm);
|
_ipVmMap.put(line, vm);
|
||||||
s_logger.info("Found ip " + line
|
s_logger.info("Found ip " + line
|
||||||
+ " for vm " + vm);
|
+ " for vm " + vm);
|
||||||
} else {
|
} else {
|
||||||
s_logger.info("Invalid ip " + line
|
s_logger.info("Invalid ip " + line
|
||||||
+ " for vm " + vm);
|
+ " for vm " + vm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
s_logger.warn("Failed to find file " + dfile);
|
s_logger.warn("Failed to find file " + dfile);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
s_logger.warn("Failed to get ip address of " + vm);
|
s_logger.warn("Failed to get ip address of " + vm);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getVmDataItem(String requester, String dataItem) {
|
public String getVmDataItem(String requester, String dataItem) {
|
||||||
String vmName = _ipVmMap.get(requester);
|
String vmName = _ipVmMap.get(requester);
|
||||||
if (vmName == null) {
|
if (vmName == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String vmDataFile = _vmDataDir + File.separator + vmName
|
String vmDataFile = _vmDataDir + File.separator + vmName
|
||||||
+ File.separator + dataItem;
|
+ File.separator + dataItem;
|
||||||
try {
|
try {
|
||||||
BufferedReader input = new BufferedReader(
|
BufferedReader input = new BufferedReader(
|
||||||
new FileReader(vmDataFile));
|
new FileReader(vmDataFile));
|
||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
String line = null;
|
String line = null;
|
||||||
while ((line = input.readLine()) != null) {
|
while ((line = input.readLine()) != null) {
|
||||||
result.append(line);
|
result.append(line);
|
||||||
}
|
}
|
||||||
input.close();
|
input.close();
|
||||||
return result.toString();
|
return result.toString();
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
s_logger.warn("Failed to find requested file " + vmDataFile);
|
s_logger.warn("Failed to find requested file " + vmDataFile);
|
||||||
return null;
|
return null;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
s_logger.warn("Failed to read requested file " + vmDataFile);
|
s_logger.warn("Failed to read requested file " + vmDataFile);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupJetty(int vmDataPort, int fileservingPort)
|
private void setupJetty(int vmDataPort, int fileservingPort)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
_jetty = new Server();
|
_jetty = new Server();
|
||||||
|
|
||||||
SelectChannelConnector connector0 = new SelectChannelConnector();
|
SelectChannelConnector connector0 = new SelectChannelConnector();
|
||||||
connector0.setHost(_hostIp);
|
connector0.setHost(_hostIp);
|
||||||
connector0.setPort(fileservingPort);
|
connector0.setPort(fileservingPort);
|
||||||
connector0.setMaxIdleTime(30000);
|
connector0.setMaxIdleTime(30000);
|
||||||
connector0.setRequestBufferSize(8192);
|
connector0.setRequestBufferSize(8192);
|
||||||
|
|
||||||
SelectChannelConnector connector1 = new SelectChannelConnector();
|
SelectChannelConnector connector1 = new SelectChannelConnector();
|
||||||
connector1.setHost(_hostIp);
|
connector1.setHost(_hostIp);
|
||||||
connector1.setPort(vmDataPort);
|
connector1.setPort(vmDataPort);
|
||||||
connector1.setThreadPool(new QueuedThreadPool(5));
|
connector1.setThreadPool(new QueuedThreadPool(5));
|
||||||
connector1.setMaxIdleTime(30000);
|
connector1.setMaxIdleTime(30000);
|
||||||
connector1.setRequestBufferSize(8192);
|
connector1.setRequestBufferSize(8192);
|
||||||
|
|
||||||
_jetty.setConnectors(new Connector[] { connector0, connector1 });
|
_jetty.setConnectors(new Connector[] { connector0, connector1 });
|
||||||
|
|
||||||
Context root = new Context(_jetty, "/latest", Context.SESSIONS);
|
Context root = new Context(_jetty, "/latest", Context.SESSIONS);
|
||||||
root.setResourceBase(_vmDataDir);
|
root.setResourceBase(_vmDataDir);
|
||||||
root.addServlet(new ServletHolder(new VmDataServlet(this, USER_DATA)),
|
root.addServlet(new ServletHolder(new VmDataServlet(this, USER_DATA)),
|
||||||
"/*");
|
"/*");
|
||||||
|
|
||||||
ResourceHandler resource_handler = new ResourceHandler();
|
ResourceHandler resource_handler = new ResourceHandler();
|
||||||
resource_handler.setResourceBase("/var/lib/images/");
|
resource_handler.setResourceBase("/var/lib/images/");
|
||||||
|
|
||||||
HandlerList handlers = new HandlerList();
|
HandlerList handlers = new HandlerList();
|
||||||
handlers.setHandlers(new Handler[] { root, resource_handler,
|
handlers.setHandlers(new Handler[] { root, resource_handler,
|
||||||
new DefaultHandler() });
|
new DefaultHandler() });
|
||||||
_jetty.setHandler(handlers);
|
_jetty.setHandler(handlers);
|
||||||
|
|
||||||
_jetty.start();
|
_jetty.start();
|
||||||
// _jetty.join();
|
// _jetty.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean start() {
|
public boolean start() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean stop() {
|
public boolean stop() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "JettyVmDataServer";
|
return "JettyVmDataServer";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Answer handleVmDataCommand(VmDataCommand cmd) {
|
public Answer handleVmDataCommand(VmDataCommand cmd) {
|
||||||
String vmDataDir = _vmDataDir + File.separator + cmd.getVmName();
|
String vmDataDir = _vmDataDir + File.separator + cmd.getVmName();
|
||||||
|
|
||||||
Script.runSimpleBashScript("rm -rf " + vmDataDir);
|
Script.runSimpleBashScript("rm -rf " + vmDataDir);
|
||||||
_fs.mkdirs(vmDataDir);
|
_fs.mkdirs(vmDataDir);
|
||||||
|
|
||||||
for (String[] item : cmd.getVmData()) {
|
for (String[] item : cmd.getVmData()) {
|
||||||
try {
|
try {
|
||||||
_fs.create(vmDataDir, item[1]);
|
_fs.create(vmDataDir, item[1]);
|
||||||
String vmDataFile = vmDataDir + File.separator + item[1];
|
String vmDataFile = vmDataDir + File.separator + item[1];
|
||||||
byte[] data;
|
byte[] data;
|
||||||
if (item[2] != null) {
|
if (item[2] != null) {
|
||||||
if (item[1].equals("user-data")) {
|
if (item[1].equals("user-data")) {
|
||||||
data = Base64.decodeBase64(item[2]);
|
data = Base64.decodeBase64(item[2]);
|
||||||
} else {
|
} else {
|
||||||
data = item[2].getBytes();
|
data = item[2].getBytes();
|
||||||
}
|
}
|
||||||
if (data != null && data.length > 0) {
|
if (data != null && data.length > 0) {
|
||||||
FileOutputStream writer = new FileOutputStream(
|
FileOutputStream writer = new FileOutputStream(
|
||||||
vmDataFile);
|
vmDataFile);
|
||||||
writer.write(data);
|
writer.write(data);
|
||||||
writer.close();
|
writer.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
s_logger.warn("Failed to write vm data item " + item[1], e);
|
s_logger.warn("Failed to write vm data item " + item[1], e);
|
||||||
return new Answer(cmd, false, "Failed to write vm data item "
|
return new Answer(cmd, false, "Failed to write vm data item "
|
||||||
+ item[1]);
|
+ item[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new Answer(cmd);
|
return new Answer(cmd);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleVmStarted(VirtualMachineTO vm) {
|
public void handleVmStarted(VirtualMachineTO vm) {
|
||||||
for (NicTO nic : vm.getNics()) {
|
for (NicTO nic : vm.getNics()) {
|
||||||
if (nic.getType() == TrafficType.Guest) {
|
if (nic.getType() == TrafficType.Guest) {
|
||||||
if (nic.getIp() != null) {
|
if (nic.getIp() != null) {
|
||||||
String ipv4File = _vmDataDir + File.separator
|
String ipv4File = _vmDataDir + File.separator
|
||||||
+ vm.getName() + File.separator + "local-ipv4";
|
+ vm.getName() + File.separator + "local-ipv4";
|
||||||
try {
|
try {
|
||||||
_fs.create(_vmDataDir + File.separator + vm.getName(),
|
_fs.create(_vmDataDir + File.separator + vm.getName(),
|
||||||
"local-ipv4");
|
"local-ipv4");
|
||||||
BufferedWriter writer = new BufferedWriter(
|
BufferedWriter writer = new BufferedWriter(
|
||||||
new FileWriter(ipv4File));
|
new FileWriter(ipv4File));
|
||||||
writer.write(nic.getIp());
|
writer.write(nic.getIp());
|
||||||
_ipVmMap.put(nic.getIp(), vm.getName());
|
_ipVmMap.put(nic.getIp(), vm.getName());
|
||||||
writer.close();
|
writer.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
s_logger.warn(
|
s_logger.warn(
|
||||||
"Failed to create or write to local-ipv4 file "
|
"Failed to create or write to local-ipv4 file "
|
||||||
+ ipv4File, e);
|
+ ipv4File, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleVmStopped(String vmName) {
|
public void handleVmStopped(String vmName) {
|
||||||
String vmDataDir = _vmDataDir + File.separator + vmName;
|
String vmDataDir = _vmDataDir + File.separator + vmName;
|
||||||
Script.runSimpleBashScript("rm -rf " + vmDataDir);
|
Script.runSimpleBashScript("rm -rf " + vmDataDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,9 +28,9 @@ import com.cloud.utils.component.Manager;
|
|||||||
*/
|
*/
|
||||||
public interface VmDataServer extends Manager {
|
public interface VmDataServer extends Manager {
|
||||||
|
|
||||||
public Answer handleVmDataCommand(VmDataCommand cmd);
|
public Answer handleVmDataCommand(VmDataCommand cmd);
|
||||||
|
|
||||||
public void handleVmStarted(VirtualMachineTO vm);
|
public void handleVmStarted(VirtualMachineTO vm);
|
||||||
|
|
||||||
public void handleVmStopped(String vmName);
|
public void handleVmStopped(String vmName);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,11 +31,11 @@ public class TestAgentShell extends Log4jEnabledTestCase {
|
|||||||
File file = null;
|
File file = null;
|
||||||
try {
|
try {
|
||||||
file = File.createTempFile("wget", ".html");
|
file = File.createTempFile("wget", ".html");
|
||||||
AgentShell.wget("http://www.google.com/", file);
|
AgentShell.wget("http://www.google.com/", file);
|
||||||
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("file saved to " + file.getAbsolutePath());
|
s_logger.debug("file saved to " + file.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
s_logger.warn("Exception while downloading agent update package, ", e);
|
s_logger.warn("Exception while downloading agent update package, ", e);
|
||||||
|
|||||||
@ -17,11 +17,13 @@
|
|||||||
package com.cloud.agent.api;
|
package com.cloud.agent.api;
|
||||||
|
|
||||||
import com.cloud.agent.api.to.VirtualMachineTO;
|
import com.cloud.agent.api.to.VirtualMachineTO;
|
||||||
|
import com.cloud.host.Host;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public class StartCommand extends Command {
|
public class StartCommand extends Command {
|
||||||
VirtualMachineTO vm;
|
VirtualMachineTO vm;
|
||||||
|
String hostIp;
|
||||||
|
|
||||||
public VirtualMachineTO getVirtualMachine() {
|
public VirtualMachineTO getVirtualMachine() {
|
||||||
return vm;
|
return vm;
|
||||||
@ -38,4 +40,13 @@ public class StartCommand extends Command {
|
|||||||
public StartCommand(VirtualMachineTO vm) {
|
public StartCommand(VirtualMachineTO vm) {
|
||||||
this.vm = vm;
|
this.vm = vm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public StartCommand(VirtualMachineTO vm, Host host) {
|
||||||
|
this.vm = vm;
|
||||||
|
this.hostIp = host.getPrivateIpAddress();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHostIp() {
|
||||||
|
return this.hostIp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,6 +40,7 @@ public class VirtualMachineTO {
|
|||||||
boolean enableHA;
|
boolean enableHA;
|
||||||
boolean limitCpuUse;
|
boolean limitCpuUse;
|
||||||
String vncPassword;
|
String vncPassword;
|
||||||
|
String vncAddr;
|
||||||
Map<String, String> params;
|
Map<String, String> params;
|
||||||
|
|
||||||
VolumeTO[] disks;
|
VolumeTO[] disks;
|
||||||
@ -192,6 +193,14 @@ public class VirtualMachineTO {
|
|||||||
this.vncPassword = vncPassword;
|
this.vncPassword = vncPassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getVncAddr() {
|
||||||
|
return this.vncAddr;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVncAddr(String vncAddr) {
|
||||||
|
this.vncAddr = vncAddr;
|
||||||
|
}
|
||||||
|
|
||||||
public Map<String, String> getDetails() {
|
public Map<String, String> getDetails() {
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -358,9 +358,12 @@ public class ApiConstants {
|
|||||||
public static final String VSM_DEVICE_STATE = "vsmdevicestate";
|
public static final String VSM_DEVICE_STATE = "vsmdevicestate";
|
||||||
public static final String ADD_VSM_FLAG = "addvsmflag";
|
public static final String ADD_VSM_FLAG = "addvsmflag";
|
||||||
public static final String END_POINT = "endpoint";
|
public static final String END_POINT = "endpoint";
|
||||||
//public static final String REGION_DETAILS = "regiondetails";
|
|
||||||
public static final String REGION_ID = "regionid";
|
public static final String REGION_ID = "regionid";
|
||||||
public static final String IS_PROPAGATE = "ispropagate";
|
public static final String IS_PROPAGATE = "ispropagate";
|
||||||
|
public static final String CAN_USE_FOR_DEPLOY = "canusefordeploy";
|
||||||
|
public static final String RESOURCE_IDS = "resourceids";
|
||||||
|
public static final String RESOURCE_ID = "resourceid";
|
||||||
|
public static final String CUSTOMER = "customer";
|
||||||
|
|
||||||
public enum HostDetails {
|
public enum HostDetails {
|
||||||
all, capacity, events, stats, min;
|
all, capacity, events, stats, min;
|
||||||
|
|||||||
@ -50,6 +50,7 @@ import com.cloud.projects.ProjectService;
|
|||||||
import com.cloud.region.RegionService;
|
import com.cloud.region.RegionService;
|
||||||
import com.cloud.resource.ResourceService;
|
import com.cloud.resource.ResourceService;
|
||||||
import com.cloud.server.ManagementService;
|
import com.cloud.server.ManagementService;
|
||||||
|
import com.cloud.server.TaggedResourceService;
|
||||||
import com.cloud.storage.StorageService;
|
import com.cloud.storage.StorageService;
|
||||||
import com.cloud.storage.snapshot.SnapshotService;
|
import com.cloud.storage.snapshot.SnapshotService;
|
||||||
import com.cloud.template.TemplateService;
|
import com.cloud.template.TemplateService;
|
||||||
@ -130,6 +131,7 @@ public abstract class BaseCmd {
|
|||||||
public static IdentityService _identityService;
|
public static IdentityService _identityService;
|
||||||
public static StorageNetworkService _storageNetworkService;
|
public static StorageNetworkService _storageNetworkService;
|
||||||
public static RegionService _regionService;
|
public static RegionService _regionService;
|
||||||
|
public static TaggedResourceService _taggedResourceService;
|
||||||
|
|
||||||
static void setComponents(ResponseGenerator generator) {
|
static void setComponents(ResponseGenerator generator) {
|
||||||
ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
|
ComponentLocator locator = ComponentLocator.getLocator(ManagementService.Name);
|
||||||
@ -158,6 +160,7 @@ public abstract class BaseCmd {
|
|||||||
_identityService = locator.getManager(IdentityService.class);
|
_identityService = locator.getManager(IdentityService.class);
|
||||||
_storageNetworkService = locator.getManager(StorageNetworkService.class);
|
_storageNetworkService = locator.getManager(StorageNetworkService.class);
|
||||||
_regionService = locator.getManager(RegionService.class);
|
_regionService = locator.getManager(RegionService.class);
|
||||||
|
_taggedResourceService = locator.getManager(TaggedResourceService.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException;
|
public abstract void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException;
|
||||||
|
|||||||
@ -57,6 +57,7 @@ import com.cloud.api.response.RegionResponse;
|
|||||||
import com.cloud.api.response.RemoteAccessVpnResponse;
|
import com.cloud.api.response.RemoteAccessVpnResponse;
|
||||||
import com.cloud.api.response.ResourceCountResponse;
|
import com.cloud.api.response.ResourceCountResponse;
|
||||||
import com.cloud.api.response.ResourceLimitResponse;
|
import com.cloud.api.response.ResourceLimitResponse;
|
||||||
|
import com.cloud.api.response.ResourceTagResponse;
|
||||||
import com.cloud.api.response.SecurityGroupResponse;
|
import com.cloud.api.response.SecurityGroupResponse;
|
||||||
import com.cloud.api.response.ServiceOfferingResponse;
|
import com.cloud.api.response.ServiceOfferingResponse;
|
||||||
import com.cloud.api.response.ServiceResponse;
|
import com.cloud.api.response.ServiceResponse;
|
||||||
@ -116,6 +117,7 @@ import com.cloud.org.Cluster;
|
|||||||
import com.cloud.projects.Project;
|
import com.cloud.projects.Project;
|
||||||
import com.cloud.projects.ProjectAccount;
|
import com.cloud.projects.ProjectAccount;
|
||||||
import com.cloud.projects.ProjectInvitation;
|
import com.cloud.projects.ProjectInvitation;
|
||||||
|
import com.cloud.server.ResourceTag;
|
||||||
import com.cloud.storage.Snapshot;
|
import com.cloud.storage.Snapshot;
|
||||||
import com.cloud.storage.StoragePool;
|
import com.cloud.storage.StoragePool;
|
||||||
import com.cloud.storage.Swift;
|
import com.cloud.storage.Swift;
|
||||||
@ -284,4 +286,12 @@ public interface ResponseGenerator {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Long getIdentiyId(String tableName, String token);
|
Long getIdentiyId(String tableName, String token);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param resourceTag
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
ResourceTagResponse createResourceTagResponse(ResourceTag resourceTag);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,8 +31,10 @@ import com.cloud.api.ServerApiException;
|
|||||||
import com.cloud.api.response.ClusterResponse;
|
import com.cloud.api.response.ClusterResponse;
|
||||||
import com.cloud.api.response.ListResponse;
|
import com.cloud.api.response.ListResponse;
|
||||||
import com.cloud.exception.DiscoveryException;
|
import com.cloud.exception.DiscoveryException;
|
||||||
|
import com.cloud.exception.ResourceInUseException;
|
||||||
import com.cloud.org.Cluster;
|
import com.cloud.org.Cluster;
|
||||||
import com.cloud.user.Account;
|
import com.cloud.user.Account;
|
||||||
|
import com.cloud.utils.IdentityProxy;
|
||||||
|
|
||||||
@Implementation(description="Adds a new cluster", responseObject=ClusterResponse.class)
|
@Implementation(description="Adds a new cluster", responseObject=ClusterResponse.class)
|
||||||
public class AddClusterCmd extends BaseCmd {
|
public class AddClusterCmd extends BaseCmd {
|
||||||
@ -167,6 +169,13 @@ public class AddClusterCmd extends BaseCmd {
|
|||||||
} catch (DiscoveryException ex) {
|
} catch (DiscoveryException ex) {
|
||||||
s_logger.warn("Exception: ", ex);
|
s_logger.warn("Exception: ", ex);
|
||||||
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
|
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
|
||||||
|
} catch (ResourceInUseException ex) {
|
||||||
|
s_logger.warn("Exception: ", ex);
|
||||||
|
ServerApiException e = new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
|
||||||
|
for (IdentityProxy proxyObj : ex.getIdProxyList()) {
|
||||||
|
e.addProxyObject(proxyObj.getTableName(), proxyObj.getValue(), proxyObj.getidFieldName());
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
136
api/src/com/cloud/api/commands/CreateTagsCmd.java
Normal file
136
api/src/com/cloud/api/commands/CreateTagsCmd.java
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
// 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.api.commands;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.cloud.api.ApiConstants;
|
||||||
|
import com.cloud.api.BaseAsyncCmd;
|
||||||
|
import com.cloud.api.BaseCmd;
|
||||||
|
import com.cloud.api.Implementation;
|
||||||
|
import com.cloud.api.Parameter;
|
||||||
|
import com.cloud.api.ServerApiException;
|
||||||
|
import com.cloud.api.response.SuccessResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
|
import com.cloud.server.ResourceTag;
|
||||||
|
import com.cloud.server.ResourceTag.TaggedResourceType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Alena Prokharchyk
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Implementation(description = "Creates resource tag(s)", responseObject = SuccessResponse.class, since = "Burbank")
|
||||||
|
public class CreateTagsCmd extends BaseAsyncCmd{
|
||||||
|
public static final Logger s_logger = Logger.getLogger(CreateTagsCmd.class.getName());
|
||||||
|
|
||||||
|
private static final String s_name = "createtagsresponse";
|
||||||
|
|
||||||
|
// ///////////////////////////////////////////////////
|
||||||
|
// ////////////// API parameters /////////////////////
|
||||||
|
// ///////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@Parameter(name = ApiConstants.TAGS, type = CommandType.MAP, required=true, description = "Map of tags (key/value pairs)")
|
||||||
|
private Map tag;
|
||||||
|
|
||||||
|
@Parameter(name=ApiConstants.RESOURCE_TYPE, type=CommandType.STRING, required=true, description="type of the resource")
|
||||||
|
private String resourceType;
|
||||||
|
|
||||||
|
@Parameter(name=ApiConstants.RESOURCE_IDS, type=CommandType.LIST, required=true,
|
||||||
|
collectionType=CommandType.STRING, description="list of resources to create the tags for")
|
||||||
|
private List<String> resourceIds;
|
||||||
|
|
||||||
|
@Parameter(name=ApiConstants.CUSTOMER, type=CommandType.STRING, description="identifies client specific tag. " +
|
||||||
|
"When the value is not null, the tag can't be used by cloudStack code internally")
|
||||||
|
private String customer;
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////
|
||||||
|
/////////////////// Accessors ///////////////////////
|
||||||
|
/////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
public TaggedResourceType getResourceType(){
|
||||||
|
return _taggedResourceService.getResourceType(resourceType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, String> getTags() {
|
||||||
|
Map<String, String> tagsMap = null;
|
||||||
|
if (!tag.isEmpty()) {
|
||||||
|
tagsMap = new HashMap<String, String>();
|
||||||
|
Collection<?> servicesCollection = tag.values();
|
||||||
|
Iterator<?> iter = servicesCollection.iterator();
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
HashMap<String, String> services = (HashMap<String, String>) iter.next();
|
||||||
|
String key = services.get("key");
|
||||||
|
String value = services.get("value");
|
||||||
|
tagsMap.put(key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tagsMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getResourceIds() {
|
||||||
|
return resourceIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCustomer() {
|
||||||
|
return customer;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ///////////////////////////////////////////////////
|
||||||
|
// ///////////// API Implementation///////////////////
|
||||||
|
// ///////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCommandName() {
|
||||||
|
return s_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getEntityOwnerId() {
|
||||||
|
//FIXME - validate the owner here
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
List<ResourceTag> tags = _taggedResourceService.createTags(getResourceIds(), getResourceType(), getTags(), getCustomer());
|
||||||
|
|
||||||
|
if (tags != null && !tags.isEmpty()) {
|
||||||
|
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||||
|
this.setResponseObject(response);
|
||||||
|
} else {
|
||||||
|
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create tags");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_TAGS_CREATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "creating tags";
|
||||||
|
}
|
||||||
|
}
|
||||||
128
api/src/com/cloud/api/commands/DeleteTagsCmd.java
Normal file
128
api/src/com/cloud/api/commands/DeleteTagsCmd.java
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
// 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.api.commands;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.cloud.api.ApiConstants;
|
||||||
|
import com.cloud.api.BaseAsyncCmd;
|
||||||
|
import com.cloud.api.BaseCmd;
|
||||||
|
import com.cloud.api.Implementation;
|
||||||
|
import com.cloud.api.Parameter;
|
||||||
|
import com.cloud.api.ServerApiException;
|
||||||
|
import com.cloud.api.response.SuccessResponse;
|
||||||
|
import com.cloud.event.EventTypes;
|
||||||
|
import com.cloud.server.ResourceTag;
|
||||||
|
import com.cloud.server.ResourceTag.TaggedResourceType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Alena Prokharchyk
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Implementation(description = "Deleting resource tag(s)", responseObject = SuccessResponse.class, since = "Burbank")
|
||||||
|
public class DeleteTagsCmd extends BaseAsyncCmd{
|
||||||
|
public static final Logger s_logger = Logger.getLogger(DeleteTagsCmd.class.getName());
|
||||||
|
|
||||||
|
private static final String s_name = "deleteTagsresponse";
|
||||||
|
|
||||||
|
// ///////////////////////////////////////////////////
|
||||||
|
// ////////////// API parameters /////////////////////
|
||||||
|
// ///////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@Parameter(name = ApiConstants.TAGS, type = CommandType.MAP, description = "Delete tags matching key/value pairs")
|
||||||
|
private Map tag;
|
||||||
|
|
||||||
|
@Parameter(name=ApiConstants.RESOURCE_TYPE, type=CommandType.STRING, required=true, description="Delete tag by resource type")
|
||||||
|
private String resourceType;
|
||||||
|
|
||||||
|
@Parameter(name=ApiConstants.RESOURCE_IDS, type=CommandType.LIST, required=true,
|
||||||
|
collectionType=CommandType.STRING, description="Delete tags for resource id(s)")
|
||||||
|
private List<String> resourceIds;
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////
|
||||||
|
/////////////////// Accessors ///////////////////////
|
||||||
|
/////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
public TaggedResourceType getResourceType(){
|
||||||
|
return _taggedResourceService.getResourceType(resourceType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, String> getTags() {
|
||||||
|
Map<String, String> tagsMap = null;
|
||||||
|
if (tag != null && !tag.isEmpty()) {
|
||||||
|
tagsMap = new HashMap<String, String>();
|
||||||
|
Collection<?> servicesCollection = tag.values();
|
||||||
|
Iterator<?> iter = servicesCollection.iterator();
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
HashMap<String, String> services = (HashMap<String, String>) iter.next();
|
||||||
|
String key = services.get("key");
|
||||||
|
String value = services.get("value");
|
||||||
|
tagsMap.put(key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tagsMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getResourceIds() {
|
||||||
|
return resourceIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ///////////////////////////////////////////////////
|
||||||
|
// ///////////// API Implementation///////////////////
|
||||||
|
// ///////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCommandName() {
|
||||||
|
return s_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getEntityOwnerId() {
|
||||||
|
//FIXME - validate the owner here
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
boolean success = _taggedResourceService.deleteTags(getResourceIds(), getResourceType(), getTags());
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||||
|
this.setResponseObject(response);
|
||||||
|
} else {
|
||||||
|
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete tags");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventType() {
|
||||||
|
return EventTypes.EVENT_TAGS_DELETE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getEventDescription() {
|
||||||
|
return "Deleting tags";
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -20,6 +20,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -252,9 +253,9 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
|
|||||||
if ((networkIds != null || ipAddress != null) && ipToNetworkList != null) {
|
if ((networkIds != null || ipAddress != null) && ipToNetworkList != null) {
|
||||||
throw new InvalidParameterValueException("NetworkIds and ipAddress can't be specified along with ipToNetworkMap parameter");
|
throw new InvalidParameterValueException("NetworkIds and ipAddress can't be specified along with ipToNetworkMap parameter");
|
||||||
}
|
}
|
||||||
Map<Long, String> ipToNetworkMap = null;
|
LinkedHashMap<Long, String> ipToNetworkMap = null;
|
||||||
if (ipToNetworkList != null && !ipToNetworkList.isEmpty()) {
|
if (ipToNetworkList != null && !ipToNetworkList.isEmpty()) {
|
||||||
ipToNetworkMap = new HashMap<Long, String>();
|
ipToNetworkMap = new LinkedHashMap<Long, String>();
|
||||||
Collection ipsCollection = ipToNetworkList.values();
|
Collection ipsCollection = ipToNetworkList.values();
|
||||||
Iterator iter = ipsCollection.iterator();
|
Iterator iter = ipsCollection.iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
|
|||||||
@ -63,15 +63,18 @@ public class ListNetworksCmd extends BaseListProjectAndAccountResourcesCmd {
|
|||||||
@Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.LONG, description="list networks by physical network id")
|
@Parameter(name=ApiConstants.PHYSICAL_NETWORK_ID, type=CommandType.LONG, description="list networks by physical network id")
|
||||||
private Long physicalNetworkId;
|
private Long physicalNetworkId;
|
||||||
|
|
||||||
@Parameter(name=ApiConstants.SUPPORTED_SERVICES, type=CommandType.LIST, collectionType=CommandType.STRING, description="list network offerings supporting certain services")
|
@Parameter(name=ApiConstants.SUPPORTED_SERVICES, type=CommandType.LIST, collectionType=CommandType.STRING, description="list networks supporting certain services")
|
||||||
private List<String> supportedServices;
|
private List<String> supportedServices;
|
||||||
|
|
||||||
@Parameter(name=ApiConstants.RESTART_REQUIRED, type=CommandType.BOOLEAN, description="list network offerings by restartRequired option")
|
@Parameter(name=ApiConstants.RESTART_REQUIRED, type=CommandType.BOOLEAN, description="list networks by restartRequired option")
|
||||||
private Boolean restartRequired;
|
private Boolean restartRequired;
|
||||||
|
|
||||||
@Parameter(name=ApiConstants.SPECIFY_IP_RANGES, type=CommandType.BOOLEAN, description="true if need to list only networks which support specifying ip ranges")
|
@Parameter(name=ApiConstants.SPECIFY_IP_RANGES, type=CommandType.BOOLEAN, description="true if need to list only networks which support specifying ip ranges")
|
||||||
private Boolean specifyIpRanges;
|
private Boolean specifyIpRanges;
|
||||||
|
|
||||||
|
@Parameter(name=ApiConstants.CAN_USE_FOR_DEPLOY, type=CommandType.BOOLEAN, description="list networks available for vm deployment")
|
||||||
|
private Boolean canUseForDeploy;
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
/////////////////// Accessors ///////////////////////
|
/////////////////// Accessors ///////////////////////
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
@ -116,7 +119,11 @@ public class ListNetworksCmd extends BaseListProjectAndAccountResourcesCmd {
|
|||||||
return specifyIpRanges;
|
return specifyIpRanges;
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
public Boolean canUseForDeploy() {
|
||||||
|
return canUseForDeploy;
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////
|
||||||
/////////////// API Implementation///////////////////
|
/////////////// API Implementation///////////////////
|
||||||
/////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
99
api/src/com/cloud/api/commands/ListTagsCmd.java
Normal file
99
api/src/com/cloud/api/commands/ListTagsCmd.java
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
// 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.api.commands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.cloud.api.ApiConstants;
|
||||||
|
import com.cloud.api.BaseListProjectAndAccountResourcesCmd;
|
||||||
|
import com.cloud.api.Implementation;
|
||||||
|
import com.cloud.api.Parameter;
|
||||||
|
import com.cloud.api.response.ListResponse;
|
||||||
|
import com.cloud.api.response.ResourceTagResponse;
|
||||||
|
import com.cloud.server.ResourceTag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Alena Prokharchyk
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Implementation(description = "List resource tag(s)", responseObject = ResourceTagResponse.class, since = "Burbank")
|
||||||
|
public class ListTagsCmd extends BaseListProjectAndAccountResourcesCmd{
|
||||||
|
private static final String s_name = "listtagsresponse";
|
||||||
|
|
||||||
|
@Parameter(name=ApiConstants.RESOURCE_TYPE, type=CommandType.STRING, description="list by resource type")
|
||||||
|
private String resourceType;
|
||||||
|
|
||||||
|
@Parameter(name=ApiConstants.RESOURCE_ID, type=CommandType.STRING, description="list by resource id")
|
||||||
|
private String resourceId;
|
||||||
|
|
||||||
|
@Parameter(name=ApiConstants.KEY, type=CommandType.STRING, description="list by key")
|
||||||
|
private String key;
|
||||||
|
|
||||||
|
@Parameter(name=ApiConstants.VALUE, type=CommandType.STRING, description="list by value")
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
@Parameter(name=ApiConstants.CUSTOMER, type=CommandType.STRING, description="list by customer name")
|
||||||
|
private String customer;
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////
|
||||||
|
/////////////////// Accessors ///////////////////////
|
||||||
|
/////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
|
||||||
|
List<? extends ResourceTag> tags = _taggedResourceService.listTags(this);
|
||||||
|
ListResponse<ResourceTagResponse> response = new ListResponse<ResourceTagResponse>();
|
||||||
|
List<ResourceTagResponse> tagResponses = new ArrayList<ResourceTagResponse>();
|
||||||
|
for (ResourceTag tag : tags) {
|
||||||
|
ResourceTagResponse tagResponse = _responseGenerator.createResourceTagResponse(tag);
|
||||||
|
tagResponses.add(tagResponse);
|
||||||
|
}
|
||||||
|
response.setResponses(tagResponses);
|
||||||
|
|
||||||
|
response.setResponseName(getCommandName());
|
||||||
|
this.setResponseObject(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getResourceType() {
|
||||||
|
return resourceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getResourceId() {
|
||||||
|
return resourceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getCommandName() {
|
||||||
|
return s_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCustomer() {
|
||||||
|
return customer;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -14,23 +14,6 @@
|
|||||||
// KIND, either express or implied. See the License for the
|
// KIND, either express or implied. See the License for the
|
||||||
// specific language governing permissions and limitations
|
// specific language governing permissions and limitations
|
||||||
// under the License.
|
// under the License.
|
||||||
/**
|
|
||||||
* Copyright (C) 2012 Citrix Systems, Inc. All rights reserved.
|
|
||||||
*
|
|
||||||
* This software is licensed under the GNU General Public License v3 or later.
|
|
||||||
*
|
|
||||||
* It is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or any later version.
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package com.cloud.api.commands;
|
package com.cloud.api.commands;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|||||||
@ -131,6 +131,9 @@ public class NetworkResponse extends BaseResponse implements ControlledEntityRes
|
|||||||
@SerializedName(ApiConstants.SPECIFY_IP_RANGES) @Param(description="true if network supports specifying ip ranges, false otherwise")
|
@SerializedName(ApiConstants.SPECIFY_IP_RANGES) @Param(description="true if network supports specifying ip ranges, false otherwise")
|
||||||
private Boolean specifyIpRanges;
|
private Boolean specifyIpRanges;
|
||||||
|
|
||||||
|
@SerializedName(ApiConstants.CAN_USE_FOR_DEPLOY) @Param(description="list networks available for vm deployment")
|
||||||
|
private Boolean canUseForDeploy;
|
||||||
|
|
||||||
public void setId(Long id) {
|
public void setId(Long id) {
|
||||||
this.id.setValue(id);
|
this.id.setValue(id);
|
||||||
}
|
}
|
||||||
@ -272,4 +275,8 @@ public class NetworkResponse extends BaseResponse implements ControlledEntityRes
|
|||||||
public void setSpecifyIpRanges(Boolean specifyIpRanges) {
|
public void setSpecifyIpRanges(Boolean specifyIpRanges) {
|
||||||
this.specifyIpRanges = specifyIpRanges;
|
this.specifyIpRanges = specifyIpRanges;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCanUseForDeploy(Boolean canUseForDeploy) {
|
||||||
|
this.canUseForDeploy = canUseForDeploy;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
104
api/src/com/cloud/api/response/ResourceTagResponse.java
Normal file
104
api/src/com/cloud/api/response/ResourceTagResponse.java
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
// 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.api.response;
|
||||||
|
|
||||||
|
import com.cloud.api.ApiConstants;
|
||||||
|
import com.cloud.serializer.Param;
|
||||||
|
import com.cloud.utils.IdentityProxy;
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Alena Prokharchyk
|
||||||
|
*/
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public class ResourceTagResponse extends BaseResponse implements ControlledEntityResponse{
|
||||||
|
@SerializedName(ApiConstants.KEY) @Param(description="tag key name")
|
||||||
|
private String key;
|
||||||
|
|
||||||
|
@SerializedName(ApiConstants.VALUE) @Param(description="tag value")
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
@SerializedName(ApiConstants.RESOURCE_TYPE) @Param(description="resource type")
|
||||||
|
private String resourceType;
|
||||||
|
|
||||||
|
@SerializedName(ApiConstants.RESOURCE_ID) @Param(description="id of the resource")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@SerializedName(ApiConstants.ACCOUNT)
|
||||||
|
@Param(description = "the account associated with the tag")
|
||||||
|
private String accountName;
|
||||||
|
|
||||||
|
@SerializedName(ApiConstants.PROJECT_ID) @Param(description="the project id the tag belongs to")
|
||||||
|
private IdentityProxy projectId = new IdentityProxy("projects");
|
||||||
|
|
||||||
|
@SerializedName(ApiConstants.PROJECT) @Param(description="the project name where tag belongs to")
|
||||||
|
private String projectName;
|
||||||
|
|
||||||
|
@SerializedName(ApiConstants.DOMAIN_ID)
|
||||||
|
@Param(description = "the ID of the domain associated with the tag")
|
||||||
|
private IdentityProxy domainId = new IdentityProxy("domain");
|
||||||
|
|
||||||
|
@SerializedName(ApiConstants.DOMAIN)
|
||||||
|
@Param(description = "the domain associated with the tag")
|
||||||
|
private String domainName;
|
||||||
|
|
||||||
|
@SerializedName(ApiConstants.CUSTOMER) @Param(description="customer associated with the tag")
|
||||||
|
private String customer;
|
||||||
|
|
||||||
|
public void setKey(String key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResourceType(String resourceType) {
|
||||||
|
this.resourceType = resourceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(String id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccountName(String accountName) {
|
||||||
|
this.accountName = accountName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDomainId(Long domainId) {
|
||||||
|
this.domainId.setValue(domainId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDomainName(String domainName) {
|
||||||
|
this.domainName = domainName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setProjectId(Long projectId) {
|
||||||
|
this.projectId.setValue(projectId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setProjectName(String projectName) {
|
||||||
|
this.projectName = projectName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCustomer(String customer) {
|
||||||
|
this.customer = customer;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -259,4 +259,9 @@ public class EventTypes {
|
|||||||
public static final String EVENT_EXTERNAL_FIREWALL_DEVICE_ADD = "PHYSICAL.FIREWALL.ADD";
|
public static final String EVENT_EXTERNAL_FIREWALL_DEVICE_ADD = "PHYSICAL.FIREWALL.ADD";
|
||||||
public static final String EVENT_EXTERNAL_FIREWALL_DEVICE_DELETE = "PHYSICAL.FIREWALL.DELETE";
|
public static final String EVENT_EXTERNAL_FIREWALL_DEVICE_DELETE = "PHYSICAL.FIREWALL.DELETE";
|
||||||
public static final String EVENT_EXTERNAL_FIREWALL_DEVICE_CONFIGURE = "PHYSICAL.FIREWALL.CONFIGURE";
|
public static final String EVENT_EXTERNAL_FIREWALL_DEVICE_CONFIGURE = "PHYSICAL.FIREWALL.CONFIGURE";
|
||||||
|
|
||||||
|
// tag related events
|
||||||
|
public static final String EVENT_TAGS_CREATE = "CREATE_TAGS";
|
||||||
|
public static final String EVENT_TAGS_DELETE = "DELETE_TAGS";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -134,4 +134,10 @@ public interface NetworkService {
|
|||||||
|
|
||||||
List<? extends Network> getIsolatedNetworksWithSourceNATOwnedByAccountInZone(long zoneId, Account owner);
|
List<? extends Network> getIsolatedNetworksWithSourceNATOwnedByAccountInZone(long zoneId, Account owner);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param network
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean canUseForDeploy(Network network);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,6 +31,7 @@ import com.cloud.api.commands.UpdateHostCmd;
|
|||||||
import com.cloud.api.commands.UpdateHostPasswordCmd;
|
import com.cloud.api.commands.UpdateHostPasswordCmd;
|
||||||
import com.cloud.exception.DiscoveryException;
|
import com.cloud.exception.DiscoveryException;
|
||||||
import com.cloud.exception.InvalidParameterValueException;
|
import com.cloud.exception.InvalidParameterValueException;
|
||||||
|
import com.cloud.exception.ResourceInUseException;
|
||||||
import com.cloud.host.Host;
|
import com.cloud.host.Host;
|
||||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||||
import com.cloud.org.Cluster;
|
import com.cloud.org.Cluster;
|
||||||
@ -61,7 +62,7 @@ public interface ResourceService {
|
|||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
* @throws DiscoveryException
|
* @throws DiscoveryException
|
||||||
*/
|
*/
|
||||||
List<? extends Cluster> discoverCluster(AddClusterCmd cmd) throws IllegalArgumentException, DiscoveryException;
|
List<? extends Cluster> discoverCluster(AddClusterCmd cmd) throws IllegalArgumentException, DiscoveryException, ResourceInUseException;
|
||||||
|
|
||||||
boolean deleteCluster(DeleteClusterCmd cmd);
|
boolean deleteCluster(DeleteClusterCmd cmd);
|
||||||
|
|
||||||
|
|||||||
67
api/src/com/cloud/server/ResourceTag.java
Normal file
67
api/src/com/cloud/server/ResourceTag.java
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
// 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.server;
|
||||||
|
|
||||||
|
import com.cloud.acl.ControlledEntity;
|
||||||
|
|
||||||
|
public interface ResourceTag extends ControlledEntity{
|
||||||
|
|
||||||
|
public enum TaggedResourceType {
|
||||||
|
UserVm,
|
||||||
|
Template,
|
||||||
|
ISO,
|
||||||
|
Volume,
|
||||||
|
Snapshot,
|
||||||
|
Network,
|
||||||
|
LoadBalancer,
|
||||||
|
PortForwardingRule,
|
||||||
|
FirewallRule,
|
||||||
|
SecurityGroup,
|
||||||
|
PublicIpAddress
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
long getId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String getKey();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String getValue();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
long getResourceId();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
TaggedResourceType getResourceType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String getCustomer();
|
||||||
|
|
||||||
|
}
|
||||||
63
api/src/com/cloud/server/TaggedResourceService.java
Normal file
63
api/src/com/cloud/server/TaggedResourceService.java
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
// 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.server;
|
||||||
|
|
||||||
|
package com.cloud.server;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.cloud.api.commands.ListTagsCmd;
|
||||||
|
import com.cloud.server.ResourceTag.TaggedResourceType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Alena Prokharchyk
|
||||||
|
*/
|
||||||
|
public interface TaggedResourceService {
|
||||||
|
|
||||||
|
TaggedResourceType getResourceType (String resourceTypeStr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param resourceIds TODO
|
||||||
|
* @param resourceType
|
||||||
|
* @param tags
|
||||||
|
* @param customer TODO
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<ResourceTag> createTags(List<String> resourceIds, TaggedResourceType resourceType, Map<String, String> tags, String customer);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param resourceId
|
||||||
|
* @param resourceType
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String getUuid(String resourceId, TaggedResourceType resourceType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param listTagsCmd
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<? extends ResourceTag> listTags(ListTagsCmd listTagsCmd);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param resourceIds
|
||||||
|
* @param resourceType
|
||||||
|
* @param tags
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean deleteTags(List<String> resourceIds, TaggedResourceType resourceType, Map<String, String> tags);
|
||||||
|
}
|
||||||
@ -1,3 +1,21 @@
|
|||||||
|
-- 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.
|
||||||
|
|
||||||
|
|
||||||
USE cloudbridge;
|
USE cloudbridge;
|
||||||
|
|
||||||
-- This file (and cloudbridge_policy_alter.sql) can be applied to an existing cloudbridge
|
-- This file (and cloudbridge_policy_alter.sql) can be applied to an existing cloudbridge
|
||||||
|
|||||||
@ -1,3 +1,21 @@
|
|||||||
|
-- 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.
|
||||||
|
|
||||||
|
|
||||||
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ANSI';
|
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ANSI';
|
||||||
|
|
||||||
DROP DATABASE IF EXISTS cloudbridge;
|
DROP DATABASE IF EXISTS cloudbridge;
|
||||||
|
|||||||
@ -1,3 +1,20 @@
|
|||||||
|
-- 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.
|
||||||
|
|
||||||
USE cloudbridge;
|
USE cloudbridge;
|
||||||
|
|
||||||
ALTER TABLE shost ADD UNIQUE shost_uq_host(Host, HostType, ExportRoot);
|
ALTER TABLE shost ADD UNIQUE shost_uq_host(Host, HostType, ExportRoot);
|
||||||
|
|||||||
@ -1,3 +1,20 @@
|
|||||||
|
-- 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.
|
||||||
|
|
||||||
USE cloudbridge;
|
USE cloudbridge;
|
||||||
|
|
||||||
-- This file can be applied to an existing cloudbridge database. It is used
|
-- This file can be applied to an existing cloudbridge database. It is used
|
||||||
|
|||||||
@ -1,3 +1,21 @@
|
|||||||
|
-- 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.
|
||||||
|
|
||||||
|
|
||||||
USE cloudbridge;
|
USE cloudbridge;
|
||||||
|
|
||||||
ALTER TABLE multipart_meta ADD CONSTRAINT FOREIGN KEY meta_uploads_id(UploadID) REFERENCES multipart_uploads(ID) ON DELETE CASCADE;
|
ALTER TABLE multipart_meta ADD CONSTRAINT FOREIGN KEY meta_uploads_id(UploadID) REFERENCES multipart_uploads(ID) ON DELETE CASCADE;
|
||||||
|
|||||||
@ -1,3 +1,21 @@
|
|||||||
|
-- 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.
|
||||||
|
|
||||||
|
|
||||||
USE cloudbridge;
|
USE cloudbridge;
|
||||||
|
|
||||||
-- This file (and cloudbridge_offering_alter.sql) can be applied to an existing cloudbridge
|
-- This file (and cloudbridge_offering_alter.sql) can be applied to an existing cloudbridge
|
||||||
|
|||||||
@ -1,3 +1,21 @@
|
|||||||
|
-- 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.
|
||||||
|
|
||||||
|
|
||||||
USE cloudbridge;
|
USE cloudbridge;
|
||||||
|
|
||||||
ALTER TABLE offering_bundle ADD UNIQUE one_offering (AmazonEC2Offering);
|
ALTER TABLE offering_bundle ADD UNIQUE one_offering (AmazonEC2Offering);
|
||||||
|
|||||||
@ -1,3 +1,21 @@
|
|||||||
|
-- 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.
|
||||||
|
|
||||||
|
|
||||||
USE cloudbridge;
|
USE cloudbridge;
|
||||||
|
|
||||||
ALTER TABLE bucket_policies ADD UNIQUE one_policy_per_bucket(BucketName);
|
ALTER TABLE bucket_policies ADD UNIQUE one_policy_per_bucket(BucketName);
|
||||||
|
|||||||
@ -1,3 +1,21 @@
|
|||||||
|
-- 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.
|
||||||
|
|
||||||
|
|
||||||
USE cloudbridge;
|
USE cloudbridge;
|
||||||
|
|
||||||
SET foreign_key_checks = 0;
|
SET foreign_key_checks = 0;
|
||||||
|
|||||||
@ -1,7 +1,20 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# deploy-db-bridge.sh -- deploys the cloudbridge database configuration.
|
# 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
|
||||||
#
|
#
|
||||||
# set -x
|
# 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.
|
||||||
|
|
||||||
if [ ! -f cloudbridge_db.sql ]; then
|
if [ ! -f cloudbridge_db.sql ]; then
|
||||||
printf "Error: Unable to find cloudbridge_db.sql\n"
|
printf "Error: Unable to find cloudbridge_db.sql\n"
|
||||||
|
|||||||
@ -1,4 +1,20 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
# 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.
|
||||||
#
|
#
|
||||||
# /etc/init.d/tomcat6 -- startup script for the Tomcat 6 servlet engine
|
# /etc/init.d/tomcat6 -- startup script for the Tomcat 6 servlet engine
|
||||||
#
|
#
|
||||||
|
|||||||
@ -1,5 +1,22 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
# tomcat6 This shell script takes care of starting and stopping Tomcat
|
# tomcat6 This shell script takes care of starting and stopping Tomcat
|
||||||
#
|
#
|
||||||
# chkconfig: - 80 20
|
# chkconfig: - 80 20
|
||||||
|
|||||||
@ -1,5 +1,22 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
# Cloud.com Bridge setup script.
|
# Cloud.com Bridge setup script.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,21 @@
|
|||||||
#!/cygdrive/c/python26/python
|
#!/cygdrive/c/python26/python
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
import hmac
|
import hmac
|
||||||
|
|||||||
@ -1,6 +1,20 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# deploy.sh -- deploys a cloud-bridge
|
# 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.
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
printf "Usage: %s: -d [tomcat directory to deploy to] -z [zip file to use]\n" $(basename $0) >&2
|
printf "Usage: %s: -d [tomcat directory to deploy to] -z [zip file to use]\n" $(basename $0) >&2
|
||||||
|
|||||||
@ -1,4 +1,20 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
# 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.
|
||||||
|
|
||||||
# install.sh -- deploys cloud-bridge and the corresponding DB
|
# install.sh -- deploys cloud-bridge and the corresponding DB
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,19 @@
|
|||||||
|
# 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.
|
||||||
CP=.
|
CP=.
|
||||||
for file in lib/*.jar
|
for file in lib/*.jar
|
||||||
do
|
do
|
||||||
|
|||||||
@ -1,3 +1,19 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ActivateLicense.java
|
* ActivateLicense.java
|
||||||
|
|||||||
@ -1,3 +1,19 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ActivateLicenseResponse.java
|
* ActivateLicenseResponse.java
|
||||||
|
|||||||
@ -1,3 +1,19 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ActivateLicenseResponseType.java
|
* ActivateLicenseResponseType.java
|
||||||
|
|||||||
@ -1,3 +1,19 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ActivateLicenseType.java
|
* ActivateLicenseType.java
|
||||||
|
|||||||
@ -1,3 +1,19 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AllocateAddress.java
|
* AllocateAddress.java
|
||||||
|
|||||||
@ -1,3 +1,19 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AllocateAddressResponse.java
|
* AllocateAddressResponse.java
|
||||||
|
|||||||
@ -1,3 +1,19 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AllocateAddressResponseType.java
|
* AllocateAddressResponseType.java
|
||||||
|
|||||||
@ -1,3 +1,19 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AllocateAddressType.java
|
* AllocateAddressType.java
|
||||||
|
|||||||
@ -1,3 +1,19 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AmazonEC2MessageReceiverInOut.java
|
* AmazonEC2MessageReceiverInOut.java
|
||||||
|
|||||||
@ -1,3 +1,19 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AmazonEC2Skeleton.java
|
* AmazonEC2Skeleton.java
|
||||||
|
|||||||
@ -1,3 +1,19 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AmazonEC2SkeletonInterface.java
|
* AmazonEC2SkeletonInterface.java
|
||||||
|
|||||||
@ -1,3 +1,19 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AssociateAddress.java
|
* AssociateAddress.java
|
||||||
|
|||||||
@ -1,3 +1,19 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AssociateAddressResponse.java
|
* AssociateAddressResponse.java
|
||||||
|
|||||||
@ -1,3 +1,19 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AssociateAddressResponseType.java
|
* AssociateAddressResponseType.java
|
||||||
|
|||||||
@ -1,3 +1,19 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AssociateAddressType.java
|
* AssociateAddressType.java
|
||||||
|
|||||||
@ -1,3 +1,19 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AssociateDhcpOptions.java
|
* AssociateDhcpOptions.java
|
||||||
|
|||||||
@ -1,3 +1,19 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AssociateDhcpOptionsResponse.java
|
* AssociateDhcpOptionsResponse.java
|
||||||
|
|||||||
@ -1,3 +1,19 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AssociateDhcpOptionsResponseType.java
|
* AssociateDhcpOptionsResponseType.java
|
||||||
|
|||||||
@ -1,3 +1,19 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AssociateDhcpOptionsType.java
|
* AssociateDhcpOptionsType.java
|
||||||
|
|||||||
@ -1,3 +1,19 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AttachVolume.java
|
* AttachVolume.java
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user