Merge branch 'main' into keyboard-shortcuts

This commit is contained in:
dahn 2024-04-18 09:45:58 +02:00 committed by GitHub
commit 5ec67af0d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3046 changed files with 60635 additions and 30743 deletions

View File

@ -53,13 +53,11 @@ github:
- acs-robot
- kiranchavala
- rajujith
- alexandremattioli
- vishesh92
- GaOrtiga
- BryanMLima
- SadiJr
- JoaoJandre
- winterhazel
- gpordeus
- hsato03
protected_branches: ~

View File

@ -33,7 +33,7 @@ jobs:
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'adopt'
@ -41,7 +41,7 @@ jobs:
cache: maven
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.8'
architecture: 'x64'

View File

@ -179,7 +179,8 @@ jobs:
"component/test_project_usage
component/test_protocol_number_security_group
component/test_public_ip
component/test_resource_limits",
component/test_resource_limits
component/test_resource_limit_tags",
"component/test_regions_accounts
component/test_routers
component/test_snapshots
@ -194,8 +195,15 @@ jobs:
component/test_vpc_network
component/test_vpc_offerings
component/test_vpc_routers
component/test_vpn_users",
"component/test_vpc_network_lbrules" ]
component/test_vpn_users
component/test_vpc_network_lbrules",
"smoke/test_list_accounts
smoke/test_list_disk_offerings
smoke/test_list_domains
smoke/test_list_hosts
smoke/test_list_service_offerings
smoke/test_list_storage_pools
smoke/test_list_volumes"]
steps:
- uses: actions/checkout@v4
@ -203,7 +211,7 @@ jobs:
fetch-depth: 0
- name: Set up JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'adopt'
@ -211,7 +219,7 @@ jobs:
cache: maven
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.8'
architecture: 'x64'
@ -278,7 +286,7 @@ jobs:
while ! nc -vzw 5 localhost 8096 2>&1 > /dev/null; do grep Exception /tmp/jetty-log; sleep 10; done
set -e
echo -e "\nStarting Advanced Zone DataCenter deployment"
python3 tools/marvin/marvin/deployDataCenter.py -i setup/dev/advanced.cfg 2>&1 || true
python3 tools/marvin/marvin/deployDataCenter.py -i setup/dev/advdualzone.cfg 2>&1 || true
- name: Run Integration Tests with Simulator
run: |
@ -291,7 +299,7 @@ jobs:
TESTS=($(echo $TESTS | tr -d '\n' | tr -s ' '))
for suite in "${TESTS[@]}" ; do
echo -e "Currently running test: $suite\n"
time nosetests-3.4 --with-xunit --xunit-file=integration-test-results/$suite.xml --with-marvin --marvin-config=setup/dev/advanced.cfg test/integration/$suite.py -s -a tags=advanced,required_hardware=false --zone=Sandbox-simulator --hypervisor=simulator || true ;
time nosetests-3.4 --with-xunit --xunit-file=integration-test-results/$suite.xml --with-marvin --marvin-config=setup/dev/advdualzone.cfg test/integration/$suite.py -s -a tags=advanced,required_hardware=false --zone=zim1 --hypervisor=simulator || true ;
done
echo -e "Stopping Simulator, integration tests run completed\n"

View File

@ -37,7 +37,7 @@ jobs:
fetch-depth: 0
- name: Set up JDK11
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'

View File

@ -37,7 +37,7 @@ jobs:
fetch-depth: 0
- name: Set up JDK11
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'

View File

@ -32,7 +32,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'adopt'

View File

@ -39,7 +39,7 @@ jobs:
fetch-depth: 0
- name: Set up JDK11
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '11'

View File

@ -15,7 +15,7 @@ was tested against a CentOS 7 x86_64 setup.
Install tools and dependencies used for development:
# yum -y install git java-11-openjdk java-11-openjdk-devel \
# yum -y install git java-17-openjdk java-17-openjdk-devel \
mysql mysql-server mkisofs git gcc python MySQL-python openssh-clients wget
Set up Maven (3.6.0):

View File

@ -5,9 +5,9 @@
# 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
@ -378,6 +378,10 @@ iscsi.session.cleanup.enabled=false
# If the time is exceeded shutdown will be forced.
#stop.script.timeout=120
# Time (in seconds) to wait for scripts to complete.
# This is currently used only while checking if the host supports UEFI.
#agent.script.timeout=60
# Definition of VMs video model type.
#vm.video.hardware=
@ -422,3 +426,7 @@ iscsi.session.cleanup.enabled=false
# Instance Conversion from Vmware to KVM through virt-v2v. Enable verbose mode
# virtv2v.verbose.enabled=false
# If set to "true", the agent will register for libvirt domain events, allowing for immediate updates on crashed or
# unexpectedly stopped. Experimental, requires agent restart.
# libvirt.events.enabled=false

View File

@ -17,91 +17,60 @@ KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<Configuration monitorInterval="60">
<Appenders>
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
<!-- ================================= -->
<!-- Preserve messages in a local file -->
<!-- ================================= -->
<!-- ================================= -->
<!-- Preserve messages in a local file -->
<!-- ================================= -->
<!-- A time/date based rolling appender -->
<RollingFile name="FILE" append="true" fileName="@AGENTLOG@" filePattern="@AGENTLOG@.%d{yyyy-MM-dd}.gz">
<ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="DENY"/>
<Policies>
<TimeBasedTriggeringPolicy/>
</Policies>
<PatternLayout pattern="%d{ISO8601} %-5p [%c{3}] (%t:%x) (logid:%X{logcontextid}) %m%ex%n"/>
</RollingFile>
<!-- A time/date based rolling appender -->
<appender name="FILE" class="org.apache.log4j.rolling.RollingFileAppender">
<param name="Append" value="true"/>
<param name="Threshold" value="INFO"/>
<rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
<param name="FileNamePattern" value="@AGENTLOG@.%d{yyyy-MM-dd}.gz"/>
<param name="ActiveFileName" value="@AGENTLOG@"/>
</rollingPolicy>
<layout class="org.apache.log4j.EnhancedPatternLayout">
<param name="ConversionPattern" value="%d{ISO8601} %-5p [%c{3}] (%t:%x) (logid:%X{logcontextid}) %m%n"/>
</layout>
</appender>
<!-- ============================== -->
<!-- Append messages to the console -->
<!-- ============================== -->
<!-- ============================== -->
<!-- Append messages to the console -->
<!-- ============================== -->
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out"/>
<param name="Threshold" value="INFO"/>
<Console name="CONSOLE" target="SYSTEM_OUT">
<ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="DENY"/>
<PatternLayout pattern="%-5p [%c{3}] (%t:%x) (logid:%X{logcontextid}) %m%ex%n"/>
</Console>
</Appenders>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%-5p [%c{3}] (%t:%x) (logid:%X{logcontextid}) %m%n"/>
</layout>
</appender>
<Loggers>
<!-- ================ -->
<!-- Limit categories -->
<!-- ================ -->
<!-- ================ -->
<!-- Limit categories -->
<!-- ================ -->
<category name="com.cloud">
<priority value="INFO"/>
</category>
<category name="com.cloud.agent.metrics">
<priority value="INFO"/>
</category>
<category name="com.cloud.agent.resource.computing.ComputingResource$StorageMonitorTask">
<priority value="INFO"/>
</category>
<Logger name="com.cloud" level="INFO"/>
<!-- Limit the org.apache category to INFO as its DEBUG is verbose -->
<category name="org.apache">
<priority value="INFO"/>
</category>
<Logger name="org.apache" level="INFO"/>
<category name="org">
<priority value="INFO"/>
</category>
<category name="net">
<priority value="INFO"/>
</category>
<Logger name="org" level="INFO"/>
<!-- Limit the com.amazonaws category to INFO as its DEBUG is verbose -->
<category name="com.amazonaws">
<priority value="INFO"/>
</category>
<Logger name="net" level="INFO"/>
<!-- Limit the httpclient.wire category to INFO as its DEBUG is verbose -->
<category name="httpclient.wire">
<priority value="INFO"/>
</category>
<Logger name="com.amazonaws" level="INFO"/>
<category name="org.apache.http.wire">
<priority value="INFO"/>
</category>
<Logger name="httpclient.wire" level="INFO"/>
<!-- ======================= -->
<!-- Setup the Root category -->
<!-- ======================= -->
<Logger name="org.apache.http.wire" level="INFO"/>
<root>
<level value="INFO"/>
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</root>
<!-- ======================= -->
<!-- Setup the Root category -->
<!-- ======================= -->
</log4j:configuration>
<Root level="INFO">
<AppenderRef ref="CONSOLE"/>
<AppenderRef ref="FILE"/>
</Root>
</Loggers>
</Configuration>

View File

@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloudstack</artifactId>
<version>4.19.0.0-SNAPSHOT</version>
<version>4.20.0.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>

View File

