mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Merge branch 'master' into rbac.
This commit is contained in:
commit
2ef4d5200c
39
INSTALL.md
39
INSTALL.md
@ -96,25 +96,22 @@ Clean and build:
|
||||
|
||||
$ mvn clean install -P systemvm,developer
|
||||
|
||||
In case you want support for VMWare, SRX and other non-Apache (referred to as nonoss)
|
||||
compliant libs, you may download the following jar artifacts from respective vendors:
|
||||
CloudStack supports several plugins that depend on libraries with distribution restrictions.
|
||||
Because of this they are not included in the default build. Enable these additional plugins
|
||||
activate their respective profiles. For convenience adding -Dnoredist will enable all plugins
|
||||
that depend on libraries with distribution restrictions. The build procedure expects that the
|
||||
required libraries are present in the maven repository.
|
||||
|
||||
deps/cloud-iControl.jar
|
||||
deps/cloud-manageontap.jar
|
||||
deps/cloud-netscaler-sdx.jar
|
||||
deps/cloud-netscaler.jar
|
||||
deps/vmware-apputils.jar
|
||||
deps/vmware-vim.jar
|
||||
deps/vmware-vim25.jar
|
||||
|
||||
Install them to ~/.m2 so maven can get them as dependencies:
|
||||
The following procedure can be used to add the libraries to the local maven repository. Details
|
||||
on obtaining the required libraries can be found in this file. Note that this will vary between
|
||||
releases of cloudstack
|
||||
|
||||
$ cd deps
|
||||
$ ./install-non-oss.sh
|
||||
|
||||
To build with nonoss components, use the build command with the nonoss flag:
|
||||
To build all non redistributable components, add the noredist flag to the build command:
|
||||
|
||||
$ mvn clean install -P systemvm,developer -Dnonoss
|
||||
$ mvn clean install -P systemvm,developer -Dnoredist
|
||||
|
||||
Clear old database (if any) and deploy the database schema:
|
||||
|
||||
@ -153,7 +150,7 @@ This section describes packaging and installation.
|
||||
|
||||
To create debs:
|
||||
|
||||
$ mvn -P deps # -D nonoss, for nonoss as described in the "Building" section above
|
||||
$ mvn -P deps # -D noredist, for noredist as described in the "Building" section above
|
||||
$ dpkg-buildpackage
|
||||
|
||||
All the deb packages will be created in ../$PWD
|
||||
@ -183,15 +180,15 @@ Install needed packages, apt-get upgrade for upgrading:
|
||||
|
||||
To create rpms:
|
||||
|
||||
$ mvn -P deps # -D nonoss, for nonoss as described in the "Building" section above
|
||||
$ ./waf rpm
|
||||
$ cd packaging/centos63
|
||||
$ bash packaging.sh [ -p NOREDIST ]
|
||||
|
||||
All the rpm packages will be create in artifacts/rpmbuild/RPMS/x86_64
|
||||
All the rpm packages will be create in dist/rpmbuild/RPMS/x86_64
|
||||
|
||||
To create a yum repo: (assuming appropriate user privileges)
|
||||
|
||||
$ path=/path/to/your/webserver/cloudstack
|
||||
$ cd artifacts/rpmbuild/RPMS/x86_64
|
||||
$ cd dist/rpmbuild/RPMS/x86_64
|
||||
$ mv *.rpm $path
|
||||
$ createrepo $path
|
||||
|
||||
@ -208,10 +205,10 @@ Installation:
|
||||
Install needed packages:
|
||||
|
||||
$ yum update
|
||||
$ yum install cloud-client # management server
|
||||
$ yum install cloudstack-management # management server
|
||||
$ yum install mysql-server # mysql server
|
||||
$ yum install cloud-agent # agent (kvm)
|
||||
$ yum install cloud-usage # usage server
|
||||
$ yum install cloudstack-agent # agent (kvm)
|
||||
$ yum install cloudstack-usage # usage server
|
||||
|
||||
## Installing CloudMonkey CLI
|
||||
|
||||
|
||||
63
agent/bindir/cloudstack-agent-upgrade.in
Normal file
63
agent/bindir/cloudstack-agent-upgrade.in
Normal file
@ -0,0 +1,63 @@
|
||||
#!/usr/bin/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.
|
||||
from cloudutils.networkConfig import networkConfig
|
||||
from cloudutils.utilities import bash
|
||||
import logging
|
||||
import re
|
||||
def isOldStyleBridge(brName):
|
||||
if brName.find("cloudVirBr") == 0:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
def upgradeBridgeName(brName, enslavedDev):
|
||||
print("upgrade bridge: %s, %s"%(brName, enslavedDev))
|
||||
vlanId = brName.replace("cloudVirBr", "")
|
||||
print("find vlan Id: %s"%vlanId)
|
||||
phyDev = enslavedDev.split(".")[0]
|
||||
print("find physical device %s"%phyDev)
|
||||
newBrName = "br" + phyDev + "-" + vlanId
|
||||
print("new bridge name %s"%newBrName)
|
||||
bash("ip link set %s down"%brName)
|
||||
bash("ip link set %s name %s"%(brName, newBrName))
|
||||
bash("ip link set %s up" %newBrName)
|
||||
cmd = "iptables-save | grep FORWARD | grep -w " + brName
|
||||
rules = bash(cmd).stdout.split('\n')
|
||||
rules.pop()
|
||||
for rule in rules:
|
||||
try:
|
||||
delrule = re.sub("-A", "-D", rule)
|
||||
newrule = re.sub(" " + brName + " ", " " + newBrName + " ", rule)
|
||||
bash("iptables " + delrule)
|
||||
bash("iptables " + newrule)
|
||||
except:
|
||||
logging.exception("Ignoring failure to update rules for rule " + rule + " on bridge " + brName)
|
||||
if __name__ == '__main__':
|
||||
netlib = networkConfig()
|
||||
bridges = netlib.listNetworks()
|
||||
bridges = filter(isOldStyleBridge, bridges)
|
||||
for br in bridges:
|
||||
enslavedDev = netlib.getEnslavedDev(br, 1)
|
||||
if enslavedDev is not None:
|
||||
upgradeBridgeName(br, enslavedDev)
|
||||
|
||||
bridges = netlib.listNetworks()
|
||||
bridges = filter(isOldStyleBridge, bridges)
|
||||
if len(bridges) > 0:
|
||||
print("Warning: upgrade is not finished, still some bridges have the old style name:" + str(bridges))
|
||||
else:
|
||||
print("Upgrade succeed")
|
||||
53
agent/bindir/libvirtqemuhook.in
Executable file
53
agent/bindir/libvirtqemuhook.in
Executable file
@ -0,0 +1,53 @@
|
||||
#!/usr/bin/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 sys
|
||||
from xml.dom.minidom import parse
|
||||
from cloudutils.configFileOps import configFileOps
|
||||
from cloudutils.networkConfig import networkConfig
|
||||
def isOldStyleBridge(brName):
|
||||
if brName.find("cloudVirBr") == 0:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
def getGuestNetworkDevice():
|
||||
netlib = networkConfig()
|
||||
cfo = configFileOps("/etc/cloudstack/agent/agent.properties")
|
||||
guestDev = cfo.getEntry("guest.network.device")
|
||||
enslavedDev = netlib.getEnslavedDev(guestDev, 1)
|
||||
return enslavedDev
|
||||
def handleMigrateBegin():
|
||||
try:
|
||||
domain = parse(sys.stdin)
|
||||
for interface in domain.getElementsByTagName("interface"):
|
||||
source = interface.getElementsByTagName("source")[0]
|
||||
bridge = source.getAttribute("bridge")
|
||||
if not isOldStyleBridge(bridge):
|
||||
continue
|
||||
vlanId = bridge.replace("cloudVirBr","")
|
||||
phyDev = getGuestNetworkDevice()
|
||||
newBrName="br" + phyDev + "-" + vlanId
|
||||
source.setAttribute("bridge", newBrName)
|
||||
print(domain.toxml())
|
||||
except:
|
||||
pass
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) != 5:
|
||||
sys.exit(0)
|
||||
|
||||
if sys.argv[2] == "migrate" and sys.argv[3] == "begin":
|
||||
handleMigrateBegin()
|
||||
@ -36,6 +36,10 @@
|
||||
<artifactId>cloud-utils</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-daemon</groupId>
|
||||
<artifactId>commons-daemon</artifactId>
|
||||
|
||||
@ -1,20 +0,0 @@
|
||||
#!/usr/bin/env 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.
|
||||
|
||||
#run.sh runs the agent client.
|
||||
java $1 -Xms128M -Xmx384M -cp cglib-nodep-2.2.jar:trilead-ssh2-build213.jar:cloud-api.jar:cloud-core-extras.jar:cloud-utils.jar:cloud-agent.jar:cloud-console-proxy.jar:cloud-console-common.jar:freemarker.jar:log4j-1.2.15.jar:ws-commons-util-1.0.2.jar:xmlrpc-client-3.1.3.jar:cloud-core.jar:xmlrpc-common-3.1.3.jar:javaee-api-5.0-1.jar:gson-1.3.jar:commons-httpclient-3.1.jar:commons-logging-1.1.1.jar:commons-codec-1.4.jar:commons-collections-3.2.1.jar:commons-pool-1.4.jar:apache-log4j-extras-1.0.jar:libvirt-0.4.5.jar:jna.jar:.:/etc/cloud:./*:/usr/share/java/*:./conf com.cloud.agent.AgentShell
|
||||
@ -26,7 +26,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.SynchronousQueue;
|
||||
@ -36,6 +35,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.cloudstack.managed.context.ManagedContextTimerTask;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.AgentControlAnswer;
|
||||
@ -45,7 +45,6 @@ import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.CronCommand;
|
||||
import com.cloud.agent.api.MaintainAnswer;
|
||||
import com.cloud.agent.api.MaintainCommand;
|
||||
import com.cloud.agent.api.ModifySshKeysCommand;
|
||||
import com.cloud.agent.api.PingCommand;
|
||||
import com.cloud.agent.api.ReadyCommand;
|
||||
import com.cloud.agent.api.ShutdownCommand;
|
||||
@ -731,7 +730,7 @@ public class Agent implements HandlerFactory, IAgentControl {
|
||||
}
|
||||
}
|
||||
|
||||
public class WatchTask extends TimerTask {
|
||||
public class WatchTask extends ManagedContextTimerTask {
|
||||
protected Request _request;
|
||||
protected Agent _agent;
|
||||
protected Link _link;
|
||||
@ -744,7 +743,7 @@ public class Agent implements HandlerFactory, IAgentControl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
protected void runInContext() {
|
||||
if (s_logger.isTraceEnabled()) {
|
||||
s_logger.trace("Scheduling " + (_request instanceof Response ? "Ping" : "Watch Task"));
|
||||
}
|
||||
@ -760,7 +759,7 @@ public class Agent implements HandlerFactory, IAgentControl {
|
||||
}
|
||||
}
|
||||
|
||||
public class StartupTask extends TimerTask {
|
||||
public class StartupTask extends ManagedContextTimerTask {
|
||||
protected Link _link;
|
||||
protected volatile boolean cancelled = false;
|
||||
|
||||
@ -782,7 +781,7 @@ public class Agent implements HandlerFactory, IAgentControl {
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void run() {
|
||||
protected synchronized void runInContext() {
|
||||
if (!cancelled) {
|
||||
if (s_logger.isInfoEnabled()) {
|
||||
s_logger.info("The startup command is now cancelled");
|
||||
|
||||
@ -19,14 +19,12 @@ package com.cloud.agent;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -39,9 +37,8 @@ import javax.naming.ConfigurationException;
|
||||
import org.apache.commons.daemon.Daemon;
|
||||
import org.apache.commons.daemon.DaemonContext;
|
||||
import org.apache.commons.daemon.DaemonInitException;
|
||||
import org.apache.commons.httpclient.HttpClient;
|
||||
import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
|
||||
import org.apache.commons.httpclient.methods.GetMethod;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.xml.DOMConfigurator;
|
||||
|
||||
@ -56,12 +53,10 @@ import com.cloud.utils.PropertiesUtil;
|
||||
import com.cloud.utils.backoff.BackoffAlgorithm;
|
||||
import com.cloud.utils.backoff.impl.ConstantTimeBackoff;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.script.Script;
|
||||
|
||||
public class AgentShell implements IAgentShell, Daemon {
|
||||
private static final Logger s_logger = Logger.getLogger(AgentShell.class
|
||||
.getName());
|
||||
private static final MultiThreadedHttpConnectionManager s_httpClientManager = new MultiThreadedHttpConnectionManager();
|
||||
|
||||
private final Properties _properties = new Properties();
|
||||
private final Map<String, Object> _cmdLineProperties = new HashMap<String, Object>();
|
||||
@ -172,7 +167,7 @@ public class AgentShell implements IAgentShell, Daemon {
|
||||
_storage.persist(name, value);
|
||||
}
|
||||
|
||||
private void loadProperties() throws ConfigurationException {
|
||||
void loadProperties() throws ConfigurationException {
|
||||
final File file = PropertiesUtil.findConfigFile("agent.properties");
|
||||
if (file == null) {
|
||||
throw new ConfigurationException("Unable to find agent.properties.");
|
||||
@ -180,14 +175,18 @@ public class AgentShell implements IAgentShell, Daemon {
|
||||
|
||||
s_logger.info("agent.properties found at " + file.getAbsolutePath());
|
||||
|
||||
InputStream propertiesStream = null;
|
||||
try {
|
||||
_properties.load(new FileInputStream(file));
|
||||
propertiesStream = new FileInputStream(file);
|
||||
_properties.load(propertiesStream);
|
||||
} catch (final FileNotFoundException ex) {
|
||||
throw new CloudRuntimeException("Cannot find the file: "
|
||||
+ file.getAbsolutePath(), ex);
|
||||
} catch (final IOException ex) {
|
||||
throw new CloudRuntimeException("IOException in reading "
|
||||
+ file.getAbsolutePath(), ex);
|
||||
} finally {
|
||||
IOUtils.closeQuietly(propertiesStream);
|
||||
}
|
||||
}
|
||||
|
||||
@ -199,30 +198,32 @@ public class AgentShell implements IAgentShell, Daemon {
|
||||
String zone = null;
|
||||
String pod = null;
|
||||
String guid = null;
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
final String[] tokens = args[i].split("=");
|
||||
for (String param : args) {
|
||||
final String[] tokens = param.split("=");
|
||||
if (tokens.length != 2) {
|
||||
System.out.println("Invalid Parameter: " + args[i]);
|
||||
System.out.println("Invalid Parameter: " + param);
|
||||
continue;
|
||||
}
|
||||
final String paramName = tokens[0];
|
||||
final String paramValue = tokens[1];
|
||||
|
||||
// save command line properties
|
||||
_cmdLineProperties.put(tokens[0], tokens[1]);
|
||||
_cmdLineProperties.put(paramName, paramValue);
|
||||
|
||||
if (tokens[0].equalsIgnoreCase("port")) {
|
||||
port = tokens[1];
|
||||
} else if (tokens[0].equalsIgnoreCase("threads") || tokens[0].equalsIgnoreCase("workers")) {
|
||||
workers = tokens[1];
|
||||
} else if (tokens[0].equalsIgnoreCase("host")) {
|
||||
host = tokens[1];
|
||||
} else if (tokens[0].equalsIgnoreCase("zone")) {
|
||||
zone = tokens[1];
|
||||
} else if (tokens[0].equalsIgnoreCase("pod")) {
|
||||
pod = tokens[1];
|
||||
} else if (tokens[0].equalsIgnoreCase("guid")) {
|
||||
guid = tokens[1];
|
||||
} else if (tokens[0].equalsIgnoreCase("eth1ip")) {
|
||||
_privateIp = tokens[1];
|
||||
if (paramName.equalsIgnoreCase("port")) {
|
||||
port = paramValue;
|
||||
} else if (paramName.equalsIgnoreCase("threads") || paramName.equalsIgnoreCase("workers")) {
|
||||
workers = paramValue;
|
||||
} else if (paramName.equalsIgnoreCase("host")) {
|
||||
host = paramValue;
|
||||
} else if (paramName.equalsIgnoreCase("zone")) {
|
||||
zone = paramValue;
|
||||
} else if (paramName.equalsIgnoreCase("pod")) {
|
||||
pod = paramValue;
|
||||
} else if (paramName.equalsIgnoreCase("guid")) {
|
||||
guid = paramValue;
|
||||
} else if (paramName.equalsIgnoreCase("eth1ip")) {
|
||||
_privateIp = paramValue;
|
||||
}
|
||||
}
|
||||
|
||||
@ -230,16 +231,16 @@ public class AgentShell implements IAgentShell, Daemon {
|
||||
port = getProperty(null, "port");
|
||||
}
|
||||
|
||||
_port = NumbersUtil.parseInt(port, 8250);
|
||||
_port = NumberUtils.toInt(port, 8250);
|
||||
|
||||
_proxyPort = NumbersUtil.parseInt(
|
||||
_proxyPort = NumberUtils.toInt(
|
||||
getProperty(null, "consoleproxy.httpListenPort"), 443);
|
||||
|
||||
if (workers == null) {
|
||||
workers = getProperty(null, "workers");
|
||||
}
|
||||
|
||||
_workers = NumbersUtil.parseInt(workers, 5);
|
||||
_workers = NumberUtils.toInt(workers, 5);
|
||||
|
||||
if (host == null) {
|
||||
host = getProperty(null, "host");
|
||||
@ -309,7 +310,7 @@ public class AgentShell implements IAgentShell, Daemon {
|
||||
// For KVM agent, do it specially here
|
||||
|
||||
File file = new File("/etc/cloudstack/agent/log4j-cloud.xml");
|
||||
if(file == null || !file.exists()) {
|
||||
if(!file.exists()) {
|
||||
file = PropertiesUtil.findConfigFile("log4j-cloud.xml");
|
||||
}
|
||||
DOMConfigurator.configureAndWatch(file.getAbsolutePath());
|
||||
|
||||
@ -17,7 +17,6 @@
|
||||
package com.cloud.agent.dao.impl;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
@ -26,6 +25,7 @@ import java.util.Properties;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.dao.StorageComponent;
|
||||
@ -59,18 +59,10 @@ public class PropertiesStorage implements StorageComponent {
|
||||
_properties.store(output, _name);
|
||||
output.flush();
|
||||
output.close();
|
||||
} catch (FileNotFoundException e) {
|
||||
s_logger.error("Who deleted the file? ", e);
|
||||
} catch (IOException e) {
|
||||
s_logger.error("Uh-oh: ", e);
|
||||
} finally {
|
||||
if (output != null) {
|
||||
try {
|
||||
output.close();
|
||||
} catch (IOException e) {
|
||||
// ignore.
|
||||
}
|
||||
}
|
||||
IOUtils.closeQuietly(output);
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,7 +91,7 @@ public class PropertiesStorage implements StorageComponent {
|
||||
}
|
||||
|
||||
try {
|
||||
_properties.load(new FileInputStream(file));
|
||||
PropertiesUtil.loadFromFile(_properties, file);
|
||||
_file = file;
|
||||
} catch (FileNotFoundException e) {
|
||||
s_logger.error("How did we get here? ", e);
|
||||
|
||||
@ -32,6 +32,7 @@ import java.util.Properties;
|
||||
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.cloudstack.managed.context.ManagedContextRunnable;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.Agent.ExitStatus;
|
||||
@ -357,8 +358,9 @@ public class ConsoleProxyResource extends ServerResourceBase implements
|
||||
private void launchConsoleProxy(final byte[] ksBits, final String ksPassword, final String encryptorPassword) {
|
||||
final Object resource = this;
|
||||
if (_consoleProxyMain == null) {
|
||||
_consoleProxyMain = new Thread(new Runnable() {
|
||||
public void run() {
|
||||
_consoleProxyMain = new Thread(new ManagedContextRunnable() {
|
||||
@Override
|
||||
protected void runInContext() {
|
||||
try {
|
||||
Class<?> consoleProxyClazz = Class.forName("com.cloud.consoleproxy.ConsoleProxy");
|
||||
try {
|
||||
|
||||
48
agent/test/com/cloud/agent/AgentShellTest.java
Normal file
48
agent/test/com/cloud/agent/AgentShellTest.java
Normal file
@ -0,0 +1,48 @@
|
||||
// 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;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class AgentShellTest {
|
||||
@Test
|
||||
public void parseCommand() throws ConfigurationException {
|
||||
AgentShell shell = new AgentShell();
|
||||
UUID anyUuid = UUID.randomUUID();
|
||||
shell.parseCommand(new String[] { "port=55555", "threads=4",
|
||||
"host=localhost", "pod=pod1", "guid=" + anyUuid, "zone=zone1" });
|
||||
Assert.assertEquals(55555, shell.getPort());
|
||||
Assert.assertEquals(4, shell.getWorkers());
|
||||
Assert.assertEquals("localhost", shell.getHost());
|
||||
Assert.assertEquals(anyUuid.toString(), shell.getGuid());
|
||||
Assert.assertEquals("pod1", shell.getPod());
|
||||
Assert.assertEquals("zone1", shell.getZone());
|
||||
}
|
||||
@Test
|
||||
public void loadProperties() throws ConfigurationException {
|
||||
AgentShell shell = new AgentShell();
|
||||
shell.loadProperties();
|
||||
Assert.assertNotNull(shell.getProperties());
|
||||
Assert.assertFalse(shell.getProperties().entrySet().isEmpty());
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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.dao.impl;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
public class PropertiesStorageTest {
|
||||
@Test
|
||||
public void configureWithNotExistingFile() {
|
||||
String fileName = "target/notyetexistingfile"
|
||||
+ System.currentTimeMillis();
|
||||
File file = new File(fileName);
|
||||
|
||||
PropertiesStorage storage = new PropertiesStorage();
|
||||
HashMap<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("path", fileName);
|
||||
Assert.assertTrue(storage.configure("test", params));
|
||||
Assert.assertTrue(file.exists());
|
||||
storage.persist("foo", "bar");
|
||||
Assert.assertEquals("bar", storage.get("foo"));
|
||||
|
||||
storage.stop();
|
||||
file.delete();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void configureWithExistingFile() throws IOException {
|
||||
String fileName = "target/existingfile"
|
||||
+ System.currentTimeMillis();
|
||||
File file = new File(fileName);
|
||||
|
||||
FileUtils.writeStringToFile(file, "a=b\n\n");
|
||||
|
||||
PropertiesStorage storage = new PropertiesStorage();
|
||||
HashMap<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("path", fileName);
|
||||
Assert.assertTrue(storage.configure("test", params));
|
||||
Assert.assertEquals("b", storage.get("a"));
|
||||
Assert.assertTrue(file.exists());
|
||||
storage.persist("foo", "bar");
|
||||
Assert.assertEquals("bar", storage.get("foo"));
|
||||
|
||||
storage.stop();
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
@ -1,12 +1,11 @@
|
||||
# Config::Simple 4.59
|
||||
# Fri May 25 12:50:59 2012
|
||||
# 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#
|
||||
# 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,
|
||||
@ -15,8 +14,5 @@
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
xml_lang: "en-US"
|
||||
type: Book
|
||||
brand: cloudstack
|
||||
|
||||
name=api-planner
|
||||
parent=planner
|
||||
@ -0,0 +1,34 @@
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-3.0.xsd"
|
||||
>
|
||||
|
||||
<bean id="UserDispersingPlanner" class="com.cloud.deploy.UserDispersingPlanner">
|
||||
<property name="name" value="UserDispersingPlanner" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
@ -20,7 +20,7 @@ package com.cloud.agent.api.to;
|
||||
|
||||
import com.cloud.storage.DataStoreRole;
|
||||
|
||||
|
||||
public interface DataStoreTO {
|
||||
public DataStoreRole getRole();
|
||||
public String getUuid();
|
||||
}
|
||||
|
||||
@ -18,21 +18,35 @@
|
||||
*/
|
||||
package com.cloud.agent.api.to;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.storage.Volume;
|
||||
|
||||
public class DiskTO {
|
||||
public static final String CHAP_INITIATOR_USERNAME = "chapInitiatorUsername";
|
||||
public static final String CHAP_INITIATOR_SECRET = "chapInitiatorSecret";
|
||||
public static final String CHAP_TARGET_USERNAME = "chapTargetUsername";
|
||||
public static final String CHAP_TARGET_SECRET = "chapTargetSecret";
|
||||
public static final String MANAGED = "managed";
|
||||
public static final String IQN = "iqn";
|
||||
public static final String STORAGE_HOST = "storageHost";
|
||||
public static final String STORAGE_PORT = "storagePort";
|
||||
public static final String VOLUME_SIZE = "volumeSize";
|
||||
|
||||
private DataTO data;
|
||||
private Long diskSeq;
|
||||
private String vdiUuid;
|
||||
private String path;
|
||||
private Volume.Type type;
|
||||
private Map<String, String> _details;
|
||||
|
||||
public DiskTO() {
|
||||
|
||||
}
|
||||
|
||||
public DiskTO(DataTO data, Long diskSeq, String vdiUuid, Volume.Type type) {
|
||||
public DiskTO(DataTO data, Long diskSeq, String path, Volume.Type type) {
|
||||
this.data = data;
|
||||
this.diskSeq = diskSeq;
|
||||
this.vdiUuid = vdiUuid;
|
||||
this.path = path;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@ -52,12 +66,12 @@ public class DiskTO {
|
||||
this.diskSeq = diskSeq;
|
||||
}
|
||||
|
||||
public String getVdiUuid() {
|
||||
return vdiUuid;
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setVdiUuid(String vdiUuid) {
|
||||
this.vdiUuid = vdiUuid;
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public Volume.Type getType() {
|
||||
@ -67,4 +81,12 @@ public class DiskTO {
|
||||
public void setType(Volume.Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void setDetails(Map<String, String> details) {
|
||||
_details = details;
|
||||
}
|
||||
|
||||
public Map<String, String> getDetails() {
|
||||
return _details;
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,6 +22,7 @@ public class NfsTO implements DataStoreTO {
|
||||
|
||||
private String _url;
|
||||
private DataStoreRole _role;
|
||||
private String uuid;
|
||||
|
||||
public NfsTO() {
|
||||
|
||||
@ -55,6 +56,12 @@ public class NfsTO implements DataStoreTO {
|
||||
this._role = _role;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,6 +39,7 @@ public final class S3TO implements S3Utils.ClientOptions, DataStoreTO {
|
||||
private Integer socketTimeout;
|
||||
private Date created;
|
||||
private boolean enableRRS;
|
||||
private long maxSingleUploadSizeInBytes;
|
||||
|
||||
public S3TO() {
|
||||
|
||||
@ -50,7 +51,7 @@ public final class S3TO implements S3Utils.ClientOptions, DataStoreTO {
|
||||
final String secretKey, final String endPoint,
|
||||
final String bucketName, final Boolean httpsFlag,
|
||||
final Integer connectionTimeout, final Integer maxErrorRetry,
|
||||
final Integer socketTimeout, final Date created, final boolean enableRRS) {
|
||||
final Integer socketTimeout, final Date created, final boolean enableRRS, final long maxUploadSize) {
|
||||
|
||||
super();
|
||||
|
||||
@ -66,6 +67,7 @@ public final class S3TO implements S3Utils.ClientOptions, DataStoreTO {
|
||||
this.socketTimeout = socketTimeout;
|
||||
this.created = created;
|
||||
this.enableRRS = enableRRS;
|
||||
this.maxSingleUploadSizeInBytes = maxUploadSize;
|
||||
|
||||
}
|
||||
|
||||
@ -268,7 +270,6 @@ public final class S3TO implements S3Utils.ClientOptions, DataStoreTO {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean getEnableRRS() {
|
||||
return enableRRS;
|
||||
}
|
||||
@ -277,5 +278,28 @@ public final class S3TO implements S3Utils.ClientOptions, DataStoreTO {
|
||||
this.enableRRS = enableRRS;
|
||||
}
|
||||
|
||||
|
||||
public long getMaxSingleUploadSizeInBytes() {
|
||||
return maxSingleUploadSizeInBytes;
|
||||
}
|
||||
|
||||
public void setMaxSingleUploadSizeInBytes(long maxSingleUploadSizeInBytes) {
|
||||
this.maxSingleUploadSizeInBytes = maxSingleUploadSizeInBytes;
|
||||
}
|
||||
|
||||
public boolean getSingleUpload(long objSize){
|
||||
if ( maxSingleUploadSizeInBytes < 0 ){
|
||||
// always use single part upload
|
||||
return true;
|
||||
} else if ( maxSingleUploadSizeInBytes == 0 ){
|
||||
// always use multi part upload
|
||||
return false;
|
||||
} else {
|
||||
// check object size to set flag
|
||||
if (objSize < maxSingleUploadSizeInBytes){
|
||||
return true;
|
||||
} else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,8 +29,7 @@ public class SwiftTO implements DataStoreTO, SwiftUtil.SwiftClientCfg {
|
||||
|
||||
public SwiftTO() { }
|
||||
|
||||
public SwiftTO(Long id, String url, String account, String userName, String key
|
||||
) {
|
||||
public SwiftTO(Long id, String url, String account, String userName, String key) {
|
||||
this.id = id;
|
||||
this.url = url;
|
||||
this.account = account;
|
||||
@ -46,14 +45,17 @@ public class SwiftTO implements DataStoreTO, SwiftUtil.SwiftClientCfg {
|
||||
return url;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAccount() {
|
||||
return account;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
@ -67,4 +69,9 @@ public class SwiftTO implements DataStoreTO, SwiftUtil.SwiftClientCfg {
|
||||
public String getEndPoint() {
|
||||
return this.url;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUuid() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,6 +76,7 @@ public class EventTypes {
|
||||
public static final String EVENT_VM_MIGRATE = "VM.MIGRATE";
|
||||
public static final String EVENT_VM_MOVE = "VM.MOVE";
|
||||
public static final String EVENT_VM_RESTORE = "VM.RESTORE";
|
||||
public static final String EVENT_VM_EXPUNGE = "VM.EXPUNGE";
|
||||
|
||||
// Domain Router
|
||||
public static final String EVENT_ROUTER_CREATE = "ROUTER.CREATE";
|
||||
@ -188,6 +189,8 @@ public class EventTypes {
|
||||
public static final String EVENT_VOLUME_DETAIL_UPDATE = "VOLUME.DETAIL.UPDATE";
|
||||
public static final String EVENT_VOLUME_DETAIL_ADD = "VOLUME.DETAIL.ADD";
|
||||
public static final String EVENT_VOLUME_DETAIL_REMOVE = "VOLUME.DETAIL.REMOVE";
|
||||
public static final String EVENT_VOLUME_UPDATE = "VOLUME.UPDATE";
|
||||
|
||||
|
||||
// Domains
|
||||
public static final String EVENT_DOMAIN_CREATE = "DOMAIN.CREATE";
|
||||
@ -197,6 +200,7 @@ public class EventTypes {
|
||||
// Snapshots
|
||||
public static final String EVENT_SNAPSHOT_CREATE = "SNAPSHOT.CREATE";
|
||||
public static final String EVENT_SNAPSHOT_DELETE = "SNAPSHOT.DELETE";
|
||||
public static final String EVENT_SNAPSHOT_REVERT = "SNAPSHOT.REVERT";
|
||||
public static final String EVENT_SNAPSHOT_POLICY_CREATE = "SNAPSHOTPOLICY.CREATE";
|
||||
public static final String EVENT_SNAPSHOT_POLICY_UPDATE = "SNAPSHOTPOLICY.UPDATE";
|
||||
public static final String EVENT_SNAPSHOT_POLICY_DELETE = "SNAPSHOTPOLICY.DELETE";
|
||||
@ -456,6 +460,9 @@ public class EventTypes {
|
||||
public static final String EVENT_ACL_GROUP_GRANT = "ACLGROUP.GRANT";
|
||||
public static final String EVENT_ACL_GROUP_REVOKE = "ACLGROUP.REVOKE";
|
||||
|
||||
// Object store migration
|
||||
public static final String EVENT_MIGRATE_PREPARE_SECONDARY_STORAGE = "MIGRATE.PREPARE.SS";
|
||||
|
||||
static {
|
||||
|
||||
// TODO: need a way to force author adding event types to declare the entity details as well, with out braking
|
||||
|
||||
@ -17,8 +17,9 @@
|
||||
package com.cloud.exception;
|
||||
|
||||
import com.cloud.utils.SerialVersionUID;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
public class ConcurrentOperationException extends CloudException {
|
||||
public class ConcurrentOperationException extends CloudRuntimeException {
|
||||
|
||||
private static final long serialVersionUID = SerialVersionUID.ConcurrentOperationException;
|
||||
|
||||
|
||||
@ -108,6 +108,7 @@ public class Networks {
|
||||
},
|
||||
Mido("mido", String.class),
|
||||
Pvlan("pvlan", String.class),
|
||||
Vxlan("vxlan", Long.class),
|
||||
UnDecided(null, null);
|
||||
|
||||
private final String scheme;
|
||||
|
||||
@ -39,7 +39,8 @@ public interface PhysicalNetwork extends Identity, InternalIdentity {
|
||||
STT,
|
||||
VNS,
|
||||
MIDO,
|
||||
SSP;
|
||||
SSP,
|
||||
VXLAN;
|
||||
}
|
||||
|
||||
public enum BroadcastDomainRange {
|
||||
|
||||
@ -31,6 +31,7 @@ public interface RemoteAccessVpn extends ControlledEntity, InternalIdentity, Ide
|
||||
String getIpRange();
|
||||
String getIpsecPresharedKey();
|
||||
String getLocalIp();
|
||||
long getNetworkId();
|
||||
Long getNetworkId();
|
||||
Long getVpcId();
|
||||
State getState();
|
||||
}
|
||||
|
||||
@ -20,14 +20,14 @@ import org.apache.cloudstack.api.Identity;
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
|
||||
public interface VirtualRouterProvider extends InternalIdentity, Identity {
|
||||
public enum VirtualRouterProviderType {
|
||||
public enum Type {
|
||||
VirtualRouter,
|
||||
ElasticLoadBalancerVm,
|
||||
VPCVirtualRouter,
|
||||
InternalLbVm
|
||||
}
|
||||
|
||||
public VirtualRouterProviderType getType();
|
||||
public Type getType();
|
||||
|
||||
public boolean isEnabled();
|
||||
|
||||
|
||||
@ -19,7 +19,6 @@ package com.cloud.network.element;
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.RemoteAccessVpn;
|
||||
import com.cloud.network.VpnUser;
|
||||
import com.cloud.utils.component.Adapter;
|
||||
@ -27,7 +26,7 @@ import com.cloud.utils.component.Adapter;
|
||||
public interface RemoteAccessVPNServiceProvider extends Adapter {
|
||||
String[] applyVpnUsers(RemoteAccessVpn vpn, List<? extends VpnUser> users) throws ResourceUnavailableException;
|
||||
|
||||
boolean startVpn(Network network, RemoteAccessVpn vpn) throws ResourceUnavailableException;
|
||||
boolean startVpn(RemoteAccessVpn vpn) throws ResourceUnavailableException;
|
||||
|
||||
boolean stopVpn(Network network, RemoteAccessVpn vpn) throws ResourceUnavailableException;
|
||||
boolean stopVpn(RemoteAccessVpn vpn) throws ResourceUnavailableException;
|
||||
}
|
||||
|
||||
@ -22,12 +22,12 @@ import org.apache.cloudstack.api.command.admin.router.ConfigureVirtualRouterElem
|
||||
import org.apache.cloudstack.api.command.admin.router.ListVirtualRouterElementsCmd;
|
||||
|
||||
import com.cloud.network.VirtualRouterProvider;
|
||||
import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
|
||||
import com.cloud.network.VirtualRouterProvider.Type;
|
||||
import com.cloud.utils.component.PluggableService;
|
||||
|
||||
public interface VirtualRouterElementService extends PluggableService{
|
||||
VirtualRouterProvider configure(ConfigureVirtualRouterElementCmd cmd);
|
||||
VirtualRouterProvider addElement(Long nspId, VirtualRouterProviderType providerType);
|
||||
VirtualRouterProvider addElement(Long nspId, Type providerType);
|
||||
VirtualRouterProvider getCreatedElement(long id);
|
||||
List<? extends VirtualRouterProvider> searchForVirtualRouterElement(ListVirtualRouterElementsCmd cmd);
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ import com.cloud.utils.Pair;
|
||||
public interface RemoteAccessVpnService {
|
||||
static final String RemoteAccessVpnClientIpRangeCK = "remote.access.vpn.client.iprange";
|
||||
|
||||
RemoteAccessVpn createRemoteAccessVpn(long vpnServerAddressId, String ipRange, boolean openFirewall, long networkId)
|
||||
RemoteAccessVpn createRemoteAccessVpn(long vpnServerAddressId, String ipRange, boolean openFirewall)
|
||||
throws NetworkRuleConflictException;
|
||||
void destroyRemoteAccessVpnForIp(long vpnServerAddressId, Account caller) throws ResourceUnavailableException;
|
||||
RemoteAccessVpn startRemoteAccessVpn(long vpnServerAddressId, boolean openFirewall) throws ResourceUnavailableException;
|
||||
@ -47,5 +47,4 @@ public interface RemoteAccessVpnService {
|
||||
List<? extends RemoteAccessVpn> listRemoteAccessVpns(long networkId);
|
||||
|
||||
RemoteAccessVpn getRemoteAccessVpn(long vpnAddrId);
|
||||
|
||||
}
|
||||
|
||||
@ -130,4 +130,6 @@ public interface NetworkOffering extends InfrastructureEntity, InternalIdentity,
|
||||
boolean getEgressDefaultPolicy();
|
||||
|
||||
Integer getConcurrentConnections();
|
||||
|
||||
boolean isKeepAliveEnabled();
|
||||
}
|
||||
|
||||
@ -19,19 +19,19 @@ package com.cloud.server;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.server.ResourceTag.TaggedResourceType;
|
||||
import org.apache.cloudstack.api.ResourceDetail;
|
||||
|
||||
import com.cloud.server.ResourceTag.ResourceObjectType;
|
||||
|
||||
public interface ResourceMetaDataService {
|
||||
|
||||
TaggedResourceType getResourceType (String resourceTypeStr);
|
||||
|
||||
/**
|
||||
* @param resourceId TODO
|
||||
* @param resourceType
|
||||
* @param details
|
||||
* @return
|
||||
*/
|
||||
boolean addResourceMetaData(String resourceId, TaggedResourceType resourceType, Map<String, String> details);
|
||||
boolean addResourceMetaData(String resourceId, ResourceObjectType resourceType, Map<String, String> details);
|
||||
|
||||
|
||||
/**
|
||||
@ -41,7 +41,14 @@ public interface ResourceMetaDataService {
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public boolean deleteResourceMetaData(String resourceId, TaggedResourceType resourceType, String key);
|
||||
public boolean deleteResourceMetaData(String resourceId, ResourceObjectType resourceType, String key);
|
||||
|
||||
|
||||
ResourceDetail getDetail(long resourceId, ResourceObjectType resourceType, String key);
|
||||
|
||||
|
||||
Map<String, String> getDetailsMap(long resourceId, ResourceObjectType resourceType, Boolean forDisplay);
|
||||
|
||||
List<? extends ResourceDetail> getDetailsList(long resourceId, ResourceObjectType resourceType, Boolean forDisplay);
|
||||
|
||||
}
|
||||
|
||||
@ -22,25 +22,45 @@ import org.apache.cloudstack.api.InternalIdentity;
|
||||
|
||||
public interface ResourceTag extends ControlledEntity, Identity, InternalIdentity {
|
||||
|
||||
public enum TaggedResourceType {
|
||||
UserVm,
|
||||
Template,
|
||||
ISO,
|
||||
Volume,
|
||||
Snapshot,
|
||||
Network,
|
||||
Nic,
|
||||
LoadBalancer,
|
||||
PortForwardingRule,
|
||||
FirewallRule,
|
||||
SecurityGroup,
|
||||
PublicIpAddress,
|
||||
Project,
|
||||
Vpc,
|
||||
NetworkACL,
|
||||
StaticRoute,
|
||||
VMSnapshot,
|
||||
RemoteAccessVpn
|
||||
//FIXME - extract enum to another interface as its used both by resourceTags and resourceMetaData code
|
||||
public enum ResourceObjectType {
|
||||
UserVm (true, true),
|
||||
Template (true, true),
|
||||
ISO (true, false),
|
||||
Volume (true, true),
|
||||
Snapshot (true, false),
|
||||
Network (true, true),
|
||||
Nic (false, true),
|
||||
LoadBalancer (true, false),
|
||||
PortForwardingRule (true, false),
|
||||
FirewallRule (true, true),
|
||||
SecurityGroup (true, false),
|
||||
PublicIpAddress (true, false),
|
||||
Project (true, false),
|
||||
Vpc (true, false),
|
||||
NetworkACL (true, false),
|
||||
StaticRoute (true, false),
|
||||
VMSnapshot (true, false),
|
||||
RemoteAccessVpn (true, false),
|
||||
Zone (false, true),
|
||||
ServiceOffering (false, true),
|
||||
Storage(false, true);
|
||||
|
||||
ResourceObjectType(boolean resourceTagsSupport, boolean resourceMetadataSupport) {
|
||||
this.resourceTagsSupport = resourceTagsSupport;
|
||||
this.metadataSupport = resourceMetadataSupport;
|
||||
}
|
||||
|
||||
private final boolean resourceTagsSupport;
|
||||
private final boolean metadataSupport;
|
||||
|
||||
public boolean resourceTagsSupport() {
|
||||
return this.resourceTagsSupport;
|
||||
}
|
||||
|
||||
public boolean resourceMetadataSupport() {
|
||||
return this.metadataSupport;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -61,7 +81,7 @@ public interface ResourceTag extends ControlledEntity, Identity, InternalIdentit
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
TaggedResourceType getResourceType();
|
||||
ResourceObjectType getResourceType();
|
||||
|
||||
/**
|
||||
* @return
|
||||
|
||||
@ -19,12 +19,10 @@ package com.cloud.server;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.server.ResourceTag.TaggedResourceType;
|
||||
import com.cloud.server.ResourceTag.ResourceObjectType;
|
||||
|
||||
public interface TaggedResourceService {
|
||||
|
||||
TaggedResourceType getResourceType (String resourceTypeStr);
|
||||
|
||||
/**
|
||||
* @param resourceIds TODO
|
||||
* @param resourceType
|
||||
@ -32,14 +30,7 @@ public interface TaggedResourceService {
|
||||
* @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);
|
||||
List<ResourceTag> createTags(List<String> resourceIds, ResourceObjectType resourceType, Map<String, String> tags, String customer);
|
||||
|
||||
|
||||
/**
|
||||
@ -48,10 +39,19 @@ public interface TaggedResourceService {
|
||||
* @param tags
|
||||
* @return
|
||||
*/
|
||||
boolean deleteTags(List<String> resourceIds, TaggedResourceType resourceType, Map<String, String> tags);
|
||||
boolean deleteTags(List<String> resourceIds, ResourceObjectType resourceType, Map<String, String> tags);
|
||||
|
||||
List<? extends ResourceTag> listByResourceTypeAndId(TaggedResourceType type, long resourceId);
|
||||
List<? extends ResourceTag> listByResourceTypeAndId(ResourceObjectType type, long resourceId);
|
||||
|
||||
public Long getResourceId(String resourceId, TaggedResourceType resourceType);
|
||||
//FIXME - the methods below should be extracted to its separate manager/service responsible just for retrieving object details
|
||||
ResourceObjectType getResourceType (String resourceTypeStr);
|
||||
|
||||
/**
|
||||
* @param resourceId
|
||||
* @param resourceType
|
||||
* @return
|
||||
*/
|
||||
String getUuid(String resourceId, ResourceObjectType resourceType);
|
||||
|
||||
public long getResourceId(String resourceId, ResourceObjectType resourceType);
|
||||
}
|
||||
|
||||
@ -22,9 +22,9 @@ import org.apache.cloudstack.api.command.admin.storage.AddImageStoreCmd;
|
||||
import org.apache.cloudstack.api.command.admin.storage.CancelPrimaryStorageMaintenanceCmd;
|
||||
import org.apache.cloudstack.api.command.admin.storage.CreateSecondaryStagingStoreCmd;
|
||||
import org.apache.cloudstack.api.command.admin.storage.CreateStoragePoolCmd;
|
||||
import org.apache.cloudstack.api.command.admin.storage.DeleteSecondaryStagingStoreCmd;
|
||||
import org.apache.cloudstack.api.command.admin.storage.DeleteImageStoreCmd;
|
||||
import org.apache.cloudstack.api.command.admin.storage.DeletePoolCmd;
|
||||
import org.apache.cloudstack.api.command.admin.storage.DeleteSecondaryStagingStoreCmd;
|
||||
import org.apache.cloudstack.api.command.admin.storage.UpdateStoragePoolCmd;
|
||||
|
||||
import com.cloud.exception.DiscoveryException;
|
||||
@ -97,4 +97,18 @@ public interface StorageService{
|
||||
|
||||
ImageStore discoverImageStore(AddImageStoreCmd cmd) throws IllegalArgumentException, DiscoveryException, InvalidParameterValueException;
|
||||
|
||||
/**
|
||||
* Prepare NFS secondary storage for object store migration
|
||||
*
|
||||
* @param cmd
|
||||
* - the command specifying secondaryStorageId
|
||||
* @return the storage pool
|
||||
* @throws ResourceUnavailableException
|
||||
* TODO
|
||||
* @throws InsufficientCapacityException
|
||||
* TODO
|
||||
*/
|
||||
public ImageStore prepareSecondaryStorageForObjectStoreMigration(Long storeId) throws ResourceUnavailableException,
|
||||
InsufficientCapacityException;
|
||||
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ public interface VolumeApiService {
|
||||
|
||||
Snapshot allocSnapshot(Long volumeId, Long policyId)
|
||||
throws ResourceAllocationException;
|
||||
Volume updateVolume(UpdateVolumeCmd updateVolumeCmd);
|
||||
Volume updateVolume(long volumeId, String path, String state, Long storageId, Boolean displayVolume);
|
||||
|
||||
/**
|
||||
* Extracts the volume to a particular location.
|
||||
|
||||
@ -106,4 +106,6 @@ public interface SnapshotApiService {
|
||||
* @return
|
||||
*/
|
||||
Long getHostIdForSnapshotOperation(Volume vol);
|
||||
|
||||
boolean revertSnapshot(Long snapshotId);
|
||||
}
|
||||
|
||||
@ -33,6 +33,9 @@ public interface DomainService {
|
||||
|
||||
Domain getDomain(String uuid);
|
||||
|
||||
Domain getDomainByName(String name, long parentId);
|
||||
|
||||
|
||||
/**
|
||||
* Return whether a domain is a child domain of a given domain.
|
||||
*
|
||||
|
||||
@ -23,6 +23,7 @@ import javax.naming.InsufficientResourcesException;
|
||||
|
||||
import org.apache.cloudstack.api.BaseCmd.HTTPMethod;
|
||||
import org.apache.cloudstack.api.command.admin.vm.AssignVMCmd;
|
||||
import org.apache.cloudstack.api.command.admin.vm.ExpungeVMCmd;
|
||||
import org.apache.cloudstack.api.command.admin.vm.RecoverVMCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.AddNicToVMCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.DeployVMCmd;
|
||||
@ -463,4 +464,8 @@ public interface UserVmService {
|
||||
|
||||
UserVm upgradeVirtualMachine(ScaleVMCmd cmd) throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException, VirtualMachineMigrationException;
|
||||
|
||||
UserVm expungeVm(ExpungeVMCmd cmd) throws ResourceUnavailableException, ConcurrentOperationException;
|
||||
|
||||
UserVm expungeVm(long vmId) throws ResourceUnavailableException, ConcurrentOperationException;
|
||||
|
||||
}
|
||||
|
||||
@ -21,4 +21,5 @@ public interface VmDetailConstants {
|
||||
public static final String NIC_ADAPTER = "nicAdapter";
|
||||
public static final String ROOK_DISK_CONTROLLER = "rootDiskController";
|
||||
public static final String NESTED_VIRTUALIZATION_FLAG = "nestedVirtualizationFlag";
|
||||
public static final String HYPERVISOR_TOOLS_VERSION = "hypervisortoolsversion";
|
||||
}
|
||||
|
||||
@ -22,6 +22,7 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.apache.cloudstack.acl.RoleType;
|
||||
import org.apache.cloudstack.api.ResponseObject.ResponseView;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@ -40,4 +41,6 @@ public @interface APICommand {
|
||||
String since() default "";
|
||||
|
||||
ResponseView responseView() default ResponseView.Admin;
|
||||
|
||||
RoleType[] authorized() default {};
|
||||
}
|
||||
|
||||
@ -28,6 +28,7 @@ public enum ApiCommandJobType {
|
||||
SystemVm,
|
||||
Host,
|
||||
StoragePool,
|
||||
ImageStore,
|
||||
IpAddress,
|
||||
PortableIpAddress,
|
||||
SecurityGroup,
|
||||
|
||||
@ -34,6 +34,7 @@ public class ApiConstants {
|
||||
public static final String BYTES_READ_RATE = "bytesreadrate";
|
||||
public static final String BYTES_WRITE_RATE = "byteswriterate";
|
||||
public static final String CATEGORY = "category";
|
||||
public static final String CAN_REVERT = "canrevert";
|
||||
public static final String CERTIFICATE = "certificate";
|
||||
public static final String PRIVATE_KEY = "privatekey";
|
||||
public static final String DOMAIN_SUFFIX = "domainsuffix";
|
||||
@ -142,6 +143,7 @@ public class ApiConstants {
|
||||
public static final String MAX_SNAPS = "maxsnaps";
|
||||
public static final String MEMORY = "memory";
|
||||
public static final String MODE = "mode";
|
||||
public static final String KEEPALIVE_ENABLED = "keepaliveenabled";
|
||||
public static final String NAME = "name";
|
||||
public static final String METHOD_NAME = "methodname";
|
||||
public static final String NETWORK_DOMAIN = "networkdomain";
|
||||
@ -186,6 +188,7 @@ public class ApiConstants {
|
||||
public static final String REQUIRES_HVM = "requireshvm";
|
||||
public static final String RESOURCE_TYPE = "resourcetype";
|
||||
public static final String RESPONSE = "response";
|
||||
public static final String REVERTABLE = "revertable";
|
||||
public static final String QUERY_FILTER = "queryfilter";
|
||||
public static final String SCHEDULE = "schedule";
|
||||
public static final String SCOPE = "scope";
|
||||
@ -530,6 +533,11 @@ public class ApiConstants {
|
||||
public static final String ENTITY_ID = "entityid";
|
||||
public static final String ACCESS_TYPE = "accesstype";
|
||||
|
||||
public static final String RESOURCE_DETAILS = "resourcedetails";
|
||||
public static final String EXPUNGE = "expunge";
|
||||
public static final String FOR_DISPLAY = "fordisplay";
|
||||
|
||||
|
||||
public enum HostDetails {
|
||||
all, capacity, events, stats, min;
|
||||
}
|
||||
|
||||
@ -21,7 +21,6 @@ import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@ -76,7 +75,6 @@ import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountService;
|
||||
import com.cloud.user.DomainService;
|
||||
import com.cloud.user.ResourceLimitService;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.db.EntityManager;
|
||||
import com.cloud.vm.UserVmService;
|
||||
import com.cloud.vm.snapshot.VMSnapshotService;
|
||||
@ -303,172 +301,6 @@ public abstract class BaseCmd {
|
||||
return lowercaseParams;
|
||||
}
|
||||
|
||||
public String buildResponse(ServerApiException apiException, String responseType) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
|
||||
// JSON response
|
||||
sb.append("{ \"" + getCommandName() + "\" : { " + "\"@attributes\":{\"cloud-stack-version\":\"" + _mgr.getVersion() + "\"},");
|
||||
sb.append("\"errorcode\" : \"" + apiException.getErrorCode() + "\", \"description\" : \"" + apiException.getDescription() + "\" } }");
|
||||
} else {
|
||||
sb.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
|
||||
sb.append("<" + getCommandName() + ">");
|
||||
sb.append("<errorcode>" + apiException.getErrorCode() + "</errorcode>");
|
||||
sb.append("<description>" + escapeXml(apiException.getDescription()) + "</description>");
|
||||
sb.append("</" + getCommandName() + " cloud-stack-version=\"" + _mgr.getVersion() + "\">");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public String buildResponse(List<Pair<String, Object>> tagList, String responseType) {
|
||||
StringBuffer prefixSb = new StringBuffer();
|
||||
StringBuffer suffixSb = new StringBuffer();
|
||||
|
||||
// set up the return value with the name of the response
|
||||
if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
|
||||
prefixSb.append("{ \"" + getCommandName() + "\" : { \"@attributes\":{\"cloud-stack-version\":\"" + _mgr.getVersion() + "\"},");
|
||||
} else {
|
||||
prefixSb.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
|
||||
prefixSb.append("<" + getCommandName() + " cloud-stack-version=\"" + _mgr.getVersion() + "\">");
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for (Pair<String, Object> tagData : tagList) {
|
||||
String tagName = tagData.first();
|
||||
Object tagValue = tagData.second();
|
||||
if (tagValue instanceof Object[]) {
|
||||
Object[] subObjects = (Object[]) tagValue;
|
||||
if (subObjects.length < 1) {
|
||||
continue;
|
||||
}
|
||||
writeObjectArray(responseType, suffixSb, i++, tagName, subObjects);
|
||||
} else {
|
||||
writeNameValuePair(suffixSb, tagName, tagValue, responseType, i++);
|
||||
}
|
||||
}
|
||||
|
||||
if (suffixSb.length() > 0) {
|
||||
if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) { // append comma only if we have some suffix else
|
||||
// not as per strict Json syntax.
|
||||
prefixSb.append(",");
|
||||
}
|
||||
prefixSb.append(suffixSb);
|
||||
}
|
||||
// close the response
|
||||
if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
|
||||
prefixSb.append("} }");
|
||||
} else {
|
||||
prefixSb.append("</" + getCommandName() + ">");
|
||||
}
|
||||
return prefixSb.toString();
|
||||
}
|
||||
|
||||
private void writeNameValuePair(StringBuffer sb, String tagName, Object tagValue, String responseType, int propertyCount) {
|
||||
if (tagValue == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (tagValue instanceof Object[]) {
|
||||
Object[] subObjects = (Object[]) tagValue;
|
||||
if (subObjects.length < 1) {
|
||||
return;
|
||||
}
|
||||
writeObjectArray(responseType, sb, propertyCount, tagName, subObjects);
|
||||
} else {
|
||||
if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
|
||||
String seperator = ((propertyCount > 0) ? ", " : "");
|
||||
sb.append(seperator + "\"" + tagName + "\" : \"" + escapeJSON(tagValue.toString()) + "\"");
|
||||
} else {
|
||||
sb.append("<" + tagName + ">" + escapeXml(tagValue.toString()) + "</" + tagName + ">");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private void writeObjectArray(String responseType, StringBuffer sb, int propertyCount, String tagName, Object[] subObjects) {
|
||||
if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
|
||||
String separator = ((propertyCount > 0) ? ", " : "");
|
||||
sb.append(separator);
|
||||
}
|
||||
int j = 0;
|
||||
for (Object subObject : subObjects) {
|
||||
if (subObject instanceof List) {
|
||||
List subObjList = (List) subObject;
|
||||
writeSubObject(sb, tagName, subObjList, responseType, j++);
|
||||
}
|
||||
}
|
||||
|
||||
if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
|
||||
sb.append("]");
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private void writeSubObject(StringBuffer sb, String tagName, List tagList, String responseType, int objectCount) {
|
||||
if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
|
||||
sb.append(((objectCount == 0) ? "\"" + tagName + "\" : [ { " : ", { "));
|
||||
} else {
|
||||
sb.append("<" + tagName + ">");
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for (Object tag : tagList) {
|
||||
if (tag instanceof Pair) {
|
||||
Pair nameValuePair = (Pair) tag;
|
||||
writeNameValuePair(sb, (String) nameValuePair.first(), nameValuePair.second(), responseType, i++);
|
||||
}
|
||||
}
|
||||
|
||||
if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
|
||||
sb.append("}");
|
||||
} else {
|
||||
sb.append("</" + tagName + ">");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape xml response set to false by default. API commands to override this method to allow escaping
|
||||
*/
|
||||
public boolean requireXmlEscape() {
|
||||
return true;
|
||||
}
|
||||
|
||||
private String escapeXml(String xml) {
|
||||
if (!requireXmlEscape()) {
|
||||
return xml;
|
||||
}
|
||||
int iLen = xml.length();
|
||||
if (iLen == 0) {
|
||||
return xml;
|
||||
}
|
||||
StringBuffer sOUT = new StringBuffer(iLen + 256);
|
||||
int i = 0;
|
||||
for (; i < iLen; i++) {
|
||||
char c = xml.charAt(i);
|
||||
if (c == '<') {
|
||||
sOUT.append("<");
|
||||
} else if (c == '>') {
|
||||
sOUT.append(">");
|
||||
} else if (c == '&') {
|
||||
sOUT.append("&");
|
||||
} else if (c == '"') {
|
||||
sOUT.append(""");
|
||||
} else if (c == '\'') {
|
||||
sOUT.append("'");
|
||||
} else {
|
||||
sOUT.append(c);
|
||||
}
|
||||
}
|
||||
return sOUT.toString();
|
||||
}
|
||||
|
||||
private static String escapeJSON(String str) {
|
||||
if (str == null) {
|
||||
return str;
|
||||
}
|
||||
|
||||
return str.replace("\"", "\\\"");
|
||||
}
|
||||
|
||||
protected long getInstanceIdFromJobSuccessResult(String result) {
|
||||
s_logger.debug("getInstanceIdFromJobSuccessResult not overridden in subclass " + this.getClass().getName());
|
||||
return 0;
|
||||
|
||||
29
api/src/org/apache/cloudstack/api/ResourceDetail.java
Normal file
29
api/src/org/apache/cloudstack/api/ResourceDetail.java
Normal file
@ -0,0 +1,29 @@
|
||||
// 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 org.apache.cloudstack.api;
|
||||
|
||||
public interface ResourceDetail extends InternalIdentity{
|
||||
|
||||
public long getResourceId();
|
||||
|
||||
public String getName();
|
||||
|
||||
public String getValue();
|
||||
|
||||
public boolean isDisplay();
|
||||
|
||||
}
|
||||
@ -102,6 +102,9 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
|
||||
@Parameter(name=ApiConstants.EGRESS_DEFAULT_POLICY, type=CommandType.BOOLEAN, description="true if default guest network egress policy is allow; false if default egress policy is deny")
|
||||
private Boolean egressDefaultPolicy;
|
||||
|
||||
@Parameter(name=ApiConstants.KEEPALIVE_ENABLED, type=CommandType.BOOLEAN, required=false, description="if true keepalive will be turned on in the loadbalancer. At the time of writing this has only an effect on haproxy; the mode http and httpclose options are unset in the haproxy conf file.")
|
||||
private Boolean keepAliveEnabled;
|
||||
|
||||
@Parameter(name=ApiConstants.MAX_CONNECTIONS, type=CommandType.INTEGER, description="maximum number of concurrent connections supported by the network offering")
|
||||
private Integer maxConnections;
|
||||
|
||||
@ -175,6 +178,10 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
|
||||
return egressDefaultPolicy;
|
||||
}
|
||||
|
||||
public Boolean getKeepAliveEnabled() {
|
||||
return keepAliveEnabled;
|
||||
}
|
||||
|
||||
public Integer getMaxconnections() {
|
||||
return maxConnections;
|
||||
}
|
||||
|
||||
@ -57,6 +57,9 @@ public class UpdateNetworkOfferingCmd extends BaseCmd {
|
||||
@Parameter(name=ApiConstants.STATE, type=CommandType.STRING, description="update state for the network offering")
|
||||
private String state;
|
||||
|
||||
@Parameter(name=ApiConstants.KEEPALIVE_ENABLED, type=CommandType.BOOLEAN, required=false, description="if true keepalive will be turned on in the loadbalancer. At the time of writing this has only an effect on haproxy; the mode http and httpclose options are unset in the haproxy conf file.")
|
||||
private Boolean keepAliveEnabled;
|
||||
|
||||
@Parameter(name=ApiConstants.MAX_CONNECTIONS, type=CommandType.INTEGER, description="maximum number of concurrent connections supported by the network offering")
|
||||
private Integer maxConnections;
|
||||
|
||||
@ -91,6 +94,10 @@ public class UpdateNetworkOfferingCmd extends BaseCmd {
|
||||
public Integer getMaxconnections() {
|
||||
return maxConnections;
|
||||
}
|
||||
|
||||
public Boolean getKeepAliveEnabled() {
|
||||
return keepAliveEnabled;
|
||||
}
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@ -49,6 +49,9 @@ public class UpdateDiskOfferingCmd extends BaseCmd{
|
||||
@Parameter(name=ApiConstants.SORT_KEY, type=CommandType.INTEGER, description="sort key of the disk offering, integer")
|
||||
private Integer sortKey;
|
||||
|
||||
@Parameter(name=ApiConstants.DISPLAY_OFFERING, type=CommandType.BOOLEAN, description="an optional field, whether to display the offering to the end user or not.")
|
||||
private Boolean displayOffering;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@ -69,6 +72,9 @@ public class UpdateDiskOfferingCmd extends BaseCmd{
|
||||
return sortKey;
|
||||
}
|
||||
|
||||
public Boolean getDisplayOffering() {
|
||||
return displayOffering;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
|
||||
@ -36,7 +36,7 @@ import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.network.VirtualRouterProvider;
|
||||
import com.cloud.network.VirtualRouterProvider.VirtualRouterProviderType;
|
||||
import com.cloud.network.VirtualRouterProvider.Type;
|
||||
import com.cloud.network.element.VirtualRouterElementService;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
@ -70,15 +70,15 @@ public class CreateVirtualRouterElementCmd extends BaseAsyncCreateCmd {
|
||||
return nspId;
|
||||
}
|
||||
|
||||
public VirtualRouterProviderType getProviderType() {
|
||||
public Type getProviderType() {
|
||||
if (providerType != null) {
|
||||
if (providerType.equalsIgnoreCase(VirtualRouterProviderType.VirtualRouter.toString())) {
|
||||
return VirtualRouterProviderType.VirtualRouter;
|
||||
} else if (providerType.equalsIgnoreCase(VirtualRouterProviderType.VPCVirtualRouter.toString())) {
|
||||
return VirtualRouterProviderType.VPCVirtualRouter;
|
||||
if (providerType.equalsIgnoreCase(Type.VirtualRouter.toString())) {
|
||||
return Type.VirtualRouter;
|
||||
} else if (providerType.equalsIgnoreCase(Type.VPCVirtualRouter.toString())) {
|
||||
return Type.VPCVirtualRouter;
|
||||
} else throw new InvalidParameterValueException("Invalid providerType specified");
|
||||
}
|
||||
return VirtualRouterProviderType.VirtualRouter;
|
||||
return Type.VirtualRouter;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@ -109,6 +109,7 @@ public class ListStoragePoolsCmd extends BaseListCmd {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiCommandJobType getInstanceType() {
|
||||
return ApiCommandJobType.StoragePool;
|
||||
}
|
||||
|
||||
@ -0,0 +1,109 @@
|
||||
// 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 org.apache.cloudstack.api.command.admin.storage;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiCommandJobType;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseAsyncCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.ImageStoreResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.storage.ImageStore;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
@APICommand(name = "prepareSecondaryStorageForMigration", description = "Prepare a NFS secondary storage to migrate to use object store like S3", responseObject = ImageStoreResponse.class)
|
||||
public class PrepareSecondaryStorageForMigrationCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(PrepareSecondaryStorageForMigrationCmd.class.getName());
|
||||
private static final String s_name = "preparesecondarystorageformigrationresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = ImageStoreResponse.class,
|
||||
required = true, description = "Secondary image store ID")
|
||||
private Long id;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiCommandJobType getInstanceType() {
|
||||
return ApiCommandJobType.ImageStore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getInstanceId() {
|
||||
return getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
Account account = CallContext.current().getCallingAccount();
|
||||
if (account != null) {
|
||||
return account.getId();
|
||||
}
|
||||
|
||||
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_MIGRATE_PREPARE_SECONDARY_STORAGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "preparing secondary storage: " + getId() + " for object store migration";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException{
|
||||
ImageStore result = _storageService.prepareSecondaryStorageForObjectStoreMigration(getId());
|
||||
if (result != null){
|
||||
ImageStoreResponse response = _responseGenerator.createImageStoreResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
response.setResponseName("secondarystorage");
|
||||
setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to prepare secondary storage for object store migration");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -39,7 +39,7 @@ import com.cloud.uservm.UserVm;
|
||||
public class AssignVMCmd extends BaseCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(AssignVMCmd.class.getName());
|
||||
|
||||
private static final String s_name = "moveuservmresponse";
|
||||
private static final String s_name = "assignvirtualmachineresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
|
||||
@ -0,0 +1,116 @@
|
||||
// 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 org.apache.cloudstack.api.command.admin.vm;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiCommandJobType;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseAsyncCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.SuccessResponse;
|
||||
import org.apache.cloudstack.api.response.UserVmResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
|
||||
@APICommand(name = "expungeVirtualMachine", description="Expunge a virtual machine. Once expunged, it cannot be recoverd.", responseObject=SuccessResponse.class)
|
||||
public class ExpungeVMCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ExpungeVMCmd.class.getName());
|
||||
|
||||
private static final String s_name = "expungevirtualmachineresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=UserVmResponse.class,
|
||||
required=true, description="The ID of the virtual machine")
|
||||
private Long id;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
UserVm vm = _responseGenerator.findUserVmById(getId());
|
||||
if (vm != null) {
|
||||
return vm.getAccountId();
|
||||
}
|
||||
|
||||
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_VM_EXPUNGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Expunging vm: " + getId();
|
||||
}
|
||||
|
||||
public ApiCommandJobType getInstanceType() {
|
||||
return ApiCommandJobType.VirtualMachine;
|
||||
}
|
||||
|
||||
public Long getInstanceId() {
|
||||
return getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException, ConcurrentOperationException{
|
||||
CallContext.current().setEventDetails("Vm Id: "+getId());
|
||||
try {
|
||||
UserVm result = _userVmService.expungeVm(this);
|
||||
|
||||
if (result != null) {
|
||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to expunge vm");
|
||||
}
|
||||
} catch (InvalidParameterValueException ipve) {
|
||||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ipve.getMessage());
|
||||
} catch (CloudRuntimeException cre) {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, cre.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -153,9 +153,7 @@ public class UpdateNetworkCmd extends BaseAsyncCmd {
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
|
||||
|
||||
StringBuffer eventMsg = new StringBuffer("Updating network: " + getId());
|
||||
StringBuilder eventMsg = new StringBuilder("Updating network: " + getId());
|
||||
if (getNetworkOfferingId() != null) {
|
||||
Network network = _networkService.getNetwork(getId());
|
||||
if (network == null) {
|
||||
|
||||
@ -16,6 +16,11 @@
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.command.user.offering;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseListCmd;
|
||||
@ -24,9 +29,10 @@ import org.apache.cloudstack.api.response.DomainResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
|
||||
import org.apache.cloudstack.api.response.UserVmResponse;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
|
||||
@APICommand(name = "listServiceOfferings", description="Lists all available service offerings.", responseObject=ServiceOfferingResponse.class)
|
||||
public class ListServiceOfferingsCmd extends BaseListCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ListServiceOfferingsCmd.class.getName());
|
||||
@ -98,7 +104,6 @@ public class ListServiceOfferingsCmd extends BaseListCmd {
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
|
||||
ListResponse<ServiceOfferingResponse> response = _queryService.searchForServiceOfferings(this);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
|
||||
@ -0,0 +1,96 @@
|
||||
/*
|
||||
* 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 org.apache.cloudstack.api.command.user.snapshot;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiCommandJobType;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseAsyncCmd;
|
||||
import org.apache.cloudstack.api.BaseCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.SnapshotResponse;
|
||||
import org.apache.cloudstack.api.response.SuccessResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.storage.Snapshot;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
@APICommand(name = "revertSnapshot", description = "revert a volume snapshot.", responseObject = SnapshotResponse.class)
|
||||
public class RevertSnapshotCmd extends BaseAsyncCmd {
|
||||
private static final String s_name = "revertsnapshotresponse";
|
||||
@Parameter(name= ApiConstants.ID, type= BaseCmd.CommandType.UUID, entityType = SnapshotResponse.class,
|
||||
required=true, description="The ID of the snapshot")
|
||||
private Long id;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
Snapshot snapshot = _entityMgr.findById(Snapshot.class, getId());
|
||||
if (snapshot != null) {
|
||||
return snapshot.getAccountId();
|
||||
}
|
||||
|
||||
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_SNAPSHOT_REVERT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "revert snapshot: " + getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiCommandJobType getInstanceType() {
|
||||
return ApiCommandJobType.Snapshot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getInstanceId() {
|
||||
return getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
CallContext.current().setEventDetails("Snapshot Id: "+getId());
|
||||
boolean result = _snapshotService.revertSnapshot(getId());
|
||||
if (result) {
|
||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to revert snapshot");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -20,16 +20,16 @@ import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.response.CreateSSHKeyPairResponse;
|
||||
import org.apache.cloudstack.api.response.DomainResponse;
|
||||
import org.apache.cloudstack.api.response.ProjectResponse;
|
||||
import org.apache.cloudstack.api.response.SSHKeyPairResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.user.SSHKeyPair;
|
||||
|
||||
@APICommand(name = "createSSHKeyPair", description="Create a new keypair and returns the private key", responseObject=SSHKeyPairResponse.class)
|
||||
@APICommand(name = "createSSHKeyPair", description="Create a new keypair and returns the private key", responseObject=CreateSSHKeyPairResponse.class)
|
||||
public class CreateSSHKeyPairCmd extends BaseCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(CreateSSHKeyPairCmd.class.getName());
|
||||
private static final String s_name = "createsshkeypairresponse";
|
||||
@ -91,7 +91,7 @@ public class CreateSSHKeyPairCmd extends BaseCmd {
|
||||
@Override
|
||||
public void execute() {
|
||||
SSHKeyPair r = _mgr.createSSHKeyPair(this);
|
||||
SSHKeyPairResponse response = new SSHKeyPairResponse(r.getName(), r.getFingerprint(), r.getPrivateKey());
|
||||
CreateSSHKeyPairResponse response = new CreateSSHKeyPairResponse(r.getName(), r.getFingerprint(), r.getPrivateKey());
|
||||
response.setResponseName(getCommandName());
|
||||
response.setObjectName("keypair");
|
||||
this.setResponseObject(response);
|
||||
|
||||
@ -34,7 +34,7 @@ import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.server.ResourceTag;
|
||||
import com.cloud.server.ResourceTag.TaggedResourceType;
|
||||
import com.cloud.server.ResourceTag.ResourceObjectType;
|
||||
@APICommand(name = "createTags", description = "Creates resource tag(s)", responseObject = SuccessResponse.class, since = "4.0.0")
|
||||
public class CreateTagsCmd extends BaseAsyncCmd{
|
||||
public static final Logger s_logger = Logger.getLogger(CreateTagsCmd.class.getName());
|
||||
@ -64,7 +64,7 @@ public class CreateTagsCmd extends BaseAsyncCmd{
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public TaggedResourceType getResourceType(){
|
||||
public ResourceObjectType getResourceType(){
|
||||
return _taggedResourceService.getResourceType(resourceType);
|
||||
}
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ import org.apache.cloudstack.api.response.SuccessResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.server.ResourceTag.TaggedResourceType;
|
||||
import com.cloud.server.ResourceTag.ResourceObjectType;
|
||||
@APICommand(name = "deleteTags", description = "Deleting resource tag(s)", responseObject = SuccessResponse.class, since = "4.0.0")
|
||||
public class DeleteTagsCmd extends BaseAsyncCmd{
|
||||
public static final Logger s_logger = Logger.getLogger(DeleteTagsCmd.class.getName());
|
||||
@ -59,7 +59,7 @@ public class DeleteTagsCmd extends BaseAsyncCmd{
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public TaggedResourceType getResourceType(){
|
||||
public ResourceObjectType getResourceType(){
|
||||
return _taggedResourceService.getResourceType(resourceType);
|
||||
}
|
||||
|
||||
|
||||
@ -16,6 +16,8 @@
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.command.user.vm;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiCommandJobType;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
@ -25,13 +27,11 @@ import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.UserVmResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.uservm.UserVm;
|
||||
|
||||
@ -49,6 +49,11 @@ public class DestroyVMCmd extends BaseAsyncCmd {
|
||||
required=true, description="The ID of the virtual machine")
|
||||
private Long id;
|
||||
|
||||
|
||||
@Parameter(name=ApiConstants.EXPUNGE, type=CommandType.BOOLEAN,
|
||||
description="If true is passed, the vm is expunged immediately. False by default. Parameter can be passed to the call by ROOT/Domain admin only", since="4.2.1")
|
||||
private Boolean expunge;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@ -57,6 +62,13 @@ public class DestroyVMCmd extends BaseAsyncCmd {
|
||||
return id;
|
||||
}
|
||||
|
||||
public boolean getExpunge() {
|
||||
if (expunge == null) {
|
||||
return false;
|
||||
}
|
||||
return expunge;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@ -97,11 +109,14 @@ public class DestroyVMCmd extends BaseAsyncCmd {
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException, ConcurrentOperationException{
|
||||
CallContext.current().setEventDetails("Vm Id: "+getId());
|
||||
UserVm result;
|
||||
result = _userVmService.destroyVm(this);
|
||||
UserVm result = _userVmService.destroyVm(this);
|
||||
|
||||
UserVmResponse response = new UserVmResponse();
|
||||
if (result != null) {
|
||||
UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0);
|
||||
List<UserVmResponse> responses = _responseGenerator.createUserVmResponse("virtualmachine", result);
|
||||
if (responses != null && !responses.isEmpty()) {
|
||||
response = responses.get(0);
|
||||
}
|
||||
response.setResponseName("virtualmachine");
|
||||
this.setResponseObject(response);
|
||||
} else {
|
||||
|
||||
@ -71,7 +71,7 @@ public class AddResourceDetailCmd extends BaseAsyncCmd {
|
||||
return detailsMap;
|
||||
}
|
||||
|
||||
public ResourceTag.TaggedResourceType getResourceType() {
|
||||
public ResourceTag.ResourceObjectType getResourceType() {
|
||||
return _taggedResourceService.getResourceType(resourceType);
|
||||
}
|
||||
|
||||
|
||||
@ -17,7 +17,8 @@
|
||||
|
||||
package org.apache.cloudstack.api.command.user.volume;
|
||||
|
||||
import com.cloud.server.ResourceTag;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseListProjectAndAccountResourcesCmd;
|
||||
@ -25,39 +26,26 @@ import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.ResourceDetailResponse;
|
||||
import org.apache.cloudstack.api.response.ResourceTagResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
|
||||
import java.util.List;
|
||||
import com.cloud.server.ResourceTag;
|
||||
|
||||
@APICommand(name = "listResourceDetails", description = "List resource detail(s)", responseObject = ResourceTagResponse.class, since = "4.2")
|
||||
public class ListResourceDetailsCmd extends BaseListProjectAndAccountResourcesCmd{
|
||||
private static final String s_name = "listresourcedetailsresponse";
|
||||
|
||||
@Parameter(name=ApiConstants.RESOURCE_TYPE, type=CommandType.STRING, description="list by resource type")
|
||||
@Parameter(name=ApiConstants.RESOURCE_TYPE, type=CommandType.STRING, description="list by resource type", required=true)
|
||||
private String resourceType;
|
||||
|
||||
@Parameter(name=ApiConstants.RESOURCE_ID, type=CommandType.STRING, description="list by resource id")
|
||||
@Parameter(name=ApiConstants.RESOURCE_ID, type=CommandType.STRING, description="list by resource id", required=true)
|
||||
private String resourceId;
|
||||
|
||||
@Parameter(name=ApiConstants.KEY, type=CommandType.STRING, description="list by key")
|
||||
private String key;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
|
||||
ListResponse<ResourceDetailResponse> response = new ListResponse<ResourceDetailResponse>();
|
||||
List<ResourceDetailResponse> resourceDetailResponse = _queryService.listResource(this);
|
||||
response.setResponses(resourceDetailResponse);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
|
||||
public ResourceTag.TaggedResourceType getResourceType() {
|
||||
return _taggedResourceService.getResourceType(resourceType);
|
||||
}
|
||||
@Parameter(name=ApiConstants.FOR_DISPLAY, type=CommandType.BOOLEAN, description="if set to true, only details marked with display=true, are returned." +
|
||||
" Always false is the call is made by the regular user", since="4.3")
|
||||
private Boolean forDisplay;
|
||||
|
||||
public String getResourceId() {
|
||||
return resourceId;
|
||||
@ -72,4 +60,32 @@ public class ListResourceDetailsCmd extends BaseListProjectAndAccountResourcesCm
|
||||
return s_name;
|
||||
}
|
||||
|
||||
public Boolean forDisplay() {
|
||||
if (!_accountService.isAdmin(CallContext.current().getCallingAccount().getType())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return forDisplay;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
|
||||
ListResponse<ResourceDetailResponse> response = new ListResponse<ResourceDetailResponse>();
|
||||
List<ResourceDetailResponse> resourceDetailResponse = _queryService.listResourceDetails(this);
|
||||
response.setResponses(resourceDetailResponse);
|
||||
response.setResponseName(getCommandName());
|
||||
this.setResponseObject(response);
|
||||
}
|
||||
|
||||
public ResourceTag.ResourceObjectType getResourceType() {
|
||||
return _taggedResourceService.getResourceType(resourceType);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -16,32 +16,21 @@
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.command.user.volume;
|
||||
|
||||
import com.cloud.server.ResourceTag;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiCommandJobType;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseAsyncCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.SuccessResponse;
|
||||
import org.apache.cloudstack.api.response.UserVmResponse;
|
||||
import org.apache.cloudstack.api.response.VolumeResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.storage.Volume;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
import java.util.*;
|
||||
import com.cloud.server.ResourceTag;
|
||||
|
||||
@APICommand(name = "removeResourceDetail", description="Removes detail for the Resource.", responseObject=SuccessResponse.class)
|
||||
public class RemoveResourceDetailCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(RemoveResourceDetailCmd.class.getName());
|
||||
private static final String s_name = "RemoveResourceDetailresponse";
|
||||
private static final String s_name = "removeresourcedetailresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
@ -62,7 +51,7 @@ public class RemoveResourceDetailCmd extends BaseAsyncCmd {
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public ResourceTag.TaggedResourceType getResourceType(){
|
||||
public ResourceTag.ResourceObjectType getResourceType(){
|
||||
return _taggedResourceService.getResourceType(resourceType);
|
||||
}
|
||||
|
||||
|
||||
@ -23,33 +23,40 @@ import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseAsyncCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.UserVmResponse;
|
||||
import org.apache.cloudstack.api.response.StoragePoolResponse;
|
||||
import org.apache.cloudstack.api.response.VolumeResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.storage.Volume;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
@APICommand(name = "updateVolume", description="Updates the volume.", responseObject=VolumeResponse.class)
|
||||
public class UpdateVolumeCmd extends BaseAsyncCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(UpdateVolumeCmd.class.getName());
|
||||
private static final String s_name = "addVolumeresponse";
|
||||
private static final String s_name = "updatevolumeresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=VolumeResponse.class,
|
||||
required=true, description="the ID of the disk volume")
|
||||
@Parameter(name=ApiConstants.ID, type=CommandType.UUID, entityType=VolumeResponse.class, description="the ID of the disk volume")
|
||||
private Long id;
|
||||
|
||||
@Parameter(name=ApiConstants.PATH, type=CommandType.STRING,
|
||||
required=true, description="the path of the volume")
|
||||
@Parameter(name=ApiConstants.PATH, type=CommandType.STRING, description="The path of the volume")
|
||||
private String path;
|
||||
|
||||
@Parameter(name=ApiConstants.STORAGE_ID, type=CommandType.UUID, entityType=StoragePoolResponse.class,
|
||||
description="Destination storage pool UUID for the volume", since="4.3")
|
||||
private Long storageId;
|
||||
|
||||
@Parameter(name=ApiConstants.STATE, type=CommandType.STRING, description="The state of the volume", since="4.3")
|
||||
private String state;
|
||||
|
||||
@Parameter(name=ApiConstants.DISPLAY_VOLUME, type=CommandType.BOOLEAN, description="an optional field, whether to the display the volume to the end user or not.")
|
||||
private Boolean displayVolume;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@ -62,6 +69,18 @@ public class UpdateVolumeCmd extends BaseAsyncCmd {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Long getStorageId() {
|
||||
return storageId;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public Boolean getDisplayVolume() {
|
||||
return displayVolume;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@ -83,25 +102,37 @@ public class UpdateVolumeCmd extends BaseAsyncCmd {
|
||||
public long getEntityOwnerId() {
|
||||
Volume volume = _responseGenerator.findVolumeById(getId());
|
||||
if (volume == null) {
|
||||
return Account.ACCOUNT_ID_SYSTEM; // bad id given, parent this command to SYSTEM so ERROR events are tracked
|
||||
throw new InvalidParameterValueException("Invalid volume id was provided");
|
||||
}
|
||||
return volume.getAccountId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventType() {
|
||||
return EventTypes.EVENT_VOLUME_ATTACH;
|
||||
return EventTypes.EVENT_VOLUME_UPDATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "adding detail to the volume: " + getId();
|
||||
StringBuilder desc = new StringBuilder("Updating volume: ");
|
||||
desc.append(getId()).append(" with");
|
||||
if (getPath() != null) {
|
||||
desc.append(" path " + getPath());
|
||||
}
|
||||
if (getStorageId() != null) {
|
||||
desc.append(", storage id " + getStorageId());
|
||||
}
|
||||
|
||||
if (getState() != null) {
|
||||
desc.append(", state " + getState());
|
||||
}
|
||||
return desc.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(){
|
||||
CallContext.current().setEventDetails("Volume Id: "+getId());
|
||||
Volume result = _volumeService.updateVolume(this);
|
||||
Volume result = _volumeService.updateVolume(getId(), getPath(), getState(), getStorageId(), getDisplayVolume());
|
||||
if (result != null) {
|
||||
VolumeResponse response = _responseGenerator.createVolumeResponse(result);
|
||||
response.setResponseName(getCommandName());
|
||||
|
||||
@ -126,25 +126,10 @@ public class CreateRemoteAccessVpnCmd extends BaseAsyncCreateCmd {
|
||||
return EventTypes.EVENT_REMOTE_ACCESS_VPN_CREATE;
|
||||
}
|
||||
|
||||
public long getNetworkId() {
|
||||
IpAddress ip = _entityMgr.findById(IpAddress.class, getPublicIpId());
|
||||
Long ntwkId = null;
|
||||
|
||||
if (ip.getAssociatedWithNetworkId() != null) {
|
||||
ntwkId = ip.getAssociatedWithNetworkId();
|
||||
}
|
||||
|
||||
if (ntwkId == null) {
|
||||
throw new InvalidParameterValueException("Unable to create remote access vpn for the ipAddress id=" + getPublicIpId() +
|
||||
" as ip is not associated with any network and no networkId is passed in");
|
||||
}
|
||||
return ntwkId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create() {
|
||||
try {
|
||||
RemoteAccessVpn vpn = _ravService.createRemoteAccessVpn(publicIpId, ipRange, getOpenFirewall(), getNetworkId());
|
||||
RemoteAccessVpn vpn = _ravService.createRemoteAccessVpn(publicIpId, ipRange, getOpenFirewall());
|
||||
if (vpn != null) {
|
||||
this.setEntityId(vpn.getServerAddressId());
|
||||
// find uuid for server ip address
|
||||
|
||||
@ -16,21 +16,21 @@
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.command.user.zone;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseListCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.BaseCmd.CommandType;
|
||||
import org.apache.cloudstack.api.response.DomainResponse;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.cloudstack.api.response.ServiceOfferingResponse;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
|
||||
@APICommand(name = "listZones", description="Lists zones", responseObject=ZoneResponse.class)
|
||||
public class ListZonesByCmd extends BaseListCmd {
|
||||
@ -63,6 +63,9 @@ public class ListZonesByCmd extends BaseListCmd {
|
||||
@Parameter(name=ApiConstants.SHOW_CAPACITIES, type=CommandType.BOOLEAN, description="flag to display the capacity of the zones")
|
||||
private Boolean showCapacities;
|
||||
|
||||
@Parameter(name = ApiConstants.TAGS, type = CommandType.MAP, description = "List zones by resource tags (key/value pairs)", since="4.3")
|
||||
private Map tags;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@ -91,6 +94,25 @@ public class ListZonesByCmd extends BaseListCmd {
|
||||
return showCapacities;
|
||||
}
|
||||
|
||||
public Map<String, String> getTags() {
|
||||
Map<String, String> tagsMap = null;
|
||||
if (tags != null && !tags.isEmpty()) {
|
||||
tagsMap = new HashMap<String, String>();
|
||||
Collection<?> servicesCollection = tags.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");
|
||||
if (value == null) {
|
||||
throw new InvalidParameterValueException("No value is passed in for key " + key);
|
||||
}
|
||||
tagsMap.put(key, value);
|
||||
}
|
||||
}
|
||||
return tagsMap;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@ -0,0 +1,41 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.response;
|
||||
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class CreateSSHKeyPairResponse extends SSHKeyPairResponse {
|
||||
|
||||
@SerializedName("privatekey") @Param(description="Private key")
|
||||
private String privateKey;
|
||||
|
||||
public CreateSSHKeyPairResponse() {}
|
||||
|
||||
public CreateSSHKeyPairResponse(String name, String fingerprint, String privateKey) {
|
||||
super(name, fingerprint);
|
||||
this.privateKey = privateKey;
|
||||
}
|
||||
|
||||
public String getPrivateKey() {
|
||||
return privateKey;
|
||||
}
|
||||
|
||||
public void setPrivateKey(String privateKey) {
|
||||
this.privateKey = privateKey;
|
||||
}
|
||||
}
|
||||
@ -16,14 +16,8 @@
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.response;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
import org.apache.cloudstack.api.EntityReference;
|
||||
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
@ -47,6 +41,11 @@ public class ResourceDetailResponse extends BaseResponse{
|
||||
@Param(description = "value of the resource detail")
|
||||
private String value;
|
||||
|
||||
|
||||
@SerializedName(ApiConstants.FOR_DISPLAY)
|
||||
@Param(description = "if detail is returned to the regular user", since="4.3")
|
||||
private boolean forDisplay;
|
||||
|
||||
public String getResourceId() {
|
||||
return resourceId;
|
||||
}
|
||||
@ -78,4 +77,8 @@ public class ResourceDetailResponse extends BaseResponse{
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public void setForDisplay(boolean forDisplay) {
|
||||
this.forDisplay = forDisplay;
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,19 +30,11 @@ public class SSHKeyPairResponse extends BaseResponse {
|
||||
@SerializedName("fingerprint") @Param(description="Fingerprint of the public key")
|
||||
private String fingerprint;
|
||||
|
||||
@SerializedName("privatekey") @Param(description="Private key")
|
||||
private String privateKey;
|
||||
|
||||
public SSHKeyPairResponse() {}
|
||||
|
||||
public SSHKeyPairResponse(String name, String fingerprint) {
|
||||
this(name, fingerprint, null);
|
||||
}
|
||||
|
||||
public SSHKeyPairResponse(String name, String fingerprint, String privateKey) {
|
||||
this.name = name;
|
||||
this.fingerprint = fingerprint;
|
||||
this.privateKey = privateKey;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@ -61,12 +53,4 @@ public class SSHKeyPairResponse extends BaseResponse {
|
||||
this.fingerprint = fingerprint;
|
||||
}
|
||||
|
||||
public String getPrivateKey() {
|
||||
return privateKey;
|
||||
}
|
||||
|
||||
public void setPrivateKey(String privateKey) {
|
||||
this.privateKey = privateKey;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -17,19 +17,15 @@
|
||||
package org.apache.cloudstack.api.response;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
import org.apache.cloudstack.api.EntityReference;
|
||||
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
@EntityReference(value = ServiceOffering.class)
|
||||
public class ServiceOfferingResponse extends BaseResponse {
|
||||
@ -109,6 +105,10 @@ public class ServiceOfferingResponse extends BaseResponse {
|
||||
@Param(description = "additional key/value details tied with this service offering", since = "4.2.0")
|
||||
private Map<String, String> details;
|
||||
|
||||
|
||||
public ServiceOfferingResponse(){
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
@ -287,4 +287,5 @@ public class ServiceOfferingResponse extends BaseResponse {
|
||||
public void setDetails(Map<String, String> details) {
|
||||
this.details = details;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -26,18 +26,8 @@ import org.apache.cloudstack.api.EntityReference;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.cloud.storage.Snapshot;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.cloud.serializer.Param;
|
||||
import com.cloud.storage.Snapshot;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
import org.apache.cloudstack.api.EntityReference;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@EntityReference(value=Snapshot.class)
|
||||
@SuppressWarnings("unused")
|
||||
public class SnapshotResponse extends BaseResponse implements ControlledEntityResponse {
|
||||
@SerializedName(ApiConstants.ID)
|
||||
@Param(description = "ID of the snapshot")
|
||||
@ -100,6 +90,9 @@ public class SnapshotResponse extends BaseResponse implements ControlledEntityRe
|
||||
@SerializedName(ApiConstants.TAGS) @Param(description="the list of resource tags associated with snapshot", responseObject = ResourceTagResponse.class)
|
||||
private List<ResourceTagResponse> tags;
|
||||
|
||||
@SerializedName(ApiConstants.REVERTABLE)
|
||||
@Param(description="indicates whether the underlying storage supports reverting the volume to this snapshot")
|
||||
private boolean revertable;
|
||||
|
||||
@Override
|
||||
public String getObjectId() {
|
||||
@ -118,6 +111,7 @@ public class SnapshotResponse extends BaseResponse implements ControlledEntityRe
|
||||
return accountName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAccountName(String accountName) {
|
||||
this.accountName = accountName;
|
||||
}
|
||||
@ -131,6 +125,7 @@ public class SnapshotResponse extends BaseResponse implements ControlledEntityRe
|
||||
this.domainId = domainId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDomainName(String domainName) {
|
||||
this.domainName = domainName;
|
||||
}
|
||||
@ -184,4 +179,12 @@ public class SnapshotResponse extends BaseResponse implements ControlledEntityRe
|
||||
public void setTags(List<ResourceTagResponse> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
public boolean isRevertable() {
|
||||
return revertable;
|
||||
}
|
||||
|
||||
public void setRevertable(boolean revertable) {
|
||||
this.revertable = revertable;
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@ package org.apache.cloudstack.api.response;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.cloudstack.affinity.AffinityGroupResponse;
|
||||
@ -178,6 +179,9 @@ public class UserVmResponse extends BaseResponse implements ControlledEntityResp
|
||||
@SerializedName(ApiConstants.TAGS) @Param(description="the list of resource tags associated with vm", responseObject = ResourceTagResponse.class)
|
||||
private Set<ResourceTagResponse> tags;
|
||||
|
||||
@SerializedName(ApiConstants.DETAILS) @Param(description="Template details in key/value pairs.", since="4.2.1")
|
||||
private Map details;
|
||||
|
||||
@SerializedName(ApiConstants.SSH_KEYPAIR) @Param(description="ssh key-pair")
|
||||
private String keyPairName;
|
||||
|
||||
@ -654,4 +658,7 @@ public class UserVmResponse extends BaseResponse implements ControlledEntityResp
|
||||
this.serviceState = state;
|
||||
}
|
||||
|
||||
public void setDetails(Map details) {
|
||||
this.details = details;
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,7 +17,6 @@
|
||||
package org.apache.cloudstack.api.response;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@ -178,12 +177,30 @@ public class VolumeResponse extends BaseResponse implements ControlledViewEntity
|
||||
@Param(description="the status of the volume")
|
||||
private String status;
|
||||
|
||||
@SerializedName(ApiConstants.TAGS) @Param(description="the list of resource tags associated with volume", responseObject = ResourceTagResponse.class)
|
||||
@SerializedName(ApiConstants.TAGS)
|
||||
@Param(description="the list of resource tags associated with volume", responseObject = ResourceTagResponse.class)
|
||||
private Set<ResourceTagResponse> tags;
|
||||
|
||||
@SerializedName(ApiConstants.DISPLAY_VOLUME) @Param(description="an optional field whether to the display the volume to the end user or not.")
|
||||
@SerializedName(ApiConstants.DISPLAY_VOLUME)
|
||||
@Param(description="an optional field whether to the display the volume to the end user or not.")
|
||||
private Boolean displayVm;
|
||||
|
||||
@SerializedName(ApiConstants.PATH)
|
||||
@Param(description="The path of the volume")
|
||||
private String path;
|
||||
|
||||
@SerializedName(ApiConstants.STORAGE_ID)
|
||||
@Param(description = "id of the primary storage hosting the disk volume; returned to admin user only", since="4.3")
|
||||
private String storagePoolId;
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public VolumeResponse(){
|
||||
tags = new LinkedHashSet<ResourceTagResponse>();
|
||||
}
|
||||
@ -388,4 +405,7 @@ public class VolumeResponse extends BaseResponse implements ControlledViewEntity
|
||||
this.displayVm = displayVm;
|
||||
}
|
||||
|
||||
public void setStoragePoolId(String storagePoolId) {
|
||||
this.storagePoolId = storagePoolId;
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,7 +16,10 @@
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.response;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
@ -99,6 +102,19 @@ public class ZoneResponse extends BaseResponse {
|
||||
@SerializedName(ApiConstants.LOCAL_STORAGE_ENABLED) @Param(description="true if local storage offering enabled, false otherwise")
|
||||
private boolean localStorageEnabled;
|
||||
|
||||
@SerializedName(ApiConstants.TAGS) @Param(description="the list of resource tags associated with zone.",
|
||||
responseObject = ResourceTagResponse.class, since="4.3")
|
||||
private Set<ResourceTagResponse> tags;
|
||||
|
||||
@SerializedName(ApiConstants.RESOURCE_DETAILS)
|
||||
@Param(description = "Meta data associated with the zone (key/value pairs)", since = "4.3.0")
|
||||
private Map<String, String> resourceDetails;
|
||||
|
||||
|
||||
public ZoneResponse(){
|
||||
tags = new LinkedHashSet<ResourceTagResponse>();
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
@ -198,4 +214,12 @@ public class ZoneResponse extends BaseResponse {
|
||||
public void setIp6Dns2(String ip6Dns2) {
|
||||
this.ip6Dns2 = ip6Dns2;
|
||||
}
|
||||
|
||||
public void addTag(ResourceTagResponse tag){
|
||||
this.tags.add(tag);
|
||||
}
|
||||
|
||||
public void setResourceDetails(Map<String, String> details) {
|
||||
this.resourceDetails = details;
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,8 +18,10 @@ package org.apache.cloudstack.context;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Stack;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.cloudstack.managed.threadlocal.ManagedThreadLocal;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.NDC;
|
||||
|
||||
@ -37,18 +39,27 @@ import com.cloud.utils.exception.CloudRuntimeException;
|
||||
*/
|
||||
public class CallContext {
|
||||
private static final Logger s_logger = Logger.getLogger(CallContext.class);
|
||||
private static ThreadLocal<CallContext> s_currentContext = new ThreadLocal<CallContext>();
|
||||
private static ManagedThreadLocal<CallContext> s_currentContext = new ManagedThreadLocal<CallContext>();
|
||||
private static ManagedThreadLocal<Stack<CallContext>> s_currentContextStack =
|
||||
new ManagedThreadLocal<Stack<CallContext>>() {
|
||||
@Override
|
||||
protected Stack<CallContext> initialValue() {
|
||||
return new Stack<CallContext>();
|
||||
}
|
||||
};
|
||||
|
||||
private String contextId;
|
||||
private Account account;
|
||||
private long accountId;
|
||||
private long startEventId = 0;
|
||||
private String eventDescription;
|
||||
private String eventDetails;
|
||||
private String eventType;
|
||||
private User user;
|
||||
private long userId;
|
||||
private final Map<Object, Object> context = new HashMap<Object, Object>();
|
||||
|
||||
private static EntityManager s_entityMgr;
|
||||
static EntityManager s_entityMgr;
|
||||
|
||||
public static void init(EntityManager entityMgr) {
|
||||
s_entityMgr = entityMgr;
|
||||
@ -57,9 +68,17 @@ public class CallContext {
|
||||
protected CallContext() {
|
||||
}
|
||||
|
||||
protected CallContext(long userId, long accountId, String contextId) {
|
||||
this.userId = userId;
|
||||
this.accountId = accountId;
|
||||
this.contextId = contextId;
|
||||
}
|
||||
|
||||
protected CallContext(User user, Account account, String contextId) {
|
||||
this.user = user;
|
||||
this.userId = user.getId();
|
||||
this.account = account;
|
||||
this.accountId = account.getId();
|
||||
this.contextId = contextId;
|
||||
}
|
||||
|
||||
@ -72,10 +91,13 @@ public class CallContext {
|
||||
}
|
||||
|
||||
public long getCallingUserId() {
|
||||
return user.getId();
|
||||
return userId;
|
||||
}
|
||||
|
||||
public User getCallingUser() {
|
||||
if (user == null) {
|
||||
user = s_entityMgr.findById(User.class, userId);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
@ -84,6 +106,9 @@ public class CallContext {
|
||||
}
|
||||
|
||||
public Account getCallingAccount() {
|
||||
if (account == null) {
|
||||
account = s_entityMgr.findById(Account.class, accountId);
|
||||
}
|
||||
return account;
|
||||
}
|
||||
|
||||
@ -101,6 +126,10 @@ public class CallContext {
|
||||
* @return CallContext
|
||||
*/
|
||||
public static CallContext register(User callingUser, Account callingAccount, String contextId) {
|
||||
return register(callingUser, callingAccount, null, null, contextId);
|
||||
}
|
||||
|
||||
protected static CallContext register(User callingUser, Account callingAccount, Long userId, Long accountId, String contextId) {
|
||||
/*
|
||||
Unit tests will have multiple times of setup/tear-down call to this, remove assertions to all unit test to run
|
||||
|
||||
@ -109,12 +138,20 @@ public class CallContext {
|
||||
throw new CloudRuntimeException("There's a context already so what does this new register context mean? " + s_currentContext.get().toString());
|
||||
}
|
||||
*/
|
||||
CallContext callingContext = new CallContext(callingUser, callingAccount, contextId);
|
||||
CallContext callingContext = null;
|
||||
if (userId == null || accountId == null) {
|
||||
callingContext = new CallContext(callingUser, callingAccount, contextId);
|
||||
} else {
|
||||
callingContext = new CallContext(userId, accountId, contextId);
|
||||
}
|
||||
s_currentContext.set(callingContext);
|
||||
NDC.push("ctx-" + UuidUtils.first(contextId));
|
||||
if (s_logger.isTraceEnabled()) {
|
||||
s_logger.trace("Registered: " + callingContext);
|
||||
}
|
||||
|
||||
s_currentContextStack.get().push(callingContext);
|
||||
|
||||
return callingContext;
|
||||
}
|
||||
|
||||
@ -126,14 +163,13 @@ public class CallContext {
|
||||
try {
|
||||
CallContext context = s_currentContext.get();
|
||||
if (context == null) {
|
||||
return register(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM);
|
||||
return register(null, null, User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, UUID.randomUUID().toString());
|
||||
}
|
||||
assert context.getCallingUserId() == User.UID_SYSTEM : "You are calling a very specific method that registers a one time system context. This method is meant for background threads that does processing.";
|
||||
return context;
|
||||
} catch (Exception e) {
|
||||
s_logger.fatal("Exiting the system because we're unable to register the system call context.", e);
|
||||
System.exit(1);
|
||||
throw new CloudRuntimeException("Should never hit this");
|
||||
s_logger.error("Failed to register the system call context.", e);
|
||||
throw new CloudRuntimeException("Failed to register system call context", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -162,10 +198,15 @@ public class CallContext {
|
||||
return register(user, account);
|
||||
}
|
||||
|
||||
public static void unregisterAll() {
|
||||
while ( unregister() != null ) {
|
||||
// NOOP
|
||||
}
|
||||
}
|
||||
|
||||
public static CallContext unregister() {
|
||||
CallContext context = s_currentContext.get();
|
||||
if (context == null) {
|
||||
s_logger.debug("No context to remove");
|
||||
return null;
|
||||
}
|
||||
s_currentContext.remove();
|
||||
@ -183,6 +224,14 @@ public class CallContext {
|
||||
s_logger.trace("Popping from NDC: " + contextId);
|
||||
}
|
||||
}
|
||||
|
||||
Stack<CallContext> stack = s_currentContextStack.get();
|
||||
stack.pop();
|
||||
|
||||
if ( ! stack.isEmpty() ) {
|
||||
s_currentContext.set(stack.peek());
|
||||
}
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
@ -195,15 +244,15 @@ public class CallContext {
|
||||
}
|
||||
|
||||
public long getCallingAccountId() {
|
||||
return account.getId();
|
||||
return accountId;
|
||||
}
|
||||
|
||||
public String getCallingAccountUuid() {
|
||||
return account.getUuid();
|
||||
return getCallingAccount().getUuid();
|
||||
}
|
||||
|
||||
public String getCallingUserUuid() {
|
||||
return user.getUuid();
|
||||
return getCallingUser().getUuid();
|
||||
}
|
||||
|
||||
public void setEventDetails(String eventDetails) {
|
||||
@ -240,8 +289,8 @@ public class CallContext {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new StringBuffer("CCtxt[acct=").append(account.getId())
|
||||
.append("; user=").append(user.getId())
|
||||
return new StringBuilder("CCtxt[acct=").append(getCallingAccountId())
|
||||
.append("; user=").append(getCallingUserId())
|
||||
.append("; id=").append(contextId)
|
||||
.append("]").toString();
|
||||
}
|
||||
|
||||
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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 org.apache.cloudstack.context;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.managed.context.ManagedContextListener;
|
||||
|
||||
import com.cloud.utils.db.EntityManager;
|
||||
|
||||
public class CallContextListener implements ManagedContextListener<Object> {
|
||||
|
||||
@Inject
|
||||
EntityManager entityMgr;
|
||||
|
||||
@Override
|
||||
public Object onEnterContext(boolean reentry) {
|
||||
if ( ! reentry ) {
|
||||
CallContext.registerSystemCallContextOnceOnly();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLeaveContext(Object unused, boolean reentry) {
|
||||
if ( ! reentry ) {
|
||||
CallContext.unregisterAll();
|
||||
}
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
CallContext.init(entityMgr);
|
||||
}
|
||||
}
|
||||
@ -123,7 +123,7 @@ public interface QueryService {
|
||||
String affinityGroupType, Long vmId, String accountName, Long domainId, boolean isRecursive,
|
||||
boolean listAll, Long startIndex, Long pageSize);
|
||||
|
||||
public List<ResourceDetailResponse> listResource(ListResourceDetailsCmd cmd);
|
||||
public List<ResourceDetailResponse> listResourceDetails(ListResourceDetailsCmd cmd);
|
||||
|
||||
ListResponse<DomainRouterResponse> searchForInternalLbVms(ListInternalLBVMsCmd cmd);
|
||||
|
||||
|
||||
@ -16,7 +16,9 @@
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>cloud-awsapi</artifactId>
|
||||
<name>Apache CloudStack AWS API Bridge</name>
|
||||
@ -35,7 +37,6 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
<version>${org.springframework.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.axis2</groupId>
|
||||
@ -72,7 +73,6 @@
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>${cs.log4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
@ -102,17 +102,14 @@
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>${cs.gson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>${cs.codec.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>${cs.servlet.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -123,7 +120,6 @@
|
||||
<dependency>
|
||||
<groupId>org.jasypt</groupId>
|
||||
<artifactId>jasypt</artifactId>
|
||||
<version>${cs.jasypt.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.caringo.client</groupId>
|
||||
@ -275,6 +271,7 @@
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk16</artifactId>
|
||||
<!-- TODO: do we need this explicit version override? -->
|
||||
<version>1.45</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
@ -358,7 +355,6 @@
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<version>1.7</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>generate-resource</id>
|
||||
@ -368,17 +364,14 @@
|
||||
</goals>
|
||||
<configuration>
|
||||
<target>
|
||||
<copy
|
||||
todir="${basedir}/target/generated-webapp/WEB-INF/classes">
|
||||
<copy todir="${basedir}/target/generated-webapp/WEB-INF/classes">
|
||||
<fileset dir="${basedir}/conf">
|
||||
<include name="*.*"/>
|
||||
</fileset>
|
||||
<globmapper from="*.in" to="*"/>
|
||||
<filterchain>
|
||||
<filterreader
|
||||
classname="org.apache.tools.ant.filters.ReplaceTokens">
|
||||
<param type="propertiesfile"
|
||||
value="${cs.replace.properties}" />
|
||||
<filterreader classname="org.apache.tools.ant.filters.ReplaceTokens">
|
||||
<param type="propertiesfile" value="${cs.replace.properties}"/>
|
||||
</filterreader>
|
||||
</filterchain>
|
||||
</copy>
|
||||
@ -426,12 +419,8 @@
|
||||
<pluginExecutions>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>
|
||||
org.apache.maven.plugins
|
||||
</groupId>
|
||||
<artifactId>
|
||||
maven-antrun-plugin
|
||||
</artifactId>
|
||||
<groupId> org.apache.maven.plugins </groupId>
|
||||
<artifactId> maven-antrun-plugin </artifactId>
|
||||
<versionRange>[1.7,)</versionRange>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
@ -485,12 +474,8 @@
|
||||
<!-- Create the WSDL directory structure used by codegen -->
|
||||
<mkdir dir="wsdl"/>
|
||||
<echo message="Downloading 2012-08-15.ec2-wsdl..."/>
|
||||
<get
|
||||
src="http://s3.amazonaws.com/ec2-downloads/2012-08-15.ec2.wsdl"
|
||||
dest="${basedir}/wsdl/"
|
||||
verbose="true"
|
||||
usetimestamp="true"
|
||||
/>
|
||||
<get src="http://s3.amazonaws.com/ec2-downloads/2012-08-15.ec2.wsdl"
|
||||
dest="${basedir}/wsdl/" verbose="true" usetimestamp="true"/>
|
||||
</target>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
@ -26,7 +26,7 @@ import com.cloud.bridge.model.BucketPolicyVO;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
|
||||
@Component
|
||||
@Local(value={BucketPolicyDao.class})
|
||||
@ -42,7 +42,7 @@ public class BucketPolicyDaoImpl extends GenericDaoBase<BucketPolicyVO, Long> im
|
||||
public BucketPolicyVO getByName( String bucketName ) {
|
||||
SearchBuilder <BucketPolicyVO> searchByBucket = createSearchBuilder();
|
||||
searchByBucket.and("BucketName", searchByBucket.entity().getBucketName(), SearchCriteria.Op.EQ);
|
||||
Transaction txn = Transaction.open(Transaction.AWSAPI_DB);
|
||||
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
try {
|
||||
txn.start();
|
||||
SearchCriteria<BucketPolicyVO> sc = searchByBucket.create();
|
||||
@ -59,7 +59,7 @@ public class BucketPolicyDaoImpl extends GenericDaoBase<BucketPolicyVO, Long> im
|
||||
public void deletePolicy( String bucketName ) {
|
||||
SearchBuilder <BucketPolicyVO> deleteByBucket = createSearchBuilder();
|
||||
deleteByBucket.and("BucketName", deleteByBucket.entity().getBucketName(), SearchCriteria.Op.EQ);
|
||||
Transaction txn = Transaction.open(Transaction.AWSAPI_DB);
|
||||
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
try {
|
||||
txn.start();
|
||||
SearchCriteria<BucketPolicyVO> sc = deleteByBucket.create();
|
||||
|
||||
@ -25,6 +25,7 @@ import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
|
||||
@Component
|
||||
@Local(value={CloudStackAccountDao.class})
|
||||
@ -34,7 +35,7 @@ public class CloudStackAccountDaoImpl extends GenericDaoBase<CloudStackAccountVO
|
||||
public String getDefaultZoneId(String accountId) {
|
||||
|
||||
SearchBuilder<CloudStackAccountVO> SearchByUUID = createSearchBuilder();
|
||||
Transaction txn = Transaction.open(Transaction.CLOUD_DB);
|
||||
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
|
||||
try {
|
||||
txn.start();
|
||||
SearchByUUID.and("uuid", SearchByUUID.entity().getUuid(),
|
||||
|
||||
@ -27,6 +27,7 @@ import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
|
||||
@Component
|
||||
@Local(value={CloudStackConfigurationDao.class})
|
||||
@ -42,7 +43,7 @@ public class CloudStackConfigurationDaoImpl extends GenericDaoBase<CloudStackCon
|
||||
@DB
|
||||
public String getConfigValue(String name) {
|
||||
NameSearch.and("name", NameSearch.entity().getName(), SearchCriteria.Op.EQ);
|
||||
Transaction txn = Transaction.open("cloud", Transaction.CLOUD_DB, true);
|
||||
TransactionLegacy txn = TransactionLegacy.open("cloud", TransactionLegacy.CLOUD_DB, true);
|
||||
try {
|
||||
txn.start();
|
||||
SearchCriteria<CloudStackConfigurationVO> sc = NameSearch.create();
|
||||
|
||||
@ -29,6 +29,7 @@ import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
|
||||
@Component
|
||||
@Local(value={CloudStackSvcOfferingDao.class})
|
||||
@ -42,7 +43,7 @@ public class CloudStackSvcOfferingDaoImpl extends GenericDaoBase<CloudStackServi
|
||||
SearchBuilder <CloudStackServiceOfferingVO> searchByName = createSearchBuilder();
|
||||
searchByName.and("name", searchByName.entity().getName(), SearchCriteria.Op.EQ);
|
||||
searchByName.done();
|
||||
Transaction txn = Transaction.open(Transaction.CLOUD_DB);
|
||||
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
|
||||
try {
|
||||
txn.start();
|
||||
SearchCriteria<CloudStackServiceOfferingVO> sc = searchByName.create();
|
||||
@ -61,7 +62,7 @@ public class CloudStackSvcOfferingDaoImpl extends GenericDaoBase<CloudStackServi
|
||||
SearchBuilder <CloudStackServiceOfferingVO> searchByID = createSearchBuilder();
|
||||
searchByID.and("uuid", searchByID.entity().getUuid(), SearchCriteria.Op.EQ);
|
||||
searchByID.done();
|
||||
Transaction txn = Transaction.open(Transaction.CLOUD_DB);
|
||||
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
|
||||
try {
|
||||
txn.start();
|
||||
SearchCriteria<CloudStackServiceOfferingVO> sc = searchByID.create();
|
||||
|
||||
@ -26,6 +26,7 @@ import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
import com.cloud.utils.crypt.DBEncryptionUtil;
|
||||
|
||||
@Component
|
||||
@ -43,7 +44,7 @@ public class CloudStackUserDaoImpl extends GenericDaoBase<CloudStackUserVO, Stri
|
||||
SearchBuilder <CloudStackUserVO> searchByAccessKey = createSearchBuilder();
|
||||
searchByAccessKey.and("apiKey", searchByAccessKey.entity().getApiKey(), SearchCriteria.Op.EQ);
|
||||
searchByAccessKey.done();
|
||||
Transaction txn = Transaction.open(Transaction.CLOUD_DB);
|
||||
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
|
||||
try {
|
||||
txn.start();
|
||||
SearchCriteria<CloudStackUserVO> sc = searchByAccessKey.create();
|
||||
|
||||
@ -25,6 +25,7 @@ import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
|
||||
@Component
|
||||
@Local(value={MHostDao.class})
|
||||
@ -38,7 +39,7 @@ public class MHostDaoImpl extends GenericDaoBase<MHostVO, Long> implements MHost
|
||||
@Override
|
||||
public MHostVO getByHostKey(String hostKey) {
|
||||
NameSearch.and("MHostKey", NameSearch.entity().getHostKey(), SearchCriteria.Op.EQ);
|
||||
Transaction txn = Transaction.open("cloudbridge", Transaction.AWSAPI_DB, true);
|
||||
TransactionLegacy txn = TransactionLegacy.open("cloudbridge", TransactionLegacy.AWSAPI_DB, true);
|
||||
try {
|
||||
txn.start();
|
||||
SearchCriteria<MHostVO> sc = NameSearch.create();
|
||||
@ -52,7 +53,7 @@ public class MHostDaoImpl extends GenericDaoBase<MHostVO, Long> implements MHost
|
||||
|
||||
@Override
|
||||
public void updateHeartBeat(MHostVO mhost) {
|
||||
Transaction txn = Transaction.open("cloudbridge", Transaction.AWSAPI_DB, true);
|
||||
TransactionLegacy txn = TransactionLegacy.open("cloudbridge", TransactionLegacy.AWSAPI_DB, true);
|
||||
try {
|
||||
txn.start();
|
||||
update(mhost.getId(), mhost);
|
||||
|
||||
@ -25,6 +25,7 @@ import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
|
||||
@Component
|
||||
@Local(value={MHostMountDao.class})
|
||||
@ -37,7 +38,7 @@ public class MHostMountDaoImpl extends GenericDaoBase<MHostMountVO, Long> implem
|
||||
public MHostMountVO getHostMount(long mHostId, long sHostId) {
|
||||
SearchByMHostID.and("MHostID", SearchByMHostID.entity().getmHostID(), SearchCriteria.Op.EQ);
|
||||
SearchByMHostID.and("SHostID", SearchByMHostID.entity().getsHostID(), SearchCriteria.Op.EQ);
|
||||
Transaction txn = Transaction.open(Transaction.AWSAPI_DB);
|
||||
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
try {
|
||||
txn.start();
|
||||
SearchCriteria<MHostMountVO> sc = SearchByMHostID.create();
|
||||
|
||||
@ -28,6 +28,7 @@ import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
|
||||
@Component
|
||||
@Local(value={MultiPartPartsDao.class})
|
||||
@ -42,7 +43,7 @@ public class MultiPartPartsDaoImpl extends GenericDaoBase<MultiPartPartsVO, Long
|
||||
ByUploadID.and("partNumber", ByUploadID.entity().getPartNumber(), SearchCriteria.Op.LT);
|
||||
Filter filter = new Filter(MultiPartPartsVO.class, "partNumber", Boolean.TRUE, null, null);
|
||||
|
||||
Transaction txn = Transaction.currentTxn(); // Transaction.open("cloudbridge", Transaction.AWSAPI_DB, true);
|
||||
TransactionLegacy txn = TransactionLegacy.currentTxn(); // Transaction.open("cloudbridge", Transaction.AWSAPI_DB, true);
|
||||
try {
|
||||
txn.start();
|
||||
SearchCriteria<MultiPartPartsVO> sc = ByUploadID.create();
|
||||
@ -61,7 +62,7 @@ public class MultiPartPartsDaoImpl extends GenericDaoBase<MultiPartPartsVO, Long
|
||||
SearchBuilder<MultiPartPartsVO> byUploadID = createSearchBuilder();
|
||||
byUploadID.and("UploadID", byUploadID.entity().getUploadid(), SearchCriteria.Op.EQ);
|
||||
byUploadID.and("partNumber", byUploadID.entity().getPartNumber(), SearchCriteria.Op.GT);
|
||||
Transaction txn = Transaction.currentTxn(); // Transaction.open("cloudbridge", Transaction.AWSAPI_DB, true);
|
||||
TransactionLegacy txn = TransactionLegacy.currentTxn(); // Transaction.open("cloudbridge", Transaction.AWSAPI_DB, true);
|
||||
try {
|
||||
txn.start();
|
||||
SearchCriteria<MultiPartPartsVO> sc = byUploadID.create();
|
||||
@ -82,7 +83,7 @@ public class MultiPartPartsDaoImpl extends GenericDaoBase<MultiPartPartsVO, Long
|
||||
SearchBuilder<MultiPartPartsVO> byUploadID = createSearchBuilder();
|
||||
byUploadID.and("UploadID", byUploadID.entity().getUploadid(), SearchCriteria.Op.EQ);
|
||||
byUploadID.and("partNumber", byUploadID.entity().getPartNumber(), SearchCriteria.Op.EQ);
|
||||
Transaction txn = Transaction.currentTxn(); // Transaction.open("cloudbridge", Transaction.AWSAPI_DB, true);
|
||||
TransactionLegacy txn = TransactionLegacy.currentTxn(); // Transaction.open("cloudbridge", Transaction.AWSAPI_DB, true);
|
||||
try {
|
||||
txn.start();
|
||||
SearchCriteria<MultiPartPartsVO> sc = byUploadID.create();
|
||||
@ -102,7 +103,7 @@ public class MultiPartPartsDaoImpl extends GenericDaoBase<MultiPartPartsVO, Long
|
||||
SearchBuilder<MultiPartPartsVO> byUploadID = createSearchBuilder();
|
||||
byUploadID.and("UploadID", byUploadID.entity().getUploadid(), SearchCriteria.Op.EQ);
|
||||
byUploadID.and("partNumber", byUploadID.entity().getPartNumber(), SearchCriteria.Op.EQ);
|
||||
Transaction txn = Transaction.currentTxn(); // Transaction.open("cloudbridge", Transaction.AWSAPI_DB, true);
|
||||
TransactionLegacy txn = TransactionLegacy.currentTxn(); // Transaction.open("cloudbridge", Transaction.AWSAPI_DB, true);
|
||||
try {
|
||||
txn.start();
|
||||
SearchCriteria<MultiPartPartsVO> sc = byUploadID.create();
|
||||
|
||||
@ -33,6 +33,7 @@ import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
|
||||
@Component
|
||||
@Local(value={MultiPartUploadsDao.class})
|
||||
@ -42,9 +43,9 @@ public class MultiPartUploadsDaoImpl extends GenericDaoBase<MultiPartUploadsVO,
|
||||
public OrderedPair<String,String> multipartExits( int uploadId ) {
|
||||
MultiPartUploadsVO uploadvo = null;
|
||||
|
||||
Transaction txn = null;
|
||||
TransactionLegacy txn = null;
|
||||
try {
|
||||
txn = Transaction.open(Transaction.AWSAPI_DB);
|
||||
txn = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
uploadvo = findById(new Long(uploadId));
|
||||
if (null != uploadvo)
|
||||
return new OrderedPair<String,String>(uploadvo.getAccessKey(), uploadvo.getNameKey());
|
||||
@ -58,9 +59,9 @@ public class MultiPartUploadsDaoImpl extends GenericDaoBase<MultiPartUploadsVO,
|
||||
@Override
|
||||
public void deleteUpload(int uploadId) {
|
||||
|
||||
Transaction txn = null;
|
||||
TransactionLegacy txn = null;
|
||||
try {
|
||||
txn = Transaction.open(Transaction.AWSAPI_DB);
|
||||
txn = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
remove(new Long(uploadId));
|
||||
txn.commit();
|
||||
}finally {
|
||||
@ -70,10 +71,10 @@ public class MultiPartUploadsDaoImpl extends GenericDaoBase<MultiPartUploadsVO,
|
||||
|
||||
@Override
|
||||
public String getAtrributeValue(String attribute, int uploadid) {
|
||||
Transaction txn = null;
|
||||
TransactionLegacy txn = null;
|
||||
MultiPartUploadsVO uploadvo = null;
|
||||
try {
|
||||
txn = Transaction.open(Transaction.AWSAPI_DB);
|
||||
txn = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
uploadvo = findById(new Long(uploadid));
|
||||
if (null != uploadvo) {
|
||||
if ( attribute.equalsIgnoreCase("AccessKey") )
|
||||
@ -105,7 +106,7 @@ public class MultiPartUploadsDaoImpl extends GenericDaoBase<MultiPartUploadsVO,
|
||||
Filter filter = new Filter(MultiPartUploadsVO.class, "nameKey", Boolean.TRUE, null, null);
|
||||
filter.addOrderBy(MultiPartUploadsVO.class, "createTime", Boolean.TRUE);
|
||||
|
||||
Transaction txn = Transaction.open("cloudbridge", Transaction.AWSAPI_DB, true);
|
||||
TransactionLegacy txn = TransactionLegacy.open("cloudbridge", TransactionLegacy.AWSAPI_DB, true);
|
||||
try {
|
||||
txn.start();
|
||||
SearchCriteria<MultiPartUploadsVO> sc = byBucket.create();
|
||||
|
||||
@ -34,6 +34,7 @@ import com.cloud.bridge.service.core.s3.S3MultipartPart;
|
||||
import com.cloud.bridge.service.core.s3.S3MultipartUpload;
|
||||
import com.cloud.bridge.util.OrderedPair;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
|
||||
public class MultipartLoadDao {
|
||||
public static final Logger logger = Logger.getLogger(MultipartLoadDao.class);
|
||||
@ -94,9 +95,9 @@ public class MultipartLoadDao {
|
||||
*/
|
||||
public int initiateUpload( String accessKey, String bucketName, String key, String cannedAccess, S3MetaDataEntry[] meta ) {
|
||||
int uploadId = -1;
|
||||
Transaction txn = null;
|
||||
TransactionLegacy txn = null;
|
||||
try {
|
||||
txn = Transaction.open(Transaction.AWSAPI_DB);
|
||||
txn = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
Date tod = new Date();
|
||||
MultiPartUploadsVO uploadVO = new MultiPartUploadsVO(accessKey,
|
||||
bucketName, key, cannedAccess, tod);
|
||||
@ -315,9 +316,9 @@ public class MultipartLoadDao {
|
||||
private void saveMultipartMeta( int uploadId, S3MetaDataEntry[] meta ) {
|
||||
if (null == meta) return;
|
||||
|
||||
Transaction txn = null;
|
||||
TransactionLegacy txn = null;
|
||||
try {
|
||||
txn = Transaction.open(Transaction.AWSAPI_DB);
|
||||
txn = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
for( int i=0; i < meta.length; i++ )
|
||||
{
|
||||
S3MetaDataEntry entry = meta[i];
|
||||
|
||||
@ -27,6 +27,7 @@ import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
|
||||
@Component
|
||||
@Local(value={MultipartMetaDao.class})
|
||||
@ -37,7 +38,7 @@ public class MultipartMetaDaoImpl extends GenericDaoBase<MultipartMetaVO, Long>
|
||||
SearchBuilder <MultipartMetaVO> searchByUID = createSearchBuilder();
|
||||
searchByUID.and("UploadID", searchByUID.entity().getUploadID(), SearchCriteria.Op.EQ);
|
||||
searchByUID.done();
|
||||
Transaction txn = Transaction.open(Transaction.AWSAPI_DB);
|
||||
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
try {
|
||||
txn.start();
|
||||
SearchCriteria<MultipartMetaVO> sc = searchByUID.create();
|
||||
|
||||
@ -29,6 +29,7 @@ import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
|
||||
@Component
|
||||
@Local(value={OfferingDao.class})
|
||||
@ -39,7 +40,7 @@ public class OfferingDaoImpl extends GenericDaoBase<OfferingBundleVO, Long> impl
|
||||
|
||||
@Override
|
||||
public int getOfferingCount() {
|
||||
Transaction txn = Transaction.open(Transaction.AWSAPI_DB);
|
||||
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
try {
|
||||
txn.start();
|
||||
return listAll().size();
|
||||
@ -56,7 +57,7 @@ public class OfferingDaoImpl extends GenericDaoBase<OfferingBundleVO, Long> impl
|
||||
SearchBuilder <OfferingBundleVO> searchByAmazon = createSearchBuilder();
|
||||
searchByAmazon.and("AmazonEC2Offering", searchByAmazon.entity().getAmazonOffering() , SearchCriteria.Op.EQ);
|
||||
searchByAmazon.done();
|
||||
Transaction txn = Transaction.open(Transaction.AWSAPI_DB);
|
||||
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
try {
|
||||
txn.start();
|
||||
SearchCriteria<OfferingBundleVO> sc = searchByAmazon.create();
|
||||
@ -74,7 +75,7 @@ public class OfferingDaoImpl extends GenericDaoBase<OfferingBundleVO, Long> impl
|
||||
SearchBuilder <OfferingBundleVO> searchByAmazon = createSearchBuilder();
|
||||
searchByAmazon.and("CloudStackOffering", searchByAmazon.entity().getAmazonOffering() , SearchCriteria.Op.EQ);
|
||||
searchByAmazon.done();
|
||||
Transaction txn = Transaction.open(Transaction.AWSAPI_DB);
|
||||
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
try {
|
||||
txn.start();
|
||||
SearchCriteria<OfferingBundleVO> sc = searchByAmazon.create();
|
||||
@ -93,7 +94,7 @@ public class OfferingDaoImpl extends GenericDaoBase<OfferingBundleVO, Long> impl
|
||||
searchByAmazon.and("CloudStackOffering", searchByAmazon.entity().getAmazonOffering() , SearchCriteria.Op.EQ);
|
||||
searchByAmazon.and("AmazonEC2Offering", searchByAmazon.entity().getCloudstackOffering() , SearchCriteria.Op.EQ);
|
||||
searchByAmazon.done();
|
||||
Transaction txn = Transaction.open(Transaction.AWSAPI_DB);
|
||||
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
OfferingBundleVO offering = null;
|
||||
try {
|
||||
txn.start();
|
||||
@ -122,7 +123,7 @@ public class OfferingDaoImpl extends GenericDaoBase<OfferingBundleVO, Long> impl
|
||||
SearchBuilder <OfferingBundleVO> searchByAmazon = createSearchBuilder();
|
||||
searchByAmazon.and("AmazonEC2Offering", searchByAmazon.entity().getAmazonOffering() , SearchCriteria.Op.EQ);
|
||||
searchByAmazon.done();
|
||||
Transaction txn = Transaction.open(Transaction.AWSAPI_DB);
|
||||
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
try {
|
||||
txn.start();
|
||||
SearchCriteria<OfferingBundleVO> sc = searchByAmazon.create();
|
||||
|
||||
@ -32,6 +32,7 @@ import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
|
||||
@Component
|
||||
@Local(value={SAclDao.class})
|
||||
@ -46,7 +47,7 @@ public class SAclDaoImpl extends GenericDaoBase<SAclVO, Long> implements SAclDao
|
||||
SearchByTarget.and("TargetID", SearchByTarget.entity().getTargetId(), SearchCriteria.Op.EQ);
|
||||
SearchByTarget.done();
|
||||
Filter filter = new Filter(SAclVO.class, "grantOrder", Boolean.TRUE, null, null);
|
||||
Transaction txn = Transaction.open( Transaction.AWSAPI_DB);
|
||||
TransactionLegacy txn = TransactionLegacy.open( TransactionLegacy.AWSAPI_DB);
|
||||
try {
|
||||
txn.start();
|
||||
SearchCriteria<SAclVO> sc = SearchByTarget.create();
|
||||
@ -66,7 +67,7 @@ public class SAclDaoImpl extends GenericDaoBase<SAclVO, Long> implements SAclDao
|
||||
SearchByAcl.and("TargetID", SearchByAcl.entity().getTargetId(), SearchCriteria.Op.EQ);
|
||||
SearchByAcl.and("GranteeCanonicalID", SearchByAcl.entity().getGranteeCanonicalId(), SearchCriteria.Op.EQ);
|
||||
Filter filter = new Filter(SAclVO.class, "grantOrder", Boolean.TRUE, null, null);
|
||||
Transaction txn = Transaction.open( Transaction.AWSAPI_DB);
|
||||
TransactionLegacy txn = TransactionLegacy.open( TransactionLegacy.AWSAPI_DB);
|
||||
try {
|
||||
txn.start();
|
||||
SearchCriteria<SAclVO> sc = SearchByAcl.create();
|
||||
@ -85,7 +86,7 @@ public class SAclDaoImpl extends GenericDaoBase<SAclVO, Long> implements SAclDao
|
||||
SearchByTarget.and("Target", SearchByTarget.entity().getTarget(), SearchCriteria.Op.EQ);
|
||||
SearchByTarget.and("TargetID", SearchByTarget.entity().getTargetId(), SearchCriteria.Op.EQ);
|
||||
|
||||
Transaction txn = Transaction.open(Transaction.AWSAPI_DB);
|
||||
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
try {
|
||||
txn.start();
|
||||
SearchCriteria<SAclVO> sc = SearchByTarget.create();
|
||||
|
||||
@ -29,6 +29,7 @@ import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
|
||||
@Component
|
||||
@Local(value={SBucketDao.class})
|
||||
@ -42,7 +43,7 @@ public class SBucketDaoImpl extends GenericDaoBase<SBucketVO, Long> implements S
|
||||
SearchBuilder<SBucketVO> SearchByName = createSearchBuilder();
|
||||
SearchByName.and("Name", SearchByName.entity().getName(), SearchCriteria.Op.EQ);
|
||||
//Transaction txn = Transaction.open(Transaction.AWSAPI_DB);
|
||||
Transaction txn = Transaction.open("cloudbridge", Transaction.AWSAPI_DB, true);
|
||||
TransactionLegacy txn = TransactionLegacy.open("cloudbridge", TransactionLegacy.AWSAPI_DB, true);
|
||||
try {
|
||||
txn.start();
|
||||
SearchCriteria<SBucketVO> sc = SearchByName.create();
|
||||
@ -59,7 +60,7 @@ public class SBucketDaoImpl extends GenericDaoBase<SBucketVO, Long> implements S
|
||||
SearchBuilder<SBucketVO> ByCanonicalID = createSearchBuilder();
|
||||
ByCanonicalID.and("OwnerCanonicalID", ByCanonicalID.entity().getOwnerCanonicalId(), SearchCriteria.Op.EQ);
|
||||
Filter filter = new Filter(SBucketVO.class, "createTime", Boolean.TRUE, null, null);
|
||||
Transaction txn = Transaction.currentTxn(); // Transaction.open("cloudbridge", Transaction.AWSAPI_DB, true);
|
||||
TransactionLegacy txn = TransactionLegacy.currentTxn(); // Transaction.open("cloudbridge", Transaction.AWSAPI_DB, true);
|
||||
try {
|
||||
txn.start();
|
||||
SearchCriteria<SBucketVO> sc = ByCanonicalID.create();
|
||||
|
||||
@ -25,6 +25,7 @@ import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
|
||||
@Component
|
||||
@Local(value={SHostDao.class})
|
||||
@ -36,7 +37,7 @@ public class SHostDaoImpl extends GenericDaoBase<SHostVO, Long> implements SHost
|
||||
SearchBuilder <SHostVO> HostSearch = createSearchBuilder();
|
||||
HostSearch.and("Host", HostSearch.entity().getHost(), SearchCriteria.Op.EQ);
|
||||
HostSearch.done();
|
||||
Transaction txn = Transaction.open(Transaction.AWSAPI_DB);
|
||||
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
try {
|
||||
txn.start();
|
||||
SearchCriteria<SHostVO> sc = HostSearch.create();
|
||||
@ -55,7 +56,7 @@ public class SHostDaoImpl extends GenericDaoBase<SHostVO, Long> implements SHost
|
||||
LocalStorageHostSearch.and("MHostID", LocalStorageHostSearch.entity().getMhostid(), SearchCriteria.Op.EQ);
|
||||
LocalStorageHostSearch.and("ExportRoot", LocalStorageHostSearch.entity().getExportRoot(), SearchCriteria.Op.EQ);
|
||||
LocalStorageHostSearch.done();
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
TransactionLegacy txn = TransactionLegacy.currentTxn();
|
||||
try {
|
||||
txn.start();
|
||||
SearchCriteria<SHostVO> sc = LocalStorageHostSearch.create();
|
||||
|
||||
@ -28,6 +28,7 @@ import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
|
||||
@Component
|
||||
@Local(value={SMetaDao.class})
|
||||
@ -41,7 +42,7 @@ public class SMetaDaoImpl extends GenericDaoBase<SMetaVO, Long> implements SMeta
|
||||
SearchByTarget.and("Target", SearchByTarget.entity().getTarget(), SearchCriteria.Op.EQ);
|
||||
SearchByTarget.and("TargetID", SearchByTarget.entity().getTargetId(), SearchCriteria.Op.EQ);
|
||||
SearchByTarget.done();
|
||||
Transaction txn = Transaction.open( Transaction.AWSAPI_DB);
|
||||
TransactionLegacy txn = TransactionLegacy.open( TransactionLegacy.AWSAPI_DB);
|
||||
try {
|
||||
txn.start();
|
||||
SearchCriteria<SMetaVO> sc = SearchByTarget.create();
|
||||
@ -71,7 +72,7 @@ public class SMetaDaoImpl extends GenericDaoBase<SMetaVO, Long> implements SMeta
|
||||
SearchBuilder <SMetaVO> SearchByTarget = createSearchBuilder();
|
||||
SearchByTarget.and("Target", SearchByTarget.entity().getTarget(), SearchCriteria.Op.EQ);
|
||||
SearchByTarget.and("TargetID", SearchByTarget.entity().getTargetId(), SearchCriteria.Op.EQ);
|
||||
Transaction txn = Transaction.open(Transaction.AWSAPI_DB);
|
||||
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
try {
|
||||
txn.start();
|
||||
SearchCriteria<SMetaVO> sc = SearchByTarget.create();
|
||||
|
||||
@ -33,6 +33,7 @@ import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
|
||||
@Component
|
||||
@Local(value={SObjectDao.class})
|
||||
@ -47,7 +48,7 @@ public class SObjectDaoImpl extends GenericDaoBase<SObjectVO, Long> implements S
|
||||
SearchBuilder<SObjectVO> SearchByName = createSearchBuilder();
|
||||
SearchByName.and("SBucketID", SearchByName.entity().getBucketID() , SearchCriteria.Op.EQ);
|
||||
SearchByName.and("NameKey", SearchByName.entity().getNameKey() , SearchCriteria.Op.EQ);
|
||||
Transaction txn = Transaction.open(Transaction.AWSAPI_DB);
|
||||
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
try {
|
||||
txn.start();
|
||||
SearchCriteria<SObjectVO> sc = SearchByName.create();
|
||||
@ -76,7 +77,7 @@ public class SObjectDaoImpl extends GenericDaoBase<SObjectVO, Long> implements S
|
||||
|
||||
SearchByBucket.and("SBucketID", SearchByBucket.entity().getBucketID(), SearchCriteria.Op.EQ);
|
||||
SearchByBucket.and("DeletionMark", SearchByBucket.entity().getDeletionMark(), SearchCriteria.Op.NULL);
|
||||
Transaction txn = Transaction.currentTxn(); // Transaction.open("cloudbridge", Transaction.AWSAPI_DB, true);
|
||||
TransactionLegacy txn = TransactionLegacy.currentTxn(); // Transaction.open("cloudbridge", Transaction.AWSAPI_DB, true);
|
||||
try {
|
||||
txn.start();
|
||||
SearchCriteria<SObjectVO> sc = SearchByBucket.create();
|
||||
@ -100,7 +101,7 @@ public class SObjectDaoImpl extends GenericDaoBase<SObjectVO, Long> implements S
|
||||
List<SObjectVO> objects = new ArrayList<SObjectVO>();
|
||||
getAllBuckets.and("SBucketID", getAllBuckets.entity().getBucketID(), SearchCriteria.Op.EQ);
|
||||
|
||||
Transaction txn = Transaction.currentTxn(); // Transaction.open("cloudbridge", Transaction.AWSAPI_DB, true);
|
||||
TransactionLegacy txn = TransactionLegacy.currentTxn(); // Transaction.open("cloudbridge", Transaction.AWSAPI_DB, true);
|
||||
try {
|
||||
txn.start();
|
||||
SearchCriteria<SObjectVO> sc = getAllBuckets.create();
|
||||
|
||||
@ -27,6 +27,7 @@ import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
|
||||
@Component
|
||||
@Local(value={SObjectItemDao.class})
|
||||
@ -39,7 +40,7 @@ public class SObjectItemDaoImpl extends GenericDaoBase<SObjectItemVO, Long> impl
|
||||
@Override
|
||||
public SObjectItemVO getByObjectIdNullVersion(long id) {
|
||||
|
||||
Transaction txn = Transaction.open(Transaction.AWSAPI_DB);
|
||||
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
SearchBuilder <SObjectItemVO> SearchByID = createSearchBuilder();
|
||||
SearchByID.and("ID", SearchByID.entity().getId(), SearchCriteria.Op.EQ);
|
||||
|
||||
@ -56,7 +57,7 @@ public class SObjectItemDaoImpl extends GenericDaoBase<SObjectItemVO, Long> impl
|
||||
@Override
|
||||
public List<SObjectItemVO> getItems(long sobjectID) {
|
||||
|
||||
Transaction txn = Transaction.open(Transaction.AWSAPI_DB);
|
||||
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
SearchBuilder<SObjectItemVO> SearchBySobjectID = createSearchBuilder();
|
||||
SearchBySobjectID.and("SObjectID", SearchBySobjectID.entity().getId(), SearchCriteria.Op.EQ);
|
||||
|
||||
|
||||
@ -29,6 +29,7 @@ import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
|
||||
@Component
|
||||
@Local(value={UserCredentialsDao.class})
|
||||
@ -41,7 +42,7 @@ public class UserCredentialsDaoImpl extends GenericDaoBase<UserCredentialsVO, Lo
|
||||
@Override
|
||||
public UserCredentialsVO getByAccessKey( String cloudAccessKey ) {
|
||||
SearchBuilder<UserCredentialsVO> SearchByAccessKey = createSearchBuilder();
|
||||
Transaction txn = Transaction.open(Transaction.AWSAPI_DB);
|
||||
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
try {
|
||||
txn.start();
|
||||
SearchByAccessKey.and("AccessKey", SearchByAccessKey.entity()
|
||||
@ -60,7 +61,7 @@ public class UserCredentialsDaoImpl extends GenericDaoBase<UserCredentialsVO, Lo
|
||||
public UserCredentialsVO getByCertUniqueId( String certId ) {
|
||||
SearchBuilder<UserCredentialsVO> SearchByCertID = createSearchBuilder();
|
||||
SearchByCertID.and("CertUniqueId", SearchByCertID.entity().getCertUniqueId(), SearchCriteria.Op.EQ);
|
||||
Transaction txn = Transaction.open(Transaction.AWSAPI_DB);
|
||||
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
try {
|
||||
txn.start();
|
||||
SearchCriteria<UserCredentialsVO> sc = SearchByCertID.create();
|
||||
|
||||
@ -161,6 +161,7 @@ import com.cloud.bridge.util.ConfigurationHelper;
|
||||
import com.cloud.bridge.util.EC2RestAuth;
|
||||
import com.cloud.stack.models.CloudStackAccount;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
|
||||
@Component("EC2RestServlet")
|
||||
public class EC2RestServlet extends HttpServlet {
|
||||
@ -377,7 +378,7 @@ public class EC2RestServlet extends HttpServlet {
|
||||
private void setUserKeys( HttpServletRequest request, HttpServletResponse response ) {
|
||||
String[] accessKey = null;
|
||||
String[] secretKey = null;
|
||||
Transaction txn = null;
|
||||
TransactionLegacy txn = null;
|
||||
try {
|
||||
// -> all these parameters are required
|
||||
accessKey = request.getParameterValues( "accesskey" );
|
||||
@ -398,7 +399,7 @@ public class EC2RestServlet extends HttpServlet {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
txn = Transaction.open(Transaction.AWSAPI_DB);
|
||||
txn = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
txn.start();
|
||||
// -> use the keys to see if the account actually exists
|
||||
ServiceProvider.getInstance().getEC2Engine().validateAccount( accessKey[0], secretKey[0] );
|
||||
@ -434,7 +435,7 @@ public class EC2RestServlet extends HttpServlet {
|
||||
*/
|
||||
private void setCertificate( HttpServletRequest request, HttpServletResponse response )
|
||||
throws Exception {
|
||||
Transaction txn = null;
|
||||
TransactionLegacy txn = null;
|
||||
try {
|
||||
// [A] Pull the cert and cloud AccessKey from the request
|
||||
String[] certificate = request.getParameterValues( "cert" );
|
||||
@ -470,7 +471,7 @@ public class EC2RestServlet extends HttpServlet {
|
||||
// [C] Associate the cert's uniqueId with the Cloud API keys
|
||||
String uniqueId = AuthenticationUtils.X509CertUniqueId( userCert );
|
||||
logger.debug( "SetCertificate, uniqueId: " + uniqueId );
|
||||
txn = Transaction.open(Transaction.AWSAPI_DB);
|
||||
txn = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
txn.start();
|
||||
UserCredentialsVO user = ucDao.getByAccessKey(accessKey[0]);
|
||||
user.setCertUniqueId(uniqueId);
|
||||
@ -505,7 +506,7 @@ public class EC2RestServlet extends HttpServlet {
|
||||
*/
|
||||
private void deleteCertificate( HttpServletRequest request, HttpServletResponse response )
|
||||
throws Exception {
|
||||
Transaction txn = null;
|
||||
TransactionLegacy txn = null;
|
||||
try {
|
||||
String [] accessKey = request.getParameterValues( "AWSAccessKeyId" );
|
||||
if ( null == accessKey || 0 == accessKey.length ) {
|
||||
@ -527,7 +528,7 @@ public class EC2RestServlet extends HttpServlet {
|
||||
/* UserCredentialsDao credentialDao = new UserCredentialsDao();
|
||||
credentialDao.setCertificateId( accessKey[0], null );
|
||||
|
||||
*/ txn = Transaction.open(Transaction.AWSAPI_DB);
|
||||
*/ txn = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
UserCredentialsVO user = ucDao.getByAccessKey(accessKey[0]);
|
||||
user.setCertUniqueId(null);
|
||||
ucDao.update(user.getId(), user);
|
||||
|
||||
@ -67,6 +67,7 @@ import com.cloud.bridge.util.RestAuth;
|
||||
import com.cloud.bridge.util.S3SoapAuth;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
public class S3RestServlet extends HttpServlet {
|
||||
private static final long serialVersionUID = -6168996266762804877L;
|
||||
public static final String ENABLE_S3_API="enable.s3.api";
|
||||
@ -139,7 +140,7 @@ public class S3RestServlet extends HttpServlet {
|
||||
*/
|
||||
private void processRequest( HttpServletRequest request, HttpServletResponse response, String method )
|
||||
{
|
||||
Transaction txn = Transaction.open("cloudbridge", Transaction.AWSAPI_DB, true);
|
||||
TransactionLegacy txn = TransactionLegacy.open("cloudbridge", TransactionLegacy.AWSAPI_DB, true);
|
||||
try {
|
||||
logRequest(request);
|
||||
|
||||
@ -274,7 +275,7 @@ public class S3RestServlet extends HttpServlet {
|
||||
// -> use the keys to see if the account actually exists
|
||||
//ServiceProvider.getInstance().getEC2Engine().validateAccount( accessKey[0], secretKey[0] );
|
||||
//UserCredentialsDaoImpl credentialDao = new UserCredentialsDao();
|
||||
Transaction txn = Transaction.open(Transaction.AWSAPI_DB);
|
||||
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
txn.start();
|
||||
UserCredentialsVO user = new UserCredentialsVO(accessKey[0], secretKey[0]);
|
||||
user = ucDao.persist(user);
|
||||
|
||||
@ -94,6 +94,7 @@ import com.cloud.bridge.util.XSerializer;
|
||||
import com.cloud.bridge.util.XSerializerXmlAdapter;
|
||||
import com.cloud.bridge.util.XmlHelper;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
|
||||
|
||||
public class S3BucketAction implements ServletAction {
|
||||
@ -371,7 +372,7 @@ public class S3BucketAction implements ServletAction {
|
||||
response.setStatus(403);
|
||||
return;
|
||||
}
|
||||
Transaction txn = Transaction.open(Transaction.AWSAPI_DB);
|
||||
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
// [B] Place the policy into the database over writting an existing policy
|
||||
try {
|
||||
// -> first make sure that the policy is valid by parsing it
|
||||
|
||||
@ -35,6 +35,7 @@ import javax.annotation.PostConstruct;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.axis2.AxisFault;
|
||||
import org.apache.cloudstack.managed.context.ManagedContextTimerTask;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.xml.DOMConfigurator;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -61,6 +62,7 @@ import com.cloud.bridge.util.OrderedPair;
|
||||
import com.cloud.utils.component.ManagerBase;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
|
||||
@Component
|
||||
public class ServiceProvider extends ManagerBase {
|
||||
@ -89,7 +91,7 @@ public class ServiceProvider extends ManagerBase {
|
||||
|
||||
protected ServiceProvider() throws IOException {
|
||||
// register service implementation object
|
||||
Transaction txn = Transaction.open(Transaction.AWSAPI_DB);
|
||||
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
txn.close();
|
||||
}
|
||||
|
||||
@ -182,7 +184,7 @@ public class ServiceProvider extends ManagerBase {
|
||||
|
||||
public UserInfo getUserInfo(String accessKey) {
|
||||
UserInfo info = new UserInfo();
|
||||
Transaction txn = Transaction.open(Transaction.AWSAPI_DB);
|
||||
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
try {
|
||||
txn.start();
|
||||
UserCredentialsVO cloudKeys = ucDao.getByAccessKey( accessKey );
|
||||
@ -252,7 +254,7 @@ public class ServiceProvider extends ManagerBase {
|
||||
|
||||
multipartDir = properties.getProperty("storage.multipartDir");
|
||||
|
||||
Transaction txn1 = Transaction.open(Transaction.AWSAPI_DB);
|
||||
TransactionLegacy txn1 = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
timer.schedule(getHeartbeatTask(), HEARTBEAT_INTERVAL, HEARTBEAT_INTERVAL);
|
||||
txn1.close();
|
||||
|
||||
@ -280,10 +282,9 @@ public class ServiceProvider extends ManagerBase {
|
||||
}
|
||||
|
||||
private TimerTask getHeartbeatTask() {
|
||||
return new TimerTask() {
|
||||
|
||||
return new ManagedContextTimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
protected void runInContext() {
|
||||
try {
|
||||
mhost.setLastHeartbeatTime(DateHelper.currentGMTTime());
|
||||
mhostDao.updateHeartBeat(mhost);
|
||||
|
||||
@ -86,6 +86,7 @@ import com.cloud.bridge.util.StringHelper;
|
||||
import com.cloud.bridge.util.Triple;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionLegacy;
|
||||
|
||||
/**
|
||||
* The CRUD control actions to be invoked from S3BucketAction or S3ObjectAction.
|
||||
@ -195,7 +196,7 @@ public class S3Engine {
|
||||
String cannedAccessPolicy = request.getCannedAccess();
|
||||
String bucketName = request.getBucketName();
|
||||
response.setBucketName( bucketName );
|
||||
Transaction txn= null;
|
||||
TransactionLegacy txn= null;
|
||||
verifyBucketName( bucketName, false );
|
||||
|
||||
S3PolicyContext context = new S3PolicyContext( PolicyActions.CreateBucket, bucketName );
|
||||
@ -205,7 +206,7 @@ public class S3Engine {
|
||||
OrderedPair<SHostVO, String> shost_storagelocation_pair = null;
|
||||
boolean success = false;
|
||||
try {
|
||||
txn = Transaction.open(Transaction.AWSAPI_DB);
|
||||
txn = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
|
||||
if (bucketDao.getByName(request.getBucketName()) != null)
|
||||
throw new ObjectAlreadyExistsException("Bucket already exists");
|
||||
@ -257,10 +258,10 @@ public class S3Engine {
|
||||
String bucketName = request.getBucketName();
|
||||
SBucketVO sbucket = bucketDao.getByName(bucketName);
|
||||
|
||||
Transaction txn = null;
|
||||
TransactionLegacy txn = null;
|
||||
if ( sbucket != null )
|
||||
{
|
||||
txn = Transaction.open(Transaction.AWSAPI_DB);
|
||||
txn = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
txn.start();
|
||||
S3PolicyContext context = new S3PolicyContext( PolicyActions.DeleteBucket, bucketName );
|
||||
switch( verifyPolicy( context ))
|
||||
@ -699,7 +700,7 @@ public class S3Engine {
|
||||
if (null != version)
|
||||
httpResp.addHeader("x-amz-version-id", version);
|
||||
httpResp.flushBuffer();
|
||||
Transaction txn = Transaction.open(Transaction.AWSAPI_DB);
|
||||
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
// [C] Re-assemble the object from its uploaded file parts
|
||||
try {
|
||||
// explicit transaction control to avoid holding transaction during
|
||||
@ -752,11 +753,11 @@ public class S3Engine {
|
||||
S3BucketAdapter bucketAdapter = getStorageHostBucketAdapter(host_storagelocation_pair.getFirst());
|
||||
String itemFileName = object_objectitem_pair.getSecond().getStoredPath();
|
||||
InputStream is = null;
|
||||
Transaction txn = null;
|
||||
TransactionLegacy txn = null;
|
||||
try {
|
||||
// explicit transaction control to avoid holding transaction during file-copy process
|
||||
|
||||
txn = Transaction.open(Transaction.AWSAPI_DB);
|
||||
txn = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
txn.start();
|
||||
is = request.getDataInputStream();
|
||||
String md5Checksum = bucketAdapter.saveObject(is, host_storagelocation_pair.getSecond(), bucket.getName(), itemFileName);
|
||||
@ -813,11 +814,11 @@ public class S3Engine {
|
||||
S3BucketAdapter bucketAdapter = getStorageHostBucketAdapter(host_storagelocation_pair.getFirst());
|
||||
String itemFileName = object_objectitem_pair.getSecond().getStoredPath();
|
||||
InputStream is = null;
|
||||
Transaction txn = null;
|
||||
TransactionLegacy txn = null;
|
||||
try {
|
||||
// explicit transaction control to avoid holding transaction during file-copy process
|
||||
|
||||
txn = Transaction.open(Transaction.AWSAPI_DB);
|
||||
txn = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
txn.start();
|
||||
|
||||
is = request.getInputStream();
|
||||
@ -1505,7 +1506,7 @@ public class S3Engine {
|
||||
context.setEvalParam( ConditionKeys.Acl, cannedAccessPolicy);
|
||||
|
||||
verifyAccess( context, "SBucket", bucket.getId(), SAcl.PERMISSION_WRITE ); // TODO - check this validates plain POSTs
|
||||
Transaction txn = Transaction.open(Transaction.AWSAPI_DB);
|
||||
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
txn.start();
|
||||
|
||||
// [B] If versioning is off them we over write a null object item
|
||||
@ -1554,7 +1555,7 @@ public class S3Engine {
|
||||
}
|
||||
else
|
||||
{
|
||||
Transaction txn1 = Transaction.open(Transaction.AWSAPI_DB);
|
||||
TransactionLegacy txn1 = TransactionLegacy.open(TransactionLegacy.AWSAPI_DB);
|
||||
txn1.start();
|
||||
// -> there is no object nor an object item
|
||||
object = new SObjectVO();
|
||||
|
||||
@ -14,6 +14,12 @@
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
label.hypervisors=Hypervisors
|
||||
label.home=Home
|
||||
label.sockets=Sockets
|
||||
label.root.disk.size=Root disk size
|
||||
label.s3.nfs.server=S3 NFS Server
|
||||
label.s3.nfs.path=S3 NFS Path
|
||||
label.delete.events=Delete events
|
||||
label.delete.alerts=Delete alerts
|
||||
label.archive.alerts=Archive alerts
|
||||
@ -200,6 +206,8 @@ label.action.enable.user.processing=Enabling User....
|
||||
label.action.enable.user=Enable User
|
||||
label.action.enable.zone.processing=Enabling Zone....
|
||||
label.action.enable.zone=Enable Zone
|
||||
label.action.expunge.instance=Expunge Instance
|
||||
label.action.expunge.instance.processing=Expunging Instance....
|
||||
label.action.force.reconnect.processing=Reconnecting....
|
||||
label.action.force.reconnect=Force Reconnect
|
||||
label.action.generate.keys.processing=Generate Keys....
|
||||
@ -249,6 +257,8 @@ label.action.stop.systemvm.processing=Stopping System VM....
|
||||
label.action.stop.systemvm=Stop System VM
|
||||
label.action.take.snapshot.processing=Taking Snapshot....
|
||||
label.action.take.snapshot=Take Snapshot
|
||||
label.action.revert.snapshot.processing=Reverting to Snapshot...
|
||||
label.action.revert.snapshot=Revert to Snapshot
|
||||
label.action.unmanage.cluster.processing=Unmanaging Cluster....
|
||||
label.action.unmanage.cluster=Unmanage Cluster
|
||||
label.action.update.OS.preference.processing=Updating OS Preference....
|
||||
@ -315,6 +325,7 @@ label.add.template=Add Template
|
||||
label.add.to.group=Add to group
|
||||
label.add.user=Add User
|
||||
label.add.vlan=Add VLAN
|
||||
label.add.vxlan=Add VXLAN
|
||||
label.add.VM.to.tier=Add VM to tier
|
||||
label.add.vm=Add VM
|
||||
label.add.vms.to.lb=Add VM(s) to load balancer rule
|
||||
@ -412,6 +423,11 @@ label.cluster.type=Cluster Type
|
||||
label.cluster=Cluster
|
||||
label.clusters=Clusters
|
||||
label.clvm=CLVM
|
||||
label.rbd=RBD
|
||||
label.rbd.monitor=Ceph monitor
|
||||
label.rbd.pool=Ceph pool
|
||||
label.rbd.id=Cephx user
|
||||
label.rbd.secret=Cephx secret
|
||||
label.code=Code
|
||||
label.community=Community
|
||||
label.compute.and.storage=Compute and Storage
|
||||
@ -540,6 +556,7 @@ label.end.IP=End IP
|
||||
label.end.port=End Port
|
||||
label.end.reserved.system.IP=End Reserved system IP
|
||||
label.end.vlan=End Vlan
|
||||
label.end.vxlan=End Vxlan
|
||||
label.endpoint.or.operation=Endpoint or Operation
|
||||
label.endpoint=Endpoint
|
||||
label.enter.token=Enter token
|
||||
@ -551,6 +568,7 @@ label.ESP.lifetime=ESP Lifetime (second)
|
||||
label.ESP.policy=ESP policy
|
||||
label.esx.host=ESX/ESXi Host
|
||||
label.example=Example
|
||||
label.expunge=Expunge
|
||||
label.external.link=External link
|
||||
label.f5=F5
|
||||
label.failed=Failed
|
||||
@ -799,6 +817,7 @@ label.network.domain.text=Network domain
|
||||
label.network.domain=Network Domain
|
||||
label.network.id=Network ID
|
||||
label.network.label.display.for.blank.value=Use default gateway
|
||||
label.network.limits=Network limits
|
||||
label.network.name=Network Name
|
||||
label.network.offering.display.text=Network Offering Display Text
|
||||
label.network.offering.id=Network Offering ID
|
||||
@ -1026,12 +1045,14 @@ label.source.nat=Source NAT
|
||||
label.source=Source
|
||||
label.specify.IP.ranges=Specify IP ranges
|
||||
label.specify.vlan=Specify VLAN
|
||||
label.specify.vxlan=Specify VXLAN
|
||||
label.SR.name = SR Name-Label
|
||||
label.srx=SRX
|
||||
label.start.IP=Start IP
|
||||
label.start.port=Start Port
|
||||
label.start.reserved.system.IP=Start Reserved system IP
|
||||
label.start.vlan=Start Vlan
|
||||
label.start.vxlan=Start Vxlan
|
||||
label.state=State
|
||||
label.static.nat.enabled=Static NAT Enabled
|
||||
label.static.nat.to=Static NAT to
|
||||
@ -1158,6 +1179,9 @@ label.virtual.routers=Virtual Routers
|
||||
label.vlan.id=VLAN ID
|
||||
label.vlan.range=VLAN Range
|
||||
label.vlan=VLAN
|
||||
label.vxlan.id=VXLAN ID
|
||||
label.vxlan.range=VXLAN Range
|
||||
label.vxlan=VXLAN
|
||||
label.vm.add=Add Instance
|
||||
label.vm.destroy=Destroy
|
||||
label.vm.display.name=VM display name
|
||||
@ -1263,6 +1287,7 @@ message.action.enable.nexusVswitch=Please confirm that you want to enable this n
|
||||
message.action.enable.physical.network=Please confirm that you want to enable this physical network.
|
||||
message.action.enable.pod=Please confirm that you want to enable this pod.
|
||||
message.action.enable.zone=Please confirm that you want to enable this zone.
|
||||
message.action.expunge.instance=Please confirm that you want to expunge this instance.
|
||||
message.action.force.reconnect=Your host has been successfully forced to reconnect. This process can take up to several minutes.
|
||||
message.action.host.enable.maintenance.mode=Enabling maintenance mode will cause a live migration of all running instances on this host to any available host.
|
||||
message.action.instance.reset.password=Please confirm that you want to change the ROOT password for this virtual machine.
|
||||
@ -1283,6 +1308,7 @@ message.action.stop.instance=Please confirm that you want to stop this instance.
|
||||
message.action.stop.router=All services provided by this virtual router will be interrupted. Please confirm that you want to stop this router.
|
||||
message.action.stop.systemvm=Please confirm that you want to stop this system VM.
|
||||
message.action.take.snapshot=Please confirm that you want to take a snapshot of this volume.
|
||||
message.action.revert.snapshot=Please confirm that you want to revert the owning volume to this snapshot.
|
||||
message.action.unmanage.cluster=Please confirm that you want to unmanage the cluster.
|
||||
message.action.vmsnapshot.delete=Please confirm that you want to delete this VM snapshot.
|
||||
message.action.vmsnapshot.revert=Revert VM snapshot
|
||||
|
||||
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