You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by wi...@apache.org on 2015/03/04 11:05:45 UTC

[01/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Repository: cloudstack
Updated Branches:
  refs/heads/reporter b26f3fcb0 -> 178a938ca (forced update)


packaging for fedora 21

Signed-off-by: Laszlo Hornyak <la...@gmail.com>


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

Branch: refs/heads/reporter
Commit: a9912a00b8f803f04c11821aa4d7a309b40fc079
Parents: 7319f25
Author: Laszlo Hornyak <la...@gmail.com>
Authored: Sat Feb 21 22:44:40 2015 +0100
Committer: Laszlo Hornyak <la...@gmail.com>
Committed: Sat Feb 21 22:44:40 2015 +0100

----------------------------------------------------------------------
 packaging/fedora21/cloud-agent.rc             | 117 ++++
 packaging/fedora21/cloud-ipallocator.rc       |  96 +++
 packaging/fedora21/cloud-management.rc        | 115 ++++
 packaging/fedora21/cloud-management.sysconfig |  23 +
 packaging/fedora21/cloud-usage.rc             | 156 +++++
 packaging/fedora21/cloud.spec                 | 706 +++++++++++++++++++++
 packaging/fedora21/cloudstack-agent.te        |  33 +
 packaging/fedora21/cloudstack-sccs            |  20 +
 packaging/fedora21/replace.properties         |  60 ++
 packaging/fedora21/tomcat.sh                  |  18 +
 10 files changed, 1344 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a9912a00/packaging/fedora21/cloud-agent.rc
----------------------------------------------------------------------
diff --git a/packaging/fedora21/cloud-agent.rc b/packaging/fedora21/cloud-agent.rc
new file mode 100755
index 0000000..6cc6abc
--- /dev/null
+++ b/packaging/fedora21/cloud-agent.rc
@@ -0,0 +1,117 @@
+#!/bin/bash
+
+# chkconfig: 35 99 10
+# description: Cloud Agent
+
+# 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.
+
+# WARNING: if this script is changed, then all other initscripts MUST BE changed to match it as well
+
+. /etc/rc.d/init.d/functions
+
+# set environment variables
+
+SHORTNAME=$(basename $0 | sed -e 's/^[SK][0-9][0-9]//')
+PIDFILE=/var/run/"$SHORTNAME".pid
+LOCKFILE=/var/lock/subsys/"$SHORTNAME"
+LOGDIR=/var/log/cloudstack/agent
+LOGFILE=${LOGDIR}/agent.log
+PROGNAME="Cloud Agent"
+CLASS="com.cloud.agent.AgentShell"
+JSVC=`which jsvc 2>/dev/null`;
+
+# exit if we don't find jsvc
+if [ -z "$JSVC" ]; then
+    echo no jsvc found in path;
+    exit 1;
+fi
+
+unset OPTIONS
+[ -r /etc/sysconfig/"$SHORTNAME" ] && source /etc/sysconfig/"$SHORTNAME"
+
+# The first existing directory is used for JAVA_HOME (if JAVA_HOME is not defined in $DEFAULT)
+JDK_DIRS="/usr/lib/jvm/jre /usr/lib/jvm/java-7-openjdk /usr/lib/jvm/java-7-openjdk-i386 /usr/lib/jvm/java-7-openjdk-amd64 /usr/lib/jvm/java-6-openjdk /usr/lib/jvm/java-6-openjdk-i386 /usr/lib/jvm/java-6-openjdk-amd64 /usr/lib/jvm/java-6-sun"
+
+for jdir in $JDK_DIRS; do
+    if [ -r "$jdir/bin/java" -a -z "${JAVA_HOME}" ]; then
+        JAVA_HOME="$jdir"
+    fi
+done
+export JAVA_HOME
+
+ACP=`ls /usr/share/cloudstack-agent/lib/*.jar | tr '\n' ':' | sed s'/.$//'`
+PCP=`ls /usr/share/cloudstack-agent/plugins/*.jar 2>/dev/null | tr '\n' ':' | sed s'/.$//'`
+
+# We need to append the JSVC daemon JAR to the classpath
+# AgentShell implements the JSVC daemon methods
+export CLASSPATH="/usr/share/java/commons-daemon.jar:$ACP:$PCP:/etc/cloudstack/agent:/usr/share/cloudstack-common/scripts"
+
+start() {
+    echo -n $"Starting $PROGNAME: "
+    if hostname --fqdn >/dev/null 2>&1 ; then
+        $JSVC -Xms256m -Xmx2048m -cp "$CLASSPATH" -pidfile "$PIDFILE" \
+            -errfile $LOGDIR/cloudstack-agent.err -outfile $LOGDIR/cloudstack-agent.out $CLASS
+        RETVAL=$?
+        echo
+    else
+        failure
+        echo
+        echo The host name does not resolve properly to an IP address.  Cannot start "$PROGNAME". > /dev/stderr
+        RETVAL=9
+    fi
+    [ $RETVAL = 0 ] && touch ${LOCKFILE}
+    return $RETVAL
+}
+
+stop() {
+    echo -n $"Stopping $PROGNAME: "
+    $JSVC -pidfile "$PIDFILE" -stop $CLASS
+    RETVAL=$?
+    echo
+    [ $RETVAL = 0 ] && rm -f ${LOCKFILE} ${PIDFILE}
+}
+
+case "$1" in
+    start)
+        start
+        ;;
+    stop)
+        stop
+        ;;
+    status)
+        status -p ${PIDFILE} $SHORTNAME
+        RETVAL=$?
+        ;;
+    restart)
+        stop
+        sleep 3
+        start
+        ;;
+    condrestart)
+        if status -p ${PIDFILE} $SHORTNAME >&/dev/null; then
+            stop
+            sleep 3
+            start
+        fi
+        ;;
+    *)
+    echo $"Usage: $SHORTNAME {start|stop|restart|condrestart|status|help}"
+    RETVAL=3
+esac
+
+exit $RETVAL

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a9912a00/packaging/fedora21/cloud-ipallocator.rc
----------------------------------------------------------------------
diff --git a/packaging/fedora21/cloud-ipallocator.rc b/packaging/fedora21/cloud-ipallocator.rc
new file mode 100755
index 0000000..d26287d
--- /dev/null
+++ b/packaging/fedora21/cloud-ipallocator.rc
@@ -0,0 +1,96 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# chkconfig: 35 99 10
+# description: Cloud Agent
+
+# WARNING: if this script is changed, then all other initscripts MUST BE changed to match it as well
+
+. /etc/rc.d/init.d/functions
+
+# set environment variables
+
+SHORTNAME=`basename $0`
+PIDFILE=/var/run/"$SHORTNAME".pid
+LOCKFILE=/var/lock/subsys/"$SHORTNAME"
+LOGFILE=/var/log/cloudstack/ipallocator/ipallocator.log
+PROGNAME="External IPAllocator"
+
+unset OPTIONS
+[ -r /etc/sysconfig/"$SHORTNAME" ] && source /etc/sysconfig/"$SHORTNAME"
+DAEMONIZE=/usr/bin/cloud-daemonize
+PROG=/usr/bin/cloud-external-ipallocator.py
+OPTIONS=8083
+
+start() {
+        echo -n $"Starting $PROGNAME: "
+	if hostname --fqdn >/dev/null 2>&1 ; then
+		daemon --check=$SHORTNAME --pidfile=${PIDFILE} "$DAEMONIZE" \
+			-n "$SHORTNAME" -p "$PIDFILE" -l "$LOGFILE" "$PROG" $OPTIONS
+		RETVAL=$?
+		echo
+	else
+		failure
+		echo
+		echo The host name does not resolve properly to an IP address.  Cannot start "$PROGNAME". > /dev/stderr
+		RETVAL=9
+	fi
+	[ $RETVAL = 0 ] && touch ${LOCKFILE}
+	return $RETVAL
+}
+
+stop() {
+	echo -n $"Stopping $PROGNAME: "
+	killproc -p ${PIDFILE} $SHORTNAME # -d 10 $SHORTNAME
+	RETVAL=$?
+	echo
+	[ $RETVAL = 0 ] && rm -f ${LOCKFILE} ${PIDFILE}
+}
+
+
+# See how we were called.
+case "$1" in
+  start)
+	start
+	;;
+  stop)
+	stop
+	;;
+  status)
+        status -p ${PIDFILE} $SHORTNAME
+	RETVAL=$?
+	;;
+  restart)
+	stop
+	sleep 3
+	start
+	;;
+  condrestart)
+	if status -p ${PIDFILE} $SHORTNAME >&/dev/null; then
+		stop
+		sleep 3
+		start
+	fi
+	;;
+  *)
+	echo $"Usage: $SHORTNAME {start|stop|restart|condrestart|status|help}"
+	RETVAL=3
+esac
+
+exit $RETVAL
+

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a9912a00/packaging/fedora21/cloud-management.rc
----------------------------------------------------------------------
diff --git a/packaging/fedora21/cloud-management.rc b/packaging/fedora21/cloud-management.rc
new file mode 100755
index 0000000..6d28748
--- /dev/null
+++ b/packaging/fedora21/cloud-management.rc
@@ -0,0 +1,115 @@
+#!/bin/bash
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# cloudstack-management      This shell script takes care of starting and stopping Tomcat
+#
+# chkconfig: - 80 20
+#
+### BEGIN INIT INFO
+# Provides: tomcat6
+# Required-Start: $network $syslog
+# Required-Stop: $network $syslog
+# Default-Start:
+# Default-Stop:
+# Description: Release implementation for Servlet 2.5 and JSP 2.1
+# Short-Description: start and stop tomcat
+### END INIT INFO
+#
+# - originally written by Henri Gomez, Keith Irwin, and Nicolas Mailhot
+# - heavily rewritten by Deepak Bhole and Jason Corley
+#
+
+if [ -r /etc/rc.d/init.d/functions ]; then
+    . /etc/rc.d/init.d/functions
+fi
+if [ -r /lib/lsb/init-functions ]; then
+    . /lib/lsb/init-functions
+fi
+
+
+NAME="$(basename $0)"
+export SERVICE_NAME="$NAME"
+stop() {
+	SHUTDOWN_WAIT="30"
+	count="0"
+	if [ -f /var/run/${NAME}.pid ]; then
+		pid=`cat /var/run/${NAME}.pid`
+		kill $pid &>/dev/null
+		until [ "$(ps --pid $pid | grep -c $pid)" -eq "0" ] || \
+			[ "$count" -gt "$SHUTDOWN_WAIT" ]
+		do
+			sleep 1
+			let count="${count}+1"
+		done
+		if [ "$(ps --pid $pid | grep -c $pid)" -eq "0" ]; then
+			log_success_msg "Stopping ${NAME}:"
+			rm -f /var/run/${NAME}.pid
+			rm -f /var/lock/subsys/${NAME}
+		else
+			log_failure_msg "Stopping ${NAME}:"
+		fi
+	else
+		echo "Cannot find PID file of ${NAME}"
+		log_failure_msg "Stopping ${NAME}:"
+	fi
+}
+
+set_ulimit() {
+    fd_limit=`ulimit -n`
+    if [ "$fd_limit" != "4096" ]; then
+        user=`whoami`
+        if [ $user == "root" ]; then
+            ulimit -n 4096
+        fi
+    fi
+}
+
+handle_pid_file() {
+     if [ "$1" -ne 0 ] && [ "$1" -ne 3 ]; then
+        echo "The pid file locates at /var/run/${NAME}.pid and lock file at /var/lock/subsys/${NAME}.
+        Starting ${NAME} will take care of them or you can manually clean up."
+    fi
+}
+
+start() {
+    readpath=$(readlink -f $0)
+    source `dirname $readpath`/tomcat.sh
+}
+
+# See how we were called.
+case "$1" in
+    status)
+		status ${NAME}
+		RETVAL=$?
+        handle_pid_file $RETVAL
+		;;
+    stop)
+		stop
+		;;
+    restart)
+		stop
+		set start
+        set_ulimit
+	        start
+		;;
+	*)
+        set_ulimit
+                start
+esac
+
+exit $RETVAL

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a9912a00/packaging/fedora21/cloud-management.sysconfig
----------------------------------------------------------------------
diff --git a/packaging/fedora21/cloud-management.sysconfig b/packaging/fedora21/cloud-management.sysconfig
new file mode 100644
index 0000000..cbc8b8b
--- /dev/null
+++ b/packaging/fedora21/cloud-management.sysconfig
@@ -0,0 +1,23 @@
+# 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.
+
+# This file is loaded in /etc/init.d/vmopsmanagement
+# ATM we only do two things here:
+
+dummy=1 ; export TOMCAT_CFG=/etc/cloudstack/management/tomcat6.conf ; . /etc/cloudstack/management/tomcat6.conf
+#--------------------------
+

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a9912a00/packaging/fedora21/cloud-usage.rc
----------------------------------------------------------------------
diff --git a/packaging/fedora21/cloud-usage.rc b/packaging/fedora21/cloud-usage.rc
new file mode 100755
index 0000000..7741137
--- /dev/null
+++ b/packaging/fedora21/cloud-usage.rc
@@ -0,0 +1,156 @@
+#!/bin/bash
+
+### BEGIN INIT INFO
+# Provides:          cloudstack-usage
+# Required-Start:    $network $local_fs
+# Required-Stop:     $network $local_fs
+# Default-Start:     3 4 5
+# Default-Stop:      0 1 2 6
+# Short-Description: Start/stop Apache CloudStack Usage Monitor
+# Description: This scripts Starts/Stops the Apache CloudStack Usage Monitor
+##  The CloudStack Usage Monitor is a part of the Apache CloudStack project and is used
+##  for storing usage statistics from instances.
+## JSVC (Java daemonizing) is used for starting and stopping the usage monitor.
+### END INIT INFO
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+. /etc/rc.d/init.d/functions
+
+SHORTNAME="cloudstack-usage"
+PIDFILE=/var/run/"$SHORTNAME".pid
+LOCKFILE=/var/lock/subsys/"$SHORTNAME"
+LOGDIR=/var/log/cloudstack/usage
+LOGFILE=${LOGDIR}/usage.log
+PROGNAME="CloudStack Usage Monitor"
+CLASS="com.cloud.usage.UsageServer"
+PROG="jsvc"
+DAEMON="/usr/bin/jsvc"
+USER=cloud
+
+unset OPTIONS
+[ -r /etc/sysconfig/default/"$SHORTNAME" ] && source /etc/sysconfig/default/"$SHORTNAME"
+
+setJavaHome() {
+  # use $JAVA_HOME if defined
+  if [ -n "$JAVA_HOME" ] ; then
+    return
+  fi
+
+  # try java first
+  java=$(which java 2>/dev/null || :)
+
+  # try javac if java is not found
+  if [ -z "$java" ] ; then
+    java=$(which javac 2>/dev/null || :)
+  fi
+
+  if [ -n "$java" ] ; then
+    JAVA_HOME=$(dirname $(dirname $(readlink -e $java)))
+    export JAVA_HOME
+    return
+  fi
+
+  # didnt find java home. exiting with error
+  exit 1
+}
+
+setJavaHome
+
+SCP=""
+DCP=""
+UCP=`ls /usr/share/cloudstack-usage/cloud-usage-*.jar`":"`ls /usr/share/cloudstack-usage/lib/*.jar | tr '\n' ':'`
+JCP="/usr/share/java/commons-daemon.jar":"/usr/share/java/mysql-connector-java.jar"
+
+# We need to append the JSVC daemon  and mysql-connector JAR to the classpath
+# AgentShell implements the JSVC daemon methods
+export CLASSPATH="$SCP:$DCP:$UCP:$JCP:/etc/cloudstack/usage"
+
+start() {
+    if [ -s "$PIDFILE" ] && kill -0 $(cat "$PIDFILE") >/dev/null 2>&1; then
+        echo "$PROGNAME apparently already running"
+        exit 0
+    fi
+
+    if hostname --fqdn >/dev/null 2>&1 ; then
+        true
+    else
+        echo "The host name does not resolve properly to an IP address. Cannot start $PROGNAME"
+        exit 1
+    fi
+
+    echo -n "Starting $PROGNAME" "$SHORTNAME"
+
+    if daemon --pidfile $PIDFILE $DAEMON -home "$JAVA_HOME" -cp "$CLASSPATH" -pidfile "$PIDFILE" -user "$USER" \
+      -errfile $LOGDIR/cloudstack-usage.err -outfile $LOGDIR/cloudstack-usage.out -Dpid=$$ $CLASS
+        RETVAL=$?
+    then
+        rc=0
+        sleep 1
+        if ! kill -0 $(cat "$PIDFILE") >/dev/null 2>&1; then
+            failure
+            rc=1
+        fi
+    else
+        rc=1
+    fi
+
+    if [ $rc -eq 0 ]; then
+        success
+    else
+        failure
+        rm -f "$PIDFILE"
+    fi
+    echo
+}
+
+stop() {
+    echo -n "Stopping $PROGNAME" "$SHORTNAME"
+    killproc -p $PIDFILE $DAEMON
+    if [ "$?" -eq 0 ]; then
+        success
+    else
+        failure
+    fi
+    rm -f "$PIDFILE"
+    echo
+}
+
+case "$1" in
+    start)
+        start
+        ;;
+    stop)
+        stop
+        ;;
+    status)
+        status -p $PIDFILE $SHORTNAME
+        RETVAL=$?
+        ;;
+    restart | force-reload)
+        stop
+        sleep 3
+        start
+        ;;
+    *)
+    echo "Usage: $0 {start|stop|restart|force-reload|status}"
+    RETVAL=3
+esac
+
+exit $RETVAL
+

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a9912a00/packaging/fedora21/cloud.spec
----------------------------------------------------------------------
diff --git a/packaging/fedora21/cloud.spec b/packaging/fedora21/cloud.spec
new file mode 100644
index 0000000..2338b3c
--- /dev/null
+++ b/packaging/fedora21/cloud.spec
@@ -0,0 +1,706 @@
+# 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.
+
+%define __os_install_post %{nil}
+%global debug_package %{nil}
+
+# DISABLE the post-percentinstall java repacking and line number stripping
+# we need to find a way to just disable the java repacking and line number stripping, but not the autodeps
+
+Name:      cloudstack
+Summary:   CloudStack IaaS Platform
+#http://fedoraproject.org/wiki/PackageNamingGuidelines#Pre-Release_packages
+%if "%{?_prerelease}" != ""
+%define _maventag %{_ver}-SNAPSHOT
+Release:   %{_rel}%{dist}
+%else
+%define _maventag %{_ver}
+Release:   %{_rel}%{dist}
+%endif
+
+%{!?python_sitearch: %define python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
+
+Version:   %{_ver}
+License:   ASL 2.0
+Vendor:    Apache CloudStack <de...@cloudstack.apache.org>
+Packager:  Apache CloudStack <de...@cloudstack.apache.org>
+Group:     System Environment/Libraries
+# FIXME do groups for every single one of the subpackages
+Source0:   %{name}-%{_maventag}.tgz
+BuildRoot: %{_tmppath}/%{name}-%{_maventag}-%{release}-build
+
+BuildRequires: java-1.8.0-openjdk-devel
+BuildRequires: tomcat
+BuildRequires: ws-commons-util
+BuildRequires: jpackage-utils
+BuildRequires: gcc
+BuildRequires: glibc-devel
+BuildRequires: /usr/bin/mkisofs
+BuildRequires: MySQL-python
+#BuildRequires: maven => 3.0.0
+
+%description
+CloudStack is a highly-scalable elastic, open source,
+intelligent IaaS cloud implementation.
+
+%package management
+Summary:   CloudStack management server UI
+Requires: tomcat
+Requires: java-1.8.0-openjdk
+Requires: python
+Requires: bash
+Requires: bzip2
+Requires: gzip
+Requires: unzip
+Requires: /sbin/mount.nfs
+Requires: openssh-clients
+Requires: nfs-utils
+Requires: wget
+Requires: mysql
+Requires: mysql-connector-java
+Requires: ws-commons-util
+Requires: jpackage-utils
+Requires: sudo
+Requires: /sbin/service
+Requires: /sbin/chkconfig
+Requires: /usr/bin/ssh-keygen
+Requires: mkisofs
+Requires: MySQL-python
+Requires: python-paramiko
+Requires: ipmitool
+Requires: %{name}-common = %{_ver}
+Requires: %{name}-awsapi = %{_ver}
+Obsoletes: cloud-client < 4.1.0
+Obsoletes: cloud-client-ui < 4.1.0
+Obsoletes: cloud-server < 4.1.0
+Obsoletes: cloud-test < 4.1.0
+Provides:  cloud-client
+Group:     System Environment/Libraries
+%description management
+The CloudStack management server is the central point of coordination,
+management, and intelligence in CloudStack.  
+
+%package common
+Summary: Apache CloudStack common files and scripts
+Requires: python
+Obsoletes: cloud-test < 4.1.0 
+Obsoletes: cloud-scripts < 4.1.0
+Obsoletes: cloud-utils < 4.1.0
+Obsoletes: cloud-core < 4.1.0
+Obsoletes: cloud-deps < 4.1.0
+Obsoletes: cloud-python < 4.1.0
+Obsoletes: cloud-setup < 4.1.0
+Obsoletes: cloud-cli < 4.1.0
+Obsoletes: cloud-daemonize < 4.1.0
+Group:   System Environment/Libraries
+%description common
+The Apache CloudStack files shared between agent and management server
+
+%package agent
+Summary: CloudStack Agent for KVM hypervisors
+Requires: openssh-clients
+Requires: java-1.8.0-openjdk
+Requires: %{name}-common = %{_ver}
+Requires: libvirt
+Requires: bridge-utils
+Requires: ebtables
+Requires: iptables
+Requires: ethtool
+Requires: vconfig
+Requires: ipset
+Requires: jsvc
+Requires: jakarta-commons-daemon
+Requires: jakarta-commons-daemon-jsvc
+Requires: perl
+Requires: libvirt-python
+Requires: qemu-img
+Requires: qemu-kvm
+Requires: libcgroup-tools
+Requires: net-tools
+Provides: cloud-agent
+Obsoletes: cloud-agent < 4.1.0
+Obsoletes: cloud-agent-libs < 4.1.0
+Obsoletes: cloud-test < 4.1.0
+Group: System Environment/Libraries
+%description agent
+The CloudStack agent for KVM hypervisors
+
+%package baremetal-agent
+Summary: CloudStack baremetal agent
+Requires: tftp-server
+Requires: xinetd
+Requires: syslinux
+Requires: chkconfig
+Requires: dhcp
+Requires: httpd
+Group:     System Environment/Libraries
+%description baremetal-agent
+The CloudStack baremetal agent
+
+%package usage
+Summary: CloudStack Usage calculation server
+Requires: java-1.8.0-openjdk
+Requires: jsvc
+Requires: jakarta-commons-daemon
+Requires: jakarta-commons-daemon-jsvc
+Group: System Environment/Libraries
+Obsoletes: cloud-usage < 4.1.0
+Provides: cloud-usage 
+%description usage
+The CloudStack usage calculation service
+
+%package cli
+Summary: Apache CloudStack CLI
+Provides: python-cloudmonkey
+Provides: python-marvin
+Group: System Environment/Libraries
+%description cli
+Apache CloudStack command line interface
+
+%package awsapi
+Summary: Apache CloudStack AWS API compatibility wrapper
+Requires: %{name}-management = %{_ver}
+Obsoletes: cloud-aws-api < 4.1.0
+Provides: cloud-aws-api
+Group: System Environment/Libraries
+%description awsapi
+Apache Cloudstack AWS API compatibility wrapper
+
+%if "%{_ossnoss}" == "noredist"
+%package mysql-ha
+Summary: Apache CloudStack Balancing Strategy for MySQL
+Requires: mysql-connector-java
+Requires: tomcat
+Group: System Environmnet/Libraries
+%description mysql-ha
+Apache CloudStack Balancing Strategy for MySQL
+
+%endif
+
+%prep
+echo Doing CloudStack build
+
+%setup -q -n %{name}-%{_maventag}
+
+%build
+
+cp packaging/centos63/replace.properties build/replace.properties
+echo VERSION=%{_maventag} >> build/replace.properties
+echo PACKAGE=%{name} >> build/replace.properties
+touch build/gitrev.txt
+echo $(git rev-parse HEAD) > build/gitrev.txt
+
+if [ "%{_ossnoss}" == "NOREDIST" -o "%{_ossnoss}" == "noredist" ] ; then
+   echo "Executing mvn packaging with non-redistributable libraries"
+   if [ "%{_sim}" == "SIMULATOR" -o "%{_sim}" == "simulator" ] ; then 
+      echo "Executing mvn noredist packaging with simulator ..."
+      mvn -Pawsapi,systemvm -Dnoredist -Dsimulator clean package 
+   else
+      echo "Executing mvn noredist packaging without simulator..."
+      mvn -Pawsapi,systemvm -Dnoredist clean package
+   fi
+else
+   if [ "%{_sim}" == "SIMULATOR" -o "%{_sim}" == "simulator" ] ; then 
+      echo "Executing mvn default packaging simulator ..."
+      mvn -Pawsapi,systemvm -Dsimulator clean package 
+   else
+      echo "Executing mvn default packaging without simulator ..."
+      mvn -Pawsapi,systemvm clean package
+   fi
+fi 
+
+%install
+[ ${RPM_BUILD_ROOT} != "/" ] && rm -rf ${RPM_BUILD_ROOT}
+# Common directories
+mkdir -p ${RPM_BUILD_ROOT}%{_bindir}
+mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}/agent
+mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}/awsapi
+mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}/ipallocator
+mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/cache/%{name}/management/work
+mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/cache/%{name}/management/temp
+mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/%{name}/mnt
+mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/%{name}/management
+mkdir -p ${RPM_BUILD_ROOT}%{_initrddir}
+mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig
+
+# Common
+mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/%{name}-common/scripts
+mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/%{name}-common/vms
+mkdir -p ${RPM_BUILD_ROOT}%{python_sitearch}/
+mkdir -p ${RPM_BUILD_ROOT}%/usr/bin
+cp -r scripts/* ${RPM_BUILD_ROOT}%{_datadir}/%{name}-common/scripts
+install -D systemvm/dist/systemvm.iso ${RPM_BUILD_ROOT}%{_datadir}/%{name}-common/vms/systemvm.iso
+install -D systemvm/dist/systemvm.zip ${RPM_BUILD_ROOT}%{_datadir}/%{name}-common/vms/systemvm.zip
+install python/lib/cloud_utils.py ${RPM_BUILD_ROOT}%{python_sitearch}/cloud_utils.py
+cp -r python/lib/cloudutils ${RPM_BUILD_ROOT}%{python_sitearch}/
+python -m py_compile ${RPM_BUILD_ROOT}%{python_sitearch}/cloud_utils.py
+python -m compileall ${RPM_BUILD_ROOT}%{python_sitearch}/cloudutils
+cp build/gitrev.txt ${RPM_BUILD_ROOT}%{_datadir}/%{name}-common/scripts
+cp packaging/centos63/cloudstack-sccs ${RPM_BUILD_ROOT}/usr/bin
+ 
+mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/%{name}-common/scripts/network/cisco
+cp -r plugins/network-elements/cisco-vnmc/scripts/network/cisco/* ${RPM_BUILD_ROOT}%{_datadir}/%{name}-common/scripts/network/cisco
+
+# Management
+mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/
+mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/webapps/client
+mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/setup
+mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}/management
+mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}/awsapi
+mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/management
+
+# Specific for tomcat
+mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/management/Catalina/localhost/client
+ln -sf /usr/share/tomcat/bin ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/bin
+ln -sf /etc/%{name}/management ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/conf
+ln -sf /usr/share/tomcat/lib ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/lib
+ln -sf /var/log/%{name}/management ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/logs
+ln -sf /var/cache/%{name}/management/temp ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/temp
+ln -sf /var/cache/%{name}/management/work ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/work
+
+/bin/touch ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}/management/catalina.out
+
+install -D client/target/utilities/bin/cloud-migrate-databases ${RPM_BUILD_ROOT}%{_bindir}/%{name}-migrate-databases
+install -D client/target/utilities/bin/cloud-set-guest-password ${RPM_BUILD_ROOT}%{_bindir}/%{name}-set-guest-password
+install -D client/target/utilities/bin/cloud-set-guest-sshkey ${RPM_BUILD_ROOT}%{_bindir}/%{name}-set-guest-sshkey
+install -D client/target/utilities/bin/cloud-setup-databases ${RPM_BUILD_ROOT}%{_bindir}/%{name}-setup-databases
+install -D client/target/utilities/bin/cloud-setup-encryption ${RPM_BUILD_ROOT}%{_bindir}/%{name}-setup-encryption
+install -D client/target/utilities/bin/cloud-setup-management ${RPM_BUILD_ROOT}%{_bindir}/%{name}-setup-management
+install -D client/target/utilities/bin/cloud-setup-baremetal ${RPM_BUILD_ROOT}%{_bindir}/%{name}-setup-baremetal
+install -D client/target/utilities/bin/cloud-sysvmadm ${RPM_BUILD_ROOT}%{_bindir}/%{name}-sysvmadm
+install -D client/target/utilities/bin/cloud-update-xenserver-licenses ${RPM_BUILD_ROOT}%{_bindir}/%{name}-update-xenserver-licenses
+
+cp -r client/target/utilities/scripts/db/* ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/setup
+cp -r client/target/cloud-client-ui-%{_maventag}/* ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/webapps/client
+
+# Don't package the scripts in the management webapp
+rm -rf ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/webapps/client/WEB-INF/classes/scripts
+rm -rf ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/webapps/client/WEB-INF/classes/vms
+
+for name in db.properties log4j-cloud.xml tomcat6-nonssl.conf tomcat6-ssl.conf server-ssl.xml server-nonssl.xml \
+            catalina.policy catalina.properties classpath.conf tomcat-users.xml web.xml environment.properties ; do
+  mv ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/webapps/client/WEB-INF/classes/$name \
+    ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/management/$name
+done
+
+ln -s %{_sysconfdir}/%{name}/management/log4j-cloud.xml \
+    ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/webapps/client/WEB-INF/classes/log4j-cloud.xml
+
+mv ${RPM_BUILD_ROOT}%{_datadir}/%{name}-management/webapps/client/WEB-INF/classes/context.xml \
+    ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/management/Catalina/localhost/client
+
+install python/bindir/cloud-external-ipallocator.py ${RPM_BUILD_ROOT}%{_bindir}/%{name}-external-ipallocator.py
+install -D client/target/pythonlibs/jasypt-1.9.2.jar ${RPM_BUILD_ROOT}%{_datadir}/%{name}-common/lib/jasypt-1.9.2.jar
+
+install -D packaging/centos63/cloud-ipallocator.rc ${RPM_BUILD_ROOT}%{_initrddir}/%{name}-ipallocator
+install -D packaging/centos63/cloud-management.rc ${RPM_BUILD_ROOT}%{_initrddir}/%{name}-management
+install -D packaging/centos63/cloud-management.sysconfig ${RPM_BUILD_ROOT}%{_sysconfdir}/sysconfig/%{name}-management
+install -D packaging/centos63/tomcat.sh ${RPM_BUILD_ROOT}%{_initrddir}/tomcat.sh
+
+chmod 770 ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/management/Catalina
+chmod 770 ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/management/Catalina/localhost
+chmod 770 ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/management/Catalina/localhost/client
+chmod 770 ${RPM_BUILD_ROOT}%{_localstatedir}/%{name}/mnt
+chmod 770 ${RPM_BUILD_ROOT}%{_localstatedir}/%{name}/management
+chmod 770 ${RPM_BUILD_ROOT}%{_localstatedir}/cache/%{name}/management/work
+chmod 770 ${RPM_BUILD_ROOT}%{_localstatedir}/cache/%{name}/management/temp
+chmod 770 ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}/management
+chmod 770 ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}/agent
+
+# KVM Agent
+mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/agent
+mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}/agent
+mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/%{name}-agent/lib
+mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/%{name}-agent/plugins
+install -D packaging/centos63/cloud-agent.rc ${RPM_BUILD_ROOT}%{_sysconfdir}/init.d/%{name}-agent
+install -D agent/target/transformed/agent.properties ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/agent/agent.properties
+install -D agent/target/transformed/environment.properties ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/agent/environment.properties
+install -D agent/target/transformed/log4j-cloud.xml ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/agent/log4j-cloud.xml
+install -D agent/target/transformed/cloud-setup-agent ${RPM_BUILD_ROOT}%{_bindir}/%{name}-setup-agent
+install -D agent/target/transformed/cloudstack-agent-upgrade ${RPM_BUILD_ROOT}%{_bindir}/%{name}-agent-upgrade
+install -D agent/target/transformed/libvirtqemuhook ${RPM_BUILD_ROOT}%{_datadir}/%{name}-agent/lib/libvirtqemuhook
+install -D agent/target/transformed/cloud-ssh ${RPM_BUILD_ROOT}%{_bindir}/%{name}-ssh
+install -D plugins/hypervisors/kvm/target/cloud-plugin-hypervisor-kvm-%{_maventag}.jar ${RPM_BUILD_ROOT}%{_datadir}/%name-agent/lib/cloud-plugin-hypervisor-kvm-%{_maventag}.jar
+cp plugins/hypervisors/kvm/target/dependencies/*  ${RPM_BUILD_ROOT}%{_datadir}/%{name}-agent/lib
+
+# Usage server
+mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/usage
+mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/%{name}-usage/lib
+install -D usage/target/cloud-usage-%{_maventag}.jar ${RPM_BUILD_ROOT}%{_datadir}/%{name}-usage/cloud-usage-%{_maventag}.jar
+install -D usage/target/transformed/db.properties ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/usage/db.properties
+install -D usage/target/transformed/log4j-cloud_usage.xml ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/usage/log4j-cloud.xml
+cp usage/target/dependencies/* ${RPM_BUILD_ROOT}%{_datadir}/%{name}-usage/lib/
+install -D packaging/centos63/cloud-usage.rc ${RPM_BUILD_ROOT}/%{_sysconfdir}/init.d/%{name}-usage
+mkdir -p ${RPM_BUILD_ROOT}%{_localstatedir}/log/%{name}/usage/
+
+# CLI
+cp -r cloud-cli/cloudtool ${RPM_BUILD_ROOT}%{python_sitearch}/
+install cloud-cli/cloudapis/cloud.py ${RPM_BUILD_ROOT}%{python_sitearch}/cloudapis.py
+
+# AWS API
+mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/%{name}-bridge/webapps/awsapi
+mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/%{name}-bridge/setup
+cp -r awsapi/target/cloud-awsapi-%{_maventag}/* ${RPM_BUILD_ROOT}%{_datadir}/%{name}-bridge/webapps/awsapi
+install -D awsapi-setup/setup/cloud-setup-bridge ${RPM_BUILD_ROOT}%{_bindir}/cloudstack-setup-bridge
+install -D awsapi-setup/setup/cloudstack-aws-api-register ${RPM_BUILD_ROOT}%{_bindir}/cloudstack-aws-api-register
+cp -r awsapi-setup/db/mysql/* ${RPM_BUILD_ROOT}%{_datadir}/%{name}-bridge/setup
+cp awsapi/resource/Axis2/axis2.xml ${RPM_BUILD_ROOT}%{_datadir}/%{name}-bridge/webapps/awsapi/WEB-INF/conf
+cp awsapi/target/WEB-INF/services/cloud-ec2.aar ${RPM_BUILD_ROOT}%{_datadir}/%{name}-bridge/webapps/awsapi/WEB-INF/services
+
+
+for name in cloud-bridge.properties commons-logging.properties ec2-service.properties ; do
+  mv ${RPM_BUILD_ROOT}%{_datadir}/%{name}-bridge/webapps/awsapi/WEB-INF/classes/$name \
+    ${RPM_BUILD_ROOT}%{_sysconfdir}/%{name}/management/$name
+done
+
+# MYSQL HA
+if [ "x%{_ossnoss}" == "xnoredist" ] ; then
+  mkdir -p ${RPM_BUILD_ROOT}%{_datadir}/%{name}-mysql-ha/lib
+  cp -r plugins/database/mysql-ha/target/cloud-plugin-database-mysqlha-%{_maventag}.jar ${RPM_BUILD_ROOT}%{_datadir}/%{name}-mysql-ha/lib
+fi
+
+#Don't package the below for AWS API
+rm -rf ${RPM_BUILD_ROOT}%{_datadir}/%{name}-bridge/webapps/awsapi/WEB-INF/classes/db.properties
+rm -rf ${RPM_BUILD_ROOT}%{_datadir}/%{name}-bridge/webapps/awsapi/WEB-INF/classes/LICENSE.txt
+rm -rf ${RPM_BUILD_ROOT}%{_datadir}/%{name}-bridge/webapps/awsapi/WEB-INF/classes/log4j.properties
+rm -rf ${RPM_BUILD_ROOT}%{_datadir}/%{name}-bridge/webapps/awsapi/WEB-INF/classes/log4j-vmops.xml
+rm -rf ${RPM_BUILD_ROOT}%{_datadir}/%{name}-bridge/webapps/awsapi/WEB-INF/classes/META-INF
+rm -rf ${RPM_BUILD_ROOT}%{_datadir}/%{name}-bridge/webapps/awsapi/WEB-INF/classes/NOTICE.txt
+rm -rf ${RPM_BUILD_ROOT}%{_datadir}/%{name}-bridge/webapps/awsapi/WEB-INF/classes/services.xml
+
+#License files from whisker
+install -D tools/whisker/NOTICE ${RPM_BUILD_ROOT}%{_defaultdocdir}/%{name}-management-%{version}/NOTICE
+install -D tools/whisker/LICENSE ${RPM_BUILD_ROOT}%{_defaultdocdir}/%{name}-management-%{version}/LICENSE
+install -D tools/whisker/NOTICE ${RPM_BUILD_ROOT}%{_defaultdocdir}/%{name}-common-%{version}/NOTICE
+install -D tools/whisker/LICENSE ${RPM_BUILD_ROOT}%{_defaultdocdir}/%{name}-common-%{version}/LICENSE
+install -D tools/whisker/NOTICE ${RPM_BUILD_ROOT}%{_defaultdocdir}/%{name}-agent-%{version}/NOTICE
+install -D tools/whisker/LICENSE ${RPM_BUILD_ROOT}%{_defaultdocdir}/%{name}-agent-%{version}/LICENSE
+install -D tools/whisker/NOTICE ${RPM_BUILD_ROOT}%{_defaultdocdir}/%{name}-usage-%{version}/NOTICE
+install -D tools/whisker/LICENSE ${RPM_BUILD_ROOT}%{_defaultdocdir}/%{name}-usage-%{version}/LICENSE
+install -D tools/whisker/NOTICE ${RPM_BUILD_ROOT}%{_defaultdocdir}/%{name}-awsapi-%{version}/NOTICE
+install -D tools/whisker/LICENSE ${RPM_BUILD_ROOT}%{_defaultdocdir}/%{name}-awsapi-%{version}/LICENSE
+install -D tools/whisker/NOTICE ${RPM_BUILD_ROOT}%{_defaultdocdir}/%{name}-cli-%{version}/NOTICE
+install -D tools/whisker/LICENSE ${RPM_BUILD_ROOT}%{_defaultdocdir}/%{name}-cli-%{version}/LICENSE
+if [ "x%{_ossnoss}" == "xnoredist" ] ; then
+  install -D tools/whisker/LICENSE ${RPM_BUILD_ROOT}%{_defaultdocdir}/%{name}-mysql-ha-%{version}/LICENSE
+  install -D tools/whisker/NOTICE ${RPM_BUILD_ROOT}%{_defaultdocdir}/%{name}-mysql-ha-%{version}/NOTICE
+fi
+
+%clean
+[ ${RPM_BUILD_ROOT} != "/" ] && rm -rf ${RPM_BUILD_ROOT}
+
+%pre awsapi
+id cloud > /dev/null 2>&1 || /usr/sbin/useradd -M -c "CloudStack unprivileged user" \
+     -r -s /bin/sh -d %{_localstatedir}/cloudstack/management cloud|| true
+
+%preun management
+/sbin/service cloudstack-management stop || true
+if [ "$1" == "0" ] ; then
+    /sbin/chkconfig --del cloudstack-management  > /dev/null 2>&1 || true
+    /sbin/service cloudstack-management stop > /dev/null 2>&1 || true
+fi
+
+%pre management
+id cloud > /dev/null 2>&1 || /usr/sbin/useradd -M -c "CloudStack unprivileged user" \
+     -r -s /bin/sh -d %{_localstatedir}/cloudstack/management cloud|| true
+
+# set max file descriptors for cloud user to 4096
+sed -i /"cloud hard nofile"/d /etc/security/limits.conf
+sed -i /"cloud soft nofile"/d /etc/security/limits.conf
+echo "cloud hard nofile 4096" >> /etc/security/limits.conf
+echo "cloud soft nofile 4096" >> /etc/security/limits.conf
+rm -rf %{_localstatedir}/cache/cloud
+rm -rf %{_localstatedir}/cache/cloudstack
+# user harcoded here, also hardcoded on wscript
+
+# save old configs if they exist (for upgrade). Otherwise we may lose them
+# when the old packages are erased. There are a lot of properties files here.
+if [ -d "%{_sysconfdir}/cloud" ] ; then
+    mv %{_sysconfdir}/cloud %{_sysconfdir}/cloud.rpmsave
+fi
+
+%post management
+if [ "$1" == "1" ] ; then
+    /sbin/chkconfig --add cloudstack-management > /dev/null 2>&1 || true
+    /sbin/chkconfig --level 345 cloudstack-management on > /dev/null 2>&1 || true
+fi
+
+if [ -d "%{_datadir}/%{name}-management" ] ; then
+   ln -s %{_datadir}/%{name}-bridge/webapps %{_datadir}/%{name}-management/webapps7080
+fi
+
+if [ ! -f %{_datadir}/cloudstack-common/scripts/vm/hypervisor/xenserver/vhd-util ] ; then
+    echo Please download vhd-util from http://download.cloud.com.s3.amazonaws.com/tools/vhd-util and put it in 
+    echo %{_datadir}/cloudstack-common/scripts/vm/hypervisor/xenserver/
+fi
+
+# change cloud user's home to 4.1+ version if needed. Would do this via 'usermod', but it
+# requires that cloud user not be in use, so RPM could not be installed while management is running
+if getent passwd cloud | grep -q /var/lib/cloud; then 
+    sed -i 's/\/var\/lib\/cloud\/management/\/var\/cloudstack\/management/g' /etc/passwd
+fi
+
+# if saved configs from upgrade exist, copy them over
+if [ -f "%{_sysconfdir}/cloud.rpmsave/management/db.properties" ]; then
+    mv %{_sysconfdir}/%{name}/management/db.properties %{_sysconfdir}/%{name}/management/db.properties.rpmnew
+    cp -p %{_sysconfdir}/cloud.rpmsave/management/db.properties %{_sysconfdir}/%{name}/management
+    if [ -f "%{_sysconfdir}/cloud.rpmsave/management/key" ]; then    
+        cp -p %{_sysconfdir}/cloud.rpmsave/management/key %{_sysconfdir}/%{name}/management
+    fi
+    # make sure we only do this on the first install of this RPM, don't want to overwrite on a reinstall
+    mv %{_sysconfdir}/cloud.rpmsave/management/db.properties %{_sysconfdir}/cloud.rpmsave/management/db.properties.rpmsave
+fi
+
+# Choose server.xml and tomcat.conf links based on old config, if exists
+serverxml=%{_sysconfdir}/%{name}/management/server.xml
+oldserverxml=%{_sysconfdir}/cloud.rpmsave/management/server.xml
+if [ -f $oldserverxml ] || [ -L $oldserverxml ]; then
+    if stat -c %N $oldserverxml| grep -q server-ssl ; then
+        if [ -f $serverxml ] || [ -L $serverxml ]; then rm -f $serverxml; fi
+        ln -s %{_sysconfdir}/%{name}/management/server-ssl.xml $serverxml
+        echo Please verify the server.xml in saved folder, and make the required changes manually , saved folder available at $oldserverxml
+    else
+        if [ -f $serverxml ] || [ -L $serverxml ]; then rm -f $serverxml; fi
+        ln -s %{_sysconfdir}/%{name}/management/server-nonssl.xml $serverxml
+        echo Please verify the server.xml in saved folder, and make the required changes manually , saved folder available at $oldserverxml
+
+    fi
+else
+    echo "Unable to determine ssl settings for server.xml, please run cloudstack-setup-management manually"
+fi
+
+
+tomcatconf=%{_sysconfdir}/%{name}/management/tomcat6.conf
+oldtomcatconf=%{_sysconfdir}/cloud.rpmsave/management/tomcat6.conf
+if [ -f $oldtomcatconf ] || [ -L $oldtomcatconf ] ; then
+    if stat -c %N $oldtomcatconf| grep -q tomcat6-ssl ; then
+        if [ -f $tomcatconf ] || [ -L $tomcatconf ]; then rm -f $tomcatconf; fi
+        ln -s %{_sysconfdir}/%{name}/management/tomcat6-ssl.conf $tomcatconf
+        echo Please verify the tomcat6.conf in saved folder, and make the required changes manually , saved folder available at $oldtomcatconf
+    else
+        if [ -f $tomcatconf ] || [ -L $tomcatconf ]; then rm -f $tomcatconf; fi
+        ln -s %{_sysconfdir}/%{name}/management/tomcat6-nonssl.conf $tomcatconf
+        echo Please verify the tomcat6.conf in saved folder, and make the required changes manually , saved folder available at $oldtomcatconf
+    fi
+else
+    echo "Unable to determine ssl settings for tomcat.conf, please run cloudstack-setup-management manually"
+fi
+
+if [ -f "%{_sysconfdir}/cloud.rpmsave/management/cloud.keystore" ]; then
+    cp -p %{_sysconfdir}/cloud.rpmsave/management/cloud.keystore %{_sysconfdir}/%{name}/management/cloudmanagementserver.keystore
+    # make sure we only do this on the first install of this RPM, don't want to overwrite on a reinstall
+    mv %{_sysconfdir}/cloud.rpmsave/management/cloud.keystore %{_sysconfdir}/cloud.rpmsave/management/cloud.keystore.rpmsave
+fi
+
+%preun agent
+/sbin/service cloudstack-agent stop || true
+if [ "$1" == "0" ] ; then
+    /sbin/chkconfig --del cloudstack-agent > /dev/null 2>&1 || true
+    /sbin/service cloudstack-agent stop > /dev/null 2>&1 || true
+fi
+
+%pre agent
+
+# save old configs if they exist (for upgrade). Otherwise we may lose them
+# when the old packages are erased. There are a lot of properties files here.
+if [ -d "%{_sysconfdir}/cloud" ] ; then
+    mv %{_sysconfdir}/cloud %{_sysconfdir}/cloud.rpmsave
+fi
+
+%post agent
+if [ "$1" == "1" ] ; then
+    echo "Running %{_bindir}/%{name}-agent-upgrade to update bridge name for upgrade from CloudStack 4.0.x (and before) to CloudStack 4.1 (and later)"
+    %{_bindir}/%{name}-agent-upgrade
+    if [ ! -d %{_sysconfdir}/libvirt/hooks ] ; then
+        mkdir %{_sysconfdir}/libvirt/hooks
+    fi
+    cp -a ${RPM_BUILD_ROOT}%{_datadir}/%{name}-agent/lib/libvirtqemuhook %{_sysconfdir}/libvirt/hooks/qemu
+    /sbin/service libvirtd restart
+    /sbin/chkconfig --add cloudstack-agent > /dev/null 2>&1 || true
+    /sbin/chkconfig --level 345 cloudstack-agent on > /dev/null 2>&1 || true
+fi
+
+# if saved configs from upgrade exist, copy them over
+if [ -f "%{_sysconfdir}/cloud.rpmsave/agent/agent.properties" ]; then
+    mv %{_sysconfdir}/%{name}/agent/agent.properties  %{_sysconfdir}/%{name}/agent/agent.properties.rpmnew
+    cp -p %{_sysconfdir}/cloud.rpmsave/agent/agent.properties %{_sysconfdir}/%{name}/agent
+    # make sure we only do this on the first install of this RPM, don't want to overwrite on a reinstall
+    mv %{_sysconfdir}/cloud.rpmsave/agent/agent.properties %{_sysconfdir}/cloud.rpmsave/agent/agent.properties.rpmsave
+fi
+
+%preun usage
+/sbin/service cloudstack-usage stop || true
+if [ "$1" == "0" ] ; then
+    /sbin/chkconfig --del cloudstack-usage > /dev/null 2>&1 || true
+    /sbin/service cloudstack-usage stop > /dev/null 2>&1 || true
+fi
+
+%post usage
+if [ -f "%{_sysconfdir}/%{name}/management/db.properties" ]; then
+    echo Replacing db.properties with management server db.properties
+    rm -f %{_sysconfdir}/%{name}/usage/db.properties
+    ln -s %{_sysconfdir}/%{name}/management/db.properties %{_sysconfdir}/%{name}/usage/db.properties
+    /sbin/chkconfig --add cloudstack-usage > /dev/null 2>&1 || true
+    /sbin/chkconfig --level 345 cloudstack-usage on > /dev/null 2>&1 || true
+fi
+
+if [ -f "%{_sysconfdir}/%{name}/management/key" ]; then
+    echo Replacing key with management server key
+    rm -f %{_sysconfdir}/%{name}/usage/key
+    ln -s %{_sysconfdir}/%{name}/management/key %{_sysconfdir}/%{name}/usage/key
+fi
+
+#%post awsapi
+#if [ -d "%{_datadir}/%{name}-management" ] ; then
+#   ln -s %{_datadir}/%{name}-bridge/webapps %{_datadir}/%{name}-management/webapps7080
+#fi
+
+#No default permission as the permission setup is complex
+%files management
+%defattr(-,root,root,-)
+%dir %attr(0770,root,cloud) %{_sysconfdir}/%{name}/management/Catalina
+%dir %attr(0770,root,cloud) %{_sysconfdir}/%{name}/management/Catalina/localhost
+%dir %attr(0770,root,cloud) %{_sysconfdir}/%{name}/management/Catalina/localhost/client
+%dir %{_datadir}/%{name}-management
+%dir %attr(0770,root,cloud) %{_localstatedir}/%{name}/mnt
+%dir %attr(0770,cloud,cloud) %{_localstatedir}/%{name}/management
+%dir %attr(0770,root,cloud) %{_localstatedir}/cache/%{name}/management
+%dir %attr(0770,root,cloud) %{_localstatedir}/cache/%{name}/management/work
+%dir %attr(0770,root,cloud) %{_localstatedir}/cache/%{name}/management/temp
+%dir %attr(0770,root,cloud) %{_localstatedir}/log/%{name}/management
+%dir %attr(0770,root,cloud) %{_localstatedir}/log/%{name}/agent
+%dir %attr(0770,root,cloud) %{_localstatedir}/log/%{name}/awsapi
+%config(noreplace) %{_sysconfdir}/sysconfig/%{name}-management
+%config(noreplace) %attr(0640,root,cloud) %{_sysconfdir}/%{name}/management/db.properties
+%config(noreplace) %{_sysconfdir}/%{name}/management/log4j-cloud.xml
+%config(noreplace) %{_sysconfdir}/%{name}/management/tomcat6-nonssl.conf
+%config(noreplace) %{_sysconfdir}/%{name}/management/tomcat6-ssl.conf
+%config(noreplace) %{_sysconfdir}/%{name}/management/Catalina/localhost/client/context.xml
+%config(noreplace) %{_sysconfdir}/%{name}/management/catalina.policy
+%config(noreplace) %{_sysconfdir}/%{name}/management/catalina.properties
+%config(noreplace) %{_sysconfdir}/%{name}/management/classpath.conf
+%config(noreplace) %{_sysconfdir}/%{name}/management/server-nonssl.xml
+%config(noreplace) %{_sysconfdir}/%{name}/management/server-ssl.xml
+%config(noreplace) %{_sysconfdir}/%{name}/management/tomcat-users.xml
+%config(noreplace) %{_sysconfdir}/%{name}/management/web.xml
+%config(noreplace) %{_sysconfdir}/%{name}/management/environment.properties
+%config(noreplace) %{_sysconfdir}/%{name}/management/cloud-bridge.properties
+%config(noreplace) %{_sysconfdir}/%{name}/management/commons-logging.properties
+%config(noreplace) %{_sysconfdir}/%{name}/management/ec2-service.properties
+%attr(0755,root,root) %{_initrddir}/%{name}-management
+%attr(0755,root,root) %{_initrddir}/tomcat.sh
+
+%attr(0755,root,root) %{_bindir}/%{name}-setup-management
+%attr(0755,root,root) %{_bindir}/%{name}-update-xenserver-licenses
+%{_datadir}/%{name}-management/webapps
+%{_datadir}/%{name}-management/bin
+%{_datadir}/%{name}-management/conf
+%{_datadir}/%{name}-management/lib
+%{_datadir}/%{name}-management/logs
+%{_datadir}/%{name}-management/temp
+%{_datadir}/%{name}-management/work
+%attr(0755,root,root) %{_bindir}/%{name}-setup-databases
+%attr(0755,root,root) %{_bindir}/%{name}-migrate-databases
+%attr(0755,root,root) %{_bindir}/%{name}-set-guest-password
+%attr(0755,root,root) %{_bindir}/%{name}-set-guest-sshkey
+%attr(0755,root,root) %{_bindir}/%{name}-sysvmadm
+%attr(0755,root,root) %{_bindir}/%{name}-setup-encryption
+%{_datadir}/%{name}-management/setup/*.sql
+%{_datadir}/%{name}-management/setup/db/*.sql
+%{_datadir}/%{name}-management/setup/*.sh
+%{_datadir}/%{name}-management/setup/server-setup.xml
+%attr(0755,root,root) %{_bindir}/%{name}-external-ipallocator.py
+%attr(0755,root,root) %{_initrddir}/%{name}-ipallocator
+%dir %attr(0770,root,root) %{_localstatedir}/log/%{name}/ipallocator
+%{_defaultdocdir}/%{name}-management-%{version}/LICENSE
+%{_defaultdocdir}/%{name}-management-%{version}/NOTICE
+%attr(0644,cloud,cloud) %{_localstatedir}/log/%{name}/management/catalina.out
+
+%files agent
+%attr(0755,root,root) %{_bindir}/%{name}-setup-agent
+%attr(0755,root,root) %{_bindir}/%{name}-agent-upgrade
+%attr(0755,root,root) %{_bindir}/%{name}-ssh
+%attr(0755,root,root) %{_sysconfdir}/init.d/%{name}-agent
+%attr(0755,root,root) %{_datadir}/%{name}-common/scripts/network/cisco
+%config(noreplace) %{_sysconfdir}/%{name}/agent
+%dir %{_localstatedir}/log/%{name}/agent
+%attr(0644,root,root) %{_datadir}/%{name}-agent/lib/*.jar
+%attr(0755,root,root) %{_datadir}/%{name}-agent/lib/libvirtqemuhook
+%dir %{_datadir}/%{name}-agent/plugins
+%{_defaultdocdir}/%{name}-agent-%{version}/LICENSE
+%{_defaultdocdir}/%{name}-agent-%{version}/NOTICE
+
+%files common
+%dir %attr(0755,root,root) %{python_sitearch}/cloudutils
+%dir %attr(0755,root,root) %{_datadir}/%{name}-common/vms
+%attr(0755,root,root) %{_datadir}/%{name}-common/scripts
+%attr(0755,root,root) /usr/bin/cloudstack-sccs
+%attr(0644, root, root) %{_datadir}/%{name}-common/vms/systemvm.iso
+%attr(0644, root, root) %{_datadir}/%{name}-common/vms/systemvm.zip
+%attr(0644,root,root) %{python_sitearch}/cloud_utils.py
+%attr(0644,root,root) %{python_sitearch}/cloud_utils.pyc
+%attr(0644,root,root) %{python_sitearch}/cloudutils/*
+%attr(0644, root, root) %{_datadir}/%{name}-common/lib/jasypt-1.9.2.jar
+%{_defaultdocdir}/%{name}-common-%{version}/LICENSE
+%{_defaultdocdir}/%{name}-common-%{version}/NOTICE
+
+%files usage
+%attr(0755,root,root) %{_sysconfdir}/init.d/%{name}-usage
+%attr(0644,root,root) %{_datadir}/%{name}-usage/*.jar
+%attr(0644,root,root) %{_datadir}/%{name}-usage/lib/*.jar
+%dir %attr(0770,root,cloud) %{_localstatedir}/log/%{name}/usage
+%attr(0644,root,root) %{_sysconfdir}/%{name}/usage/db.properties
+%attr(0644,root,root) %{_sysconfdir}/%{name}/usage/log4j-cloud.xml
+%{_defaultdocdir}/%{name}-usage-%{version}/LICENSE
+%{_defaultdocdir}/%{name}-usage-%{version}/NOTICE
+
+%files cli
+%attr(0644,root,root) %{python_sitearch}/cloudapis.py
+%attr(0644,root,root) %{python_sitearch}/cloudtool/__init__.py
+%attr(0644,root,root) %{python_sitearch}/cloudtool/utils.py
+%{_defaultdocdir}/%{name}-cli-%{version}/LICENSE
+%{_defaultdocdir}/%{name}-cli-%{version}/NOTICE
+
+%files awsapi
+%defattr(0644,cloud,cloud,0755)
+%{_datadir}/%{name}-bridge/webapps/awsapi
+%attr(0644,root,root) %{_datadir}/%{name}-bridge/setup/*
+%attr(0755,root,root) %{_bindir}/cloudstack-aws-api-register
+%attr(0755,root,root) %{_bindir}/cloudstack-setup-bridge
+%attr(0666,cloud,cloud) %{_datadir}/%{name}-bridge/webapps/awsapi/WEB-INF/classes/crypto.properties
+%attr(0666,cloud,cloud) %{_datadir}/%{name}-bridge/webapps/awsapi/WEB-INF/classes/xes.keystore
+
+%{_defaultdocdir}/%{name}-awsapi-%{version}/LICENSE
+%{_defaultdocdir}/%{name}-awsapi-%{version}/NOTICE
+
+%if "%{_ossnoss}" == "noredist"
+%files mysql-ha
+%defattr(0644,cloud,cloud,0755)
+%attr(0644,root,root) %{_datadir}/%{name}-mysql-ha/lib/*
+%{_defaultdocdir}/%{name}-mysql-ha-%{version}/LICENSE
+%{_defaultdocdir}/%{name}-mysql-ha-%{version}/NOTICE
+%endif
+
+%files baremetal-agent
+%attr(0755,root,root) %{_bindir}/cloudstack-setup-baremetal
+
+%changelog
+* Fri Jul 04 2014 Hugo Trippaers <hu...@apache.org> 4.5.0
+- Add a package for the mysql ha module
+
+* Fri Oct 03 2012 Hugo Trippaers <hu...@apache.org> 4.1.0
+- new style spec file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a9912a00/packaging/fedora21/cloudstack-agent.te
----------------------------------------------------------------------
diff --git a/packaging/fedora21/cloudstack-agent.te b/packaging/fedora21/cloudstack-agent.te
new file mode 100644
index 0000000..4259e17
--- /dev/null
+++ b/packaging/fedora21/cloudstack-agent.te
@@ -0,0 +1,33 @@
+# 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.
+
+module cloudstack-agent 1.0;
+
+require {
+	type nfs_t;
+	type system_conf_t;
+	type mount_t;
+	type qemu_t;
+	class file unlink;
+	class filesystem getattr;
+}
+
+#============= mount_t ==============
+allow mount_t system_conf_t:file unlink;
+
+#============= qemu_t ==============
+allow qemu_t nfs_t:filesystem getattr;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a9912a00/packaging/fedora21/cloudstack-sccs
----------------------------------------------------------------------
diff --git a/packaging/fedora21/cloudstack-sccs b/packaging/fedora21/cloudstack-sccs
new file mode 100644
index 0000000..e05d372
--- /dev/null
+++ b/packaging/fedora21/cloudstack-sccs
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+cat /usr/share/cloudstack-common/scripts/gitrev.txt

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a9912a00/packaging/fedora21/replace.properties
----------------------------------------------------------------------
diff --git a/packaging/fedora21/replace.properties b/packaging/fedora21/replace.properties
new file mode 100644
index 0000000..8345854
--- /dev/null
+++ b/packaging/fedora21/replace.properties
@@ -0,0 +1,60 @@
+# 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.
+
+DBUSER=cloud
+DBPW=cloud
+DBROOTPW=
+MSLOG=vmops.log
+APISERVERLOG=api.log
+DBHOST=localhost
+COMPONENTS-SPEC=components-premium.xml
+AWSAPILOG=awsapi.log
+REMOTEHOST=localhost
+AGENTCLASSPATH=
+AGENTLOG=/var/log/cloudstack/agent/agent.log
+AGENTLOGDIR=/var/log/cloudstack/agent/
+AGENTSYSCONFDIR=/etc/cloudstack/agent
+APISERVERLOG=/var/log/cloudstack/management/apilog.log
+AWSAPILOG=/var/log/cloudstack/awsapi/awsapi.log
+BINDIR=/usr/bin
+COMMONLIBDIR=/usr/share/cloudstack-common
+CONFIGUREVARS=
+DEPSCLASSPATH=
+DOCDIR=
+IPALOCATORLOG=/var/log/cloudstack/management/ipallocator.log
+JAVADIR=/usr/share/java
+LIBEXECDIR=/usr/libexec
+LOCKDIR=/var/lock
+MSCLASSPATH=
+MSCONF=/etc/cloudstack/management
+MSENVIRON=/usr/share/cloudstack-management
+MSLOG=/var/log/cloudstack/management/management-server.log
+MSLOGDIR=/var/log/cloudstack/management/
+MSMNTDIR=/var/cloudstack/mnt
+MSUSER=cloud
+PIDDIR=/var/run
+PLUGINJAVADIR=/usr/share/cloudstack-management/plugin
+PREMIUMJAVADIR=/usr/share/cloudstack-management/premium
+PYTHONDIR=/usr/lib/python2.6/site-packages/
+SERVERSYSCONFDIR=/etc/sysconfig
+SETUPDATADIR=/usr/share/cloudstack-management/setup
+SYSCONFDIR=/etc/sysconfig
+SYSTEMCLASSPATH=
+SYSTEMJARS=
+USAGECLASSPATH=
+USAGELOG=/var/log/cloudstack/usage/usage.log
+USAGESYSCONFDIR=/etc/sysconfig

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a9912a00/packaging/fedora21/tomcat.sh
----------------------------------------------------------------------
diff --git a/packaging/fedora21/tomcat.sh b/packaging/fedora21/tomcat.sh
new file mode 100644
index 0000000..76ba741
--- /dev/null
+++ b/packaging/fedora21/tomcat.sh
@@ -0,0 +1,18 @@
+# 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.
+
+service tomcat start


[43/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
CLOUDSTACK-8265: added  foreign key constriant on guest os id


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

Branch: refs/heads/reporter
Commit: 58c5850beed8037c608e2b902004be6375ed0dae
Parents: ef99f01
Author: Abhinandan Prateek <ab...@shapeblue.com>
Authored: Tue Mar 3 01:45:48 2015 -0500
Committer: Abhinandan Prateek <ab...@shapeblue.com>
Committed: Tue Mar 3 02:25:09 2015 -0500

----------------------------------------------------------------------
 setup/db/db/schema-442to450.sql | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/58c5850b/setup/db/db/schema-442to450.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-442to450.sql b/setup/db/db/schema-442to450.sql
index a1d9b0e..4a8f250 100644
--- a/setup/db/db/schema-442to450.sql
+++ b/setup/db/db/schema-442to450.sql
@@ -1024,3 +1024,4 @@ INSERT IGNORE INTO `cloud`.`configuration` (`category`, `instance`, `component`,
 
 UPDATE `cloud`.`configuration` SET description='Uuid of the service offering used by secondary storage; if NULL - system offering will be used' where name='secstorage.service.offering';
 
+ALTER TABLE `cloud`.`guest_os_hypervisor` ADD FOREIGN KEY (`guest_os_id`) REFERENCES `cloud`.`guest_os`(`id`);


[41/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
Merge remote-tracking branch 'laszlo/CLOUDSTACK-8292'

This closes #91

Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/reporter
Commit: 085554d81d6f05209d52cc6708103514d4bc496d
Parents: db443c1 0fda5a0
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Mon Mar 2 16:37:11 2015 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Mon Mar 2 16:37:20 2015 +0530

----------------------------------------------------------------------
 .../resource/LibvirtComputingResourceTest.java  | 254 ++++++-------------
 1 file changed, 83 insertions(+), 171 deletions(-)
----------------------------------------------------------------------



[46/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
CLOUDSTACK-4807: tests for NetUtils

Signed-off-by: Laszlo Hornyak <la...@gmail.com>


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

Branch: refs/heads/reporter
Commit: 1f72548f57fb76dca3b9542f232fc539bbfd1ea6
Parents: 57cd7f3
Author: Laszlo Hornyak <la...@gmail.com>
Authored: Tue Mar 3 20:42:46 2015 +0100
Committer: Laszlo Hornyak <la...@gmail.com>
Committed: Tue Mar 3 21:21:52 2015 +0100

----------------------------------------------------------------------
 utils/src/com/cloud/utils/net/NetUtils.java     | 24 ++++++------
 .../test/com/cloud/utils/net/NetUtilsTest.java  | 39 ++++++++++++++++++++
 2 files changed, 52 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1f72548f/utils/src/com/cloud/utils/net/NetUtils.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/net/NetUtils.java b/utils/src/com/cloud/utils/net/NetUtils.java
index 8875bb9..cc48ef1 100644
--- a/utils/src/com/cloud/utils/net/NetUtils.java
+++ b/utils/src/com/cloud/utils/net/NetUtils.java
@@ -373,7 +373,7 @@ public class NetUtils {
         }
     }
 
-    public static long ip2Long(String ip) {
+    public static long ip2Long(final String ip) {
         String[] tokens = ip.split("[.]");
         assert (tokens.length == 4);
         long result = 0;
@@ -388,8 +388,8 @@ public class NetUtils {
         return result;
     }
 
-    public static String long2Ip(long ip) {
-        StringBuilder result = new StringBuilder(15);
+    public static String long2Ip(final long ip) {
+        final StringBuilder result = new StringBuilder(15);
         result.append((ip >> 24 & 0xff)).append(".");
         result.append((ip >> 16 & 0xff)).append(".");
         result.append((ip >> 8 & 0xff)).append(".");
@@ -398,8 +398,8 @@ public class NetUtils {
         return result.toString();
     }
 
-    public static long mac2Long(String macAddress) {
-        String[] tokens = macAddress.split(":");
+    public static long mac2Long(final String macAddress) {
+        final String[] tokens = macAddress.split(":");
         assert (tokens.length == 6);
         long result = 0;
         for (int i = 0; i < tokens.length; i++) {
@@ -464,12 +464,14 @@ public class NetUtils {
         return result.toString();
     }
 
-    public static String long2Mac(long macAddress) {
-        StringBuilder result = new StringBuilder(17);
-        Formatter formatter = new Formatter(result);
-        formatter.format("%02x:%02x:%02x:%02x:%02x:%02x", (macAddress >> 40) & 0xff, (macAddress >> 32) & 0xff, (macAddress >> 24) & 0xff, (macAddress >> 16) & 0xff,
-                (macAddress >> 8) & 0xff, (macAddress & 0xff));
-        formatter.close();
+    public static String long2Mac(final long macAddress) {
+        final StringBuilder result = new StringBuilder(17);
+        try (Formatter formatter = new Formatter(result)) {
+            formatter.format("%02x:%02x:%02x:%02x:%02x:%02x",
+                    (macAddress >> 40) & 0xff, (macAddress >> 32) & 0xff,
+                    (macAddress >> 24) & 0xff, (macAddress >> 16) & 0xff,
+                    (macAddress >> 8) & 0xff, (macAddress & 0xff));
+        }
         return result.toString();
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1f72548f/utils/test/com/cloud/utils/net/NetUtilsTest.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/net/NetUtilsTest.java b/utils/test/com/cloud/utils/net/NetUtilsTest.java
index 62476ea..c4eceab 100644
--- a/utils/test/com/cloud/utils/net/NetUtilsTest.java
+++ b/utils/test/com/cloud/utils/net/NetUtilsTest.java
@@ -303,4 +303,43 @@ public class NetUtilsTest {
 
         assertTrue(NetUtils.validateGuestCidr(guestCidr));
     }
+
+    @Test
+    public void testMac2Long() {
+        assertEquals(0l, NetUtils.mac2Long("00:00:00:00:00:00"));
+        assertEquals(1l, NetUtils.mac2Long("00:00:00:00:00:01"));
+        assertEquals(0xFFl, NetUtils.mac2Long("00:00:00:00:00:FF"));
+        assertEquals(0xFFAAl, NetUtils.mac2Long("00:00:00:00:FF:AA"));
+        assertEquals(0x11FFAAl, NetUtils.mac2Long("00:00:00:11:FF:AA"));
+        assertEquals(0x12345678l, NetUtils.mac2Long("00:00:12:34:56:78"));
+        assertEquals(0x123456789Al, NetUtils.mac2Long("00:12:34:56:78:9A"));
+        assertEquals(0x123456789ABCl, NetUtils.mac2Long("12:34:56:78:9A:BC"));
+    }
+
+    @Test
+    public void testLong2Mac() {
+        assertEquals("00:00:00:00:00:00", NetUtils.long2Mac(0l));
+        assertEquals("00:00:00:00:00:01", NetUtils.long2Mac(1l));
+        assertEquals("00:00:00:00:00:ff", NetUtils.long2Mac(0xFFl));
+        assertEquals("00:00:00:00:ff:aa", NetUtils.long2Mac(0xFFAAl));
+        assertEquals("00:00:00:11:ff:aa", NetUtils.long2Mac(0x11FFAAl));
+        assertEquals("00:00:12:34:56:78", NetUtils.long2Mac(0x12345678l));
+        assertEquals("00:12:34:56:78:9a", NetUtils.long2Mac(0x123456789Al));
+        assertEquals("12:34:56:78:9a:bc", NetUtils.long2Mac(0x123456789ABCl));
+    }
+
+    @Test
+    public void testIp2Long() {
+        assertEquals(0x7f000001l, NetUtils.ip2Long("127.0.0.1"));
+        assertEquals(0xc0a80001l, NetUtils.ip2Long("192.168.0.1"));
+        assertEquals(0x08080808l, NetUtils.ip2Long("8.8.8.8"));
+    }
+
+    @Test
+    public void testLong2Ip() {
+        assertEquals("127.0.0.1", NetUtils.long2Ip(0x7f000001l));
+        assertEquals("192.168.0.1", NetUtils.long2Ip(0xc0a80001l));
+        assertEquals("8.8.8.8", NetUtils.long2Ip(0x08080808l));
+    }
+
 }


[05/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
CLOUDSTACK-8265: added os mappings for Ubuntu 14.04


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

Branch: refs/heads/reporter
Commit: 6caee8590a91695b98e4b932cb1d4ee6faff6d44
Parents: 77d11eb
Author: Abhinandan Prateek <ab...@shapeblue.com>
Authored: Tue Feb 24 07:27:23 2015 -0500
Committer: Abhinandan Prateek <ab...@shapeblue.com>
Committed: Tue Feb 24 07:30:54 2015 -0500

----------------------------------------------------------------------
 setup/db/db/schema-442to450.sql | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6caee859/setup/db/db/schema-442to450.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-442to450.sql b/setup/db/db/schema-442to450.sql
index 798b232..a1d9b0e 100644
--- a/setup/db/db/schema-442to450.sql
+++ b/setup/db/db/schema-442to450.sql
@@ -763,7 +763,7 @@ INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name, crea
 INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name, created) VALUES (238, UUID(), 4, 'Red Hat Enterprise Linux 5 (64-bit)', utc_timestamp());
 INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name, created) VALUES (239, UUID(), 4, 'Red Hat Enterprise Linux 6 (32-bit)', utc_timestamp());
 INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name, created) VALUES (240, UUID(), 4, 'Red Hat Enterprise Linux 6 (64-bit)', utc_timestamp());
-INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name, created) VALUES (241, UUID(), 10, 'Ubuntu 14.04', utc_timestamp());
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name, created) VALUES (241, UUID(), 10, 'Ubuntu 14.04 (32-bit)', utc_timestamp());
 INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name, created) VALUES (244, UUID(), 5, 'SUSE Linux Enterprise Server 12 (64-bit)', utc_timestamp());
 INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name, created) VALUES (245, UUID(), 4, 'Red Hat Enterprise Linux 7', utc_timestamp());
 INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name, created) VALUES (246, UUID(), 1, 'CentOS 7', utc_timestamp());
@@ -772,6 +772,7 @@ INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name, crea
 INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name, created) VALUES (249, UUID(), 1, 'CentOS 6 (64-bit)', utc_timestamp());
 INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name, created) VALUES (250, UUID(), 3, 'Oracle Enterprise Linux 6.5 (32-bit)', utc_timestamp());
 INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name, created) VALUES (251, UUID(), 3, 'Oracle Enterprise Linux 6.5 (64-bit)', utc_timestamp());
+INSERT IGNORE INTO `cloud`.`guest_os` (id, uuid, category_id, display_name, created) VALUES (254, UUID(), 10, 'Ubuntu 14.04 (64-bit)', utc_timestamp());
 
 INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'Xenserver', '6.5.0', 'CentOS 4.5 (32-bit)', 1, utc_timestamp(), 0);
 INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'Xenserver', '6.5.0', 'CentOS 4.6 (32-bit)', 2, utc_timestamp(), 0);
@@ -936,6 +937,7 @@ INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervis
 INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'Xenserver', '6.5.0', 'Ubuntu Precise Pangolin 12.04 (32-bit)', 163, utc_timestamp(), 0);
 INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'Xenserver', '6.5.0', 'Ubuntu Precise Pangolin 12.04 (64-bit)', 164, utc_timestamp(), 0);
 INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'Xenserver', '6.5.0', 'Ubuntu Trusty Tahr 14.04', 241, utc_timestamp(), 0);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'Xenserver', '6.5.0', 'Ubuntu Trusty Tahr 14.04', 254, utc_timestamp(), 0);
 INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'Xenserver', '6.5.0', 'Other install media', 169, utc_timestamp(), 0);
 INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'Xenserver', '6.5.0', 'Other install media', 170, utc_timestamp(), 0);
 INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'Xenserver', '6.5.0', 'Other install media', 98, utc_timestamp(), 0);
@@ -950,6 +952,7 @@ INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervis
 INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'Xenserver', '6.5.0', 'Other install media', 203, utc_timestamp(), 0);
 
 
+
 INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(uuid, hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled, max_data_volumes_limit, storage_motion_supported) VALUES (UUID(), 'XenServer', '6.5.0', 500, 1, 13, 1);
 
 update vlan set vlan_id=concat('vlan://', vlan_id) where vlan_type = "VirtualNetwork" and vlan_id not like "vlan://%";
@@ -995,7 +998,7 @@ INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervis
 INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'VMware', '5.1', 'rhel6Guest', 252, utc_timestamp(), 0);
 INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'VMware', '5.1', 'rhel6_64Guest', 253, utc_timestamp(), 0);
 INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'VMware', '5.5', 'rhel6Guest', 252, utc_timestamp(), 0);
-INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'VMware', '5,5', 'rhel6_64Guest', 253, utc_timestamp(), 0);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'VMware', '5.5', 'rhel6_64Guest', 253, utc_timestamp(), 0);
 
 --Support for Debian 7 on KVM/LXC
 INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'KVM', 'default', 'Debian GNU/Linux 7(32-bit)', 183, utc_timestamp(), 0);
@@ -1003,6 +1006,20 @@ INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervis
 INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'LXC', 'default', 'Debian GNU/Linux 7(32-bit)', 183, utc_timestamp(), 0);
 INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'LXC', 'default', 'Debian GNU/Linux 7(64-bit)', 184, utc_timestamp(), 0);
 
+
+--Support for Ubuntu 14.04
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'VMware', '5.0', 'ubuntuGuest', 241, utc_timestamp(), 0);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'VMware', '5.1', 'ubuntuGuest', 241, utc_timestamp(), 0);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'VMware', '5.5', 'ubuntuGuest', 241, utc_timestamp(), 0);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'VMware', '5.0', 'ubuntu64Guest', 254, utc_timestamp(), 0);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'VMware', '5.1', 'ubuntu64Guest', 254, utc_timestamp(), 0);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'VMware', '5.5', 'ubuntu64Guest', 254, utc_timestamp(), 0);
+
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'KVM', 'default', 'Ubuntu 14.04', 241, utc_timestamp(), 0);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'KVM', 'default', 'Ubuntu 14.04', 254, utc_timestamp(), 0);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'LXC', 'default', 'Ubuntu 14.04', 241, utc_timestamp(), 0);
+INSERT IGNORE INTO `cloud`.`guest_os_hypervisor` (uuid,hypervisor_type, hypervisor_version, guest_os_name, guest_os_id, created, is_user_defined) VALUES (UUID(),'LXC', 'default', 'Ubuntu 14.04', 254, utc_timestamp(), 0);
+
 INSERT IGNORE INTO `cloud`.`configuration` (`category`, `instance`, `component`, `name`, `value`, `default_value`, `description`) VALUES ('Advanced', 'DEFAULT', 'ManagementServer', 'xen.heartbeat.timeout' , '180', '120', 'Timeout value to send to the xenheartbeat script for guarding the self fencing functionality');
 
 UPDATE `cloud`.`configuration` SET description='Uuid of the service offering used by secondary storage; if NULL - system offering will be used' where name='secstorage.service.offering';


[12/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f3931993/test/integration/component/test_shared_networks.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_shared_networks.py b/test/integration/component/test_shared_networks.py
index 4d71ed3..4492a3e 100644
--- a/test/integration/component/test_shared_networks.py
+++ b/test/integration/component/test_shared_networks.py
@@ -17,139 +17,140 @@
 
 """ P1 tests for shared networks
 """
-# Import Local Modules
 from nose.plugins.attrib import attr
 from marvin.cloudstackTestCase import cloudstackTestCase, unittest
 from marvin.lib.base import (Account,
-                                         Network,
-                                         NetworkOffering,
-                                         VirtualMachine,
-                                         Project,
-                                         PhysicalNetwork,
-                                         Domain,
-                                         StaticNATRule,
-                                         FireWallRule,
-                                         ServiceOffering,
-                                         PublicIPAddress)
+                             Network,
+                             NetworkOffering,
+                             VirtualMachine,
+                             Project,
+                             PhysicalNetwork,
+                             Domain,
+                             StaticNATRule,
+                             FireWallRule,
+                             ServiceOffering,
+                             PublicIPAddress)
 from marvin.lib.utils import (cleanup_resources,
-                                          validateList,
-                                          xsplit)
+                              validateList)
 from marvin.lib.common import (get_domain,
-                                           get_zone,
-                                           get_template,
-                                           wait_for_cleanup,
-                                           get_free_vlan)
-from marvin.codes import *
+                               get_zone,
+                               get_template,
+                               wait_for_cleanup,
+                               get_free_vlan)
+from marvin.codes import PASS
 import random
 import netaddr
 
+
 class Services:
+
     """ Test shared networks """
 
     def __init__(self):
         self.services = {
-                          "domain": {
-                                   "name": "DOM",
-                                   },
-                         "project": {
-                                    "name": "Project",
-                                    "displaytext": "Test project",
-                                    },
-                         "account": {
-                                    "email": "admin-XABU1@test.com",
-                                    "firstname": "admin-XABU1",
-                                    "lastname": "admin-XABU1",
-                                    "username": "admin-XABU1",
-                                    # Random characters are appended for unique
-                                    # username
-                                    "password": "password",
-                                    },
-                         "service_offering": {
-                                    "name": "Tiny Instance",
-                                    "displaytext": "Tiny Instance",
-                                    "cpunumber": 1,
-                                    "cpuspeed": 100,  # in MHz
-                                    "memory": 128,  # In MBs
-                                    },
-                         "network_offering": {
-                                    "name": 'MySharedOffering',
-                                    "displaytext": 'MySharedOffering',
-                                    "guestiptype": 'Shared',
-                                    "supportedservices": 'Dhcp,Dns,UserData',
-                                    "specifyVlan" : "False",
-                                    "specifyIpRanges" : "False",
-                                    "traffictype": 'GUEST',
-                                    "serviceProviderList" : {
-                                            "Dhcp": 'VirtualRouter',
-                                            "Dns": 'VirtualRouter',
-                                            "UserData": 'VirtualRouter'
-                                        },
-                                },
-                         "network": {
-                                  "name": "MySharedNetwork - Test",
-                                  "displaytext": "MySharedNetwork",
-                                  "gateway" :"",
-                                  "netmask" :"255.255.255.0",
-                                  "startip" :"",
-                                  "endip" :"",
-                                  "acltype" : "Domain",
-                                  "scope":"all",
-                                },
-                         "network1": {
-                                  "name": "MySharedNetwork - Test1",
-                                  "displaytext": "MySharedNetwork1",
-                                  "gateway" :"",
-                                  "netmask" :"255.255.255.0",
-                                  "startip" :"",
-                                  "endip" :"",
-                                  "acltype" : "Domain",
-                                  "scope":"all",
-                                },
-						 "isolated_network_offering": {
-                                    "name": 'Network offering-VR services',
-                                    "displaytext": 'Network offering-VR services',
-                                    "guestiptype": 'Isolated',
-                                    "supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding,Vpn,Firewall,Lb,UserData,StaticNat',
-                                    "traffictype": 'GUEST',
-                                    "availability": 'Optional',
-                                    "serviceProviderList": {
-                                            "Dhcp": 'VirtualRouter',
-                                            "Dns": 'VirtualRouter',
-                                            "SourceNat": 'VirtualRouter',
-                                            "PortForwarding": 'VirtualRouter',
-                                            "Vpn": 'VirtualRouter',
-                                            "Firewall": 'VirtualRouter',
-                                            "Lb": 'VirtualRouter',
-                                            "UserData": 'VirtualRouter',
-                                            "StaticNat": 'VirtualRouter',
-                                        },
-                         },
-                         "isolated_network": {
-                                  "name": "Isolated Network",
-                                  "displaytext": "Isolated Network",
-                         },
-                         "fw_rule": {
-                                    "startport": 22,
-                                    "endport": 22,
-                                    "cidr": '0.0.0.0/0',
-                         },
-                         "virtual_machine": {
-                                    "displayname": "Test VM",
-                                    "username": "root",
-                                    "password": "password",
-                                    "ssh_port": 22,
-                                    "hypervisor": 'XenServer',
-                                    # Hypervisor type should be same as
-                                    # hypervisor type of cluster
-                                    "privateport": 22,
-                                    "publicport": 22,
-                                    "protocol": 'TCP',
-                                },
-                         "ostype": 'CentOS 5.3 (64-bit)',
-                         # Cent OS 5.3 (64 bit)
-                         "timeout": 10,
-                         "mode": 'advanced'
-                    }
+            "domain": {
+                "name": "DOM",
+            },
+            "project": {
+                "name": "Project",
+                "displaytext": "Test project",
+            },
+            "account": {
+                "email": "admin-XABU1@test.com",
+                "firstname": "admin-XABU1",
+                "lastname": "admin-XABU1",
+                "username": "admin-XABU1",
+                # Random characters are appended for unique
+                # username
+                "password": "password",
+            },
+            "service_offering": {
+                "name": "Tiny Instance",
+                "displaytext": "Tiny Instance",
+                "cpunumber": 1,
+                "cpuspeed": 100,  # in MHz
+                "memory": 128,  # In MBs
+            },
+            "network_offering": {
+                "name": 'MySharedOffering',
+                "displaytext": 'MySharedOffering',
+                "guestiptype": 'Shared',
+                "supportedservices": 'Dhcp,Dns,UserData',
+                "specifyVlan": "False",
+                "specifyIpRanges": "False",
+                "traffictype": 'GUEST',
+                "serviceProviderList": {
+                    "Dhcp": 'VirtualRouter',
+                    "Dns": 'VirtualRouter',
+                    "UserData": 'VirtualRouter'
+                },
+            },
+            "network": {
+                "name": "MySharedNetwork - Test",
+                "displaytext": "MySharedNetwork",
+                "gateway": "",
+                "netmask": "255.255.255.0",
+                "startip": "",
+                "endip": "",
+                "acltype": "Domain",
+                "scope": "all",
+            },
+            "network1": {
+                "name": "MySharedNetwork - Test1",
+                "displaytext": "MySharedNetwork1",
+                "gateway": "",
+                "netmask": "255.255.255.0",
+                "startip": "",
+                "endip": "",
+                "acltype": "Domain",
+                "scope": "all",
+            },
+            "isolated_network_offering": {
+                "name": 'Network offering-VR services',
+                "displaytext": 'Network offering-VR services',
+                "guestiptype": 'Isolated',
+                "supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding,Vpn,Firewall,Lb,UserData,StaticNat',
+                "traffictype": 'GUEST',
+                "availability": 'Optional',
+                "serviceProviderList": {
+                    "Dhcp": 'VirtualRouter',
+                    "Dns": 'VirtualRouter',
+                    "SourceNat": 'VirtualRouter',
+                    "PortForwarding": 'VirtualRouter',
+                    "Vpn": 'VirtualRouter',
+                    "Firewall": 'VirtualRouter',
+                    "Lb": 'VirtualRouter',
+                    "UserData": 'VirtualRouter',
+                    "StaticNat": 'VirtualRouter',
+                },
+            },
+            "isolated_network": {
+                "name": "Isolated Network",
+                "displaytext": "Isolated Network",
+            },
+            "fw_rule": {
+                "startport": 22,
+                "endport": 22,
+                "cidr": '0.0.0.0/0',
+            },
+            "virtual_machine": {
+                "displayname": "Test VM",
+                "username": "root",
+                "password": "password",
+                "ssh_port": 22,
+                "hypervisor": 'XenServer',
+                # Hypervisor type should be same as
+                # hypervisor type of cluster
+                "privateport": 22,
+                "publicport": 22,
+                "protocol": 'TCP',
+            },
+            "ostype": 'CentOS 5.3 (64-bit)',
+            # Cent OS 5.3 (64 bit)
+            "timeout": 10,
+            "mode": 'advanced'
+        }
+
 
 class TestSharedNetworks(cloudstackTestCase):
 
@@ -163,22 +164,22 @@ class TestSharedNetworks(cloudstackTestCase):
         cls.domain = get_domain(cls.api_client)
         cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.template = get_template(
-                            cls.api_client,
-                            cls.zone.id,
-                            cls.services["ostype"]
-                            )
+            cls.api_client,
+            cls.zone.id,
+            cls.services["ostype"]
+        )
 
         cls.services["virtual_machine"]["zoneid"] = cls.zone.id
         cls.services["virtual_machine"]["template"] = cls.template.id
 
         cls.service_offering = ServiceOffering.create(
-                                            cls.api_client,
-                                            cls.services["service_offering"]
-                                            )
+            cls.api_client,
+            cls.services["service_offering"]
+        )
 
         cls._cleanup = [
-                        cls.service_offering,
-                        ]
+            cls.service_offering,
+        ]
         return
 
     @classmethod
@@ -198,13 +199,19 @@ class TestSharedNetworks(cloudstackTestCase):
         # of each test case to avoid overlapping of ip addresses
         shared_network_subnet_number = random.randrange(1, 254)
 
-        self.services["network"]["gateway"] = "172.16." + str(shared_network_subnet_number) + ".1"
-        self.services["network"]["startip"] = "172.16." + str(shared_network_subnet_number) + ".2"
-        self.services["network"]["endip"] = "172.16." + str(shared_network_subnet_number) + ".20"
+        self.services["network"]["gateway"] = "172.16." + \
+            str(shared_network_subnet_number) + ".1"
+        self.services["network"]["startip"] = "172.16." + \
+            str(shared_network_subnet_number) + ".2"
+        self.services["network"]["endip"] = "172.16." + \
+            str(shared_network_subnet_number) + ".20"
 
-        self.services["network1"]["gateway"] = "172.16." + str(shared_network_subnet_number + 1) + ".1"
-        self.services["network1"]["startip"] = "172.16." + str(shared_network_subnet_number + 1) + ".2"
-        self.services["network1"]["endip"] = "172.16." + str(shared_network_subnet_number + 1) + ".20"
+        self.services["network1"]["gateway"] = "172.16." + \
+            str(shared_network_subnet_number + 1) + ".1"
+        self.services["network1"]["startip"] = "172.16." + \
+            str(shared_network_subnet_number + 1) + ".2"
+        self.services["network1"]["endip"] = "172.16." + \
+            str(shared_network_subnet_number + 1) + ".20"
 
         self.cleanup = []
         self.cleanup_networks = []
@@ -221,26 +228,34 @@ class TestSharedNetworks(cloudstackTestCase):
         except Exception as e:
             raise Exception("Warning: Exception during cleanup : %s" % e)
 
-        # below components is not a part of cleanup because to mandate the order and to cleanup network
+        # below components is not a part of cleanup because to mandate the
+        # order and to cleanup network
         try:
             for vm in self.cleanup_vms:
-               vm.delete(self.api_client)
+                vm.delete(self.api_client)
         except Exception as e:
-            raise Exception("Warning: Exception during virtual machines cleanup : %s" % e)
+            raise Exception(
+                "Warning: Exception during virtual machines cleanup : %s" %
+                e)
 
         try:
             for project in self.cleanup_projects:
-                 project.delete(self.api_client)
+                project.delete(self.api_client)
         except Exception as e:
-             raise Exception("Warning: Exception during project cleanup : %s" % e)
+            raise Exception(
+                "Warning: Exception during project cleanup : %s" %
+                e)
 
         try:
             for account in self.cleanup_accounts:
                 account.delete(self.api_client)
         except Exception as e:
-            raise Exception("Warning: Exception during account cleanup : %s" % e)
+            raise Exception(
+                "Warning: Exception during account cleanup : %s" %
+                e)
 
-        # Wait till all resources created are cleaned up completely and then attempt to delete domains
+        # Wait till all resources created are cleaned up completely and then
+        # attempt to delete domains
         wait_for_cleanup(self.api_client, ["account.cleanup.interval"])
 
         try:
@@ -254,7 +269,9 @@ class TestSharedNetworks(cloudstackTestCase):
             for domain in self.cleanup_domains:
                 domain.delete(self.api_client)
         except Exception as e:
-            raise Exception("Warning: Exception during domain cleanup : %s" % e)
+            raise Exception(
+                "Warning: Exception during domain cleanup : %s" %
+                e)
 
         return
 
@@ -278,57 +295,59 @@ class TestSharedNetworks(cloudstackTestCase):
         #  1. listAccounts name=admin-XABU1, state=enabled returns your account
         #  2. listPhysicalNetworks should return at least one active physical network
         #  3. listNetworkOfferings - name=mysharedoffering , should list offering in disabled state
-        #  4. listNetworkOfferings - name=mysharedoffering, should list enabled offering
+        # 4. listNetworkOfferings - name=mysharedoffering, should list enabled
+        # offering
 
         # Create an account
         self.account = Account.create(
-                         self.api_client,
-                         self.services["account"],
-                         admin=True,
-                         domainid=self.domain.id
-                         )
+            self.api_client,
+            self.services["account"],
+            admin=True,
+            domainid=self.domain.id
+        )
 
         self.cleanup_accounts.append(self.account)
 
         # verify that the account got created with state enabled
         list_accounts_response = Account.list(
-                                        self.api_client,
-                                        id=self.account.id,
-                                        listall=True
-                                        )
+            self.api_client,
+            id=self.account.id,
+            listall=True
+        )
         self.assertEqual(
             isinstance(list_accounts_response, list),
             True,
             "listAccounts returned invalid object in response."
-            )
+        )
         self.assertNotEqual(
             len(list_accounts_response),
             0,
             "listAccounts returned empty list."
-            )
+        )
         self.assertEqual(
             list_accounts_response[0].state,
             "enabled",
             "The admin account created is not enabled."
-            )
+        )
 
         self.debug("Admin Type account created: %s" % self.account.name)
 
-        # Verify that there should be at least one physical network present in zone.
+        # Verify that there should be at least one physical network present in
+        # zone.
         list_physical_networks_response = PhysicalNetwork.list(
-                                                         self.api_client,
-                                                         zoneid=self.zone.id
-                                                         )
+            self.api_client,
+            zoneid=self.zone.id
+        )
         self.assertEqual(
             isinstance(list_physical_networks_response, list),
             True,
             "listPhysicalNetworks returned invalid object in response."
-            )
+        )
         self.assertNotEqual(
             len(list_physical_networks_response),
             0,
             "listPhysicalNetworks should return at least one physical network."
-            )
+        )
 
         physical_network = list_physical_networks_response[0]
 
@@ -339,60 +358,62 @@ class TestSharedNetworks(cloudstackTestCase):
 
         # Create Network Offering
         self.shared_network_offering = NetworkOffering.create(
-                                                 self.api_client,
-                                                 self.services["network_offering"],
-                                                 conservemode=False
-                                                 )
+            self.api_client,
+            self.services["network_offering"],
+            conservemode=False
+        )
 
         # Verify that the network offering got created
         list_network_offerings_response = NetworkOffering.list(
-                                                         self.api_client,
-                                                         id=self.shared_network_offering.id
-                                                         )
+            self.api_client,
+            id=self.shared_network_offering.id
+        )
         self.assertEqual(
             isinstance(list_network_offerings_response, list),
             True,
             "listNetworkOfferings returned invalid object in response."
-            )
+        )
         self.assertNotEqual(
             len(list_network_offerings_response),
             0,
             "listNetworkOfferings returned empty list."
-            )
+        )
         self.assertEqual(
             list_network_offerings_response[0].state,
             "Disabled",
             "The network offering created should be bydefault disabled."
-            )
+        )
 
         # Update network offering state from disabled to enabled.
         NetworkOffering.update(
-                                self.shared_network_offering,
-                                self.api_client,
-                                id=self.shared_network_offering.id,
-                                state="enabled"
-                                )
+            self.shared_network_offering,
+            self.api_client,
+            id=self.shared_network_offering.id,
+            state="enabled"
+        )
         # Verify that the state of the network offering is updated
         list_network_offerings_response = NetworkOffering.list(
-                                                         self.api_client,
-                                                         id=self.shared_network_offering.id
-                                                         )
+            self.api_client,
+            id=self.shared_network_offering.id
+        )
         self.assertEqual(
             isinstance(list_network_offerings_response, list),
             True,
             "listNetworkOfferings returned invalid object in response."
-            )
+        )
         self.assertNotEqual(
             len(list_network_offerings_response),
             0,
             "listNetworkOfferings returned empty list."
-            )
+        )
         self.assertEqual(
             list_network_offerings_response[0].state,
             "Enabled",
             "The network offering state should get updated to Enabled."
-            )
-        self.debug("NetworkOffering created and enabled: %s" % self.shared_network_offering.id)
+        )
+        self.debug(
+            "NetworkOffering created and enabled: %s" %
+            self.shared_network_offering.id)
 
     @attr(tags=["advanced", "advancedns"], required_hardware="false")
     def test_sharedNetworkOffering_02(self):
@@ -412,57 +433,59 @@ class TestSharedNetworks(cloudstackTestCase):
         # Validations,
         #  1. listAccounts name=admin-XABU1, state=enabled returns your account
         #  2. listPhysicalNetworks should return at least one active physical network
-        #  3. createNetworkOffering fails - vlan should be specified in advanced zone
+        # 3. createNetworkOffering fails - vlan should be specified in advanced
+        # zone
 
         # Create an account
         self.account = Account.create(
-                         self.api_client,
-                         self.services["account"],
-                         admin=True,
-                         domainid=self.domain.id
-                         )
+            self.api_client,
+            self.services["account"],
+            admin=True,
+            domainid=self.domain.id
+        )
 
         self.cleanup_accounts.append(self.account)
 
         # verify that the account got created with state enabled
         list_accounts_response = Account.list(
-                                        self.api_client,
-                                        id=self.account.id,
-                                        listall=True
-                                        )
+            self.api_client,
+            id=self.account.id,
+            listall=True
+        )
         self.assertEqual(
             isinstance(list_accounts_response, list),
             True,
             "listAccounts returned invalid object in response."
-            )
+        )
         self.assertNotEqual(
             len(list_accounts_response),
             0,
             "listAccounts returned empty list."
-            )
+        )
         self.assertEqual(
             list_accounts_response[0].state,
             "enabled",
             "The admin account created is not enabled."
-            )
+        )
 
         self.debug("Admin type account created: %s" % self.account.name)
 
-        # Verify that there should be at least one physical network present in zone.
+        # Verify that there should be at least one physical network present in
+        # zone.
         list_physical_networks_response = PhysicalNetwork.list(
-                                                         self.api_client,
-                                                         zoneid=self.zone.id
-                                                         )
+            self.api_client,
+            zoneid=self.zone.id
+        )
         self.assertEqual(
             isinstance(list_physical_networks_response, list),
             True,
             "listPhysicalNetworks returned invalid object in response."
-            )
+        )
         self.assertNotEqual(
             len(list_physical_networks_response),
             0,
             "listPhysicalNetworks should return at least one physical network."
-            )
+        )
 
         physical_network = list_physical_networks_response[0]
 
@@ -474,14 +497,16 @@ class TestSharedNetworks(cloudstackTestCase):
         try:
             # Create Network Offering
             self.shared_network_offering = NetworkOffering.create(
-                                                     self.api_client,
-                                                     self.services["network_offering"],
-                                                     conservemode=False
-                                                     )
-            self.fail("Network offering got created with vlan as False in advance mode and shared guest type, which is invalid case.")
+                self.api_client,
+                self.services["network_offering"],
+                conservemode=False
+            )
+            self.fail(
+                "Network offering got created with vlan as False in advance mode and shared guest type, which is invalid case.")
         except Exception as e:
-            self.debug("Network Offering creation failed with vlan as False in advance mode and shared guest type. Exception: %s" %
-                        e)
+            self.debug(
+                "Network Offering creation failed with vlan as False in advance mode and shared guest type. Exception: %s" %
+                e)
 
     @attr(tags=["advanced", "advancedns"], required_hardware="false")
     def test_sharedNetworkOffering_03(self):
@@ -501,58 +526,59 @@ class TestSharedNetworks(cloudstackTestCase):
         # Validations,
         #  1. listAccounts name=admin-XABU1, state=enabled returns your account
         #  2. listPhysicalNetworks should return at least one active physical network
-        #  3. createNetworkOffering fails - ip ranges should be specified when creating shared network offering
-
+        # 3. createNetworkOffering fails - ip ranges should be specified when
+        # creating shared network offering
 
         # Create an account
         self.account = Account.create(
-                         self.api_client,
-                         self.services["account"],
-                         admin=True,
-                         domainid=self.domain.id
-                         )
+            self.api_client,
+            self.services["account"],
+            admin=True,
+            domainid=self.domain.id
+        )
 
         self.cleanup_accounts.append(self.account)
 
         # verify that the account got created with state enabled
         list_accounts_response = Account.list(
-                                        self.api_client,
-                                        id=self.account.id,
-                                        listall=True
-                                        )
+            self.api_client,
+            id=self.account.id,
+            listall=True
+        )
         self.assertEqual(
             isinstance(list_accounts_response, list),
             True,
             "listAccounts returned invalid object in response."
-            )
+        )
         self.assertNotEqual(
             len(list_accounts_response),
             0,
             "listAccounts returned empty list."
-            )
+        )
         self.assertEqual(
             list_accounts_response[0].state,
             "enabled",
             "The admin account created is not enabled."
-            )
+        )
 
         self.debug("Admin Type account created: %s" % self.account.name)
 
-        # Verify that there should be at least one physical network present in zone.
+        # Verify that there should be at least one physical network present in
+        # zone.
         list_physical_networks_response = PhysicalNetwork.list(
-                                                         self.api_client,
-                                                         zoneid=self.zone.id
-                                                         )
+            self.api_client,
+            zoneid=self.zone.id
+        )
         self.assertEqual(
             isinstance(list_physical_networks_response, list),
             True,
             "listPhysicalNetworks returned invalid object in response."
-            )
+        )
         self.assertNotEqual(
             len(list_physical_networks_response),
             0,
             "listPhysicalNetworks should return at least one physical network."
-            )
+        )
 
         physical_network = list_physical_networks_response[0]
 
@@ -564,14 +590,17 @@ class TestSharedNetworks(cloudstackTestCase):
         try:
             # Create Network Offering
             self.shared_network_offering = NetworkOffering.create(
-                                                     self.api_client,
-                                                     self.services["network_offering"],
-                                                     conservemode=False
-                                                     )
-            self.fail("Network offering got created with vlan as True and ip ranges as False in advance mode and with shared guest type, which is invalid case.")
+                self.api_client,
+                self.services["network_offering"],
+                conservemode=False
+            )
+            self.fail(
+                "Network offering got created with vlan as True and ip ranges as False in advance mode and with shared guest type, which is invalid case.")
         except Exception as e:
-            self.debug("Network Offering creation failed with vlan as true and ip ranges as False in advance mode and with shared guest type.\
-                        Exception : %s" % e)
+            self.debug(
+                "Network Offering creation failed with vlan as true and ip ranges as False in advance mode and with shared guest type.\
+                        Exception : %s" %
+                e)
 
     @attr(tags=["advanced", "advancedns"], required_hardware="false")
     def test_createSharedNetwork_All(self):
@@ -609,73 +638,74 @@ class TestSharedNetworks(cloudstackTestCase):
 
         # Create admin account
         self.admin_account = Account.create(
-                                    self.api_client,
-                                    self.services["account"],
-                                    admin=True,
-                                    domainid=self.domain.id
-                                    )
+            self.api_client,
+            self.services["account"],
+            admin=True,
+            domainid=self.domain.id
+        )
 
         self.cleanup_accounts.append(self.admin_account)
 
         # verify that the account got created with state enabled
         list_accounts_response = Account.list(
-                                        self.api_client,
-                                        id=self.admin_account.id,
-                                        listall=True
-                                        )
+            self.api_client,
+            id=self.admin_account.id,
+            listall=True
+        )
         self.assertEqual(
             isinstance(list_accounts_response, list),
             True,
             "listAccounts returned invalid object in response."
-            )
+        )
         self.assertNotEqual(
             len(list_accounts_response),
             0,
             "listAccounts returned empty list."
-            )
+        )
         self.assertEqual(
             list_accounts_response[0].state,
             "enabled",
             "The admin account created is not enabled."
-            )
+        )
 
         self.debug("Admin type account created: %s" % self.admin_account.name)
 
         # Create an user account
         self.user_account = Account.create(
-                                   self.api_client,
-                                   self.services["account"],
-                                   admin=False,
-                                   domainid=self.domain.id
-                                   )
+            self.api_client,
+            self.services["account"],
+            admin=False,
+            domainid=self.domain.id
+        )
 
         self.cleanup_accounts.append(self.user_account)
 
         # verify that the account got created with state enabled
         list_accounts_response = Account.list(
-                                        self.api_client,
-                                        id=self.user_account.id,
-                                        listall=True
-                                        )
+            self.api_client,
+            id=self.user_account.id,
+            listall=True
+        )
         self.assertEqual(
             isinstance(list_accounts_response, list),
             True,
             "listAccounts returned invalid object in response."
-            )
+        )
         self.assertNotEqual(
             len(list_accounts_response),
             0,
             "listAccounts returned empty list."
-            )
+        )
         self.assertEqual(
             list_accounts_response[0].state,
             "enabled",
             "The user account created is not enabled."
-            )
+        )
 
         self.debug("User type account created: %s" % self.user_account.name)
 
-        physical_network, shared_vlan = get_free_vlan(self.api_client, self.zone.id)
+        physical_network, shared_vlan = get_free_vlan(
+            self.api_client, self.zone.id)
         if shared_vlan is None:
             self.fail("Failed to get free vlan id for shared network")
 
@@ -684,165 +714,180 @@ class TestSharedNetworks(cloudstackTestCase):
         self.services["network_offering"]["specifyVlan"] = "True"
         self.services["network_offering"]["specifyIpRanges"] = "True"
 
-
         # Create Network Offering
         self.shared_network_offering = NetworkOffering.create(
-                                                 self.api_client,
-                                                 self.services["network_offering"],
-                                                 conservemode=False
-                                                 )
-
-
+            self.api_client,
+            self.services["network_offering"],
+            conservemode=False
+        )
 
         # Verify that the network offering got created
         list_network_offerings_response = NetworkOffering.list(
-                                                         self.api_client,
-                                                         id=self.shared_network_offering.id
-                                                         )
+            self.api_client,
+            id=self.shared_network_offering.id
+        )
         self.assertEqual(
             isinstance(list_network_offerings_response, list),
             True,
             "listNetworkOfferings returned invalid object in response."
-            )
+        )
         self.assertNotEqual(
             len(list_network_offerings_response),
             0,
             "listNetworkOfferings returned empty list."
-            )
+        )
         self.assertEqual(
             list_network_offerings_response[0].state,
             "Disabled",
             "The network offering created should be bydefault disabled."
-            )
+        )
 
-        self.debug("Shared Network offering created: %s" % self.shared_network_offering.id)
+        self.debug(
+            "Shared Network offering created: %s" %
+            self.shared_network_offering.id)
 
         # Update network offering state from disabled to enabled.
         NetworkOffering.update(
-                                self.shared_network_offering,
-                                self.api_client,
-                                id=self.shared_network_offering.id,
-                                state="enabled"
-                                )
+            self.shared_network_offering,
+            self.api_client,
+            id=self.shared_network_offering.id,
+            state="enabled"
+        )
 
         # Verify that the state of the network offering is updated
         list_network_offerings_response = NetworkOffering.list(
-                                                         self.api_client,
-                                                         id=self.shared_network_offering.id
-                                                         )
+            self.api_client,
+            id=self.shared_network_offering.id
+        )
         self.assertEqual(
             isinstance(list_network_offerings_response, list),
             True,
             "listNetworkOfferings returned invalid object in response."
-            )
+        )
         self.assertNotEqual(
             len(list_network_offerings_response),
             0,
             "listNetworkOfferings returned empty list."
-            )
+        )
         self.assertEqual(
             list_network_offerings_response[0].state,
             "Enabled",
             "The network offering state should get updated to Enabled."
-            )
+        )
 
         # create network using the shared network offering created
         self.services["network"]["acltype"] = "Domain"
-        self.services["network"]["networkofferingid"] = self.shared_network_offering.id
+        self.services["network"][
+            "networkofferingid"] = self.shared_network_offering.id
         self.services["network"]["physicalnetworkid"] = physical_network.id
         self.services["network"]["vlan"] = shared_vlan
 
         self.network = Network.create(
-                         self.api_client,
-                         self.services["network"],
-                         networkofferingid=self.shared_network_offering.id,
-                         zoneid=self.zone.id,
-                         )
+            self.api_client,
+            self.services["network"],
+            networkofferingid=self.shared_network_offering.id,
+            zoneid=self.zone.id,
+        )
 
         self.cleanup_networks.append(self.network)
 
         list_networks_response = Network.list(
-                                        self.api_client,
-                                        id=self.network.id
-                                        )
+            self.api_client,
+            id=self.network.id
+        )
         self.assertEqual(
             isinstance(list_networks_response, list),
             True,
             "listNetworks returned invalid object in response."
-            )
+        )
         self.assertNotEqual(
             len(list_networks_response),
             0,
             "listNetworks returned empty list."
-            )
+        )
         self.assertEqual(
             list_networks_response[0].specifyipranges,
             True,
-            "The network is created with ip range but the flag is set to False."
-            )
+            "The network is created with ip range but the flag is set to False.")
 
-        self.debug("Shared Network created for scope domain: %s" % self.network.id)
+        self.debug(
+            "Shared Network created for scope domain: %s" %
+            self.network.id)
 
         self.admin_account_virtual_machine = VirtualMachine.create(
-                                                       self.api_client,
-                                                       self.services["virtual_machine"],
-                                                       networkids=self.network.id,
-                                                       serviceofferingid=self.service_offering.id
-                                                       )
+            self.api_client,
+            self.services["virtual_machine"],
+            networkids=self.network.id,
+            serviceofferingid=self.service_offering.id
+        )
 
         self.cleanup_vms.append(self.admin_account_virtual_machine)
 
         vms = VirtualMachine.list(
-                            self.api_client,
-                            id=self.admin_account_virtual_machine.id,
-                            listall=True
-                            )
+            self.api_client,
+            id=self.admin_account_virtual_machine.id,
+            listall=True
+        )
         self.assertEqual(
             isinstance(vms, list),
             True,
             "listVirtualMachines returned invalid object in response."
-            )
+        )
         self.assertNotEqual(
             len(vms),
             0,
             "listVirtualMachines returned empty list."
-            )
+        )
 
-        self.debug("Virtual Machine created: %s" % self.admin_account_virtual_machine.id)
+        self.debug(
+            "Virtual Machine created: %s" %
+            self.admin_account_virtual_machine.id)
 
-        ip_range = list(netaddr.iter_iprange(unicode(self.services["network"]["startip"]), unicode(self.services["network"]["endip"])))
+        ip_range = list(
+            netaddr.iter_iprange(
+                unicode(
+                    self.services["network"]["startip"]), unicode(
+                    self.services["network"]["endip"])))
         if netaddr.IPAddress(unicode(vms[0].nic[0].ipaddress)) not in ip_range:
-            self.fail("Virtual machine ip should be from the ip range assigned to network created.")
+            self.fail(
+                "Virtual machine ip should be from the ip range assigned to network created.")
 
         self.user_account_virtual_machine = VirtualMachine.create(
-                                                       self.api_client,
-                                                       self.services["virtual_machine"],
-                                                       accountid=self.user_account.name,
-                                                       domainid=self.user_account.domainid,
-                                                       serviceofferingid=self.service_offering.id,
-                                                       networkids=self.network.id
-                                                       )
+            self.api_client,
+            self.services["virtual_machine"],
+            accountid=self.user_account.name,
+            domainid=self.user_account.domainid,
+            serviceofferingid=self.service_offering.id,
+            networkids=self.network.id
+        )
         vms = VirtualMachine.list(
-                            self.api_client,
-                            id=self.user_account_virtual_machine.id,
-                            listall=True
-                            )
+            self.api_client,
+            id=self.user_account_virtual_machine.id,
+            listall=True
+        )
         self.assertEqual(
             isinstance(vms, list),
             True,
             "listVirtualMachines returned invalid object in response."
-            )
+        )
         self.assertNotEqual(
             len(vms),
             0,
             "listVirtualMachines returned empty list."
-            )
+        )
 
-        self.debug("Virtual Machine created: %s" % self.user_account_virtual_machine.id)
+        self.debug(
+            "Virtual Machine created: %s" %
+            self.user_account_virtual_machine.id)
 
-        ip_range = list(netaddr.iter_iprange(unicode(self.services["network"]["startip"]), unicode(self.services["network"]["endip"])))
+        ip_range = list(
+            netaddr.iter_iprange(
+                unicode(
+                    self.services["network"]["startip"]), unicode(
+                    self.services["network"]["endip"])))
         if netaddr.IPAddress(unicode(vms[0].nic[0].ipaddress)) not in ip_range:
-            self.fail("Virtual machine ip should be from the ip range assigned to network created.")
+            self.fail(
+                "Virtual machine ip should be from the ip range assigned to network created.")
 
     @attr(tags=["advanced", "advancedns"], required_hardware="false")
     def test_createSharedNetwork_accountSpecific(self):
@@ -880,73 +925,74 @@ class TestSharedNetworks(cloudstackTestCase):
 
         # Create admin account
         self.admin_account = Account.create(
-                                     self.api_client,
-                                     self.services["account"],
-                                     admin=True,
-                                     domainid=self.domain.id
-                                     )
+            self.api_client,
+            self.services["account"],
+            admin=True,
+            domainid=self.domain.id
+        )
 
         self.cleanup_accounts.append(self.admin_account)
 
         # verify that the account got created with state enabled
         list_accounts_response = Account.list(
-                                        self.api_client,
-                                        id=self.admin_account.id,
-                                        listall=True
-                                        )
+            self.api_client,
+            id=self.admin_account.id,
+            listall=True
+        )
         self.assertEqual(
             isinstance(list_accounts_response, list),
             True,
             "listAccounts returned invalid object in response."
-            )
+        )
         self.assertNotEqual(
             len(list_accounts_response),
             0,
             "listAccounts returned empty list."
-            )
+        )
         self.assertEqual(
             list_accounts_response[0].state,
             "enabled",
             "The admin account created is not enabled."
-            )
+        )
 
         self.debug("Admin type account created: %s" % self.admin_account.name)
 
         # Create an user account
         self.user_account = Account.create(
-                         self.api_client,
-                         self.services["account"],
-                         admin=False,
-                         domainid=self.domain.id
-                         )
+            self.api_client,
+            self.services["account"],
+            admin=False,
+            domainid=self.domain.id
+        )
 
         self.cleanup_accounts.append(self.user_account)
 
         # verify that the account got created with state enabled
         list_accounts_response = Account.list(
-                                        self.api_client,
-                                        id=self.user_account.id,
-                                        listall=True
-                                        )
+            self.api_client,
+            id=self.user_account.id,
+            listall=True
+        )
         self.assertEqual(
             isinstance(list_accounts_response, list),
             True,
             "listAccounts returned invalid object in response."
-            )
+        )
         self.assertNotEqual(
             len(list_accounts_response),
             0,
             "listAccounts returned empty list."
-            )
+        )
         self.assertEqual(
             list_accounts_response[0].state,
             "enabled",
             "The user account created is not enabled."
-            )
+        )
 
         self.debug("User type account created: %s" % self.user_account.name)
 
-        physical_network, shared_vlan = get_free_vlan(self.api_client, self.zone.id)
+        physical_network, shared_vlan = get_free_vlan(
+            self.api_client, self.zone.id)
         if shared_vlan is None:
             self.fail("Failed to get free vlan id for shared network")
 
@@ -957,141 +1003,151 @@ class TestSharedNetworks(cloudstackTestCase):
 
         # Create Network Offering
         self.shared_network_offering = NetworkOffering.create(
-                                                 self.api_client,
-                                                 self.services["network_offering"],
-                                                 conservemode=False
-                                                 )
+            self.api_client,
+            self.services["network_offering"],
+            conservemode=False
+        )
 
         # Verify that the network offering got created
         list_network_offerings_response = NetworkOffering.list(
-                                                         self.api_client,
-                                                         id=self.shared_network_offering.id
-                                                         )
+            self.api_client,
+            id=self.shared_network_offering.id
+        )
         self.assertEqual(
             isinstance(list_network_offerings_response, list),
             True,
             "listNetworkOfferings returned invalid object in response."
-            )
+        )
         self.assertNotEqual(
             len(list_network_offerings_response),
             0,
             "listNetworkOfferings returned empty list."
-            )
+        )
         self.assertEqual(
             list_network_offerings_response[0].state,
             "Disabled",
             "The network offering created should be by default disabled."
-            )
+        )
 
-        self.debug("Shared Network Offering created: %s" % self.shared_network_offering.id)
+        self.debug(
+            "Shared Network Offering created: %s" %
+            self.shared_network_offering.id)
 
         # Update network offering state from disabled to enabled.
         NetworkOffering.update(
-                                self.shared_network_offering,
-                                self.api_client,
-                                id=self.shared_network_offering.id,
-                                state="enabled"
-                                )
+            self.shared_network_offering,
+            self.api_client,
+            id=self.shared_network_offering.id,
+            state="enabled"
+        )
         # Verify that the state of the network offering is updated
         list_network_offerings_response = NetworkOffering.list(
-                                                         self.api_client,
-                                                         id=self.shared_network_offering.id
-                                                         )
+            self.api_client,
+            id=self.shared_network_offering.id
+        )
         self.assertEqual(
             isinstance(list_network_offerings_response, list),
             True,
             "listNetworkOfferings returned invalid object in response."
-            )
+        )
         self.assertNotEqual(
             len(list_network_offerings_response),
             0,
             "listNetworkOfferings returned empty list."
-            )
+        )
         self.assertEqual(
             list_network_offerings_response[0].state,
             "Enabled",
             "The network offering state should get updated to Enabled."
-            )
+        )
 
         # create network using the shared network offering created
         self.services["network"]["acltype"] = "Account"
-        self.services["network"]["networkofferingid"] = self.shared_network_offering.id
+        self.services["network"][
+            "networkofferingid"] = self.shared_network_offering.id
         self.services["network"]["physicalnetworkid"] = physical_network.id
         self.services["network"]["vlan"] = shared_vlan
 
         self.network = Network.create(
-                         self.api_client,
-                         self.services["network"],
-                         accountid=self.user_account.name,
-                         domainid=self.user_account.domainid,
-                         networkofferingid=self.shared_network_offering.id,
-                         zoneid=self.zone.id
-                         )
+            self.api_client,
+            self.services["network"],
+            accountid=self.user_account.name,
+            domainid=self.user_account.domainid,
+            networkofferingid=self.shared_network_offering.id,
+            zoneid=self.zone.id
+        )
 
         self.cleanup_networks.append(self.network)
 
         list_networks_response = Network.list(
-                                        self.api_client,
-                                        id=self.network.id
-                                        )
+            self.api_client,
+            id=self.network.id
+        )
         self.assertEqual(
             isinstance(list_networks_response, list),
             True,
             "listNetworks returned invalid object in response."
-            )
+        )
         self.assertNotEqual(
             len(list_networks_response),
             0,
             "listNetworks returned empty list."
-            )
+        )
         self.assertEqual(
             list_networks_response[0].specifyipranges,
             True,
-            "The network is created with ip range but the flag is set to False."
-            )
+            "The network is created with ip range but the flag is set to False.")
 
         self.debug("Network created: %s" % self.network.id)
 
         try:
             self.admin_account_virtual_machine = VirtualMachine.create(
-                                                           self.api_client,
-                                                           self.services["virtual_machine"],
-                                                           accountid=self.admin_account.name,
-                                                           domainid=self.admin_account.domainid,
-                                                           networkids=self.network.id,
-                                                           serviceofferingid=self.service_offering.id
-                                                           )
-            self.fail("Virtual Machine got created in admin account with network created but the network used is of scope account and for user account.")
+                self.api_client,
+                self.services["virtual_machine"],
+                accountid=self.admin_account.name,
+                domainid=self.admin_account.domainid,
+                networkids=self.network.id,
+                serviceofferingid=self.service_offering.id
+            )
+            self.fail(
+                "Virtual Machine got created in admin account with network created but the network used is of scope account and for user account.")
         except Exception as e:
-            self.debug("Virtual Machine creation failed as network used have scoped only for user account. Exception: %s" % e)
+            self.debug(
+                "Virtual Machine creation failed as network used have scoped only for user account. Exception: %s" %
+                e)
 
         self.user_account_virtual_machine = VirtualMachine.create(
-                                                       self.api_client,
-                                                       self.services["virtual_machine"],
-                                                       accountid=self.user_account.name,
-                                                       domainid=self.user_account.domainid,
-                                                       networkids=self.network.id,
-                                                       serviceofferingid=self.service_offering.id
-                                                       )
+            self.api_client,
+            self.services["virtual_machine"],
+            accountid=self.user_account.name,
+            domainid=self.user_account.domainid,
+            networkids=self.network.id,
+            serviceofferingid=self.service_offering.id
+        )
         vms = VirtualMachine.list(
-                            self.api_client,
-                            id=self.user_account_virtual_machine.id,
-                            listall=True
-                            )
+            self.api_client,
+            id=self.user_account_virtual_machine.id,
+            listall=True
+        )
         self.assertEqual(
             isinstance(vms, list),
             True,
             "listVirtualMachines returned invalid object in response."
-            )
+        )
         self.assertNotEqual(
             len(vms),
             0,
             "listVirtualMachines returned empty list."
-            )
+        )
 
-        ip_range = list(netaddr.iter_iprange(unicode(self.services["network"]["startip"]), unicode(self.services["network"]["endip"])))
+        ip_range = list(
+            netaddr.iter_iprange(
+                unicode(
+                    self.services["network"]["startip"]), unicode(
+                    self.services["network"]["endip"])))
         if netaddr.IPAddress(unicode(vms[0].nic[0].ipaddress)) not in ip_range:
-            self.fail("Virtual machine ip should be from the ip range assigned to network created.")
+            self.fail(
+                "Virtual machine ip should be from the ip range assigned to network created.")
 
     @attr(tags=["advanced", "advancedns"], required_hardware="false")
     def test_createSharedNetwork_domainSpecific(self):
@@ -1131,133 +1187,138 @@ class TestSharedNetworks(cloudstackTestCase):
 
         # Create admin account
         self.admin_account = Account.create(
-                                     self.api_client,
-                                     self.services["account"],
-                                     admin=True,
-                                     domainid=self.domain.id
-                                     )
+            self.api_client,
+            self.services["account"],
+            admin=True,
+            domainid=self.domain.id
+        )
 
         self.cleanup_accounts.append(self.admin_account)
 
         # verify that the account got created with state enabled
         list_accounts_response = Account.list(
-                                        self.api_client,
-                                        id=self.admin_account.id,
-                                        listall=True
-                                        )
+            self.api_client,
+            id=self.admin_account.id,
+            listall=True
+        )
         self.assertEqual(
             isinstance(list_accounts_response, list),
             True,
             "listAccounts returned invalid object in response."
-            )
+        )
         self.assertNotEqual(
             len(list_accounts_response),
             0,
             "listAccounts returned empty list."
-            )
+        )
         self.assertEqual(
             list_accounts_response[0].state,
             "enabled",
             "The admin account created is not enabled."
-            )
+        )
 
         self.debug("Admin type account created: %s" % self.admin_account.id)
 
         # create domain
         self.dom_domain = Domain.create(
-                                self.api_client,
-                                self.services["domain"],
-                                )
+            self.api_client,
+            self.services["domain"],
+        )
 
         self.cleanup_domains.append(self.dom_domain)
 
         # verify that the account got created with state enabled
         list_domains_response = Domain.list(
-                                      self.api_client,
-                                      id=self.dom_domain.id
-                                      )
+            self.api_client,
+            id=self.dom_domain.id
+        )
         self.assertEqual(
             isinstance(list_domains_response, list),
             True,
             "listDomains returned invalid object in response."
-            )
+        )
         self.assertNotEqual(
             len(list_domains_response),
             0,
             "listDomains returned empty list."
-            )
+        )
 
         self.debug("Domain created: %s" % self.dom_domain.id)
 
         # Create admin account
         self.domain_admin_account = Account.create(
-                                     self.api_client,
-                                     self.services["account"],
-                                     admin=True,
-                                     domainid=self.dom_domain.id
-                                     )
+            self.api_client,
+            self.services["account"],
+            admin=True,
+            domainid=self.dom_domain.id
+        )
 
         self.cleanup_accounts.append(self.domain_admin_account)
 
         # verify that the account got created with state enabled
         list_accounts_response = Account.list(
-                                        self.api_client,
-                                        id=self.domain_admin_account.id,
-                                        listall=True
-                                        )
+            self.api_client,
+            id=self.domain_admin_account.id,
+            listall=True
+        )
         self.assertEqual(
             isinstance(list_accounts_response, list),
             True,
             "listAccounts returned invalid object in response."
-            )
+        )
         self.assertNotEqual(
             len(list_accounts_response),
             0,
             "listAccounts returned empty list."
-            )
+        )
         self.assertEqual(
             list_accounts_response[0].state,
             "enabled",
             "The domain admin account created is not enabled."
-            )
+        )
 
-        self.debug("Domain admin account created: %s" % self.domain_admin_account.id)
+        self.debug(
+            "Domain admin account created: %s" %
+            self.domain_admin_account.id)
 
         # Create an user account
         self.domain_user_account = Account.create(
-                         self.api_client,
-                         self.services["account"],
-                         admin=False,
-                         domainid=self.dom_domain.id
-                         )
+            self.api_client,
+            self.services["account"],
+            admin=False,
+            domainid=self.dom_domain.id
+        )
 
         self.cleanup_accounts.append(self.domain_user_account)
 
         # verify that the account got created with state enabled
         list_accounts_response = Account.list(
-                                        self.api_client,
-                                        id=self.domain_user_account.id,
-                                        listall=True
-                                        )
+            self.api_client,
+            id=self.domain_user_account.id,
+            listall=True
+        )
         self.assertEqual(
             isinstance(list_accounts_response, list),
             True,
             "listAccounts returned invalid object in response."
-            )
+        )
         self.assertNotEqual(
             len(list_accounts_response),
             0,
             "listAccounts returned empty list."
-            )
+        )
         self.assertEqual(
             list_accounts_response[0].state,
             "enabled",
             "The domain user account created is not enabled."
-            )
+        )
 
-        self.debug("Domain user account created: %s" % self.domain_user_account.id)
+        self.debug(
+            "Domain user account created: %s" %
+            self.domain_user_account.id)
 
-        physical_network, shared_vlan = get_free_vlan(self.api_client, self.zone.id)
+        physical_network, shared_vlan = get_free_vlan(
+            self.api_client, self.zone.id)
         if shared_vlan is None:
             self.fail("Failed to get free vlan id for shared network")
 
@@ -1268,174 +1329,188 @@ class TestSharedNetworks(cloudstackTestCase):
 
         # Create Network Offering
         self.shared_network_offering = NetworkOffering.create(
-                                                 self.api_client,
-                                                 self.services["network_offering"],
-                                                 conservemode=False
-                                                 )
-
+            self.api_client,
+            self.services["network_offering"],
+            conservemode=False
+        )
 
         # Verify that the network offering got created
         list_network_offerings_response = NetworkOffering.list(
-                                                         self.api_client,
-                                                         id=self.shared_network_offering.id
-                                                         )
+            self.api_client,
+            id=self.shared_network_offering.id
+        )
         self.assertEqual(
             isinstance(list_network_offerings_response, list),
             True,
             "listNetworkOfferings returned invalid object in response."
-            )
+        )
         self.assertNotEqual(
             len(list_network_offerings_response),
             0,
             "listNetworkOfferings returned empty list."
-            )
+        )
         self.assertEqual(
             list_network_offerings_response[0].state,
             "Disabled",
             "The network offering created should be by default disabled."
-            )
+        )
 
-        self.debug("Shared Network Offering created: %s" % self.shared_network_offering.id)
+        self.debug(
+            "Shared Network Offering created: %s" %
+            self.shared_network_offering.id)
 
         # Update network offering state from disabled to enabled.
         NetworkOffering.update(
-                                self.shared_network_offering,
-                                self.api_client,
-                                id=self.shared_network_offering.id,
-                                state="enabled"
-                                )
+            self.shared_network_offering,
+            self.api_client,
+            id=self.shared_network_offering.id,
+            state="enabled"
+        )
 
         # Verify that the state of the network offering is updated
         list_network_offerings_response = NetworkOffering.list(
-                                                         self.api_client,
-                                                         id=self.shared_network_offering.id
-                                                         )
+            self.api_client,
+            id=self.shared_network_offering.id
+        )
         self.assertEqual(
             isinstance(list_network_offerings_response, list),
             True,
             "listNetworkOfferings returned invalid object in response."
-            )
+        )
         self.assertNotEqual(
             len(list_network_offerings_response),
             0,
             "listNetworkOfferings returned empty list."
-            )
+        )
         self.assertEqual(
             list_network_offerings_response[0].state,
             "Enabled",
             "The network offering state should get updated to Enabled."
-            )
+        )
 
         # create network using the shared network offering created
         self.services["network"]["acltype"] = "domain"
-        self.services["network"]["networkofferingid"] = self.shared_network_offering.id
+        self.services["network"][
+            "networkofferingid"] = self.shared_network_offering.id
         self.services["network"]["physicalnetworkid"] = physical_network.id
         self.services["network"]["vlan"] = shared_vlan
 
         self.network = Network.create(
-                         self.api_client,
-                         self.services["network"],
-                         accountid=self.domain_admin_account.name,
-                         domainid=self.dom_domain.id,
-                         networkofferingid=self.shared_network_offering.id,
-                         zoneid=self.zone.id
-                         )
+            self.api_client,
+            self.services["network"],
+            accountid=self.domain_admin_account.name,
+            domainid=self.dom_domain.id,
+            networkofferingid=self.shared_network_offering.id,
+            zoneid=self.zone.id
+        )
 
         self.cleanup_networks.append(self.network)
 
         list_networks_response = Network.list(
-                                        self.api_client,
-                                        id=self.network.id,
-                                        listall=True
-                                        )
+            self.api_client,
+            id=self.network.id,
+            listall=True
+        )
         self.assertEqual(
             isinstance(list_networks_response, list),
             True,
             "listNetworks returned invalid object in response."
-            )
+        )
         self.assertNotEqual(
             len(list_networks_response),
             0,
             "listNetworks returned empty list."
-            )
+        )
         self.assertEqual(
             list_networks_response[0].specifyipranges,
             True,
-            "The network is created with ip range but the flag is set to False."
-            )
+            "The network is created with ip range but the flag is set to False.")
 
         self.debug("Shared Network created: %s" % self.network.id)
 
         try:
             self.admin_account_virtual_machine = VirtualMachine.create(
-                                                           self.api_client,
-                                                           self.services["virtual_machine"],
-                                                           accountid=self.admin_account.name,
-                                                           domainid=self.admin_account.domainid,
-                                                           networkids=self.network.id,
-                                                           serviceofferingid=self.service_offering.id
-                                                           )
-            self.fail("Virtual Machine got created in admin account with network specified but the network used is of scope domain and admin account is not part of this domain.")
+                self.api_client,
+                self.services["virtual_machine"],
+                accountid=self.admin_account.name,
+                domainid=self.admin_account.domainid,
+                networkids=self.network.id,
+                serviceofferingid=self.service_offering.id
+            )
+            self.fail(
+                "Virtual Machine got created in admin account with network specified but the network used is of scope domain and admin account is not part of this domain.")
         except Exception as e:
-            self.debug("Virtual Machine creation failed as network used have scoped only for DOM domain. Exception: %s" % e)
+            self.debug(
+                "Virtual Machine creation failed as network used have scoped only for DOM domain. Exception: %s" %
+                e)
 
         self.domain_user_account_virtual_machine = VirtualMachine.create(
-                                                       self.api_client,
-                                                       self.services["virtual_machine"],
-                                                       accountid=self.domain_user_account.name,
-                                                       domainid=self.domain_user_account.domainid,
-                                                       networkids=self.network.id,
-                                                       serviceofferingid=self.service_offering.id
-                                                       )
+            self.api_client,
+            self.services["virtual_machine"],
+            accountid=self.domain_user_account.name,
+            domainid=self.domain_user_account.domainid,
+            networkids=self.network.id,
+            serviceofferingid=self.service_offering.id
+        )
         self.cleanup_vms.append(self.domain_user_account_virtual_machine)
         vms = VirtualMachine.list(
-                            self.api_client,
-                            id=self.domain_user_account_virtual_machine.id,
-                            listall=True
-                            )
+            self.api_client,
+            id=self.domain_user_account_virtual_machine.id,
+            listall=True
+        )
         self.assertEqual(
             isinstance(vms, list),
             True,
             "listVirtualMachines returned invalid object in response."
-            )
+        )
         self.assertNotEqual(
             len(vms),
             0,
             "listVirtualMachines returned empty list."
-            )
+        )
 
-        ip_range = list(netaddr.iter_iprange(unicode(self.services["network"]["startip"]), unicode(self.services["network"]["endip"])))
+        ip_range = list(
+            netaddr.iter_iprange(
+                unicode(
+                    self.services["network"]["startip"]), unicode(
+                    self.services["network"]["endip"])))
         if netaddr.IPAddress(unicode(vms[0].nic[0].ipaddress)) not in ip_range:
-            self.fail("Virtual machine ip should be from the ip range assigned to network created.")
+            self.fail(
+                "Virtual machine ip should be from the ip range assigned to network created.")
 
         self.domain_admin_account_virtual_machine = VirtualMachine.create(
-                                                       self.api_client,
-                                                       self.services["virtual_machine"],
-                                                       accountid=self.domain_admin_account.name,
-                                                       domainid=self.domain_admin_account.domainid,
-                                                       networkids=self.network.id,
-                                                       serviceofferingid=self.service_offering.id
-                                                       )
+            self.api_client,
+            self.services["virtual_machine"],
+            accountid=self.domain_admin_account.name,
+            domainid=self.domain_admin_account.domainid,
+            networkids=self.network.id,
+            serviceofferingid=self.service_offering.id
+        )
         self.cleanup_vms.append(self.domain_admin_account_virtual_machine)
         vms = VirtualMachine.list(
-                            self.api_client,
-                            id=self.domain_admin_account_virtual_machine.id,
-                            listall=True
-                            )
+            self.api_client,
+            id=self.domain_admin_account_virtual_machine.id,
+            listall=True
+        )
         self.assertEqual(
             isinstance(vms, list),
             True,
             "listVirtualMachines returned invalid object in response."
-            )
+        )
         self.assertNotEqual(
             len(vms),
             0,
             "listVirtualMachines returned empty list."
-            )
+        )
 
-        ip_range = list(netaddr.iter_iprange(unicode(self.services["network"]["startip"]), unicode(self.services["network"]["endip"])))
+        ip_range = list(
+            netaddr.iter_iprange(
+                unicode(
+                    self.services["network"]["startip"]), unicode(
+                    self.services["network"]["endip"])))
         if netaddr.IPAddress(unicode(vms[0].nic[0].ipaddress)) not in ip_range:
-            self.fail("Virtual machine ip should be from the ip range assigned to network created.")
+            self.fail(
+                "Virtual machine ip should be from the ip range assigned to network created.")
 
     @attr(tags=["advanced", "advancedns"], required_hardware="false")
     def test_createSharedNetwork_projectSpecific(self):
@@ -1474,35 +1549,35 @@ class TestSharedNetworks(cloudstackTestCase):
 
         # Create admin account
         self.admin_account = Account.create(
-                                     self.api_client,
-                                     self.services["account"],
-                                     admin=True,
-                                     domainid=self.domain.id
-                                     )
+            self.api_client,
+            self.services["account"],
+            admin=True,
+            domainid=self.domain.id
+        )
 
         self.cleanup_accounts.append(self.admin_account)
 
         # verify that the account got created with state enabled
         list_accounts_response = Account.list(
-                                        self.api_client,
-                                        id=self.admin_account.id,
-                                        listall=True
-                                        )
+            self.api_client,
+            id=self.admin_account.id,
+            listall=True
+        )
         self.assertEqual(
             isinstance(list_accounts_response, list),
             True,
             "listAccounts returned invalid object in response."
-            )
+        )
         self.assertNotEqual(
             len(list_accounts_response),
             0,
             "listAccounts returned empty list."
-            )
+        )
         self.assertEqual(
             list_accounts_response[0].state,
             "enabled",
             "The admin account created is not enabled."
-            )
+        )
 
         self.debug("Admin account created: %s" % self.admin_account.id)
 
@@ -1510,29 +1585,29 @@ class TestSharedNetworks(cloudstackTestCase):
         self.services["project"]["displaytext"] = "proj-SADJKS"
 
         self.project1 = Project.create(
-                                 self.api_client,
-                                 self.services["project"],
-                                 account=self.admin_account.name,
-                                 domainid=self.admin_account.domainid
-                                 )
+            self.api_client,
+            self.services["project"],
+            account=self.admin_account.name,
+            domainid=self.admin_account.domainid
+        )
 
         self.cleanup_projects.append(self.project1)
 
         list_projects_response = Project.list(
-                                        self.api_client,
-                                        id=self.project1.id,
-                                        listall=True
-                                        )
+            self.api_client,
+            id=self.project1.id,
+            listall=True
+        )
         self.assertEqual(
             isinstance(list_projects_response, list),
             True,
             "listProjects returned invalid object in response."
-            )
+        )
         self.assertNotEqual(
             len(list_projects_response),
             0,
             "listProjects should return at least one."
-            )
+        )
 
         self.debug("Project created: %s" % self.project1.id)
 
@@ -1540,33 +1615,34 @@ class TestSharedNetworks(cloudstackTestCase):
         self.services["project"]["displaytext"] = "proj-SLDJK"
 
         self.project2 = Project.create(
-                                 self.api_client,
-                                 self.services["project"],
-                                 account=self.admin_account.name,
-                                 domainid=self.admin_account.domainid
-                                 )
+            self.api_client,
+            self.services["project"],
+            account=self.admin_account.name,
+            domainid=self.admin_account.domainid
+        )
 
         self.cleanup_projects.append(self.project2)
 
         list_projects_response = Project.list(
-                                        self.api_client,
-                                        id=self.project2.id,
-                                        listall=True
-                                        )
+            self.api_client,
+            id=self.project2.id,
+            listall=True
+        )
         self.assertEqual(
             isinstance(list_projects_response, list),
             True,
             "listProjects returned invalid object in response."
-            )
+        )
         self.assertNotEqual(
             len(list_projects_response),
             0,
             "listProjects should return at least one."
-            )
+        )
 
         self.debug("Project2 created: %s" % self.project2.id)
 
-        physical_network, shared_vlan = get_free_vlan(self.api_client, self.zone.id)
+        physical_network, shared_vlan = get_free_vlan(
+            self.api_client, self.zone.id)
         if shared_vlan is None:
             self.fail("Failed to get free vlan id for shared network")
 
@@ -1575,145 +1651,150 @@ class TestSharedNetworks(cloudstackTestCase):
         self.services["network_offering"]["specifyVlan"] = "True"
         self.services["network_offering"]["specifyIpRanges"] = "True"
 
-
         # Create Network Offering
         self.shared_network_offering = NetworkOffering.create(
-                                                 self.api_client,
-                                                 self.services["network_offering"],
-                                                 conservemode=False
-                                                 )
-
+            self.api_client,
+            self.services["network_offering"],
+            conservemode=False
+        )
 
         # Verify that the network offering got created
         list_network_offerings_response = NetworkOffering.list(
-                                                         self.api_client,
-                                                         id=self.shared_network_offering.id
-                                                         )
+            self.api_client,
+            id=self.shared_network_offering.id
+        )
         self.assertEqual(
             isinstance(list_network_offerings_response, list),
             True,
             "listNetworkOfferings returned invalid object in response."
-            )
+        )
         self.assertNotEqual(
             len(list_network_offerings_response),
             0,
             "listNetworkOfferings returned empty list."
-            )
+        )
         self.assertEqual(
             list_network_offerings_response[0].state,
             "Disabled",
             "The network offering created should be by default disabled."
-            )
+        )
 
         # Update network offering state from disabled to enabled.
         NetworkOffering.update(
-                                self.shared_network_offering,
-                                self.api_client,
-                                id=self.shared_network_offering.id,
-                                state="enabled"
-                                )
+            self.shared_network_offering,
+            self.api_client,
+            id=self.shared_network_offering.id,
+            state="enabled"
+        )
 
         # Verify that the state of the network offering is updated
         list_network_offerings_response = NetworkOffering.list(
-                                                         self.api_client,
-                                                         id=self.shared_network_offering.id
-                                                         )
+            self.api_client,
+            id=self.shared_network_offering.id
+        )
         self.assertEqual(
             isinstance(list_network_offerings_response, list),
             True,
             "listNetworkOfferings returned invalid object in response."
-            )
+        )
         self.assertNotEqual(
             len(list_network_offerings_response),
             0,
             "listNetworkOfferings returned empty list."
-            )
+        )
         self.assertEqual(
             list_network_offerings_response[0].state,
             "Enabled",
             "The network offering state should get updated to Enabled."
-            )
+        )
 
-        self.debug("Shared Network found: %s" % self.shared_network_offering.id)
+        self.debug(
+            "Shared Network found: %s" %
+            self.shared_network_offering.id)
 
         # create network using the shared network offering created
         self.services["network"]["acltype"] = "account"
-        self.services["network"]["networkofferingid"] = self.shared_network_offering.id
+        self.services["network"][
+            "networkofferingid"] = self.shared_network_offering.id
         self.services["network"]["physicalnetworkid"] = physical_network.id
         self.services["network"]["vlan"] = shared_vlan
 
         self.network = Network.create(
-                         self.api_client,
-                         self.services["network"],
-                         projectid=self.project1.id,
-                         domainid=self.admin_account.domainid,
-                         networkofferingid=self.shared_network_offering.id,
-                         zoneid=self.zone.id
-                         )
+            self.api_client,
+            self.services["network"],
+            projectid=self.project1.id,
+            domainid=self.admin_account.domainid,
+            networkofferingid=self.shared_network_offering.id,
+            zoneid=self.zone.id
+        )
         self.cleanup_networks.append(self.network)
 
         list_networks_response = Network.list(
-                                        self.api_client,
-                                        id=self.network.id,
-                    projectid=self.project1.id,
-                    listall=True
-                                        )
+            self.api_client,
+            id=self.network.id,
+            projectid=self.project1.id,
+            listall=True
+        )
         self.assertEqual(
             isinstance(list_networks_response, list),
             True,
             "listNetworks returned invalid object in response."
-            )
+        )
         self.assertNotEqual(
             len(list_networks_response),
             0,
             "listNetworks returned empty list."
-            )
+        )
         self.assertEqual(

<TRUNCATED>

[44/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
CLOUDSTACK-8296 VMs cannot be migrated with XenMotion as network is not available.


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

Branch: refs/heads/reporter
Commit: 736c7d7668796af96f223a2c6cd82aac6789a2ee
Parents: 58c5850
Author: Sanjay Tripathi <sa...@citrix.com>
Authored: Mon Mar 2 11:22:49 2015 +0530
Committer: Sanjay Tripathi <sa...@citrix.com>
Committed: Tue Mar 3 13:14:04 2015 +0530

----------------------------------------------------------------------
 .../hypervisor/xenserver/resource/XenServer610Resource.java    | 6 ++++++
 1 file changed, 6 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/736c7d76/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServer610Resource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServer610Resource.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServer610Resource.java
index 5e3f95c..2283477 100644
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServer610Resource.java
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XenServer610Resource.java
@@ -132,6 +132,12 @@ public class XenServer610Resource extends XenServer600Resource {
 
         try {
             prepareISO(connection, vmSpec.getName());
+
+            // Get the list of networks and recreate VLAN, if required.
+            for (NicTO nicTo : vmSpec.getNics()) {
+                getNetwork(connection, nicTo);
+            }
+
             Map<String, String> other = new HashMap<String, String>();
             other.put("live", "true");
             Network networkForSm = getNativeNetworkForTraffic(connection, TrafficType.Storage, null).getNetwork();


[49/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
listDirectory method updated to use ObjectListing.isTruncated().

Because buckets can contain a virtually unlimited number of keys, the
complete results of a list query can be extremely large. To manage large
result sets, Amazon S3 uses pagination to split them into multiple
responses.

Signed-off-by: Rajani Karuturi <ra...@gmail.com>

This closes #25


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

Branch: refs/heads/reporter
Commit: 0b6c540a203453580bb76a0d0a60be292fccfa0e
Parents: 7c1590f
Author: santhosh <sa...@47line.com>
Authored: Fri Oct 24 21:15:29 2014 +0530
Committer: Rajani Karuturi <ra...@gmail.com>
Committed: Wed Mar 4 12:52:48 2015 +0530

----------------------------------------------------------------------
 utils/src/com/cloud/utils/S3Utils.java | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0b6c540a/utils/src/com/cloud/utils/S3Utils.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/S3Utils.java b/utils/src/com/cloud/utils/S3Utils.java
index d9b850d..37aeb91 100644
--- a/utils/src/com/cloud/utils/S3Utils.java
+++ b/utils/src/com/cloud/utils/S3Utils.java
@@ -57,13 +57,14 @@ import com.amazonaws.services.s3.AmazonS3Client;
 import com.amazonaws.services.s3.model.Bucket;
 import com.amazonaws.services.s3.model.CannedAccessControlList;
 import com.amazonaws.services.s3.model.GetObjectRequest;
+import com.amazonaws.services.s3.model.ListObjectsRequest;
+import com.amazonaws.services.s3.model.ObjectListing;
 import com.amazonaws.services.s3.model.ObjectMetadata;
 import com.amazonaws.services.s3.model.PutObjectRequest;
 import com.amazonaws.services.s3.model.S3Object;
 import com.amazonaws.services.s3.model.S3ObjectSummary;
 import com.amazonaws.services.s3.transfer.TransferManager;
 import com.amazonaws.services.s3.transfer.Upload;
-
 import com.cloud.utils.exception.CloudRuntimeException;
 
 public final class S3Utils {
@@ -338,9 +339,19 @@ public final class S3Utils {
 
     private static List<S3ObjectSummary> listDirectory(final String bucketName, final String directory, final AmazonS3 client) {
 
-        final List<S3ObjectSummary> objects = client.listObjects(bucketName, directory + SEPARATOR).getObjectSummaries();
-
-        if (objects == null) {
+   	 List<S3ObjectSummary> objects = new ArrayList<S3ObjectSummary>();
+   	 ListObjectsRequest listObjectsRequest = new ListObjectsRequest().withBucketName(bucketName).withPrefix(directory + SEPARATOR);
+   	 ObjectListing objectListing;
+
+   	 do {
+   	 	objectListing = client.listObjects(listObjectsRequest);
+   	 	
+   	 	if (objectListing != null )
+   	 		objects.addAll(objectListing.getObjectSummaries());
+   	 	listObjectsRequest.setMarker(objectListing.getNextMarker());
+   	 } while (objectListing.isTruncated());
+        
+        if (objects.isEmpty()) {
             return emptyList();
         }
 


[25/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
server: fix unit test to fix build

Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
(cherry picked from commit dd5fb2ebd6904026e2ba0b3efcb6c382f860ffdd)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/reporter
Commit: 3786aa0e67c3ae0981699b8194ed4e90ca7494e1
Parents: 43cf1da
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Fri Feb 27 19:18:18 2015 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Fri Feb 27 19:19:09 2015 +0530

----------------------------------------------------------------------
 server/test/com/cloud/user/AccountManagerImplTest.java | 11 +++++++++++
 1 file changed, 11 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3786aa0e/server/test/com/cloud/user/AccountManagerImplTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/user/AccountManagerImplTest.java b/server/test/com/cloud/user/AccountManagerImplTest.java
index 5fff331..f70aa39 100644
--- a/server/test/com/cloud/user/AccountManagerImplTest.java
+++ b/server/test/com/cloud/user/AccountManagerImplTest.java
@@ -18,6 +18,7 @@ package com.cloud.user;
 
 import java.lang.reflect.Field;
 import java.util.Arrays;
+import java.util.ArrayList;
 
 import javax.inject.Inject;
 
@@ -40,6 +41,10 @@ import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 import org.apache.cloudstack.framework.messagebus.MessageBus;
 import org.apache.cloudstack.region.gslb.GlobalLoadBalancerRuleDao;
 
+import com.cloud.vm.snapshot.VMSnapshotManager;
+import com.cloud.vm.snapshot.VMSnapshotVO;
+import com.cloud.vm.snapshot.dao.VMSnapshotDao;
+
 import com.cloud.configuration.ConfigurationManager;
 import com.cloud.configuration.dao.ResourceCountDao;
 import com.cloud.configuration.dao.ResourceLimitDao;
@@ -178,6 +183,11 @@ public class AccountManagerImplTest {
     MessageBus _messageBus;
 
     @Mock
+    VMSnapshotManager _vmSnapshotMgr;
+    @Mock
+    VMSnapshotDao _vmSnapshotDao;
+
+    @Mock
     User callingUser;
     @Mock
     Account callingAccount;
@@ -264,6 +274,7 @@ public class AccountManagerImplTest {
                 securityChecker.checkAccess(Mockito.any(Account.class),
                         Mockito.any(Domain.class)))
                 .thenReturn(true);
+        Mockito.when(_vmSnapshotDao.listByAccountId(Mockito.anyLong())).thenReturn(new ArrayList<VMSnapshotVO>());
 
         Assert.assertTrue(accountManager.deleteUserAccount(42));
         // assert that this was a clean delete


[39/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
Merge remote-tracking branch 'laszlo/CLOUDSTACK-8279'

This closes #90

Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/reporter
Commit: 541c23ed07ffee30861926a2d0e84ddf0f3b9ef4
Parents: 62e179b df11bb2
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Mon Mar 2 16:35:27 2015 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Mon Mar 2 16:35:36 2015 +0530

----------------------------------------------------------------------
 .../api/routing/SetFirewallRulesCommand.java    |   4 +-
 .../VirtualRoutingResourceTest.java             | 212 +++++++++++--------
 2 files changed, 124 insertions(+), 92 deletions(-)
----------------------------------------------------------------------



[29/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
CLOUDSTACK-8279: Fix unit test for java 1.8

Signed-off-by: Laszlo Hornyak <la...@gmail.com>


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

Branch: refs/heads/reporter
Commit: df11bb28110d49b5a46790c351a3f309b5c6569e
Parents: f8c003d
Author: Laszlo Hornyak <la...@gmail.com>
Authored: Fri Feb 27 20:06:27 2015 +0100
Committer: Laszlo Hornyak <la...@gmail.com>
Committed: Fri Feb 27 20:06:27 2015 +0100

----------------------------------------------------------------------
 .../resource/virtualnetwork/VirtualRoutingResourceTest.java  | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/df11bb28/core/test/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResourceTest.java
----------------------------------------------------------------------
diff --git a/core/test/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResourceTest.java b/core/test/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResourceTest.java
index 6d7ff29..c6189c5 100644
--- a/core/test/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResourceTest.java
+++ b/core/test/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResourceTest.java
@@ -674,7 +674,13 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
 
     private void verifyArgs(SetFirewallRulesCommand cmd, String script, String args) {
         assertEquals(script, VRScripts.FIREWALL_INGRESS);
-        assertEquals(args, " -F -a 64.10.10.10:ICMP:0:0:10.10.1.1/24-10.10.1.2/24:,64.10.10.10:TCP:22:80:10.10.1.1/24-10.10.1.2/24:,64.10.10.10:reverted:0:0:0:,");
+
+        //Since the arguments are generated with a Set
+        //one can not make a bet on the order
+        assertTrue(args.startsWith(" -F -a "));
+        assertTrue(args.contains("64.10.10.10:ICMP:0:0:10.10.1.1/24-10.10.1.2/24:"));
+        assertTrue(args.contains("64.10.10.10:reverted:0:0:0:"));
+        assertTrue(args.contains("64.10.10.10:TCP:22:80:10.10.1.1/24-10.10.1.2/24:"));
     }
 
     @Test


[03/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
Update messages.properties

Instances ca be scaled up or down, no only up.

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

Branch: refs/heads/reporter
Commit: 81378c49de0143c6b9c4b2c145c8884b5bf6b93e
Parents: 09e26c8
Author: NuxRo <nu...@li.nux.ro>
Authored: Mon Feb 23 16:01:42 2015 +0000
Committer: NuxRo <nu...@li.nux.ro>
Committed: Mon Feb 23 16:01:42 2015 +0000

----------------------------------------------------------------------
 client/WEB-INF/classes/resources/messages.properties | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/81378c49/client/WEB-INF/classes/resources/messages.properties
----------------------------------------------------------------------
diff --git a/client/WEB-INF/classes/resources/messages.properties b/client/WEB-INF/classes/resources/messages.properties
index b46be06..a4e4e1a 100644
--- a/client/WEB-INF/classes/resources/messages.properties
+++ b/client/WEB-INF/classes/resources/messages.properties
@@ -1322,7 +1322,7 @@ label.remove.vpc.offering=Remove VPC offering
 label.vpc.distributedvpcrouter=Distributed VPC Router
 label.vpc.supportsregionlevelvpc=Supports Region Level VPC
 label.dynamically.scalable=Dynamically Scalable
-label.instance.scaled.up=Instance Scaled Up
+label.instance.scaled.up=Instance Scaled
 label.tag.key=Tag Key
 label.tag.value=Tag Value
 label.ipv6.address=IPv6 IP Address


[36/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
CLOUDSTACK-8294: fix for java 1.8 build

The test testFindSecurityProfileByUuid built an assumptio on the order of the arguments after transforming through a HashMap.

Signed-off-by: Laszlo Hornyak <la...@gmail.com>


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

Branch: refs/heads/reporter
Commit: 873649eb3b52f2ec25c0e60d2a2465f95c97e428
Parents: ed099c3
Author: Laszlo Hornyak <la...@gmail.com>
Authored: Sun Mar 1 13:20:51 2015 +0100
Committer: Laszlo Hornyak <la...@gmail.com>
Committed: Sun Mar 1 13:20:51 2015 +0100

----------------------------------------------------------------------
 .../cloud/network/nicira/NiciraNvpApiTest.java  | 21 ++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/873649eb/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java
index 51964bf..1435cc5 100644
--- a/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java
+++ b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java
@@ -20,12 +20,18 @@
 package com.cloud.network.nicira;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Matchers.any;
 
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
 
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.HttpMethod;
@@ -38,10 +44,11 @@ import org.apache.commons.httpclient.methods.PutMethod;
 import org.apache.commons.httpclient.params.HttpClientParams;
 import org.junit.Before;
 import org.junit.Test;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
 
 import com.google.gson.Gson;
 import com.google.gson.JsonParseException;
-
 import com.cloud.utils.rest.RESTServiceConnector;
 import com.cloud.utils.rest.RESTValidationStrategy;
 
@@ -144,13 +151,23 @@ public class NiciraNvpApiTest {
                 new NameValuePair("uuid", UUID),
                 new NameValuePair("fields","*")
         };
+        final List<NameValuePair> queryStringNvps = new ArrayList<>();
+        doAnswer(new Answer<Void>() {
+
+            @Override
+            public Void answer(InvocationOnMock invocation) throws Throwable {
+                final NameValuePair[] arguments = (NameValuePair[]) invocation.getArguments()[0];
+                queryStringNvps.addAll(Arrays.asList(arguments));
+                return null;
+            }}).when(method).setQueryString(any(NameValuePair[].class));
 
         // Execute
         final NiciraNvpList<SecurityProfile> actualProfiles = api.findSecurityProfile(UUID);
 
         // Assert
         verify(method, times(1)).releaseConnection();
-        verify(method, times(1)).setQueryString(queryString);
+        assertTrue(queryStringNvps.containsAll(Arrays.asList(queryString)));
+        assertEquals(queryString.length, queryStringNvps.size());
         assertEquals("Wrong Uuid in the newly created SecurityProfile",
                 UUID, actualProfiles.getResults().get(0).getUuid());
         assertEquals("Wrong Uuid in the newly created SecurityProfile",


[38/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
Merge remote-tracking branch 'exoscale/fix/python-support'

This closes #89

Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/reporter
Commit: 62e179b16d84cc12369ee9af17affe571abd0f29
Parents: a0eb144 d5e3d49
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Mon Mar 2 16:31:10 2015 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Mon Mar 2 16:31:23 2015 +0530

----------------------------------------------------------------------
 tools/apidoc/gen_toc.py | 54 +++++++++++++++++++++++---------------------
 1 file changed, 28 insertions(+), 26 deletions(-)
----------------------------------------------------------------------



[50/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
Proposal of a Usage Reporter / call-home functionality for CloudStack

With this commit the Management Server will be default generate a anonymous Usage
report every 7 (seven) days and submit this information back to the Apache CloudStack project.

These anonymous reports do NOT contain any information about Instance names, subnets, etc. It only
contains numbers about how CloudStack is being used.

This information is vital for the project to gain more insight in how CloudStack is being used.

Users can turn the reporting off by setting usage.report.interval to 0 (zero)


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

Branch: refs/heads/reporter
Commit: 178a938ca18f69ab50c64bd60ca27a8751a78230
Parents: 0b6c540
Author: Wido den Hollander <wi...@widodh.nl>
Authored: Thu Nov 20 14:43:33 2014 +0100
Committer: Wido den Hollander <wi...@widodh.nl>
Committed: Wed Mar 4 11:01:54 2015 +0100

----------------------------------------------------------------------
 .../src/com/cloud/upgrade/dao/VersionDao.java   |   4 +
 .../com/cloud/upgrade/dao/VersionDaoImpl.java   |   9 +
 pom.xml                                         |   2 +-
 reporter/README.md                              |  18 +
 reporter/usage-report-collector.py              |  64 +++
 server/pom.xml                                  |  10 +
 .../spring-server-core-managers-context.xml     |   2 +
 server/src/com/cloud/configuration/Config.java  |   5 +-
 .../cloudstack/report/AtomicGsonAdapter.java    |  48 ++
 .../apache/cloudstack/report/UsageReporter.java | 470 +++++++++++++++++++
 setup/db/db/schema-450to460.sql                 |   2 +
 11 files changed, 632 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/178a938c/engine/schema/src/com/cloud/upgrade/dao/VersionDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/dao/VersionDao.java b/engine/schema/src/com/cloud/upgrade/dao/VersionDao.java
index e280e0b..1a60f36 100644
--- a/engine/schema/src/com/cloud/upgrade/dao/VersionDao.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/VersionDao.java
@@ -16,6 +16,8 @@
 // under the License.
 package com.cloud.upgrade.dao;
 
+import java.util.List;
+
 import com.cloud.upgrade.dao.VersionVO.Step;
 import com.cloud.utils.db.GenericDao;
 
@@ -23,4 +25,6 @@ public interface VersionDao extends GenericDao<VersionVO, Long> {
     VersionVO findByVersion(String version, Step step);
 
     String getCurrentVersion();
+
+    List<VersionVO> getAllVersions();
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/178a938c/engine/schema/src/com/cloud/upgrade/dao/VersionDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/dao/VersionDaoImpl.java b/engine/schema/src/com/cloud/upgrade/dao/VersionDaoImpl.java
index 3be101b..344d8c0 100644
--- a/engine/schema/src/com/cloud/upgrade/dao/VersionDaoImpl.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/VersionDaoImpl.java
@@ -170,4 +170,13 @@ public class VersionDaoImpl extends GenericDaoBase<VersionVO, Long> implements V
         }
 
     }
+
+    @Override
+    @DB
+    public List<VersionVO> getAllVersions() {
+        SearchCriteria<VersionVO> sc = AllFieldsSearch.create();
+        sc.setParameters("step", "Complete");
+
+        return listBy(sc);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/178a938c/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 66fe7f7..e0c46e8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -62,7 +62,7 @@
     <cs.jasypt.version>1.9.2</cs.jasypt.version>
     <cs.trilead.version>1.0.0-build217</cs.trilead.version>
     <cs.ehcache.version>2.6.9</cs.ehcache.version>
-    <cs.gson.version>1.7.2</cs.gson.version>
+    <cs.gson.version>2.3.1</cs.gson.version>
     <cs.guava.version>18.0</cs.guava.version>
     <cs.xapi.version>6.2.0-3.1</cs.xapi.version>
     <cs.httpclient.version>4.3.6</cs.httpclient.version>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/178a938c/reporter/README.md
----------------------------------------------------------------------
diff --git a/reporter/README.md b/reporter/README.md
new file mode 100644
index 0000000..6453fa4
--- /dev/null
+++ b/reporter/README.md
@@ -0,0 +1,18 @@
+# CloudStack Usage Report
+
+This directory contains the CloudStack reporter webservice used by the Apache CloudStack project
+to gather anonymous statistical information about CloudStack deployments.
+
+Since version <FIX ME!!> the management server sends out a anonymized Usage Report out to the
+project every 7 days.
+
+This information is used to gain information about how CloudStack is being used.
+
+Turning this Usage Reporting functionality off can be done in the Global Settings by setting
+'usage.report.interval' to 0.
+
+# The webservice
+The Python Flask application in this directory is the webservice running on https://reports.cloudstack.apache.org/ (FIX ME?)
+and stores all the incoming information in a ElasticSearch database.
+
+Since Apache CloudStack is Open Source we show not only how we generate the report, but also how we process it.

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/178a938c/reporter/usage-report-collector.py
----------------------------------------------------------------------
diff --git a/reporter/usage-report-collector.py b/reporter/usage-report-collector.py
new file mode 100755
index 0000000..500a4d2
--- /dev/null
+++ b/reporter/usage-report-collector.py
@@ -0,0 +1,64 @@
+#!/usr/bin/env python
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+from flask import abort, Flask, request, Response
+from elasticsearch import Elasticsearch
+import json
+import time
+
+def json_response(response):
+    return json.dumps(response, indent=2) + "\n", 200, {'Content-Type': 'application/json; charset=utf-8'}
+
+def generate_app(config=None):
+    app = Flask(__name__)
+
+    @app.route('/report/<unique_id>', methods=['POST'])
+    def report(unique_id):
+        # We expect JSON data, so if the Content-Type doesn't match JSON data we throw an error
+        if 'Content-Type' in request.headers:
+            if request.headers['Content-Type'] != 'application/json':
+                abort(417, "No or incorrect Content-Type header was supplied")
+
+        index = "cloudstack-%s" % time.strftime("%Y.%m.%d", time.gmtime())
+        timestamp = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
+
+        es = Elasticsearch()
+        es.indices.create(index=index, ignore=400)
+
+        report = json.loads(request.data)
+        report["unique_id"] = unique_id
+        report["timestamp"] = timestamp
+
+        es.index(index=index, doc_type="usage-report", body=json.dumps(report), timestamp=timestamp, refresh=True)
+
+        response = {}
+        return json_response(response)
+
+    return app
+
+
+app = generate_app()
+
+# Only run the App if this script is invoked from a Shell
+if __name__ == '__main__':
+    app.debug = True
+    app.run(host='0.0.0.0', port=8088)
+
+# Otherwise provide a variable called 'application' for mod_wsgi
+else:
+    application = app

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/178a938c/server/pom.xml
----------------------------------------------------------------------
diff --git a/server/pom.xml b/server/pom.xml
index c293aa1..f2a2a0e 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -138,6 +138,16 @@
       <artifactId>opensaml</artifactId>
       <version>${cs.opensaml.version}</version>
     </dependency>
+    <dependency>
+      <groupId>com.google.code.gson</groupId>
+      <artifactId>gson</artifactId>
+      <version>${cs.gson.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>com.google.guava</groupId>
+      <artifactId>guava</artifactId>
+      <version>${cs.guava.version}</version>
+    </dependency>
   </dependencies>
   <build>
     <testResources>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/178a938c/server/resources/META-INF/cloudstack/core/spring-server-core-managers-context.xml
----------------------------------------------------------------------
diff --git a/server/resources/META-INF/cloudstack/core/spring-server-core-managers-context.xml b/server/resources/META-INF/cloudstack/core/spring-server-core-managers-context.xml
index 6d8f32e..faa5286 100644
--- a/server/resources/META-INF/cloudstack/core/spring-server-core-managers-context.xml
+++ b/server/resources/META-INF/cloudstack/core/spring-server-core-managers-context.xml
@@ -222,6 +222,8 @@
 
     <bean id="statsCollector" class="com.cloud.server.StatsCollector" />
 
+    <bean id="usageReporter" class="org.apache.cloudstack.report.UsageReporter" />
+
     <bean id="storagePoolAutomationImpl" class="com.cloud.storage.StoragePoolAutomationImpl" />
 
     <bean id="domainManagerImpl" class="com.cloud.user.DomainManagerImpl" />

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/178a938c/server/src/com/cloud/configuration/Config.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java
index 982958e..42c0914 100644
--- a/server/src/com/cloud/configuration/Config.java
+++ b/server/src/com/cloud/configuration/Config.java
@@ -2065,7 +2065,10 @@ public enum Config {
     PublishAsynJobEvent("Advanced", ManagementServer.class, Boolean.class, "publish.async.job.events", "true", "enable or disable publishing of usage events on the event bus", null),
 
     // StatsCollector
-    StatsOutPutGraphiteHost("Advanced", ManagementServer.class, String.class, "stats.output.uri", "", "URI to additionally send StatsCollector statistics to", null);
+    StatsOutPutGraphiteHost("Advanced", ManagementServer.class, String.class, "stats.output.uri", "", "URI to additionally send StatsCollector statistics to", null),
+
+    // Usage Reporting service
+    UsageReportInterval("Advanced", ManagementServer.class, Integer.class, "usage.report.interval", "7", "Interval (days) between sending anonymous Usage Reports back to the CloudStack project", null);
 
     private final String _category;
     private final Class<?> _componentClass;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/178a938c/server/src/org/apache/cloudstack/report/AtomicGsonAdapter.java
----------------------------------------------------------------------
diff --git a/server/src/org/apache/cloudstack/report/AtomicGsonAdapter.java b/server/src/org/apache/cloudstack/report/AtomicGsonAdapter.java
new file mode 100644
index 0000000..23d83f1
--- /dev/null
+++ b/server/src/org/apache/cloudstack/report/AtomicGsonAdapter.java
@@ -0,0 +1,48 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.report;
+
+import com.google.gson.TypeAdapter;
+import com.google.gson.stream.JsonReader;
+import com.google.gson.stream.JsonWriter;
+import com.google.common.util.concurrent.AtomicLongMap;
+import java.util.Map;
+import java.io.IOException;
+
+public class AtomicGsonAdapter extends TypeAdapter<AtomicLongMap> {
+
+    public AtomicLongMap<Object> read(JsonReader reader) throws IOException {
+        reader.nextNull();
+        return null;
+    }
+
+    public void write(JsonWriter writer, AtomicLongMap value) throws IOException {
+        if (value == null) {
+            writer.nullValue();
+            return;
+        }
+
+        @SuppressWarnings("unchecked")
+        Map <String, Long> map = value.asMap();
+
+        writer.beginObject();
+        for (Map.Entry<String, Long> entry : map.entrySet()) {
+            writer.name(entry.getKey()).value(entry.getValue());
+        }
+        writer.endObject();
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/178a938c/server/src/org/apache/cloudstack/report/UsageReporter.java
----------------------------------------------------------------------
diff --git a/server/src/org/apache/cloudstack/report/UsageReporter.java b/server/src/org/apache/cloudstack/report/UsageReporter.java
new file mode 100644
index 0000000..4656cc4
--- /dev/null
+++ b/server/src/org/apache/cloudstack/report/UsageReporter.java
@@ -0,0 +1,470 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+package org.apache.cloudstack.report;
+
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.net.URL;
+import java.net.HttpURLConnection;
+import java.net.SocketTimeoutException;
+import java.net.MalformedURLException;
+import java.net.ProtocolException;
+import java.io.OutputStreamWriter;
+import java.io.IOException;
+
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
+import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
+import org.apache.cloudstack.managed.context.ManagedContextRunnable;
+
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
+import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
+
+import org.apache.commons.codec.digest.DigestUtils;
+
+import com.cloud.host.HostVO;
+import com.cloud.host.dao.HostDao;
+import com.cloud.dc.ClusterVO;
+import com.cloud.dc.dao.ClusterDao;
+import com.cloud.dc.DataCenterVO;
+import com.cloud.dc.dao.DataCenterDao;
+import com.cloud.vm.UserVmVO;
+import com.cloud.vm.dao.UserVmDao;
+import com.cloud.vm.VMInstanceVO;
+import com.cloud.vm.dao.VMInstanceDao;
+import com.cloud.utils.db.SearchCriteria;
+import com.cloud.utils.NumbersUtil;
+import com.cloud.utils.component.ManagerBase;
+import com.cloud.utils.component.ComponentMethodInterceptable;
+import com.cloud.utils.concurrency.NamedThreadFactory;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.db.TransactionLegacy;
+import com.cloud.upgrade.dao.VersionDao;
+import com.cloud.upgrade.dao.VersionVO;
+import com.cloud.storage.dao.DiskOfferingDao;
+import com.cloud.storage.DiskOfferingVO;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.common.util.concurrent.AtomicLongMap;
+
+@Component
+public class UsageReporter extends ManagerBase implements ComponentMethodInterceptable {
+    public static final Logger s_logger = Logger.getLogger(UsageReporter.class.getName());
+
+    /* !FIX ME! This should point to a Apache Infra host with SSL! */
+    private String reportHost = "http://cs-report.widodh.nl:8088/report";
+
+    private String uniqueID = null;
+
+    private static UsageReporter s_instance = null;
+
+    private ScheduledExecutorService _executor = null;
+
+    @Inject
+    private ConfigurationDao _configDao;
+    @Inject
+    private HostDao _hostDao;
+    @Inject
+    private ClusterDao _clusterDao;
+    @Inject
+    private PrimaryDataStoreDao _storagePoolDao;
+    @Inject
+    private DataCenterDao _dataCenterDao;
+    @Inject
+    private UserVmDao _userVmDao;
+    @Inject
+    private VMInstanceDao _vmInstance;
+    @Inject
+    private VersionDao _versionDao;
+    @Inject
+    private DiskOfferingDao _diskOfferingDao;
+
+    int usageReportInterval = -1;
+
+    public static UsageReporter getInstance() {
+        return s_instance;
+    }
+
+    public static UsageReporter getInstance(Map<String, String> configs) {
+        s_instance.init(configs);
+        return s_instance;
+    }
+
+    public UsageReporter() {
+        s_instance = this;
+    }
+
+    @Override
+    public boolean start() {
+        init(_configDao.getConfiguration());
+        return true;
+    }
+
+    private void init(Map<String, String> configs) {
+        _executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("UsageReporter"));
+
+        usageReportInterval = NumbersUtil.parseInt(configs.get("usage.report.interval"), 7);
+
+        if (usageReportInterval > 0) {
+            _executor.scheduleWithFixedDelay(new UsageCollector(), 7, usageReportInterval, TimeUnit.DAYS);
+        }
+
+        uniqueID = getUniqueId();
+    }
+
+    private void sendReport(String reportUri, String uniqueID, Map<String, Object> reportMap) {
+
+        GsonBuilder builder = new GsonBuilder();
+
+        AtomicGsonAdapter adapter = new AtomicGsonAdapter();
+        builder.registerTypeAdapter(AtomicLongMap.class, adapter);
+
+        Gson gson = builder.create();
+        String report = gson.toJson(reportMap);
+
+        int http_timeout = 15000;
+
+        try {
+            s_logger.info("Usage Report will be send to: " + reportUri);
+            s_logger.debug("REPORT: " + report);
+
+            URL url = new URL(reportUri + "/" + uniqueID);
+
+            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+            conn.setConnectTimeout(http_timeout);
+            conn.setReadTimeout(http_timeout);
+            conn.setRequestMethod("POST");
+            conn.setDoOutput(true);
+            conn.setRequestProperty("Content-Type", "application/json");
+            conn.setRequestProperty("Accept", "application/json");
+
+            OutputStreamWriter osw = new OutputStreamWriter(conn.getOutputStream());
+            osw.write(report);
+            osw.flush();
+            osw.close();
+
+            int resp_code = conn.getResponseCode();
+
+            if (resp_code == HttpURLConnection.HTTP_OK){
+                s_logger.info("Usage Report succesfully send to: " + reportUri);
+            } else {
+                s_logger.warn("Failed to send Usage Report: " + conn.getResponseMessage());
+            }
+
+        } catch (SocketTimeoutException e) {
+            s_logger.warn("Sending Usage Report to " + reportUri + " timed out: " + e.getMessage());
+        } catch (MalformedURLException e) {
+            s_logger.warn(reportUri + " is a invalid URL for sending Usage Report to: "+ e.getMessage());
+        } catch (ProtocolException e) {
+            s_logger.warn("Sending Usage Report failed due to a invalid protocol: " + e.getMessage());
+        } catch (IOException e) {
+            s_logger.warn("Failed to write Usage Report due to a IOException: " + e.getMessage());
+        }
+    }
+
+    @DB
+    private String getUniqueId() {
+        String unique = null;
+        Connection conn = null;
+
+        try {
+            conn = TransactionLegacy.getStandaloneConnection();
+
+            PreparedStatement pstmt = conn.prepareStatement("SELECT version,updated FROM version ORDER BY id ASC LIMIT 1");
+            ResultSet rs = pstmt.executeQuery();
+            if (rs.next()) {
+                unique = DigestUtils.sha256Hex(rs.getString(1) + rs.getString(2));
+            } else {
+                s_logger.debug("No rows found in the version table. Unable to obtain unique ID for this environment");
+            }
+
+            rs.close();
+        } catch (SQLException e) {
+            s_logger.debug("Unable to get the unique ID of this environment: " + e.getMessage());
+        } finally {
+            try {
+                conn.close();
+            } catch (SQLException e) {
+            }
+        }
+
+        s_logger.debug("Usage Report Unique ID is: " + unique);
+
+        return unique;
+    }
+
+    private Map<String, AtomicLongMap> getHostReport() {
+        Map<String, AtomicLongMap> hostMap = new HashMap<String, AtomicLongMap>();
+        AtomicLongMap<Object> host_types = AtomicLongMap.create();
+        AtomicLongMap<Object> host_hypervisor_type = AtomicLongMap.create();
+        AtomicLongMap<Object> host_version = AtomicLongMap.create();
+
+        SearchCriteria<HostVO> host_sc = _hostDao.createSearchCriteria();
+        List<HostVO> hosts = _hostDao.search(host_sc, null);
+        for (HostVO host : hosts) {
+            host_types.getAndIncrement(host.getType());
+            if (host.getHypervisorType() != null) {
+                host_hypervisor_type.getAndIncrement(host.getHypervisorType());
+            }
+
+            host_version.getAndIncrement(host.getVersion());
+        }
+
+        hostMap.put("version", host_version);
+        hostMap.put("hypervisor_type", host_hypervisor_type);
+        hostMap.put("type", host_types);
+
+        return hostMap;
+    }
+
+    private Map<String, AtomicLongMap> getClusterReport() {
+        Map<String, AtomicLongMap> clusterMap = new HashMap<String, AtomicLongMap>();
+        AtomicLongMap<Object> cluster_hypervisor_type = AtomicLongMap.create();
+        AtomicLongMap<Object> cluster_types = AtomicLongMap.create();
+
+        SearchCriteria<ClusterVO> cluster_sc = _clusterDao.createSearchCriteria();
+        List<ClusterVO> clusters = _clusterDao.search(cluster_sc, null);
+        for (ClusterVO cluster : clusters) {
+            if (cluster.getClusterType() != null) {
+                cluster_types.getAndIncrement(cluster.getClusterType());
+            }
+
+            if (cluster.getHypervisorType() != null) {
+                cluster_hypervisor_type.getAndIncrement(cluster.getHypervisorType());
+            }
+        }
+
+        clusterMap.put("hypervisor_type", cluster_hypervisor_type);
+        clusterMap.put("type", cluster_types);
+
+        return clusterMap;
+    }
+
+    private Map<String, AtomicLongMap> getStoragePoolReport() {
+        Map<String, AtomicLongMap> storagePoolMap = new HashMap<String, AtomicLongMap>();
+        AtomicLongMap<Object> storage_pool_types = AtomicLongMap.create();
+        AtomicLongMap<Object> storage_pool_provider = AtomicLongMap.create();
+        AtomicLongMap<Object> storage_pool_scope = AtomicLongMap.create();
+
+        List<StoragePoolVO> storagePools = _storagePoolDao.listAll();
+        for (StoragePoolVO pool : storagePools) {
+            if (pool.getPoolType() != null) {
+                storage_pool_types.getAndIncrement(pool.getPoolType());
+            }
+
+            if (pool.getStorageProviderName() != null) {
+                storage_pool_provider.getAndIncrement(pool.getStorageProviderName());
+            }
+
+            if (pool.getScope() != null) {
+                storage_pool_scope.getAndIncrement(pool.getScope());
+            }
+        }
+
+        storagePoolMap.put("type", storage_pool_types);
+        storagePoolMap.put("provider", storage_pool_provider);
+        storagePoolMap.put("scope", storage_pool_scope);
+
+        return storagePoolMap;
+    }
+
+    private Map<String, AtomicLongMap> getDataCenterReport() {
+        Map<String, AtomicLongMap> datacenterMap = new HashMap<String, AtomicLongMap>();
+        AtomicLongMap<Object> network_type = AtomicLongMap.create();
+        AtomicLongMap<Object> dns_provider = AtomicLongMap.create();
+        AtomicLongMap<Object> dhcp_provider = AtomicLongMap.create();
+        AtomicLongMap<Object> lb_provider = AtomicLongMap.create();
+        AtomicLongMap<Object> firewall_provider = AtomicLongMap.create();
+        AtomicLongMap<Object> gateway_provider = AtomicLongMap.create();
+        AtomicLongMap<Object> userdata_provider = AtomicLongMap.create();
+        AtomicLongMap<Object> vpn_provider = AtomicLongMap.create();
+
+        List<DataCenterVO> datacenters = _dataCenterDao.listAllZones();
+        for (DataCenterVO datacenter : datacenters) {
+            if (datacenter.getNetworkType() != null) {
+                network_type.getAndIncrement(datacenter.getNetworkType());
+            }
+
+            if (datacenter.getDnsProvider() != null) {
+                dns_provider.getAndIncrement(datacenter.getDnsProvider());
+            }
+
+            if (datacenter.getDhcpProvider() != null) {
+                dhcp_provider.getAndIncrement(datacenter.getDhcpProvider());
+            }
+
+            if (datacenter.getLoadBalancerProvider() != null) {
+                lb_provider.getAndIncrement(datacenter.getLoadBalancerProvider());
+            }
+
+            if (datacenter.getFirewallProvider() != null) {
+                firewall_provider.getAndIncrement(datacenter.getFirewallProvider());
+            }
+
+            if (datacenter.getGatewayProvider() != null) {
+                gateway_provider.getAndIncrement(datacenter.getGatewayProvider());
+            }
+
+            if (datacenter.getUserDataProvider() != null) {
+                userdata_provider.getAndIncrement(datacenter.getUserDataProvider());
+            }
+
+            if (datacenter.getVpnProvider() != null) {
+                vpn_provider.getAndIncrement(datacenter.getVpnProvider());
+            }
+        }
+
+        datacenterMap.put("network_type", network_type);
+        datacenterMap.put("dns_provider", dns_provider);
+        datacenterMap.put("dhcp_provider", dhcp_provider);
+        datacenterMap.put("lb_provider", lb_provider);
+        datacenterMap.put("firewall_provider", firewall_provider);
+        datacenterMap.put("gateway_provider", gateway_provider);
+        datacenterMap.put("userdata_provider", userdata_provider);
+        datacenterMap.put("vpn_provider", vpn_provider);
+
+        return datacenterMap;
+    }
+
+    private Map<String, AtomicLongMap> getInstanceReport() {
+
+        Map<String, AtomicLongMap> instanceMap = new HashMap<String, AtomicLongMap>();
+        AtomicLongMap<Object> hypervisor_type = AtomicLongMap.create();
+        AtomicLongMap<Object> instance_state = AtomicLongMap.create();
+        AtomicLongMap<Object> instance_type = AtomicLongMap.create();
+        AtomicLongMap<Object> ha_enabled = AtomicLongMap.create();
+        AtomicLongMap<Object> dynamically_scalable = AtomicLongMap.create();
+
+        SearchCriteria<HostVO> host_sc = _hostDao.createSearchCriteria();
+        List<HostVO> hosts = _hostDao.search(host_sc, null);
+        for (HostVO host : hosts) {
+            List<UserVmVO> vms = _userVmDao.listByLastHostId(host.getId());
+            for (UserVmVO vm : vms) {
+                VMInstanceVO vmVO = _vmInstance.findById(vm.getId());
+
+                if (vmVO.getHypervisorType() != null) {
+                    hypervisor_type.getAndIncrement(vmVO.getHypervisorType());
+                }
+
+                if (vmVO.getState() != null) {
+                    instance_state.getAndIncrement(vmVO.getState());
+                }
+
+                if (vmVO.getType() != null) {
+                    instance_type.getAndIncrement(vmVO.getType());
+                }
+
+                ha_enabled.getAndIncrement(vmVO.isHaEnabled());
+                dynamically_scalable.getAndIncrement(vmVO.isDynamicallyScalable());
+            }
+        }
+
+        instanceMap.put("hypervisor_type", hypervisor_type);
+        instanceMap.put("state", instance_state);
+        instanceMap.put("type", instance_type);
+        instanceMap.put("ha_enabled", ha_enabled);
+        instanceMap.put("dynamically_scalable", dynamically_scalable);
+
+        return instanceMap;
+    }
+
+    private Map<String, Object> getDiskOfferingReport() {
+        Map<String, Object> diskOfferingReport = new HashMap<String, Object>();
+
+        AtomicLongMap<Object> system_use = AtomicLongMap.create();
+        AtomicLongMap<Object> provisioning_type = AtomicLongMap.create();
+        AtomicLongMap<Object> use_local_storage = AtomicLongMap.create();
+
+        List<DiskOfferingVO> private_offerings = _diskOfferingDao.findPrivateDiskOffering();
+        List<DiskOfferingVO> public_offerings = _diskOfferingDao.findPublicDiskOfferings();
+
+        List<DiskOfferingVO> offerings = new ArrayList<DiskOfferingVO>();
+        offerings.addAll(private_offerings);
+        offerings.addAll(public_offerings);
+
+        long disk_size = 0;
+        for (DiskOfferingVO offering : offerings) {
+            provisioning_type.getAndIncrement(offering.getProvisioningType());
+            system_use.getAndIncrement(offering.getSystemUse());
+            use_local_storage.getAndIncrement(offering.getUseLocalStorage());
+            disk_size += offering.getDiskSize();
+        }
+
+        diskOfferingReport.put("system_use", system_use);
+        diskOfferingReport.put("provisioning_type", provisioning_type);
+        diskOfferingReport.put("use_local_storage", use_local_storage);
+        diskOfferingReport.put("avg_disk_size", disk_size / offerings.size());
+
+        return diskOfferingReport;
+    }
+
+    private Map<String, String> getVersionReport() {
+        Map<String, String> versionMap = new HashMap<String, String>();
+
+        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
+
+        List<VersionVO> versions = _versionDao.getAllVersions();
+        for (VersionVO version : versions) {
+            versionMap.put(version.getVersion(), dateFormat.format(version.getUpdated()));
+        }
+
+        return versionMap;
+    }
+
+    private String getCurrentVersion() {
+        return _versionDao.getCurrentVersion();
+    }
+
+    class UsageCollector extends ManagedContextRunnable {
+        @Override
+        protected void runInContext() {
+            try {
+                s_logger.warn("UsageReporter is running...");
+
+                Map<String, Object> reportMap = new HashMap<String, Object>();
+
+                reportMap.put("hosts", getHostReport());
+                reportMap.put("clusters", getClusterReport());
+                reportMap.put("primaryStorage", getStoragePoolReport());
+                reportMap.put("zones", getDataCenterReport());
+                reportMap.put("instances", getInstanceReport());
+                reportMap.put("diskOffering", getDiskOfferingReport());
+                reportMap.put("versions", getVersionReport());
+                reportMap.put("current_version", getCurrentVersion());
+
+                sendReport(reportHost, uniqueID, reportMap);
+
+            } catch (Exception e) {
+                s_logger.warn("Failed to compile Usage Report: " + e.getMessage());
+            }
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/178a938c/setup/db/db/schema-450to460.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-450to460.sql b/setup/db/db/schema-450to460.sql
index 4a5ea93..6c6da25 100644
--- a/setup/db/db/schema-450to460.sql
+++ b/setup/db/db/schema-450to460.sql
@@ -353,3 +353,5 @@ CREATE VIEW `cloud`.`user_vm_view` AS
         `cloud`.`user_vm_details` `custom_speed`  ON (((`custom_speed`.`vm_id` = `cloud`.`vm_instance`.`id`) and (`custom_speed`.`name` = 'CpuSpeed')))
            left join
         `cloud`.`user_vm_details` `custom_ram_size`  ON (((`custom_ram_size`.`vm_id` = `cloud`.`vm_instance`.`id`) and (`custom_ram_size`.`name` = 'memory')));
+
+INSERT IGNORE INTO `cloud`.`configuration` VALUES ("Advanced", 'DEFAULT', 'management-server', "usage.report.interval", 7, "Interval (days) between sending anonymous Usage Reports back to the CloudStack project", "", NULL, NULL, 0);


[37/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
packaging: date fix

rpmbuild complained about the date "Fri Oct 03 2012"
according to the calendar, Oct 3 2012 was Wednesday

Signed-off-by: Laszlo Hornyak <la...@gmail.com>


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

Branch: refs/heads/reporter
Commit: a0eb1449870497f088d539ab1d8a61cc341fd8f2
Parents: ed099c3
Author: Laszlo Hornyak <la...@gmail.com>
Authored: Mon Mar 2 01:56:55 2015 +0100
Committer: Laszlo Hornyak <la...@gmail.com>
Committed: Mon Mar 2 02:08:17 2015 +0100

----------------------------------------------------------------------
 packaging/fedora20/cloud.spec | 2 +-
 packaging/fedora21/cloud.spec | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a0eb1449/packaging/fedora20/cloud.spec
----------------------------------------------------------------------
diff --git a/packaging/fedora20/cloud.spec b/packaging/fedora20/cloud.spec
index d0269f7..84b29db 100644
--- a/packaging/fedora20/cloud.spec
+++ b/packaging/fedora20/cloud.spec
@@ -701,5 +701,5 @@ fi
 * Fri Jul 04 2014 Hugo Trippaers <hu...@apache.org> 4.5.0
 - Add a package for the mysql ha module
 
-* Fri Oct 03 2012 Hugo Trippaers <hu...@apache.org> 4.1.0
+* Wed Oct 03 2012 Hugo Trippaers <hu...@apache.org> 4.1.0
 - new style spec file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a0eb1449/packaging/fedora21/cloud.spec
----------------------------------------------------------------------
diff --git a/packaging/fedora21/cloud.spec b/packaging/fedora21/cloud.spec
index 73de980..98b12ba 100644
--- a/packaging/fedora21/cloud.spec
+++ b/packaging/fedora21/cloud.spec
@@ -701,5 +701,5 @@ fi
 * Fri Jul 04 2014 Hugo Trippaers <hu...@apache.org> 4.5.0
 - Add a package for the mysql ha module
 
-* Fri Oct 03 2012 Hugo Trippaers <hu...@apache.org> 4.1.0
+* Wed Oct 03 2012 Hugo Trippaers <hu...@apache.org> 4.1.0
 - new style spec file


[27/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
Logical expression simplification, == true is redundant

Signed-off-by: Laszlo Hornyak <la...@gmail.com>


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

Branch: refs/heads/reporter
Commit: 5626a340dd271ec585f973dfa99a2a7fb45abac3
Parents: 3786aa0
Author: Laszlo Hornyak <la...@gmail.com>
Authored: Wed Feb 25 20:55:56 2015 +0100
Committer: Laszlo Hornyak <la...@gmail.com>
Committed: Fri Feb 27 19:38:12 2015 +0100

----------------------------------------------------------------------
 core/src/com/cloud/agent/api/routing/SetFirewallRulesCommand.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5626a340/core/src/com/cloud/agent/api/routing/SetFirewallRulesCommand.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/routing/SetFirewallRulesCommand.java b/core/src/com/cloud/agent/api/routing/SetFirewallRulesCommand.java
index be85887..e030545 100644
--- a/core/src/com/cloud/agent/api/routing/SetFirewallRulesCommand.java
+++ b/core/src/com/cloud/agent/api/routing/SetFirewallRulesCommand.java
@@ -53,7 +53,7 @@ public class SetFirewallRulesCommand extends NetworkElementCommand {
              *  each entry format      <ip>:protocol:srcport:destport:scidr:
              *  reverted entry format  <ip>:reverted:0:0:0:
              */
-            if (fwTO.revoked() == true) {
+            if (fwTO.revoked()) {
                 StringBuilder sb = new StringBuilder();
                 /* This entry is added just to make sure atleast there will one entry in the list to get the ipaddress */
                 sb.append(fwTO.getSrcIp()).append(":reverted:0:0:0:");


[23/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
plugins: fix version to fix build

Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/reporter
Commit: 8829a0d4a7f396549af9ce6071c75eac86ae0bfe
Parents: a75ff23
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Fri Feb 27 16:20:27 2015 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Fri Feb 27 16:20:27 2015 +0530

----------------------------------------------------------------------
 plugins/user-authenticators/pbkdf2/pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8829a0d4/plugins/user-authenticators/pbkdf2/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/pbkdf2/pom.xml b/plugins/user-authenticators/pbkdf2/pom.xml
index e656045..f085003 100644
--- a/plugins/user-authenticators/pbkdf2/pom.xml
+++ b/plugins/user-authenticators/pbkdf2/pom.xml
@@ -23,7 +23,7 @@
   <parent>
     <groupId>org.apache.cloudstack</groupId>
     <artifactId>cloudstack-plugins</artifactId>
-    <version>4.5.0-SNAPSHOT</version>
+    <version>4.6.0-SNAPSHOT</version>
     <relativePath>../../pom.xml</relativePath>
   </parent>
 </project>


[16/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
server: Add missing import, fixes build

Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/reporter
Commit: 4dde4106c0c37e0aa1597bfeac0cbd82c181dbe2
Parents: 6df2fe7
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Thu Feb 26 17:49:55 2015 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Thu Feb 26 17:49:55 2015 +0530

----------------------------------------------------------------------
 server/src/com/cloud/user/AccountManagerImpl.java | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4dde4106/server/src/com/cloud/user/AccountManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/user/AccountManagerImpl.java b/server/src/com/cloud/user/AccountManagerImpl.java
index bced7b3..78a8733 100644
--- a/server/src/com/cloud/user/AccountManagerImpl.java
+++ b/server/src/com/cloud/user/AccountManagerImpl.java
@@ -147,6 +147,7 @@ import javax.crypto.spec.SecretKeySpec;
 import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
+import java.net.InetAddress;
 import java.net.URLEncoder;
 import java.security.NoSuchAlgorithmException;
 import java.util.ArrayList;


[18/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
Add distribution fedora21 in packaging/package.sh


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

Branch: refs/heads/reporter
Commit: b6d9163ae2c1eb255bb4012b1a676193a0a227b5
Parents: d8e1bf1
Author: ghxandsky <gh...@gmail.com>
Authored: Thu Feb 26 22:54:04 2015 +0800
Committer: ghxandsky <gh...@gmail.com>
Committed: Thu Feb 26 22:54:04 2015 +0800

----------------------------------------------------------------------
 packaging/package.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b6d9163a/packaging/package.sh
----------------------------------------------------------------------
diff --git a/packaging/package.sh b/packaging/package.sh
index 3abbaf2..5e7304a 100755
--- a/packaging/package.sh
+++ b/packaging/package.sh
@@ -23,7 +23,7 @@ function usage() {
     echo "The commonly used Arguments are:"
     echo "-p|--pack oss|OSS             To package with only redistributable libraries (default)"
     echo "-p|--pack noredist|NOREDIST   To package with non-redistributable libraries"
-    echo "-d centos7|centos63|fedora20  To build a package for a distribution"
+    echo "-d centos7|centos63|fedora20|fedora21  To build a package for a distribution"
     echo "-s simulator|SIMULATOR        To build for Simulator"
     echo ""
     echo "Examples: ./package.sh -p|--pack oss|OSS"


[09/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
Merge branch 'patch-1' of https://github.com/NuxRo/cloudstack


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

Branch: refs/heads/reporter
Commit: cc9461bdb83047d2597605a9a6ca9b9c2975da7f
Parents: 76010d8 f06dc56
Author: Daan Hoogland <da...@onecht.net>
Authored: Wed Feb 25 11:35:16 2015 +0100
Committer: Daan Hoogland <da...@onecht.net>
Committed: Wed Feb 25 11:35:16 2015 +0100

----------------------------------------------------------------------
 client/WEB-INF/classes/resources/messages.properties | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------



[24/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
CLOUDSTACK-5238: password checks, NPE fixes and minor fixes

- insecure authenticators excluded in configuration
- snapshot response should have zone
- remove vmsnapshots when removing accounts

Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
(cherry picked from commit 5481485a083957ff58da3b6fea9d7b6d20f06875)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>

Conflicts:
	api/src/org/apache/cloudstack/api/response/VMSnapshotResponse.java
	server/src/com/cloud/api/ApiResponseHelper.java
	server/src/com/cloud/storage/download/DownloadActiveState.java


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

Branch: refs/heads/reporter
Commit: 43cf1da865c1e4ed6523fb5b2ba315a547fac79f
Parents: 8829a0d
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Fri Feb 27 18:20:10 2015 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Fri Feb 27 18:24:46 2015 +0530

----------------------------------------------------------------------
 .../api/response/VMSnapshotResponse.java        |  2 +-
 .../cloud/vm/snapshot/dao/VMSnapshotDao.java    |  2 ++
 .../vm/snapshot/dao/VMSnapshotDaoImpl.java      |  6 +++++
 server/src/com/cloud/api/ApiResponseHelper.java |  4 +++
 .../cloud/ha/dao/HighAvailabilityDaoImpl.java   |  2 ++
 .../cloud/hypervisor/HypervisorGuruBase.java    |  6 +++--
 server/src/com/cloud/hypervisor/KVMGuru.java    | 27 +++++++++++++++-----
 .../com/cloud/resource/ResourceManagerImpl.java |  6 ++---
 .../resourcelimit/ResourceLimitManagerImpl.java |  3 ++-
 .../cloud/server/ConfigurationServerImpl.java   |  3 +++
 .../src/com/cloud/user/AccountManagerImpl.java  | 23 ++++++++++++++++-
 11 files changed, 69 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43cf1da8/api/src/org/apache/cloudstack/api/response/VMSnapshotResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/VMSnapshotResponse.java b/api/src/org/apache/cloudstack/api/response/VMSnapshotResponse.java
index 29d06b9..1285f73 100644
--- a/api/src/org/apache/cloudstack/api/response/VMSnapshotResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/VMSnapshotResponse.java
@@ -192,7 +192,7 @@ public class VMSnapshotResponse extends BaseResponse implements ControlledEntity
       this.parent = parent;
     }
 
-  public String getType() {
+    public String getType() {
         return type;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43cf1da8/engine/schema/src/com/cloud/vm/snapshot/dao/VMSnapshotDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/snapshot/dao/VMSnapshotDao.java b/engine/schema/src/com/cloud/vm/snapshot/dao/VMSnapshotDao.java
index e714a6e..31999ef 100644
--- a/engine/schema/src/com/cloud/vm/snapshot/dao/VMSnapshotDao.java
+++ b/engine/schema/src/com/cloud/vm/snapshot/dao/VMSnapshotDao.java
@@ -36,4 +36,6 @@ public interface VMSnapshotDao extends GenericDao<VMSnapshotVO, Long>, StateDao<
     List<VMSnapshotVO> listByParent(Long vmSnapshotId);
 
     VMSnapshotVO findByName(Long vmId, String name);
+
+    List<VMSnapshotVO> listByAccountId(Long accountId);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43cf1da8/engine/schema/src/com/cloud/vm/snapshot/dao/VMSnapshotDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/snapshot/dao/VMSnapshotDaoImpl.java b/engine/schema/src/com/cloud/vm/snapshot/dao/VMSnapshotDaoImpl.java
index dccd19f..a87d284 100644
--- a/engine/schema/src/com/cloud/vm/snapshot/dao/VMSnapshotDaoImpl.java
+++ b/engine/schema/src/com/cloud/vm/snapshot/dao/VMSnapshotDaoImpl.java
@@ -121,6 +121,12 @@ public class VMSnapshotDaoImpl extends GenericDaoBase<VMSnapshotVO, Long> implem
         return null;
     }
 
+    public List<VMSnapshotVO> listByAccountId(Long accountId) {
+        SearchCriteria sc = this.AllFieldsSearch.create();
+        sc.setParameters("accountId", new Object[] { accountId });
+        return listBy(sc, null);
+    }
+
     @Override
     public boolean updateState(State currentState, Event event, State nextState, VMSnapshot vo, Object data) {
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43cf1da8/server/src/com/cloud/api/ApiResponseHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java
index f7059ef..b17b5cc 100644
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -472,6 +472,10 @@ public class ApiResponseHelper implements ResponseGenerator {
             snapshotResponse.setVolumeId(volume.getUuid());
             snapshotResponse.setVolumeName(volume.getName());
             snapshotResponse.setVolumeType(volume.getVolumeType().name());
+            DataCenter zone = ApiDBUtils.findZoneById(volume.getDeviceId());
+            if (zone != null) {
+                snapshotResponse.setZoneId(zone.getUuid());
+            }
         }
         snapshotResponse.setCreated(snapshot.getCreated());
         snapshotResponse.setName(snapshot.getName());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43cf1da8/server/src/com/cloud/ha/dao/HighAvailabilityDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/ha/dao/HighAvailabilityDaoImpl.java b/server/src/com/cloud/ha/dao/HighAvailabilityDaoImpl.java
index d25c6a7..724f4f6 100644
--- a/server/src/com/cloud/ha/dao/HighAvailabilityDaoImpl.java
+++ b/server/src/com/cloud/ha/dao/HighAvailabilityDaoImpl.java
@@ -63,6 +63,7 @@ public class HighAvailabilityDaoImpl extends GenericDaoBase<HaWorkVO, Long> impl
         TBASearch.and("server", TBASearch.entity().getServerId(), Op.NULL);
         TBASearch.and("taken", TBASearch.entity().getDateTaken(), Op.NULL);
         TBASearch.and("time", TBASearch.entity().getTimeToTry(), Op.LTEQ);
+        TBASearch.and("step", TBASearch.entity().getStep(), Op.NIN);
         TBASearch.done();
 
         PreviousInstanceSearch = createSearchBuilder();
@@ -151,6 +152,7 @@ public class HighAvailabilityDaoImpl extends GenericDaoBase<HaWorkVO, Long> impl
         try {
             final SearchCriteria<HaWorkVO> sc = TBASearch.create();
             sc.setParameters("time", System.currentTimeMillis() >> 10);
+            sc.setParameters("step", Step.Done, Step.Cancelled);
 
             final Filter filter = new Filter(HaWorkVO.class, null, true, 0l, 1l);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43cf1da8/server/src/com/cloud/hypervisor/HypervisorGuruBase.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/hypervisor/HypervisorGuruBase.java b/server/src/com/cloud/hypervisor/HypervisorGuruBase.java
index 0cb9af5..0188778 100644
--- a/server/src/com/cloud/hypervisor/HypervisorGuruBase.java
+++ b/server/src/com/cloud/hypervisor/HypervisorGuruBase.java
@@ -35,6 +35,7 @@ import com.cloud.offering.ServiceOffering;
 import com.cloud.resource.ResourceManager;
 import com.cloud.server.ConfigurationServer;
 import com.cloud.service.ServiceOfferingDetailsVO;
+import com.cloud.service.dao.ServiceOfferingDao;
 import com.cloud.service.dao.ServiceOfferingDetailsDao;
 import com.cloud.storage.dao.VMTemplateDetailsDao;
 import com.cloud.utils.Pair;
@@ -71,6 +72,8 @@ public abstract class HypervisorGuruBase extends AdapterBase implements Hypervis
     ResourceManager _resourceMgr;
     @Inject
     ServiceOfferingDetailsDao _serviceOfferingDetailsDao;
+    @Inject
+    ServiceOfferingDao _serviceOfferingDao;
 
     protected HypervisorGuruBase() {
         super();
@@ -125,8 +128,7 @@ public abstract class HypervisorGuruBase extends AdapterBase implements Hypervis
     }
 
     protected VirtualMachineTO toVirtualMachineTO(VirtualMachineProfile vmProfile) {
-
-        ServiceOffering offering = vmProfile.getServiceOffering();
+        ServiceOffering offering = _serviceOfferingDao.findById(vmProfile.getId(), vmProfile.getServiceOfferingId());
         VirtualMachine vm = vmProfile.getVirtualMachine();
         Long minMemory = (long)(offering.getRamSize() / vmProfile.getMemoryOvercommitRatio());
         int minspeed = (int)(offering.getSpeed() / vmProfile.getCpuOvercommitRatio());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43cf1da8/server/src/com/cloud/hypervisor/KVMGuru.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/hypervisor/KVMGuru.java b/server/src/com/cloud/hypervisor/KVMGuru.java
index a2534bd..e15a417 100644
--- a/server/src/com/cloud/hypervisor/KVMGuru.java
+++ b/server/src/com/cloud/hypervisor/KVMGuru.java
@@ -16,24 +16,25 @@
 // under the License.
 package com.cloud.hypervisor;
 
-import java.util.Map;
-
-import javax.ejb.Local;
-import javax.inject.Inject;
-
-import org.apache.cloudstack.storage.command.StorageSubSystemCommand;
-
 import com.cloud.agent.api.Command;
+import com.cloud.agent.api.to.DataObjectType;
 import com.cloud.agent.api.to.VirtualMachineTO;
 import com.cloud.host.HostVO;
 import com.cloud.host.dao.HostDao;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
+import com.cloud.storage.DataStoreRole;
 import com.cloud.storage.GuestOSHypervisorVO;
 import com.cloud.storage.GuestOSVO;
 import com.cloud.storage.dao.GuestOSDao;
 import com.cloud.storage.dao.GuestOSHypervisorDao;
 import com.cloud.utils.Pair;
 import com.cloud.vm.VirtualMachineProfile;
+import org.apache.cloudstack.storage.command.CopyCommand;
+import org.apache.cloudstack.storage.command.StorageSubSystemCommand;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+import java.util.Map;
 
 @Local(value = HypervisorGuru.class)
 public class KVMGuru extends HypervisorGuruBase implements HypervisorGuru {
@@ -77,6 +78,18 @@ public class KVMGuru extends HypervisorGuruBase implements HypervisorGuru {
 
     @Override
     public Pair<Boolean, Long> getCommandHostDelegation(long hostId, Command cmd) {
+        if (cmd instanceof CopyCommand) {
+            CopyCommand c = (CopyCommand) cmd;
+            boolean inSeq = true;
+            if (c.getSrcTO().getObjectType() == DataObjectType.SNAPSHOT ||
+                    c.getDestTO().getObjectType() == DataObjectType.SNAPSHOT) {
+                inSeq = false;
+            } else if (c.getDestTO().getDataStore().getRole() == DataStoreRole.Image ||
+                    c.getDestTO().getDataStore().getRole() == DataStoreRole.ImageCache) {
+                inSeq = false;
+            }
+            c.setExecuteInSequence(inSeq);
+        }
         if (cmd instanceof StorageSubSystemCommand) {
             StorageSubSystemCommand c = (StorageSubSystemCommand)cmd;
             c.setExecuteInSequence(false);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43cf1da8/server/src/com/cloud/resource/ResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java
index d6dbff9..6beea23 100644
--- a/server/src/com/cloud/resource/ResourceManagerImpl.java
+++ b/server/src/com/cloud/resource/ResourceManagerImpl.java
@@ -30,7 +30,6 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
-import com.cloud.capacity.CapacityState;
 import com.cloud.vm.VirtualMachine;
 
 import org.apache.cloudstack.api.ApiConstants;
@@ -71,6 +70,7 @@ import com.cloud.agent.api.to.GPUDeviceTO;
 import com.cloud.agent.transport.Request;
 import com.cloud.capacity.Capacity;
 import com.cloud.capacity.CapacityManager;
+import com.cloud.capacity.CapacityState;
 import com.cloud.capacity.CapacityVO;
 import com.cloud.capacity.dao.CapacityDao;
 import com.cloud.cluster.ClusterManager;
@@ -1174,12 +1174,13 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
         MaintainAnswer answer = (MaintainAnswer)_agentMgr.easySend(hostId, new MaintainCommand());
         if (answer == null || !answer.getResult()) {
             s_logger.warn("Unable to send MaintainCommand to host: " + hostId);
+            return false;
         }
 
         try {
             resourceStateTransitTo(host, ResourceState.Event.AdminAskMaintenace, _nodeId);
         } catch (NoTransitionException e) {
-            String err = "Cannot transimit resource state of host " + host.getId() + " to " + ResourceState.Maintenance;
+            String err = "Cannot transmit resource state of host " + host.getId() + " to " + ResourceState.Maintenance;
             s_logger.debug(err, e);
             throw new CloudRuntimeException(err + e.getMessage());
         }
@@ -1210,7 +1211,6 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
                 }
             }
         }
-
         return true;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43cf1da8/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java b/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java
index 00b76cc..1651ad7 100644
--- a/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java
+++ b/server/src/com/cloud/resourcelimit/ResourceLimitManagerImpl.java
@@ -868,8 +868,9 @@ public class ResourceLimitManagerImpl extends ManagerBase implements ResourceLim
 
         // this lock guards against the updates to user_vm, volume, snapshot, public _ip and template table
         // as any resource creation precedes with the resourceLimitExceeded check which needs this lock too
+        Set rowIdsToLock = _resourceCountDao.listAllRowsToUpdate(accountId, Resource.ResourceOwnerType.Account, type);
         SearchCriteria<ResourceCountVO> sc = ResourceCountSearch.create();
-        sc.setParameters("accountId", accountId);
+        sc.setParameters("id", rowIdsToLock.toArray());
         _resourceCountDao.lockRows(sc, null, true);
 
         ResourceCountVO accountRC = _resourceCountDao.findByOwnerAndType(accountId, ResourceOwnerType.Account, type);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43cf1da8/server/src/com/cloud/server/ConfigurationServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ConfigurationServerImpl.java b/server/src/com/cloud/server/ConfigurationServerImpl.java
index 6081c9e..a3bd14a 100644
--- a/server/src/com/cloud/server/ConfigurationServerImpl.java
+++ b/server/src/com/cloud/server/ConfigurationServerImpl.java
@@ -219,6 +219,9 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
             _configDao.update("secstorage.secure.copy.cert", "realhostip");
             s_logger.debug("ConfigurationServer made secondary storage copy use realhostip.");
 
+            _configDao.update("user.password.encoders.exclude", "MD5,LDAP,PLAINTEXT");
+            s_logger.debug("Configuration server excluded insecure encoders");
+
             // Save default service offerings
             createServiceOffering(User.UID_SYSTEM, "Small Instance", 1, 512, 500, "Small Instance", ProvisioningType.THIN, false, false, null);
             createServiceOffering(User.UID_SYSTEM, "Medium Instance", 1, 1024, 1000, "Medium Instance", ProvisioningType.THIN, false, false, null);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/43cf1da8/server/src/com/cloud/user/AccountManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/user/AccountManagerImpl.java b/server/src/com/cloud/user/AccountManagerImpl.java
index 29ea9aa..f40cd8f 100644
--- a/server/src/com/cloud/user/AccountManagerImpl.java
+++ b/server/src/com/cloud/user/AccountManagerImpl.java
@@ -117,6 +117,10 @@ import com.cloud.vm.VirtualMachineManager;
 import com.cloud.vm.dao.InstanceGroupDao;
 import com.cloud.vm.dao.UserVmDao;
 import com.cloud.vm.dao.VMInstanceDao;
+import com.cloud.vm.snapshot.VMSnapshot;
+import com.cloud.vm.snapshot.VMSnapshotManager;
+import com.cloud.vm.snapshot.VMSnapshotVO;
+import com.cloud.vm.snapshot.dao.VMSnapshotDao;
 import org.apache.cloudstack.acl.ControlledEntity;
 import org.apache.cloudstack.acl.QuerySelector;
 import org.apache.cloudstack.acl.RoleType;
@@ -201,6 +205,10 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
     @Inject
     private SnapshotManager _snapMgr;
     @Inject
+    private VMSnapshotManager _vmSnapshotMgr;
+    @Inject
+    private VMSnapshotDao _vmSnapshotDao;
+    @Inject
     private UserVmManager _vmMgr;
     @Inject
     private TemplateManager _tmpltMgr;
@@ -730,6 +738,16 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
                 accountCleanupNeeded = true;
             }
 
+            // Destroy VM Snapshots
+            List<VMSnapshotVO> vmSnapshots = _vmSnapshotDao.listByAccountId(Long.valueOf(accountId));
+            for (VMSnapshot vmSnapshot : vmSnapshots) {
+                try {
+                    _vmSnapshotMgr.deleteVMSnapshot(vmSnapshot.getId());
+                } catch (Exception e) {
+                    s_logger.debug("Failed to cleanup vm snapshot " + vmSnapshot.getId() + " due to " + e.toString());
+                }
+            }
+
             // Destroy the account's VMs
             List<UserVmVO> vms = _userVmDao.listByAccountId(accountId);
             if (s_logger.isDebugEnabled()) {
@@ -1169,6 +1187,9 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
         }
 
         if (password != null) {
+            if (password.isEmpty()) {
+                throw new InvalidParameterValueException("Password cannot be empty");
+            }
             String encodedPassword = null;
             for (Iterator<UserAuthenticator> en = _userPasswordEncoders.iterator(); en.hasNext();) {
                 UserAuthenticator authenticator = en.next();
@@ -1977,7 +1998,7 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
     @Override
     public UserAccount authenticateUser(String username, String password, Long domainId, InetAddress loginIpAddress, Map<String, Object[]> requestParameters) {
         UserAccount user = null;
-        if (password != null) {
+        if (password != null && !password.isEmpty()) {
             user = getUserAccount(username, password, domainId, requestParameters);
         } else {
             String key = _configDao.getValue("security.singlesignon.key");


[34/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
server: check and set sercure cookie flag only after login

Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
(cherry picked from commit 0f819f1583116d93ca3ebf460b69cd74144a25b2)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/reporter
Commit: ed099c3f964e4b18a3c431b59cdb63533ec91d81
Parents: 20bcb4b
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Sat Feb 28 18:20:56 2015 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Sat Feb 28 18:23:05 2015 +0530

----------------------------------------------------------------------
 server/src/com/cloud/api/ApiServlet.java | 8 ++++++++
 1 file changed, 8 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ed099c3f/server/src/com/cloud/api/ApiServlet.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiServlet.java b/server/src/com/cloud/api/ApiServlet.java
index 5628d98..1fd16ba 100644
--- a/server/src/com/cloud/api/ApiServlet.java
+++ b/server/src/com/cloud/api/ApiServlet.java
@@ -194,6 +194,14 @@ public class ApiServlet extends HttpServlet {
                             }
                         }
                         session = req.getSession(true);
+                        if (ApiServer.isSecureSessionCookieEnabled()) {
+                            resp.setHeader("SET-COOKIE", "JSESSIONID=" + session.getId() + ";Secure;Path=/client");
+                            if (s_logger.isDebugEnabled()) {
+                                if (s_logger.isDebugEnabled()) {
+                                    s_logger.debug("Session cookie is marked secure!");
+                                }
+                            }
+                        }
                     }
 
                     try {


[08/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
Update messages.properties

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

Branch: refs/heads/reporter
Commit: f06dc56e6ac886bebe340913b0ad5873466ac6df
Parents: 81378c4
Author: NuxRo <nu...@li.nux.ro>
Authored: Wed Feb 25 10:31:57 2015 +0000
Committer: NuxRo <nu...@li.nux.ro>
Committed: Wed Feb 25 10:31:57 2015 +0000

----------------------------------------------------------------------
 client/WEB-INF/classes/resources/messages.properties | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f06dc56e/client/WEB-INF/classes/resources/messages.properties
----------------------------------------------------------------------
diff --git a/client/WEB-INF/classes/resources/messages.properties b/client/WEB-INF/classes/resources/messages.properties
index a4e4e1a..553bfc6 100644
--- a/client/WEB-INF/classes/resources/messages.properties
+++ b/client/WEB-INF/classes/resources/messages.properties
@@ -1322,7 +1322,7 @@ label.remove.vpc.offering=Remove VPC offering
 label.vpc.distributedvpcrouter=Distributed VPC Router
 label.vpc.supportsregionlevelvpc=Supports Region Level VPC
 label.dynamically.scalable=Dynamically Scalable
-label.instance.scaled.up=Instance Scaled
+label.instance.scaled.up=Instance scaled to the requested offering
 label.tag.key=Tag Key
 label.tag.value=Tag Value
 label.ipv6.address=IPv6 IP Address


[35/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
CLOUDSTACK-8292: fix for java 1.8 compilation

Refactored to use the XPatch expressions to check the generated domain xml rathern than string comparison.

Signed-off-by: Laszlo Hornyak <la...@gmail.com>


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

Branch: refs/heads/reporter
Commit: 0fda5a03a43916a7b3ae59208ba0bfc8b3e5b841
Parents: ed099c3
Author: Laszlo Hornyak <la...@gmail.com>
Authored: Sat Feb 28 19:36:01 2015 +0100
Committer: Laszlo Hornyak <la...@gmail.com>
Committed: Sat Feb 28 20:11:46 2015 +0100

----------------------------------------------------------------------
 .../resource/LibvirtComputingResourceTest.java  | 254 ++++++-------------
 1 file changed, 83 insertions(+), 171 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0fda5a03/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java
index bf4546c..b82796f 100644
--- a/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java
+++ b/plugins/hypervisors/kvm/test/com/cloud/hypervisor/kvm/resource/LibvirtComputingResourceTest.java
@@ -19,17 +19,23 @@
 
 package com.cloud.hypervisor.kvm.resource;
 
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Random;
 import java.util.UUID;
 
-import junit.framework.Assert;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
 
 import org.apache.commons.lang.SystemUtils;
+import org.junit.Assert;
 import org.junit.Assume;
 import org.junit.Test;
 import org.libvirt.Connect;
@@ -43,6 +49,8 @@ import org.mockito.Matchers;
 import org.mockito.Mockito;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
 
 import com.cloud.agent.api.VmStatsEntry;
 import com.cloud.agent.api.to.VirtualMachineTO;
@@ -75,8 +83,6 @@ public class LibvirtComputingResourceTest {
         int maxRam = 512 * 1024;
 
         String os = "Ubuntu";
-        boolean haEnabled = false;
-        boolean limitCpuUse = false;
 
         String vncAddr = "";
         String vncPassword = "mySuperSecretPassword";
@@ -89,47 +95,7 @@ public class LibvirtComputingResourceTest {
         LibvirtVMDef vm = lcr.createVMFromSpec(to);
         vm.setHvsType(_hyperVisorType);
 
-        String vmStr = "<domain type='" + _hyperVisorType + "'>\n";
-        vmStr += "<name>" + name + "</name>\n";
-        vmStr += "<uuid>b0f0a72d-7efb-3cad-a8ff-70ebf30b3af9</uuid>\n";
-        vmStr += "<description>" + os + "</description>\n";
-        vmStr += "<clock offset='utc'>\n";
-        vmStr += "</clock>\n";
-        vmStr += "<features>\n";
-        vmStr += "<pae/>\n";
-        vmStr += "<apic/>\n";
-        vmStr += "<acpi/>\n";
-        vmStr += "</features>\n";
-        vmStr += "<devices>\n";
-        vmStr += "<serial type='pty'>\n";
-        vmStr += "<target port='0'/>\n";
-        vmStr += "</serial>\n";
-        vmStr += "<graphics type='vnc' autoport='yes' listen='" + vncAddr + "' passwd='" + vncPassword + "'/>\n";
-        vmStr += "<console type='pty'>\n";
-        vmStr += "<target port='0'/>\n";
-        vmStr += "</console>\n";
-        vmStr += "<input type='tablet' bus='usb'/>\n";
-        vmStr += "</devices>\n";
-        vmStr += "<memory>" + maxRam / 1024 + "</memory>\n";
-        vmStr += "<currentMemory>" + minRam / 1024 + "</currentMemory>\n";
-        vmStr += "<devices>\n";
-        vmStr += "<memballoon model='virtio'/>\n";
-        vmStr += "</devices>\n";
-        vmStr += "<vcpu>" + cpus + "</vcpu>\n";
-        vmStr += "<os>\n";
-        vmStr += "<type  machine='pc'>hvm</type>\n";
-        vmStr += "<boot dev='cdrom'/>\n";
-        vmStr += "<boot dev='hd'/>\n";
-        vmStr += "</os>\n";
-        //vmStr += "<cputune>\n";
-        //vmStr += "<shares>" + (cpus * speed) + "</shares>\n";
-        //vmStr += "</cputune>\n";
-        vmStr += "<cpu></cpu>";
-        vmStr += "<on_reboot>restart</on_reboot>\n";
-        vmStr += "<on_poweroff>destroy</on_poweroff>\n";
-        vmStr += "<on_crash>destroy</on_crash>\n";
-        vmStr += "</domain>\n";
-        assertEquals(vmStr, vm.toString());
+        verifyVm(to, vm);
     }
 
     /**
@@ -147,8 +113,6 @@ public class LibvirtComputingResourceTest {
         int maxRam = 512 * 1024;
 
         String os = "Ubuntu";
-        boolean haEnabled = false;
-        boolean limitCpuUse = false;
 
         String vncAddr = "";
         String vncPassword = "mySuperSecretPassword";
@@ -161,45 +125,7 @@ public class LibvirtComputingResourceTest {
         LibvirtVMDef vm = lcr.createVMFromSpec(to);
         vm.setHvsType(_hyperVisorType);
 
-        String vmStr = "<domain type='" + _hyperVisorType + "'>\n";
-        vmStr += "<name>" + name + "</name>\n";
-        vmStr += "<uuid>b0f0a72d-7efb-3cad-a8ff-70ebf30b3af9</uuid>\n";
-        vmStr += "<description>" + os + "</description>\n";
-        vmStr += "<clock offset='utc'>\n";
-        vmStr += "</clock>\n";
-        vmStr += "<features>\n";
-        vmStr += "<pae/>\n";
-        vmStr += "<apic/>\n";
-        vmStr += "<acpi/>\n";
-        vmStr += "</features>\n";
-        vmStr += "<devices>\n";
-        vmStr += "<serial type='pty'>\n";
-        vmStr += "<target port='0'/>\n";
-        vmStr += "</serial>\n";
-        vmStr += "<graphics type='vnc' autoport='yes' listen='" + vncAddr + "' passwd='" + vncPassword + "'/>\n";
-        vmStr += "<console type='pty'>\n";
-        vmStr += "<target port='0'/>\n";
-        vmStr += "</console>\n";
-        vmStr += "<input type='tablet' bus='usb'/>\n";
-        vmStr += "</devices>\n";
-        vmStr += "<memory>" + maxRam / 1024 + "</memory>\n";
-        vmStr += "<currentMemory>" + minRam / 1024 + "</currentMemory>\n";
-        vmStr += "<devices>\n";
-        vmStr += "<memballoon model='virtio'/>\n";
-        vmStr += "</devices>\n";
-        vmStr += "<vcpu>" + cpus + "</vcpu>\n";
-        vmStr += "<os>\n";
-        vmStr += "<type  machine='pc'>hvm</type>\n";
-        vmStr += "<boot dev='cdrom'/>\n";
-        vmStr += "<boot dev='hd'/>\n";
-        vmStr += "</os>\n";
-        vmStr += "<cpu><topology sockets='2' cores='6' threads='1' /></cpu>";
-        vmStr += "<on_reboot>restart</on_reboot>\n";
-        vmStr += "<on_poweroff>destroy</on_poweroff>\n";
-        vmStr += "<on_crash>destroy</on_crash>\n";
-        vmStr += "</domain>\n";
-
-        assertEquals(vmStr, vm.toString());
+        verifyVm(to, vm);
     }
 
     /**
@@ -217,8 +143,6 @@ public class LibvirtComputingResourceTest {
         int maxRam = 512 * 1024;
 
         String os = "Ubuntu";
-        boolean haEnabled = false;
-        boolean limitCpuUse = false;
 
         String vncAddr = "";
         String vncPassword = "mySuperSecretPassword";
@@ -231,45 +155,7 @@ public class LibvirtComputingResourceTest {
         LibvirtVMDef vm = lcr.createVMFromSpec(to);
         vm.setHvsType(_hyperVisorType);
 
-        String vmStr = "<domain type='" + _hyperVisorType + "'>\n";
-        vmStr += "<name>" + name + "</name>\n";
-        vmStr += "<uuid>b0f0a72d-7efb-3cad-a8ff-70ebf30b3af9</uuid>\n";
-        vmStr += "<description>" + os + "</description>\n";
-        vmStr += "<clock offset='utc'>\n";
-        vmStr += "</clock>\n";
-        vmStr += "<features>\n";
-        vmStr += "<pae/>\n";
-        vmStr += "<apic/>\n";
-        vmStr += "<acpi/>\n";
-        vmStr += "</features>\n";
-        vmStr += "<devices>\n";
-        vmStr += "<serial type='pty'>\n";
-        vmStr += "<target port='0'/>\n";
-        vmStr += "</serial>\n";
-        vmStr += "<graphics type='vnc' autoport='yes' listen='" + vncAddr + "' passwd='" + vncPassword + "'/>\n";
-        vmStr += "<console type='pty'>\n";
-        vmStr += "<target port='0'/>\n";
-        vmStr += "</console>\n";
-        vmStr += "<input type='tablet' bus='usb'/>\n";
-        vmStr += "</devices>\n";
-        vmStr += "<memory>" + maxRam / 1024 + "</memory>\n";
-        vmStr += "<currentMemory>" + minRam / 1024 + "</currentMemory>\n";
-        vmStr += "<devices>\n";
-        vmStr += "<memballoon model='virtio'/>\n";
-        vmStr += "</devices>\n";
-        vmStr += "<vcpu>" + cpus + "</vcpu>\n";
-        vmStr += "<os>\n";
-        vmStr += "<type  machine='pc'>hvm</type>\n";
-        vmStr += "<boot dev='cdrom'/>\n";
-        vmStr += "<boot dev='hd'/>\n";
-        vmStr += "</os>\n";
-        vmStr += "<cpu><topology sockets='2' cores='4' threads='1' /></cpu>";
-        vmStr += "<on_reboot>restart</on_reboot>\n";
-        vmStr += "<on_poweroff>destroy</on_poweroff>\n";
-        vmStr += "<on_crash>destroy</on_crash>\n";
-        vmStr += "</domain>\n";
-
-        assertEquals(vmStr, vm.toString());
+        verifyVm(to, vm);
     }
 
     /**
@@ -291,8 +177,6 @@ public class LibvirtComputingResourceTest {
         int maxRam = 512 * 1024;
 
         String os = "Ubuntu";
-        boolean haEnabled = false;
-        boolean limitCpuUse = false;
 
         String vncAddr = "";
         String vncPassword = "mySuperSecretPassword";
@@ -306,48 +190,76 @@ public class LibvirtComputingResourceTest {
         LibvirtVMDef vm = lcr.createVMFromSpec(to);
         vm.setHvsType(_hyperVisorType);
 
-        String vmStr = "<domain type='" + _hyperVisorType + "'>\n";
-        vmStr += "<name>" + name + "</name>\n";
-        vmStr += "<uuid>b0f0a72d-7efb-3cad-a8ff-70ebf30b3af9</uuid>\n";
-        vmStr += "<description>" + os + "</description>\n";
-        vmStr += "<clock offset='utc'>\n";
-        vmStr += "</clock>\n";
-        vmStr += "<features>\n";
-        vmStr += "<pae/>\n";
-        vmStr += "<apic/>\n";
-        vmStr += "<acpi/>\n";
-        vmStr += "</features>\n";
-        vmStr += "<devices>\n";
-        vmStr += "<serial type='pty'>\n";
-        vmStr += "<target port='0'/>\n";
-        vmStr += "</serial>\n";
-        vmStr += "<graphics type='vnc' autoport='yes' listen='" + vncAddr + "' passwd='" + vncPassword + "'/>\n";
-        vmStr += "<console type='pty'>\n";
-        vmStr += "<target port='0'/>\n";
-        vmStr += "</console>\n";
-        vmStr += "<input type='tablet' bus='usb'/>\n";
-        vmStr += "</devices>\n";
-        vmStr += "<memory>" + maxRam / 1024 + "</memory>\n";
-        vmStr += "<currentMemory>" + minRam / 1024 + "</currentMemory>\n";
-        vmStr += "<devices>\n";
-        vmStr += "<memballoon model='virtio'/>\n";
-        vmStr += "</devices>\n";
-        vmStr += "<vcpu>" + cpus + "</vcpu>\n";
-        vmStr += "<os>\n";
-        vmStr += "<type  machine='pc'>hvm</type>\n";
-        vmStr += "<boot dev='cdrom'/>\n";
-        vmStr += "<boot dev='hd'/>\n";
-        vmStr += "</os>\n";
-        //vmStr += "<cputune>\n";
-        //vmStr += "<shares>" + (cpus * minSpeed) + "</shares>\n";
-        //vmStr += "</cputune>\n";
-        vmStr += "<cpu></cpu>";
-        vmStr += "<on_reboot>restart</on_reboot>\n";
-        vmStr += "<on_poweroff>destroy</on_poweroff>\n";
-        vmStr += "<on_crash>destroy</on_crash>\n";
-        vmStr += "</domain>\n";
-
-        assertEquals(vmStr, vm.toString());
+        verifyVm(to, vm);
+    }
+
+    private void verifyVm(VirtualMachineTO to, LibvirtVMDef vm) {
+        Document domainDoc = parse(vm.toString());
+        assertXpath(domainDoc, "/domain/@type", vm.getHvsType());
+        assertXpath(domainDoc, "/domain/name/text()", to.getName());
+        assertXpath(domainDoc, "/domain/uuid/text()", to.getUuid());
+        assertXpath(domainDoc, "/domain/description/text()", to.getOs());
+        assertXpath(domainDoc, "/domain/clock/@offset", "utc");
+        assertNodeExists(domainDoc, "/domain/features/pae");
+        assertNodeExists(domainDoc, "/domain/features/apic");
+        assertNodeExists(domainDoc, "/domain/features/acpi");
+        assertXpath(domainDoc, "/domain/devices/serial/@type", "pty");
+        assertXpath(domainDoc, "/domain/devices/serial/target/@port", "0");
+        assertXpath(domainDoc, "/domain/devices/graphics/@type", "vnc");
+        assertXpath(domainDoc, "/domain/devices/graphics/@listen", to.getVncAddr());
+        assertXpath(domainDoc, "/domain/devices/graphics/@autoport", "yes");
+        assertXpath(domainDoc, "/domain/devices/graphics/@passwd", to.getVncPassword());
+
+        assertXpath(domainDoc, "/domain/devices/console/@type", "pty");
+        assertXpath(domainDoc, "/domain/devices/console/target/@port", "0");
+        assertXpath(domainDoc, "/domain/devices/input/@type", "tablet");
+        assertXpath(domainDoc, "/domain/devices/input/@bus", "usb");
+
+        assertXpath(domainDoc, "/domain/memory/text()", String.valueOf( to.getMaxRam() / 1024 ));
+        assertXpath(domainDoc, "/domain/currentMemory/text()", String.valueOf( to.getMinRam() / 1024 ));
+
+        assertXpath(domainDoc, "/domain/devices/memballoon/@model", "virtio");
+        assertXpath(domainDoc, "/domain/vcpu/text()", String.valueOf(to.getCpus()));
+
+        assertXpath(domainDoc, "/domain/os/type/@machine", "pc");
+        assertXpath(domainDoc, "/domain/os/type/text()", "hvm");
+
+        assertNodeExists(domainDoc, "/domain/cpu");
+        assertNodeExists(domainDoc, "/domain/os/boot[@dev='cdrom']");
+        assertNodeExists(domainDoc, "/domain/os/boot[@dev='hd']");
+
+        assertXpath(domainDoc, "/domain/on_reboot/text()", "restart");
+        assertXpath(domainDoc, "/domain/on_poweroff/text()", "destroy");
+        assertXpath(domainDoc, "/domain/on_crash/text()", "destroy");
+    }
+
+    static Document parse(final String input) {
+        try {
+            return DocumentBuilderFactory.newInstance().newDocumentBuilder()
+                    .parse(new ByteArrayInputStream(input.getBytes()));
+        } catch (SAXException | IOException | ParserConfigurationException e) {
+            throw new IllegalArgumentException("Cloud not parse: "+input, e);
+        }
+    }
+
+    static void assertNodeExists(final Document doc, final String xPathExpr) {
+        try {
+            Assert.assertNotNull(XPathFactory.newInstance().newXPath()
+                    .evaluate(xPathExpr, doc, XPathConstants.NODE));
+        } catch (XPathExpressionException e) {
+            Assert.fail(e.getMessage());
+        }
+    }
+
+    static void assertXpath(final Document doc, final String xPathExpr,
+            final String expected) {
+        try {
+            Assert.assertEquals(expected, XPathFactory.newInstance().newXPath()
+                    .evaluate(xPathExpr, doc));
+        } catch (XPathExpressionException e) {
+            Assert.fail("Could not evaluate xpath" + xPathExpr + ":"
+                    + e.getMessage());
+        }
     }
 
     @Test


[02/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
db: use explicit USE statements to avoid SQL failures

create-schema-premium.sql may fail with certain MySQL/MariaDB version which
require explicit database use.

Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/reporter
Commit: 09e26c826f3942946a9e3cbd0c632fc0c7791e56
Parents: 245c325
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Mon Feb 23 02:00:18 2015 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Mon Feb 23 02:00:18 2015 +0530

----------------------------------------------------------------------
 setup/db/create-schema-premium.sql | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/09e26c82/setup/db/create-schema-premium.sql
----------------------------------------------------------------------
diff --git a/setup/db/create-schema-premium.sql b/setup/db/create-schema-premium.sql
index a8feff4..3c86710 100644
--- a/setup/db/create-schema-premium.sql
+++ b/setup/db/create-schema-premium.sql
@@ -16,6 +16,7 @@
 -- under the License.
 
 SET foreign_key_checks = 0;
+USE `cloud_usage`;
 DROP TABLE IF EXISTS `cloud_usage`.`cloud_usage`;
 DROP TABLE IF EXISTS `cloud_usage`.`usage_vm_instance`;
 DROP TABLE IF EXISTS `cloud_usage`.`usage_ip_address`;
@@ -282,6 +283,8 @@ ALTER TABLE `cloud_usage`.`usage_security_group` ADD INDEX `i_usage_security_gro
 ALTER TABLE `cloud_usage`.`usage_security_group` ADD INDEX `i_usage_security_group__created`(`created`);
 ALTER TABLE `cloud_usage`.`usage_security_group` ADD INDEX `i_usage_security_group__deleted`(`deleted`);
 
+USE `cloud`;
+
 CREATE TABLE `cloud`.`netapp_volume` (
   `id` bigint unsigned NOT NULL UNIQUE AUTO_INCREMENT COMMENT 'id',
   `ip_address` varchar(255) NOT NULL COMMENT 'ip address/fqdn of the volume',


[19/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
Fix cloud.spec for building management rpm, need not create agent dir but agetn rpm (kvm host agent)


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

Branch: refs/heads/reporter
Commit: eaf734915fc2b61affcf8b9fb2b4b9fc7eeda2bf
Parents: b6d9163
Author: ghxandsky <gh...@gmail.com>
Authored: Thu Feb 26 23:51:43 2015 +0800
Committer: ghxandsky <gh...@gmail.com>
Committed: Thu Feb 26 23:51:43 2015 +0800

----------------------------------------------------------------------
 packaging/centos63/cloud.spec | 1 -
 packaging/centos7/cloud.spec  | 1 -
 packaging/fedora20/cloud.spec | 1 -
 packaging/fedora21/cloud.spec | 1 -
 4 files changed, 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/eaf73491/packaging/centos63/cloud.spec
----------------------------------------------------------------------
diff --git a/packaging/centos63/cloud.spec b/packaging/centos63/cloud.spec
index dff5dcb..5601dff 100644
--- a/packaging/centos63/cloud.spec
+++ b/packaging/centos63/cloud.spec
@@ -580,7 +580,6 @@ fi
 %dir %attr(0770,root,cloud) %{_localstatedir}/cache/%{name}/management/work
 %dir %attr(0770,root,cloud) %{_localstatedir}/cache/%{name}/management/temp
 %dir %attr(0770,root,cloud) %{_localstatedir}/log/%{name}/management
-%dir %attr(0770,root,cloud) %{_localstatedir}/log/%{name}/agent
 %dir %attr(0770,root,cloud) %{_localstatedir}/log/%{name}/awsapi
 %config(noreplace) %{_sysconfdir}/sysconfig/%{name}-management
 %config(noreplace) %attr(0640,root,cloud) %{_sysconfdir}/%{name}/management/db.properties

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/eaf73491/packaging/centos7/cloud.spec
----------------------------------------------------------------------
diff --git a/packaging/centos7/cloud.spec b/packaging/centos7/cloud.spec
index 88c3190..3aec349 100644
--- a/packaging/centos7/cloud.spec
+++ b/packaging/centos7/cloud.spec
@@ -490,7 +490,6 @@ fi
 %dir %attr(0770,root,cloud) %{_localstatedir}/cache/%{name}/management/work
 %dir %attr(0770,root,cloud) %{_localstatedir}/cache/%{name}/management/temp
 %dir %attr(0770,root,cloud) %{_localstatedir}/log/%{name}/management
-%dir %attr(0770,root,cloud) %{_localstatedir}/log/%{name}/agent
 %dir %attr(0770,root,cloud) %{_localstatedir}/log/%{name}/awsapi
 %config(noreplace) %{_sysconfdir}/sysconfig/%{name}-management
 %config(noreplace) %{_sysconfdir}/sudoers.d/%{name}-management

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/eaf73491/packaging/fedora20/cloud.spec
----------------------------------------------------------------------
diff --git a/packaging/fedora20/cloud.spec b/packaging/fedora20/cloud.spec
index ea1739e..d0269f7 100644
--- a/packaging/fedora20/cloud.spec
+++ b/packaging/fedora20/cloud.spec
@@ -582,7 +582,6 @@ fi
 %dir %attr(0770,root,cloud) %{_localstatedir}/cache/%{name}/management/work
 %dir %attr(0770,root,cloud) %{_localstatedir}/cache/%{name}/management/temp
 %dir %attr(0770,root,cloud) %{_localstatedir}/log/%{name}/management
-%dir %attr(0770,root,cloud) %{_localstatedir}/log/%{name}/agent
 %dir %attr(0770,root,cloud) %{_localstatedir}/log/%{name}/awsapi
 %config(noreplace) %{_sysconfdir}/sysconfig/%{name}-management
 %config(noreplace) %attr(0640,root,cloud) %{_sysconfdir}/%{name}/management/db.properties

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/eaf73491/packaging/fedora21/cloud.spec
----------------------------------------------------------------------
diff --git a/packaging/fedora21/cloud.spec b/packaging/fedora21/cloud.spec
index 2338b3c..73de980 100644
--- a/packaging/fedora21/cloud.spec
+++ b/packaging/fedora21/cloud.spec
@@ -582,7 +582,6 @@ fi
 %dir %attr(0770,root,cloud) %{_localstatedir}/cache/%{name}/management/work
 %dir %attr(0770,root,cloud) %{_localstatedir}/cache/%{name}/management/temp
 %dir %attr(0770,root,cloud) %{_localstatedir}/log/%{name}/management
-%dir %attr(0770,root,cloud) %{_localstatedir}/log/%{name}/agent
 %dir %attr(0770,root,cloud) %{_localstatedir}/log/%{name}/awsapi
 %config(noreplace) %{_sysconfdir}/sysconfig/%{name}-management
 %config(noreplace) %attr(0640,root,cloud) %{_sysconfdir}/%{name}/management/db.properties


[31/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
Merge branch 'master' of https://github.com/ghxandsky/cloudstack


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

Branch: refs/heads/reporter
Commit: a831beb9820de2284bbaf5a20264cea4c14cdf76
Parents: 694a694 eaf7349
Author: Daan Hoogland <da...@onecht.net>
Authored: Sat Feb 28 00:03:33 2015 +0100
Committer: Daan Hoogland <da...@onecht.net>
Committed: Sat Feb 28 00:03:33 2015 +0100

----------------------------------------------------------------------
 packaging/centos63/cloud.spec | 1 -
 packaging/centos7/cloud.spec  | 1 -
 packaging/fedora20/cloud.spec | 1 -
 packaging/fedora21/cloud.spec | 1 -
 packaging/package.sh          | 2 +-
 5 files changed, 1 insertion(+), 5 deletions(-)
----------------------------------------------------------------------



[21/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
CLOUDSTACK-5237: Add a default PBKDF2-SHA-256 based authenticator

Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
(cherry picked from commit 9533c54db669b22b268fcc21766e21c231e48d84)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/reporter
Commit: 6f4db0ce4b493106eb4ac06737d3f2e9781ed535
Parents: d8e1bf1
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Fri Feb 27 15:45:06 2015 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Fri Feb 27 15:53:58 2015 +0530

----------------------------------------------------------------------
 client/pom.xml                                  |   5 +
 .../core/spring-core-registry-core-context.xml  |   4 +-
 plugins/pom.xml                                 |   1 +
 plugins/user-authenticators/pbkdf2/pom.xml      |  29 ++++
 .../cloudstack/pbkdf2/module.properties         |  18 +++
 .../cloudstack/pbkdf2/spring-pbkdf2-context.xml |  32 +++++
 .../server/auth/PBKDF2UserAuthenticator.java    | 143 +++++++++++++++++++
 .../server/auth/PBKD2UserAuthenticatorTest.java |  75 ++++++++++
 8 files changed, 305 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6f4db0ce/client/pom.xml
----------------------------------------------------------------------
diff --git a/client/pom.xml b/client/pom.xml
index 590a9ad..9453159 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -77,6 +77,11 @@
     </dependency>
     <dependency>
       <groupId>org.apache.cloudstack</groupId>
+      <artifactId>cloud-plugin-user-authenticator-pbkdf2</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.cloudstack</groupId>
       <artifactId>cloud-plugin-user-authenticator-plaintext</artifactId>
       <version>${project.version}</version>
     </dependency>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6f4db0ce/core/resources/META-INF/cloudstack/core/spring-core-registry-core-context.xml
----------------------------------------------------------------------
diff --git a/core/resources/META-INF/cloudstack/core/spring-core-registry-core-context.xml b/core/resources/META-INF/cloudstack/core/spring-core-registry-core-context.xml
index 939cffe..d967540 100644
--- a/core/resources/META-INF/cloudstack/core/spring-core-registry-core-context.xml
+++ b/core/resources/META-INF/cloudstack/core/spring-core-registry-core-context.xml
@@ -33,7 +33,7 @@
         class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
         <property name="orderConfigKey" value="user.authenticators.order" />
         <property name="excludeKey" value="user.authenticators.exclude" />
-        <property name="orderConfigDefault" value="SHA256SALT,MD5,LDAP,SAML2,PLAINTEXT" />
+        <property name="orderConfigDefault" value="PBKDF2,SHA256SALT,MD5,LDAP,SAML2,PLAINTEXT" />
     </bean>
 
     <bean id="pluggableAPIAuthenticatorsRegistry"
@@ -47,7 +47,7 @@
         class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
         <property name="orderConfigKey" value="user.password.encoders.order" />
         <property name="excludeKey" value="user.password.encoders.exclude" />
-        <property name="orderConfigDefault" value="SHA256SALT,MD5,LDAP,PLAINTEXT" />
+        <property name="orderConfigDefault" value="PBKDF2,SHA256SALT,MD5,LDAP,SAML2,PLAINTEXT" />
     </bean>
 
     <bean id="securityCheckersRegistry"

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6f4db0ce/plugins/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/pom.xml b/plugins/pom.xml
index 76119dc..962ce46 100755
--- a/plugins/pom.xml
+++ b/plugins/pom.xml
@@ -71,6 +71,7 @@
     <module>storage-allocators/random</module>
     <module>user-authenticators/ldap</module>
     <module>user-authenticators/md5</module>
+    <module>user-authenticators/pbkdf2</module>
     <module>user-authenticators/plain-text</module>
     <module>user-authenticators/saml2</module>
     <module>user-authenticators/sha256salted</module>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6f4db0ce/plugins/user-authenticators/pbkdf2/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/pbkdf2/pom.xml b/plugins/user-authenticators/pbkdf2/pom.xml
new file mode 100644
index 0000000..e656045
--- /dev/null
+++ b/plugins/user-authenticators/pbkdf2/pom.xml
@@ -0,0 +1,29 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>cloud-plugin-user-authenticator-pbkdf2</artifactId>
+  <name>Apache CloudStack Plugin - User Authenticator PBKDF2-SHA-256</name>
+  <parent>
+    <groupId>org.apache.cloudstack</groupId>
+    <artifactId>cloudstack-plugins</artifactId>
+    <version>4.5.0-SNAPSHOT</version>
+    <relativePath>../../pom.xml</relativePath>
+  </parent>
+</project>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6f4db0ce/plugins/user-authenticators/pbkdf2/resources/META-INF/cloudstack/pbkdf2/module.properties
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/pbkdf2/resources/META-INF/cloudstack/pbkdf2/module.properties b/plugins/user-authenticators/pbkdf2/resources/META-INF/cloudstack/pbkdf2/module.properties
new file mode 100644
index 0000000..7c2b38d
--- /dev/null
+++ b/plugins/user-authenticators/pbkdf2/resources/META-INF/cloudstack/pbkdf2/module.properties
@@ -0,0 +1,18 @@
+# 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.
+name=pbkdf2
+parent=api

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6f4db0ce/plugins/user-authenticators/pbkdf2/resources/META-INF/cloudstack/pbkdf2/spring-pbkdf2-context.xml
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/pbkdf2/resources/META-INF/cloudstack/pbkdf2/spring-pbkdf2-context.xml b/plugins/user-authenticators/pbkdf2/resources/META-INF/cloudstack/pbkdf2/spring-pbkdf2-context.xml
new file mode 100644
index 0000000..a6272dd
--- /dev/null
+++ b/plugins/user-authenticators/pbkdf2/resources/META-INF/cloudstack/pbkdf2/spring-pbkdf2-context.xml
@@ -0,0 +1,32 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xmlns:aop="http://www.springframework.org/schema/aop"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
+                      http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+                      http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
+                      http://www.springframework.org/schema/context
+                      http://www.springframework.org/schema/context/spring-context-3.0.xsd"
+                      >
+    <bean id="PBKDF2UserAuthenticator" class="org.apache.cloudstack.server.auth.PBKDF2UserAuthenticator">
+        <property name="name" value="PBKDF2"/>
+    </bean>
+</beans>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6f4db0ce/plugins/user-authenticators/pbkdf2/src/org/apache/cloudstack/server/auth/PBKDF2UserAuthenticator.java
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/pbkdf2/src/org/apache/cloudstack/server/auth/PBKDF2UserAuthenticator.java b/plugins/user-authenticators/pbkdf2/src/org/apache/cloudstack/server/auth/PBKDF2UserAuthenticator.java
new file mode 100644
index 0000000..43c32c7
--- /dev/null
+++ b/plugins/user-authenticators/pbkdf2/src/org/apache/cloudstack/server/auth/PBKDF2UserAuthenticator.java
@@ -0,0 +1,143 @@
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//    http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+
+package org.apache.cloudstack.server.auth;
+
+import com.cloud.server.auth.DefaultUserAuthenticator;
+import com.cloud.server.auth.UserAuthenticator;
+import com.cloud.user.UserAccount;
+import com.cloud.user.dao.UserAccountDao;
+import com.cloud.utils.ConstantTimeComparator;
+import com.cloud.utils.Pair;
+import com.cloud.utils.exception.CloudRuntimeException;
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+import org.bouncycastle.crypto.PBEParametersGenerator;
+import org.bouncycastle.crypto.generators.PKCS5S2ParametersGenerator;
+import org.bouncycastle.crypto.params.KeyParameter;
+import org.bouncycastle.util.encoders.Base64;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+import java.io.UnsupportedEncodingException;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+import java.security.spec.InvalidKeySpecException;
+import java.util.Map;
+
+import static java.lang.String.format;
+
+@Local({UserAuthenticator.class})
+public class PBKDF2UserAuthenticator extends DefaultUserAuthenticator {
+    public static final Logger s_logger = Logger.getLogger(PBKDF2UserAuthenticator.class);
+    private static final int s_saltlen = 64;
+    private static final int s_rounds = 100000;
+    private static final int s_keylen = 512;
+
+    @Inject
+    private UserAccountDao _userAccountDao;
+
+    public Pair<Boolean, UserAuthenticator.ActionOnFailedAuthentication> authenticate(String username, String password, Long domainId, Map<String, Object[]> requestParameters) {
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Retrieving user: " + username);
+        }
+        boolean isValidUser = false;
+        UserAccount user = this._userAccountDao.getUserAccount(username, domainId);
+        if (user != null) {
+            isValidUser = true;
+        } else {
+            s_logger.debug("Unable to find user with " + username + " in domain " + domainId);
+        }
+
+        byte[] salt = new byte[0];
+        int rounds = s_rounds;
+        try {
+            if (isValidUser) {
+                String[] storedPassword = user.getPassword().split(":");
+                if ((storedPassword.length != 3) || (!StringUtils.isNumeric(storedPassword[2]))) {
+                    s_logger.warn("The stored password for " + username + " isn't in the right format for this authenticator");
+                    isValidUser = false;
+                } else {
+                    // Encoding format = <salt>:<password hash>:<rounds>
+                    salt = decode(storedPassword[0]);
+                    rounds = Integer.parseInt(storedPassword[2]);
+                }
+            }
+            boolean result = false;
+            if (isValidUser && validateCredentials(password, salt)) {
+                result = ConstantTimeComparator.compareStrings(user.getPassword(), encode(password, salt, rounds));
+            }
+
+            UserAuthenticator.ActionOnFailedAuthentication action = null;
+            if ((!result) && (isValidUser)) {
+                action = UserAuthenticator.ActionOnFailedAuthentication.INCREMENT_INCORRECT_LOGIN_ATTEMPT_COUNT;
+            }
+            return new Pair(Boolean.valueOf(result), action);
+        } catch (NumberFormatException e) {
+            throw new CloudRuntimeException("Unable to hash password", e);
+        } catch (NoSuchAlgorithmException e) {
+            throw new CloudRuntimeException("Unable to hash password", e);
+        } catch (UnsupportedEncodingException e) {
+            throw new CloudRuntimeException("Unable to hash password", e);
+        } catch (InvalidKeySpecException e) {
+            throw new CloudRuntimeException("Unable to hash password", e);
+        }
+    }
+
+    public String encode(String password)
+    {
+        try
+        {
+            return encode(password, makeSalt(), s_rounds);
+        } catch (NoSuchAlgorithmException e) {
+            throw new CloudRuntimeException("Unable to hash password", e);
+        } catch (UnsupportedEncodingException e) {
+            throw new CloudRuntimeException("Unable to hash password", e);
+        } catch (InvalidKeySpecException e) {
+            s_logger.error("Exception in EncryptUtil.createKey ", e);
+            throw new CloudRuntimeException("Unable to hash password", e);
+        }
+    }
+
+    public String encode(String password, byte[] salt, int rounds)
+            throws UnsupportedEncodingException, NoSuchAlgorithmException, InvalidKeySpecException {
+        PKCS5S2ParametersGenerator generator = new PKCS5S2ParametersGenerator();
+        generator.init(PBEParametersGenerator.PKCS5PasswordToBytes(
+                        password.toCharArray()),
+                salt,
+                rounds);
+        return format("%s:%s:%d", encode(salt),
+                encode(((KeyParameter)generator.generateDerivedParameters(s_keylen)).getKey()), rounds);
+    }
+
+    public static byte[] makeSalt() throws NoSuchAlgorithmException {
+        SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");
+        byte[] salt = new byte[s_saltlen];
+        sr.nextBytes(salt);
+        return salt;
+    }
+
+    private static boolean validateCredentials(String plainPassword, byte[] hash) {
+        return !(plainPassword == null || plainPassword.isEmpty() || hash == null || hash.length == 0);
+    }
+
+    private static String encode(byte[] input) {
+        return new String(Base64.encode(input));
+    }
+
+    private static byte[] decode(String input) throws UnsupportedEncodingException {
+        return Base64.decode(input.getBytes("UTF-8"));
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6f4db0ce/plugins/user-authenticators/pbkdf2/test/org/apache/cloudstack/server/auth/PBKD2UserAuthenticatorTest.java
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/pbkdf2/test/org/apache/cloudstack/server/auth/PBKD2UserAuthenticatorTest.java b/plugins/user-authenticators/pbkdf2/test/org/apache/cloudstack/server/auth/PBKD2UserAuthenticatorTest.java
new file mode 100644
index 0000000..f401416
--- /dev/null
+++ b/plugins/user-authenticators/pbkdf2/test/org/apache/cloudstack/server/auth/PBKD2UserAuthenticatorTest.java
@@ -0,0 +1,75 @@
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//    http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+
+package org.apache.cloudstack.server.auth;
+
+import com.cloud.server.auth.UserAuthenticator;
+import com.cloud.user.UserAccountVO;
+import com.cloud.user.dao.UserAccountDao;
+import com.cloud.utils.Pair;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+
+import java.lang.reflect.Field;
+import java.security.NoSuchAlgorithmException;
+
+@RunWith(MockitoJUnitRunner.class)
+public class PBKD2UserAuthenticatorTest {
+    @Mock
+    UserAccountDao dao;
+
+    @Test
+    public void encodePasswordTest() {
+        PBKDF2UserAuthenticator authenticator = new PBKDF2UserAuthenticator();
+        String encodedPassword = authenticator.encode("password123ABCS!@#$%");
+        Assert.assertTrue(encodedPassword.length() < 255 && encodedPassword.length() >= 182);
+    }
+
+    @Test
+    public void saltTest() throws NoSuchAlgorithmException {
+        byte[] salt = new PBKDF2UserAuthenticator().makeSalt();
+        Assert.assertTrue(salt.length > 16);
+    }
+
+    @Test
+    public void authenticateValidTest() throws IllegalAccessException, NoSuchFieldException {
+        PBKDF2UserAuthenticator authenticator = new PBKDF2UserAuthenticator();
+        Field daoField = PBKDF2UserAuthenticator.class.getDeclaredField("_userAccountDao");
+        daoField.setAccessible(true);
+        daoField.set(authenticator, dao);
+        UserAccountVO account = new UserAccountVO();
+        account.setPassword("FMDMdx/2QjrZniqNRAgOAC1ai/CY/C+2kmKhp3vo+98pkqhO+AR6hCyUl0bOXtkq3XWqNiSQTwbi7KTiwuWhyw==:+u8T5LzCtikCPvKnUDn6JDezf1Hg2bood/ke5Oo93pz9s1eD9k/JLsa497Z3h9QWfOQfq0zvCRmkzfXMF913vQ==:4096");
+        Mockito.when(dao.getUserAccount(Mockito.anyString(), Mockito.anyLong())).thenReturn(account);
+        Pair<Boolean, UserAuthenticator.ActionOnFailedAuthentication> pair = authenticator.authenticate("admin", "password", 1l, null);
+        Assert.assertTrue(pair.first());
+    }
+
+    @Test
+    public void authenticateInValidTest() throws IllegalAccessException, NoSuchFieldException {
+        PBKDF2UserAuthenticator authenticator = new PBKDF2UserAuthenticator();
+        Field daoField = PBKDF2UserAuthenticator.class.getDeclaredField("_userAccountDao");
+        daoField.setAccessible(true);
+        daoField.set(authenticator, dao);
+        UserAccountVO account = new UserAccountVO();
+        account.setPassword("5f4dcc3b5aa765d61d8327deb882cf99");
+        Mockito.when(dao.getUserAccount(Mockito.anyString(), Mockito.anyLong())).thenReturn(account);
+        Pair<Boolean, UserAuthenticator.ActionOnFailedAuthentication> pair = authenticator.authenticate("admin", "password", 1l, null);
+        Assert.assertFalse(pair.first());
+    }
+}


[13/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f3931993/test/integration/component/test_multiple_ips_per_nic.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_multiple_ips_per_nic.py b/test/integration/component/test_multiple_ips_per_nic.py
index 58aac9f..536c39d 100644
--- a/test/integration/component/test_multiple_ips_per_nic.py
+++ b/test/integration/component/test_multiple_ips_per_nic.py
@@ -23,15 +23,34 @@
     Design Document: https://cwiki.apache.org/confluence/display/CLOUDSTACK/Multiple+IP+address+per+NIC
 """
 from marvin.cloudstackTestCase import cloudstackTestCase
-from marvin.lib.utils import *
-from marvin.lib.base import *
-from marvin.lib.common import *
-
+from marvin.lib.utils import (cleanup_resources,
+                              random_gen,
+                              validateList)
+from marvin.lib.base import (Account,
+                             VirtualMachine,
+                             PublicIPAddress,
+                             NATRule,
+                             StaticNATRule,
+                             FireWallRule,
+                             NIC,
+                             Network,
+                             VPC,
+                             ServiceOffering,
+                             VpcOffering,
+                             Domain,
+                             Router)
+from marvin.lib.common import (get_domain,
+                               get_template,
+                               get_zone,
+                               setSharedNetworkParams,
+                               get_free_vlan,
+                               createEnabledNetworkOffering)
 from nose.plugins.attrib import attr
-from marvin.codes import PASS, ISOLATED_NETWORK, VPC_NETWORK, SHARED_NETWORK, FAIL
+from marvin.codes import PASS, ISOLATED_NETWORK, VPC_NETWORK, SHARED_NETWORK, FAIL, FAILED
 from ddt import ddt, data
 import time
 
+
 def createNetwork(self, networkType):
     """Create a network of given type (isolated/shared/isolated in VPC)"""
 
@@ -39,27 +58,36 @@ def createNetwork(self, networkType):
 
     if networkType == ISOLATED_NETWORK:
         try:
-            network = Network.create(self.apiclient,self.services["isolated_network"],
-                                     networkofferingid=self.isolated_network_offering.id,
-                                     accountid=self.account.name,domainid=self.account.domainid,
-                                     zoneid=self.zone.id)
+            network = Network.create(
+                self.apiclient,
+                self.services["isolated_network"],
+                networkofferingid=self.isolated_network_offering.id,
+                accountid=self.account.name,
+                domainid=self.account.domainid,
+                zoneid=self.zone.id)
         except Exception as e:
             self.fail("Isolated network creation failed because: %s" % e)
 
     elif networkType == SHARED_NETWORK:
         physical_network, vlan = get_free_vlan(self.api_client, self.zone.id)
 
-        #create network using the shared network offering created
+        # create network using the shared network offering created
         self.services["shared_network"]["acltype"] = "domain"
         self.services["shared_network"]["vlan"] = vlan
-        self.services["shared_network"]["networkofferingid"] = self.shared_network_offering.id
-        self.services["shared_network"]["physicalnetworkid"] = physical_network.id
+        self.services["shared_network"][
+            "networkofferingid"] = self.shared_network_offering.id
+        self.services["shared_network"][
+            "physicalnetworkid"] = physical_network.id
 
-        self.services["shared_network"] = setSharedNetworkParams(self.services["shared_network"])
+        self.services["shared_network"] = setSharedNetworkParams(
+            self.services["shared_network"])
 
         try:
-            network = Network.create(self.api_client, self.services["shared_network"],
-                                     networkofferingid=self.shared_network_offering.id, zoneid=self.zone.id)
+            network = Network.create(
+                self.api_client,
+                self.services["shared_network"],
+                networkofferingid=self.shared_network_offering.id,
+                zoneid=self.zone.id)
             self.cleanup.append(network)
         except Exception as e:
             self.fail("Shared Network creation failed because: %s" % e)
@@ -67,53 +95,96 @@ def createNetwork(self, networkType):
     elif networkType == VPC_NETWORK:
         self.services["vpc"]["cidr"] = "10.1.1.1/16"
         self.debug("creating a VPC network in the account: %s" %
-                                                    self.account.name)
-        vpc = VPC.create(self.apiclient, self.services["vpc"],
-                         vpcofferingid=self.vpc_off.id, zoneid=self.zone.id,
-                         account=self.account.name, domainid=self.account.domainid)
+                   self.account.name)
+        vpc = VPC.create(
+            self.apiclient,
+            self.services["vpc"],
+            vpcofferingid=self.vpc_off.id,
+            zoneid=self.zone.id,
+            account=self.account.name,
+            domainid=self.account.domainid)
         vpcs = VPC.list(self.apiclient, id=vpc.id)
-        self.assertEqual(validateList(vpcs)[0], PASS, "VPC list validation failed, vpc list is %s" % vpcs)
-
-        network = Network.create(self.api_client,self.services["isolated_network"],
-                                 networkofferingid=self.isolated_network_offering_vpc.id,
-                                 accountid=self.account.name,domainid=self.account.domainid,
-                                 zoneid=self.zone.id, vpcid=vpc.id, gateway="10.1.1.1", netmask="255.255.255.0")
+        self.assertEqual(
+            validateList(vpcs)[0],
+            PASS,
+            "VPC list validation failed, vpc list is %s" %
+            vpcs)
+
+        network = Network.create(
+            self.api_client,
+            self.services["isolated_network"],
+            networkofferingid=self.isolated_network_offering_vpc.id,
+            accountid=self.account.name,
+            domainid=self.account.domainid,
+            zoneid=self.zone.id,
+            vpcid=vpc.id,
+            gateway="10.1.1.1",
+            netmask="255.255.255.0")
     return network
 
+
 def CreateEnabledNetworkOffering(apiclient, networkServices):
     """Create network offering of given services and enable it"""
 
     result = createEnabledNetworkOffering(apiclient, networkServices)
-    assert result[0] == PASS, "Network offering creation/enabling failed due to %s" % result[2]
+    assert result[
+        0] == PASS, "Network offering creation/enabling failed due to %s" % result[2]
     return result[1]
 
-def createNetworkRules(self, virtual_machine, network, vmguestip, networktype, ruletype):
+
+def createNetworkRules(
+        self,
+        virtual_machine,
+        network,
+        vmguestip,
+        networktype,
+        ruletype):
     """ Acquire public ip in the given network, open firewall if required and
         create NAT rule for the public ip to the given guest vm ip address"""
 
     try:
-        public_ip = PublicIPAddress.create(self.api_client,accountid=self.account.name,
-                                           zoneid=self.zone.id,domainid=self.account.domainid,
-                                           networkid=network.id, vpcid = network.vpcid if networktype == VPC_NETWORK else None)
+        public_ip = PublicIPAddress.create(
+            self.api_client,
+            accountid=self.account.name,
+            zoneid=self.zone.id,
+            domainid=self.account.domainid,
+            networkid=network.id,
+            vpcid=network.vpcid if networktype == VPC_NETWORK else None)
 
         if networktype != VPC_NETWORK:
-            FireWallRule.create(self.apiclient,ipaddressid=public_ip.ipaddress.id,
-                                      protocol='TCP', cidrlist=[self.services["fwrule"]["cidr"]],
-                                      startport=self.services["fwrule"]["startport"],endport=self.services["fwrule"]["endport"])
+            FireWallRule.create(
+                self.apiclient,
+                ipaddressid=public_ip.ipaddress.id,
+                protocol='TCP',
+                cidrlist=[
+                    self.services["fwrule"]["cidr"]],
+                startport=self.services["fwrule"]["startport"],
+                endport=self.services["fwrule"]["endport"])
 
         if ruletype == "nat":
-            NATRule.create(self.api_client, virtual_machine,
-                       self.services["natrule"],ipaddressid=public_ip.ipaddress.id,
-                       networkid=network.id, vmguestip = vmguestip)
+            NATRule.create(
+                self.api_client,
+                virtual_machine,
+                self.services["natrule"],
+                ipaddressid=public_ip.ipaddress.id,
+                networkid=network.id,
+                vmguestip=vmguestip)
         elif ruletype == "staticnat":
-            StaticNATRule.enable(self.apiclient, public_ip.ipaddress.id, virtual_machine.id, network.id, vmguestip=vmguestip)
-    except Exception:
+            StaticNATRule.enable(
+                self.apiclient,
+                public_ip.ipaddress.id,
+                virtual_machine.id,
+                network.id,
+                vmguestip=vmguestip)
+    except Exception as e:
+        self.debug("Exception occured while creating network rules: %s" % e)
         return FAIL
-
     return PASS
 
+
 @ddt
 class TestBasicOperations(cloudstackTestCase):
+
     """Test Basic operations (add/remove/list) IP to/from NIC
     """
 
@@ -129,34 +200,42 @@ class TestBasicOperations(cloudstackTestCase):
         cls.domain = get_domain(cls.api_client)
         cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.template = get_template(
-                            cls.api_client,
-                            cls.zone.id,
-                            cls.services["ostype"]
-                            )
+            cls.api_client,
+            cls.zone.id,
+            cls.services["ostype"]
+        )
         if cls.template == FAILED:
-            assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+            assert False, "get_template() failed to return template with description %s" % cls.services[
+                "ostype"]
 
         cls.services["virtual_machine"]["zoneid"] = cls.zone.id
         cls.services["virtual_machine"]["template"] = cls.template.id
         cls.service_offering = ServiceOffering.create(
-                                            cls.api_client,
-                                            cls.services["service_offering"]
-                                            )
+            cls.api_client,
+            cls.services["service_offering"]
+        )
         cls._cleanup = [cls.service_offering]
-        cls.services["shared_network_offering_all_services"]["specifyVlan"] = "True"
-        cls.services["shared_network_offering_all_services"]["specifyIpRanges"] = "True"
-
-        cls.shared_network_offering = CreateEnabledNetworkOffering(cls.api_client,
-                                                                      cls.services["shared_network_offering_all_services"])
+        cls.services["shared_network_offering_all_services"][
+            "specifyVlan"] = "True"
+        cls.services["shared_network_offering_all_services"][
+            "specifyIpRanges"] = "True"
+
+        cls.shared_network_offering = CreateEnabledNetworkOffering(
+            cls.api_client,
+            cls.services["shared_network_offering_all_services"])
         cls._cleanup.append(cls.shared_network_offering)
         cls.mode = cls.zone.networktype
-        cls.isolated_network_offering = CreateEnabledNetworkOffering(cls.api_client,
-                                                                      cls.services["isolated_network_offering"])
+        cls.isolated_network_offering = CreateEnabledNetworkOffering(
+            cls.api_client,
+            cls.services["isolated_network_offering"])
         cls._cleanup.append(cls.isolated_network_offering)
-        cls.isolated_network_offering_vpc = CreateEnabledNetworkOffering(cls.api_client,
-                                                    cls.services["nw_offering_isolated_vpc"])
+        cls.isolated_network_offering_vpc = CreateEnabledNetworkOffering(
+            cls.api_client,
+            cls.services["nw_offering_isolated_vpc"])
         cls._cleanup.append(cls.isolated_network_offering_vpc)
-        cls.vpc_off = VpcOffering.create(cls.api_client, cls.services["vpc_offering"])
+        cls.vpc_off = VpcOffering.create(
+            cls.api_client,
+            cls.services["vpc_offering"])
         cls.vpc_off.update(cls.api_client, state='Enabled')
         cls._cleanup.append(cls.vpc_off)
         return
@@ -173,7 +252,7 @@ class TestBasicOperations(cloudstackTestCase):
     def setUp(self):
         self.apiclient = self.testClient.getApiClient()
         self.dbclient = self.testClient.getDbConnection()
-        self.cleanup = [ ]
+        self.cleanup = []
         return
 
     def tearDown(self):
@@ -188,14 +267,24 @@ class TestBasicOperations(cloudstackTestCase):
     def VerifyStaticNatForPublicIp(self, ipaddressid, natrulestatus):
         """ List public IP and verify that NAT rule status for the IP is as desired """
 
-        publiciplist = PublicIPAddress.list(self.apiclient, id=ipaddressid, listall=True)
-        self.assertEqual(validateList(publiciplist)[0], PASS, "Public IP list validation failed")
-        self.assertEqual(publiciplist[0].isstaticnat, natrulestatus, "isstaticnat should be %s, it is %s" %
-                (natrulestatus, publiciplist[0].isstaticnat))
+        publiciplist = PublicIPAddress.list(
+            self.apiclient,
+            id=ipaddressid,
+            listall=True)
+        self.assertEqual(
+            validateList(publiciplist)[0],
+            PASS,
+            "Public IP list validation failed")
+        self.assertEqual(
+            publiciplist[0].isstaticnat,
+            natrulestatus,
+            "isstaticnat should be %s, it is %s" %
+            (natrulestatus,
+             publiciplist[0].isstaticnat))
 
         return
 
-    @data(ISOLATED_NETWORK, SHARED_NETWORK, VPC_NETWORK)
+    @data(SHARED_NETWORK)
     @attr(tags=["advanced"])
     def test_add_ip_to_nic(self, value):
         """ Add secondary IP to NIC of a VM"""
@@ -206,7 +295,8 @@ class TestBasicOperations(cloudstackTestCase):
         # 3. Add secondary IP to the default nic of VM
         # 4. Try to add the same IP again
         # 5. Try to add secondary IP providing wrong virtual machine id
-        # 6. Try to add secondary IP with correct virtual machine id but wrong IP address
+        # 6. Try to add secondary IP with correct virtual machine id but wrong
+        # IP address
 
         # Validations:
         # 1. Step 3 should succeed
@@ -214,41 +304,60 @@ class TestBasicOperations(cloudstackTestCase):
         # 3. Step 5 should should fail
         # 4. Step 6 should fail
 
-        self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id)
+        self.account = Account.create(
+            self.apiclient,
+            self.services["account"],
+            domainid=self.domain.id)
         self.cleanup.append(self.account)
 
         network = createNetwork(self, value)
 
-        try:
-            virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"],
-                                                    networkids=[network.id],serviceofferingid=self.service_offering.id,
-                                                    accountid=self.account.name,domainid=self.account.domainid)
-        except Exception as e:
-            self.fail("vm creation failed: %s" % e)
+        virtual_machine = VirtualMachine.create(
+            self.apiclient,
+            self.services["virtual_machine"],
+            networkids=[
+                network.id],
+            serviceofferingid=self.service_offering.id,
+            accountid=self.account.name,
+            domainid=self.account.domainid)
 
-        try:
-            ipaddress_1 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
-        except Exception as e:
-            self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id)
+        ipaddress_1 = NIC.addIp(
+            self.apiclient,
+            id=virtual_machine.nic[0].id)
 
         try:
-            NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id, ipaddress=ipaddress_1.ipaddress)
-            self.debug("Adding already added secondary IP %s to NIC of vm %s succeeded, should have failed" %
-                    (ipaddress_1.ipaddress, virtual_machine.id))
+            NIC.addIp(
+                self.apiclient,
+                id=virtual_machine.nic[0].id,
+                ipaddress=ipaddress_1.ipaddress)
+            self.debug(
+                "Adding already added secondary IP %s to NIC of vm %s succeeded, should have failed" %
+                (ipaddress_1.ipaddress, virtual_machine.id))
         except Exception as e:
-            self.debug("Failed while adding already added secondary IP to NIC of vm %s" % virtual_machine.id)
+            self.debug(
+                "Failed while adding already added secondary IP to NIC of vm %s" %
+                virtual_machine.id)
 
         try:
-            NIC.addIp(self.apiclient, id=(virtual_machine.nic[0].id + random_gen()))
-            self.fail("Adding secondary IP with wrong NIC id succeded, it shoud have failed")
+            NIC.addIp(
+                self.apiclient, id=(
+                    virtual_machine.nic[0].id + random_gen()))
+            self.fail(
+                "Adding secondary IP with wrong NIC id succeded, it shoud have failed")
         except Exception as e:
             self.debug("Failed while adding secondary IP to wrong NIC")
 
         try:
-            NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id, ipaddress = "255.255.255.300")
-            self.fail("Adding secondary IP with wrong ipaddress succeded, it should have failed")
+            NIC.addIp(
+                self.apiclient,
+                id=virtual_machine.nic[0].id,
+                ipaddress="255.255.255.300")
+            self.fail(
+                "Adding secondary IP with wrong ipaddress succeded, it should have failed")
         except Exception as e:
-            self.debug("Failed while adding wrong secondary IP to NIC of VM %s" % virtual_machine.id)
+            self.debug(
+                "Failed while adding wrong secondary IP to NIC of VM %s: %s" %
+                (virtual_machine.id, e))
         return
 
     @data(ISOLATED_NETWORK, SHARED_NETWORK, VPC_NETWORK)
@@ -267,33 +376,39 @@ class TestBasicOperations(cloudstackTestCase):
         # 1. Step 4 should succeed
         # 2. Step 5 should fail
 
-        self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id)
+        self.account = Account.create(
+            self.apiclient,
+            self.services["account"],
+            domainid=self.domain.id)
         self.cleanup.append(self.account)
 
         network = createNetwork(self, value)
 
-        try:
-            virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"],
-                                                    networkids=[network.id],serviceofferingid=self.service_offering.id,
-                                                    accountid=self.account.name,domainid=self.account.domainid)
-        except Exception as e:
-            self.fail("vm creation failed: %s" % e)
-
-        try:
-            ipaddress_1 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
-        except Exception as e:
-            self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id)
+        virtual_machine = VirtualMachine.create(
+            self.apiclient,
+            self.services["virtual_machine"],
+            networkids=[
+                network.id],
+            serviceofferingid=self.service_offering.id,
+            accountid=self.account.name,
+            domainid=self.account.domainid)
 
-        try:
-            NIC.removeIp(self.apiclient, ipaddressid=ipaddress_1.id)
-        except Exception as e:
-            self.fail("Removing seondary IP %s from NIC failed as expected with Exception %s" % (ipaddress_1.id,e))
+        ipaddress_1 = NIC.addIp(
+            self.apiclient,
+            id=virtual_machine.nic[0].id)
 
+        NIC.removeIp(self.apiclient, ipaddressid=ipaddress_1.id)
         try:
-            NIC.removeIp(self.apiclient, ipaddressid=(ipaddress_1.id + random_gen()))
+            NIC.removeIp(
+                self.apiclient,
+                ipaddressid=(
+                    ipaddress_1.id +
+                    random_gen()))
             self.fail("Removing invalid IP address, it should have failed")
         except Exception as e:
-            self.debug("Removing invalid IP failed as expected with Exception %s" % e)
+            self.debug(
+                "Removing invalid IP failed as expected with Exception %s" %
+                e)
         return
 
     @attr(tags=["advanced"])
@@ -308,9 +423,12 @@ class TestBasicOperations(cloudstackTestCase):
 
         try:
             NIC.removeIp(self.apiclient, ipaddressid="")
-            self.fail("Removing IP address without passing IP succeeded, it should have failed")
+            self.fail(
+                "Removing IP address without passing IP succeeded, it should have failed")
         except Exception as e:
-            self.debug("Removing IP from NIC without passing ipaddressid failed as expected with Exception %s" % e)
+            self.debug(
+                "Removing IP from NIC without passing ipaddressid failed as expected with Exception %s" %
+                e)
         return
 
     @data(ISOLATED_NETWORK, SHARED_NETWORK, VPC_NETWORK)
@@ -327,7 +445,8 @@ class TestBasicOperations(cloudstackTestCase):
         # 6. Try to list secondary IPs by passing correct vm id and its nic id
         # 7. Try to list secondary IPs by passing incorrect vm id and correct nic id
         # 8. Try to list secondary IPs by passing correct vm id and incorrect nic id
-        # 9. Try to list secondary IPs by passing incorrect vm id and incorrect nic id
+        # 9. Try to list secondary IPs by passing incorrect vm id and incorrect
+        # nic id
 
         # Validations:
         # 1. Step 4 should fail
@@ -337,58 +456,89 @@ class TestBasicOperations(cloudstackTestCase):
         # 5. Step 8 should fail
         # 6. Step 9 should fail
 
-
-        self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id)
+        self.account = Account.create(
+            self.apiclient,
+            self.services["account"],
+            domainid=self.domain.id)
         self.cleanup.append(self.account)
 
         network = createNetwork(self, value)
 
-        try:
-            virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"],
-                                                    networkids=[network.id],serviceofferingid=self.service_offering.id,
-                                                    accountid=self.account.name,domainid=self.account.domainid)
-        except Exception as e:
-            self.fail("vm creation failed: %s" % e)
+        virtual_machine = VirtualMachine.create(
+            self.apiclient,
+            self.services["virtual_machine"],
+            networkids=[
+                network.id],
+            serviceofferingid=self.service_offering.id,
+            accountid=self.account.name,
+            domainid=self.account.domainid)
 
-        try:
-            NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
-        except Exception as e:
-            self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id)
+        NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
 
         try:
             nics = NIC.list(self.apiclient)
-            self.fail("Listing NICs without passign VM id succeeded, it should have failed, list is %s" % nics)
+            self.fail(
+                "Listing NICs without passign VM id succeeded, it should have failed, list is %s" %
+                nics)
         except Exception as e:
-            self.debug("Listing NICs without passing virtual machine id failed as expected")
+            self.debug(
+                "Listing NICs without passing virtual machine id failed as expected")
 
         try:
             NIC.list(self.apiclient, virtualmachineid=virtual_machine.id)
         except Exception as e:
-            self.fail("Listing NICs for virtual machine %s failed with Exception %s" % (virtual_machine.id, e))
+            self.fail(
+                "Listing NICs for virtual machine %s failed with Exception %s" %
+                (virtual_machine.id, e))
 
-        try:
-            NIC.list(self.apiclient, virtualmachineid=virtual_machine.id, nicid=virtual_machine.nic[0].id)
-        except Exception as e:
-            self.fail("Listing NICs for virtual machine %s and nic id %s failed with Exception %s" %
-                    (virtual_machine.id, virtual_machine.nic[0].id, e))
+        NIC.list(
+            self.apiclient,
+            virtualmachineid=virtual_machine.id,
+            nicid=virtual_machine.nic[0].id)
 
         try:
-            nics = NIC.list(self.apiclient, virtualmachineid=(virtual_machine.id + random_gen()), nicid=virtual_machine.nic[0].id)
-            self.fail("Listing NICs with wrong virtual machine id and right nic id succeeded, should have failed")
+            nics = NIC.list(
+                self.apiclient,
+                virtualmachineid=(
+                    virtual_machine.id +
+                    random_gen()),
+                nicid=virtual_machine.nic[0].id)
+            self.fail(
+                "Listing NICs with wrong virtual machine id and right nic id succeeded, should have failed")
         except Exception as e:
-            self.debug("Listing NICs with wrong virtual machine id and right nic failed as expected with Exception %s" % e)
+            self.debug(
+                "Listing NICs with wrong virtual machine id and right nic failed as expected with Exception %s" %
+                e)
 
         try:
-            nics = NIC.list(self.apiclient, virtualmachineid=virtual_machine.id, nicid=(virtual_machine.nic[0].id + random_gen()))
-            self.fail("Listing NICs with correct virtual machine id but wrong nic id succeeded, should have failed")
+            nics = NIC.list(
+                self.apiclient,
+                virtualmachineid=virtual_machine.id,
+                nicid=(
+                    virtual_machine.nic[0].id +
+                    random_gen()))
+            self.fail(
+                "Listing NICs with correct virtual machine id but wrong nic id succeeded, should have failed")
         except Exception as e:
-            self.debug("Listing NICs with correct virtual machine id but wrong nic id failed as expected with Exception %s" % e)
+            self.debug(
+                "Listing NICs with correct virtual machine id but wrong nic id failed as expected with Exception %s" %
+                e)
 
         try:
-            nics = NIC.list(self.apiclient, virtualmachineid=(virtual_machine.id+random_gen()), nicid=(virtual_machine.nic[0].id + random_gen()))
-            self.fail("Listing NICs with wrong virtual machine id and wrong nic id succeeded, should have failed")
+            nics = NIC.list(
+                self.apiclient,
+                virtualmachineid=(
+                    virtual_machine.id +
+                    random_gen()),
+                nicid=(
+                    virtual_machine.nic[0].id +
+                    random_gen()))
+            self.fail(
+                "Listing NICs with wrong virtual machine id and wrong nic id succeeded, should have failed")
         except Exception as e:
-            self.debug("Listing NICs with wrong virtual machine id and wrong nic id failed as expected with Exception %s" % e)
+            self.debug(
+                "Listing NICs with wrong virtual machine id and wrong nic id failed as expected with Exception %s" %
+                e)
 
         return
 
@@ -409,49 +559,65 @@ class TestBasicOperations(cloudstackTestCase):
         # Validations:
         # 1. All the operations should be successful
 
-        child_domain = Domain.create(self.apiclient,services=self.services["domain"],
-                                     parentdomainid=self.domain.id)
+        child_domain = Domain.create(
+            self.apiclient,
+            services=self.services["domain"],
+            parentdomainid=self.domain.id)
 
-        self.account = Account.create(self.apiclient,self.services["account"],domainid=child_domain.id)
+        self.account = Account.create(
+            self.apiclient,
+            self.services["account"],
+            domainid=child_domain.id)
         self.cleanup.append(self.account)
         self.cleanup.append(child_domain)
 
-        apiclient = self.testClient.getUserApiClient(UserName=self.account.name, DomainName=self.account.domain)
+        apiclient = self.testClient.getUserApiClient(
+            UserName=self.account.name,
+            DomainName=self.account.domain)
 
         network = createNetwork(self, value)
 
-        try:
-            virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"],
-                                                    networkids=[network.id],serviceofferingid=self.service_offering.id,
-                                                    accountid=self.account.name,domainid=self.account.domainid)
-        except Exception as e:
-            self.fail("vm creation failed: %s" % e)
+        virtual_machine = VirtualMachine.create(
+            self.apiclient,
+            self.services["virtual_machine"],
+            networkids=[
+                network.id],
+            serviceofferingid=self.service_offering.id,
+            accountid=self.account.name,
+            domainid=self.account.domainid)
 
-        try:
-            ipaddress_1 = NIC.addIp(apiclient, id=virtual_machine.nic[0].id)
-        except Exception as e:
-            self.fail("Failed while adding secondary IP to NIC of vm %s: %s" % (virtual_machine.id, e))
+        ipaddress_1 = NIC.addIp(apiclient, id=virtual_machine.nic[0].id)
 
         try:
             NIC.list(apiclient, virtualmachineid=virtual_machine.id)
         except Exception as e:
-            self.fail("Listing NICs for virtual machine %s failed with Exception %s" % (virtual_machine.id, e))
+            self.fail(
+                "Listing NICs for virtual machine %s failed with Exception %s" %
+                (virtual_machine.id, e))
 
         try:
-            NIC.list(apiclient, virtualmachineid=virtual_machine.id, nicid=virtual_machine.nic[0].id)
+            NIC.list(
+                apiclient,
+                virtualmachineid=virtual_machine.id,
+                nicid=virtual_machine.nic[0].id)
         except Exception as e:
-            self.fail("Listing NICs for virtual machine %s and nic id %s failed with Exception %s" %
-                    (virtual_machine.id, virtual_machine.nic[0].id, e))
+            self.fail(
+                "Listing NICs for virtual machine %s and nic id %s failed with Exception %s" %
+                (virtual_machine.id, virtual_machine.nic[0].id, e))
 
         try:
             NIC.removeIp(apiclient, ipaddressid=ipaddress_1.id)
         except Exception as e:
-            self.fail("Removing seondary IP %s from NIC failed as expected with Exception %s" % (ipaddress_1.id,e))
+            self.fail(
+                "Removing seondary IP %s from NIC failed as expected with Exception %s" %
+                (ipaddress_1.id, e))
 
         return
 
+
 @ddt
 class TestNetworkRules(cloudstackTestCase):
+
     """Test PF/NAT/static nat rules with the secondary IPs
     """
 
@@ -467,32 +633,42 @@ class TestNetworkRules(cloudstackTestCase):
         cls.domain = get_domain(cls.api_client)
         cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.template = get_template(
-                            cls.api_client,
-                            cls.zone.id,
-                            cls.services["ostype"]
-                            )
+            cls.api_client,
+            cls.zone.id,
+            cls.services["ostype"]
+        )
         if cls.template == FAILED:
-            assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+            assert False, "get_template() failed to return template with description %s" % cls.services[
+                "ostype"]
 
         cls.services["virtual_machine"]["zoneid"] = cls.zone.id
         cls.services["virtual_machine"]["template"] = cls.template.id
         cls.service_offering = ServiceOffering.create(
-                                            cls.api_client,
-                                            cls.services["service_offering"]
-                                            )
+            cls.api_client,
+            cls.services["service_offering"]
+        )
         cls._cleanup = [cls.service_offering]
-        cls.services["shared_network_offering_all_services"]["specifyVlan"] = "True"
-        cls.services["shared_network_offering_all_services"]["specifyIpRanges"] = "True"
-
-        cls.shared_network_offering = CreateEnabledNetworkOffering(cls.api_client,
-                                        cls.services["shared_network_offering_all_services"])
+        cls.services["shared_network_offering_all_services"][
+            "specifyVlan"] = "True"
+        cls.services["shared_network_offering_all_services"][
+            "specifyIpRanges"] = "True"
+
+        cls.shared_network_offering = CreateEnabledNetworkOffering(
+            cls.api_client,
+            cls.services["shared_network_offering_all_services"])
         cls._cleanup.append(cls.shared_network_offering)
         cls.mode = cls.zone.networktype
-        cls.isolated_network_offering = CreateEnabledNetworkOffering(cls.api_client, cls.services["isolated_network_offering"])
+        cls.isolated_network_offering = CreateEnabledNetworkOffering(
+            cls.api_client,
+            cls.services["isolated_network_offering"])
         cls._cleanup.append(cls.isolated_network_offering)
-        cls.isolated_network_offering_vpc = CreateEnabledNetworkOffering(cls.api_client, cls.services["nw_offering_isolated_vpc"])
+        cls.isolated_network_offering_vpc = CreateEnabledNetworkOffering(
+            cls.api_client,
+            cls.services["nw_offering_isolated_vpc"])
         cls._cleanup.append(cls.isolated_network_offering_vpc)
-        cls.vpc_off = VpcOffering.create(cls.api_client, cls.services["vpc_offering"])
+        cls.vpc_off = VpcOffering.create(
+            cls.api_client,
+            cls.services["vpc_offering"])
         cls.vpc_off.update(cls.api_client, state='Enabled')
         cls._cleanup.append(cls.vpc_off)
         return
@@ -509,7 +685,7 @@ class TestNetworkRules(cloudstackTestCase):
     def setUp(self):
         self.apiclient = self.testClient.getApiClient()
         self.dbclient = self.testClient.getDbConnection()
-        self.cleanup = [ ]
+        self.cleanup = []
         return
 
     def tearDown(self):
@@ -524,10 +700,20 @@ class TestNetworkRules(cloudstackTestCase):
     def VerifyStaticNatForPublicIp(self, ipaddressid, natrulestatus):
         """ List public IP and verify that NAT rule status for the IP is as desired """
 
-        publiciplist = PublicIPAddress.list(self.apiclient, id=ipaddressid, listall=True)
-        self.assertEqual(validateList(publiciplist)[0], PASS, "Public IP list validation failed")
-        self.assertEqual(publiciplist[0].isstaticnat, natrulestatus, "isstaticnat should be %s, it is %s" %
-                (natrulestatus, publiciplist[0].isstaticnat))
+        publiciplist = PublicIPAddress.list(
+            self.apiclient,
+            id=ipaddressid,
+            listall=True)
+        self.assertEqual(
+            validateList(publiciplist)[0],
+            PASS,
+            "Public IP list validation failed")
+        self.assertEqual(
+            publiciplist[0].isstaticnat,
+            natrulestatus,
+            "isstaticnat should be %s, it is %s" %
+            (natrulestatus,
+             publiciplist[0].isstaticnat))
 
         return
 
@@ -552,36 +738,71 @@ class TestNetworkRules(cloudstackTestCase):
         # 3. Step 6 should succeed
         # 4. Step 7 should fail
 
-        self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id)
+        self.account = Account.create(
+            self.apiclient,
+            self.services["account"],
+            domainid=self.domain.id)
         self.cleanup.append(self.account)
 
         network = createNetwork(self, value)
 
-        try:
-            virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"],
-                                                    networkids=[network.id],serviceofferingid=self.service_offering.id,
-                                                    accountid=self.account.name,domainid=self.account.domainid)
-        except Exception as e:
-            self.fail("vm creation failed: %s" % e)
-
-        try:
-            ipaddress_1 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
-        except Exception as e:
-            self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id)
-
-        try:
-            ipaddress_2 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
-        except Exception as e:
-            self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id)
-
-        self.assertEqual(createNetworkRules(self, virtual_machine, network, ipaddress_1.ipaddress, value, ruletype="nat"),
-                PASS, "Failure in creating NAT rule")
-        self.assertEqual(createNetworkRules(self, virtual_machine, network, ipaddress_1.ipaddress, value, ruletype="nat"),
-                PASS, "Failure in creating NAT rule")
-        self.assertEqual(createNetworkRules(self, virtual_machine, network, ipaddress_2.ipaddress, value, ruletype="nat"),
-                PASS, "Failure in creating NAT rule")
-        self.assertEqual(createNetworkRules(self, virtual_machine, network, "255.255.255.300", value, ruletype="nat"),
-                FAIL, "Failure in NAT rule creation")
+        virtual_machine = VirtualMachine.create(
+            self.apiclient,
+            self.services["virtual_machine"],
+            networkids=[
+                network.id],
+            serviceofferingid=self.service_offering.id,
+            accountid=self.account.name,
+            domainid=self.account.domainid)
+
+        ipaddress_1 = NIC.addIp(
+            self.apiclient,
+            id=virtual_machine.nic[0].id)
+
+        ipaddress_2 = NIC.addIp(
+            self.apiclient,
+            id=virtual_machine.nic[0].id)
+
+        self.assertEqual(
+            createNetworkRules(
+                self,
+                virtual_machine,
+                network,
+                ipaddress_1.ipaddress,
+                value,
+                ruletype="nat"),
+            PASS,
+            "Failure in creating NAT rule")
+        self.assertEqual(
+            createNetworkRules(
+                self,
+                virtual_machine,
+                network,
+                ipaddress_1.ipaddress,
+                value,
+                ruletype="nat"),
+            PASS,
+            "Failure in creating NAT rule")
+        self.assertEqual(
+            createNetworkRules(
+                self,
+                virtual_machine,
+                network,
+                ipaddress_2.ipaddress,
+                value,
+                ruletype="nat"),
+            PASS,
+            "Failure in creating NAT rule")
+        self.assertEqual(
+            createNetworkRules(
+                self,
+                virtual_machine,
+                network,
+                "255.255.255.300",
+                value,
+                ruletype="nat"),
+            FAIL,
+            "Failure in NAT rule creation")
         return
 
     @data(ISOLATED_NETWORK, SHARED_NETWORK, VPC_NETWORK)
@@ -602,61 +823,81 @@ class TestNetworkRules(cloudstackTestCase):
         # 1. Step 5 should fail
         # 2. Step 6 should succeed
 
-        self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id)
+        self.account = Account.create(
+            self.apiclient,
+            self.services["account"],
+            domainid=self.domain.id)
         self.cleanup.append(self.account)
 
         network = createNetwork(self, value)
         firewallrule = None
 
-        try:
-            virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"],
-                                                    networkids=[network.id],serviceofferingid=self.service_offering.id,
-                                                    accountid=self.account.name,domainid=self.account.domainid)
-        except Exception as e:
-            self.fail("vm creation failed: %s" % e)
-
-        try:
-            ipaddress_1 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
-        except Exception as e:
-            self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id)
-
-        public_ip = PublicIPAddress.create(self.api_client,accountid=self.account.name,
-                                           zoneid=self.zone.id,domainid=self.account.domainid,
-                                           networkid=network.id, vpcid = network.vpcid if value == VPC_NETWORK else None)
+        virtual_machine = VirtualMachine.create(
+            self.apiclient,
+            self.services["virtual_machine"],
+            networkids=[
+                network.id],
+            serviceofferingid=self.service_offering.id,
+            accountid=self.account.name,
+            domainid=self.account.domainid)
+
+        ipaddress_1 = NIC.addIp(
+            self.apiclient,
+            id=virtual_machine.nic[0].id)
+
+        public_ip = PublicIPAddress.create(
+            self.api_client,
+            accountid=self.account.name,
+            zoneid=self.zone.id,
+            domainid=self.account.domainid,
+            networkid=network.id,
+            vpcid=network.vpcid if value == VPC_NETWORK else None)
 
         if value != VPC_NETWORK:
-            firewallrule = FireWallRule.create(self.apiclient,ipaddressid=public_ip.ipaddress.id,
-                                      protocol='TCP', cidrlist=[self.services["fwrule"]["cidr"]],
-                                      startport=self.services["fwrule"]["startport"],endport=self.services["fwrule"]["endport"])
+            firewallrule = FireWallRule.create(
+                self.apiclient,
+                ipaddressid=public_ip.ipaddress.id,
+                protocol='TCP',
+                cidrlist=[
+                    self.services["fwrule"]["cidr"]],
+                startport=self.services["fwrule"]["startport"],
+                endport=self.services["fwrule"]["endport"])
 
         # Create NAT rule
-        natrule = NATRule.create(self.api_client, virtual_machine,
-                       self.services["natrule"],ipaddressid=public_ip.ipaddress.id,
-                       networkid=network.id, vmguestip = ipaddress_1.ipaddress)
+        natrule = NATRule.create(
+            self.api_client,
+            virtual_machine,
+            self.services["natrule"],
+            ipaddressid=public_ip.ipaddress.id,
+            networkid=network.id,
+            vmguestip=ipaddress_1.ipaddress)
         try:
             NIC.removeIp(self.apiclient, ipaddressid=ipaddress_1.id)
-            self.fail("Removing secondary IP succeeded while it had active NAT rule on it, should have failed")
+            self.fail(
+                "Removing secondary IP succeeded while it had active NAT rule on it, should have failed")
         except Exception as e:
-            self.debug("Removing secondary IP with active NAT rule failed as expected")
+            self.debug(
+                "Removing secondary IP with active NAT rule failed as expected")
 
         if firewallrule:
             try:
                 firewallrule.delete(self.apiclient)
             except Exception as e:
-                self.fail("Exception while deleting firewall rule %s: %s" % (firewallrule.id, e))
+                self.fail(
+                    "Exception while deleting firewall rule %s: %s" %
+                    (firewallrule.id, e))
 
-        try:
-            natrule.delete(self.apiclient)
-        except Exception as e:
-            self.fail("Exception while deleting nat rule %s: %s" % (natrule.id, e))
+        natrule.delete(self.apiclient)
         return
 
     @data(ISOLATED_NETWORK, SHARED_NETWORK, VPC_NETWORK)
     @attr(tags=["advanced"])
-    def test_disassociate_ip_mapped_to_secondary_ip_through_PF_rule(self, value):
+    def test_disassociate_ip_mapped_to_secondary_ip_through_PF_rule(
+            self,
+            value):
         """ Add secondary IP to NIC of a VM"""
 
-        ## Steps:
+        # Steps:
         # 1. Create Account and create network in it (isoalted/ shared/ vpc)
         # 2. Deploy a VM in this network and account
         # 3. Add secondary IP to the default nic of VM
@@ -667,41 +908,55 @@ class TestNetworkRules(cloudstackTestCase):
         # Validations:
         # 1. Step 5 should succeed
 
-        self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id)
+        self.account = Account.create(
+            self.apiclient,
+            self.services["account"],
+            domainid=self.domain.id)
         self.cleanup.append(self.account)
 
         network = createNetwork(self, value)
 
-        try:
-            virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"],
-                                                    networkids=[network.id],serviceofferingid=self.service_offering.id,
-                                                    accountid=self.account.name,domainid=self.account.domainid)
-        except Exception as e:
-            self.fail("vm creation failed: %s" % e)
-
-        try:
-            ipaddress_1 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
-        except Exception as e:
-            self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id)
-
-        public_ip = PublicIPAddress.create(self.api_client,accountid=self.account.name,
-                                           zoneid=self.zone.id,domainid=self.account.domainid,
-                                           networkid=network.id, vpcid = network.vpcid if value == VPC_NETWORK else None)
+        virtual_machine = VirtualMachine.create(
+            self.apiclient,
+            self.services["virtual_machine"],
+            networkids=[
+                network.id],
+            serviceofferingid=self.service_offering.id,
+            accountid=self.account.name,
+            domainid=self.account.domainid)
+
+        ipaddress_1 = NIC.addIp(
+            self.apiclient,
+            id=virtual_machine.nic[0].id)
+
+        public_ip = PublicIPAddress.create(
+            self.api_client,
+            accountid=self.account.name,
+            zoneid=self.zone.id,
+            domainid=self.account.domainid,
+            networkid=network.id,
+            vpcid=network.vpcid if value == VPC_NETWORK else None)
 
         if value != VPC_NETWORK:
-            FireWallRule.create(self.apiclient,ipaddressid=public_ip.ipaddress.id,
-                                      protocol='TCP', cidrlist=[self.services["fwrule"]["cidr"]],
-                                      startport=self.services["fwrule"]["startport"],endport=self.services["fwrule"]["endport"])
+            FireWallRule.create(
+                self.apiclient,
+                ipaddressid=public_ip.ipaddress.id,
+                protocol='TCP',
+                cidrlist=[
+                    self.services["fwrule"]["cidr"]],
+                startport=self.services["fwrule"]["startport"],
+                endport=self.services["fwrule"]["endport"])
 
         # Create NAT rule
-        natrule = NATRule.create(self.api_client, virtual_machine,
-                       self.services["natrule"],ipaddressid=public_ip.ipaddress.id,
-                       networkid=network.id, vmguestip = ipaddress_1.ipaddress)
+        NATRule.create(
+            self.api_client,
+            virtual_machine,
+            self.services["natrule"],
+            ipaddressid=public_ip.ipaddress.id,
+            networkid=network.id,
+            vmguestip=ipaddress_1.ipaddress)
 
-        try:
-            public_ip.delete(self.apiclient)
-        except Exception as e:
-            self.fail("Exception while deleting nat rule %s: %s" % (natrule.id, e))
+        public_ip.delete(self.apiclient)
         return
 
     @data(ISOLATED_NETWORK, SHARED_NETWORK, VPC_NETWORK)
@@ -727,42 +982,80 @@ class TestNetworkRules(cloudstackTestCase):
         # 4. Step 7 should fail
         # 5. Step 8 should succeed
 
-        self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id)
+        self.account = Account.create(
+            self.apiclient,
+            self.services["account"],
+            domainid=self.domain.id)
         self.cleanup.append(self.account)
 
         network = createNetwork(self, value)
 
-        try:
-            virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"],
-                                                    networkids=[network.id],serviceofferingid=self.service_offering.id,
-                                                    accountid=self.account.name,domainid=self.account.domainid)
-        except Exception as e:
-            self.fail("vm creation failed: %s" % e)
-
-        try:
-            ipaddress_1 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
-        except Exception as e:
-            self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id)
-
-        try:
-            ipaddress_2 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
-        except Exception as e:
-            self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id)
-
-        self.assertEqual(createNetworkRules(self, virtual_machine, network, ipaddress_1.ipaddress, value, ruletype="staticnat"),
-                PASS, "Failure in creating NAT rule")
-        self.assertEqual(createNetworkRules(self, virtual_machine, network, ipaddress_1.ipaddress, value, ruletype="staticnat"),
-                FAIL, "Failure in creating NAT rule")
-        self.assertEqual(createNetworkRules(self, virtual_machine, network, ipaddress_2.ipaddress, value, ruletype="staticnat"),
-                PASS, "Failure in creating NAT rule")
-        self.assertEqual(createNetworkRules(self, virtual_machine, network, "255.255.255.300", value, ruletype="staticnat"),
-                FAIL, "Failure in NAT rule creation")
+        virtual_machine = VirtualMachine.create(
+            self.apiclient,
+            self.services["virtual_machine"],
+            networkids=[
+                network.id],
+            serviceofferingid=self.service_offering.id,
+            accountid=self.account.name,
+            domainid=self.account.domainid)
+
+        ipaddress_1 = NIC.addIp(
+            self.apiclient,
+            id=virtual_machine.nic[0].id)
+
+        ipaddress_2 = NIC.addIp(
+            self.apiclient,
+            id=virtual_machine.nic[0].id)
+
+        self.assertEqual(
+            createNetworkRules(
+                self,
+                virtual_machine,
+                network,
+                ipaddress_1.ipaddress,
+                value,
+                ruletype="staticnat"),
+            PASS,
+            "Failure in creating NAT rule")
+        self.assertEqual(
+            createNetworkRules(
+                self,
+                virtual_machine,
+                network,
+                ipaddress_1.ipaddress,
+                value,
+                ruletype="staticnat"),
+            FAIL,
+            "Failure in creating NAT rule")
+        self.assertEqual(
+            createNetworkRules(
+                self,
+                virtual_machine,
+                network,
+                ipaddress_2.ipaddress,
+                value,
+                ruletype="staticnat"),
+            PASS,
+            "Failure in creating NAT rule")
+        self.assertEqual(
+            createNetworkRules(
+                self,
+                virtual_machine,
+                network,
+                "255.255.255.300",
+                value,
+                ruletype="staticnat"),
+            FAIL,
+            "Failure in NAT rule creation")
 
         try:
             NIC.removeIp(self.apiclient, ipaddress_1.id)
-            self.fail("Ip address should not get removed when active static NAT rule is defined for it")
+            self.fail(
+                "Ip address should not get removed when active static NAT rule is defined for it")
         except Exception as e:
-            self.debug("Exception while removing secondary ip address as expected because static nat rule is present for it")
+            self.debug(
+                "Exception while removing secondary ip address as expected\
+                        because static nat rule is present for it: %s" % e)
         return
 
     @data(ISOLATED_NETWORK, SHARED_NETWORK, VPC_NETWORK)
@@ -779,36 +1072,54 @@ class TestNetworkRules(cloudstackTestCase):
         # 5. Disable the static nat rule and enable it again
 
         # Validations:
-        # 1. Verify step 5 by listing seconday IP and checking the appropriate flag
+        # 1. Verify step 5 by listing seconday IP and checking the appropriate
+        # flag
 
-        self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id)
+        self.account = Account.create(
+            self.apiclient,
+            self.services["account"],
+            domainid=self.domain.id)
         self.cleanup.append(self.account)
 
         network = createNetwork(self, value)
 
-        try:
-            virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"],
-                                                    networkids=[network.id],serviceofferingid=self.service_offering.id,
-                                                    accountid=self.account.name,domainid=self.account.domainid)
-        except Exception as e:
-            self.fail("vm creation failed: %s" % e)
-
-        try:
-            ipaddress_1 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
-        except Exception as e:
-            self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id)
-
-        public_ip = PublicIPAddress.create(self.api_client,accountid=self.account.name,
-                                           zoneid=self.zone.id,domainid=self.account.domainid,
-                                           networkid=network.id, vpcid = network.vpcid if value == VPC_NETWORK else None)
+        virtual_machine = VirtualMachine.create(
+            self.apiclient,
+            self.services["virtual_machine"],
+            networkids=[
+                network.id],
+            serviceofferingid=self.service_offering.id,
+            accountid=self.account.name,
+            domainid=self.account.domainid)
+
+        ipaddress_1 = NIC.addIp(
+            self.apiclient,
+            id=virtual_machine.nic[0].id)
+
+        public_ip = PublicIPAddress.create(
+            self.api_client,
+            accountid=self.account.name,
+            zoneid=self.zone.id,
+            domainid=self.account.domainid,
+            networkid=network.id,
+            vpcid=network.vpcid if value == VPC_NETWORK else None)
 
         if value != VPC_NETWORK:
-            FireWallRule.create(self.apiclient,ipaddressid=public_ip.ipaddress.id,
-                                      protocol='TCP', cidrlist=[self.services["fwrule"]["cidr"]],
-                                      startport=self.services["fwrule"]["startport"],endport=self.services["fwrule"]["endport"])
-
-        StaticNATRule.enable(self.apiclient, public_ip.ipaddress.id, virtual_machine.id,
-                    network.id, vmguestip=ipaddress_1.ipaddress)
+            FireWallRule.create(
+                self.apiclient,
+                ipaddressid=public_ip.ipaddress.id,
+                protocol='TCP',
+                cidrlist=[
+                    self.services["fwrule"]["cidr"]],
+                startport=self.services["fwrule"]["startport"],
+                endport=self.services["fwrule"]["endport"])
+
+        StaticNATRule.enable(
+            self.apiclient,
+            public_ip.ipaddress.id,
+            virtual_machine.id,
+            network.id,
+            vmguestip=ipaddress_1.ipaddress)
 
         self.VerifyStaticNatForPublicIp(public_ip.ipaddress.id, True)
 
@@ -817,16 +1128,22 @@ class TestNetworkRules(cloudstackTestCase):
 
         self.VerifyStaticNatForPublicIp(public_ip.ipaddress.id, False)
 
-        StaticNATRule.enable(self.apiclient, public_ip.ipaddress.id, virtual_machine.id,
-                    network.id, vmguestip=ipaddress_1.ipaddress)
+        StaticNATRule.enable(
+            self.apiclient,
+            public_ip.ipaddress.id,
+            virtual_machine.id,
+            network.id,
+            vmguestip=ipaddress_1.ipaddress)
 
         self.VerifyStaticNatForPublicIp(public_ip.ipaddress.id, True)
 
         public_ip.delete(self.apiclient)
         return
 
+
 @ddt
 class TestVmNetworkOperations(cloudstackTestCase):
+
     """Test VM and Network operations with network rules created on secondary IP
     """
 
@@ -842,31 +1159,41 @@ class TestVmNetworkOperations(cloudstackTestCase):
         cls.domain = get_domain(cls.api_client)
         cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.template = get_template(
-                            cls.api_client,
-                            cls.zone.id,
-                            cls.services["ostype"]
-                            )
+            cls.api_client,
+            cls.zone.id,
+            cls.services["ostype"]
+        )
         if cls.template == FAILED:
-            assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+            assert False, "get_template() failed to return template with description %s" % cls.services[
+                "ostype"]
         cls.services["virtual_machine"]["zoneid"] = cls.zone.id
         cls.services["virtual_machine"]["template"] = cls.template.id
         cls.service_offering = ServiceOffering.create(
-                                            cls.api_client,
-                                            cls.services["service_offering"]
-                                            )
+            cls.api_client,
+            cls.services["service_offering"]
+        )
         cls._cleanup = [cls.service_offering]
-        cls.services["shared_network_offering_all_services"]["specifyVlan"] = "True"
-        cls.services["shared_network_offering_all_services"]["specifyIpRanges"] = "True"
-
-        cls.shared_network_offering = CreateEnabledNetworkOffering(cls.api_client,
-                                        cls.services["shared_network_offering_all_services"])
+        cls.services["shared_network_offering_all_services"][
+            "specifyVlan"] = "True"
+        cls.services["shared_network_offering_all_services"][
+            "specifyIpRanges"] = "True"
+
+        cls.shared_network_offering = CreateEnabledNetworkOffering(
+            cls.api_client,
+            cls.services["shared_network_offering_all_services"])
         cls._cleanup.append(cls.shared_network_offering)
         cls.mode = cls.zone.networktype
-        cls.isolated_network_offering = CreateEnabledNetworkOffering(cls.api_client, cls.services["isolated_network_offering"])
+        cls.isolated_network_offering = CreateEnabledNetworkOffering(
+            cls.api_client,
+            cls.services["isolated_network_offering"])
         cls._cleanup.append(cls.isolated_network_offering)
-        cls.isolated_network_offering_vpc = CreateEnabledNetworkOffering(cls.api_client, cls.services["nw_offering_isolated_vpc"])
+        cls.isolated_network_offering_vpc = CreateEnabledNetworkOffering(
+            cls.api_client,
+            cls.services["nw_offering_isolated_vpc"])
         cls._cleanup.append(cls.isolated_network_offering_vpc)
-        cls.vpc_off = VpcOffering.create(cls.api_client, cls.services["vpc_offering"])
+        cls.vpc_off = VpcOffering.create(
+            cls.api_client,
+            cls.services["vpc_offering"])
         cls.vpc_off.update(cls.api_client, state='Enabled')
         cls._cleanup.append(cls.vpc_off)
         return
@@ -883,7 +1210,7 @@ class TestVmNetworkOperations(cloudstackTestCase):
     def setUp(self):
         self.apiclient = self.testClient.getApiClient()
         self.dbclient = self.testClient.getDbConnection()
-        self.cleanup = [ ]
+        self.cleanup = []
         return
 
     def tearDown(self):
@@ -897,10 +1224,20 @@ class TestVmNetworkOperations(cloudstackTestCase):
     def VerifyStaticNatForPublicIp(self, ipaddressid, natrulestatus):
         """ List public IP and verify that NAT rule status for the IP is as desired """
 
-        publiciplist = PublicIPAddress.list(self.apiclient, id=ipaddressid, listall=True)
-        self.assertEqual(validateList(publiciplist)[0], PASS, "Public IP list validation failed")
-        self.assertEqual(publiciplist[0].isstaticnat, natrulestatus, "isstaticnat should be %s, it is %s" %
-                (natrulestatus, publiciplist[0].isstaticnat))
+        publiciplist = PublicIPAddress.list(
+            self.apiclient,
+            id=ipaddressid,
+            listall=True)
+        self.assertEqual(
+            validateList(publiciplist)[0],
+            PASS,
+            "Public IP list validation failed")
+        self.assertEqual(
+            publiciplist[0].isstaticnat,
+            natrulestatus,
+            "isstaticnat should be %s, it is %s" %
+            (natrulestatus,
+             publiciplist[0].isstaticnat))
 
         return
 
@@ -920,49 +1257,73 @@ class TestVmNetworkOperations(cloudstackTestCase):
         # 7. Verify that nat rule does not exist and static nat is not enabled for
         #    secondary IP
 
-        self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id)
+        self.account = Account.create(
+            self.apiclient,
+            self.services["account"],
+            domainid=self.domain.id)
         self.cleanup.append(self.account)
 
         network = createNetwork(self, value)
 
-        try:
-            virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"],
-                                                    networkids=[network.id],serviceofferingid=self.service_offering.id,
-                                                    accountid=self.account.name,domainid=self.account.domainid)
-        except Exception as e:
-            self.fail("vm creation failed: %s" % e)
+        virtual_machine = VirtualMachine.create(
+            self.apiclient,
+            self.services["virtual_machine"],
+            networkids=[
+                network.id],
+            serviceofferingid=self.service_offering.id,
+            accountid=self.account.name,
+            domainid=self.account.domainid)
 
         # Add secondary IPs to default NIC of VM
-        try:
-            ipaddress_1 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
-            ipaddress_2 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
-        except Exception as e:
-            self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id)
+        ipaddress_1 = NIC.addIp(
+            self.apiclient,
+            id=virtual_machine.nic[0].id)
+        ipaddress_2 = NIC.addIp(
+            self.apiclient,
+            id=virtual_machine.nic[0].id)
 
         # Acquire public IP addresses in the network
-        try:
-            public_ip_1 = PublicIPAddress.create(self.api_client,accountid=self.account.name,
-                                           zoneid=self.zone.id,domainid=self.account.domainid,
-                                           networkid=network.id, vpcid = network.vpcid if value == VPC_NETWORK else None)
-
-            public_ip_2 = PublicIPAddress.create(self.api_client,accountid=self.account.name,
-                                           zoneid=self.zone.id,domainid=self.account.domainid,
-                                           networkid=network.id, vpcid = network.vpcid if value == VPC_NETWORK else None)
-        except Exception as e:
-            self.fail("Exception while acquiring public ip address: %s" % e)
+        public_ip_1 = PublicIPAddress.create(
+            self.api_client,
+            accountid=self.account.name,
+            zoneid=self.zone.id,
+            domainid=self.account.domainid,
+            networkid=network.id,
+            vpcid=network.vpcid if value == VPC_NETWORK else None)
+
+        public_ip_2 = PublicIPAddress.create(
+            self.api_client,
+            accountid=self.account.name,
+            zoneid=self.zone.id,
+            domainid=self.account.domainid,
+            networkid=network.id,
+            vpcid=network.vpcid if value == VPC_NETWORK else None)
 
         # Create Firewall and natrule for 1st IP and static nat rule for 2nd IP
         if value != VPC_NETWORK:
-            FireWallRule.create(self.apiclient,ipaddressid=public_ip_1.ipaddress.id,
-                                      protocol='TCP', cidrlist=[self.services["fwrule"]["cidr"]],
-                                      startport=self.services["fwrule"]["startport"],endport=self.services["fwrule"]["endport"])
-
-        natrule = NATRule.create(self.api_client, virtual_machine,
-                       self.services["natrule"],ipaddressid=public_ip_1.ipaddress.id,
-                       networkid=network.id, vmguestip = ipaddress_1.ipaddress)
-
-        StaticNATRule.enable(self.apiclient, public_ip_2.ipaddress.id, virtual_machine.id,
-                    network.id, vmguestip=ipaddress_2.ipaddress)
+            FireWallRule.create(
+                self.apiclient,
+                ipaddressid=public_ip_1.ipaddress.id,
+                protocol='TCP',
+                cidrlist=[
+                    self.services["fwrule"]["cidr"]],
+                startport=self.services["fwrule"]["startport"],
+                endport=self.services["fwrule"]["endport"])
+
+        natrule = NATRule.create(
+            self.api_client,
+            virtual_machine,
+            self.services["natrule"],
+            ipaddressid=public_ip_1.ipaddress.id,
+            networkid=network.id,
+            vmguestip=ipaddress_1.ipaddress)
+
+        StaticNATRule.enable(
+            self.apiclient,
+            public_ip_2.ipaddress.id,
+            virtual_machine.id,
+            network.id,
+            vmguestip=ipaddress_2.ipaddress)
 
         # Delete VM
         virtual_machine.delete(self.apiclient, expunge=True)
@@ -1001,46 +1362,70 @@ class TestVmNetworkOperations(cloudstackTestCase):
         # 6. Destroy the virtual machine and recover it
         # 7. Verify that nat and static nat rules exist
 
-        self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id)
+        self.account = Account.create(
+            self.apiclient,
+            self.services["account"],
+            domainid=self.domain.id)
         self.cleanup.append(self.account)
 
         network = createNetwork(self, value)
 
-        try:
-            virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"],
-                                                    networkids=[network.id],serviceofferingid=self.service_offering.id,
-                                                    accountid=self.account.name,domainid=self.account.domainid)
-        except Exception as e:
-            self.fail("vm creation failed: %s" % e)
-
-        try:
-            ipaddress_1 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
-            ipaddress_2 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
-        except Exception as e:
-            self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id)
-
-        try:
-            public_ip_1 = PublicIPAddress.create(self.api_client,accountid=self.account.name,
-                                           zoneid=self.zone.id,domainid=self.account.domainid,
-                                           networkid=network.id, vpcid = network.vpcid if value == VPC_NETWORK else None)
-
-            public_ip_2 = PublicIPAddress.create(self.api_client,accountid=self.account.name,
-                                           zoneid=self.zone.id,domainid=self.account.domainid,
-                                           networkid=network.id, vpcid = network.vpcid if value == VPC_NETWORK else None)
-        except Exception as e:
-            self.fail("Exception while acquiring public ip address: %s" % e)
+        virtual_machine = VirtualMachine.create(
+            self.apiclient,
+            self.services["virtual_machine"],
+            networkids=[
+                network.id],
+            serviceofferingid=self.service_offering.id,
+            accountid=self.account.name,
+            domainid=self.account.domainid)
+
+        ipaddress_1 = NIC.addIp(
+            self.apiclient,
+            id=virtual_machine.nic[0].id)
+        ipaddress_2 = NIC.addIp(
+            self.apiclient,
+            id=virtual_machine.nic[0].id)
+
+        public_ip_1 = PublicIPAddress.create(
+            self.api_client,
+            accountid=self.account.name,
+            zoneid=self.zone.id,
+            domainid=self.account.domainid,
+            networkid=network.id,
+            vpcid=network.vpcid if value == VPC_NETWORK else None)
+
+        public_ip_2 = PublicIPAddress.create(
+            self.api_client,
+            accountid=self.account.name,
+            zoneid=self.zone.id,
+            domainid=self.account.domainid,
+            networkid=network.id,
+            vpcid=network.vpcid if value == VPC_NETWORK else None)
 
         if value != VPC_NETWORK:
-            FireWallRule.create(self.apiclient,ipaddressid=public_ip_1.ipaddress.id,
-                                      protocol='TCP', cidrlist=[self.services["fwrule"]["cidr"]],
-                                      startport=self.services["fwrule"]["startport"],endport=self.services["fwrule"]["endport"])
-
-        natrule = NATRule.create(self.api_client, virtual_machine,
-                       self.services["natrule"],ipaddressid=public_ip_1.ipaddress.id,
-                       networkid=network.id, vmguestip = ipaddress_1.ipaddress)
-
-        StaticNATRule.enable(self.apiclient, public_ip_2.ipaddress.id, virtual_machine.id,
-                    network.id, vmguestip=ipaddress_2.ipaddress)
+            FireWallRule.create(
+                self.apiclient,
+                ipaddressid=public_ip_1.ipaddress.id,
+                protocol='TCP',
+                cidrlist=[
+                    self.services["fwrule"]["cidr"]],
+                startport=self.services["fwrule"]["startport"],
+                endport=self.services["fwrule"]["endport"])
+
+        natrule = NATRule.create(
+            self.api_client,
+            virtual_machine,
+            self.services["natrule"],
+            ipaddressid=public_ip_1.ipaddress.id,
+            networkid=network.id,
+            vmguestip=ipaddress_1.ipaddress)
+
+        StaticNATRule.enable(
+            self.apiclient,
+            public_ip_2.ipaddress.id,
+            virtual_machine.id,
+            network.id,
+            vmguestip=ipaddress_2.ipaddress)
 
         virtual_machine.delete(self.apiclient, expunge=False)
         virtual_machine.recover(self.apiclient)
@@ -1048,7 +1433,10 @@ class TestVmNetworkOperations(cloudstackTestCase):
         retriesCount = 10
         while True:
             vms = VirtualMachine.list(self.apiclient, id=virtual_machine.id)
-            self.assertEqual(validateList(vms)[0], PASS, "vms list validation failed")
+            self.assertEqual(
+                validateList(vms)[0],
+                PASS,
+                "vms list validation failed")
             if str(vms[0].state).lower() == "stopped":
                 break
             elif retriesCount == 0:
@@ -1057,7 +1445,10 @@ class TestVmNetworkOperations(cloudstackTestCase):
             retriesCount -= 1
 
         natrules = NATRule.list(self.apiclient, id=natrule.id, listall=True)
-        self.assertEqual(validateList(natrules)[0], PASS, "nat rules validation failed")
+        self.assertEqual(
+            validateList(natrules)[0],
+            PASS,
+            "nat rules validation failed")
 
         self.VerifyStaticNatForPublicIp(public_ip_2.ipaddress.id, True)
 
@@ -1078,51 +1469,78 @@ class TestVmNetworkOperations(cloudstackTestCase):
         # 6. Restart the network with cleanup option True
         # 7. Verify that nat and static nat rules exist after network restart
 
-        self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id)
+        self.account = Account.create(
+            self.apiclient,
+            self.services["account"],
+            domainid=self.domain.id)
         self.cleanup.append(self.account)
 
         network = createNetwork(self, value)
 
-        try:
-            virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"],
-                                                    networkids=[network.id],serviceofferingid=self.service_offering.id,
-                                                    accountid=self.account.name,domainid=self.account.domainid)
-        except Exception as e:
-            self.fail("vm creation failed: %s" % e)
-
-        try:
-            ipaddress_1 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
-            ipaddress_2 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
-        except Exception as e:
-            self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id)
-
-        try:
-            public_ip_1 = PublicIPAddress.create(self.api_client,accountid=self.account.name,
-                                           zoneid=self.zone.id,domainid=self.account.domainid,
-                                           networkid=network.id, vpcid = network.vpcid if value == VPC_NETWORK else None)
-
-            public_ip_2 = PublicIPAddress.create(self.api_client,accountid=self.account.name,
-                                           zoneid=self.zone.id,domainid=self.account.domainid,
-                                           networkid=network.id, vpcid = network.vpcid if value == VPC_NETWORK else None)
-        except Exception as e:
-            self.fail("Exception while acquiring public ip address: %s" % e)
+        virtual_machine = VirtualMachine.create(
+            self.apiclient,
+            self.services["virtual_machine"],
+            networkids=[
+                network.id],
+            serviceofferingid=self.service_offering.id,
+            accountid=self.account.name,
+            domainid=self.account.domainid)
+
+        ipaddress_1 = NIC.addIp(
+            self.apiclient,
+            id=virtual_machine.nic[0].id)
+        ipaddress_2 = NIC.addIp(
+            self.apiclient,
+            id=virtual_machine.nic[0].id)
+
+        public_ip_1 = PublicIPAddress.create(
+            self.api_client,
+            accountid=self.account.name,
+            zoneid=self.zone.id,
+            domainid=self.account.domainid,
+            networkid=network.id,
+            vpcid=network.vpcid if value == VPC_NETWORK else None)
+
+        public_ip_2 = PublicIPAddress.create(
+            self.api_client,
+            accountid=self.account.name,
+            zoneid=self.zone.id,
+            domainid=self.account.domainid,
+            networkid=network.id,
+            vpcid=network.vpcid if value == VPC_NETWORK else None)
 
         if value != VPC_NETWORK:
-            FireWallRule.create(self.apiclient,ipaddressid=public_ip_1.ipaddress.id,
-                                      protocol='TCP', cidrlist=[self.services["fwrule"]["cidr"]],
-                                      startport=self.services["fwrule"]["startport"],endport=self.services["fwrule"]["endport"])
-
-        natrule = NATRule.create(self.api_client, virtual_machine,
-                       self.services["natrule"],ipaddressid=public_ip_1.ipaddress.id,
-                       networkid=network.id, vmguestip = ipaddress_1.ipaddress)
-
-        StaticNATRule.enable(self.apiclient, public_ip_2.ipaddress.id, virtual_machine.id,
-                    network.id, vmguestip=ipaddress_2.ipaddress)
+            FireWallRule.create(
+                self.apiclient,
+                ipaddressid=public_ip_1.ipaddress.id,
+                protocol='TCP',
+                cidrlist=[
+                    self.services["fwrule"]["cidr"]],
+                startport=self.services["fwrule"]["startport"],
+                endport=self.services["fwrule"]["endport"])
+
+        natrule = NATRule.create(
+            self.api_client,
+            virtual_machine,
+            self.services["natrule"],
+            ipaddressid=public_ip_1.ipaddress.id,
+            networkid=network.id,
+            vmguestip=ipaddress_1.ipaddress)
+
+        StaticNATRule.enable(
+            self.apiclient,
+            public_ip_2.ipaddress.id,
+            virtual_machine.id,
+            network.id,
+            vmguestip=ipaddress_2.ipaddress)
 
         network.restart(self.apiclient, cleanup=True)
 
         natrulelist = NATRule.list(self.apiclient, id=natrule.id, listall=True)
-        self.assertEqual(validateList(natrulelist)[0], PASS, "nat rules list validation failed")
+        self.assertEqual(
+            validateList(natrulelist)[0],
+            PASS,
+            "nat rules list validation failed")
 
         self.VerifyStaticNatForPublicIp(public_ip_2.ipaddress.id, True)
         return
@@ -1142,51 +1560,78 @@ class TestVmNetworkOperations(cloudstackTestCase):
         # 6. Restart the network with cleanup option False
         # 7. Verify that nat and static nat rules exist after network restart
 
-        self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id)
+        self.account = Account.create(
+            self.apiclient,
+            self.services["account"],
+            domainid=self.domain.id)
         self.cleanup.append(self.account)
 
         network = createNetwork(self, value)
 
-        try:
-            virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"],
-                                                    networkids=[network.id],serviceofferingid=self.service_offering.id,
-                                                    accountid=self.account.name,domainid=self.account.domainid)
-        except Exception as e:
-            self.fail("vm creation failed: %s" % e)
-
-        try:
-            ipaddress_1 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
-            ipaddress_2 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
-        except Exception as e:
-            self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id)
-
-        try:
-            public_ip_1 = PublicIPAddress.create(self.api_client,accountid=self.account.name,
-                                           zoneid=self.zone.id,domainid=self.account.domainid,
-                                           networkid=network.id, vpcid = network.vpcid if value == VPC_NETWORK else None)
-
-            public_ip_2 = PublicIPAddress.create(self.api_client,accountid=self.account.name,
-                                           zoneid=self.zone.id,domainid=self.account.domainid,
-                                           networkid=network.id, vpcid = network.vpcid if value == VPC_NETWORK else None)
-        except Exception as e:
-            self.fail("Exception while acquiring public ip address: %s" % e)
+        virtual_machine = VirtualMachine.create(
+            self.apiclient,
+            self.services["virtual_machine"],
+            networkids=[
+                network.id],
+            serviceofferingid=self.service_offering.id,
+            accountid=self.account.name,
+            domainid=self.account.domainid)
+
+        ipaddress_1 = NIC.addIp(
+            self.apiclient,
+            id=virtual_machine.nic[0].id)
+        ipaddress_2 = NIC.addIp(
+            self.apiclient,
+            id=virtual_machine.nic[0].id)
+
+        public_ip_1 = PublicIPAddress.create(
+            self.api_client,
+            accountid=self.account.name,
+            zoneid=self.zone.id,
+            domainid=self.account.domainid,
+            networkid=network.id,
+            vpcid=network.vpcid if value == VPC_NETWORK else None)
+
+        public_ip_2 = PublicIPAddress.create(
+            self.api_client,
+            accountid=self.account.name,
+            zoneid=self.zone.id,
+            domainid=self.account.domainid,
+            networkid=network.id,
+            vpcid=network.vpcid if value == VPC_NETWORK else None)
 
         if value != VPC_NETWORK:
-            FireWallRule.create(self.apiclient,ipaddressid=public_ip_1.ipaddress.id,
-                                      protocol='TCP', cidrlist=[self.services["fwrule"]["cidr"]],
-                                      startport=self.services["fwrule"]["startport"],endport=self.services["fwrule"]["endport"])
-
-        natrule = NATRule.create(self.api_client, virtual_machine,
-                       self.services["natrule"],ipaddressid=public_ip_1.ipaddress.id,
-                       networkid=network.id, vmguestip = ipaddress_1.ipaddress)
-
-        StaticNATRule.enable(self.apiclient, public_ip_2.ipaddress.id, virtual_machine.id,
-                    network.id, vmguestip=ipaddress_2.ipaddress)
+            FireWallRule.create(
+                self.apiclient,
+                ipaddressid=public_ip_1.ipaddress.id,
+                protocol='TCP',
+                cidrlist=[
+                    self.services["fwrule"]["cidr"]],
+                startport=self.services["fwrule"]["startport"],
+                endport=self.services["fwrule"]["endport"])
+
+        natrule = NATRule.create(
+            self.api_client,
+            virtual_machine,
+            self.services["natrule"],
+            ipaddressid=public_ip_1.ipaddress.id,
+            networkid=network.id,
+            vmguestip=ipaddress_1.ipaddress)
+
+        StaticNATRule.enable(
+            self.apiclient,
+            public_ip_2.ipaddress.id,
+            virtual_machine.id,
+            network.id,
+            vmguestip=ipaddress_2.ipaddress)
 
         network.restart(self.apiclient, cleanup=False)
 
         natrulelist = NATRule.list(self.apiclient, id=natrule.id, listall=True)
-        self.assertEqual(validateList(natrulelist)[0], PASS, "nat rules list validation failed")
+        self.assertEqual(
+            validateList(natrulelist)[0],
+            PASS,
+            "nat rules list validation failed")
 
         self.VerifyStaticNatForPublicIp(public_ip_2.ipaddress.id, True)
         return
@@ -1206,54 +1651,87 @@ class TestVmNetworkOperations(cloudstackTestCase):
         # 6. Reboot router VM
         # 7. Verify that nat and static nat rules exist after router restart
 
-        self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id)
+        self.account = Account.create(
+            self.apiclient,
+            self.services["account"],
+            domainid=self.domain.id)
         self.cleanup.append(self.account)
 
         network = createNetwork(self, value)
 
-        try:
-            virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"],
-                                                    networkids=[network.id],serviceofferingid=self.service_offering.id,
-                                                    accountid=self.account.name,domainid=self.account.domainid)
-        except Exception as e:
-            self.fail("vm creation failed: %s" % e)
-
-        try:
-            ipaddress_1 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
-            ipaddress_2 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
-        except Exception as e:
-            self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id)
-
-        try:
-            public_ip_1 = PublicIPAddress.create(self.api_client,accountid=self.account.name,
-                                           zoneid=self.zone.id,domainid=self.account.domainid,
-                                           networkid=network.id, vpcid = network.vpcid if value == VPC_NETWORK else None)
-
-            public_ip_2 = PublicIPAddress.create(self.api_client,accountid=self.account.name,
-                                           zoneid=self.zone.id,domainid=self.account.domainid,
-                                           networkid=network.id, vpcid = network.vpcid if value == VPC_NETWORK else None)
-        except Exception as e:
-            self.fail("Exception while acquiring public ip address: %s" % e)
+        virtual_machine = VirtualMachine.create(
+            self.apiclient,
+            self.services["virtual_machine"],
+            networkids=[
+                network.id],
+            serviceofferingid=self.service_offering.id,
+            accountid=self.account.name,
+            domainid=self.account.domainid)
+
+        ipaddress_1 = NIC.addIp(
+            self.apiclient,
+            id=virtual_machine.nic[0].id)
+        ipaddress_2 = NIC.addIp(
+            self.apiclient,
+            id=virtual_machine.nic[0].id)
+
+        public_ip_1 = PublicIPAddress.create(
+            self.api_client,
+            accountid=self.account.name,
+            zoneid=self.zone.id,
+            domainid=self.account.domainid,
+            networkid=network.id,
+            vpcid=network.vpcid if value == VPC_NETWORK else None)
+
+        public_ip_2 = PublicIPAddress.create(
+            self.api_client,
+            accountid=self.account.name,
+            zoneid=self.zone.id,
+            domainid=self.account.domainid,
+            networkid=network.id,
+            vpcid=network.vpcid if value == VPC_NETWORK else None)
 
         if value != VPC_NETWORK:
-            FireWallRule.create(self.apiclient,ipaddressid=public_ip_1.ipaddress.id,
-                                      protocol='TCP', cidrlist=[self.services["fwrule"]["cidr"]],
-                                      startport=self.services["fwrule"]["startport"],endport=self.services["fwrule"]["endport"])
-
-        natrule = NATRule.create(self.api_client, virtual_machine,
-                       self.services["natrule"],ipaddressid=public_ip_1.ipaddress.id,
-                       networkid=network.id, vmguestip = ipaddress_1.ipaddress)
-
-        StaticNATRule.enable(self.apiclient, public_ip_2.ipaddress.id, virtual_machine.id,
-                    network.id, vmguestip=ipaddress_2.ipaddress)
-
-        routers = Router.list(self.apiclient, networkid=network.id, listall=True)
-        self.assertEqual(validateList(routers)[0], PASS, "routers list validation failed")
+            FireWallRule.create(
+                self.apiclient,
+                ipaddressid=public_ip_1.ipaddress.id,
+                protocol='TCP',
+                cidrlist=[
+                    self.services["fwrule"]["cidr"]],
+                startport=self.services["fwrule"]["startport"],
+                endport=self.services["fwrule"]["endport"])
+
+        natrule = NATRule.create(
+          

<TRUNCATED>

[40/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
Merge remote-tracking branch 'laszlo/CLOUDSTACK-8294'

This closes #92

Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/reporter
Commit: db443c1734c738ebd265259264ed7be5502fb246
Parents: 541c23e 873649e
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Mon Mar 2 16:36:27 2015 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Mon Mar 2 16:36:39 2015 +0530

----------------------------------------------------------------------
 .../cloud/network/nicira/NiciraNvpApiTest.java  | 21 ++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
----------------------------------------------------------------------



[11/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
CLOUDSTACK-8276: Changes in Marvin to find free vlan in a setup when vlan is not returned for an existing network with listNetworks API

Signed-off-by: SrikanteswaraRao Talluri <ta...@apache.org>


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

Branch: refs/heads/reporter
Commit: 429abe2bd53147381f3be1d1eae37cef7f5894cc
Parents: e1827fc
Author: Gaurav Aradhye <ga...@clogeny.com>
Authored: Sun Feb 22 23:44:33 2015 -0800
Committer: SrikanteswaraRao Talluri <ta...@apache.org>
Committed: Thu Feb 26 13:04:20 2015 +0530

----------------------------------------------------------------------
 tools/marvin/marvin/lib/common.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/429abe2b/tools/marvin/marvin/lib/common.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/lib/common.py b/tools/marvin/marvin/lib/common.py
index c59cf10..de6f146 100644
--- a/tools/marvin/marvin/lib/common.py
+++ b/tools/marvin/marvin/lib/common.py
@@ -977,9 +977,9 @@ def get_free_vlan(apiclient, zoneid):
 
     if isinstance(networks, list) and len(networks) > 0:
         usedVlanIds = [int(nw.vlan)
-                       for nw in networks if nw.vlan != "untagged"]
+                       for nw in networks if (nw.vlan and str(nw.vlan).lower() != "untagged")]
 
-    if hasattr(physical_network, "vlan") is False:
+    if not hasattr(physical_network, "vlan"):
         while True:
             shared_ntwk_vlan = random.randrange(1, 4095)
             if shared_ntwk_vlan in usedVlanIds:


[32/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
scripts: use cloudmanagementserver.keystore instead of cloud.keystore

Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
(cherry picked from commit f70afa1375dd353a68c3ee9be941a605025cfc04)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/reporter
Commit: 843c0f891b902f9c5c4192e672244e6aee2a4f71
Parents: a831beb
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Sat Feb 28 17:05:29 2015 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Sat Feb 28 17:06:27 2015 +0530

----------------------------------------------------------------------
 scripts/common/keys/ssl-keys.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/843c0f89/scripts/common/keys/ssl-keys.py
----------------------------------------------------------------------
diff --git a/scripts/common/keys/ssl-keys.py b/scripts/common/keys/ssl-keys.py
index 074a777..d6804cc 100644
--- a/scripts/common/keys/ssl-keys.py
+++ b/scripts/common/keys/ssl-keys.py
@@ -33,7 +33,7 @@ import traceback
 def generateSSLKey(outputPath):
   logf = open("ssl-keys.log", "w")
   hostName = socket.gethostbyname(socket.gethostname())
-  keyFile = outputPath + os.sep + "cloud.keystore"
+  keyFile = outputPath + os.sep + "cloudmanagementserver.keystore"
   logf.write("HostName = %s\n" % hostName)
   logf.write("OutputPath = %s\n" % keyFile)
   dname='cn="Cloudstack User",ou="' + hostName + '",o="' + hostName + '",c="Unknown"';


[48/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
kvm: Check the return value of the cloudstack-setup-agent command

Bug-Url: https://issues.apache.org/jira/browse/CLOUDSTACK-8016
Signed-off-by: Laszlo Hornyak <la...@gmail.com>
Signed-off-by: Rajani Karuturi <ra...@gmail.com>

This closes #93


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

Branch: refs/heads/reporter
Commit: 7c1590ffd67b74f52fe374b0fb91f8c1ef731c39
Parents: 619f014
Author: Laszlo Hornyak <la...@gmail.com>
Authored: Sat Jan 17 22:09:16 2015 +0100
Committer: Rajani Karuturi <ra...@gmail.com>
Committed: Wed Mar 4 12:42:14 2015 +0530

----------------------------------------------------------------------
 .../hypervisor/kvm/discoverer/LibvirtServerDiscoverer.java    | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7c1590ff/server/src/com/cloud/hypervisor/kvm/discoverer/LibvirtServerDiscoverer.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/hypervisor/kvm/discoverer/LibvirtServerDiscoverer.java b/server/src/com/cloud/hypervisor/kvm/discoverer/LibvirtServerDiscoverer.java
index d475f4d..350b9a7 100644
--- a/server/src/com/cloud/hypervisor/kvm/discoverer/LibvirtServerDiscoverer.java
+++ b/server/src/com/cloud/hypervisor/kvm/discoverer/LibvirtServerDiscoverer.java
@@ -205,7 +205,12 @@ public abstract class LibvirtServerDiscoverer extends DiscovererBase implements
             parameters += " --guestNic=" + kvmGuestNic;
             parameters += " --hypervisor=" + cluster.getHypervisorType().toString().toLowerCase();
 
-            SSHCmdHelper.sshExecuteCmd(sshConnection, "cloudstack-setup-agent " + parameters, 3);
+            if (!SSHCmdHelper.sshExecuteCmd(sshConnection,
+                    "cloudstack-setup-agent " + parameters, 3)) {
+                s_logger.info("cloudstack agent setup command failed: "
+                        + "cloudstack-setup-agent " + parameters);
+                return null;
+            }
 
             KvmDummyResourceBase kvmResource = new KvmDummyResourceBase();
             Map<String, Object> params = new HashMap<String, Object>();


[10/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
CLOUDSTACK-8285: check and update IP capacity states based on allocation state

- Backend should update if state was diabled and now has changed
- UI's fetch latest does not actually fetch latest

Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
(cherry picked from commit 985a61652eb5dc97503c002e9fc3c3a7ca39b70c)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/reporter
Commit: e1827fc696b1c4554881e340ae4cbc455495f13f
Parents: cc9461b
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Wed Feb 25 15:52:57 2015 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Wed Feb 25 16:47:40 2015 +0530

----------------------------------------------------------------------
 .../src/com/cloud/alert/AlertManagerImpl.java   | 17 ++++----
 .../com/cloud/server/ManagementServerImpl.java  |  5 +++
 .../com/cloud/storage/StorageManagerImpl.java   | 41 ++++++++------------
 ui/scripts/dashboard.js                         | 14 ++-----
 4 files changed, 33 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e1827fc6/server/src/com/cloud/alert/AlertManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/alert/AlertManagerImpl.java b/server/src/com/cloud/alert/AlertManagerImpl.java
index 3f599a1..8653069 100644
--- a/server/src/com/cloud/alert/AlertManagerImpl.java
+++ b/server/src/com/cloud/alert/AlertManagerImpl.java
@@ -364,16 +364,16 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi
         int totalVlans = _dcDao.countZoneVlans(dcId, false);
         int allocatedVlans = _dcDao.countZoneVlans(dcId, true);
 
+        CapacityState vlanCapacityState = (capacityState == AllocationState.Disabled) ? CapacityState.Disabled : CapacityState.Enabled;
         if (capacities.size() == 0) {
             CapacityVO newVlanCapacity = new CapacityVO(null, dcId, null, null, allocatedVlans, totalVlans, Capacity.CAPACITY_TYPE_VLAN);
-            if (capacityState == AllocationState.Disabled) {
-                newVlanCapacity.setCapacityState(CapacityState.Disabled);
-            }
+            newVlanCapacity.setCapacityState(vlanCapacityState);
             _capacityDao.persist(newVlanCapacity);
-        } else if (!(capacities.get(0).getUsedCapacity() == allocatedVlans && capacities.get(0).getTotalCapacity() == totalVlans)) {
+        } else if (!(capacities.get(0).getUsedCapacity() == allocatedVlans && capacities.get(0).getTotalCapacity() == totalVlans && capacities.get(0).getCapacityState() == vlanCapacityState)) {
             CapacityVO capacity = capacities.get(0);
             capacity.setUsedCapacity(allocatedVlans);
             capacity.setTotalCapacity(totalVlans);
+            capacity.setCapacityState(vlanCapacityState);
             _capacityDao.update(capacity.getId(), capacity);
         }
 
@@ -402,19 +402,18 @@ public class AlertManagerImpl extends ManagerBase implements AlertManager, Confi
             allocatedIPs = _publicIPAddressDao.countIPsForNetwork(dcId, true, VlanType.DirectAttached);
         }
 
+        CapacityState ipCapacityState = (capacityState == AllocationState.Disabled) ? CapacityState.Disabled : CapacityState.Enabled;
         if (capacities.size() == 0) {
             CapacityVO newPublicIPCapacity = new CapacityVO(null, dcId, podId, null, allocatedIPs, totalIPs, capacityType);
-            if (capacityState == AllocationState.Disabled) {
-                newPublicIPCapacity.setCapacityState(CapacityState.Disabled);
-            }
+            newPublicIPCapacity.setCapacityState(ipCapacityState);
             _capacityDao.persist(newPublicIPCapacity);
-        } else if (!(capacities.get(0).getUsedCapacity() == allocatedIPs && capacities.get(0).getTotalCapacity() == totalIPs)) {
+        } else if (!(capacities.get(0).getUsedCapacity() == allocatedIPs && capacities.get(0).getTotalCapacity() == totalIPs && capacities.get(0).getCapacityState() == ipCapacityState)) {
             CapacityVO capacity = capacities.get(0);
             capacity.setUsedCapacity(allocatedIPs);
             capacity.setTotalCapacity(totalIPs);
+            capacity.setCapacityState(ipCapacityState);
             _capacityDao.update(capacity.getId(), capacity);
         }
-
     }
 
     class CapacityChecker extends ManagedContextTimerTask {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e1827fc6/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java
index aa158b4..eabaf23 100644
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -2390,11 +2390,16 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
         Long zoneId = cmd.getZoneId();
         Long podId = cmd.getPodId();
         Long clusterId = cmd.getClusterId();
+        Boolean fetchLatest = cmd.getFetchLatest();
 
         if (clusterId != null) {
             throw new InvalidParameterValueException("Currently clusterId param is not suppoerted");
         }
         zoneId = _accountMgr.checkAccessAndSpecifyAuthority(CallContext.current().getCallingAccount(), zoneId);
+
+        if (fetchLatest != null && fetchLatest) {
+            _alertMgr.recalculateCapacity();
+        }
         List<SummedCapacity> summedCapacities = new ArrayList<SummedCapacity>();
 
         if (zoneId == null && podId == null) {// Group by Zone, capacity type

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e1827fc6/server/src/com/cloud/storage/StorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java
index bfaa461..d72cc69 100644
--- a/server/src/com/cloud/storage/StorageManagerImpl.java
+++ b/server/src/com/cloud/storage/StorageManagerImpl.java
@@ -927,39 +927,32 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
         }
 
         s_logger.debug("Total over provisioned capacity of the pool " + storagePool.getName() + " id: " + storagePool.getId() + " is " + totalOverProvCapacity);
+        CapacityState capacityState = CapacityState.Enabled;
+        if (storagePool.getScope() == ScopeType.ZONE) {
+            DataCenterVO dc = ApiDBUtils.findZoneById(storagePool.getDataCenterId());
+            AllocationState allocationState = dc.getAllocationState();
+            capacityState = (allocationState == AllocationState.Disabled) ? CapacityState.Disabled : CapacityState.Enabled;
+        } else {
+            if (storagePool.getClusterId() != null) {
+                ClusterVO cluster = ApiDBUtils.findClusterById(storagePool.getClusterId());
+                if (cluster != null) {
+                    AllocationState allocationState = _configMgr.findClusterAllocationState(cluster);
+                    capacityState = (allocationState == AllocationState.Disabled) ? CapacityState.Disabled : CapacityState.Enabled;
+                }
+            }
+        }
         if (capacities.size() == 0) {
             CapacityVO capacity =
                     new CapacityVO(storagePool.getId(), storagePool.getDataCenterId(), storagePool.getPodId(), storagePool.getClusterId(), allocated, totalOverProvCapacity,
                             capacityType);
-
-            if (storagePool.getScope() == ScopeType.ZONE) {
-                DataCenterVO dc = ApiDBUtils.findZoneById(storagePool.getDataCenterId());
-                AllocationState allocationState = dc.getAllocationState();
-                CapacityState capacityState = (allocationState == AllocationState.Disabled) ? CapacityState.Disabled : CapacityState.Enabled;
-                capacity.setCapacityState(capacityState);
-            } else {
-                if (storagePool.getClusterId() != null) {
-                    ClusterVO cluster = ApiDBUtils.findClusterById(storagePool.getClusterId());
-                    if (cluster != null) {
-                        AllocationState allocationState = _configMgr.findClusterAllocationState(cluster);
-                        CapacityState capacityState = (allocationState == AllocationState.Disabled) ? CapacityState.Disabled : CapacityState.Enabled;
-                        capacity.setCapacityState(capacityState);
-                    }
-                }
-            }
+            capacity.setCapacityState(capacityState);
             _capacityDao.persist(capacity);
         } else {
             CapacityVO capacity = capacities.get(0);
-            boolean update = false;
-            if (capacity.getTotalCapacity() != totalOverProvCapacity) {
+            if (capacity.getTotalCapacity() != totalOverProvCapacity || allocated != 0L || capacity.getCapacityState() != capacityState) {
                 capacity.setTotalCapacity(totalOverProvCapacity);
-                update = true;
-            }
-            if (allocated != 0) {
                 capacity.setUsedCapacity(allocated);
-                update = true;
-            }
-            if (update) {
+                capacity.setCapacityState(capacityState);
                 _capacityDao.update(capacity.getId(), capacity);
             }
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e1827fc6/ui/scripts/dashboard.js
----------------------------------------------------------------------
diff --git a/ui/scripts/dashboard.js b/ui/scripts/dashboard.js
index 15e5e52..dff6a91 100644
--- a/ui/scripts/dashboard.js
+++ b/ui/scripts/dashboard.js
@@ -183,20 +183,12 @@
                         });
                     },
                     capacity: function(data) {
-                        var latestData = null;
                         if (window.fetchLatestflag == 1) {
-                            latestData = {
-
-                                fetchLatest: true
-                            }
+                            data.fetchLastest = true;
                         } else {
-                            latestData = {
-                                fetchLatest: false
-                            }
+                            data.fetchLastest = false;
                         }
-
                         window.fetchLatestflag = 0;
-
                         dataFns.alerts(data);
                     },
 
@@ -252,7 +244,7 @@
                         $.ajax({
                             url: createURL('listCapacity'),
                             data: {
-                                fetchLatest: false,
+                                fetchLatest: data.fetchLatest,
                                 sortBy: 'usage',
                                 page: 0,
                                 pageSize: (pageSize > 8? 8: pageSize) 


[26/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
removed redundant autoboxing

Signed-off-by: Laszlo Hornyak <la...@gmail.com>


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

Branch: refs/heads/reporter
Commit: e6e3a20bd6ef95d40af2018c74430a0b5f77166b
Parents: 5626a34
Author: Laszlo Hornyak <la...@gmail.com>
Authored: Wed Feb 25 20:58:25 2015 +0100
Committer: Laszlo Hornyak <la...@gmail.com>
Committed: Fri Feb 27 19:38:12 2015 +0100

----------------------------------------------------------------------
 core/src/com/cloud/agent/api/routing/SetFirewallRulesCommand.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e6e3a20b/core/src/com/cloud/agent/api/routing/SetFirewallRulesCommand.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/routing/SetFirewallRulesCommand.java b/core/src/com/cloud/agent/api/routing/SetFirewallRulesCommand.java
index e030545..1f8d4cf 100644
--- a/core/src/com/cloud/agent/api/routing/SetFirewallRulesCommand.java
+++ b/core/src/com/cloud/agent/api/routing/SetFirewallRulesCommand.java
@@ -77,7 +77,7 @@ public class SetFirewallRulesCommand extends NetworkElementCommand {
             if (cidr == null || cidr.isEmpty()) {
                 sb.append("0.0.0.0/0");
             } else {
-                Boolean firstEntry = true;
+                boolean firstEntry = true;
                 for (String tag : cidr) {
                     if (!firstEntry)
                         sb.append("-");


[28/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
CLOUDSTACK-8279: test fix for java 1.8

The test build on an assumption on the order of items in a Set, while this changed in java 1.8

Signed-off-by: Laszlo Hornyak <la...@gmail.com>


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

Branch: refs/heads/reporter
Commit: f8c003d13a4b26839712d8534f8b89fa00dc1275
Parents: e6e3a20
Author: Laszlo Hornyak <la...@gmail.com>
Authored: Fri Feb 27 19:03:08 2015 +0100
Committer: Laszlo Hornyak <la...@gmail.com>
Committed: Fri Feb 27 19:38:12 2015 +0100

----------------------------------------------------------------------
 .../VirtualRoutingResourceTest.java             | 204 +++++++++++--------
 1 file changed, 115 insertions(+), 89 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f8c003d1/core/test/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResourceTest.java
----------------------------------------------------------------------
diff --git a/core/test/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResourceTest.java b/core/test/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResourceTest.java
index b77e92d..6d7ff29 100644
--- a/core/test/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResourceTest.java
+++ b/core/test/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResourceTest.java
@@ -24,6 +24,8 @@ import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
@@ -80,6 +82,9 @@ import com.cloud.network.vpc.NetworkACLItem.TrafficType;
 import com.cloud.network.vpc.VpcGateway;
 import com.cloud.utils.ExecutionResult;
 import com.cloud.utils.net.NetUtils;
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
 
 @RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(loader = AnnotationConfigContextLoader.class)
@@ -1003,95 +1008,116 @@ public class VirtualRoutingResourceTest implements VirtualRouterDeployer {
         assertEquals(path, "/var/cache/cloud/");
         assertTrue(filename.startsWith("VR-"));
         assertTrue(filename.endsWith(".cfg"));
-        assertEquals(content, "#Apache CloudStack Virtual Router Config File\n" +
-                "<version>\n" +
-                "1.0\n" +
-                "</version>\n" +
-                "<script>\n" +
-                "/opt/cloud/bin/ipassoc.sh -A -s -f -l 64.1.1.10/24 -c eth2 -g 64.1.1.1\n" +
-                "</script>\n" +
-                "<script>\n" +
-                "/opt/cloud/bin/ipassoc.sh -D -l 64.1.1.11/24 -c eth2 -g 64.1.1.1\n" +
-                "</script>\n" +
-                "<script>\n" +
-                "/opt/cloud/bin/ipassoc.sh -A -l 65.1.1.11/24 -c eth2 -g 65.1.1.1\n" +
-                "</script>\n" +
-                "<script>\n" +
-                "/opt/cloud/bin/vpc_ipassoc.sh  -A  -l 64.1.1.10 -c eth2 -g 64.1.1.1 -m 24 -n 64.1.1.0\n" +
-                "</script>\n" +
-                "<script>\n" +
-                "/opt/cloud/bin/vpc_privateGateway.sh  -A  -l 64.1.1.10 -c eth2\n" +
-                "</script>\n" +
-                "<script>\n" +
-                "/opt/cloud/bin/vpc_ipassoc.sh  -D  -l 64.1.1.11 -c eth2 -g 64.1.1.1 -m 24 -n 64.1.1.0\n" +
-                "</script>\n" +
-                "<script>\n" +
-                "/opt/cloud/bin/vpc_privateGateway.sh  -D  -l 64.1.1.11 -c eth2\n" +
-                "</script>\n" +
-                "<script>\n" +
-                "/opt/cloud/bin/vpc_ipassoc.sh  -A  -l 65.1.1.11 -c eth2 -g 65.1.1.1 -m 24 -n 65.1.1.0\n" +
-                "</script>\n" +
-                "<script>\n" +
-                "/opt/cloud/bin/firewall_ingress.sh  -F -a 64.10.10.10:ICMP:0:0:10.10.1.1/24-10.10.1.2/24:,64.10.10.10:TCP:22:80:10.10.1.1/24-10.10.1.2/24:,64.10.10.10:reverted:0:0:0:,\n" +
-                "</script>\n" +
-                "<script>\n" +
-                "/opt/cloud/bin/firewall_nat.sh -A -P tcp -l 64.1.1.10 -p 22:80 -r 10.10.1.10 -d 22:80\n" +
-                "</script>\n" +
-                "<script>\n" +
-                "/opt/cloud/bin/firewall_nat.sh -D -P udp -l 64.1.1.11 -p 8080:8080 -r 10.10.1.11 -d 8080:8080\n" +
-                "</script>\n" +
-                "<script>\n" +
-                "/opt/cloud/bin/vpc_portforwarding.sh -A -P tcp -l 64.1.1.10 -p 22:80 -r 10.10.1.10 -d 22-80\n" +
-                "</script>\n" +
-                "<script>\n" +
-                "/opt/cloud/bin/vpc_portforwarding.sh -D -P udp -l 64.1.1.11 -p 8080:8080 -r 10.10.1.11 -d 8080-8080\n" +
-                "</script>\n" +
-                "<script>\n" +
-                "/opt/cloud/bin/createIpAlias.sh 1:169.254.3.10:255.255.255.0-2:169.254.3.11:255.255.255.0-3:169.254.3.12:255.255.255.0-\n" +
-                "</script>\n" +
-                "<script>\n" +
-                "/opt/cloud/bin/deleteIpAlias.sh 1:169.254.3.10:255.255.255.0-2:169.254.3.11:255.255.255.0-3:169.254.3.12:255.255.255.0-- 1:169.254.3.10:255.255.255.0-2:169.254.3.11:255.255.255.0-3:169.254.3.12:255.255.255.0-\n" +
-                "</script>\n" +
-                "<script>\n" +
-                "/opt/cloud/bin/dnsmasq.sh 10.1.20.2:10.1.20.1:255.255.255.0:10.1.20.5-10.1.21.2:10.1.21.1:255.255.255.0:10.1.21.5-\n" +
-                "</script>\n" +
-                "<script>\n" +
-                "/opt/cloud/bin/vpn_l2tp.sh -r 10.10.1.10-10.10.1.20 -p sharedkey -s 124.10.10.10 -l 10.10.1.1 -c  -C 10.1.1.1/24 -i eth2\n" +
-                "</script>\n" +
-                "<script>\n" +
-                "/opt/cloud/bin/vpn_l2tp.sh -d  -s 124.10.10.10 -C 10.1.1.1/24 -i eth2\n" +
-                "</script>\n" +
-                "<script>\n" +
-                "/opt/cloud/bin/vpn_l2tp.sh -r 10.10.1.10-10.10.1.20 -p sharedkey -s 124.10.10.10 -l 10.10.1.1 -c  -C 10.1.1.1/24 -i eth1\n" +
-                "</script>\n" +
-                "<script>\n" +
-                "/opt/cloud/bin/firewall_nat.sh -A -P tcp -l 64.1.1.10 -p 22:80 -r 10.10.1.10 -d 22:80\n" +
-                "</script>\n" +
-                "<script>\n" +
-                "/opt/cloud/bin/firewall_nat.sh -D -P udp -l 64.1.1.11 -p 8080:8080 -r 10.10.1.11 -d 8080:8080\n" +
-                "</script>\n" +
-                "<script>\n" +
-                "/opt/cloud/bin/vpc_portforwarding.sh -A -P tcp -l 64.1.1.10 -p 22:80 -r 10.10.1.10 -d 22-80\n" +
-                "</script>\n" +
-                "<script>\n" +
-                "/opt/cloud/bin/vpc_portforwarding.sh -D -P udp -l 64.1.1.11 -p 8080:8080 -r 10.10.1.11 -d 8080-8080\n" +
-                "</script>\n" +
-                "<script>\n" +
-                "/opt/cloud/bin/edithosts.sh  -m 12:34:56:78:90:AB -4 10.1.10.2 -h vm1\n" +
-                "</script>\n" +
-                "<script>\n" +
-                "/opt/cloud/bin/edithosts.sh  -m 12:34:56:78:90:AB -h vm1 -6 2001:db8:0:0:0:ff00:42:8329 -u 00:03:00:01:12:34:56:78:90:AB\n" +
-                "</script>\n" +
-                "<script>\n" +
-                "/opt/cloud/bin/edithosts.sh  -m 12:34:56:78:90:AB -4 10.1.10.2 -h vm1 -6 2001:db8:0:0:0:ff00:42:8329 -u 00:03:00:01:12:34:56:78:90:AB\n" +
-                "</script>\n" +
-                "<script>\n" +
-                "/opt/cloud/bin/savepassword.sh -v 10.1.10.4 -p 123pass\n" +
-                "</script>\n" +
-                "<script>\n" +
-                "/opt/cloud/bin/vmdata.py -d eyIxMC4xLjEwLjQiOltbInVzZXJkYXRhIiwidXNlci1kYXRhIiwidXNlci1kYXRhIl0sWyJtZXRhZGF0YSIsInNlcnZpY2Utb2ZmZXJpbmciLCJzZXJ2aWNlT2ZmZXJpbmciXSxbIm1ldGFkYXRhIiwiYXZhaWxhYmlsaXR5LXpvbmUiLCJ6b25lTmFtZSJdLFsibWV0YWRhdGEiLCJsb2NhbC1pcHY0IiwiMTAuMS4xMC40Il0sWyJtZXRhZGF0YSIsImxvY2FsLWhvc3RuYW1lIiwidGVzdC12bSJdLFsibWV0YWRhdGEiLCJwdWJsaWMtaXB2NCIsIjExMC4xLjEwLjQiXSxbIm1ldGFkYXRhIiwicHVibGljLWhvc3RuYW1lIiwiaG9zdG5hbWUiXSxbIm1ldGFkYXRhIiwiaW5zdGFuY2UtaWQiLCJpLTQtVk0iXSxbIm1ldGFkYXRhIiwidm0taWQiLCI0Il0sWyJtZXRhZGF0YSIsInB1YmxpYy1rZXlzIiwicHVibGlja2V5Il0sWyJtZXRhZGF0YSIsImNsb3VkLWlkZW50aWZpZXIiLCJDbG91ZFN0YWNrLXt0ZXN0fSJdXX0=\n" +
-                "</script>" +
-                "\n");
+        Collection<String> filteredScripts = Collections2.transform(Collections2.filter (
+                Arrays.asList(content.split("</?script>")), new Predicate<String>() {
+
+                    @Override
+                    public boolean apply(String str) {
+                        return str.trim().startsWith("/opt/cloud");
+                    }
+                }), new Function<String, String>() {
+
+                    @Override
+                    public String apply(String str) {
+                        return str.trim();
+                    }
+                });
+        String[] scripts = filteredScripts.toArray(new String[filteredScripts
+                .size()]);
+
+        assertEquals(
+                "/opt/cloud/bin/ipassoc.sh -A -s -f -l 64.1.1.10/24 -c eth2 -g 64.1.1.1",
+                scripts[0]);
+
+        assertEquals(
+                "/opt/cloud/bin/ipassoc.sh -D -l 64.1.1.11/24 -c eth2 -g 64.1.1.1",
+                scripts[1]);
+
+        assertEquals(
+                "/opt/cloud/bin/ipassoc.sh -A -l 65.1.1.11/24 -c eth2 -g 65.1.1.1",
+                scripts[2]);
+        assertEquals(
+                "/opt/cloud/bin/vpc_ipassoc.sh  -A  -l 64.1.1.10 -c eth2 -g 64.1.1.1 -m 24 -n 64.1.1.0",
+                scripts[3]);
+        assertEquals(
+                "/opt/cloud/bin/vpc_privateGateway.sh  -A  -l 64.1.1.10 -c eth2",
+                scripts[4]);
+        assertEquals(
+                "/opt/cloud/bin/vpc_ipassoc.sh  -D  -l 64.1.1.11 -c eth2 -g 64.1.1.1 -m 24 -n 64.1.1.0",
+                scripts[5]);
+        assertEquals(
+                "/opt/cloud/bin/vpc_privateGateway.sh  -D  -l 64.1.1.11 -c eth2",
+                scripts[6]);
+        assertEquals(
+                "/opt/cloud/bin/vpc_ipassoc.sh  -A  -l 65.1.1.11 -c eth2 -g 65.1.1.1 -m 24 -n 65.1.1.0",
+                scripts[7]);
+        //the list generated by SetFirewallCmd is actually generated through a Set
+        //therefore we can not bet on the order of the parameters
+        assertTrue(
+                scripts[8].matches("/opt/cloud/bin/firewall_ingress.sh  -F -a .*"));
+        assertTrue(
+                scripts[8].contains("64.10.10.10:ICMP:0:0:10.10.1.1/24-10.10.1.2/24:"));
+        assertTrue(
+                scripts[8].contains("64.10.10.10:TCP:22:80:10.10.1.1/24-10.10.1.2/24:"));
+        assertTrue(
+                scripts[8].contains("64.10.10.10:reverted:0:0:0:"));
+
+        assertEquals(
+                "/opt/cloud/bin/firewall_nat.sh -A -P tcp -l 64.1.1.10 -p 22:80 -r 10.10.1.10 -d 22:80",
+                scripts[9]);
+        assertEquals(
+                "/opt/cloud/bin/firewall_nat.sh -D -P udp -l 64.1.1.11 -p 8080:8080 -r 10.10.1.11 -d 8080:8080",
+                scripts[10]);
+        assertEquals(
+                "/opt/cloud/bin/vpc_portforwarding.sh -A -P tcp -l 64.1.1.10 -p 22:80 -r 10.10.1.10 -d 22-80",
+                scripts[11]);
+        assertEquals(
+                "/opt/cloud/bin/vpc_portforwarding.sh -D -P udp -l 64.1.1.11 -p 8080:8080 -r 10.10.1.11 -d 8080-8080",
+                scripts[12]);
+        assertEquals(
+                "/opt/cloud/bin/createIpAlias.sh 1:169.254.3.10:255.255.255.0-2:169.254.3.11:255.255.255.0-3:169.254.3.12:255.255.255.0-",
+                scripts[13]);
+        assertEquals(
+                "/opt/cloud/bin/deleteIpAlias.sh 1:169.254.3.10:255.255.255.0-2:169.254.3.11:255.255.255.0-3:169.254.3.12:255.255.255.0-- 1:169.254.3.10:255.255.255.0-2:169.254.3.11:255.255.255.0-3:169.254.3.12:255.255.255.0-",
+                scripts[14]);
+        assertEquals(
+                "/opt/cloud/bin/dnsmasq.sh 10.1.20.2:10.1.20.1:255.255.255.0:10.1.20.5-10.1.21.2:10.1.21.1:255.255.255.0:10.1.21.5-",
+                scripts[15]);
+        assertEquals(
+                "/opt/cloud/bin/vpn_l2tp.sh -r 10.10.1.10-10.10.1.20 -p sharedkey -s 124.10.10.10 -l 10.10.1.1 -c  -C 10.1.1.1/24 -i eth2",
+                scripts[16]);
+        assertEquals(
+                "/opt/cloud/bin/vpn_l2tp.sh -d  -s 124.10.10.10 -C 10.1.1.1/24 -i eth2",
+                scripts[17]);
+        assertEquals(
+                "/opt/cloud/bin/vpn_l2tp.sh -r 10.10.1.10-10.10.1.20 -p sharedkey -s 124.10.10.10 -l 10.10.1.1 -c  -C 10.1.1.1/24 -i eth1",
+                scripts[18]);
+        assertEquals(
+                "/opt/cloud/bin/firewall_nat.sh -A -P tcp -l 64.1.1.10 -p 22:80 -r 10.10.1.10 -d 22:80",
+                scripts[19]);
+        assertEquals(
+                "/opt/cloud/bin/firewall_nat.sh -D -P udp -l 64.1.1.11 -p 8080:8080 -r 10.10.1.11 -d 8080:8080",
+                scripts[20]);
+        assertEquals(
+                "/opt/cloud/bin/vpc_portforwarding.sh -A -P tcp -l 64.1.1.10 -p 22:80 -r 10.10.1.10 -d 22-80",
+                scripts[21]);
+        assertEquals(
+                "/opt/cloud/bin/vpc_portforwarding.sh -D -P udp -l 64.1.1.11 -p 8080:8080 -r 10.10.1.11 -d 8080-8080",
+                scripts[22]);
+        assertEquals(
+                "/opt/cloud/bin/edithosts.sh  -m 12:34:56:78:90:AB -4 10.1.10.2 -h vm1",
+                scripts[23]);
+        assertEquals(
+                "/opt/cloud/bin/edithosts.sh  -m 12:34:56:78:90:AB -h vm1 -6 2001:db8:0:0:0:ff00:42:8329 -u 00:03:00:01:12:34:56:78:90:AB",
+                scripts[24]);
+        assertEquals(
+                "/opt/cloud/bin/edithosts.sh  -m 12:34:56:78:90:AB -4 10.1.10.2 -h vm1 -6 2001:db8:0:0:0:ff00:42:8329 -u 00:03:00:01:12:34:56:78:90:AB",
+                scripts[25]);
+        assertEquals("/opt/cloud/bin/savepassword.sh -v 10.1.10.4 -p 123pass",
+                scripts[26]);
+        assertEquals(
+                "/opt/cloud/bin/vmdata.py -d eyIxMC4xLjEwLjQiOltbInVzZXJkYXRhIiwidXNlci1kYXRhIiwidXNlci1kYXRhIl0sWyJtZXRhZGF0YSIsInNlcnZpY2Utb2ZmZXJpbmciLCJzZXJ2aWNlT2ZmZXJpbmciXSxbIm1ldGFkYXRhIiwiYXZhaWxhYmlsaXR5LXpvbmUiLCJ6b25lTmFtZSJdLFsibWV0YWRhdGEiLCJsb2NhbC1pcHY0IiwiMTAuMS4xMC40Il0sWyJtZXRhZGF0YSIsImxvY2FsLWhvc3RuYW1lIiwidGVzdC12bSJdLFsibWV0YWRhdGEiLCJwdWJsaWMtaXB2NCIsIjExMC4xLjEwLjQiXSxbIm1ldGFkYXRhIiwicHVibGljLWhvc3RuYW1lIiwiaG9zdG5hbWUiXSxbIm1ldGFkYXRhIiwiaW5zdGFuY2UtaWQiLCJpLTQtVk0iXSxbIm1ldGFkYXRhIiwidm0taWQiLCI0Il0sWyJtZXRhZGF0YSIsInB1YmxpYy1rZXlzIiwicHVibGlja2V5Il0sWyJtZXRhZGF0YSIsImNsb3VkLWlkZW50aWZpZXIiLCJDbG91ZFN0YWNrLXt0ZXN0fSJdXX0=",
+                scripts[27]);
     }
 
 }


[14/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
CLOUDSTACK-8277: Code improvement - test_shared_networks.py, test_multiple_ip_ranges.py

Signed-off-by: SrikanteswaraRao Talluri <ta...@apache.org>


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

Branch: refs/heads/reporter
Commit: f39319932576804eaafb9e51235290fdf23f3841
Parents: 429abe2
Author: Gaurav Aradhye <ga...@clogeny.com>
Authored: Mon Feb 23 00:23:46 2015 -0800
Committer: SrikanteswaraRao Talluri <ta...@apache.org>
Committed: Thu Feb 26 13:05:45 2015 +0530

----------------------------------------------------------------------
 .../component/test_multiple_ips_per_nic.py      | 1492 +++++++----
 .../component/test_shared_networks.py           | 2429 ++++++++++--------
 2 files changed, 2272 insertions(+), 1649 deletions(-)
----------------------------------------------------------------------



[33/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
CLOUDSTACK-7063, CLOUDSTACK-7064: Add security headers on HTTP response

- Adds X-XSS-Protection header
- Adds X-Content-Type-Options header
- Fixes to use json content type defined from global settings
- Uses secure cookie if enabled in global settings

Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
(cherry picked from commit b6b3494782d8bc1033941b802380ba1d5ebd464c)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/reporter
Commit: 20bcb4b673ea83dd3d4e301705425632daa226ca
Parents: 843c0f8
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Sat Feb 28 18:12:37 2015 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Sat Feb 28 18:14:49 2015 +0530

----------------------------------------------------------------------
 server/src/com/cloud/api/ApiServer.java        | 21 ++++++++++++-----
 server/src/com/cloud/api/ApiServlet.java       | 24 ++++++++++++-------
 server/src/com/cloud/configuration/Config.java | 15 +++++++++---
 utils/src/com/cloud/utils/HttpUtils.java       | 26 ++++++++++++++++++---
 4 files changed, 66 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20bcb4b6/server/src/com/cloud/api/ApiServer.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiServer.java b/server/src/com/cloud/api/ApiServer.java
index daf24ef..cf719c0 100644
--- a/server/src/com/cloud/api/ApiServer.java
+++ b/server/src/com/cloud/api/ApiServer.java
@@ -181,7 +181,8 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
     private static final Logger s_accessLogger = Logger.getLogger("apiserver." + ApiServer.class.getName());
 
     public static boolean encodeApiResponse = false;
-    public static String jsonContentType = "text/javascript";
+    public static boolean s_enableSecureCookie = false;
+    public static String s_jsonContentType = HttpUtils.JSON_CONTENT_TYPE;
 
     /**
      * Non-printable ASCII characters - numbers 0 to 31 and 127 decimal
@@ -362,9 +363,13 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
         }
 
         setEncodeApiResponse(Boolean.valueOf(_configDao.getValue(Config.EncodeApiResponse.key())));
-        final String jsonType = _configDao.getValue(Config.JavaScriptDefaultContentType.key());
+        final String jsonType = _configDao.getValue(Config.JSONDefaultContentType.key());
         if (jsonType != null) {
-            jsonContentType = jsonType;
+            s_jsonContentType = jsonType;
+        }
+        final Boolean enableSecureSessionCookie = Boolean.valueOf(_configDao.getValue(Config.EnableSecureSessionCookie.key()));
+        if (enableSecureSessionCookie != null) {
+            s_enableSecureCookie = enableSecureSessionCookie;
         }
 
         if (apiPort != null) {
@@ -1136,7 +1141,7 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
             final BasicHttpEntity body = new BasicHttpEntity();
             if (HttpUtils.RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
                 // JSON response
-                body.setContentType(jsonContentType);
+                body.setContentType(getJSONContentType());
                 if (responseText == null) {
                     body.setContent(new ByteArrayInputStream("{ \"error\" : { \"description\" : \"Internal Server Error\" } }".getBytes(HttpUtils.UTF_8)));
                 }
@@ -1367,7 +1372,11 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer
         ApiServer.encodeApiResponse = encodeApiResponse;
     }
 
-    public static String getJsonContentType() {
-        return jsonContentType;
+    public static boolean isSecureSessionCookieEnabled() {
+        return s_enableSecureCookie;
+    }
+
+    public static String getJSONContentType() {
+        return s_jsonContentType;
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20bcb4b6/server/src/com/cloud/api/ApiServlet.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiServlet.java b/server/src/com/cloud/api/ApiServlet.java
index 3c73375..5628d98 100644
--- a/server/src/com/cloud/api/ApiServlet.java
+++ b/server/src/com/cloud/api/ApiServlet.java
@@ -155,12 +155,20 @@ public class ApiServlet extends HttpServlet {
         try {
 
             if (HttpUtils.RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
-                resp.setContentType(HttpUtils.JSON_CONTENT_TYPE);
+                resp.setContentType(ApiServer.getJSONContentType());
             } else if (HttpUtils.RESPONSE_TYPE_XML.equalsIgnoreCase(responseType)){
                 resp.setContentType(HttpUtils.XML_CONTENT_TYPE);
             }
 
             HttpSession session = req.getSession(false);
+            if (ApiServer.isSecureSessionCookieEnabled()) {
+                resp.setHeader("SET-COOKIE", "JSESSIONID=" + session.getId() + ";Secure;Path=/client");
+                if (s_logger.isDebugEnabled()) {
+                    if (s_logger.isDebugEnabled()) {
+                        s_logger.debug("Session cookie is marked secure!");
+                    }
+                }
+            }
             final Object[] responseTypeParam = params.get(ApiConstants.RESPONSE);
             if (responseTypeParam != null) {
                 responseType = (String)responseTypeParam[0];
@@ -213,7 +221,7 @@ public class ApiServlet extends HttpServlet {
                             }
                         }
                     }
-                    HttpUtils.writeHttpResponse(resp, responseString, httpResponseCode, responseType);
+                    HttpUtils.writeHttpResponse(resp, responseString, httpResponseCode, responseType, ApiServer.getJSONContentType());
                     return;
                 }
             }
@@ -240,7 +248,7 @@ public class ApiServlet extends HttpServlet {
                     auditTrailSb.append(" " + HttpServletResponse.SC_UNAUTHORIZED + " " + "unable to verify user credentials");
                     final String serializedResponse =
                         _apiServer.getSerializedApiError(HttpServletResponse.SC_UNAUTHORIZED, "unable to verify user credentials", params, responseType);
-                    HttpUtils.writeHttpResponse(resp, serializedResponse, HttpServletResponse.SC_UNAUTHORIZED, responseType);
+                    HttpUtils.writeHttpResponse(resp, serializedResponse, HttpServletResponse.SC_UNAUTHORIZED, responseType, ApiServer.getJSONContentType());
                     return;
                 }
 
@@ -251,7 +259,7 @@ public class ApiServlet extends HttpServlet {
                         s_logger.info("missing command, ignoring request...");
                         auditTrailSb.append(" " + HttpServletResponse.SC_BAD_REQUEST + " " + "no command specified");
                         final String serializedResponse = _apiServer.getSerializedApiError(HttpServletResponse.SC_BAD_REQUEST, "no command specified", params, responseType);
-                        HttpUtils.writeHttpResponse(resp, serializedResponse, HttpServletResponse.SC_BAD_REQUEST, responseType);
+                        HttpUtils.writeHttpResponse(resp, serializedResponse, HttpServletResponse.SC_BAD_REQUEST, responseType, ApiServer.getJSONContentType());
                         return;
                     }
                     final User user = _entityMgr.findById(User.class, userId);
@@ -267,7 +275,7 @@ public class ApiServlet extends HttpServlet {
                     auditTrailSb.append(" " + HttpServletResponse.SC_UNAUTHORIZED + " " + "unable to verify user credentials");
                     final String serializedResponse =
                         _apiServer.getSerializedApiError(HttpServletResponse.SC_UNAUTHORIZED, "unable to verify user credentials", params, responseType);
-                    HttpUtils.writeHttpResponse(resp, serializedResponse, HttpServletResponse.SC_UNAUTHORIZED, responseType);
+                    HttpUtils.writeHttpResponse(resp, serializedResponse, HttpServletResponse.SC_UNAUTHORIZED, responseType, ApiServer.getJSONContentType());
                     return;
                 }
             } else {
@@ -281,7 +289,7 @@ public class ApiServlet extends HttpServlet {
                 // Add the HTTP method (GET/POST/PUT/DELETE) as well into the params map.
                 params.put("httpmethod", new String[] {req.getMethod()});
                 final String response = _apiServer.handleRequest(params, responseType, auditTrailSb);
-                HttpUtils.writeHttpResponse(resp, response != null ? response : "", HttpServletResponse.SC_OK, responseType);
+                HttpUtils.writeHttpResponse(resp, response != null ? response : "", HttpServletResponse.SC_OK, responseType, ApiServer.getJSONContentType());
             } else {
                 if (session != null) {
                     try {
@@ -294,13 +302,13 @@ public class ApiServlet extends HttpServlet {
                 final String serializedResponse =
                     _apiServer.getSerializedApiError(HttpServletResponse.SC_UNAUTHORIZED, "unable to verify user credentials and/or request signature", params,
                         responseType);
-                HttpUtils.writeHttpResponse(resp, serializedResponse, HttpServletResponse.SC_UNAUTHORIZED, responseType);
+                HttpUtils.writeHttpResponse(resp, serializedResponse, HttpServletResponse.SC_UNAUTHORIZED, responseType, ApiServer.getJSONContentType());
 
             }
         } catch (final ServerApiException se) {
             final String serializedResponseText = _apiServer.getSerializedApiError(se, params, responseType);
             resp.setHeader("X-Description", se.getDescription());
-            HttpUtils.writeHttpResponse(resp, serializedResponseText, se.getErrorCode().getHttpCode(), responseType);
+            HttpUtils.writeHttpResponse(resp, serializedResponseText, se.getErrorCode().getHttpCode(), responseType, ApiServer.getJSONContentType());
             auditTrailSb.append(" " + se.getErrorCode() + " " + se.getDescription());
         } catch (final Exception ex) {
             s_logger.error("unknown exception writing api response", ex);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20bcb4b6/server/src/com/cloud/configuration/Config.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java
index dd9bfc0..982958e 100644
--- a/server/src/com/cloud/configuration/Config.java
+++ b/server/src/com/cloud/configuration/Config.java
@@ -1592,13 +1592,22 @@ public enum Config {
             "Percentage (as a value between 0 and 1) of connected agents after which agent load balancing will start happening",
             null),
 
-    JavaScriptDefaultContentType(
+    JSONDefaultContentType(
             "Advanced",
             ManagementServer.class,
             String.class,
             "json.content.type",
-            "text/javascript",
-            "Http response content type for .js files (default is text/javascript)",
+            "application/json; charset=UTF-8",
+            "Http response content type for JSON",
+            null),
+
+    EnableSecureSessionCookie(
+            "Advanced",
+            ManagementServer.class,
+            Boolean.class,
+            "enable.secure.session.cookie",
+            "false",
+            "Session cookie's secure flag is enabled if true. Use this only when using HTTPS",
             null),
 
     DefaultMaxDomainUserVms("Domain Defaults", ManagementServer.class, Long.class, "max.domain.user.vms", "40", "The default maximum number of user VMs that can be deployed for a domain", null),

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20bcb4b6/utils/src/com/cloud/utils/HttpUtils.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/HttpUtils.java b/utils/src/com/cloud/utils/HttpUtils.java
index 0ed2afa..58768dc 100644
--- a/utils/src/com/cloud/utils/HttpUtils.java
+++ b/utils/src/com/cloud/utils/HttpUtils.java
@@ -31,20 +31,40 @@ public class HttpUtils {
     public static final String UTF_8 = "UTF-8";
     public static final String RESPONSE_TYPE_JSON = "json";
     public static final String RESPONSE_TYPE_XML = "xml";
-    public static final String JSON_CONTENT_TYPE = "text/javascript; charset=UTF-8";
+    public static final String JSON_CONTENT_TYPE = "application/json; charset=UTF-8";
     public static final String XML_CONTENT_TYPE = "text/xml; charset=UTF-8";
 
+    public static void addSecurityHeaders(final HttpServletResponse resp) {
+        if (resp.containsHeader("X-Content-Type-Options")) {
+            resp.setHeader("X-Content-Type-Options", "nosniff");
+        }
+        else {
+            resp.addHeader("X-Content-Type-Options", "nosniff");
+        }
+        if (resp.containsHeader("X-XSS-Protection")) {
+            resp.setHeader("X-XSS-Protection", "1;mode=block");
+        }
+        else {
+            resp.addHeader("X-XSS-Protection", "1;mode=block");
+        }
+    }
+
     public static void writeHttpResponse(final HttpServletResponse resp, final String response,
-                                         final Integer responseCode, final String responseType) {
+                                         final Integer responseCode, final String responseType, final String jsonContentType) {
         try {
             if (RESPONSE_TYPE_JSON.equalsIgnoreCase(responseType)) {
-                resp.setContentType(JSON_CONTENT_TYPE);
+                if (jsonContentType != null && !jsonContentType.isEmpty()) {
+                    resp.setContentType(jsonContentType);
+                } else {
+                    resp.setContentType(JSON_CONTENT_TYPE);
+                }
             } else if (RESPONSE_TYPE_XML.equalsIgnoreCase(responseType)){
                 resp.setContentType(XML_CONTENT_TYPE);
             }
             if (responseCode != null) {
                 resp.setStatus(responseCode);
             }
+            addSecurityHeaders(resp);
             resp.getWriter().print(response);
         } catch (final IOException ioex) {
             if (s_logger.isTraceEnabled()) {


[15/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
CLOUDSTACK-8273: refactor baremetal user name to utils, restrict baremetal user

Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
(cherry picked from commit cb08707addbffa12abc50aec9ad980059f23910c)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>

Conflicts:
	server/src/com/cloud/user/AccountManagerImpl.java


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

Branch: refs/heads/reporter
Commit: 6df2fe7a8ad70a10b4584391d1c56fc03ff0f85b
Parents: f393199
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Thu Feb 26 17:42:21 2015 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Thu Feb 26 17:47:01 2015 +0530

----------------------------------------------------------------------
 .../baremetal/manager/BaremetalVlanManager.java |  4 -
 .../manager/BaremetalVlanManagerImpl.java       | 11 +--
 .../src/com/cloud/user/AccountManagerImpl.java  | 93 ++++++++++----------
 .../utils/baremetal/BaremetalUtils.java         | 24 +++++
 4 files changed, 77 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6df2fe7a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManager.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManager.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManager.java
index 76f1052..b6311f7 100644
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManager.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManager.java
@@ -27,11 +27,7 @@ import com.cloud.vm.VirtualMachineProfile;
 import org.apache.cloudstack.api.AddBaremetalRctCmd;
 import org.apache.cloudstack.api.DeleteBaremetalRctCmd;
 
-/**
- * Created by frank on 4/30/14.
- */
 public interface BaremetalVlanManager extends Manager, PluggableService {
-    public static final String BAREMETAL_SYSTEM_ACCOUNT_NAME = "baremetal-system-account";
 
     BaremetalRctResponse addRct(AddBaremetalRctCmd cmd);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6df2fe7a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManagerImpl.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManagerImpl.java
index a77cf35..3169597 100644
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManagerImpl.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManagerImpl.java
@@ -43,6 +43,7 @@ import org.apache.cloudstack.api.AddBaremetalRctCmd;
 import org.apache.cloudstack.api.DeleteBaremetalRctCmd;
 import org.apache.cloudstack.api.ListBaremetalRctCmd;
 import org.apache.cloudstack.api.command.admin.user.RegisterCmd;
+import org.apache.cloudstack.utils.baremetal.BaremetalUtils;
 import org.springframework.web.client.RestTemplate;
 
 import javax.inject.Inject;
@@ -235,14 +236,14 @@ public class BaremetalVlanManagerImpl extends ManagerBase implements BaremetalVl
     @Override
     public boolean start() {
         QueryBuilder<AccountVO> acntq = QueryBuilder.create(AccountVO.class);
-        acntq.and(acntq.entity().getAccountName(), SearchCriteria.Op.EQ, BaremetalVlanManager.BAREMETAL_SYSTEM_ACCOUNT_NAME);
+        acntq.and(acntq.entity().getAccountName(), SearchCriteria.Op.EQ, BaremetalUtils.BAREMETAL_SYSTEM_ACCOUNT_NAME);
         AccountVO acnt = acntq.find();
         if (acnt != null) {
             return true;
         }
 
         acnt = new AccountVO();
-        acnt.setAccountName(BAREMETAL_SYSTEM_ACCOUNT_NAME);
+        acnt.setAccountName(BaremetalUtils.BAREMETAL_SYSTEM_ACCOUNT_NAME);
         acnt.setUuid(UUID.randomUUID().toString());
         acnt.setState(Account.State.enabled);
         acnt.setDomainId(1);
@@ -252,9 +253,9 @@ public class BaremetalVlanManagerImpl extends ManagerBase implements BaremetalVl
         user.setState(Account.State.enabled);
         user.setUuid(UUID.randomUUID().toString());
         user.setAccountId(acnt.getAccountId());
-        user.setUsername(BAREMETAL_SYSTEM_ACCOUNT_NAME);
-        user.setFirstname(BAREMETAL_SYSTEM_ACCOUNT_NAME);
-        user.setLastname(BAREMETAL_SYSTEM_ACCOUNT_NAME);
+        user.setUsername(BaremetalUtils.BAREMETAL_SYSTEM_ACCOUNT_NAME);
+        user.setFirstname(BaremetalUtils.BAREMETAL_SYSTEM_ACCOUNT_NAME);
+        user.setLastname(BaremetalUtils.BAREMETAL_SYSTEM_ACCOUNT_NAME);
         user.setPassword(UUID.randomUUID().toString());
         user = userDao.persist(user);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6df2fe7a/server/src/com/cloud/user/AccountManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/user/AccountManagerImpl.java b/server/src/com/cloud/user/AccountManagerImpl.java
index 28115a2..bced7b3 100644
--- a/server/src/com/cloud/user/AccountManagerImpl.java
+++ b/server/src/com/cloud/user/AccountManagerImpl.java
@@ -16,52 +16,6 @@
 // under the License.
 package com.cloud.user;
 
-import java.net.URLEncoder;
-import java.net.InetAddress;
-import java.security.NoSuchAlgorithmException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-import javax.crypto.KeyGenerator;
-import javax.crypto.Mac;
-import javax.crypto.SecretKey;
-import javax.crypto.spec.SecretKeySpec;
-import javax.ejb.Local;
-import javax.inject.Inject;
-import javax.naming.ConfigurationException;
-
-import org.apache.commons.codec.binary.Base64;
-import org.apache.commons.lang.StringUtils;
-import org.apache.log4j.Logger;
-
-import org.apache.cloudstack.acl.ControlledEntity;
-import org.apache.cloudstack.acl.QuerySelector;
-import org.apache.cloudstack.acl.RoleType;
-import org.apache.cloudstack.acl.SecurityChecker;
-import org.apache.cloudstack.acl.SecurityChecker.AccessType;
-import org.apache.cloudstack.affinity.AffinityGroup;
-import org.apache.cloudstack.affinity.dao.AffinityGroupDao;
-import org.apache.cloudstack.api.command.admin.account.UpdateAccountCmd;
-import org.apache.cloudstack.api.command.admin.user.DeleteUserCmd;
-import org.apache.cloudstack.api.command.admin.user.RegisterCmd;
-import org.apache.cloudstack.api.command.admin.user.UpdateUserCmd;
-import org.apache.cloudstack.context.CallContext;
-import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
-import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
-import org.apache.cloudstack.framework.messagebus.MessageBus;
-import org.apache.cloudstack.framework.messagebus.PublishScope;
-import org.apache.cloudstack.managed.context.ManagedContextRunnable;
-import org.apache.cloudstack.region.gslb.GlobalLoadBalancerRuleDao;
-
 import com.cloud.api.ApiDBUtils;
 import com.cloud.api.query.vo.ControlledViewEntity;
 import com.cloud.configuration.Config;
@@ -163,6 +117,49 @@ import com.cloud.vm.VirtualMachineManager;
 import com.cloud.vm.dao.InstanceGroupDao;
 import com.cloud.vm.dao.UserVmDao;
 import com.cloud.vm.dao.VMInstanceDao;
+import org.apache.cloudstack.acl.ControlledEntity;
+import org.apache.cloudstack.acl.QuerySelector;
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.acl.SecurityChecker;
+import org.apache.cloudstack.acl.SecurityChecker.AccessType;
+import org.apache.cloudstack.affinity.AffinityGroup;
+import org.apache.cloudstack.affinity.dao.AffinityGroupDao;
+import org.apache.cloudstack.api.command.admin.account.UpdateAccountCmd;
+import org.apache.cloudstack.api.command.admin.user.DeleteUserCmd;
+import org.apache.cloudstack.api.command.admin.user.RegisterCmd;
+import org.apache.cloudstack.api.command.admin.user.UpdateUserCmd;
+import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
+import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
+import org.apache.cloudstack.framework.messagebus.MessageBus;
+import org.apache.cloudstack.framework.messagebus.PublishScope;
+import org.apache.cloudstack.managed.context.ManagedContextRunnable;
+import org.apache.cloudstack.region.gslb.GlobalLoadBalancerRuleDao;
+import org.apache.cloudstack.utils.baremetal.BaremetalUtils;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+
+import javax.crypto.KeyGenerator;
+import javax.crypto.Mac;
+import javax.crypto.SecretKey;
+import javax.crypto.spec.SecretKeySpec;
+import javax.ejb.Local;
+import javax.inject.Inject;
+import javax.naming.ConfigurationException;
+import java.net.URLEncoder;
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
 
 @Local(value = {AccountManager.class, AccountService.class})
 public class AccountManagerImpl extends ManagerBase implements AccountManager, Manager {
@@ -2194,6 +2191,10 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
         if (user.getId() == User.UID_SYSTEM) {
             throw new PermissionDeniedException("user id : " + user.getId() + " is system account, update is not allowed");
         }
+        // don't allow baremetal system user
+        if (BaremetalUtils.BAREMETAL_SYSTEM_ACCOUNT_NAME.equals(user.getUsername())) {
+            throw new PermissionDeniedException("user id : " + user.getId() + " is system account, update is not allowed");
+        }
 
         // generate both an api key and a secret key, update the user table with the keys, return the keys to the user
         final String[] keys = new String[2];

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6df2fe7a/utils/src/org/apache/cloudstack/utils/baremetal/BaremetalUtils.java
----------------------------------------------------------------------
diff --git a/utils/src/org/apache/cloudstack/utils/baremetal/BaremetalUtils.java b/utils/src/org/apache/cloudstack/utils/baremetal/BaremetalUtils.java
new file mode 100644
index 0000000..85704a5
--- /dev/null
+++ b/utils/src/org/apache/cloudstack/utils/baremetal/BaremetalUtils.java
@@ -0,0 +1,24 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+
+package org.apache.cloudstack.utils.baremetal;
+
+public class BaremetalUtils {
+    public static final String BAREMETAL_SYSTEM_ACCOUNT_NAME = "baremetal-system-account";
+}


[17/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
CLOUDSTACK-7089: don't log VNC password

Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
(cherry picked from commit e287de9fd90a06ee7f86d31ba69a84481f0820f1)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/reporter
Commit: d8e1bf15062bb2d4bbd4dd3ae1d32697ce1053b5
Parents: 4dde410
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Thu Feb 26 18:10:23 2015 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Thu Feb 26 18:11:12 2015 +0530

----------------------------------------------------------------------
 server/src/com/cloud/consoleproxy/AgentHookBase.java  | 2 +-
 server/src/com/cloud/servlet/ConsoleProxyServlet.java | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d8e1bf15/server/src/com/cloud/consoleproxy/AgentHookBase.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/consoleproxy/AgentHookBase.java b/server/src/com/cloud/consoleproxy/AgentHookBase.java
index 8a5bae5..b61ba13 100644
--- a/server/src/com/cloud/consoleproxy/AgentHookBase.java
+++ b/server/src/com/cloud/consoleproxy/AgentHookBase.java
@@ -146,7 +146,7 @@ public abstract class AgentHookBase implements AgentHook {
 
         String sid = cmd.getSid();
         if (sid == null || !sid.equals(vm.getVncPassword())) {
-            s_logger.warn("sid " + sid + " in url does not match stored sid " + vm.getVncPassword());
+            s_logger.warn("sid " + sid + " in url does not match stored sid.");
             return new ConsoleAccessAuthenticationAnswer(cmd, false);
         }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d8e1bf15/server/src/com/cloud/servlet/ConsoleProxyServlet.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/servlet/ConsoleProxyServlet.java b/server/src/com/cloud/servlet/ConsoleProxyServlet.java
index d08bcdb..3389d92 100644
--- a/server/src/com/cloud/servlet/ConsoleProxyServlet.java
+++ b/server/src/com/cloud/servlet/ConsoleProxyServlet.java
@@ -317,7 +317,7 @@ public class ConsoleProxyServlet extends HttpServlet {
 
         String sid = req.getParameter("sid");
         if (sid == null || !sid.equals(vm.getVncPassword())) {
-            s_logger.warn("sid " + sid + " in url does not match stored sid " + vm.getVncPassword());
+            s_logger.warn("sid " + sid + " in url does not match stored sid.");
             sendResponse(resp, "failed");
             return;
         }


[47/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
CLOUDSTACK-8298: Update copying large size VR config file in xenserver

 When there is large size VR configuration (aggregate commands) copying data to VR using vmops plugin was failed
 because of the ARG_MAX size limitation. The configuration data size is around 300KB.

 Updated this to create file in host by scp with file contents. This will create file in host.
 Then copy the file from the host to VR using hte vmops createFileInDomr method.

  In host file get created in /tmp/ with name VR-<UUID>.cfg, once it copied to VR this file will be removed.


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

Branch: refs/heads/reporter
Commit: 619f0142555d2245e3fa90036f825525191b31bd
Parents: 1f72548
Author: Jayapal <ja...@apache.org>
Authored: Mon Feb 23 13:51:20 2015 +0530
Committer: Jayapal <ja...@apache.org>
Committed: Wed Mar 4 11:52:10 2015 +0530

----------------------------------------------------------------------
 .../xenserver/resource/CitrixResourceBase.java  | 14 ++++++++++---
 scripts/vm/hypervisor/xenserver/vmops           | 21 +++++++++-----------
 2 files changed, 20 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/619f0142/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
index 6d777e4..a4aa4b6 100644
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
@@ -571,9 +571,17 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
     @Override
     public ExecutionResult createFileInVR(String routerIp, String path, String filename, String content) {
         Connection conn = getConnection();
-        String rc = callHostPlugin(conn, "vmops", "createFileInDomr", "domrip", routerIp, "filepath", path + filename, "filecontents", content);
-        s_logger.debug ("VR Config file " + filename + " got created in VR with ip " + routerIp + " with content \n" + content);
-        // Fail case would be start with "fail#"
+        String hostPath = "/tmp/";
+
+        s_logger.debug("Copying VR with ip " + routerIp +" config file into host "+ _host.ip );
+        try {
+            SshHelper.scpTo(_host.ip, 22, _username, null, _password.peek(), hostPath, content.getBytes(), filename, null);
+        } catch (Exception e) {
+            s_logger.warn("scp VR config file into host " + _host.ip + " failed with exception " + e.getMessage().toString());
+        }
+
+        String rc = callHostPlugin(conn, "vmops", "createFileInDomr", "domrip", routerIp, "srcfilepath", hostPath + filename, "dstfilepath", path);
+        s_logger.debug ("VR Config file " + filename + " got created in VR, ip " + routerIp + " with content \n" + content);
         return new ExecutionResult(rc.startsWith("succ#"), rc.substring(5));
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/619f0142/scripts/vm/hypervisor/xenserver/vmops
----------------------------------------------------------------------
diff --git a/scripts/vm/hypervisor/xenserver/vmops b/scripts/vm/hypervisor/xenserver/vmops
index 62a60bb..a73084a 100755
--- a/scripts/vm/hypervisor/xenserver/vmops
+++ b/scripts/vm/hypervisor/xenserver/vmops
@@ -204,20 +204,17 @@ def createFile(session, args):
 
 @echo
 def createFileInDomr(session, args):
-    file_path = args['filepath']
-    file_contents = args['filecontents']
+    src_filepath = args['srcfilepath']
+    dst_path = args['dstfilepath']
     domrip = args['domrip']
+    txt=""
     try:
-        tmpfile = util.pread2(['mktemp']).strip()
-        f = open(tmpfile, "w")
-        f.write(file_contents)
-        f.close()
-        target = "root@" + domrip + ":" + file_path
-        txt = util.pread2(['scp','-P','3922','-q','-o','StrictHostKeyChecking=no','-i','/root/.ssh/id_rsa.cloud',tmpfile, target])
-        util.pread2(['rm',tmpfile])
+        target = "root@" + domrip + ":" + dst_path
+        txt = util.pread2(['scp','-P','3922','-q','-o','StrictHostKeyChecking=no','-i','/root/.ssh/id_rsa.cloud',src_filepath, target])
+        util.pread2(['rm',src_filepath])
         txt = 'succ#' + txt
     except:
-        logging.debug("failed to create file " + file_path + " in VR, contain: " + file_contents)
+        logging.debug("failed to copy file " + src_filepath + " from host to VR with ip " + domrip)
         txt = 'fail#' + txt
     return txt
 
@@ -1486,8 +1483,8 @@ if __name__ == "__main__":
                             "destroy_network_rules_for_vm":destroy_network_rules_for_vm, 
                             "default_network_rules_systemvm":default_network_rules_systemvm, 
                             "network_rules_vmSecondaryIp":network_rules_vmSecondaryIp,
-                            "get_rule_logs_for_vms":get_rule_logs_for_vms, 
-			    "add_to_VCPUs_params_live":add_to_VCPUs_params_live,
+                            "get_rule_logs_for_vms":get_rule_logs_for_vms,
+                            "add_to_VCPUs_params_live":add_to_VCPUs_params_live,
                             "setLinkLocalIP":setLinkLocalIP,
                             "cleanup_rules":cleanup_rules,
                             "createFileInDomr":createFileInDomr,


[20/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
Support all pythons from 2.6 up.


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

Branch: refs/heads/reporter
Commit: d5e3d4911dbb2d7620cf3d30ae780336ab7c9496
Parents: d8e1bf1
Author: Pierre-Yves Ritschard <py...@spootnik.org>
Authored: Fri Feb 27 09:26:13 2015 +0100
Committer: Pierre-Yves Ritschard <py...@spootnik.org>
Committed: Fri Feb 27 09:27:52 2015 +0100

----------------------------------------------------------------------
 tools/apidoc/gen_toc.py | 54 +++++++++++++++++++++++---------------------
 1 file changed, 28 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d5e3d491/tools/apidoc/gen_toc.py
----------------------------------------------------------------------
diff --git a/tools/apidoc/gen_toc.py b/tools/apidoc/gen_toc.py
index 95f06c8..3d48bc5 100644
--- a/tools/apidoc/gen_toc.py
+++ b/tools/apidoc/gen_toc.py
@@ -6,9 +6,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
@@ -131,7 +131,7 @@ known_categories = {
     'Project': 'Project',
     'Lun': 'Storage',
     'Pool': 'Pool',
-    'VPC': 'VPC', 
+    'VPC': 'VPC',
     'PrivateGateway': 'VPC',
     'Simulator': 'simulator',
     'StaticRoute': 'VPC',
@@ -177,7 +177,7 @@ categories = {}
 
 
 def choose_category(fn):
-    for k, v in known_categories.iteritems():
+    for k, v in known_categories.items():
         if k in fn:
             return v
     raise Exception('Need to add a category for %s to %s:known_categories' %
@@ -198,7 +198,8 @@ for f in sys.argv:
     if dirname.startswith('./'):
         dirname = dirname[2:]
     try:
-        dom = minidom.parse(file(f))
+        with open(f) as data:
+            dom = minidom.parse(data)
         name = dom.getElementsByTagName('name')[0].firstChild.data
         isAsync = dom.getElementsByTagName('isAsync')[0].firstChild.data
         category = choose_category(fn)
@@ -210,11 +211,11 @@ for f in sys.argv:
             'async': isAsync == 'true',
             'user': dirname_to_user[dirname],
             })
-    except ExpatError, e:
+    except ExpatError as e:
         pass
-    except IndexError, e:
-        print fn
-    
+    except IndexError as e:
+        print(fn)
+
 
 def xml_for(command):
     name = command['name']
@@ -227,9 +228,9 @@ def xml_for(command):
 
 
 def write_xml(out, user):
-    with file(out, 'w') as f:
+    with open(out, 'w') as f:
         cat_strings = []
-        
+
         for category in categories.keys():
             strings = []
             for command in categories[category]:
@@ -244,24 +245,24 @@ def write_xml(out, user):
         i = 0
         for _1, category, all_strings in cat_strings:
             if i == 0:
-                print >>f, '<div class="apismallsections">'
-            print >>f, '''<div class="apismallbullet_box">
+                f.write('<div class="apismallsections">\n')
+            f.write('''<div class="apismallbullet_box">
 <h5>%(category)s</h5>
 <ul>
 <xsl:for-each select="commands/command">
 %(all_strings)s
 </xsl:for-each>
-</ul>      
+</ul>
 </div>
 
-''' % locals()
+''' % locals())
             if i == 3:
-                print >>f, '</div>'
+                f.write('</div>\n')
                 i = 0
             else:
                 i += 1
         if i != 0:
-            print >>f, '</div>'
+            f.write('</div>\n')
 
 
 def java_for(command, user):
@@ -277,7 +278,7 @@ def java_for_user(user):
         for command in categories[category]:
             if command['user'] == user:
                 strings.append(java_for(command, user))
-    func = user_to_func[user]        
+    func = user_to_func[user]
     all_strings = ''.join(strings)
     return '''
     public void %(func)s() {
@@ -287,8 +288,8 @@ def java_for_user(user):
 
 
 def write_java(out):
-    with file(out, 'w') as f:
-        print >>f, '''/* Generated using gen_toc.py.  Do not edit. */
+    with open(out, 'w') as f:
+        f.write('''/* Generated using gen_toc.py.  Do not edit. */
 
 import java.util.HashSet;
 import java.util.Set;
@@ -299,14 +300,15 @@ public class XmlToHtmlConverterData {
 	Set<String> domainAdminCommandNames = new HashSet<String>();
 	Set<String> userCommandNames = new HashSet<String>();
 
-'''
-        print >>f, java_for_user(REGULAR_USER)
-        print >>f, java_for_user(ROOT_ADMIN)
-        print >>f, java_for_user(DOMAIN_ADMIN)
+''')
+        f.write(java_for_user(REGULAR_USER) + "\n");
+        f.write(java_for_user(ROOT_ADMIN) + "\n")
+        f.write(java_for_user(DOMAIN_ADMIN) + "\n")
 
-        print >>f, '''
+        f.write('''
 }
-'''
+
+''')
 
 
 write_xml('generatetocforuser_include.xsl', REGULAR_USER)


[04/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
LibvirtComputingResource: Fix coverity scan, recent bugfixes revealed a potential unhandled null in getResizeScriptType

Change-Id: I5715a4424646261f2c43cd5e0a16fd72dd12c753


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

Branch: refs/heads/reporter
Commit: 77d11eb1a3f58c3c78cddfac600252f3c6af6862
Parents: 09e26c8
Author: Marcus Sorensen <ma...@apple.com>
Authored: Mon Feb 23 16:55:56 2015 -0800
Committer: Marcus Sorensen <ma...@apple.com>
Committed: Mon Feb 23 16:56:19 2015 -0800

----------------------------------------------------------------------
 .../hypervisor/kvm/resource/LibvirtComputingResource.java      | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/77d11eb1/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
index 48ad19d..341c4f8 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
@@ -1840,7 +1840,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
                 && volFormat == PhysicalDiskFormat.QCOW2 ) {
             return "QCOW2";
         }
-        return null;
+        throw new CloudRuntimeException("Cannot determine resize type from pool type " + pool.getType());
     }
 
     /* uses a local script now, eventually support for virStorageVolResize() will maybe work on
@@ -1867,9 +1867,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
             String type = getResizeScriptType(pool, vol);
 
             if (pool.getType() != StoragePoolType.RBD) {
-                if (type == null) {
-                    return new ResizeVolumeAnswer(cmd, false, "Unsupported volume format: pool type '" + pool.getType() + "' and volume format '" + vol.getFormat() + "'");
-                } else if (type.equals("QCOW2") && shrinkOk) {
+                if (type.equals("QCOW2") && shrinkOk) {
                     return new ResizeVolumeAnswer(cmd, false, "Unable to shrink volumes of type " + type);
                 }
             } else {


[45/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
LibvirtComputingResource: Support 'Oracle Linux 7' as pv guest

Change-Id: Ib3fd2fec7434564e937ac5b6b3cfee472a5fdc98


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

Branch: refs/heads/reporter
Commit: 57cd7f3db54700e29a2a1f2fec0a99b0ea829d7b
Parents: 736c7d7
Author: Marcus Sorensen <ma...@apple.com>
Authored: Tue Mar 3 10:44:12 2015 -0800
Committer: Marcus Sorensen <ma...@apple.com>
Committed: Tue Mar 3 10:44:12 2015 -0800

----------------------------------------------------------------------
 .../cloud/hypervisor/kvm/resource/LibvirtComputingResource.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/57cd7f3d/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
index 341c4f8..b6ac38c 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
@@ -4754,7 +4754,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
                 guestOSName.startsWith("CentOS 5.5") || guestOSName.startsWith("CentOS") || guestOSName.startsWith("Fedora") ||
                 guestOSName.startsWith("Red Hat Enterprise Linux 5.3") || guestOSName.startsWith("Red Hat Enterprise Linux 5.4") ||
                 guestOSName.startsWith("Red Hat Enterprise Linux 5.5") || guestOSName.startsWith("Red Hat Enterprise Linux 6") || guestOSName.startsWith("Debian GNU/Linux") ||
-                guestOSName.startsWith("FreeBSD 10") || guestOSName.startsWith("Oracle Enterprise Linux") || guestOSName.startsWith("Other PV")) {
+                guestOSName.startsWith("FreeBSD 10") || guestOSName.startsWith("Oracle") || guestOSName.startsWith("Other PV")) {
             return true;
         } else {
             return false;


[22/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
CLOUDSTACK-8273: fix baremetal account creation

Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
(cherry picked from commit e000646790597cb6c245311f57761b41d23a4e34)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>

Conflicts:
	plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManagerImpl.java


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

Branch: refs/heads/reporter
Commit: a75ff231315e045d441c25e6b368ad2e863cc004
Parents: 6f4db0c
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Fri Feb 27 15:52:25 2015 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Fri Feb 27 15:55:09 2015 +0530

----------------------------------------------------------------------
 api/src/com/cloud/user/AccountService.java      |  2 ++
 .../manager/BaremetalVlanManagerImpl.java       |  7 ++----
 .../contrail/management/MockAccountManager.java |  6 +++++
 .../src/com/cloud/user/AccountManagerImpl.java  | 23 ++++++++++++++++++++
 .../com/cloud/user/MockAccountManagerImpl.java  |  5 +++++
 5 files changed, 38 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a75ff231/api/src/com/cloud/user/AccountService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/user/AccountService.java b/api/src/com/cloud/user/AccountService.java
index 75f95ce..c483d05 100644
--- a/api/src/com/cloud/user/AccountService.java
+++ b/api/src/com/cloud/user/AccountService.java
@@ -105,6 +105,8 @@ public interface AccountService {
 
     public String[] createApiKeyAndSecretKey(RegisterCmd cmd);
 
+    public String[] createApiKeyAndSecretKey(final long userId);
+
     UserAccount getUserByApiKey(String apiKey);
 
     RoleType getRoleType(Account account);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a75ff231/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManagerImpl.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManagerImpl.java
index 3169597..d3ea3d2 100644
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManagerImpl.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManagerImpl.java
@@ -42,8 +42,7 @@ import com.google.gson.Gson;
 import org.apache.cloudstack.api.AddBaremetalRctCmd;
 import org.apache.cloudstack.api.DeleteBaremetalRctCmd;
 import org.apache.cloudstack.api.ListBaremetalRctCmd;
-import org.apache.cloudstack.api.command.admin.user.RegisterCmd;
-import org.apache.cloudstack.utils.baremetal.BaremetalUtils;
+import org.apache.cloudstack.utils.baremetal.BaremetalUtils;
 import org.springframework.web.client.RestTemplate;
 
 import javax.inject.Inject;
@@ -259,9 +258,7 @@ public class BaremetalVlanManagerImpl extends ManagerBase implements BaremetalVl
         user.setPassword(UUID.randomUUID().toString());
         user = userDao.persist(user);
 
-        RegisterCmd cmd = new RegisterCmd();
-        cmd.setId(user.getId());
-        String[] keys = acntMgr.createApiKeyAndSecretKey(cmd);
+        String[] keys = acntMgr.createApiKeyAndSecretKey(user.getId());
         user.setApiKey(keys[0]);
         user.setSecretKey(keys[1]);
         userDao.update(user.getId(), user);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a75ff231/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/MockAccountManager.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/MockAccountManager.java b/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/MockAccountManager.java
index daeb6bd..9bc11d6 100644
--- a/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/MockAccountManager.java
+++ b/plugins/network-elements/juniper-contrail/test/org/apache/cloudstack/network/contrail/management/MockAccountManager.java
@@ -116,6 +116,12 @@ public class MockAccountManager extends ManagerBase implements AccountManager {
     }
 
     @Override
+    public String[] createApiKeyAndSecretKey(final long userId) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
     public User createUser(String arg0, String arg1, String arg2, String arg3, String arg4, String arg5, String arg6, Long arg7, String arg8) {
         // TODO Auto-generated method stub
         return null;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a75ff231/server/src/com/cloud/user/AccountManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/user/AccountManagerImpl.java b/server/src/com/cloud/user/AccountManagerImpl.java
index 78a8733..29ea9aa 100644
--- a/server/src/com/cloud/user/AccountManagerImpl.java
+++ b/server/src/com/cloud/user/AccountManagerImpl.java
@@ -2079,6 +2079,11 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
                 s_logger.error("Failed to authenticate user: " + username + " in domain " + domainId);
                 return null;
             }
+            // don't allow baremetal system user
+            if (BaremetalUtils.BAREMETAL_SYSTEM_ACCOUNT_NAME.equals(user.getUsername())) {
+                s_logger.error("Won't authenticate user: " + username + " in domain " + domainId);
+                return null;
+            }
 
             if (s_logger.isDebugEnabled()) {
                 s_logger.debug("User: " + username + " in domain " + domainId + " has successfully logged in");
@@ -2210,6 +2215,24 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
         return keys;
     }
 
+    @Override
+    @DB
+    @ActionEvent(eventType = EventTypes.EVENT_REGISTER_FOR_SECRET_API_KEY, eventDescription = "register for the developer API keys")
+    public String[] createApiKeyAndSecretKey(final long userId) {
+        User user = getUserIncludingRemoved(userId);
+        if (user == null) {
+            throw new InvalidParameterValueException("Unable to find user by id");
+        }
+        final String[] keys = new String[2];
+        Transaction.execute(new TransactionCallbackNoReturn() {
+            public void doInTransactionWithoutResult(TransactionStatus status) {
+                keys[0] = AccountManagerImpl.this.createUserApiKey(userId);
+                keys[1] = AccountManagerImpl.this.createUserSecretKey(userId);
+            }
+        });
+        return keys;
+    }
+
     private String createUserApiKey(long userId) {
         try {
             UserVO updatedUser = _userDao.createForUpdate();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a75ff231/server/test/com/cloud/user/MockAccountManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/user/MockAccountManagerImpl.java b/server/test/com/cloud/user/MockAccountManagerImpl.java
index 35eb94a..26f8904 100644
--- a/server/test/com/cloud/user/MockAccountManagerImpl.java
+++ b/server/test/com/cloud/user/MockAccountManagerImpl.java
@@ -278,6 +278,11 @@ public class MockAccountManagerImpl extends ManagerBase implements Manager, Acco
     }
 
     @Override
+    public String[] createApiKeyAndSecretKey(final long userId) {
+        return null;
+    }
+
+    @Override
     public boolean enableAccount(long accountId) {
         // TODO Auto-generated method stub
         return false;


[42/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
Merge remote-tracking branch 'anshul/CLOUDSTACK-6900'

This closes #68

Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/reporter
Commit: ef99f01e59aafc98feb034fff08c7ead28e69e2b
Parents: 085554d 91e1881
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Mon Mar 2 16:40:33 2015 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Mon Mar 2 16:40:44 2015 +0530

----------------------------------------------------------------------
 .../image/db/VolumeDataStoreDaoImpl.java        | 24 +++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)
----------------------------------------------------------------------



[30/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
pbkdf2: fix encoding issue when converting byte[] to String

Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
(cherry picked from commit 814e5574dcabbbf52b878d9fd448be7a66118597)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/reporter
Commit: 694a6948600aec8584d02ab8dc00d6642b46e3c7
Parents: 3786aa0
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Sat Feb 28 00:42:27 2015 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Sat Feb 28 00:44:20 2015 +0530

----------------------------------------------------------------------
 .../apache/cloudstack/server/auth/PBKDF2UserAuthenticator.java   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/694a6948/plugins/user-authenticators/pbkdf2/src/org/apache/cloudstack/server/auth/PBKDF2UserAuthenticator.java
----------------------------------------------------------------------
diff --git a/plugins/user-authenticators/pbkdf2/src/org/apache/cloudstack/server/auth/PBKDF2UserAuthenticator.java b/plugins/user-authenticators/pbkdf2/src/org/apache/cloudstack/server/auth/PBKDF2UserAuthenticator.java
index 43c32c7..58f5ea2 100644
--- a/plugins/user-authenticators/pbkdf2/src/org/apache/cloudstack/server/auth/PBKDF2UserAuthenticator.java
+++ b/plugins/user-authenticators/pbkdf2/src/org/apache/cloudstack/server/auth/PBKDF2UserAuthenticator.java
@@ -133,8 +133,8 @@ public class PBKDF2UserAuthenticator extends DefaultUserAuthenticator {
         return !(plainPassword == null || plainPassword.isEmpty() || hash == null || hash.length == 0);
     }
 
-    private static String encode(byte[] input) {
-        return new String(Base64.encode(input));
+    private static String encode(byte[] input) throws UnsupportedEncodingException {
+        return new String(Base64.encode(input), "UTF-8");
     }
 
     private static byte[] decode(String input) throws UnsupportedEncodingException {


[06/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
CLOUDSTACK-8282: startSystemVM should override consoleproxy.start setting

Signed-off-by: Rohit Yadav <ro...@shapeblue.com>
(cherry picked from commit b462a56f27b21455b70415ea03663af5cd62647e)
Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/reporter
Commit: 4f9bc70b1f777daeff5aeebd54144db50545e907
Parents: 6caee85
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Wed Feb 25 14:21:11 2015 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Wed Feb 25 14:30:13 2015 +0530

----------------------------------------------------------------------
 .../cloud/consoleproxy/AgentBasedConsoleProxyManager.java    | 2 +-
 server/src/com/cloud/consoleproxy/ConsoleProxyManager.java   | 2 +-
 .../src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java  | 8 ++++----
 server/src/com/cloud/server/ManagementServerImpl.java        | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4f9bc70b/server/src/com/cloud/consoleproxy/AgentBasedConsoleProxyManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/consoleproxy/AgentBasedConsoleProxyManager.java b/server/src/com/cloud/consoleproxy/AgentBasedConsoleProxyManager.java
index 3a1c387..6824b9c 100644
--- a/server/src/com/cloud/consoleproxy/AgentBasedConsoleProxyManager.java
+++ b/server/src/com/cloud/consoleproxy/AgentBasedConsoleProxyManager.java
@@ -175,7 +175,7 @@ public class AgentBasedConsoleProxyManager extends ManagerBase implements Consol
     }
 
     @Override
-    public ConsoleProxyVO startProxy(long proxyVmId) {
+    public ConsoleProxyVO startProxy(long proxyVmId, boolean ignoreRestartSetting) {
         return null;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4f9bc70b/server/src/com/cloud/consoleproxy/ConsoleProxyManager.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/consoleproxy/ConsoleProxyManager.java b/server/src/com/cloud/consoleproxy/ConsoleProxyManager.java
index 9d22b7f..8496301 100644
--- a/server/src/com/cloud/consoleproxy/ConsoleProxyManager.java
+++ b/server/src/com/cloud/consoleproxy/ConsoleProxyManager.java
@@ -40,7 +40,7 @@ public interface ConsoleProxyManager extends Manager, ConsoleProxyService {
 
     public void resumeLastManagementState();
 
-    public ConsoleProxyVO startProxy(long proxyVmId);
+    public ConsoleProxyVO startProxy(long proxyVmId, boolean ignoreRestartSetting);
 
     public boolean stopProxy(long proxyVmId);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4f9bc70b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
index 0851a68..478aab1 100644
--- a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
+++ b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java
@@ -520,7 +520,7 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
     }
 
     @Override
-    public ConsoleProxyVO startProxy(long proxyVmId) {
+    public ConsoleProxyVO startProxy(long proxyVmId, boolean ignoreRestartSetting) {
         try {
             ConsoleProxyVO proxy = _consoleProxyDao.findById(proxyVmId);
             if (proxy.getState() == VirtualMachine.State.Running) {
@@ -528,7 +528,7 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
             }
 
             String restart = _configDao.getValue(Config.ConsoleProxyRestart.key());
-            if (restart != null && restart.equalsIgnoreCase("false")) {
+            if (!ignoreRestartSetting && restart != null && restart.equalsIgnoreCase("false")) {
                 return null;
             }
 
@@ -912,7 +912,7 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
 
             if (proxy != null) {
                 long proxyVmId = proxy.getId();
-                proxy = startProxy(proxyVmId);
+                proxy = startProxy(proxyVmId, false);
 
                 if (proxy != null) {
                     if (s_logger.isInfoEnabled()) {
@@ -1134,7 +1134,7 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
                 return false;
             }
         } else {
-            return startProxy(proxyVmId) != null;
+            return startProxy(proxyVmId, false) != null;
         }
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4f9bc70b/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java
index 9de7f1d..aa158b4 100644
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -2183,7 +2183,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
     }
 
     private ConsoleProxyVO startConsoleProxy(long instanceId) {
-        return _consoleProxyMgr.startProxy(instanceId);
+        return _consoleProxyMgr.startProxy(instanceId, true);
     }
 
     private ConsoleProxyVO stopConsoleProxy(VMInstanceVO systemVm, boolean isForced) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException {


[07/50] [abbrv] git commit: updated refs/heads/reporter to 178a938

Posted by wi...@apache.org.
Merge branch 'CLOUDSTACK-8210_2' of https://github.com/K0zka/cloudstack


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

Branch: refs/heads/reporter
Commit: 76010d8871f259cccf0344b35ddaa49ffe686662
Parents: 4f9bc70 a9912a0
Author: Daan Hoogland <da...@onecht.net>
Authored: Wed Feb 25 10:22:28 2015 +0100
Committer: Daan Hoogland <da...@onecht.net>
Committed: Wed Feb 25 10:22:28 2015 +0100

----------------------------------------------------------------------
 packaging/fedora20/cloud-agent.rc             | 117 ++++
 packaging/fedora20/cloud-ipallocator.rc       |  96 +++
 packaging/fedora20/cloud-management.rc        | 115 ++++
 packaging/fedora20/cloud-management.sysconfig |  23 +
 packaging/fedora20/cloud-usage.rc             | 156 +++++
 packaging/fedora20/cloud.spec                 | 706 +++++++++++++++++++++
 packaging/fedora20/cloudstack-agent.te        |  33 +
 packaging/fedora20/cloudstack-sccs            |  20 +
 packaging/fedora20/replace.properties         |  60 ++
 packaging/fedora20/tomcat.sh                  |  18 +
 packaging/fedora21/cloud-agent.rc             | 117 ++++
 packaging/fedora21/cloud-ipallocator.rc       |  96 +++
 packaging/fedora21/cloud-management.rc        | 115 ++++
 packaging/fedora21/cloud-management.sysconfig |  23 +
 packaging/fedora21/cloud-usage.rc             | 156 +++++
 packaging/fedora21/cloud.spec                 | 706 +++++++++++++++++++++
 packaging/fedora21/cloudstack-agent.te        |  33 +
 packaging/fedora21/cloudstack-sccs            |  20 +
 packaging/fedora21/replace.properties         |  60 ++
 packaging/fedora21/tomcat.sh                  |  18 +
 packaging/package.sh                          |   2 +-
 21 files changed, 2689 insertions(+), 1 deletion(-)
----------------------------------------------------------------------