@ -55,9 +55,10 @@ import org.apache.cloudstack.managed.context.ManagedContextTimerTask;
import org.apache.cloudstack.utils.security.KeyStoreUtils;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.apache.log4j.MDC;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import com.cloud.agent.api.AgentControlAnswer;
import com.cloud.agent.api.AgentControlCommand;
@ -89,6 +90,7 @@ import com.cloud.utils.nio.NioConnection;
import com.cloud.utils.nio.Task;
import com.cloud.utils.script.OutputInterpreter;
import com.cloud.utils.script.Script;
import org.apache.logging.log4j.ThreadContext;
/**
* @config
@ -104,7 +106,7 @@ import com.cloud.utils.script.Script;
*
**/
public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater {
protected static Logger s_logger = Logger.getLogger(Agent.class);
protected Logger logger = LogManager.getLogger(getClass());
public enum ExitStatus {
Normal(0), // Normal status = 0.
@ -181,7 +183,7 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
final String value = _shell.getPersistentProperty(getResourceName(), "id");
_id = value != null ? Long.parseLong(value) : null;
s_logger.info("id is " + (_id != null ? _id : ""));
logger.info("id is {}", ObjectUtils.defaultIfNull(_id, ""));
final Map<String, Object> params = new HashMap<>();
@ -199,7 +201,7 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
// ((NioClient)_connection).setBindAddress(_shell.getPrivateIp());
s_logger.debug("Adding shutdown hook");
logger.debug("Adding shutdown hook");
Runtime.getRuntime().addShutdownHook(_shutdownThread);
_ugentTaskPool =
@ -210,8 +212,8 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
new ThreadPoolExecutor(_shell.getWorkers(), 5 * _shell.getWorkers(), 1, TimeUnit.DAYS, new LinkedBlockingQueue<Runnable>(), new NamedThreadFactory(
"agentRequest-Handler"));
s_logger.info("Agent [id = " + (_id != null ? _id : "new") + " : type = " + getResourceName() + " : zone = " + _shell.getZone() + " : pod = " + _shell.getPod() +
" : workers = " + _shell.getWorkers() + " : host = " + host + " : port = " + _shell.getPort());
logger.info("Agent [id = {} : type = {} : zone = {} : pod = {} : workers = {} : host = {} : port = {}", ObjectUtils.defaultIfNull(_id, "new"), getResourceName(),
_shell.getZone(), _shell.getPod(), _shell.getWorkers(), host, _shell.getPort());
}
public String getVersion() {
@ -268,7 +270,7 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
public void start() {
if (!_resource.start()) {
s_logger.error("Unable to start the resource: " + _resource.getName());
logger.error("Unable to start the resource: {}", _resource.getName());
throw new CloudRuntimeException("Unable to start the resource: " + _resource.getName());
}
@ -285,14 +287,13 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
try {
_connection.start();
} catch (final NioConnectionException e) {
s_logger.warn("NIO Connection Exception " + e);
s_logger.info("Attempted to connect to the server, but received an unexpected exception, trying again...");
logger.warn("Attempt to connect to server generated NIO Connection Exception {}, trying again", e.getLocalizedMessage());
}
while (!_connection.isStartup()) {
final String host = _shell.getNextHost();
_shell.getBackoffAlgorithm().waitBeforeRetry();
_connection = new NioClient("Agent", host, _shell.getPort(), _shell.getWorkers(), this);
s_logger.info("Connecting to host:" + host);
logger.info("Connecting to host:{}", host);
try {
_connection.start();
} catch (final NioConnectionException e) {
@ -300,9 +301,9 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
try {
_connection.cleanUp();
} catch (final IOException ex) {
s_logger.warn("Fail to clean up old connection. " + ex);
logger.warn("Fail to clean up old connection. {}", ex);
}
s_logger.info("Attempted to connect to the server, but received an unexpected exception, trying again...", e);
logger.info("Attempted to connect to the server, but received an unexpected exception, trying again...", e);
}
}
_shell.updateConnectedHost();
@ -311,7 +312,7 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
}
public void stop(final String reason, final String detail) {
s_logger.info("Stopping the agent: Reason = " + reason + (detail != null ? ": Detail = " + detail : ""));
logger.info("Stopping the agent: Reason = {} {}", reason, ": Detail = " + ObjectUtils.defaultIfNull(detail, ""));
_reconnectAllowed = false;
if (_connection != null) {
final ShutdownCommand cmd = new ShutdownCommand(reason, detail);
@ -321,15 +322,15 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
_link.send(req.toBytes());
}
} catch (final ClosedChannelException e) {
s_logger.warn("Unable to send: " + cmd.toString());
logger.warn("Unable to send: {}", cmd.toString());
} catch (final Exception e) {
s_logger.warn("Unable to send: " + cmd.toString() + " due to exception: ", e);
logger.warn("Unable to send: {} due to exception: {}", cmd.toString(), e);
}
s_logger.debug("Sending shutdown to management server");
logger.debug("Sending shutdown to management server");
try {
Thread.sleep(1000);
} catch (final InterruptedException e) {
s_logger.debug("Who the heck interrupted me here?");
logger.debug("Who the heck interrupted me here?");
}
_connection.stop();
_connection = null;
@ -376,7 +377,7 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
}
public void setId(final Long id) {
s_logger.info("Set agent id " + id);
logger.debug("Set agent id {}", id);
_id = id;
_shell.setPersistentProperty(getResourceName(), "id", Long.toString(id));
}
@ -395,7 +396,7 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
hostLBTimer.cancel();
}
if (checkInterval > 0L) {
s_logger.info("Scheduling preferred host timer task with host.lb.interval=" + checkInterval + "ms");
logger.info("Scheduling preferred host timer task with host.lb.interval={}ms", checkInterval);
hostLBTimer = new Timer("Host LB Timer");
hostLBTimer.scheduleAtFixedRate(new PreferredHostCheckerTask(), checkInterval, checkInterval);
}
@ -403,9 +404,8 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
public void scheduleWatch(final Link link, final Request request, final long delay, final long period) {
synchronized (_watchList) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Adding a watch list");
}
logger.debug("Adding task with request: {} to watch list", request.toString());
final WatchTask task = new WatchTask(link, request, this);
_timer.schedule(task, 0, period);
_watchList.add(task);
@ -415,14 +415,14 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
public void triggerUpdate() {
PingCommand command = _resource.getCurrentStatus(getId());
command.setOutOfBand(true);
s_logger.debug("Sending out of band ping");
logger.debug("Sending out of band ping");
final Request request = new Request(_id, -1, command, false);
request.setSequence(getNextSequence());
try {
_link.send(request.toBytes());
} catch (final ClosedChannelException e) {
s_logger.warn("Unable to send ping update: " + request.toString());
logger.warn("Unable to send ping update: {}", request.toString());
}
}
@ -431,9 +431,7 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
for (final WatchTask task : _watchList) {
task.cancel();
}
if (s_logger.isDebugEnabled()) {
s_logger.debug("Clearing watch list: " + _watchList.size());
}
logger.debug("Clearing {} tasks of watch list", _watchList.size());
_watchList.clear();
}
}
@ -469,14 +467,12 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
final Request request = new Request(_id != null ? _id : -1, -1, commands, false, false);
request.setSequence(getNextSequence());
if (s_logger.isDebugEnabled()) {
s_logger.debug("Sending Startup: " + request.toString());
}
logger.debug("Sending Startup: {}", request.toString());
lockStartupTask(link);
try {
link.send(request.toBytes());
} catch (final ClosedChannelException e) {
s_logger.warn("Unable to send request: " + request.toString());
logger.warn("Unable to send request: {}", request.toString());
}
if (_resource instanceof ResourceStatusUpdater) {
@ -490,11 +486,11 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
try {
addr = InetAddress.getLocalHost();
} catch (final UnknownHostException e) {
s_logger.warn("unknown host? ", e);
logger.warn("unknown host? ", e);
throw new CloudRuntimeException("Cannot get local IP address");
}
final Script command = new Script("hostname", 500, s_logger);
final Script command = new Script("hostname", 500, logger);
final OutputInterpreter.OneLineParser parser = new OutputInterpreter.OneLineParser();
final String result = command.execute(parser);
final String hostname = result == null ? parser.getLine() : addr.toString();
@ -536,14 +532,14 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
_resource.disconnected();
s_logger.info("Lost connection to host: " + _shell.getConnectedHost() + ". Attempting reconnection while we still have " + _inProgress.get() + " commands in progress.");
logger.info("Lost connection to host: {}. Attempting reconnection while we still have {} commands in progress.", _shell.getConnectedHost(), _inProgress.get());
_connection.stop();
try {
_connection.cleanUp();
} catch (final IOException e) {
s_logger.warn("Fail to clean up old connection. " + e);
logger.warn("Fail to clean up old connection. {}", e);
}
while (_connection.isStartup()) {
@ -553,22 +549,22 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
do {
final String host = _shell.getNextHost();
_connection = new NioClient("Agent", host, _shell.getPort(), _shell.getWorkers(), this);
s_logger.info("Reconnecting to host:" + host);
logger.info("Reconnecting to host:{}", host);
try {
_connection.start();
} catch (final NioConnectionException e) {
s_logger.info("Attempted to re-connect to the server, but received an unexpected exception, trying again...", e);
logger.info("Attempted to re-connect to the server, but received an unexpected exception, trying again...", e);
_connection.stop();
try {
_connection.cleanUp();
} catch (final IOException ex) {
s_logger.warn("Fail to clean up old connection. " + ex);
logger.warn("Fail to clean up old connection. {}", ex);
}
}
_shell.getBackoffAlgorithm().waitBeforeRetry();
} while (!_connection.isStartup());
_shell.updateConnectedHost();
s_logger.info("Connected to the host: " + _shell.getConnectedHost());
logger.info("Connected to the host: {}", _shell.getConnectedHost());
}
public void processStartupAnswer(final Answer answer, final Response response, final Link link) {
@ -583,15 +579,15 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
}
final StartupAnswer startup = (StartupAnswer)answer;
if (!startup.getResult()) {
s_logger.error("Not allowed to connect to the server: " + answer.getDetails());
logger.error("Not allowed to connect to the server: {}", answer.getDetails());
System.exit(1);
}
if (cancelled) {
s_logger.warn("Threw away a startup answer because we're reconnecting.");
logger.warn("Threw away a startup answer because we're reconnecting.");
return;
}
s_logger.info("Process agent startup answer, agent id = " + startup.getHostId());
logger.info("Process agent startup answer, agent id = {}", startup.getHostId());
setId(startup.getHostId());
_pingInterval = (long)startup.getPingInterval() * 1000; // change to ms.
@ -601,7 +597,7 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
_ugentTaskPool.setKeepAliveTime(2 * _pingInterval, TimeUnit.MILLISECONDS);
s_logger.info("Startup Response Received: agent id = " + getId());
logger.info("Startup Response Received: agent id = {}", getId());
}
protected void processRequest(final Request request, final Link link) {
@ -616,18 +612,18 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
Answer answer;
try {
if (cmd.getContextParam("logid") != null) {
MDC.put("logcontextid", cmd.getContextParam("logid"));
ThreadContext.put("logcontextid", cmd.getContextParam("logid"));
}
if (s_logger.isDebugEnabled()) {
if (logger.isDebugEnabled()) {
if (!requestLogged) // ensures request is logged only once per method call
{
final String requestMsg = request.toString();
if (requestMsg != null) {
s_logger.debug("Request:" + requestMsg);
logger.debug("Request:{}",requestMsg);
}
requestLogged = true;
}
s_logger.debug("Processing command: " + cmd.toString());
logger.debug("Processing command: {}", cmd.toString());
}
if (cmd instanceof CronCommand) {
@ -636,7 +632,7 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
answer = new Answer(cmd, true, null);
} else if (cmd instanceof ShutdownCommand) {
final ShutdownCommand shutdown = (ShutdownCommand)cmd;
s_logger.debug("Received shutdownCommand, due to: " + shutdown.getReason());
logger.debug("Received shutdownCommand, due to: {}", shutdown.getReason());
cancelTasks();
if (shutdown.isRemoveHost()) {
cleanupAgentZoneProperties();
@ -644,11 +640,11 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
_reconnectAllowed = false;
answer = new Answer(cmd, true, null);
} else if (cmd instanceof ReadyCommand && ((ReadyCommand)cmd).getDetails() != null) {
s_logger.debug("Not ready to connect to mgt server: " + ((ReadyCommand)cmd).getDetails());
logger.debug("Not ready to connect to mgt server: {}", ((ReadyCommand)cmd).getDetails());
System.exit(1);
return;
} else if (cmd instanceof MaintainCommand) {
s_logger.debug("Received maintainCommand, do not cancel current tasks");
logger.debug("Received maintainCommand, do not cancel current tasks");
answer = new MaintainAnswer((MaintainCommand)cmd);
} else if (cmd instanceof AgentControlCommand) {
answer = null;
@ -662,7 +658,7 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
}
if (answer == null) {
s_logger.warn("No handler found to process cmd: " + cmd.toString());
logger.warn("No handler found to process cmd: {}", cmd.toString());
answer = new AgentControlAnswer(cmd);
}
} else if (cmd instanceof SetupKeyStoreCommand && ((SetupKeyStoreCommand) cmd).isHandleByAgent()) {
@ -685,12 +681,12 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
_inProgress.decrementAndGet();
}
if (answer == null) {
s_logger.debug("Response: unsupported command" + cmd.toString());
logger.debug("Response: unsupported command {}", cmd.toString());
answer = Answer.createUnsupportedCommandAnswer(cmd);
}
}
} catch (final Throwable th) {
s_logger.warn("Caught: ", th);
logger.warn("Caught: ", th);
final StringWriter writer = new StringWriter();
th.printStackTrace(new PrintWriter(writer));
answer = new Answer(cmd, false, writer.toString());
@ -706,10 +702,10 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
}
response = new Response(request, answers);
} finally {
if (s_logger.isDebugEnabled()) {
if (logger.isDebugEnabled()) {
final String responseMsg = response.toString();
if (responseMsg != null) {
s_logger.debug(response.toString());
logger.debug(response.toString());
}
}
@ -717,7 +713,7 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
try {
link.send(response.toBytes());
} catch (final ClosedChannelException e) {
s_logger.warn("Unable to send response: " + response.toString());
logger.warn("Unable to send response: {}", response.toString());
}
}
}
@ -727,7 +723,7 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
final String keyStorePassword = cmd.getKeystorePassword();
final long validityDays = cmd.getValidityDays();
s_logger.debug("Setting up agent keystore file and generating CSR");
logger.debug("Setting up agent keystore file and generating CSR");
final File agentFile = PropertiesUtil.findConfigFile("agent.properties");
if (agentFile == null) {
@ -742,7 +738,7 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
_shell.setPersistentProperty(null, KeyStoreUtils.KS_PASSPHRASE_PROPERTY, storedPassword);
}
Script script = new Script(_keystoreSetupPath, 300000, s_logger);
Script script = new Script(_keystoreSetupPath, 300000, logger);
script.add(agentFile.getAbsolutePath());
script.add(keyStoreFile);
script.add(storedPassword);
@ -767,7 +763,7 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
final String privateKey = cmd.getPrivateKey();
final String caCertificates = cmd.getCaCertificates();
s_logger.debug("Importing received certificate to agent's keystore");
logger.debug("Importing received certificate to agent's keystore");
final File agentFile = PropertiesUtil.findConfigFile("agent.properties");
if (agentFile == null) {
@ -781,13 +777,13 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
try {
FileUtils.writeStringToFile(new File(certFile), certificate, Charset.defaultCharset());
FileUtils.writeStringToFile(new File(caCertFile), caCertificates, Charset.defaultCharset());
s_logger.debug("Saved received client certificate to: " + certFile);
logger.debug("Saved received client certificate to: {}", certFile);
} catch (IOException e) {
throw new CloudRuntimeException("Unable to save received agent client and ca certificates", e);
}
String ksPassphrase = _shell.getPersistentProperty(null, KeyStoreUtils.KS_PASSPHRASE_PROPERTY);
Script script = new Script(_keystoreCertImportPath, 300000, s_logger);
Script script = new Script(_keystoreCertImportPath, 300000, logger);
script.add(agentFile.getAbsolutePath());
script.add(ksPassphrase);
script.add(keyStoreFile);
@ -812,7 +808,7 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
_shell.setPersistentProperty(null, "host", newMSHosts);
_shell.setHosts(newMSHosts);
_shell.resetHostCounter();
s_logger.info("Processed new management server list: " + newMSHosts);
logger.info("Processed new management server list: {}", newMSHosts);
} catch (final Exception e) {
throw new CloudRuntimeException("Could not persist received management servers list", e);
}
@ -831,9 +827,7 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
public void processResponse(final Response response, final Link link) {
final Answer answer = response.getAnswer();
if (s_logger.isDebugEnabled()) {
s_logger.debug("Received response: " + response.toString());
}
logger.debug("Received response: {}", response.toString());
if (answer instanceof StartupAnswer) {
processStartupAnswer(answer, response, link);
} else if (answer instanceof AgentControlAnswer) {
@ -844,7 +838,7 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
}
}
} else if (answer instanceof PingAnswer && (((PingAnswer) answer).isSendStartup()) && _reconnectAllowed) {
s_logger.info("Management server requested startup command to reinitialize the agent");
logger.info("Management server requested startup command to reinitialize the agent");
sendStartup(link);
} else {
setLastPingResponseTime();
@ -859,44 +853,42 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
NumbersUtil.enableHumanReadableSizes = humanReadable;
}
s_logger.info("Processing agent ready command, agent id = " + ready.getHostId());
logger.info("Processing agent ready command, agent id = {}", ready.getHostId());
if (ready.getHostId() != null) {
setId(ready.getHostId());
}
processManagementServerList(ready.getMsHostList(), ready.getLbAlgorithm(), ready.getLbCheckInterval());
s_logger.info("Ready command is processed for agent id = " + getId());
logger.info("Ready command is processed for agent id = {}", getId());
}
public void processOtherTask(final Task task) {
final Object obj = task.get();
if (obj instanceof Response) {
if (System.currentTimeMillis() - _lastPingResponseTime > _pingInterval * _shell.getPingRetries()) {
s_logger.error("Ping Interval has gone past " + _pingInterval * _shell.getPingRetries() + ". Won't reconnect to mgt server, as connection is still alive");
logger.error("Ping Interval has gone past {}. Won't reconnect to mgt server, as connection is still alive", _pingInterval * _shell.getPingRetries());
return;
}
final PingCommand ping = _resource.getCurrentStatus(getId());
final Request request = new Request(_id, -1, ping, false);
request.setSequence(getNextSequence());
if (s_logger.isDebugEnabled()) {
s_logger.debug("Sending ping: " + request.toString());
}
logger.debug("Sending ping: {}", request.toString());
try {
task.getLink().send(request.toBytes());
//if i can send pingcommand out, means the link is ok
setLastPingResponseTime();
} catch (final ClosedChannelException e) {
s_logger.warn("Unable to send request: " + request.toString());
logger.warn("Unable to send request: {}", request.toString());
}
} else if (obj instanceof Request) {
final Request req = (Request)obj;
final Command command = req.getCommand();
if (command.getContextParam("logid") != null) {
MDC.put("logcontextid", command.getContextParam("logid"));
ThreadContext.put("logcontextid", command.getContextParam("logid"));
}
Answer answer = null;
_inProgress.incrementAndGet();
@ -908,17 +900,15 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
if (answer != null) {
final Response response = new Response(req, answer);
if (s_logger.isDebugEnabled()) {
s_logger.debug("Watch Sent: " + response.toString());
}
logger.debug("Watch Sent: {}", response.toString());
try {
task.getLink().send(response.toBytes());
} catch (final ClosedChannelException e) {
s_logger.warn("Unable to send response: " + response.toString());
logger.warn("Unable to send response: {}", response.toString());
}
}
} else {
s_logger.warn("Ignoring an unknown task");
logger.warn("Ignoring an unknown task");
}
}
@ -958,7 +948,7 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
try {
listener.wait(timeoutInMilliseconds);
} catch (final InterruptedException e) {
s_logger.warn("sendRequest is interrupted, exit waiting");
logger.warn("sendRequest is interrupted, exit waiting");
}
}
@ -980,7 +970,7 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
try {
_link.send(request.toBytes());
} catch (final ClosedChannelException e) {
s_logger.warn("Unable to post agent control request: " + request.toString());
logger.warn("Unable to post agent control request: {}", request.toString());
throw new AgentControlChannelException("Unable to post agent control request due to " + e.getMessage());
}
} else {
@ -1044,9 +1034,7 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
@Override
protected void runInContext() {
if (s_logger.isTraceEnabled()) {
s_logger.trace("Scheduling " + (_request instanceof Response ? "Ping" : "Watch Task"));
}
logger.trace("Scheduling {}", (_request instanceof Response ? "Ping" : "Watch Task"));
try {
if (_request instanceof Response) {
_ugentTaskPool.submit(new ServerHandler(Task.Type.OTHER, _link, _request));
@ -1054,7 +1042,7 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
_link.schedule(new ServerHandler(Task.Type.OTHER, _link, _request));
}
} catch (final ClosedChannelException e) {
s_logger.warn("Unable to schedule task because channel is closed");
logger.warn("Unable to schedule task because channel is closed");
}
}
}
@ -1064,7 +1052,7 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
protected volatile boolean cancelled = false;
public StartupTask(final Link link) {
s_logger.debug("Startup task created");
logger.debug("Startup task created");
_link = link;
}
@ -1074,7 +1062,7 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
if (!cancelled) {
cancelled = true;
_startupWait = _startupWaitDefault;
s_logger.debug("Startup task cancelled");
logger.debug("Startup task cancelled");
return super.cancel();
}
return true;
@ -1083,9 +1071,7 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
@Override
protected synchronized void runInContext() {
if (!cancelled) {
if (s_logger.isInfoEnabled()) {
s_logger.info("The startup command is now cancelled");
}
logger.info("The startup command is now cancelled");
cancelled = true;
_startup = null;
_startupWait = _startupWaitDefault * 2;
@ -1136,9 +1122,9 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
_executor.submit(new AgentRequestHandler(getType(), getLink(), request));
}
} catch (final ClassNotFoundException e) {
s_logger.error("Unable to find this request ");
logger.error("Unable to find this request ");
} catch (final Exception e) {
s_logger.error("Error parsing task", e);
logger.error("Error parsing task", e);
}
} else if (task.getType() == Task.Type.DISCONNECT) {
reconnect(task.getLink());
@ -1166,7 +1152,7 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
while (true) {
try {
if (_inProgress.get() == 0) {
s_logger.debug("Running post certificate renewal task to restart services.");
logger.debug("Running post certificate renewal task to restart services.");
// Let the resource perform any post certificate renewal cleanups
_resource.executeRequest(new PostCertificateRenewalCommand());
@ -1191,12 +1177,11 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
shell.launchNewAgent(resource);
return;
}
if (s_logger.isTraceEnabled()) {
s_logger.debug("Other tasks are in progress, will retry post certificate renewal command after few seconds");
}
logger.debug("Other tasks are in progress, will retry post certificate renewal command after few seconds");
Thread.sleep(5000);
} catch (final Exception e) {
s_logger.warn("Failed to execute post certificate renewal command:", e);
logger.warn("Failed to execute post certificate renewal command:", e);
break;
}
}
@ -1214,29 +1199,26 @@ public class Agent implements HandlerFactory, IAgentControl, AgentStatusUpdater
}
final String preferredHost = msList[0];
final String connectedHost = _shell.getConnectedHost();
if (s_logger.isTraceEnabled()) {
s_logger.trace("Running preferred host checker task, connected host=" + connectedHost + ", preferred host=" + preferredHost);
}
logger.trace("Running preferred host checker task, connected host={}, preferred host={}", connectedHost, preferredHost);
if (preferredHost != null && !preferredHost.equals(connectedHost) && _link != null) {
boolean isHostUp = true;
try (final Socket socket = new Socket()) {
socket.connect(new InetSocketAddress(preferredHost, _shell.getPort()), 5000);
} catch (final IOException e) {
isHostUp = false;
if (s_logger.isTraceEnabled()) {
s_logger.trace("Host: " + preferredHost + " is not reachable");
}
logger.trace("Host: {} is not reachable", preferredHost);
}
if (isHostUp && _link != null && _inProgress.get() == 0) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Preferred host " + preferredHost + " is found to be reachable, trying to reconnect");
}
logger.debug("Preferred host {} is found to be reachable, trying to reconnect", preferredHost);
_shell.resetHostCounter();
reconnect(_link);
}
}
} catch (Throwable t) {
s_logger.error("Error caught while attempting to connect to preferred host", t);
logger.error("Error caught while attempting to connect to preferred host", t);
}
}

View File

@ -34,8 +34,9 @@ import org.apache.commons.daemon.DaemonInitException;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.apache.log4j.xml.DOMConfigurator;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.config.Configurator;
import javax.naming.ConfigurationException;
import java.io.File;
@ -53,7 +54,7 @@ import java.util.Properties;
import java.util.UUID;
public class AgentShell implements IAgentShell, Daemon {
private static final Logger s_logger = Logger.getLogger(AgentShell.class.getName());
protected static Logger LOGGER = LogManager.getLogger(AgentShell.class);
private final Properties _properties = new Properties();
private final Map<String, Object> _cmdLineProperties = new HashMap<String, Object>();
@ -221,7 +222,7 @@ public class AgentShell implements IAgentShell, Daemon {
throw new ConfigurationException("Unable to find agent.properties.");
}
s_logger.info("agent.properties found at " + file.getAbsolutePath());
LOGGER.info("agent.properties found at {}", file.getAbsolutePath());
try {
PropertiesUtil.loadFromFile(_properties, file);
@ -349,7 +350,7 @@ public class AgentShell implements IAgentShell, Daemon {
@Override
public void init(DaemonContext dc) throws DaemonInitException {
s_logger.debug("Initializing AgentShell from JSVC");
LOGGER.debug("Initializing AgentShell from JSVC");
try {
init(dc.getArguments());
} catch (ConfigurationException ex) {
@ -369,11 +370,11 @@ public class AgentShell implements IAgentShell, Daemon {
}
if (null != file) {
DOMConfigurator.configureAndWatch(file.getAbsolutePath());
Configurator.initialize(null, file.getAbsolutePath());
s_logger.info("Agent started");
LOGGER.info("Agent started");
} else {
s_logger.error("Could not start the Agent because the absolute path of the \"log4j-cloud.xml\" file cannot be determined.");
LOGGER.error("Could not start the Agent because the absolute path of the \"log4j-cloud.xml\" file cannot be determined.");
}
final Class<?> c = this.getClass();
@ -381,19 +382,19 @@ public class AgentShell implements IAgentShell, Daemon {
if (_version == null) {
throw new CloudRuntimeException("Unable to find the implementation version of this agent");
}
s_logger.info("Implementation Version is " + _version);
LOGGER.info("Implementation Version is {}", _version);
loadProperties();
parseCommand(args);
if (s_logger.isDebugEnabled()) {
if (LOGGER.isDebugEnabled()) {
List<String> properties = Collections.list((Enumeration<String>)_properties.propertyNames());
for (String property : properties) {
s_logger.debug("Found property: " + property);
LOGGER.debug("Found property: {}", property);
}
}
s_logger.info("Defaulting to using properties file for storage");
LOGGER.info("Defaulting to using properties file for storage");
_storage = new PropertiesStorage();
_storage.configure("Storage", new HashMap<String, Object>());
@ -403,14 +404,14 @@ public class AgentShell implements IAgentShell, Daemon {
_properties.put(cmdLineProp.getKey(), cmdLineProp.getValue());
}
s_logger.info("Defaulting to the constant time backoff algorithm");
LOGGER.info("Defaulting to the constant time backoff algorithm");
_backoff = new ConstantTimeBackoff();
_backoff.configure("ConstantTimeBackoff", new HashMap<String, Object>());
}
private void launchAgent() throws ConfigurationException {
String resourceClassNames = AgentPropertiesFileHandler.getPropertyValue(AgentProperties.RESOURCE);
s_logger.trace("resource=" + resourceClassNames);
LOGGER.trace("resource={}", resourceClassNames);
if (resourceClassNames != null) {
launchAgentFromClassInfo(resourceClassNames);
return;
@ -440,10 +441,10 @@ public class AgentShell implements IAgentShell, Daemon {
private void launchAgentFromTypeInfo() throws ConfigurationException {
String typeInfo = getProperty(null, "type");
if (typeInfo == null) {
s_logger.error("Unable to retrieve the type");
LOGGER.error("Unable to retrieve the type");
throw new ConfigurationException("Unable to retrieve the type of this agent.");
}
s_logger.trace("Launching agent based on type=" + typeInfo);
LOGGER.trace("Launching agent based on type={}", typeInfo);
}
public void launchNewAgent(ServerResource resource) throws ConfigurationException {
@ -477,17 +478,17 @@ public class AgentShell implements IAgentShell, Daemon {
}
if (ipv6disabled) {
s_logger.info("Preferring IPv4 address family for agent connection");
LOGGER.info("Preferring IPv4 address family for agent connection");
System.setProperty("java.net.preferIPv4Stack", "true");
if (ipv6prefer) {
s_logger.info("ipv6prefer is set to true, but ipv6disabled is false. Not preferring IPv6 for agent connection");
LOGGER.info("ipv6prefer is set to true, but ipv6disabled is false. Not preferring IPv6 for agent connection");
}
} else {
if (ipv6prefer) {
s_logger.info("Preferring IPv6 address family for agent connection");
LOGGER.info("Preferring IPv6 address family for agent connection");
System.setProperty("java.net.preferIPv6Addresses", "true");
} else {
s_logger.info("Using default Java settings for IPv6 preference for agent connection");
LOGGER.info("Using default Java settings for IPv6 preference for agent connection");
}
}
@ -505,7 +506,7 @@ public class AgentShell implements IAgentShell, Daemon {
String pidDir = getProperty(null, "piddir");
final String run = "agent." + instance + "pid";
s_logger.debug("Checking to see if " + run + " exists.");
LOGGER.debug("Checking to see if {} exists.", run);
ProcessUtil.pidCheck(pidDir, run);
launchAgent();
@ -514,11 +515,11 @@ public class AgentShell implements IAgentShell, Daemon {
while (!_exit)
Thread.sleep(1000);
} catch (InterruptedException e) {
s_logger.debug("[ignored] AgentShell was interrupted.");
LOGGER.debug("[ignored] AgentShell was interrupted.");
}
} catch (final Exception e) {
s_logger.error("Unable to start agent: ", e);
LOGGER.error("Unable to start agent: ", e);
System.exit(ExitStatus.Error.value());
}
}
@ -535,7 +536,7 @@ public class AgentShell implements IAgentShell, Daemon {
public static void main(String[] args) {
try {
s_logger.debug("Initializing AgentShell from main");
LOGGER.debug("Initializing AgentShell from main");
AgentShell shell = new AgentShell();
shell.init(args);
shell.start();

View File

@ -24,7 +24,8 @@ import java.util.Map;
import java.util.Properties;
import org.apache.commons.io.IOUtils;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import com.cloud.agent.dao.StorageComponent;
import com.cloud.utils.PropertiesUtil;
@ -36,7 +37,7 @@ import com.cloud.utils.PropertiesUtil;
* path to the properties _file | String | db/db.properties || * }
**/
public class PropertiesStorage implements StorageComponent {
private static final Logger s_logger = Logger.getLogger(PropertiesStorage.class);
protected Logger logger = LogManager.getLogger(getClass());
Properties _properties = new Properties();
File _file;
String _name;
@ -49,7 +50,7 @@ public class PropertiesStorage implements StorageComponent {
@Override
public synchronized void persist(String key, String value) {
if (!loadFromFile(_file)) {
s_logger.error("Failed to load changes and then write to them");
logger.error("Failed to load changes and then write to them");
}
_properties.setProperty(key, value);
FileOutputStream output = null;
@ -59,7 +60,7 @@ public class PropertiesStorage implements StorageComponent {
output.flush();
output.close();
} catch (IOException e) {
s_logger.error("Uh-oh: ", e);
logger.error("Uh-oh: ", e);
} finally {
IOUtils.closeQuietly(output);
}
@ -70,10 +71,10 @@ public class PropertiesStorage implements StorageComponent {
PropertiesUtil.loadFromFile(_properties, file);
_file = file;
} catch (FileNotFoundException e) {
s_logger.error("How did we get here? ", e);
logger.error("How did we get here? ", e);
return false;
} catch (IOException e) {
s_logger.error("IOException: ", e);
logger.error("IOException: ", e);
return false;
}
return true;
@ -92,14 +93,12 @@ public class PropertiesStorage implements StorageComponent {
file = new File(path);
try {
if (!file.createNewFile()) {
s_logger.error(String.format("Unable to create _file: %s", file.getAbsolutePath()));
logger.error("Unable to create _file: {}", file.getAbsolutePath());
return false;
}
} catch (IOException e) {
s_logger.error(String.format("Unable to create file: %s", file.getAbsolutePath()));
if (s_logger.isDebugEnabled()) {
s_logger.debug(String.format("IOException while trying to create file: %s", file.getAbsolutePath()), e);
}
logger.error("Unable to create file: {}", file.getAbsolutePath());
logger.debug("IOException while trying to create file: {}", file.getAbsolutePath(), e);
return false;
}
}

View File

@ -25,12 +25,13 @@ import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import org.apache.log4j.Logger;
import com.cloud.utils.concurrency.NamedThreadFactory;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
public class DhcpProtocolParserServer extends Thread {
private static final Logger s_logger = Logger.getLogger(DhcpProtocolParserServer.class);;
protected Logger logger = LogManager.getLogger(DhcpProtocolParserServer.class);;
protected ExecutorService _executor;
private int dhcpServerPort = 67;
private int bufferSize = 300;
@ -54,7 +55,7 @@ public class DhcpProtocolParserServer extends Thread {
dhcpSocket.receive(dgp);
}
} catch (IOException e) {
s_logger.debug(e.getMessage());
logger.debug(e.getMessage());
}
}
}

View File

@ -22,14 +22,15 @@ import java.util.Map;
import java.util.Random;
import java.util.Set;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import com.cloud.agent.api.to.VirtualMachineTO;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.vm.VirtualMachine.State;
public class MockVmMgr implements VmMgr {
private static final Logger s_logger = Logger.getLogger(MockVmMgr.class);
protected Logger logger = LogManager.getLogger(getClass());
private static final int DEFAULT_DOM0_MEM_MB = 128;
private static final Random randSeed = new Random();
@ -56,14 +57,14 @@ public class MockVmMgr implements VmMgr {
public String startVM(String vmName, String vnetId, String gateway, String dns, String privateIP, String privateMac, String privateMask, String publicIP,
String publicMac, String publicMask, int cpuCount, int cpuUtilization, long ramSize, String localPath, String vncPassword) {
if (s_logger.isInfoEnabled()) {
if (logger.isInfoEnabled()) {
StringBuffer sb = new StringBuffer();
sb.append("Start VM. name: " + vmName + ", vnet: " + vnetId + ", dns: " + dns);
sb.append(", privateIP: " + privateIP + ", privateMac: " + privateMac + ", privateMask: " + privateMask);
sb.append(", publicIP: " + publicIP + ", publicMac: " + publicMac + ", publicMask: " + publicMask);
sb.append(", cpu count: " + cpuCount + ", cpuUtilization: " + cpuUtilization + ", ram : " + ramSize);
sb.append(", localPath: " + localPath);
s_logger.info(sb.toString());
logger.info(sb.toString());
}
synchronized (this) {
@ -86,8 +87,7 @@ public class MockVmMgr implements VmMgr {
@Override
public String stopVM(String vmName, boolean force) {
if (s_logger.isInfoEnabled())
s_logger.info("Stop VM. name: " + vmName);
logger.info("Stop VM. name: {}", vmName);
synchronized (this) {
MockVm vm = vms.get(vmName);
@ -102,8 +102,7 @@ public class MockVmMgr implements VmMgr {
@Override
public String rebootVM(String vmName) {
if (s_logger.isInfoEnabled())
s_logger.info("Reboot VM. name: " + vmName);
logger.info("Reboot VM. name: {}", vmName);
synchronized (this) {
MockVm vm = vms.get(vmName);
@ -115,8 +114,7 @@ public class MockVmMgr implements VmMgr {
@Override
public boolean migrate(String vmName, String params) {
if (s_logger.isInfoEnabled())
s_logger.info("Migrate VM. name: " + vmName);
logger.info("Migrate VM. name: {}", vmName);
synchronized (this) {
MockVm vm = vms.get(vmName);
@ -258,13 +256,13 @@ public class MockVmMgr implements VmMgr {
vm = vms.get(vmName);
if (vm == null) {
if (ramSize > getHostFreeMemory()) {
s_logger.debug("host is out of memory");
logger.debug("host is out of memory");
throw new CloudRuntimeException("Host is out of Memory");
}
int vncPort = allocVncPort();
if (vncPort < 0) {
s_logger.debug("Unable to allocate VNC port");
logger.debug("Unable to allocate VNC port");
throw new CloudRuntimeException("Unable to allocate vnc port");
}

View File

@ -659,6 +659,14 @@ public class AgentProperties{
*/
public static final Property<Integer> STOP_SCRIPT_TIMEOUT = new Property<>("stop.script.timeout", 120);
/**
* Time (in seconds) to wait for scripts to complete.<br>
* This is currently used only while checking if the host supports UEFI.<br>
* Data type: Integer.<br>
* Default value: <code>60</code>
*/
public static final Property<Integer> AGENT_SCRIPT_TIMEOUT = new Property<>("agent.script.timeout", 60);
/**
* Definition of VMs video model type.<br>
* Data type: String.<br>
@ -687,6 +695,13 @@ public class AgentProperties{
*/
public static final Property<Boolean> DEVELOPER = new Property<>("developer", false);
/**
* If set to "true", the agent will register for libvirt domain events, allowing for immediate updates on crashed or unexpectedly
* stopped VMs. Experimental, requires agent restart.
* Default value: <code>false</code>
*/
public static final Property<Boolean> LIBVIRT_EVENTS_ENABLED = new Property<>("libvirt.events.enabled", false);
/**
* Can only be used if developer = true. This property is used to define the local bridge name and private network name.<br>
* Data type: String.<br>

View File

@ -22,7 +22,8 @@ import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.beanutils.converters.IntegerConverter;
import org.apache.commons.beanutils.converters.LongConverter;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
/**
* This class provides a facility to read the agent's properties file and get
@ -31,7 +32,7 @@ import org.apache.log4j.Logger;
*/
public class AgentPropertiesFileHandler {
private static final Logger logger = Logger.getLogger(AgentPropertiesFileHandler.class);
protected static Logger LOGGER = LogManager.getLogger(AgentPropertiesFileHandler.class);
/**
* This method reads the property in the agent.properties file.
@ -47,7 +48,7 @@ public class AgentPropertiesFileHandler {
File agentPropertiesFile = PropertiesUtil.findConfigFile(KeyStoreUtils.AGENT_PROPSFILE);
if (agentPropertiesFile == null) {
logger.debug(String.format("File [%s] was not found, we will use default defined values. Property [%s]: [%s].", KeyStoreUtils.AGENT_PROPSFILE, name, defaultValue));
LOGGER.debug("File [{}] was not found, we will use default defined values. Property [{}]: [{}].", KeyStoreUtils.AGENT_PROPSFILE, name, defaultValue);
return defaultValue;
}
@ -55,7 +56,7 @@ public class AgentPropertiesFileHandler {
try {
String configValue = PropertiesUtil.loadFromFile(agentPropertiesFile).getProperty(name);
if (StringUtils.isBlank(configValue)) {
logger.debug(String.format("Property [%s] has empty or null value. Using default value [%s].", name, defaultValue));
LOGGER.debug("Property [{}] has empty or null value. Using default value [{}].", name, defaultValue);
return defaultValue;
}
@ -67,11 +68,11 @@ public class AgentPropertiesFileHandler {
ConvertUtils.register(new LongConverter(defaultValue), Long.class);
}
logger.debug(String.format("Property [%s] was altered. Now using the value [%s].", name, configValue));
LOGGER.debug("Property [{}] was altered. Now using the value [{}].", name, configValue);
return (T)ConvertUtils.convert(configValue, property.getTypeClass());
} catch (IOException ex) {
logger.debug(String.format("Failed to get property [%s]. Using default value [%s].", name, defaultValue), ex);
LOGGER.debug("Failed to get property [{}]. Using default value [{}].", name, defaultValue, ex);
}
return defaultValue;

View File

@ -34,7 +34,6 @@ import javax.naming.ConfigurationException;
import com.cloud.agent.api.proxy.AllowConsoleAccessCommand;
import org.apache.cloudstack.managed.context.ManagedContextRunnable;
import org.apache.log4j.Logger;
import com.cloud.agent.Agent.ExitStatus;
import com.cloud.agent.api.AgentControlAnswer;
@ -81,7 +80,6 @@ import com.google.gson.Gson;
*
*/
public class ConsoleProxyResource extends ServerResourceBase implements ServerResource {
static final Logger s_logger = Logger.getLogger(ConsoleProxyResource.class);
private final Properties properties = new Properties();
private Thread consoleProxyMain = null;
@ -101,7 +99,7 @@ public class ConsoleProxyResource extends ServerResourceBase implements ServerRe
} else if (cmd instanceof WatchConsoleProxyLoadCommand) {
return execute((WatchConsoleProxyLoadCommand)cmd);
} else if (cmd instanceof ReadyCommand) {
s_logger.info("Receive ReadyCommand, response with ReadyAnswer");
logger.info("Receive ReadyCommand, response with ReadyAnswer");
return new ReadyAnswer((ReadyCommand)cmd);
} else if (cmd instanceof CheckHealthCommand) {
return new CheckHealthAnswer((CheckHealthCommand)cmd, true);
@ -123,13 +121,13 @@ public class ConsoleProxyResource extends ServerResourceBase implements ServerRe
return new Answer(cmd);
} catch (SecurityException | NoSuchMethodException | ClassNotFoundException | InvocationTargetException | IllegalAccessException e) {
String errorMsg = "Unable to add allowed session due to: " + e.getMessage();
s_logger.error(errorMsg, e);
logger.error(errorMsg, e);
return new Answer(cmd, false, errorMsg);
}
}
private Answer execute(StartConsoleProxyAgentHttpHandlerCommand cmd) {
s_logger.info("Invoke launchConsoleProxy() in responding to StartConsoleProxyAgentHttpHandlerCommand");
logger.info("Invoke launchConsoleProxy() in responding to StartConsoleProxyAgentHttpHandlerCommand");
launchConsoleProxy(cmd.getKeystoreBits(), cmd.getKeystorePassword(), cmd.getEncryptorPassword(), cmd.isSourceIpCheckEnabled());
return new Answer(cmd);
}
@ -140,7 +138,7 @@ public class ConsoleProxyResource extends ServerResourceBase implements ServerRe
{
out.write("0");
} catch (IOException e) {
s_logger.warn("Unable to disable rp_filter");
logger.warn("Unable to disable rp_filter");
}
}
@ -177,12 +175,12 @@ public class ConsoleProxyResource extends ServerResourceBase implements ServerRe
try {
is.close();
} catch (final IOException e) {
s_logger.warn("Exception when closing , console proxy address : " + proxyManagementIp);
logger.warn("Exception when closing , console proxy address : {}", proxyManagementIp);
success = false;
}
}
} catch (final IOException e) {
s_logger.warn("Unable to open console proxy command port url, console proxy address : " + proxyManagementIp);
logger.warn("Unable to open console proxy command port url, console proxy address : {}", proxyManagementIp);
success = false;
}
@ -227,14 +225,14 @@ public class ConsoleProxyResource extends ServerResourceBase implements ServerRe
if (eth1Ip != null) {
params.put("private.network.device", "eth1");
} else {
s_logger.info("eth1ip parameter has not been configured, assuming that we are not inside a system vm");
logger.info("eth1ip parameter has not been configured, assuming that we are not inside a system vm");
}
String eth2ip = (String)params.get("eth2ip");
if (eth2ip != null) {
params.put("public.network.device", "eth2");
} else {
s_logger.info("eth2ip parameter is not found, assuming that we are not inside a system vm");
logger.info("eth2ip parameter is not found, assuming that we are not inside a system vm");
}
super.configure(name, params);
@ -262,7 +260,7 @@ public class ConsoleProxyResource extends ServerResourceBase implements ServerRe
}
String internalDns1 = (String) params.get("internaldns1");
if (internalDns1 == null) {
s_logger.warn("No DNS entry found during configuration of ConsoleProxy");
logger.warn("No DNS entry found during configuration of ConsoleProxy");
} else {
addRouteToInternalIpOrCidr(localGateway, eth1Ip, eth1Mask, internalDns1);
}
@ -280,20 +278,19 @@ public class ConsoleProxyResource extends ServerResourceBase implements ServerRe
disableRpFilter();
}
if (s_logger.isInfoEnabled())
s_logger.info("Receive proxyVmId in ConsoleProxyResource configuration as " + proxyVmId);
logger.info("Receive proxyVmId in ConsoleProxyResource configuration as {}", proxyVmId);
return true;
}
private void addRouteToInternalIpOrCidr(String localgw, String eth1ip, String eth1mask, String destIpOrCidr) {
s_logger.debug("addRouteToInternalIp: localgw=" + localgw + ", eth1ip=" + eth1ip + ", eth1mask=" + eth1mask + ",destIp=" + destIpOrCidr);
logger.debug("addRouteToInternalIp: localgw={}, eth1ip={}, eth1mask={}, destIp={}", localgw, eth1ip, eth1mask, destIpOrCidr);
if (destIpOrCidr == null) {
s_logger.debug("addRouteToInternalIp: destIp is null");
logger.debug("addRouteToInternalIp: destIp is null");
return;
}
if (!NetUtils.isValidIp4(destIpOrCidr) && !NetUtils.isValidIp4Cidr(destIpOrCidr)) {
s_logger.warn(" destIp is not a valid ip address or cidr destIp=" + destIpOrCidr);
logger.warn(" destIp is not a valid ip address or cidr destIp={}", destIpOrCidr);
return;
}
boolean inSameSubnet = false;
@ -301,27 +298,27 @@ public class ConsoleProxyResource extends ServerResourceBase implements ServerRe
if (eth1ip != null && eth1mask != null) {
inSameSubnet = NetUtils.sameSubnet(eth1ip, destIpOrCidr, eth1mask);
} else {
s_logger.warn("addRouteToInternalIp: unable to determine same subnet: eth1ip=" + eth1ip + ", dest ip=" + destIpOrCidr + ", eth1mask=" + eth1mask);
logger.warn("addRouteToInternalIp: unable to determine same subnet: eth1ip={}, dest ip={}, eth1mask={}", eth1ip, destIpOrCidr, eth1mask);
}
} else {
inSameSubnet = NetUtils.isNetworkAWithinNetworkB(destIpOrCidr, NetUtils.ipAndNetMaskToCidr(eth1ip, eth1mask));
}
if (inSameSubnet) {
s_logger.debug("addRouteToInternalIp: dest ip " + destIpOrCidr + " is in the same subnet as eth1 ip " + eth1ip);
logger.debug("addRouteToInternalIp: dest ip {} is in the same subnet as eth1 ip {}", destIpOrCidr, eth1ip);
return;
}
Script command = new Script("/bin/bash", s_logger);
Script command = new Script("/bin/bash", logger);
command.add("-c");
command.add("ip route delete " + destIpOrCidr);
command.execute();
command = new Script("/bin/bash", s_logger);
command = new Script("/bin/bash", logger);
command.add("-c");
command.add("ip route add " + destIpOrCidr + " via " + localgw);
String result = command.execute();
if (result != null) {
s_logger.warn("Error in configuring route to internal ip err=" + result);
logger.warn("Error in configuring route to internal ip err={}", result);
} else {
s_logger.debug("addRouteToInternalIp: added route to internal ip=" + destIpOrCidr + " via " + localgw);
logger.debug("addRouteToInternalIp: added route to internal ip={} via {}", destIpOrCidr, localgw);
}
}
@ -332,36 +329,36 @@ public class ConsoleProxyResource extends ServerResourceBase implements ServerRe
private void launchConsoleProxy(final byte[] ksBits, final String ksPassword, final String encryptorPassword, final Boolean isSourceIpCheckEnabled) {
final Object resource = this;
s_logger.info("Building class loader for com.cloud.consoleproxy.ConsoleProxy");
logger.info("Building class loader for com.cloud.consoleproxy.ConsoleProxy");
if (consoleProxyMain == null) {
s_logger.info("Running com.cloud.consoleproxy.ConsoleProxy with encryptor password=" + encryptorPassword);
logger.info("Running com.cloud.consoleproxy.ConsoleProxy with encryptor password={}", encryptorPassword);
consoleProxyMain = new Thread(new ManagedContextRunnable() {
@Override
protected void runInContext() {
try {
Class<?> consoleProxyClazz = Class.forName("com.cloud.consoleproxy.ConsoleProxy");
try {
s_logger.info("Invoke startWithContext()");
logger.info("Invoke startWithContext()");
Method method = consoleProxyClazz.getMethod("startWithContext", Properties.class, Object.class, byte[].class, String.class, String.class, Boolean.class);
method.invoke(null, properties, resource, ksBits, ksPassword, encryptorPassword, isSourceIpCheckEnabled);
} catch (SecurityException e) {
s_logger.error("Unable to launch console proxy due to SecurityException", e);
logger.error("Unable to launch console proxy due to SecurityException", e);
System.exit(ExitStatus.Error.value());
} catch (NoSuchMethodException e) {
s_logger.error("Unable to launch console proxy due to NoSuchMethodException", e);
logger.error("Unable to launch console proxy due to NoSuchMethodException", e);
System.exit(ExitStatus.Error.value());
} catch (IllegalArgumentException e) {
s_logger.error("Unable to launch console proxy due to IllegalArgumentException", e);
logger.error("Unable to launch console proxy due to IllegalArgumentException", e);
System.exit(ExitStatus.Error.value());
} catch (IllegalAccessException e) {
s_logger.error("Unable to launch console proxy due to IllegalAccessException", e);
logger.error("Unable to launch console proxy due to IllegalAccessException", e);
System.exit(ExitStatus.Error.value());
} catch (InvocationTargetException e) {
s_logger.error("Unable to launch console proxy due to InvocationTargetException " + e.getTargetException().toString(), e);
logger.error("Unable to launch console proxy due to InvocationTargetException {}", e.getTargetException().toString(), e);
System.exit(ExitStatus.Error.value());
}
} catch (final ClassNotFoundException e) {
s_logger.error("Unable to launch console proxy due to ClassNotFoundException");
logger.error("Unable to launch console proxy due to ClassNotFoundException");
System.exit(ExitStatus.Error.value());
}
}
@ -369,7 +366,7 @@ public class ConsoleProxyResource extends ServerResourceBase implements ServerRe
consoleProxyMain.setDaemon(true);
consoleProxyMain.start();
} else {
s_logger.info("com.cloud.consoleproxy.ConsoleProxy is already running");
logger.info("com.cloud.consoleproxy.ConsoleProxy is already running");
try {
Class<?> consoleProxyClazz = Class.forName("com.cloud.consoleproxy.ConsoleProxy");
@ -378,22 +375,22 @@ public class ConsoleProxyResource extends ServerResourceBase implements ServerRe
methodSetup = consoleProxyClazz.getMethod("setIsSourceIpCheckEnabled", Boolean.class);
methodSetup.invoke(null, isSourceIpCheckEnabled);
} catch (SecurityException e) {
s_logger.error("Unable to launch console proxy due to SecurityException", e);
logger.error("Unable to launch console proxy due to SecurityException", e);
System.exit(ExitStatus.Error.value());
} catch (NoSuchMethodException e) {
s_logger.error("Unable to launch console proxy due to NoSuchMethodException", e);
logger.error("Unable to launch console proxy due to NoSuchMethodException", e);
System.exit(ExitStatus.Error.value());
} catch (IllegalArgumentException e) {
s_logger.error("Unable to launch console proxy due to IllegalArgumentException", e);
logger.error("Unable to launch console proxy due to IllegalArgumentException", e);
System.exit(ExitStatus.Error.value());
} catch (IllegalAccessException e) {
s_logger.error("Unable to launch console proxy due to IllegalAccessException", e);
logger.error("Unable to launch console proxy due to IllegalAccessException", e);
System.exit(ExitStatus.Error.value());
} catch (InvocationTargetException e) {
s_logger.error("Unable to launch console proxy due to InvocationTargetException " + e.getTargetException().toString(), e);
logger.error("Unable to launch console proxy due to InvocationTargetException " + e.getTargetException().toString(), e);
System.exit(ExitStatus.Error.value());
} catch (final ClassNotFoundException e) {
s_logger.error("Unable to launch console proxy due to ClassNotFoundException", e);
logger.error("Unable to launch console proxy due to ClassNotFoundException", e);
System.exit(ExitStatus.Error.value());
}
}
@ -420,10 +417,10 @@ public class ConsoleProxyResource extends ServerResourceBase implements ServerRe
result.setTunnelUrl(authAnswer.getTunnelUrl());
result.setTunnelSession(authAnswer.getTunnelSession());
} else {
s_logger.error("Authentication failed for vm: " + vmId + " with sid: " + sid);
logger.error("Authentication failed for vm: {} with sid: {}", vmId, sid);
}
} catch (AgentControlChannelException e) {
s_logger.error("Unable to send out console access authentication request due to " + e.getMessage(), e);
logger.error("Unable to send out console access authentication request due to {}", e.getMessage(), e);
}
return new Gson().toJson(result);
@ -433,18 +430,15 @@ public class ConsoleProxyResource extends ServerResourceBase implements ServerRe
ConsoleProxyLoadReportCommand cmd = new ConsoleProxyLoadReportCommand(proxyVmId, gsonLoadInfo);
try {
getAgentControl().postRequest(cmd);
if (s_logger.isDebugEnabled())
s_logger.debug("Report proxy load info, proxy : " + proxyVmId + ", load: " + gsonLoadInfo);
logger.debug("Report proxy load info, proxy : {}, load: {}", proxyVmId, gsonLoadInfo);
} catch (AgentControlChannelException e) {
s_logger.error("Unable to send out load info due to " + e.getMessage(), e);
logger.error("Unable to send out load info due to {}", e.getMessage(), e);
}
}
public void ensureRoute(String address) {
if (localGateway != null) {
if (s_logger.isDebugEnabled())
s_logger.debug("Ensure route for " + address + " via " + localGateway);
logger.debug("Ensure route for {} via {}", address, localGateway);
// this method won't be called in high frequency, serialize access
// to script execution
@ -452,7 +446,7 @@ public class ConsoleProxyResource extends ServerResourceBase implements ServerRe
try {
addRouteToInternalIpOrCidr(localGateway, eth1Ip, eth1Mask, address);
} catch (Throwable e) {
s_logger.warn("Unexpected exception while adding internal route to " + address, e);
logger.warn("Unexpected exception while adding internal route to {}", address, e);
}
}
}

View File

@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.cloudstack</groupId>
<artifactId>cloudstack</artifactId>
<version>4.19.0.0-SNAPSHOT</version>
<version>4.20.0.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>

View File

@ -20,6 +20,8 @@ import java.util.HashMap;
import java.util.Map;
import com.cloud.agent.api.LogLevel.Log4jLevel;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
/**
* implemented by classes that extends the Command class. Command specifies
@ -27,6 +29,8 @@ import com.cloud.agent.api.LogLevel.Log4jLevel;
*/
public abstract class Command {
protected transient Logger logger = LogManager.getLogger(getClass());
public static enum OnError {
Continue, Stop
}

View File

@ -23,8 +23,8 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.Logger;
/**
*/
@ -41,7 +41,7 @@ public @interface LogLevel {
}
public boolean enabled(Logger logger) {
return _level != Level.OFF && logger.isEnabledFor(_level);
return _level != Level.OFF && logger.isEnabled(_level);
}
}

View File

@ -39,7 +39,8 @@ import org.apache.cloudstack.utils.security.ParserUtils;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@ -63,7 +64,7 @@ import com.cloud.utils.compression.CompressionUtil;
import com.cloud.utils.exception.CloudRuntimeException;
public class OVFHelper {
private static final Logger s_logger = Logger.getLogger(OVFHelper.class);
protected Logger logger = LogManager.getLogger(getClass());
private final OVFParser ovfParser;
@ -118,7 +119,7 @@ public class OVFHelper {
boolean password = StringUtils.isNotBlank(passStr) && passStr.equalsIgnoreCase("true");
String label = ovfParser.getChildNodeValue(node, "Label");
String description = ovfParser.getChildNodeValue(node, "Description");
s_logger.debug("Creating OVF property index " + index + (category == null ? "" : " for category " + category)
logger.debug("Creating OVF property index " + index + (category == null ? "" : " for category " + category)
+ " with key = " + key);
return new OVFPropertyTO(key, type, value, qualifiers, userConfigurable,
label, description, password, index, category);
@ -151,7 +152,7 @@ public class OVFHelper {
if (child.getNodeName().equalsIgnoreCase("Category") ||
child.getNodeName().endsWith(":Category")) {
lastCategoryFound = child.getTextContent();
s_logger.info("Category found " + lastCategoryFound);
logger.info("Category found " + lastCategoryFound);
} else if (child.getNodeName().equalsIgnoreCase("Property") ||
child.getNodeName().endsWith(":Property")) {
OVFPropertyTO prop = createOVFPropertyFromNode(child, propertyIndex, lastCategoryFound);
@ -249,13 +250,13 @@ public class OVFHelper {
int diskNumber = 0;
for (OVFVirtualHardwareItemTO diskItem : diskHardwareItems) {
if (StringUtils.isBlank(diskItem.getHostResource())) {
s_logger.error("Missing disk information for hardware item " + diskItem.getElementName() + " " + diskItem.getInstanceId());
logger.error("Missing disk information for hardware item " + diskItem.getElementName() + " " + diskItem.getInstanceId());
continue;
}
String diskId = extractDiskIdFromDiskHostResource(diskItem.getHostResource());
OVFDisk diskDefinition = getDiskDefinitionFromDiskId(diskId, disks);
if (diskDefinition == null) {
s_logger.error("Missing disk definition for disk ID " + diskId);
logger.error("Missing disk definition for disk ID " + diskId);
}
OVFFile fileDefinition = getFileDefinitionFromDiskDefinition(diskDefinition._fileRef, files);
DatadiskTO datadiskTO = generateDiskTO(fileDefinition, diskDefinition, ovfParentPath, diskNumber, diskItem);
@ -277,7 +278,7 @@ public class OVFHelper {
if (StringUtils.isNotBlank(path)) {
File f = new File(path);
if (!f.exists() || f.isDirectory()) {
s_logger.error("One of the attached disk or iso does not exists " + path);
logger.error("One of the attached disk or iso does not exists " + path);
throw new InternalErrorException("One of the attached disk or iso as stated on OVF does not exists " + path);
}
}
@ -333,8 +334,8 @@ public class OVFHelper {
od._controller = getControllerType(items, od._diskId);
vd.add(od);
}
if (s_logger.isTraceEnabled()) {
s_logger.trace(String.format("found %d disk definitions",vd.size()));
if (logger.isTraceEnabled()) {
logger.trace(String.format("found %d disk definitions",vd.size()));
}
return vd;
}
@ -365,8 +366,8 @@ public class OVFHelper {
vf.add(of);
}
}
if (s_logger.isTraceEnabled()) {
s_logger.trace(String.format("found %d file definitions in %s",vf.size(), ovfFile.getPath()));
if (logger.isTraceEnabled()) {
logger.trace(String.format("found %d file definitions in %s",vf.size(), ovfFile.getPath()));
}
return vf;
}
@ -461,7 +462,7 @@ public class OVFHelper {
Element disk = (Element)disks.item(i);
String fileRef = ovfParser.getNodeAttribute(disk, "fileRef");
if (keepfile == null) {
s_logger.info("FATAL: OVA format error");
logger.info("FATAL: OVA format error");
} else if (keepfile.equals(fileRef)) {
keepdisk = ovfParser.getNodeAttribute(disk, "diskId");
} else {
@ -505,7 +506,7 @@ public class OVFHelper {
outfile.write(writer.toString());
outfile.close();
} catch (IOException | TransformerException e) {
s_logger.info("Unexpected exception caught while rewriting OVF:" + e.getMessage(), e);
logger.info("Unexpected exception caught while rewriting OVF:" + e.getMessage(), e);
throw new CloudRuntimeException(e);
}
}
@ -521,8 +522,8 @@ public class OVFHelper {
public List<OVFNetworkTO> getNetPrerequisitesFromDocument(Document doc) throws InternalErrorException {
if (doc == null) {
if (s_logger.isTraceEnabled()) {
s_logger.trace("no document to parse; returning no prerequisite networks");
if (logger.isTraceEnabled()) {
logger.trace("no document to parse; returning no prerequisite networks");
}
return Collections.emptyList();
}
@ -539,8 +540,8 @@ public class OVFHelper {
private void matchNicsToNets(Map<String, OVFNetworkTO> nets, Node systemElement) {
final DocumentTraversal traversal = (DocumentTraversal) systemElement;
final NodeIterator iterator = traversal.createNodeIterator(systemElement, NodeFilter.SHOW_ELEMENT, null, true);
if (s_logger.isTraceEnabled()) {
s_logger.trace(String.format("starting out with %d network-prerequisites, parsing hardware",nets.size()));
if (logger.isTraceEnabled()) {
logger.trace(String.format("starting out with %d network-prerequisites, parsing hardware",nets.size()));
}
int nicCount = 0;
for (Node n = iterator.nextNode(); n != null; n = iterator.nextNode()) {
@ -549,8 +550,8 @@ public class OVFHelper {
nicCount++;
String name = e.getTextContent(); // should be in our nets
if(nets.get(name) == null) {
if(s_logger.isInfoEnabled()) {
s_logger.info(String.format("found a nic definition without a network definition byname %s, adding it to the list.", name));
if(logger.isInfoEnabled()) {
logger.info(String.format("found a nic definition without a network definition byname %s, adding it to the list.", name));
}
nets.put(name, new OVFNetworkTO());
}
@ -560,8 +561,8 @@ public class OVFHelper {
}
}
}
if (s_logger.isTraceEnabled()) {
s_logger.trace(String.format("ending up with %d network-prerequisites, parsed %d nics", nets.size(), nicCount));
if (logger.isTraceEnabled()) {
logger.trace(String.format("ending up with %d network-prerequisites, parsed %d nics", nets.size(), nicCount));
}
}
@ -584,7 +585,7 @@ public class OVFHelper {
int addressOnParent = Integer.parseInt(addressOnParentStr);
nic.setAddressOnParent(addressOnParent);
} catch (NumberFormatException e) {
s_logger.warn("Encountered element of type \"AddressOnParent\", that could not be parse to an integer number: " + addressOnParentStr);
logger.warn("Encountered element of type \"AddressOnParent\", that could not be parse to an integer number: " + addressOnParentStr);
}
boolean automaticAllocation = StringUtils.isNotBlank(automaticAllocationStr) && Boolean.parseBoolean(automaticAllocationStr);
@ -596,7 +597,7 @@ public class OVFHelper {
int instanceId = Integer.parseInt(instanceIdStr);
nic.setInstanceID(instanceId);
} catch (NumberFormatException e) {
s_logger.warn("Encountered element of type \"InstanceID\", that could not be parse to an integer number: " + instanceIdStr);
logger.warn("Encountered element of type \"InstanceID\", that could not be parse to an integer number: " + instanceIdStr);
}
nic.setResourceSubType(resourceSubType);
@ -608,7 +609,7 @@ public class OVFHelper {
NodeList systemElements = ovfParser.getElementsFromOVFDocument(doc, "VirtualSystem");
if (systemElements.getLength() != 1) {
String msg = "found " + systemElements.getLength() + " system definitions in OVA, can only handle exactly one.";
s_logger.warn(msg);
logger.warn(msg);
throw new InternalErrorException(msg);
}
}
@ -629,8 +630,8 @@ public class OVFHelper {
nets.put(networkName,network);
}
if (s_logger.isTraceEnabled()) {
s_logger.trace(String.format("found %d networks in template", nets.size()));
if (logger.isTraceEnabled()) {
logger.trace(String.format("found %d networks in template", nets.size()));
}
return nets;
}
@ -770,7 +771,7 @@ public class OVFHelper {
try {
return Long.parseLong(value);
} catch (NumberFormatException e) {
s_logger.debug("Could not parse the value: " + value + ", ignoring it");
logger.debug("Could not parse the value: " + value + ", ignoring it");
}
}
return null;
@ -781,7 +782,7 @@ public class OVFHelper {
try {
return Integer.parseInt(value);
} catch (NumberFormatException e) {
s_logger.debug("Could not parse the value: " + value + ", ignoring it");
logger.debug("Could not parse the value: " + value + ", ignoring it");
}
}
return null;
@ -819,7 +820,7 @@ public class OVFHelper {
try {
compressedLicense = compressOVFEula(eulaLicense);
} catch (IOException e) {
s_logger.error("Could not compress the license for info " + eulaInfo);
logger.error("Could not compress the license for info " + eulaInfo);
continue;
}
OVFEulaSectionTO eula = new OVFEulaSectionTO(eulaInfo, compressedLicense, eulaIndex);

View File

@ -27,7 +27,8 @@ import javax.xml.parsers.ParserConfigurationException;
import org.apache.cloudstack.utils.security.ParserUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@ -36,7 +37,7 @@ import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
public class OVFParser {
private static final Logger s_logger = Logger.getLogger(OVFParser.class);
protected Logger logger = LogManager.getLogger(getClass());
private static final String DEFAULT_OVF_SCHEMA = "http://schemas.dmtf.org/ovf/envelope/1";
private static final String VMW_SCHEMA = "http://www.vmware.com/schema/ovf";
@ -53,7 +54,7 @@ public class OVFParser {
documentBuilderFactory.setNamespaceAware(true);
documentBuilder = documentBuilderFactory.newDocumentBuilder();
} catch (ParserConfigurationException e) {
s_logger.error("Cannot start the OVF parser: " + e.getMessage(), e);
logger.error("Cannot start the OVF parser: " + e.getMessage(), e);
}
}
@ -69,7 +70,7 @@ public class OVFParser {
try {
return documentBuilder.parse(new File(ovfFilePath));
} catch (SAXException | IOException e) {
s_logger.error("Error parsing " + ovfFilePath + " " + e.getMessage(), e);
logger.error("Error parsing " + ovfFilePath + " " + e.getMessage(), e);
return null;
}
}

View File

@ -32,6 +32,9 @@ public class NicTO extends NetworkTO {
Map<NetworkOffering.Detail, String> details;
boolean dpdkEnabled;
Integer mtu;
Long networkId;
String networkSegmentName;
public NicTO() {
super();
@ -127,4 +130,20 @@ public class NicTO extends NetworkTO {
public void setMtu(Integer mtu) {
this.mtu = mtu;
}
public Long getNetworkId() {
return networkId;
}
public void setNetworkId(Long networkId) {
this.networkId = networkId;
}
public String getNetworkSegmentName() {
return networkSegmentName;
}
public void setNetworkSegmentName(String networkSegmentName) {
this.networkSegmentName = networkSegmentName;
}
}

View File

@ -82,6 +82,7 @@ public class VirtualMachineTO {
Map<String, String> guestOsDetails = new HashMap<String, String>();
Map<String, String> extraConfig = new HashMap<>();
Map<Long, String> networkIdToNetworkNameMap = new HashMap<>();
DeployAsIsInfoTO deployAsIsInfo;
public VirtualMachineTO(long id, String instanceName, VirtualMachine.Type type, int cpus, Integer speed, long minRam, long maxRam, BootloaderType bootloader,
@ -392,6 +393,14 @@ public class VirtualMachineTO {
return extraConfig;
}
public Map<Long, String> getNetworkIdToNetworkNameMap() {
return networkIdToNetworkNameMap;
}
public void setNetworkIdToNetworkNameMap(Map<Long, String> networkIdToNetworkNameMap) {
this.networkIdToNetworkNameMap = networkIdToNetworkNameMap;
}
public String getBootType() {
return bootType;
}

View File

@ -16,6 +16,8 @@
// under the License.
package com.cloud.capacity;
import java.util.List;
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;
@ -35,6 +37,11 @@ public interface Capacity extends InternalIdentity, Identity {
public static final short CAPACITY_TYPE_CPU_CORE = 90;
public static final List<Short> STORAGE_CAPACITY_TYPES = List.of(CAPACITY_TYPE_STORAGE,
CAPACITY_TYPE_STORAGE_ALLOCATED,
CAPACITY_TYPE_SECONDARY_STORAGE,
CAPACITY_TYPE_LOCAL_STORAGE);
public Long getHostOrPoolId();
public Long getDataCenterId();
@ -54,4 +61,6 @@ public interface Capacity extends InternalIdentity, Identity {
public Float getUsedPercentage();
public Long getAllocatedCapacity();
public String getTag();
}

View File

@ -85,5 +85,6 @@ public interface Resource {
long getOwnerId();
ResourceOwnerType getResourceOwnerType();
String getTag();
}

View File

@ -57,6 +57,17 @@ public interface DeploymentClusterPlanner extends DeploymentPlanner {
false,
ConfigKey.Scope.Global);
static final ConfigKey<String> VmAllocationAlgorithm = new ConfigKey<>(
String.class,
"vm.allocation.algorithm",
"Advanced",
"random",
"Order in which hosts within a cluster will be considered for VM/volume allocation. The value can be 'random', 'firstfit', 'userdispersing', 'userconcentratedpod_random', 'userconcentratedpod_firstfit', or 'firstfitleastconsumed'.",
true,
ConfigKey.Scope.Global, null, null, null, null, null,
ConfigKey.Kind.Select,
"random,firstfit,userdispersing,userconcentratedpod_random,userconcentratedpod_firstfit,firstfitleastconsumed");
/**
* This is called to determine list of possible clusters where a virtual
* machine can be deployed.

View File

@ -21,8 +21,12 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import com.cloud.dc.DataCenter;
import com.cloud.dc.Pod;
import com.cloud.exception.CloudException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InsufficientServerCapacityException;
import com.cloud.exception.ResourceUnavailableException;
@ -75,7 +79,7 @@ public interface DeploymentPlanner extends Adapter {
public static class ExcludeList implements Serializable {
private static final long serialVersionUID = -482175549460148301L;
protected static Logger LOGGER = LogManager.getLogger(ExcludeList.class);
private Set<Long> _dcIds;
private Set<Long> _podIds;
private Set<Long> _clusterIds;
@ -104,13 +108,26 @@ public interface DeploymentPlanner extends Adapter {
}
}
private void logAvoid(Class<?> scope, CloudException e) {
Long id = null;
if (e instanceof InsufficientCapacityException) {
id = ((InsufficientCapacityException) e).getId();
} else if (e instanceof ResourceUnavailableException) {
id = ((ResourceUnavailableException) e).getResourceId();
} else {
LOGGER.debug("Failed to log avoided component due to unexpected exception type [{}].", e.getMessage());
return;
}
LOGGER.debug("Adding {} [{}] to the avoid set due to [{}].", scope.getSimpleName(), id, e.getMessage());
}
public boolean add(InsufficientCapacityException e) {
Class<?> scope = e.getScope();
if (scope == null) {
return false;
}
logAvoid(scope, e);
if (Host.class.isAssignableFrom(scope)) {
addHost(e.getId());
} else if (Pod.class.isAssignableFrom(scope)) {
@ -128,13 +145,14 @@ public interface DeploymentPlanner extends Adapter {
return true;
}
public boolean add(ResourceUnavailableException e) {
Class<?> scope = e.getScope();
if (scope == null) {
return false;
}
logAvoid(scope, e);
if (Host.class.isAssignableFrom(scope)) {
addHost(e.getResourceId());
} else if (Pod.class.isAssignableFrom(scope)) {

View File

@ -31,6 +31,7 @@ import org.apache.cloudstack.config.Configuration;
import org.apache.cloudstack.ha.HAConfig;
import org.apache.cloudstack.storage.object.Bucket;
import org.apache.cloudstack.storage.object.ObjectStore;
import org.apache.cloudstack.quota.QuotaTariff;
import org.apache.cloudstack.usage.Usage;
import org.apache.cloudstack.vm.schedule.VMSchedule;
@ -303,6 +304,7 @@ public class EventTypes {
public static final String EVENT_VOLUME_CREATE = "VOLUME.CREATE";
public static final String EVENT_VOLUME_DELETE = "VOLUME.DELETE";
public static final String EVENT_VOLUME_ATTACH = "VOLUME.ATTACH";
public static final String EVENT_VOLUME_CHECK = "VOLUME.CHECK";
public static final String EVENT_VOLUME_DETACH = "VOLUME.DETACH";
public static final String EVENT_VOLUME_EXTRACT = "VOLUME.EXTRACT";
public static final String EVENT_VOLUME_UPLOAD = "VOLUME.UPLOAD";
@ -400,6 +402,7 @@ public class EventTypes {
public static final String EVENT_IMAGE_STORE_DATA_MIGRATE = "IMAGE.STORE.MIGRATE.DATA";
public static final String EVENT_IMAGE_STORE_RESOURCES_MIGRATE = "IMAGE.STORE.MIGRATE.RESOURCES";
public static final String EVENT_IMAGE_STORE_OBJECT_DOWNLOAD = "IMAGE.STORE.OBJECT.DOWNLOAD";
public static final String EVENT_UPDATE_IMAGE_STORE_ACCESS_STATE = "IMAGE.STORE.ACCESS.UPDATED";
// Configuration Table
public static final String EVENT_CONFIGURATION_VALUE_EDIT = "CONFIGURATION.VALUE.EDIT";
@ -727,6 +730,11 @@ public class EventTypes {
public static final String EVENT_BUCKET_DELETE = "BUCKET.DELETE";
public static final String EVENT_BUCKET_UPDATE = "BUCKET.UPDATE";
// Quota
public static final String EVENT_QUOTA_TARIFF_CREATE = "QUOTA.TARIFF.CREATE";
public static final String EVENT_QUOTA_TARIFF_DELETE = "QUOTA.TARIFF.DELETE";
public static final String EVENT_QUOTA_TARIFF_UPDATE = "QUOTA.TARIFF.UPDATE";
static {
// TODO: need a way to force author adding event types to declare the entity details as well, with out braking
@ -1164,6 +1172,7 @@ public class EventTypes {
entityEventDetails.put(EVENT_IMAGE_STORE_DATA_MIGRATE, ImageStore.class);
entityEventDetails.put(EVENT_IMAGE_STORE_OBJECT_DOWNLOAD, ImageStore.class);
entityEventDetails.put(EVENT_UPDATE_IMAGE_STORE_ACCESS_STATE, ImageStore.class);
entityEventDetails.put(EVENT_LIVE_PATCH_SYSTEMVM, "SystemVMs");
//Object Store
@ -1175,6 +1184,11 @@ public class EventTypes {
entityEventDetails.put(EVENT_BUCKET_CREATE, Bucket.class);
entityEventDetails.put(EVENT_BUCKET_UPDATE, Bucket.class);
entityEventDetails.put(EVENT_BUCKET_DELETE, Bucket.class);
// Quota
entityEventDetails.put(EVENT_QUOTA_TARIFF_CREATE, QuotaTariff.class);
entityEventDetails.put(EVENT_QUOTA_TARIFF_DELETE, QuotaTariff.class);
entityEventDetails.put(EVENT_QUOTA_TARIFF_UPDATE, QuotaTariff.class);
}
public static String getEntityForEvent(String eventName) {

View File

@ -17,55 +17,45 @@
package com.cloud.hypervisor;
import com.cloud.storage.Storage.ImageFormat;
import org.apache.commons.lang3.StringUtils;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
public class Hypervisor {
public static class HypervisorType {
private static final Map<String, HypervisorType> hypervisorTypeMap = new LinkedHashMap<>();
public static final HypervisorType None = new HypervisorType("None"); //for storage hosts
public static final HypervisorType XenServer = new HypervisorType("XenServer", ImageFormat.VHD);
public static final HypervisorType KVM = new HypervisorType("KVM", ImageFormat.QCOW2);
public static final HypervisorType VMware = new HypervisorType("VMware", ImageFormat.OVA);
public static final HypervisorType Hyperv = new HypervisorType("Hyperv");
public static final HypervisorType VirtualBox = new HypervisorType("VirtualBox");
public static final HypervisorType Parralels = new HypervisorType("Parralels");
public static final HypervisorType BareMetal = new HypervisorType("BareMetal");
public static final HypervisorType Simulator = new HypervisorType("Simulator");
public static final HypervisorType Ovm = new HypervisorType("Ovm", ImageFormat.RAW);
public static final HypervisorType Ovm3 = new HypervisorType("Ovm3", ImageFormat.RAW);
public static final HypervisorType LXC = new HypervisorType("LXC");
public static final HypervisorType Custom = new HypervisorType("Custom");
public static final HypervisorType Any = new HypervisorType("Any"); /*If you don't care about the hypervisor type*/
private final String name;
private final ImageFormat imageFormat;
static Map<String, HypervisorType> hypervisorTypeMap;
static Map<HypervisorType, ImageFormat> supportedImageFormatMap;
public HypervisorType(String name) {
this(name, null);
}
public enum HypervisorType {
None, //for storage hosts
XenServer,
KVM,
VMware,
Hyperv,
VirtualBox,
Parralels,
BareMetal,
Simulator,
Ovm,
Ovm3,
LXC,
Custom,
Any; /*If you don't care about the hypervisor type*/
static {
hypervisorTypeMap = new HashMap<>();
hypervisorTypeMap.put("xenserver", HypervisorType.XenServer);
hypervisorTypeMap.put("kvm", HypervisorType.KVM);
hypervisorTypeMap.put("vmware", HypervisorType.VMware);
hypervisorTypeMap.put("hyperv", HypervisorType.Hyperv);
hypervisorTypeMap.put("virtualbox", HypervisorType.VirtualBox);
hypervisorTypeMap.put("parallels", HypervisorType.Parralels);
hypervisorTypeMap.put("baremetal", HypervisorType.BareMetal);
hypervisorTypeMap.put("simulator", HypervisorType.Simulator);
hypervisorTypeMap.put("ovm", HypervisorType.Ovm);
hypervisorTypeMap.put("lxc", HypervisorType.LXC);
hypervisorTypeMap.put("any", HypervisorType.Any);
hypervisorTypeMap.put("ovm3", HypervisorType.Ovm3);
hypervisorTypeMap.put("custom", HypervisorType.Custom);
supportedImageFormatMap = new HashMap<>();
supportedImageFormatMap.put(HypervisorType.XenServer, ImageFormat.VHD);
supportedImageFormatMap.put(HypervisorType.KVM, ImageFormat.QCOW2);
supportedImageFormatMap.put(HypervisorType.VMware, ImageFormat.OVA);
supportedImageFormatMap.put(HypervisorType.Ovm, ImageFormat.RAW);
supportedImageFormatMap.put(HypervisorType.Ovm3, ImageFormat.RAW);
public HypervisorType(String name, ImageFormat imageFormat) {
this.name = name;
this.imageFormat = imageFormat;
if (name.equals("Parralels")){ // typo in the original code
hypervisorTypeMap.put("parallels", this);
} else {
hypervisorTypeMap.putIfAbsent(name.toLowerCase(Locale.ROOT), this);
}
}
public static HypervisorType getType(String hypervisor) {
@ -75,24 +65,62 @@ public class Hypervisor {
hypervisorTypeMap.getOrDefault(hypervisor.toLowerCase(Locale.ROOT), HypervisorType.None));
}
public static HypervisorType[] values() {
return hypervisorTypeMap.values().toArray(HypervisorType[]::new).clone();
}
public static HypervisorType valueOf(String name) {
if (StringUtils.isBlank(name)) {
return null;
}
HypervisorType hypervisorType = hypervisorTypeMap.get(name.toLowerCase(Locale.ROOT));
if (hypervisorType == null) {
throw new IllegalArgumentException("HypervisorType '" + name + "' not found");
}
return hypervisorType;
}
/**
* Returns the display name of a hypervisor type in case the custom hypervisor is used,
* using the 'hypervisor.custom.display.name' setting. Otherwise, returns hypervisor name
*/
public String getHypervisorDisplayName() {
return !Hypervisor.HypervisorType.Custom.equals(this) ?
this.toString() :
HypervisorGuru.HypervisorCustomDisplayName.value();
return HypervisorType.Custom.equals(this) ? HypervisorGuru.HypervisorCustomDisplayName.value() : name;
}
/**
* This method really needs to be part of the properties of the hypervisor type itself.
*
* @param hyperType
* @return
*/
public static ImageFormat getSupportedImageFormat(HypervisorType hyperType) {
return supportedImageFormatMap.getOrDefault(hyperType, null);
public ImageFormat getSupportedImageFormat() {
return imageFormat;
}
public String name() {
return name;
}
@Override
public int hashCode() {
return Objects.hash(name);
}
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
} else if (o == null || getClass() != o.getClass()) {
return false;
}
HypervisorType that = (HypervisorType) o;
return Objects.equals(name, that.name);
}
@Override
public String toString() {
return name;
}
}

View File

@ -22,4 +22,5 @@ import org.apache.cloudstack.acl.ControlledEntity;
public interface KubernetesClusterHelper extends Adapter {
ControlledEntity findByUuid(String uuid);
ControlledEntity findByVmId(long vmId);
}

View File

@ -97,4 +97,6 @@ public interface IpAddress extends ControlledEntity, Identity, InternalIdentity,
void setRuleState(State ruleState);
boolean isForSystemVms();
}

View File

@ -205,6 +205,8 @@ public interface Network extends ControlledEntity, StateObject<Network.State>, I
//Add Tungsten Fabric provider
public static final Provider Tungsten = new Provider("Tungsten", false);
public static final Provider Nsx = new Provider("Nsx", false);
private final String name;
private final boolean isExternal;
@ -427,6 +429,8 @@ public interface Network extends ControlledEntity, StateObject<Network.State>, I
long getDataCenterId();
long getAccountId();
long getNetworkOfferingId();
@Override

View File

@ -22,10 +22,8 @@ import java.util.Date;
import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.Networks.Mode;
import com.cloud.network.Networks.TrafficType;
import org.apache.log4j.Logger;
public class NetworkProfile implements Network {
static final Logger s_logger = Logger.getLogger(NetworkProfile.class);
private final long id;
private final String uuid;
private final long dataCenterId;

View File

@ -19,6 +19,7 @@ package com.cloud.network;
import java.util.List;
import java.util.Map;
import com.cloud.dc.DataCenter;
import org.apache.cloudstack.api.command.admin.address.ReleasePodIpCmdByAdmin;
import org.apache.cloudstack.api.command.admin.network.DedicateGuestVlanRangeCmd;
import org.apache.cloudstack.api.command.admin.network.ListDedicatedGuestVlanRangesCmd;
@ -55,6 +56,7 @@ import com.cloud.utils.Pair;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.vm.Nic;
import com.cloud.vm.NicSecondaryIp;
import org.apache.cloudstack.network.element.InternalLoadBalancerElementService;
/**
* The NetworkService interface is the "public" api to entities that make requests to the orchestration engine
@ -87,6 +89,8 @@ public interface NetworkService {
IpAddress reserveIpAddress(Account account, Boolean displayIp, Long ipAddressId) throws ResourceAllocationException;
IpAddress reserveIpAddressWithVlanDetail(Account account, DataCenter zone, Boolean displayIp, String vlanDetailKey) throws ResourceAllocationException;
boolean releaseReservedIpAddress(long ipAddressId) throws InsufficientAddressCapacityException;
boolean releaseIpAddress(long ipAddressId) throws InsufficientAddressCapacityException;
@ -254,4 +258,9 @@ public interface NetworkService {
PublicIpQuarantine updatePublicIpAddressInQuarantine(UpdateQuarantinedIpCmd cmd);
void removePublicIpAddressFromQuarantine(RemoveQuarantinedIpCmd cmd);
InternalLoadBalancerElementService getInternalLoadBalancerElementByType(VirtualRouterProvider.Type type);
InternalLoadBalancerElementService getInternalLoadBalancerElementByNetworkServiceProviderId(long networkProviderId);
InternalLoadBalancerElementService getInternalLoadBalancerElementById(long providerId);
List<InternalLoadBalancerElementService> getInternalLoadBalancerElements();
}

View File

@ -128,7 +128,8 @@ public class Networks {
},
UnDecided(null, null),
OpenDaylight("opendaylight", String.class),
TUNGSTEN("tf", String.class);
TUNGSTEN("tf", String.class),
NSX("nsx", String.class);
private final String scheme;
private final Class<?> type;

View File

@ -30,6 +30,8 @@ public interface PublicIpQuarantine extends InternalIdentity, Identity {
String getRemovalReason();
Long getRemoverAccountId();
Date getRemoved();
Date getCreated();

View File

@ -21,7 +21,7 @@ import org.apache.cloudstack.api.InternalIdentity;
public interface VirtualRouterProvider extends InternalIdentity, Identity {
public enum Type {
VirtualRouter, ElasticLoadBalancerVm, VPCVirtualRouter, InternalLbVm, NetScalerVm
VirtualRouter, ElasticLoadBalancerVm, VPCVirtualRouter, InternalLbVm, NetScalerVm, Nsx
}
public Type getType();

View File

@ -21,6 +21,7 @@ import java.util.List;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.Network;
import com.cloud.network.vpc.NetworkACLItem;
import com.cloud.network.vpc.Vpc;
public interface NetworkACLServiceProvider extends NetworkElement {
@ -32,4 +33,6 @@ public interface NetworkACLServiceProvider extends NetworkElement {
*/
boolean applyNetworkACLs(Network config, List<? extends NetworkACLItem> rules) throws ResourceUnavailableException;
boolean reorderAclRules(Vpc vpc, List<? extends Network> networks, List<? extends NetworkACLItem> networkACLItems);
}

View File

@ -22,6 +22,7 @@ import com.cloud.deploy.DeployDestination;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.IpAddress;
import com.cloud.network.vpc.NetworkACLItem;
import com.cloud.network.vpc.PrivateGateway;
import com.cloud.network.vpc.StaticRouteProfile;
@ -52,4 +53,6 @@ public interface VpcProvider extends NetworkElement {
boolean applyStaticRoutes(Vpc vpc, List<StaticRouteProfile> routes) throws ResourceUnavailableException;
boolean applyACLItemsToPrivateGw(PrivateGateway gateway, List<? extends NetworkACLItem> rules) throws ResourceUnavailableException;
boolean updateVpcSourceNatIp(Vpc vpc, IpAddress address);
}

View File

@ -79,20 +79,24 @@ public interface NetworkGuru extends Adapter {
* be used to make determination can be isolation methods, services
* provided on the guest network and the service provider that's on the
* guest network.
*
* <p>
* If a network is already fully substantiated with the necessary resources
* during this design phase, then the state should be set to Setup. If
* the resources are not allocated at this point, the state should be set
* to Allocated.
*
* @param offering network offering that contains the package of services
* the end user intends to use on that network.
* @param plan where is this network being deployed.
* @param offering network offering that contains the package of services
* the end user intends to use on that network.
* @param plan where is this network being deployed.
* @param userSpecified user specified parameters for this network.
* @param owner owner of this network.
* @param name
* @param vpcId
* @param owner owner of this network.
* @return Network
*/
Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner);
Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, String name, Long vpcId, Account owner);
void setup(Network network, long networkId);
/**
* For guest networks that are in Allocated state after the design stage,

View File

@ -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.
package com.cloud.network.nsx;
import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity;
public interface NsxProvider extends InternalIdentity, Identity {
String getHostname();
String getPort();
String getProviderName();
String getUsername();
long getZoneId();
String getTier0Gateway();
String getEdgeCluster();
String getTransportZone();
}

View File

@ -0,0 +1,26 @@
// 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.network.nsx;
import com.cloud.network.IpAddress;
import com.cloud.network.vpc.Vpc;
public interface NsxService {
boolean createVpcNetwork(Long zoneId, long accountId, long domainId, Long vpcId, String vpcName, boolean sourceNatEnabled);
boolean updateVpcSourceNatIp(Vpc vpc, IpAddress address);
}

View File

@ -29,6 +29,8 @@ public interface VpcOffering extends InternalIdentity, Identity {
public static final String defaultVPCOfferingName = "Default VPC offering";
public static final String defaultVPCNSOfferingName = "Default VPC offering with Netscaler";
public static final String redundantVPCOfferingName = "Redundant VPC offering";
public static final String DEFAULT_VPC_NAT_NSX_OFFERING_NAME = "VPC offering with NSX - NAT Mode";
public static final String DEFAULT_VPC_ROUTE_NSX_OFFERING_NAME = "VPC offering with NSX - Route Mode";
/**
*
@ -53,6 +55,10 @@ public interface VpcOffering extends InternalIdentity, Identity {
*/
boolean isDefault();
boolean isForNsx();
String getNsxMode();
/**
* @return service offering id used by VPC virtual router
*/

View File

@ -36,7 +36,8 @@ public interface VpcProvisioningService {
VpcOffering createVpcOffering(String name, String displayText, List<String> supportedServices,
Map<String, List<String>> serviceProviders,
Map serviceCapabilitystList, NetUtils.InternetProtocol internetProtocol,
Long serviceOfferingId, List<Long> domainIds, List<Long> zoneIds, VpcOffering.State state);
Long serviceOfferingId, Boolean forNsx, String mode,
List<Long> domainIds, List<Long> zoneIds, VpcOffering.State state);
Pair<List<? extends VpcOffering>,Integer> listVpcOfferings(ListVPCOfferingsCmd cmd);

View File

@ -43,6 +43,11 @@ public interface NetworkOffering extends InfrastructureEntity, InternalIdentity,
InternalLbProvider, PublicLbProvider, servicepackageuuid, servicepackagedescription, PromiscuousMode, MacAddressChanges, ForgedTransmits, MacLearning, RelatedNetworkOffering, domainid, zoneid, pvlanType, internetProtocol
}
public enum NsxMode {
NATTED,
ROUTED
}
public final static String SystemPublicNetwork = "System-Public-Network";
public final static String SystemControlNetwork = "System-Control-Network";
public final static String SystemManagementNetwork = "System-Management-Network";
@ -52,6 +57,11 @@ public interface NetworkOffering extends InfrastructureEntity, InternalIdentity,
public final static String DefaultSharedNetworkOfferingWithSGService = "DefaultSharedNetworkOfferingWithSGService";
public static final String DEFAULT_TUNGSTEN_SHARED_NETWORK_OFFERING_WITH_SGSERVICE = "DefaultTungstenSharedNetworkOfferingWithSGService";
public static final String DEFAULT_NAT_NSX_OFFERING_FOR_VPC = "DefaultNATNSXNetworkOfferingForVpc";
public static final String DEFAULT_NAT_NSX_OFFERING_FOR_VPC_WITH_ILB = "DefaultNATNSXNetworkOfferingForVpcWithInternalLB";
public static final String DEFAULT_ROUTED_NSX_OFFERING_FOR_VPC = "DefaultRoutedNSXNetworkOfferingForVpc";
public static final String DEFAULT_NAT_NSX_OFFERING = "DefaultNATNSXNetworkOffering";
public static final String DEFAULT_ROUTED_NSX_OFFERING = "DefaultRoutedNSXNetworkOffering";
public final static String QuickCloudNoServices = "QuickCloudNoServices";
public final static String DefaultIsolatedNetworkOfferingWithSourceNatService = "DefaultIsolatedNetworkOfferingWithSourceNatService";
public final static String OvsIsolatedNetworkOfferingWithSourceNatService = "OvsIsolatedNetworkOfferingWithSourceNatService";
@ -90,6 +100,10 @@ public interface NetworkOffering extends InfrastructureEntity, InternalIdentity,
boolean isForTungsten();
boolean isForNsx();
String getNsxMode();
TrafficType getTrafficType();
boolean isSpecifyVlan();

View File

@ -102,7 +102,7 @@ public interface ServiceOffering extends InfrastructureEntity, InternalIdentity,
boolean getDefaultUse();
String getSystemVmType();
String getVmType();
String getDeploymentPlanner();

View File

@ -449,10 +449,11 @@ public interface ManagementService {
* this method removes the child storage pools and adds the corresponding parent datastore cluster for API response listing
*
* @param Long volumeId
* @param String keyword if passed, will only return storage pools that contain this keyword in the name
* @return Pair<List<? extends StoragePool>, List<? extends StoragePool>> List of storage pools in cluster and list
* of pools with enough capacity.
*/
Pair<List<? extends StoragePool>, List<? extends StoragePool>> listStoragePoolsForMigrationOfVolume(Long volumeId);
Pair<List<? extends StoragePool>, List<? extends StoragePool>> listStoragePoolsForMigrationOfVolume(Long volumeId, String keyword);
Pair<List<? extends StoragePool>, List<? extends StoragePool>> listStoragePoolsForSystemMigrationOfVolume(Long volumeId, Long newDiskOfferingId, Long newSize, Long newMinIops, Long newMaxIops, boolean keepSourceStoragePool, boolean bypassStorageTypeCheck);

View File

@ -20,6 +20,7 @@ package com.cloud.storage;
import com.cloud.utils.exception.CloudRuntimeException;
public enum DataStoreRole {
Primary("primary"), Image("image"), ImageCache("imagecache"), Backup("backup"), Object("object");

View File

@ -16,10 +16,14 @@
// under the License.
package com.cloud.storage;
import org.apache.commons.lang.NotImplementedException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.apache.commons.lang.NotImplementedException;
import org.apache.commons.lang3.StringUtils;
public class Storage {
public static enum ImageFormat {
@ -135,37 +139,72 @@ public class Storage {
ISODISK /* Template corresponding to a iso (non root disk) present in an OVA */
}
public static enum StoragePoolType {
Filesystem(false, true, true), // local directory
NetworkFilesystem(true, true, true), // NFS
IscsiLUN(true, false, false), // shared LUN, with a clusterfs overlay
Iscsi(true, false, false), // for e.g., ZFS Comstar
ISO(false, false, false), // for iso image
LVM(false, false, false), // XenServer local LVM SR
CLVM(true, false, false),
RBD(true, true, false), // http://libvirt.org/storage.html#StorageBackendRBD
SharedMountPoint(true, false, true),
VMFS(true, true, false), // VMware VMFS storage
PreSetup(true, true, false), // for XenServer, Storage Pool is set up by customers.
EXT(false, true, false), // XenServer local EXT SR
OCFS2(true, false, false),
SMB(true, false, false),
Gluster(true, false, false),
PowerFlex(true, true, true), // Dell EMC PowerFlex/ScaleIO (formerly VxFlexOS)
ManagedNFS(true, false, false),
Linstor(true, true, false),
DatastoreCluster(true, true, false), // for VMware, to abstract pool of clusters
StorPool(true, true, true),
FiberChannel(true, true, false); // Fiber Channel Pool for KVM hypervisors is used to find the volume by WWN value (/dev/disk/by-id/wwn-<wwnvalue>)
/**
* StoragePoolTypes carry some details about the format and capabilities of a storage pool. While not necessarily a
* 1:1 with PrimaryDataStoreDriver (and for KVM agent, KVMStoragePool and StorageAdaptor) implementations, it is
* often used to decide which storage plugin or storage command to call, so it may be necessary for new storage
* plugins to add a StoragePoolType. This can be done by adding it below, or by creating a new public static final
* instance of StoragePoolType in the plugin itself, which registers it with the map.
*
* Note that if the StoragePoolType is for KVM and defined in plugin code rather than below, care must be taken to
* ensure this is available on the agent side as well. This is best done by defining the StoragePoolType in a common
* package available on both management server and agent plugin jars.
*/
public static class StoragePoolType {
private static final Map<String, StoragePoolType> map = new LinkedHashMap<>();
public static final StoragePoolType Filesystem = new StoragePoolType("Filesystem", false, true, true);
public static final StoragePoolType NetworkFilesystem = new StoragePoolType("NetworkFilesystem", true, true, true);
public static final StoragePoolType IscsiLUN = new StoragePoolType("IscsiLUN", true, false, false);
public static final StoragePoolType Iscsi = new StoragePoolType("Iscsi", true, false, false);
public static final StoragePoolType ISO = new StoragePoolType("ISO", false, false, false);
public static final StoragePoolType LVM = new StoragePoolType("LVM", false, false, false);
public static final StoragePoolType CLVM = new StoragePoolType("CLVM", true, false, false);
public static final StoragePoolType RBD = new StoragePoolType("RBD", true, true, false);
public static final StoragePoolType SharedMountPoint = new StoragePoolType("SharedMountPoint", true, true, true);
public static final StoragePoolType VMFS = new StoragePoolType("VMFS", true, true, false);
public static final StoragePoolType PreSetup = new StoragePoolType("PreSetup", true, true, false);
public static final StoragePoolType EXT = new StoragePoolType("EXT", false, true, false);
public static final StoragePoolType OCFS2 = new StoragePoolType("OCFS2", true, false, false);
public static final StoragePoolType SMB = new StoragePoolType("SMB", true, false, false);
public static final StoragePoolType Gluster = new StoragePoolType("Gluster", true, false, false);
public static final StoragePoolType PowerFlex = new StoragePoolType("PowerFlex", true, true, true);
public static final StoragePoolType ManagedNFS = new StoragePoolType("ManagedNFS", true, false, false);
public static final StoragePoolType Linstor = new StoragePoolType("Linstor", true, true, false);
public static final StoragePoolType DatastoreCluster = new StoragePoolType("DatastoreCluster", true, true, false);
public static final StoragePoolType StorPool = new StoragePoolType("StorPool", true,true,true);
public static final StoragePoolType FiberChannel = new StoragePoolType("FiberChannel", true,true,false);
private final String name;
private final boolean shared;
private final boolean overprovisioning;
private final boolean overProvisioning;
private final boolean encryption;
StoragePoolType(boolean shared, boolean overprovisioning, boolean encryption) {
/**
* New StoragePoolType, set the name to check with it in Dao (Note: Do not register it into the map of pool types).
* @param name name of the StoragePoolType.
*/
public StoragePoolType(String name) {
this.name = name;
this.shared = false;
this.overProvisioning = false;
this.encryption = false;
}
/**
* Define a new StoragePoolType, and register it into the map of pool types known to the management server.
* @param name Simple unique name of the StoragePoolType.
* @param shared Storage pool is shared/accessible to multiple hypervisors
* @param overProvisioning Storage pool supports overProvisioning
* @param encryption Storage pool supports encrypted volumes
*/
public StoragePoolType(String name, boolean shared, boolean overProvisioning, boolean encryption) {
this.name = name;
this.shared = shared;
this.overprovisioning = overprovisioning;
this.overProvisioning = overProvisioning;
this.encryption = encryption;
addStoragePoolType(this);
}
public boolean isShared() {
@ -173,14 +212,58 @@ public class Storage {
}
public boolean supportsOverProvisioning() {
return overprovisioning;
return overProvisioning;
}
public boolean supportsEncryption() { return encryption; }
public boolean supportsEncryption() {
return encryption;
}
private static void addStoragePoolType(StoragePoolType storagePoolType) {
map.putIfAbsent(storagePoolType.name, storagePoolType);
}
public static StoragePoolType[] values() {
return map.values().toArray(StoragePoolType[]::new).clone();
}
public static StoragePoolType valueOf(String name) {
if (StringUtils.isBlank(name)) {
return null;
}
StoragePoolType storage = map.get(name);
if (storage == null) {
throw new IllegalArgumentException("StoragePoolType '" + name + "' not found");
}
return storage;
}
@Override
public String toString() {
return name;
}
public String name() {
return name;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
StoragePoolType that = (StoragePoolType) o;
return Objects.equals(name, that.name);
}
@Override
public int hashCode() {
return Objects.hash(name);
}
}
public static List<StoragePoolType> getNonSharedStoragePoolTypes() {
List<StoragePoolType> nonSharedStoragePoolTypes = new ArrayList<StoragePoolType>();
List<StoragePoolType> nonSharedStoragePoolTypes = new ArrayList<>();
for (StoragePoolType storagePoolType : StoragePoolType.values()) {
if (!storagePoolType.isShared()) {
nonSharedStoragePoolTypes.add(storagePoolType);

View File

@ -30,6 +30,8 @@ import com.cloud.utils.fsm.StateObject;
public interface Volume extends ControlledEntity, Identity, InternalIdentity, BasedOn, StateObject<Volume.State>, Displayable {
static final long DISK_OFFERING_SUITABILITY_CHECK_VOLUME_ID = -1;
// Managed storage volume parameters (specified in the compute/disk offering for PowerFlex)
String BANDWIDTH_LIMIT_IN_MBPS = "bandwidthLimitInMbps";
String IOPS_LIMIT = "iopsLimit";
@ -39,30 +41,38 @@ public interface Volume extends ControlledEntity, Identity, InternalIdentity, Ba
};
enum State {
Allocated("The volume is allocated but has not been created yet."),
Creating("The volume is being created. getPoolId() should reflect the pool where it is being created."),
Ready("The volume is ready to be used."),
Migrating("The volume is migrating to other storage pool"),
Snapshotting("There is a snapshot created on this volume, not backed up to secondary storage yet"),
RevertSnapshotting("There is a snapshot created on this volume, the volume is being reverting from snapshot"),
Resizing("The volume is being resized"),
Expunging("The volume is being expunging"),
Expunged("The volume has been expunged, and can no longer be recovered"),
Destroy("The volume is destroyed, and can be recovered."),
Destroying("The volume is destroying, and can't be recovered."),
UploadOp("The volume upload operation is in progress or in short the volume is on secondary storage"),
Copying("Volume is copying from image store to primary, in case it's an uploaded volume"),
Uploaded("Volume is uploaded"),
NotUploaded("The volume entry is just created in DB, not yet uploaded"),
UploadInProgress("Volume upload is in progress"),
UploadError("Volume upload encountered some error"),
UploadAbandoned("Volume upload is abandoned since the upload was never initiated within a specified time"),
Attaching("The volume is attaching to a VM from Ready state."),
Restoring("The volume is being restored from backup.");
Allocated(false, "The volume is allocated but has not been created yet."),
Creating(true, "The volume is being created. getPoolId() should reflect the pool where it is being created."),
Ready(false, "The volume is ready to be used."),
Migrating(true, "The volume is migrating to other storage pool"),
Snapshotting(true, "There is a snapshot created on this volume, not backed up to secondary storage yet"),
RevertSnapshotting(true, "There is a snapshot created on this volume, the volume is being reverting from snapshot"),
Resizing(true, "The volume is being resized"),
Expunging(true, "The volume is being expunging"),
Expunged(false, "The volume has been expunged, and can no longer be recovered"),
Destroy(false, "The volume is destroyed, and can be recovered."),
Destroying(false, "The volume is destroying, and can't be recovered."),
UploadOp(true, "The volume upload operation is in progress or in short the volume is on secondary storage"),
Copying(true, "Volume is copying from image store to primary, in case it's an uploaded volume"),
Uploaded(false, "Volume is uploaded"),
NotUploaded(true, "The volume entry is just created in DB, not yet uploaded"),
UploadInProgress(true, "Volume upload is in progress"),
UploadError(false, "Volume upload encountered some error"),
UploadAbandoned(false, "Volume upload is abandoned since the upload was never initiated within a specified time"),
Attaching(true, "The volume is attaching to a VM from Ready state."),
Restoring(true, "The volume is being restored from backup.");
boolean _transitional;
String _description;
private State(String description) {
/**
* Volume State
* @param transitional true for transition/non-final state, otherwise false
* @param description description of the state
*/
private State(boolean transitional, String description) {
_transitional = transitional;
_description = description;
}
@ -70,6 +80,10 @@ public interface Volume extends ControlledEntity, Identity, InternalIdentity, Ba
return s_fsm;
}
public boolean isTransitional() {
return _transitional;
}
public String getDescription() {
return _description;
}

View File

@ -22,9 +22,11 @@ import java.net.MalformedURLException;
import java.util.List;
import java.util.Map;
import com.cloud.utils.Pair;
import org.apache.cloudstack.api.command.user.volume.AssignVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.AttachVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.ChangeOfferingForVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.CheckAndRepairVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.CreateVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.DetachVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.ExtractVolumeCmd;
@ -173,9 +175,13 @@ public interface VolumeApiService {
boolean validateVolumeSizeInBytes(long size);
void validateDestroyVolume(Volume volume, Account caller, boolean expunge, boolean forceExpunge);
Volume changeDiskOfferingForVolume(ChangeOfferingForVolumeCmd cmd) throws ResourceAllocationException;
void publishVolumeCreationUsageEvent(Volume volume);
boolean stateTransitTo(Volume vol, Volume.Event event) throws NoTransitionException;
Pair<String, String> checkAndRepairVolume(CheckAndRepairVolumeCmd cmd) throws ResourceAllocationException;
}

View File

@ -18,13 +18,18 @@ package com.cloud.user;
import java.util.List;
import org.apache.cloudstack.api.response.AccountResponse;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.framework.config.ConfigKey;
import com.cloud.configuration.Resource.ResourceType;
import com.cloud.configuration.ResourceCount;
import com.cloud.configuration.ResourceLimit;
import com.cloud.domain.Domain;
import com.cloud.exception.ResourceAllocationException;
import org.apache.cloudstack.framework.config.ConfigKey;
import org.apache.cloudstack.user.ResourceReservation;
import com.cloud.offering.DiskOffering;
import com.cloud.offering.ServiceOffering;
import com.cloud.template.VirtualMachineTemplate;
public interface ResourceLimitService {
@ -33,7 +38,14 @@ public interface ResourceLimitService {
static final ConfigKey<Long> MaxProjectSecondaryStorage = new ConfigKey<>("Project Defaults", Long.class, "max.project.secondary.storage", "400",
"The default maximum secondary storage space (in GiB) that can be used for a project", false);
static final ConfigKey<Long> ResourceCountCheckInterval = new ConfigKey<>("Advanced", Long.class, "resourcecount.check.interval", "300",
"Time (in seconds) to wait before running resource recalculation and fixing task. Default is 300 seconds, Setting this to 0 disables execution of the task", false);
"Time (in seconds) to wait before running resource recalculation and fixing task. Default is 300 seconds, Setting this to 0 disables execution of the task", true);
static final ConfigKey<String> ResourceLimitHostTags = new ConfigKey<>("Advanced", String.class, "resource.limit.host.tags", "",
"A comma-separated list of tags for host resource limits", true);
static final ConfigKey<String> ResourceLimitStorageTags = new ConfigKey<>("Advanced", String.class, "resource.limit.storage.tags", "",
"A comma-separated list of tags for storage resource limits", true);
static final List<ResourceType> HostTagsSupportingTypes = List.of(ResourceType.user_vm, ResourceType.cpu, ResourceType.memory);
static final List<ResourceType> StorageTagsSupportingTypes = List.of(ResourceType.volume, ResourceType.primary_storage);
/**
* Updates an existing resource limit with the specified details. If a limit doesn't exist, will create one.
@ -46,22 +58,27 @@ public interface ResourceLimitService {
* TODO
* @param max
* TODO
* @param tag
* tag for the resource type
*
* @return the updated/created resource limit
*/
ResourceLimit updateResourceLimit(Long accountId, Long domainId, Integer resourceType, Long max);
ResourceLimit updateResourceLimit(Long accountId, Long domainId, Integer resourceType, Long max, String tag);
/**
* Updates an existing resource count details for the account/domain
*
* @param accountId
* TODO
* Id of the account for which resource recalculation to be done
* @param domainId
* TODO
* Id of the domain for which resource recalculation to be doneDO
* @param typeId
* TODO
* type of the resource for which recalculation to be done
* @param tag
* tag for the resource type for which recalculation to be done
* @return the updated/created resource counts
*/
List<? extends ResourceCount> recalculateResourceCount(Long accountId, Long domainId, Integer typeId, String tag);
List<? extends ResourceCount> recalculateResourceCount(Long accountId, Long domainId, Integer typeId);
/**
@ -77,7 +94,7 @@ public interface ResourceLimitService {
* TODO
* @return a list of limits that match the criteria
*/
public List<? extends ResourceLimit> searchForLimits(Long id, Long accountId, Long domainId, ResourceType resourceType, Long startIndex, Long pageSizeVal);
public List<? extends ResourceLimit> searchForLimits(Long id, Long accountId, Long domainId, ResourceType resourceType, String tag, Long startIndex, Long pageSizeVal);
/**
* Finds the resource limit for a specified account and type. If the account has an infinite limit, will check
@ -85,9 +102,10 @@ public interface ResourceLimitService {
*
* @param account
* @param type
* @param tag
* @return resource limit
*/
public long findCorrectResourceLimitForAccount(Account account, ResourceType type);
public long findCorrectResourceLimitForAccount(Account account, ResourceType type, String tag);
/**
* This call should be used when we have already queried resource limit for an account. This is to handle
@ -105,9 +123,10 @@ public interface ResourceLimitService {
*
* @param domain
* @param type
* @param tag
* @return resource limit
*/
public long findCorrectResourceLimitForDomain(Domain domain, ResourceType type);
public long findCorrectResourceLimitForDomain(Domain domain, ResourceType type, String tag);
/**
* Finds the default resource limit for a specified type.
@ -122,9 +141,10 @@ public interface ResourceLimitService {
*
* @param domain
* @param type
* @param tag
* @return resource limit
*/
public long findCorrectResourceLimitForAccountAndDomain(Account account, Domain domain, ResourceType type);
public long findCorrectResourceLimitForAccountAndDomain(Account account, Domain domain, ResourceType type, String tag);
/**
* Increments the resource count
@ -134,6 +154,7 @@ public interface ResourceLimitService {
* @param delta
*/
public void incrementResourceCount(long accountId, ResourceType type, Long... delta);
public void incrementResourceCountWithTag(long accountId, ResourceType type, String tag, Long... delta);
/**
* Decrements the resource count
@ -143,6 +164,7 @@ public interface ResourceLimitService {
* @param delta
*/
public void decrementResourceCount(long accountId, ResourceType type, Long... delta);
public void decrementResourceCountWithTag(long accountId, ResourceType type, String tag, Long... delta);
/**
* Checks if a limit has been exceeded for an account
@ -155,15 +177,17 @@ public interface ResourceLimitService {
* @throws ResourceAllocationException
*/
public void checkResourceLimit(Account account, ResourceCount.ResourceType type, long... count) throws ResourceAllocationException;
public void checkResourceLimitWithTag(Account account, ResourceCount.ResourceType type, String tag, long... count) throws ResourceAllocationException;
/**
* Gets the count of resources for a resource type and account
*
* @param account
* @param type
* @param tag
* @return count of resources
*/
public long getResourceCount(Account account, ResourceType type);
public long getResourceCount(Account account, ResourceType type, String tag);
/**
* Checks if a limit has been exceeded for an account if displayResource flag is on
@ -208,15 +232,25 @@ public interface ResourceLimitService {
*/
void decrementResourceCount(long accountId, ResourceType type, Boolean displayResource, Long... delta);
/**
* Adds a reservation that will be counted in subsequent calls to {count}getResourceCount{code} until {code}this[code}
* is closed. It will create a reservation record that will be counted when resource limits are checked.
* @param account The account for which the reservation is.
* @param displayResource whether this resource is shown to users at all (if not it is not counted to limits)
* @param type resource type
* @param delta amount to reserve (will not be <+ 0)
* @return a {code}AutoClosable{Code} object representing the resource the user needs
*/
ResourceReservation getReservation(Account account, Boolean displayResource, ResourceType type, Long delta) throws ResourceAllocationException;
List<String> getResourceLimitHostTags();
List<String> getResourceLimitHostTags(ServiceOffering serviceOffering, VirtualMachineTemplate template);
List<String> getResourceLimitStorageTags();
List<String> getResourceLimitStorageTags(DiskOffering diskOffering);
void updateTaggedResourceLimitsAndCountsForAccounts(List<AccountResponse> responses, String tag);
void updateTaggedResourceLimitsAndCountsForDomains(List<DomainResponse> responses, String tag);
void checkVolumeResourceLimit(Account owner, Boolean display, Long size, DiskOffering diskOffering) throws ResourceAllocationException;
void incrementVolumeResourceCount(long accountId, Boolean display, Long size, DiskOffering diskOffering);
void decrementVolumeResourceCount(long accountId, Boolean display, Long size, DiskOffering diskOffering);
void incrementVolumePrimaryStorageResourceCount(long accountId, Boolean display, Long size, DiskOffering diskOffering);
void decrementVolumePrimaryStorageResourceCount(long accountId, Boolean display, Long size, DiskOffering diskOffering);
void checkVmResourceLimit(Account owner, Boolean display, ServiceOffering serviceOffering, VirtualMachineTemplate template) throws ResourceAllocationException;
void incrementVmResourceCount(long accountId, Boolean display, ServiceOffering serviceOffering, VirtualMachineTemplate template);
void decrementVmResourceCount(long accountId, Boolean display, ServiceOffering serviceOffering, VirtualMachineTemplate template);
void checkVmCpuResourceLimit(Account owner, Boolean display, ServiceOffering serviceOffering, VirtualMachineTemplate template, Long cpu) throws ResourceAllocationException;
void incrementVmCpuResourceCount(long accountId, Boolean display, ServiceOffering serviceOffering, VirtualMachineTemplate template, Long cpu);
void decrementVmCpuResourceCount(long accountId, Boolean display, ServiceOffering serviceOffering, VirtualMachineTemplate template, Long cpu);
void checkVmMemoryResourceLimit(Account owner, Boolean display, ServiceOffering serviceOffering, VirtualMachineTemplate template, Long memory) throws ResourceAllocationException;
void incrementVmMemoryResourceCount(long accountId, Boolean display, ServiceOffering serviceOffering, VirtualMachineTemplate template, Long memory);
void decrementVmMemoryResourceCount(long accountId, Boolean display, ServiceOffering serviceOffering, VirtualMachineTemplate template, Long memory);
}

View File

@ -442,6 +442,6 @@ public class NicProfile implements InternalIdentity, Serializable {
@Override
public String toString() {
return String.format("NicProfile %s", ReflectionToStringBuilderUtils.reflectOnlySelectedFields(this, "id", "vmId", "reservationId", "iPv4Address", "broadcastUri"));
return String.format("NicProfile %s", ReflectionToStringBuilderUtils.reflectOnlySelectedFields(this, "id", "vmId", "deviceId", "broadcastUri", "reservationId", "iPv4Address"));
}
}

View File

@ -492,7 +492,7 @@ public interface UserVmService {
UserVm restoreVM(RestoreVMCmd cmd) throws InsufficientCapacityException, ResourceUnavailableException;
UserVm restoreVirtualMachine(Account caller, long vmId, Long newTemplateId) throws InsufficientCapacityException, ResourceUnavailableException;
UserVm restoreVirtualMachine(Account caller, long vmId, Long newTemplateId, Long rootDiskOfferingId, boolean expunge, Map<String, String> details) throws InsufficientCapacityException, ResourceUnavailableException;
UserVm upgradeVirtualMachine(ScaleVMCmd cmd) throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException,
VirtualMachineMigrationException;

View File

@ -60,6 +60,8 @@ public interface VirtualMachineProfile {
void setConfigDriveLocation(NetworkElement.Location location);
void setServiceOffering(ServiceOffering offering);
public static class Param {
public static final Param VmPassword = new Param("VmPassword");

View File

@ -38,7 +38,9 @@ public interface RoleService {
* Moreover, we will check if the requested role is of 'Admin' type; roles with 'Admin' type should only be visible to 'root admins'.
* Therefore, if a non-'root admin' user tries to search for an 'Admin' role, this method will return null.
*/
Role findRole(Long id, boolean removePrivateRoles);
Role findRole(Long id, boolean ignorePrivateRoles);
List<Role> findRoles(List<Long> ids, boolean ignorePrivateRoles);
Role findRole(Long id);

View File

@ -20,7 +20,8 @@ import org.apache.commons.lang3.StringUtils;
import com.cloud.user.Account;
import com.google.common.base.Enums;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import java.util.HashMap;
import java.util.Map;
@ -37,7 +38,7 @@ public enum RoleType {
private Account.Type accountType;
private int mask;
private static Logger logger = Logger.getLogger(RoleType.class.getName());
private static Logger LOGGER = LogManager.getLogger(RoleType.class.getName());
private static Map<Account.Type, RoleType> ACCOUNT_TYPE_MAP = new HashMap<>();
static {
@ -104,10 +105,10 @@ public enum RoleType {
* */
public static Account.Type getAccountTypeByRole(final Role role, final Account.Type defautAccountType) {
if (role != null) {
logger.debug(String.format("Role [%s] is not null; therefore, we use its account type [%s].", role, defautAccountType));
LOGGER.debug(String.format("Role [%s] is not null; therefore, we use its account type [%s].", role, defautAccountType));
return role.getRoleType().getAccountType();
}
logger.debug(String.format("Role is null; therefore, we use the default account type [%s] value.", defautAccountType));
LOGGER.debug(String.format("Role is null; therefore, we use the default account type [%s] value.", defautAccountType));
return defautAccountType;
}
}

View File

@ -52,7 +52,7 @@ public interface AlertService {
public static final AlertType ALERT_TYPE_ROUTING = new AlertType((short)11, "ALERT.NETWORK.ROUTING", true);
public static final AlertType ALERT_TYPE_STORAGE_MISC = new AlertType((short)12, "ALERT.STORAGE.MISC", true);
public static final AlertType ALERT_TYPE_USAGE_SERVER = new AlertType((short)13, "ALERT.USAGE", true);
public static final AlertType ALERT_TYPE_MANAGMENT_NODE = new AlertType((short)14, "ALERT.MANAGEMENT", true);
public static final AlertType ALERT_TYPE_MANAGEMENT_NODE = new AlertType((short)14, "ALERT.MANAGEMENT", true);
public static final AlertType ALERT_TYPE_DOMAIN_ROUTER_MIGRATE = new AlertType((short)15, "ALERT.NETWORK.DOMAINROUTERMIGRATE", true);
public static final AlertType ALERT_TYPE_CONSOLE_PROXY_MIGRATE = new AlertType((short)16, "ALERT.SERVICE.CONSOLEPROXYMIGRATE", true);
public static final AlertType ALERT_TYPE_USERVM_MIGRATE = new AlertType((short)17, "ALERT.USERVM.MIGRATE", true);
@ -91,6 +91,10 @@ public interface AlertService {
return null;
}
public static Set<AlertType> getAlertTypes() {
return defaultAlertTypes;
}
@Override
public String toString() {
return String.valueOf(this.getType());

View File

@ -25,11 +25,9 @@ import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.GetUploadParamsResponse;
import org.apache.cloudstack.api.response.ProjectResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.log4j.Logger;
public abstract class AbstractGetUploadParamsCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(AbstractGetUploadParamsCmd.class.getName());
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "the name of the volume/template/iso")
private String name;

View File

@ -80,7 +80,8 @@ public enum ApiCommandResourceType {
VpnCustomerGateway(com.cloud.network.Site2SiteCustomerGateway.class),
ManagementServer(org.apache.cloudstack.management.ManagementServerHost.class),
ObjectStore(org.apache.cloudstack.storage.object.ObjectStore.class),
Bucket(org.apache.cloudstack.storage.object.Bucket.class);
Bucket(org.apache.cloudstack.storage.object.Bucket.class),
QuotaTariff(org.apache.cloudstack.quota.QuotaTariff.class);
private final Class<?> clazz;

View File

@ -285,6 +285,7 @@ public class ApiConstants {
public static final String LAST_SERVER_STOP = "lastserverstop";
public static final String LEVEL = "level";
public static final String LENGTH = "length";
public static final String LIMIT = "limit";
public static final String LIMIT_CPU_USE = "limitcpuuse";
public static final String LIST_HOSTS = "listhosts";
public static final String LOCK = "lock";
@ -302,6 +303,8 @@ public class ApiConstants {
public static final String MIGRATIONS = "migrations";
public static final String MEMORY = "memory";
public static final String MODE = "mode";
public static final String NSX_MODE = "nsxmode";
public static final String NSX_ENABLED = "isnsxenabled";
public static final String NAME = "name";
public static final String METHOD_NAME = "methodname";
public static final String NETWORK_DOMAIN = "networkdomain";
@ -321,6 +324,7 @@ public class ApiConstants {
public static final String IS_DEFAULT_USE = "defaultuse";
public static final String OLD_FORMAT = "oldformat";
public static final String OP = "op";
public static final String OPTION = "option";
public static final String OPTIONS = "options";
public static final String OS_CATEGORY_ID = "oscategoryid";
public static final String OS_CATEGORY_NAME = "oscategoryname";
@ -378,7 +382,9 @@ public class ApiConstants {
public static final String RECEIVED_BYTES = "receivedbytes";
public static final String RECONNECT = "reconnect";
public static final String RECOVER = "recover";
public static final String REPAIR = "repair";
public static final String REQUIRES_HVM = "requireshvm";
public static final String RESOURCE_COUNT = "resourcecount";
public static final String RESOURCE_NAME = "resourcename";
public static final String RESOURCE_TYPE = "resourcetype";
public static final String RESOURCE_TYPE_NAME = "resourcetypename";
@ -419,8 +425,9 @@ public class ApiConstants {
public static final String SNAPSHOT_POLICY_ID = "snapshotpolicyid";
public static final String SNAPSHOT_TYPE = "snapshottype";
public static final String SNAPSHOT_QUIESCEVM = "quiescevm";
public static final String SUPPORTS_STORAGE_SNAPSHOT = "supportsstoragesnapshot";
public static final String SOURCE_ZONE_ID = "sourcezoneid";
public static final String SUITABLE_FOR_VM = "suitableforvirtualmachine";
public static final String SUPPORTS_STORAGE_SNAPSHOT = "supportsstoragesnapshot";
public static final String START_DATE = "startdate";
public static final String START_ID = "startid";
public static final String START_IP = "startip";
@ -448,6 +455,7 @@ public class ApiConstants {
public static final String TIMEOUT = "timeout";
public static final String TIMEZONE = "timezone";
public static final String TIMEZONEOFFSET = "timezoneoffset";
public static final String TOTAL = "total";
public static final String TOTAL_SUBNETS = "totalsubnets";
public static final String TYPE = "type";
public static final String TRUST_STORE = "truststore";
@ -501,6 +509,9 @@ public class ApiConstants {
public static final String IS_VOLATILE = "isvolatile";
public static final String VOLUME_ID = "volumeid";
public static final String VOLUMES = "volumes";
public static final String VOLUME_CHECK_RESULT = "volumecheckresult";
public static final String VOLUME_REPAIR_RESULT = "volumerepairresult";
public static final String ZONE = "zone";
public static final String ZONE_ID = "zoneid";
public static final String ZONE_NAME = "zonename";
@ -695,6 +706,12 @@ public class ApiConstants {
public static final String VSWITCH_TYPE_PUBLIC_TRAFFIC = "publicvswitchtype";
public static final String VSWITCH_NAME_GUEST_TRAFFIC = "guestvswitchname";
public static final String VSWITCH_NAME_PUBLIC_TRAFFIC = "publicvswitchname";
// NSX
public static final String EDGE_CLUSTER = "edgecluster";
public static final String TIER0_GATEWAY = "tier0gateway";
public static final String TRANSPORT_ZONE = "transportzone";
// Tungsten-Fabric
public static final String TUNGSTEN_VIRTUAL_ROUTER_UUID = "tungstenvirtualrouteruuid";
public static final String TUNGSTEN_PROVIDER_HOSTNAME = "tungstenproviderhostname";
@ -718,6 +735,7 @@ public class ApiConstants {
public static final String POLICY_UUID = "policyuuid";
public static final String RULE_UUID = "ruleuuid";
public static final String DIRECTION = "direction";
public static final String TAGGED_RESOURCES = "taggedresources";
public static final String TAG_UUID = "taguuid";
public static final String TAG_TYPE = "tagtype";
public static final String TAG_VALUE = "tagvalue";
@ -803,6 +821,7 @@ public class ApiConstants {
public static final String IPSEC_PSK = "ipsecpsk";
public static final String GUEST_IP = "guestip";
public static final String REMOVED = "removed";
public static final String REMOVER_ACCOUNT_ID = "removeraccountid";
public static final String REMOVAL_REASON = "removalreason";
public static final String COMPLETED = "completed";
public static final String IKE_VERSION = "ikeversion";
@ -814,6 +833,9 @@ public class ApiConstants {
public static final String FORCE_ENCAP = "forceencap";
public static final String SPLIT_CONNECTIONS = "splitconnections";
public static final String FOR_VPC = "forvpc";
public static final String FOR_NSX = "fornsx";
public static final String NSX_SUPPORT_LB = "nsxsupportlb";
public static final String NSX_SUPPORTS_INTERNAL_LB = "nsxsupportsinternallb";
public static final String FOR_TUNGSTEN = "fortungsten";
public static final String SHRINK_OK = "shrinkok";
public static final String NICIRA_NVP_DEVICE_ID = "nvpdeviceid";
@ -823,6 +845,11 @@ public class ApiConstants {
public static final String NICIRA_NVP_L2_GATEWAYSERVICE_UUID = "l2gatewayserviceuuid";
public static final String NSX_LOGICAL_SWITCH = "nsxlogicalswitch";
public static final String NSX_LOGICAL_SWITCH_PORT = "nsxlogicalswitchport";
public static final String NSX_PROVIDER_UUID = "nsxprovideruuid";
public static final String NSX_PROVIDER_HOSTNAME = "nsxproviderhostname";
public static final String NSX_PROVIDER_PORT = "nsxproviderport";
public static final String NSX_CONTROLLER_ID = "nsxcontrollerid";
public static final String S3_ACCESS_KEY = "accesskey";
public static final String S3_SECRET_KEY = "secretkey";
public static final String S3_END_POINT = "endpoint";
@ -947,6 +974,7 @@ public class ApiConstants {
public static final String SUPPORTS_REGION_LEVEL_VPC = "supportsregionLevelvpc";
public static final String SUPPORTS_STRECHED_L2_SUBNET = "supportsstrechedl2subnet";
public static final String SUPPORTS_PUBLIC_ACCESS = "supportspublicaccess";
public static final String SUPPORTS_INTERNAL_LB = "supportsinternallb";
public static final String SUPPORTS_VM_AUTOSCALING = "supportsvmautoscaling";
public static final String REGION_LEVEL_VPC = "regionlevelvpc";
public static final String STRECHED_L2_SUBNET = "strechedl2subnet";
@ -1065,14 +1093,13 @@ public class ApiConstants {
public static final String SOURCE_NAT_IP = "sourcenatipaddress";
public static final String SOURCE_NAT_IP_ID = "sourcenatipaddressid";
public static final String HAS_RULES = "hasrules";
public static final String NSX_DETAIL_KEY = "forNsx";
public static final String DISK_PATH = "diskpath";
public static final String IMPORT_SOURCE = "importsource";
public static final String TEMP_PATH = "temppath";
public static final String OBJECT_STORAGE = "objectstore";
public static final String HEURISTIC_RULE = "heuristicrule";
public static final String HEURISTIC_TYPE_VALID_OPTIONS = "Valid options are: ISO, SNAPSHOT, TEMPLATE and VOLUME.";
public static final String MANAGEMENT = "management";
public static final String IS_VNF = "isvnf";
public static final String VNF_NICS = "vnfnics";

View File

@ -17,7 +17,6 @@
package org.apache.cloudstack.api;
import org.apache.log4j.Logger;
/**
* queryAsyncJobResult API command.
@ -30,7 +29,6 @@ public abstract class BaseAsyncCmd extends BaseCmd {
public static final String migrationSyncObject = "migration";
public static final String snapshotHostSyncObject = "snapshothost";
public static final String gslbSyncObject = "globalserverloadbalancer";
private static final Logger s_logger = Logger.getLogger(BaseAsyncCmd.class.getName());
private Object job;

View File

@ -38,7 +38,6 @@ import org.apache.cloudstack.affinity.AffinityGroupService;
import org.apache.cloudstack.alert.AlertService;
import org.apache.cloudstack.annotation.AnnotationService;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.network.element.InternalLoadBalancerElementService;
import org.apache.cloudstack.network.lb.ApplicationLoadBalancerService;
import org.apache.cloudstack.network.lb.InternalLoadBalancerVMService;
import org.apache.cloudstack.query.QueryService;
@ -47,7 +46,8 @@ import org.apache.cloudstack.storage.ImageStoreService;
import org.apache.cloudstack.storage.template.VnfTemplateManager;
import org.apache.cloudstack.usage.UsageService;
import org.apache.commons.collections.MapUtils;
import org.apache.log4j.Logger;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import com.cloud.configuration.ConfigurationService;
import com.cloud.exception.ConcurrentOperationException;
@ -95,7 +95,7 @@ import com.cloud.vm.UserVmService;
import com.cloud.vm.snapshot.VMSnapshotService;
public abstract class BaseCmd {
private static final Logger s_logger = Logger.getLogger(BaseCmd.class.getName());
protected transient Logger logger = LogManager.getLogger(getClass());
public static final String RESPONSE_SUFFIX = "response";
public static final String RESPONSE_TYPE_XML = HttpUtils.RESPONSE_TYPE_XML;
public static final String RESPONSE_TYPE_JSON = HttpUtils.RESPONSE_TYPE_JSON;
@ -200,8 +200,6 @@ public abstract class BaseCmd {
@Inject
public AffinityGroupService _affinityGroupService;
@Inject
public InternalLoadBalancerElementService _internalLbElementSvc;
@Inject
public InternalLoadBalancerVMService _internalLbSvc;
@Inject
public NetworkModel _ntwkModel;
@ -374,7 +372,7 @@ public abstract class BaseCmd {
if (roleIsAllowed) {
validFields.add(field);
} else {
s_logger.debug("Ignoring parameter " + parameterAnnotation.name() + " as the caller is not authorized to pass it in");
logger.debug("Ignoring parameter " + parameterAnnotation.name() + " as the caller is not authorized to pass it in");
}
}
@ -419,7 +417,7 @@ public abstract class BaseCmd {
if(!isDisplay)
break;
} catch (Exception e){
s_logger.trace("Caught exception while checking first class entities for display property, continuing on", e);
logger.trace("Caught exception while checking first class entities for display property, continuing on", e);
}
}

View File

@ -18,7 +18,6 @@ package org.apache.cloudstack.api;
import java.util.List;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ResponseObject.ResponseView;
import org.apache.cloudstack.api.command.ResponseViewProvider;
@ -28,7 +27,6 @@ import com.cloud.template.VirtualMachineTemplate;
import com.cloud.user.Account;
public abstract class BaseListTemplateOrIsoPermissionsCmd extends BaseCmd implements ResponseViewProvider {
public Logger logger = getLogger();
protected static final String s_name = "listtemplatepermissionsresponse";
/////////////////////////////////////////////////////
@ -59,9 +57,6 @@ public abstract class BaseListTemplateOrIsoPermissionsCmd extends BaseCmd implem
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
}
protected Logger getLogger() {
return Logger.getLogger(BaseListTemplateOrIsoPermissionsCmd.class);
}
@Override
public String getCommandName() {

View File

@ -16,7 +16,6 @@
// under the License.
package org.apache.cloudstack.api;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.response.GuestOSResponse;
import org.apache.cloudstack.api.response.TemplateResponse;
@ -24,7 +23,6 @@ import java.util.Collection;
import java.util.Map;
public abstract class BaseUpdateTemplateOrIsoCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(BaseUpdateTemplateOrIsoCmd.class.getName());
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////

View File

@ -18,7 +18,6 @@ package org.apache.cloudstack.api;
import java.util.List;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.response.ProjectResponse;
import org.apache.cloudstack.api.response.SuccessResponse;
@ -27,16 +26,12 @@ import org.apache.cloudstack.api.response.TemplateResponse;
import com.cloud.exception.InvalidParameterValueException;
public abstract class BaseUpdateTemplateOrIsoPermissionsCmd extends BaseCmd {
public Logger _logger = getLogger();
protected String _name = getResponseName();
// ///////////////////////////////////////////////////
// ////////////// API parameters /////////////////////
// ///////////////////////////////////////////////////
protected Logger getLogger() {
return Logger.getLogger(BaseUpdateTemplateOrIsoPermissionsCmd.class);
}
protected String getResponseName() {
return "updatetemplateorisopermissionsresponse";

View File

@ -25,4 +25,18 @@ import java.io.Serializable;
public interface InternalIdentity extends Serializable {
long getId();
/*
Helper method to add conditions in joins where some column name is equal to a string value
*/
default Object setString(String str) {
return null;
}
/*
Helper method to add conditions in joins where some column name is equal to a long value
*/
default Object setLong(Long l) {
return null;
}
}

View File

@ -21,7 +21,6 @@ import java.util.Map;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
@ -43,7 +42,6 @@ import com.cloud.user.UserAccount;
@APICommand(name = "createAccount", description = "Creates an account", responseObject = AccountResponse.class, entityType = {Account.class},
requestHasSensitiveInfo = true, responseHasSensitiveInfo = true)
public class CreateAccountCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(CreateAccountCmd.class.getName());
/////////////////////////////////////////////////////

View File

@ -31,7 +31,6 @@ import org.apache.cloudstack.api.response.AccountResponse;
import org.apache.cloudstack.api.response.SuccessResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.region.RegionService;
import org.apache.log4j.Logger;
import com.cloud.event.EventTypes;
import com.cloud.user.Account;
@ -39,7 +38,6 @@ import com.cloud.user.Account;
@APICommand(name = "deleteAccount", description = "Deletes a account, and all users associated with this account", responseObject = SuccessResponse.class, entityType = {Account.class},
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class DeleteAccountCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(DeleteAccountCmd.class.getName());
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////

View File

@ -18,7 +18,6 @@ package org.apache.cloudstack.api.command.admin.account;
import javax.inject.Inject;
import org.apache.log4j.Logger;
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
import org.apache.cloudstack.api.ACL;
@ -43,7 +42,6 @@ import com.cloud.user.Account;
@APICommand(name = "disableAccount", description = "Disables an account", responseObject = AccountResponse.class, entityType = {Account.class},
requestHasSensitiveInfo = false, responseHasSensitiveInfo = true)
public class DisableAccountCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(DisableAccountCmd.class.getName());
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////

View File

@ -19,7 +19,6 @@ package org.apache.cloudstack.api.command.admin.account;
import javax.inject.Inject;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.log4j.Logger;
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
import org.apache.cloudstack.api.ACL;
@ -39,7 +38,6 @@ import com.cloud.user.Account;
@APICommand(name = "enableAccount", description = "Enables an account", responseObject = AccountResponse.class, entityType = {Account.class},
requestHasSensitiveInfo = false, responseHasSensitiveInfo = true)
public class EnableAccountCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(EnableAccountCmd.class.getName());
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////

View File

@ -16,7 +16,6 @@
// under the License.
package org.apache.cloudstack.api.command.admin.account;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
@ -35,7 +34,6 @@ import com.cloud.utils.exception.CloudRuntimeException;
requestHasSensitiveInfo = false,
responseHasSensitiveInfo = true)
public class LockAccountCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(LockAccountCmd.class.getName());
/////////////////////////////////////////////////////

View File

@ -23,7 +23,6 @@ import javax.inject.Inject;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.response.RoleResponse;
import org.apache.log4j.Logger;
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
import org.apache.cloudstack.api.ACL;
@ -43,7 +42,6 @@ import com.cloud.user.Account;
@APICommand(name = "updateAccount", description = "Updates account information for the authenticated user", responseObject = AccountResponse.class, entityType = {Account.class},
requestHasSensitiveInfo = false, responseHasSensitiveInfo = true)
public class UpdateAccountCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(UpdateAccountCmd.class.getName());
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////

View File

@ -20,6 +20,7 @@ package org.apache.cloudstack.api.command.admin.acl.project;
import org.apache.cloudstack.acl.ProjectRole;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
@ -70,4 +71,13 @@ public class CreateProjectRoleCmd extends ProjectRoleCmd {
return Account.ACCOUNT_ID_SYSTEM;
}
@Override
public Long getApiResourceId() {
return getProjectId();
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Project;
}
}

View File

@ -22,6 +22,7 @@ import org.apache.cloudstack.acl.ProjectRolePermission;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiArgValidator;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.Parameter;
@ -96,4 +97,14 @@ public class CreateProjectRolePermissionCmd extends BaseRolePermissionCmd {
response.setObjectName("projectrolepermission");
setResponseObject(response);
}
@Override
public Long getApiResourceId() {
return getProjectId();
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Project;
}
}

View File

@ -21,6 +21,7 @@ import org.apache.cloudstack.acl.ProjectRole;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiArgValidator;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
@ -79,4 +80,14 @@ public class DeleteProjectRoleCmd extends BaseCmd {
public long getEntityOwnerId() {
return CallContext.current().getCallingAccountId();
}
@Override
public Long getApiResourceId() {
return getProjectId();
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Project;
}
}

View File

@ -21,6 +21,7 @@ import org.apache.cloudstack.acl.ProjectRolePermission;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiArgValidator;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
@ -80,4 +81,14 @@ public class DeleteProjectRolePermissionCmd extends BaseCmd {
public long getEntityOwnerId() {
return CallContext.current().getCallingAccountId();
}
@Override
public Long getApiResourceId() {
return getProjectId();
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Project;
}
}

View File

@ -21,6 +21,7 @@ import org.apache.cloudstack.acl.ProjectRole;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiArgValidator;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
@ -76,4 +77,14 @@ public class UpdateProjectRoleCmd extends ProjectRoleCmd {
public long getEntityOwnerId() {
return 0;
}
@Override
public Long getApiResourceId() {
return getProjectId();
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Project;
}
}

View File

@ -26,6 +26,7 @@ import org.apache.cloudstack.acl.ProjectRolePermission;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiArgValidator;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
@ -154,4 +155,14 @@ public class UpdateProjectRolePermissionCmd extends BaseCmd {
public long getEntityOwnerId() {
return CallContext.current().getCallingAccountId();
}
@Override
public Long getApiResourceId() {
return getProjectId();
}
@Override
public ApiCommandResourceType getApiResourceType() {
return ApiCommandResourceType.Project;
}
}

View File

@ -16,7 +16,6 @@
// under the License.
package org.apache.cloudstack.api.command.admin.address;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
@ -35,7 +34,6 @@ import com.cloud.exception.ResourceUnavailableException;
@APICommand(name = "acquirePodIpAddress", description = "Allocates IP addresses in respective Pod of a Zone", responseObject = AcquirePodIpCmdResponse.class, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class AcquirePodIpCmdByAdmin extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(AcquirePodIpCmdByAdmin.class.getName());
private static final String s_name = "acquirepodipaddress";
/////////////////////////////////////////////////////

View File

@ -16,7 +16,6 @@
// under the License.
package org.apache.cloudstack.api.command.admin.address;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ResponseObject.ResponseView;
@ -27,5 +26,4 @@ import org.apache.cloudstack.api.response.IPAddressResponse;
@APICommand(name = "associateIpAddress", description = "Acquires and associates a public IP to an account.", responseObject = IPAddressResponse.class, responseView = ResponseView.Full,
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class AssociateIPAddrCmdByAdmin extends AssociateIPAddrCmd implements AdminCmd {
public static final Logger s_logger = Logger.getLogger(AssociateIPAddrCmdByAdmin.class.getName());
}

View File

@ -16,7 +16,6 @@
//under the License.
package org.apache.cloudstack.api.command.admin.address;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
@ -31,7 +30,6 @@ import com.cloud.user.Account;
@APICommand(name = "releasePodIpAddress", description = "Releases a Pod IP back to the Pod", responseObject = SuccessResponse.class, requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class ReleasePodIpCmdByAdmin extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(ReleasePodIpCmdByAdmin.class.getName());
private static final String s_name = "releasepodipresponse";

View File

@ -16,7 +16,6 @@
// under the License.
package org.apache.cloudstack.api.command.admin.affinitygroup;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ResponseObject.ResponseView;
@ -33,5 +32,4 @@ import com.cloud.vm.VirtualMachine;
requestHasSensitiveInfo = false,
responseHasSensitiveInfo = true)
public class UpdateVMAffinityGroupCmdByAdmin extends UpdateVMAffinityGroupCmd implements AdminCmd {
public static final Logger s_logger = Logger.getLogger(UpdateVMAffinityGroupCmdByAdmin.class.getName());
}

View File

@ -27,7 +27,6 @@ import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.PodResponse;
import org.apache.cloudstack.api.response.SuccessResponse;
import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.log4j.Logger;
import com.cloud.event.EventTypes;
@ -35,7 +34,6 @@ import com.cloud.event.EventTypes;
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class GenerateAlertCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(GenerateAlertCmd.class.getName());
// ///////////////////////////////////////////////////

View File

@ -17,7 +17,6 @@
package org.apache.cloudstack.api.command.admin.autoscale;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandResourceType;
@ -35,7 +34,6 @@ import com.cloud.user.Account;
@APICommand(name = "createCounter", description = "Adds metric counter for VM auto scaling", responseObject = CounterResponse.class,
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class CreateCounterCmd extends BaseAsyncCreateCmd {
public static final Logger s_logger = Logger.getLogger(CreateCounterCmd.class.getName());
private static final String s_name = "counterresponse";
// ///////////////////////////////////////////////////

View File

@ -17,7 +17,6 @@
package org.apache.cloudstack.api.command.admin.autoscale;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandResourceType;
@ -36,7 +35,6 @@ import com.cloud.user.Account;
@APICommand(name = "deleteCounter", description = "Deletes a counter for VM auto scaling", responseObject = SuccessResponse.class,
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class DeleteCounterCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(DeleteCounterCmd.class.getName());
// ///////////////////////////////////////////////////
// ////////////// API parameters /////////////////////
@ -55,7 +53,7 @@ public class DeleteCounterCmd extends BaseAsyncCmd {
try {
result = _autoScaleService.deleteCounter(getId());
} catch (ResourceInUseException ex) {
s_logger.warn("Exception: ", ex);
logger.warn("Exception: ", ex);
throw new ServerApiException(ApiErrorCode.RESOURCE_IN_USE_ERROR, ex.getMessage());
}
@ -63,7 +61,7 @@ public class DeleteCounterCmd extends BaseAsyncCmd {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
s_logger.warn("Failed to delete counter with Id: " + getId());
logger.warn("Failed to delete counter with Id: " + getId());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete counter.");
}
}

View File

@ -30,7 +30,6 @@ import org.apache.cloudstack.backup.BackupManager;
import org.apache.cloudstack.backup.BackupOffering;
import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.user.Account;
@ -39,7 +38,6 @@ import com.cloud.utils.exception.CloudRuntimeException;
@APICommand(name = "updateBackupOffering", description = "Updates a backup offering.", responseObject = BackupOfferingResponse.class,
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, since = "4.16.0")
public class UpdateBackupOfferingCmd extends BaseCmd {
private static final Logger LOGGER = Logger.getLogger(UpdateBackupOfferingCmd.class.getName());
@Inject
private BackupManager backupManager;
@ -100,7 +98,7 @@ public class UpdateBackupOfferingCmd extends BaseCmd {
this.setResponseObject(response);
} catch (CloudRuntimeException e) {
ApiErrorCode paramError = e instanceof InvalidParameterValueException ? ApiErrorCode.PARAM_ERROR : ApiErrorCode.INTERNAL_ERROR;
LOGGER.error(String.format("Failed to update Backup Offering [id: %s] due to: [%s].", id, e.getMessage()), e);
logger.error(String.format("Failed to update Backup Offering [id: %s] due to: [%s].", id, e.getMessage()), e);
throw new ServerApiException(paramError, e.getMessage());
}
}

View File

@ -37,7 +37,6 @@ import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.framework.ca.Certificate;
import org.apache.cloudstack.utils.security.CertUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import com.cloud.event.EventTypes;
@ -49,7 +48,6 @@ import com.cloud.event.EventTypes;
since = "4.11.0",
authorized = {RoleType.Admin})
public class IssueCertificateCmd extends BaseAsyncCmd {
private static final Logger LOG = Logger.getLogger(IssueCertificateCmd.class);
@Inject
@ -132,7 +130,7 @@ public class IssueCertificateCmd extends BaseAsyncCmd {
certificateResponse.setCaCertificate(CertUtils.x509CertificatesToPem(certificate.getCaCertificates()));
}
} catch (final IOException e) {
LOG.error("Failed to generate and convert client certificate(s) to PEM due to error: ", e);
logger.error("Failed to generate and convert client certificate(s) to PEM due to error: ", e);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to process and return client certificate");
}
certificateResponse.setResponseName(getCommandName());

View File

@ -21,7 +21,6 @@ import java.util.ArrayList;
import java.util.List;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
@ -42,7 +41,6 @@ import com.cloud.user.Account;
@APICommand(name = "addCluster", description = "Adds a new cluster", responseObject = ClusterResponse.class,
requestHasSensitiveInfo = true, responseHasSensitiveInfo = false)
public class AddClusterCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(AddClusterCmd.class.getName());
@Parameter(name = ApiConstants.CLUSTER_NAME, type = CommandType.STRING, required = true, description = "the cluster name")
@ -226,10 +224,10 @@ public class AddClusterCmd extends BaseCmd {
this.setResponseObject(response);
} catch (DiscoveryException ex) {
s_logger.warn("Exception: ", ex);
logger.warn("Exception: ", ex);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
} catch (ResourceInUseException ex) {
s_logger.warn("Exception: ", ex);
logger.warn("Exception: ", ex);
ServerApiException e = new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
for (String proxyObj : ex.getIdProxyList()) {
e.addProxyObject(proxyObj);

View File

@ -17,7 +17,6 @@
package org.apache.cloudstack.api.command.admin.cluster;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
@ -33,7 +32,6 @@ import com.cloud.user.Account;
@APICommand(name = "deleteCluster", description = "Deletes a cluster.", responseObject = SuccessResponse.class,
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class DeleteClusterCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(DeleteClusterCmd.class.getName());
/////////////////////////////////////////////////////

View File

@ -19,7 +19,6 @@ package org.apache.cloudstack.api.command.admin.cluster;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
@ -36,7 +35,6 @@ import com.cloud.utils.Pair;
@APICommand(name = "listClusters", description = "Lists clusters.", responseObject = ClusterResponse.class,
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class ListClustersCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListClustersCmd.class.getName());
/////////////////////////////////////////////////////

View File

@ -17,7 +17,6 @@
package org.apache.cloudstack.api.command.admin.cluster;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
@ -34,7 +33,6 @@ import com.cloud.user.Account;
@APICommand(name = "updateCluster", description = "Updates an existing cluster", responseObject = ClusterResponse.class,
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class UpdateClusterCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(AddClusterCmd.class.getName());
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = ClusterResponse.class, required = true, description = "the ID of the Cluster")

View File

@ -27,14 +27,12 @@ import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.response.ConfigurationGroupResponse;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.config.ConfigurationGroup;
import org.apache.log4j.Logger;
import com.cloud.utils.Pair;
@APICommand(name = ListCfgGroupsByCmd.APINAME, description = "Lists all configuration groups (primarily used for UI).", responseObject = ConfigurationGroupResponse.class,
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, since = "4.18.0")
public class ListCfgGroupsByCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListCfgGroupsByCmd.class.getName());
public static final String APINAME = "listConfigurationGroups";

View File

@ -23,7 +23,6 @@ import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
@ -47,7 +46,6 @@ import com.cloud.utils.exception.CloudRuntimeException;
public class ListCfgsByCmd extends BaseListCmd {
public static final String APINAME = "listConfigurations";
public static final Logger s_logger = Logger.getLogger(ListCfgsByCmd.class.getName());
// ///////////////////////////////////////////////////

View File

@ -19,7 +19,6 @@ package org.apache.cloudstack.api.command.admin.config;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.BaseListCmd;
@ -29,7 +28,6 @@ import org.apache.cloudstack.api.response.ListResponse;
@APICommand(name = "listDeploymentPlanners", description = "Lists all DeploymentPlanners available.", responseObject = DeploymentPlannersResponse.class,
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class ListDeploymentPlannersCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListDeploymentPlannersCmd.class.getName());
/////////////////////////////////////////////////////

View File

@ -19,7 +19,6 @@ package org.apache.cloudstack.api.command.admin.config;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
@ -39,7 +38,6 @@ import com.cloud.utils.Pair;
requestHasSensitiveInfo = false,
responseHasSensitiveInfo = false)
public class ListHypervisorCapabilitiesCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListHypervisorCapabilitiesCmd.class.getName());
/////////////////////////////////////////////////////

Some files were not shown because too many files have changed in this diff Show More