From 2327831f7f2177894397dfc7265ffb4d8b77872a Mon Sep 17 00:00:00 2001 From: Radhika PC Date: Mon, 18 Feb 2013 15:07:05 +0530 Subject: [PATCH 01/14] cloudstack-991 Signed-off-by: Radhika PC --- docs/en-US/console-proxy.xml | 6 +-- docs/en-US/working-with-system-vm.xml | 56 +++++++++++++++------------ 2 files changed, 34 insertions(+), 28 deletions(-) diff --git a/docs/en-US/console-proxy.xml b/docs/en-US/console-proxy.xml index 3dd7b9fd692..697ee2e2146 100644 --- a/docs/en-US/console-proxy.xml +++ b/docs/en-US/console-proxy.xml @@ -24,11 +24,11 @@ console view via the web UI. It connects the user’s browser to the VNC port made available via the hypervisor for the console of the guest. Both the administrator and end user web UIs offer a console connection. - Clicking on a console icon brings up a new window. The AJAX code downloaded into that window + Clicking a console icon brings up a new window. The AJAX code downloaded into that window refers to the public IP address of a console proxy VM. There is exactly one public IP address allocated per console proxy VM. The AJAX application connects to this IP. The console proxy then - proxies the connection to the VNC port for the requested VM on the Host hosting the guest. - . + proxies the connection to the VNC port for the requested VM on the Host hosting the + guest. The hypervisors will have many ports assigned to VNC usage so that multiple VNC sessions can occur simultaneously. diff --git a/docs/en-US/working-with-system-vm.xml b/docs/en-US/working-with-system-vm.xml index 97459f947bf..70f7dd1aa4e 100644 --- a/docs/en-US/working-with-system-vm.xml +++ b/docs/en-US/working-with-system-vm.xml @@ -1,33 +1,39 @@ - %BOOK_ENTITIES; ]> - - - Working with System Virtual Machines - &PRODUCT; uses several types of system virtual machines to perform tasks in the cloud. In general &PRODUCT; manages these system VMs and creates, starts, and stops them as needed based on scale and immediate needs. However, the administrator should be aware of them and their roles to assist in debugging issues. - - - - - + Working with System Virtual Machines + &PRODUCT; uses several types of system virtual machines to perform tasks in the cloud. In + general &PRODUCT; manages these system VMs and creates, starts, and stops them as needed based + on scale and immediate needs. However, the administrator should be aware of them and their roles + to assist in debugging issues. + + You can configure the system.vm.random.password parameter to create a random system VM + password to ensure higher security. If you reset the value for system.vm.random.password to + true and restart the Management Server, a random password is generated and stored encrypted in + the database. You can view the decrypted password under the system.vm.password global + parameter on the &PRODUCT; UI or by calling the listConfigurations API. + + + + + + From ab63a433ecbf60e18ad6cbcb0353c61fa432bcdc Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Mon, 18 Feb 2013 18:37:34 +0530 Subject: [PATCH 02/14] systemvmtemplate: Fix definitions and partition map - Fix definitions, create vhd (virtual disk) format (reusable for hyperv) - Fix partition maps in preseed, create /boot, /home, /var, /usr, /opt etc. Signed-off-by: Rohit Yadav --- .../systemvmtemplate/definition.rb | 2 +- .../definitions/systemvmtemplate/preseed.cfg | 64 +++++++++++++++---- 2 files changed, 54 insertions(+), 12 deletions(-) diff --git a/tools/appliance/definitions/systemvmtemplate/definition.rb b/tools/appliance/definitions/systemvmtemplate/definition.rb index a839182bbd9..8fd85306018 100644 --- a/tools/appliance/definitions/systemvmtemplate/definition.rb +++ b/tools/appliance/definitions/systemvmtemplate/definition.rb @@ -1,7 +1,7 @@ Veewee::Definition.declare({ :cpu_count => '1', :memory_size=> '256', - :disk_size => '2048', :disk_format => 'VMDK', :hostiocache => 'off', + :disk_size => '2048', :disk_format => 'VHD', :hostiocache => 'off', :os_type_id => 'Debian', :iso_file => "debian-wheezy-DI-b4-i386-netinst.iso", :iso_src => "http://cdimage.debian.org/cdimage/wheezy_di_beta4/i386/iso-cd/debian-wheezy-DI-b4-i386-netinst.iso", diff --git a/tools/appliance/definitions/systemvmtemplate/preseed.cfg b/tools/appliance/definitions/systemvmtemplate/preseed.cfg index 204d573a9d0..b4d28955473 100644 --- a/tools/appliance/definitions/systemvmtemplate/preseed.cfg +++ b/tools/appliance/definitions/systemvmtemplate/preseed.cfg @@ -99,29 +99,28 @@ d-i clock-setup/ntp boolean true d-i partman-auto/disk string /dev/sda # In addition, you'll need to specify the method to use. # The presently available methods are: "regular", "lvm" and "crypto" -d-i partman-auto/method string lvm +d-i partman-auto/method string regular # If one of the disks that are going to be automatically partitioned # contains an old LVM configuration, the user will normally receive a # warning. This can be preseeded away... -d-i partman-lvm/device_remove_lvm boolean true +#d-i partman-lvm/device_remove_lvm boolean true # The same applies to pre-existing software RAID array: -d-i partman-md/device_remove_md boolean true +#d-i partman-md/device_remove_md boolean true # And the same goes for the confirmation to write the lvm partitions. -d-i partman-lvm/confirm boolean true -d-i partman-lvm/confirm_nooverwrite boolean true +#d-i partman-lvm/confirm boolean true +#d-i partman-lvm/confirm_nooverwrite boolean true - -d-i partman/choose_partition select finish -d-i partman-auto-lvm/guided_size string max +#d-i partman/choose_partition select finish +#d-i partman-auto-lvm/guided_size string max # You can choose one of the three predefined partitioning recipes: # - atomic: all files in one partition # - home: separate /home partition # - multi: separate /home, /usr, /var, and /tmp partitions -d-i partman-auto/choose_recipe select multi -d-i partman/default_filesystem string ext3 +d-i partman-auto/choose_recipe select atomic +#d-i partman/default_filesystem string ext3 # Or provide a recipe of your own... # The recipe format is documented in the file devel/partman-auto-recipe.txt. @@ -129,6 +128,48 @@ d-i partman/default_filesystem string ext3 # just point at it. #d-i partman-auto/expert_recipe_file string /hd-media/recipe +d-i partman-auto/expert_recipe string \ + boot-root :: \ + 40 50 100 ext4 \ + $primary{ } $bootable{ } \ + method{ format } format{ } \ + use_filesystem{ } filesystem{ ext4 } \ + mountpoint{ /boot } \ + . \ + 400 40 500 ext4 \ + method{ format } format{ } \ + use_filesystem{ } filesystem{ ext4 } \ + mountpoint{ / } \ + . \ + 60 100 200 ext4 \ + method{ format } format{ } \ + use_filesystem{ } filesystem{ ext4 } \ + mountpoint{ /home } \ + . \ + 500 30 1000 ext4 \ + method{ format } format{ } \ + use_filesystem{ } filesystem{ ext4 } \ + mountpoint{ /usr } \ + . \ + 400 40 500 ext4 \ + method{ format } format{ } \ + use_filesystem{ } filesystem{ ext4 } \ + mountpoint{ /opt } \ + . \ + 500 60 1000 ext4 \ + method{ format } format{ } \ + use_filesystem{ } filesystem{ ext4 } \ + mountpoint{ /var } \ + . \ + 100 70 400 ext4 \ + method{ format } format{ } \ + use_filesystem{ } filesystem{ ext4 } \ + mountpoint{ /tmp } \ + . \ + 64 512 300% linux-swap \ + method{ swap } format{ } \ + . + # If not, you can put an entire recipe into the preconfiguration file in one # (logical) line. This example creates a small /boot partition, suitable # swap, and uses the rest of the space for the root partition: @@ -154,11 +195,12 @@ d-i partman/default_filesystem string ext3 # This makes partman automatically partition without confirmation, provided # that you told it what to do using one of the methods above. +#d-i partman-partitioning/confirm_write_new_label boolean true d-i partman/confirm_write_new_label boolean true +d-i partman/choose_partition select finish d-i partman/confirm boolean true d-i partman/confirm_nooverwrite boolean true - ### Base system installation # Select the initramfs generator used to generate the initrd for 2.6 kernels. #d-i base-installer/kernel/linux/initramfs-generators string yaird From a4ed061dbfa5daec0208e2c3a84273c1e3f84a52 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Mon, 18 Feb 2013 18:51:17 +0530 Subject: [PATCH 03/14] systemvmtemplate: Fix build.sh to export ova, vhd, qcow2 and vhd-hyperv Signed-off-by: Rohit Yadav --- tools/appliance/build.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tools/appliance/build.sh b/tools/appliance/build.sh index cfd4e8b2349..ef3e384b597 100644 --- a/tools/appliance/build.sh +++ b/tools/appliance/build.sh @@ -18,6 +18,9 @@ set -x appliance="systemvmtemplate" +build_date=`date +%Y-%m-%d` +branch="master" +rootdir=$PWD # Initialize veewee and dependencies bundle @@ -25,3 +28,34 @@ bundle # Start building the appliance veewee vbox build $appliance --nogui veewee vbox halt $appliance + +# Get appliance uuids +machine_uuid=`vboxmanage showvminfo $appliance | grep UUID | head -1 | awk '{print $2}'` +hdd_uuid=`vboxmanage showvminfo $appliance | grep vhd | head -1 | awk '{print $8}' | cut -d ')' -f 1` + +# Start exporting +rm -fr dist +mkdir dist +cd dist + +# Export for VMWare vSphere +vboxmanage export $machine_uuid --output $appliance-$build_date-$branch-vmware.ova + +# Export for HyperV +vboxmanage clonehd $hdd_uuid $appliance-$build_date-$branch-hyperv.vhd --format VHD +bzip2 $appliance-$build_date-$branch-hyperv.vhd +rm $appliance-$build_date-$branch-hyperv.vhd + +# Export for KVM +vboxmanage clonehd $hdd_uuid raw.img --format RAW +qemu-img convert -f raw -O qcow2 raw.img $appliance-$build_date-$branch-kvm.qcow2 +bzip2 $appliance-$build_date-$branch-kvm.qcow2 +rm $appliance-$build_date-$branch-kvm.qcow2 + +# Export for Xen +# This will be an overwrite convert so, do it at the end +vhd-util convert -s 0 -t 1 -i raw.img -o $appliance-$build_date-$branch-xen.vhd +bzip2 $appliance-$build_date-$branch-hyperv.vhd +rm $appliance-$build_date-$branch-hyperv.vhd + +cd $rootdir From cc2a3c5498f18cc99ac2dc23554d440138aabb7a Mon Sep 17 00:00:00 2001 From: Kishan Kavala Date: Mon, 18 Feb 2013 20:29:19 +0530 Subject: [PATCH 04/14] CLOUDSTACK-651: Removed 7 nics limitation for VR on XenServer # of nics can be configured using global param xen.nics.max. Param defaults to 7 Added new param to upgrade schema. --- .../xen/discoverer/XcpServerDiscoverer.java | 1 + .../xen/resource/CitrixResourceBase.java | 45 ++++++++----------- .../src/com/cloud/configuration/Config.java | 4 +- .../com/cloud/resource/DiscovererBase.java | 1 + setup/db/db/schema-410to420.sql | 1 + 5 files changed, 23 insertions(+), 29 deletions(-) diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java index 65a97a8de31..a0540637e95 100755 --- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java +++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/discoverer/XcpServerDiscoverer.java @@ -315,6 +315,7 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L params.put("wait", Integer.toString(_wait)); details.put("wait", Integer.toString(_wait)); params.put("migratewait", _configDao.getValue(Config.MigrateWait.toString())); + params.put(Config.XenMaxNics.toString().toLowerCase(), _configDao.getValue(Config.XenMaxNics.toString())); params.put(Config.InstanceName.toString().toLowerCase(), _instance); details.put(Config.InstanceName.toString().toLowerCase(), _instance); try { diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index 22f4ba9cb80..e2e2d6696a9 100644 --- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -331,6 +331,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe protected boolean _isOvs = false; protected List _tmpDom0Vif = new ArrayList(); protected XenServerStorageResource storageResource; + protected int _maxNics = 7; public enum SRType { NFS, LVM, ISCSI, ISO, LVMOISCSI, LVMOHBA, EXT, FILE; @@ -3842,22 +3843,6 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe throw new CloudRuntimeException("Could not find an available slot in VM with name to attach a new disk."); } - - protected String getUnusedVIFNum(Connection conn, VM vm) { - String vmName = ""; - try { - vmName = vm.getNameLabel(conn); - Set allowedVIFDevices = vm.getAllowedVIFDevices(conn); - if (allowedVIFDevices.size() > 0) { - return allowedVIFDevices.iterator().next(); - } - } catch (Exception e) { - String msg = "getUnusedVIFNum failed due to " + e.toString(); - s_logger.warn(msg, e); - } - throw new CloudRuntimeException("Could not find available VIF slot in VM with name: " + vmName + " to plug a VIF"); - } - protected String callHostPlugin(Connection conn, String plugin, String cmd, String... params) { Map args = new HashMap(); String msg; @@ -3990,21 +3975,25 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe protected String getLowestAvailableVIFDeviceNum(Connection conn, VM vm) { try { - Set availableDeviceNums = vm.getAllowedVIFDevices(conn); - Iterator deviceNumsIterator = availableDeviceNums.iterator(); - List sortedDeviceNums = new ArrayList(); - - while (deviceNumsIterator.hasNext()) { - try { - sortedDeviceNums.add(Integer.valueOf(deviceNumsIterator.next())); + List usedDeviceNums = new ArrayList(); + Set vifs = vm.getVIFs(conn); + Iterator vifIter = vifs.iterator(); + while(vifIter.hasNext()){ + VIF vif = vifIter.next(); + try{ + usedDeviceNums.add(Integer.valueOf(vif.getDevice(conn))); } catch (NumberFormatException e) { - s_logger.debug("Obtained an invalid value for an available VIF device number for VM: " + vm.getNameLabel(conn)); + s_logger.debug("Obtained an invalid value for an allocated VIF device number for VM: " + vm.getNameLabel(conn)); return null; } } - Collections.sort(sortedDeviceNums); - return String.valueOf(sortedDeviceNums.get(0)); + for(Integer i=0; i< _maxNics; i++){ + if(!usedDeviceNums.contains(i)){ + s_logger.debug("Lowest available Vif device number: "+i+" for VM: " + vm.getNameLabel(conn)); + return i.toString(); + } + } } catch (XmlRpcException e) { String msg = "Caught XmlRpcException: " + e.getMessage(); s_logger.warn(msg, e); @@ -5655,6 +5644,8 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe value = (String) params.get("migratewait"); _migratewait = NumbersUtil.parseInt(value, 3600); + _maxNics = NumbersUtil.parseInt((String) params.get("xen.nics.max"), 7); + if (_pod == null) { throw new ConfigurationException("Unable to get the pod"); } @@ -7765,7 +7756,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe s_logger.warn(msg); return new PlugNicAnswer(cmd, false, msg); } - String deviceId = getUnusedVIFNum(conn, vm); + String deviceId = getLowestAvailableVIFDeviceNum(conn, vm); nic.setDeviceId(Integer.parseInt(deviceId)); vif = createVif(conn, vmName, vm, nic); vif.plug(conn); diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java index abc6a09e4ef..4a0306a1986 100755 --- a/server/src/com/cloud/configuration/Config.java +++ b/server/src/com/cloud/configuration/Config.java @@ -247,7 +247,7 @@ public enum Config { XenBondStorageNic("Advanced", ManagementServer.class, String.class, "xen.bond.storage.nics", null, "Attempt to bond the two networks if found", null), XenHeartBeatInterval("Advanced", ManagementServer.class, Integer.class, "xen.heartbeat.interval", "60", "heartbeat to use when implementing XenServer Self Fencing", null), XenGuestNetwork("Hidden", ManagementServer.class, String.class, "xen.guest.network.device", null, "Specify for guest network name label", null), - + XenMaxNics("Advanced", AgentManager.class, Integer.class, "xen.nics.max", "7", "Maximum allowed nics for Vms created on Xen", null), // VMware VmwarePrivateNetworkVSwitch("Hidden", ManagementServer.class, String.class, "vmware.private.vswitch", null, "Specify the vSwitch on host for private network", null), VmwarePublicNetworkVSwitch("Hidden", ManagementServer.class, String.class, "vmware.public.vswitch", null, "Specify the vSwitch on host for public network", null), @@ -360,7 +360,7 @@ public enum Config { VpcMaxNetworks("Advanced", ManagementServer.class, Integer.class, "vpc.max.networks", "3", "Maximum number of networks per vpc", null), DetailBatchQuerySize("Advanced", ManagementServer.class, Integer.class, "detail.batch.query.size", "2000", "Default entity detail batch query size for listing", null), ConcurrentSnapshotsThresholdPerHost("Advanced", ManagementServer.class, Long.class, "concurrent.snapshots.threshold.perhost", - null, "Limits number of snapshots that can be handled by the host concurrently; default is NULL - unlimited", null), + null, "Limits number of snapshots that can be handled by the host concurrently; default is NULL - unlimited", null), NetworkIPv6SearchRetryMax("Network", ManagementServer.class, Integer.class, "network.ipv6.search.retry.max", "10000", "The maximum number of retrying times to search for an available IPv6 address in the table", null), ExternalBaremetalSystemUrl("Advanced", ManagementServer.class, String.class, "external.baremetal.system.url", null, "url of external baremetal system that CloudStack will talk to", null), diff --git a/server/src/com/cloud/resource/DiscovererBase.java b/server/src/com/cloud/resource/DiscovererBase.java index 940608c4419..b7c5b6f58de 100644 --- a/server/src/com/cloud/resource/DiscovererBase.java +++ b/server/src/com/cloud/resource/DiscovererBase.java @@ -128,6 +128,7 @@ public abstract class DiscovererBase extends AdapterBase implements Discoverer { params.put("secondary.storage.vm", "false"); params.put("max.template.iso.size", _configDao.getValue(Config.MaxTemplateAndIsoSize.toString())); params.put("migratewait", _configDao.getValue(Config.MigrateWait.toString())); + params.put(Config.XenMaxNics.toString().toLowerCase(), _configDao.getValue(Config.XenMaxNics.toString())); return params; } diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql index 8bd9bfd353e..65add75294b 100644 --- a/setup/db/db/schema-410to420.sql +++ b/setup/db/db/schema-410to420.sql @@ -23,3 +23,4 @@ ALTER TABLE `cloud`.`hypervisor_capabilities` ADD COLUMN `max_hosts_per_cluster` UPDATE `cloud`.`hypervisor_capabilities` SET `max_hosts_per_cluster`=32 WHERE `hypervisor_type`='VMware'; INSERT IGNORE INTO `cloud`.`hypervisor_capabilities`(hypervisor_type, hypervisor_version, max_guests_limit, security_group_enabled, max_hosts_per_cluster) VALUES ('VMware', '5.1', 128, 0, 32); DELETE FROM `cloud`.`configuration` where name='vmware.percluster.host.max'; +INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Advanced', 'DEFAULT', 'AgentManager', 'xen.nics.max', '7', 'Maximum allowed nics for Vms created on Xen'); \ No newline at end of file From c97653b42ecb5741fefa3ce45477744c223f6806 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Mon, 18 Feb 2013 21:32:30 +0530 Subject: [PATCH 05/14] systemvmtemplate: Clean any old vm before building appliance Signed-off-by: Rohit Yadav --- tools/appliance/build.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/appliance/build.sh b/tools/appliance/build.sh index ef3e384b597..e504d9cbf67 100644 --- a/tools/appliance/build.sh +++ b/tools/appliance/build.sh @@ -25,7 +25,8 @@ rootdir=$PWD # Initialize veewee and dependencies bundle -# Start building the appliance +# Clean and start building the appliance +veewee vbox destroy $appliance veewee vbox build $appliance --nogui veewee vbox halt $appliance From a6f5052958d56a2cba672dcda754d3328557e6b9 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Tue, 19 Feb 2013 11:33:45 +0530 Subject: [PATCH 06/14] CLOUDSTACK-1066: Wait for appliance to shutdown before exporting to various fmts Signed-off-by: Rohit Yadav --- tools/appliance/build.sh | 14 +++++++++----- .../definitions/systemvmtemplate/definition.rb | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/tools/appliance/build.sh b/tools/appliance/build.sh index e504d9cbf67..38d71fd00d0 100644 --- a/tools/appliance/build.sh +++ b/tools/appliance/build.sh @@ -16,6 +16,7 @@ # under the License. set -x +set -e appliance="systemvmtemplate" build_date=`date +%Y-%m-%d` @@ -30,9 +31,15 @@ veewee vbox destroy $appliance veewee vbox build $appliance --nogui veewee vbox halt $appliance +while [[ `vboxmanage list runningvms | grep $appliance | wc -l` -ne 0 ]]; +do + echo "Waiting for $appliance to shutdown" + sleep 2; +done + # Get appliance uuids machine_uuid=`vboxmanage showvminfo $appliance | grep UUID | head -1 | awk '{print $2}'` -hdd_uuid=`vboxmanage showvminfo $appliance | grep vhd | head -1 | awk '{print $8}' | cut -d ')' -f 1` +hdd_uuid=`vboxmanage showvminfo $appliance | grep vmdk | head -1 | awk '{print $8}' | cut -d ')' -f 1` # Start exporting rm -fr dist @@ -45,18 +52,15 @@ vboxmanage export $machine_uuid --output $appliance-$build_date-$branch-vmware.o # Export for HyperV vboxmanage clonehd $hdd_uuid $appliance-$build_date-$branch-hyperv.vhd --format VHD bzip2 $appliance-$build_date-$branch-hyperv.vhd -rm $appliance-$build_date-$branch-hyperv.vhd # Export for KVM vboxmanage clonehd $hdd_uuid raw.img --format RAW qemu-img convert -f raw -O qcow2 raw.img $appliance-$build_date-$branch-kvm.qcow2 bzip2 $appliance-$build_date-$branch-kvm.qcow2 -rm $appliance-$build_date-$branch-kvm.qcow2 # Export for Xen # This will be an overwrite convert so, do it at the end vhd-util convert -s 0 -t 1 -i raw.img -o $appliance-$build_date-$branch-xen.vhd -bzip2 $appliance-$build_date-$branch-hyperv.vhd -rm $appliance-$build_date-$branch-hyperv.vhd +bzip2 $appliance-$build_date-$branch-xen.vhd cd $rootdir diff --git a/tools/appliance/definitions/systemvmtemplate/definition.rb b/tools/appliance/definitions/systemvmtemplate/definition.rb index 8fd85306018..a839182bbd9 100644 --- a/tools/appliance/definitions/systemvmtemplate/definition.rb +++ b/tools/appliance/definitions/systemvmtemplate/definition.rb @@ -1,7 +1,7 @@ Veewee::Definition.declare({ :cpu_count => '1', :memory_size=> '256', - :disk_size => '2048', :disk_format => 'VHD', :hostiocache => 'off', + :disk_size => '2048', :disk_format => 'VMDK', :hostiocache => 'off', :os_type_id => 'Debian', :iso_file => "debian-wheezy-DI-b4-i386-netinst.iso", :iso_src => "http://cdimage.debian.org/cdimage/wheezy_di_beta4/i386/iso-cd/debian-wheezy-DI-b4-i386-netinst.iso", From a5f77d348da1b83146e054966ea69b1a4c75013b Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Tue, 19 Feb 2013 12:31:32 +0530 Subject: [PATCH 07/14] CLOUDSTACK-1066: RVM needs a login shell, fix build.sh to start with a login shell Signed-off-by: Rohit Yadav --- tools/appliance/build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/appliance/build.sh b/tools/appliance/build.sh index 38d71fd00d0..4dcb200915e 100644 --- a/tools/appliance/build.sh +++ b/tools/appliance/build.sh @@ -1,3 +1,4 @@ +#!/bin/bash -xl # 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 From 447b2d9c956337de51dfc1725b043b1f360e71a8 Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Tue, 19 Feb 2013 12:26:23 +0530 Subject: [PATCH 08/14] listroutercmd: response should be set to the name of router host name of router returned instead of the name of the router. correcting the setter. Signed-off-by: Prasanna Santhanam --- server/src/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java index 96b91df79f9..3b780ee83ef 100644 --- a/server/src/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java +++ b/server/src/com/cloud/api/query/dao/DomainRouterJoinDaoImpl.java @@ -68,7 +68,7 @@ public class DomainRouterJoinDaoImpl extends GenericDaoBase Date: Tue, 19 Feb 2013 13:24:30 +0530 Subject: [PATCH 09/14] CLOUDSTACK-1066: Make appliance export verbose, put archived images in dist/ Signed-off-by: Rohit Yadav --- tools/appliance/build.sh | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/tools/appliance/build.sh b/tools/appliance/build.sh index 4dcb200915e..366b246fbe2 100644 --- a/tools/appliance/build.sh +++ b/tools/appliance/build.sh @@ -45,23 +45,25 @@ hdd_uuid=`vboxmanage showvminfo $appliance | grep vmdk | head -1 | awk '{print $ # Start exporting rm -fr dist mkdir dist -cd dist # Export for VMWare vSphere -vboxmanage export $machine_uuid --output $appliance-$build_date-$branch-vmware.ova +vboxmanage export $machine_uuid --output dist/$appliance-$build_date-$branch-vmware.ova +echo "$appliance exported for VMWare: dist/$appliance-$build_date-$branch-vmware.ova" # Export for HyperV -vboxmanage clonehd $hdd_uuid $appliance-$build_date-$branch-hyperv.vhd --format VHD -bzip2 $appliance-$build_date-$branch-hyperv.vhd +vboxmanage clonehd $hdd_uuid dist/$appliance-$build_date-$branch-hyperv.vhd --format VHD +bzip2 dist/$appliance-$build_date-$branch-hyperv.vhd +echo "$appliance exported for HyperV: dist/$appliance-$build_date-$branch-hyperv.vhd.bz2" # Export for KVM -vboxmanage clonehd $hdd_uuid raw.img --format RAW -qemu-img convert -f raw -O qcow2 raw.img $appliance-$build_date-$branch-kvm.qcow2 -bzip2 $appliance-$build_date-$branch-kvm.qcow2 +vboxmanage clonehd $hdd_uuid dist/raw.img --format RAW +qemu-img convert -f raw -O qcow2 dist/raw.img dist/$appliance-$build_date-$branch-kvm.qcow2 +bzip2 dist/$appliance-$build_date-$branch-kvm.qcow2 +echo "$appliance exported for KVM: dist/$appliance-$build_date-$branch-kvm.qcow2.bz2" # Export for Xen # This will be an overwrite convert so, do it at the end -vhd-util convert -s 0 -t 1 -i raw.img -o $appliance-$build_date-$branch-xen.vhd -bzip2 $appliance-$build_date-$branch-xen.vhd +vhd-util convert -s 0 -t 1 -i dist/raw.img -o dist/$appliance-$build_date-$branch-xen.vhd +bzip2 dist/$appliance-$build_date-$branch-xen.vhd +echo "$appliance exported for Xen: dist/$appliance-$build_date-$branch-xen.vhd.bz2" -cd $rootdir From ca432fe6b7d006952bd0a7d85b94b988cf68c623 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Tue, 19 Feb 2013 13:36:21 +0530 Subject: [PATCH 10/14] db: Fix upgrade paths to 4.1.0 Signed-off-by: Rohit Yadav --- .../cloud/upgrade/DatabaseUpgradeChecker.java | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/server/src/com/cloud/upgrade/DatabaseUpgradeChecker.java b/server/src/com/cloud/upgrade/DatabaseUpgradeChecker.java index f831a032385..f48709452b1 100755 --- a/server/src/com/cloud/upgrade/DatabaseUpgradeChecker.java +++ b/server/src/com/cloud/upgrade/DatabaseUpgradeChecker.java @@ -83,81 +83,81 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker { new UpgradeSnapshot217to224(), new Upgrade222to224(), new Upgrade224to225(), new Upgrade225to226(), new Upgrade227to228(), new Upgrade228to229(), new Upgrade229to2210(), new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(), new Upgrade2214to30(), - new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40() }); + new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41() }); _upgradeMap.put("2.1.8", new DbUpgrade[] { new Upgrade218to22(), new Upgrade221to222(), new UpgradeSnapshot217to224(), new Upgrade222to224(), new Upgrade218to224DomainVlans(), new Upgrade224to225(), new Upgrade225to226(), new Upgrade227to228(), new Upgrade228to229(), new Upgrade229to2210(), new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(), - new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40() }); + new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41() }); _upgradeMap.put("2.1.9", new DbUpgrade[] { new Upgrade218to22(), new Upgrade221to222(), new UpgradeSnapshot217to224(), new Upgrade222to224(), new Upgrade218to224DomainVlans(), new Upgrade224to225(), new Upgrade225to226(), new Upgrade227to228(), new Upgrade228to229(), new Upgrade229to2210(), new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(), new Upgrade2214to30(), - new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40() }); + new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41() }); _upgradeMap.put("2.2.1", new DbUpgrade[] { new Upgrade221to222(), new UpgradeSnapshot223to224(), new Upgrade222to224(), new Upgrade224to225(), new Upgrade225to226(), new Upgrade227to228(), new Upgrade228to229(), new Upgrade229to2210(), new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(), - new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40() }); + new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41() }); _upgradeMap.put("2.2.2", new DbUpgrade[] { new Upgrade222to224(), new UpgradeSnapshot223to224(), new Upgrade224to225(), new Upgrade225to226(), new Upgrade227to228(), new Upgrade228to229(), new Upgrade229to2210(), new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(), - new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40() }); + new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41() }); _upgradeMap.put("2.2.3", new DbUpgrade[] { new Upgrade222to224(), new UpgradeSnapshot223to224(), new Upgrade224to225(), new Upgrade225to226(), new Upgrade227to228(), new Upgrade228to229(), new Upgrade229to2210(), new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(), - new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40() }); + new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41() }); _upgradeMap.put("2.2.4", new DbUpgrade[] { new Upgrade224to225(), new Upgrade225to226(), new Upgrade227to228(), new Upgrade228to229(), new Upgrade229to2210(), new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), - new Upgrade301to302(), new Upgrade302to40() }); + new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41() }); _upgradeMap.put("2.2.5", new DbUpgrade[] { new Upgrade225to226(), new Upgrade227to228(), new Upgrade228to229(), new Upgrade229to2210(), new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), - new Upgrade302to40() }); + new Upgrade302to40(), new Upgrade40to41() }); _upgradeMap.put("2.2.6", new DbUpgrade[] { new Upgrade227to228(), new Upgrade228to229(), new Upgrade229to2210(), new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(), - new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40() }); + new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41() }); _upgradeMap.put("2.2.7", new DbUpgrade[] { new Upgrade227to228(), new Upgrade228to229(), new Upgrade229to2210(), new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(), - new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40() }); + new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41() }); _upgradeMap.put("2.2.8", new DbUpgrade[] { new Upgrade228to229(), new Upgrade229to2210(), new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(), new Upgrade2214to30() - , new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40() }); + , new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41() }); _upgradeMap.put("2.2.9", new DbUpgrade[] { new Upgrade229to2210(), new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), - new Upgrade301to302(), new Upgrade302to40() }); + new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41() }); _upgradeMap.put("2.2.10", new DbUpgrade[] { new Upgrade2210to2211(), new Upgrade2211to2212(), new Upgrade2212to2213(), - new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40() }); + new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41() }); _upgradeMap.put("2.2.11", new DbUpgrade[] { new Upgrade2211to2212(), new Upgrade2212to2213(), new Upgrade2213to2214(), - new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40() }); + new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41() }); _upgradeMap.put("2.2.12", new DbUpgrade[] { new Upgrade2212to2213(), new Upgrade2213to2214(), new Upgrade2214to30(), - new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40() }); + new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41() }); _upgradeMap.put("2.2.13", new DbUpgrade[] { new Upgrade2213to2214(), new Upgrade2214to30(), new Upgrade30to301(), - new Upgrade301to302(), new Upgrade302to40() }); + new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41() }); _upgradeMap.put("2.2.14", new DbUpgrade[] { new Upgrade2214to30(), new Upgrade30to301(), new Upgrade301to302(), - new Upgrade302to40() }); + new Upgrade302to40(), new Upgrade40to41() }); - _upgradeMap.put("3.0.0", new DbUpgrade[] { new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40() }); + _upgradeMap.put("3.0.0", new DbUpgrade[] { new Upgrade30to301(), new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41() }); - _upgradeMap.put("3.0.1", new DbUpgrade[] { new Upgrade301to302(), new Upgrade302to40() }); + _upgradeMap.put("3.0.1", new DbUpgrade[] { new Upgrade301to302(), new Upgrade302to40(), new Upgrade40to41() }); - _upgradeMap.put("3.0.2", new DbUpgrade[] { new Upgrade302to40() }); + _upgradeMap.put("3.0.2", new DbUpgrade[] { new Upgrade302to40(), new Upgrade40to41() }); _upgradeMap.put("4.0.0", new DbUpgrade[] { new Upgrade40to41() }); } From e85b1cbe8fd25eb8612ad9fe08f8802a554be707 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Tue, 19 Feb 2013 14:01:50 +0530 Subject: [PATCH 11/14] CLOUDSTACK-1066: Fix README for building systemvm appliance Signed-off-by: Rohit Yadav --- tools/appliance/README.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tools/appliance/README.md b/tools/appliance/README.md index aa1001e1b1b..2f6f656212d 100644 --- a/tools/appliance/README.md +++ b/tools/appliance/README.md @@ -19,6 +19,8 @@ under the License. # Setting up Tools and Environment + - Install VirtualBox 4.2 or latest + - Tool for exporting appliances: qemu-img, vboxmanage, vhd-util - Install [RVM](https://rvm.io/rvm/install) - Setup paths: export PATH=~/.rvm/bin:$PATH @@ -36,7 +38,14 @@ Note, gem may require gcc-4.2, make sure link exists: sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2 -# How to build SystemVM template appliance +# How to build SystemVMs automatically + +Just run build.sh, it will export archived appliances for KVM, Xen, +VMWare and HyperV in `dist`: + + sh build.sh + +# Building SystemVM template appliance manually List available appliances one can build: @@ -50,3 +59,9 @@ Build systemvm template appliance: Start the box: veewee vbox up 'systemvmtemplate' + +Halt the box: + + veewee vbox halt 'systemvmtemplate' + +Now VirtualBox can be used to export appliance. From c94a75c0a6d4048fced1ff1db2e8219b534d3d2f Mon Sep 17 00:00:00 2001 From: Kishan Kavala Date: Tue, 19 Feb 2013 14:14:52 +0530 Subject: [PATCH 12/14] CLOUDSTACK-752: Removed 1 private gateway for VPC limitation. Verified that more than 8 private gateways can be created. --- .../hypervisor/xen/resource/CitrixResourceBase.java | 11 +++++++---- .../router/VpcVirtualNetworkApplianceManagerImpl.java | 4 ++-- server/src/com/cloud/network/vpc/VpcManagerImpl.java | 10 ++-------- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index e2e2d6696a9..33ad18d0331 100644 --- a/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -3974,7 +3974,9 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe } protected String getLowestAvailableVIFDeviceNum(Connection conn, VM vm) { + String vmName = ""; try { + vmName = vm.getNameLabel(conn); List usedDeviceNums = new ArrayList(); Set vifs = vm.getVIFs(conn); Iterator vifIter = vifs.iterator(); @@ -3983,14 +3985,15 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe try{ usedDeviceNums.add(Integer.valueOf(vif.getDevice(conn))); } catch (NumberFormatException e) { - s_logger.debug("Obtained an invalid value for an allocated VIF device number for VM: " + vm.getNameLabel(conn)); - return null; + String msg = "Obtained an invalid value for an allocated VIF device number for VM: " + vmName; + s_logger.debug(msg, e); + throw new CloudRuntimeException(msg); } } for(Integer i=0; i< _maxNics; i++){ if(!usedDeviceNums.contains(i)){ - s_logger.debug("Lowest available Vif device number: "+i+" for VM: " + vm.getNameLabel(conn)); + s_logger.debug("Lowest available Vif device number: "+i+" for VM: " + vmName); return i.toString(); } } @@ -4002,7 +4005,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe s_logger.warn(msg, e); } - return null; + throw new CloudRuntimeException("Could not find available VIF slot in VM with name: " + vmName); } protected VDI mount(Connection conn, StoragePoolType pooltype, String volumeFolder, String volumePath) { diff --git a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java index d7fe3e05d97..4d1968d9f94 100644 --- a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java +++ b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java @@ -341,11 +341,11 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian _agentMgr.send(dest.getHost().getId(), cmds); PlugNicAnswer plugNicAnswer = cmds.getAnswer(PlugNicAnswer.class); if (!(plugNicAnswer != null && plugNicAnswer.getResult())) { - s_logger.warn("Unable to plug nic for vm " + vm.getHostName()); + s_logger.warn("Unable to plug nic for vm " + vm.getName()); result = false; } } catch (OperationTimedoutException e) { - throw new AgentUnavailableException("Unable to plug nic for router " + vm.getHostName() + " in network " + network, + throw new AgentUnavailableException("Unable to plug nic for router " + vm.getName() + " in network " + network, dest.getHost().getId(), e); } } else { diff --git a/server/src/com/cloud/network/vpc/VpcManagerImpl.java b/server/src/com/cloud/network/vpc/VpcManagerImpl.java index 7197c363264..fbb5788d362 100644 --- a/server/src/com/cloud/network/vpc/VpcManagerImpl.java +++ b/server/src/com/cloud/network/vpc/VpcManagerImpl.java @@ -1233,13 +1233,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager{ ex.addProxyObject("vpc", vpcId, "VPC"); throw ex; } - - //allow only one private gateway per vpc - VpcGatewayVO gatewayVO = _vpcGatewayDao.getPrivateGatewayForVpc(vpcId); - if (gatewayVO != null) { - throw new InvalidParameterValueException("Private ip address already exists for vpc " + vpc); - } - + //Validate physical network if (physicalNetworkId == null) { List pNtwks = _ntwkModel.getPhysicalNtwksSupportingTrafficType(vpc.getZoneId(), TrafficType.Guest); @@ -1258,7 +1252,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager{ vlan, ipAddress, null, gateway, netmask, gatewayOwnerId, vpcId); //2) create gateway entry - gatewayVO = new VpcGatewayVO(ipAddress, VpcGateway.Type.Private, vpcId, privateNtwk.getDataCenterId(), + VpcGatewayVO gatewayVO = new VpcGatewayVO(ipAddress, VpcGateway.Type.Private, vpcId, privateNtwk.getDataCenterId(), privateNtwk.getId(), vlan, gateway, netmask, vpc.getAccountId(), vpc.getDomainId()); _vpcGatewayDao.persist(gatewayVO); From f2b97db0f9409b3a45eb58d88d04f27709e3ace0 Mon Sep 17 00:00:00 2001 From: Abhinandan Prateek Date: Tue, 19 Feb 2013 15:36:39 +0530 Subject: [PATCH 13/14] CLOUDSTACK-1172: LDAP enhancements --- .../configuration/ConfigurationService.java | 2 + .../api/command/admin/ldap/LDAPConfigCmd.java | 61 ++++++++++++++++--- .../api/response/LDAPConfigResponse.java | 2 +- .../server/auth/LDAPUserAuthenticator.java | 9 ++- .../ConfigurationManagerImpl.java | 33 ++++++++-- .../vpc/MockConfigurationManagerImpl.java | 9 +++ 6 files changed, 99 insertions(+), 17 deletions(-) diff --git a/api/src/com/cloud/configuration/ConfigurationService.java b/api/src/com/cloud/configuration/ConfigurationService.java index a9595fe7574..e63fcece525 100644 --- a/api/src/com/cloud/configuration/ConfigurationService.java +++ b/api/src/com/cloud/configuration/ConfigurationService.java @@ -264,6 +264,8 @@ public interface ConfigurationService { boolean removeLDAP(LDAPRemoveCmd cmd); + LDAPConfigCmd listLDAPConfig(LDAPConfigCmd cmd); + /** * @param offering * @return diff --git a/api/src/org/apache/cloudstack/api/command/admin/ldap/LDAPConfigCmd.java b/api/src/org/apache/cloudstack/api/command/admin/ldap/LDAPConfigCmd.java index fbe8ab000e6..2976de4bf28 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/ldap/LDAPConfigCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/ldap/LDAPConfigCmd.java @@ -31,6 +31,7 @@ import com.cloud.exception.ConcurrentOperationException; import com.cloud.exception.InsufficientCapacityException; import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceUnavailableException; +import com.cloud.exception.InvalidParameterValueException; import com.cloud.user.Account; @APICommand(name = "ldapConfig", description="Configure the LDAP context for this site.", responseObject=LDAPConfigResponse.class, since="3.0.0") @@ -43,7 +44,10 @@ public class LDAPConfigCmd extends BaseCmd { //////////////// API parameters ///////////////////// ///////////////////////////////////////////////////// - @Parameter(name=ApiConstants.HOST_NAME, type=CommandType.STRING, required=true, description="Hostname or ip address of the ldap server eg: my.ldap.com") + @Parameter(name=ApiConstants.LIST_ALL, type=CommandType.STRING, description="Hostname or ip address of the ldap server eg: my.ldap.com") + private String listall; + + @Parameter(name=ApiConstants.HOST_NAME, type=CommandType.STRING, description="Hostname or ip address of the ldap server eg: my.ldap.com") private String hostname; @Parameter(name=ApiConstants.PORT, type=CommandType.INTEGER, description="Specify the LDAP port if required, default is 389.") @@ -52,10 +56,10 @@ public class LDAPConfigCmd extends BaseCmd { @Parameter(name=ApiConstants.USE_SSL, type=CommandType.BOOLEAN, description="Check Use SSL if the external LDAP server is configured for LDAP over SSL.") private Boolean useSSL; - @Parameter(name=ApiConstants.SEARCH_BASE, type=CommandType.STRING, required=true, description="The search base defines the starting point for the search in the directory tree Example: dc=cloud,dc=com.") + @Parameter(name=ApiConstants.SEARCH_BASE, type=CommandType.STRING, description="The search base defines the starting point for the search in the directory tree Example: dc=cloud,dc=com.") private String searchBase; - @Parameter(name=ApiConstants.QUERY_FILTER, type=CommandType.STRING, required=true, description="You specify a query filter here, which narrows down the users, who can be part of this domain.") + @Parameter(name=ApiConstants.QUERY_FILTER, type=CommandType.STRING, description="You specify a query filter here, which narrows down the users, who can be part of this domain.") private String queryFilter; @Parameter(name=ApiConstants.BIND_DN, type=CommandType.STRING, description="Specify the distinguished name of a user with the search permission on the directory.") @@ -74,6 +78,10 @@ public class LDAPConfigCmd extends BaseCmd { /////////////////// Accessors /////////////////////// ///////////////////////////////////////////////////// + public String getListAll() { + return listall == null ? "false" : listall; + } + public String getBindPassword() { return bindPassword; } @@ -82,30 +90,56 @@ public class LDAPConfigCmd extends BaseCmd { return bindDN; } + public void setBindDN(String bdn) { + this.bindDN=bdn; + } + public String getQueryFilter() { return queryFilter; } + public void setQueryFilter(String queryFilter) { + this.queryFilter=queryFilter; + } public String getSearchBase() { return searchBase; } + public void setSearchBase(String searchBase) { + this.searchBase=searchBase; + } + public Boolean getUseSSL() { - return useSSL == null ? Boolean.FALSE : Boolean.TRUE; + return useSSL == null ? Boolean.FALSE : useSSL; + } + + public void setUseSSL(Boolean useSSL) { + this.useSSL=useSSL; } public String getHostname() { return hostname; } + public void setHostname(String hostname) { + this.hostname=hostname; + } + public Integer getPort() { return port <= 0 ? 389 : port; } + public void setPort(Integer port) { + this.port=port; + } + public String getTrustStore() { return trustStore; } + public void setTrustStore(String trustStore) { + this.trustStore=trustStore; + } public String getTrustStorePassword() { return trustStorePassword; @@ -122,12 +156,25 @@ public class LDAPConfigCmd extends BaseCmd { InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException { try { - boolean result = _configService.updateLDAP(this); - if (result){ - LDAPConfigResponse lr = _responseGenerator.createLDAPConfigResponse(getHostname(), getPort(), getUseSSL(), getQueryFilter(), getSearchBase(), getBindDN()); + if ("true".equalsIgnoreCase(getListAll())){ + // return the existing conf + LDAPConfigCmd cmd = _configService.listLDAPConfig(this); + LDAPConfigResponse lr = _responseGenerator.createLDAPConfigResponse(cmd.getHostname(), cmd.getPort(), cmd.getUseSSL(), + cmd.getQueryFilter(), cmd.getSearchBase(), cmd.getBindDN()); lr.setResponseName(getCommandName()); this.setResponseObject(lr); } + else if (getHostname()==null || getSearchBase() == null || getQueryFilter() == null) { + throw new InvalidParameterValueException("You need to provide hostname, serachbase and queryfilter to configure your LDAP server"); + } + else { + boolean result = _configService.updateLDAP(this); + if (result){ + LDAPConfigResponse lr = _responseGenerator.createLDAPConfigResponse(getHostname(), getPort(), getUseSSL(), getQueryFilter(), getSearchBase(), getBindDN()); + lr.setResponseName(getCommandName()); + this.setResponseObject(lr); + } + } } catch (NamingException ne){ ne.printStackTrace(); diff --git a/api/src/org/apache/cloudstack/api/response/LDAPConfigResponse.java b/api/src/org/apache/cloudstack/api/response/LDAPConfigResponse.java index aa10229f2bd..bbeec630d81 100644 --- a/api/src/org/apache/cloudstack/api/response/LDAPConfigResponse.java +++ b/api/src/org/apache/cloudstack/api/response/LDAPConfigResponse.java @@ -30,7 +30,7 @@ public class LDAPConfigResponse extends BaseResponse { @SerializedName(ApiConstants.PORT) @Param(description="Specify the LDAP port if required, default is 389") private String port; - @SerializedName(ApiConstants.PORT) @Param(description="Check Use SSL if the external LDAP server is configured for LDAP over SSL") + @SerializedName(ApiConstants.USE_SSL) @Param(description="Check Use SSL if the external LDAP server is configured for LDAP over SSL") private String useSSL; @SerializedName(ApiConstants.SEARCH_BASE) @Param(description="The search base defines the starting point for the search in the directory tree Example: dc=cloud,dc=com") diff --git a/plugins/user-authenticators/ldap/src/com/cloud/server/auth/LDAPUserAuthenticator.java b/plugins/user-authenticators/ldap/src/com/cloud/server/auth/LDAPUserAuthenticator.java index fb0273e6ea3..61eebe5fc93 100644 --- a/plugins/user-authenticators/ldap/src/com/cloud/server/auth/LDAPUserAuthenticator.java +++ b/plugins/user-authenticators/ldap/src/com/cloud/server/auth/LDAPUserAuthenticator.java @@ -66,7 +66,7 @@ public class LDAPUserAuthenticator extends DefaultUserAuthenticator { String port = _configDao.getValue(LDAPParams.port.toString()); String queryFilter = _configDao.getValue(LDAPParams.queryfilter.toString()); String searchBase = _configDao.getValue(LDAPParams.searchbase.toString()); - String useSSL = _configDao.getValue(LDAPParams.usessl.toString()); + Boolean useSSL = Boolean.valueOf(_configDao.getValue(LDAPParams.usessl.toString())); String bindDN = _configDao.getValue(LDAPParams.dn.toString()); String bindPasswd = _configDao.getValue(LDAPParams.passwd.toString()); String trustStore = _configDao.getValue(LDAPParams.truststore.toString()); @@ -77,7 +77,7 @@ public class LDAPUserAuthenticator extends DefaultUserAuthenticator { Hashtable env = new Hashtable(11); env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory"); String protocol = "ldap://" ; - if (new Boolean(useSSL)){ + if (useSSL){ env.put(Context.SECURITY_PROTOCOL, "ssl"); protocol="ldaps://" ; System.setProperty("javax.net.ssl.trustStore", trustStore); @@ -123,7 +123,7 @@ public class LDAPUserAuthenticator extends DefaultUserAuthenticator { env = new Hashtable(11); env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory"); protocol = "ldap://" ; - if (new Boolean(useSSL)){ + if (useSSL){ env.put(Context.SECURITY_PROTOCOL, "ssl"); protocol="ldaps://" ; } @@ -135,8 +135,7 @@ public class LDAPUserAuthenticator extends DefaultUserAuthenticator { ctx.close(); } catch (NamingException ne) { - ne.printStackTrace(); - s_logger.warn("Authentication failed due to " + ne.getMessage()); + s_logger.warn("Authentication Failed ! " + ne.getMessage() + (ne.getCause() != null ? ("; Caused by:" + ne.getCause().getMessage()) : "")); return false; } catch (Exception e){ diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java index 074675cdd33..b886bedbc48 100755 --- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java +++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java @@ -1246,6 +1246,27 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati return true; } + + @Override + @DB + public LDAPConfigCmd listLDAPConfig(LDAPConfigCmd cmd) { + String hostname = _configDao.getValue(LDAPParams.hostname.toString()); + cmd.setHostname(hostname == null ? "" : hostname); + String port = _configDao.getValue(LDAPParams.port.toString()); + cmd.setPort(port == null ? 0 : Integer.valueOf(port)); + String queryFilter = _configDao.getValue(LDAPParams.queryfilter.toString()); + cmd.setQueryFilter(queryFilter == null ? "" : queryFilter); + String searchBase = _configDao.getValue(LDAPParams.searchbase.toString()); + cmd.setSearchBase(searchBase == null ? "" : searchBase); + String useSSL = _configDao.getValue(LDAPParams.usessl.toString()); + cmd.setUseSSL(useSSL == null ? Boolean.FALSE : Boolean.valueOf(useSSL)); + String binddn = _configDao.getValue(LDAPParams.dn.toString()); + cmd.setBindDN(binddn == null ? "" : binddn); + String truststore = _configDao.getValue(LDAPParams.truststore.toString()); + cmd.setTrustStore(truststore == null ? "" : truststore); + return cmd; + } + @Override @DB public boolean updateLDAP(LDAPConfigCmd cmd) { @@ -1265,11 +1286,16 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati throw new InvalidParameterValueException("If you specify a bind name then you need to provide bind password too."); } + // check query filter if it contains valid substitution + if (!queryFilter.contains("%u") && !queryFilter.contains("%n") && !queryFilter.contains("%e")){ + throw new InvalidParameterValueException("QueryFilter should contain at least one of the substitutions: %u, %n or %e: " + queryFilter); + } + // check if the info is correct Hashtable env = new Hashtable(11); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); String protocol = "ldap://"; - if (new Boolean(useSSL)) { + if (useSSL) { env.put(Context.SECURITY_PROTOCOL, "ssl"); protocol = "ldaps://"; if (trustStore == null || trustStorePassword == null) { @@ -1288,7 +1314,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati DirContext ctx = new InitialDirContext(env); ctx.close(); - // store the result in DB COnfiguration + // store the result in DB Configuration ConfigurationVO cvo = _configDao.findByName(LDAPParams.hostname.toString()); if (cvo == null) { cvo = new ConfigurationVO("Hidden", "DEFAULT", "management-server", LDAPParams.hostname.toString(), null, "Hostname or ip address of the ldap server eg: my.ldap.com"); @@ -1356,8 +1382,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati s_logger.debug("The ldap server is configured: " + hostname); } catch (NamingException ne) { - ne.printStackTrace(); - throw new InvalidParameterValueException("Naming Exception, check you ldap data ! " + ne.getMessage() + (ne.getCause() != null ? ("Caused by:" + ne.getCause().getMessage()) : "")); + throw new InvalidParameterValueException("Naming Exception, check you ldap data ! " + ne.getMessage() + (ne.getCause() != null ? ("; Caused by:" + ne.getCause().getMessage()) : "")); } return true; } diff --git a/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java b/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java index 574ce0a0352..180138ac136 100644 --- a/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java +++ b/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java @@ -365,6 +365,15 @@ public class MockConfigurationManagerImpl extends ManagerBase implements Configu return false; } + /* (non-Javadoc) + * @see com.cloud.configuration.ConfigurationService#listLDAPConfig(org.apache.cloudstack.api.commands.LDAPConfigCmd) + */ + @Override + public LDAPConfigCmd listLDAPConfig(LDAPConfigCmd cmd) { + // TODO Auto-generated method stub + return null; + } + /* (non-Javadoc) * @see com.cloud.configuration.ConfigurationService#isOfferingForVpc(com.cloud.offering.NetworkOffering) */ From edac894f318e79c5bd121ba4f914998bf48f21f5 Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Tue, 19 Feb 2013 16:30:25 +0530 Subject: [PATCH 14/14] spring changes for simulator component allow spring to do DI for simulator plugin. componentContext.xml will have simulator components disabled by default. Signed-off-by: Prasanna Santhanam --- client/tomcatconf/componentContext.xml.in | 13 ++++ .../agent/manager/MockAgentManagerImpl.java | 2 + .../agent/manager/MockStorageManagerImpl.java | 2 + .../agent/manager/MockVmManagerImpl.java | 61 ++++----------- .../agent/manager/SimulatorManagerImpl.java | 76 +++---------------- .../cloud/resource/SimulatorDiscoverer.java | 2 +- .../SimulatorSecondaryDiscoverer.java | 2 + .../com/cloud/simulator/SimulatorGuru.java | 7 +- .../dao/MockConfigurationDaoImpl.java | 13 ++-- .../cloud/simulator/dao/MockHostDaoImpl.java | 6 +- .../simulator/dao/MockSecStorageDaoImpl.java | 6 +- .../dao/MockSecurityRulesDaoImpl.java | 14 ++-- .../simulator/dao/MockStoragePoolDaoImpl.java | 6 +- .../cloud/simulator/dao/MockVMDaoImpl.java | 17 +++-- .../simulator/dao/MockVolumeDaoImpl.java | 9 ++- 15 files changed, 90 insertions(+), 146 deletions(-) diff --git a/client/tomcatconf/componentContext.xml.in b/client/tomcatconf/componentContext.xml.in index c45ab1bd91b..370c0fc1518 100644 --- a/client/tomcatconf/componentContext.xml.in +++ b/client/tomcatconf/componentContext.xml.in @@ -174,6 +174,13 @@ + + + @@ -265,5 +272,11 @@ + + diff --git a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockAgentManagerImpl.java b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockAgentManagerImpl.java index 2178651403e..8542de3bd9f 100755 --- a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockAgentManagerImpl.java +++ b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockAgentManagerImpl.java @@ -62,7 +62,9 @@ import com.cloud.utils.db.DB; import com.cloud.utils.db.Transaction; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.net.NetUtils; +import org.springframework.stereotype.Component; +@Component @Local(value = { MockAgentManager.class }) public class MockAgentManagerImpl extends ManagerBase implements MockAgentManager { private static final Logger s_logger = Logger.getLogger(MockAgentManagerImpl.class); diff --git a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockStorageManagerImpl.java b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockStorageManagerImpl.java index f445bb32900..859acc85958 100644 --- a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockStorageManagerImpl.java +++ b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockStorageManagerImpl.java @@ -97,7 +97,9 @@ import com.cloud.utils.db.Transaction; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.vm.DiskProfile; import com.cloud.vm.VirtualMachine.State; +import org.springframework.stereotype.Component; +@Component @Local(value = { MockStorageManager.class }) public class MockStorageManagerImpl extends ManagerBase implements MockStorageManager { private static final Logger s_logger = Logger.getLogger(MockStorageManagerImpl.class); diff --git a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java index 60e1a61a0bd..40a5b9846db 100644 --- a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java +++ b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java @@ -17,58 +17,12 @@ package com.cloud.agent.manager; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import javax.ejb.Local; -import javax.inject.Inject; -import javax.naming.ConfigurationException; - -import org.apache.log4j.Logger; - -import com.cloud.agent.api.Answer; -import com.cloud.agent.api.BumpUpPriorityCommand; -import com.cloud.agent.api.CheckRouterAnswer; -import com.cloud.agent.api.CheckRouterCommand; -import com.cloud.agent.api.CheckVirtualMachineAnswer; -import com.cloud.agent.api.CheckVirtualMachineCommand; -import com.cloud.agent.api.CleanupNetworkRulesCmd; -import com.cloud.agent.api.GetDomRVersionAnswer; -import com.cloud.agent.api.GetDomRVersionCmd; -import com.cloud.agent.api.GetVmStatsAnswer; -import com.cloud.agent.api.GetVmStatsCommand; -import com.cloud.agent.api.GetVncPortAnswer; -import com.cloud.agent.api.GetVncPortCommand; -import com.cloud.agent.api.MigrateAnswer; -import com.cloud.agent.api.MigrateCommand; -import com.cloud.agent.api.NetworkUsageAnswer; -import com.cloud.agent.api.NetworkUsageCommand; -import com.cloud.agent.api.PrepareForMigrationAnswer; -import com.cloud.agent.api.PrepareForMigrationCommand; -import com.cloud.agent.api.RebootAnswer; -import com.cloud.agent.api.RebootCommand; -import com.cloud.agent.api.SecurityGroupRuleAnswer; -import com.cloud.agent.api.SecurityGroupRulesCmd; -import com.cloud.agent.api.StartAnswer; -import com.cloud.agent.api.StartCommand; -import com.cloud.agent.api.StopAnswer; -import com.cloud.agent.api.StopCommand; -import com.cloud.agent.api.VmStatsEntry; +import com.cloud.agent.api.*; import com.cloud.agent.api.check.CheckSshAnswer; import com.cloud.agent.api.check.CheckSshCommand; import com.cloud.agent.api.proxy.CheckConsoleProxyLoadCommand; import com.cloud.agent.api.proxy.WatchConsoleProxyLoadCommand; -import com.cloud.agent.api.routing.DhcpEntryCommand; -import com.cloud.agent.api.routing.IpAssocCommand; -import com.cloud.agent.api.routing.LoadBalancerConfigCommand; -import com.cloud.agent.api.routing.NetworkElementCommand; -import com.cloud.agent.api.routing.SavePasswordCommand; -import com.cloud.agent.api.routing.SetFirewallRulesCommand; -import com.cloud.agent.api.routing.SetPortForwardingRulesCommand; -import com.cloud.agent.api.routing.SetStaticNatRulesCommand; -import com.cloud.agent.api.routing.VmDataCommand; +import com.cloud.agent.api.routing.*; import com.cloud.agent.api.to.NicTO; import com.cloud.agent.api.to.VirtualMachineTO; import com.cloud.network.Networks.TrafficType; @@ -86,7 +40,18 @@ import com.cloud.utils.component.ManagerBase; import com.cloud.utils.db.Transaction; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.vm.VirtualMachine.State; +import org.apache.log4j.Logger; +import org.springframework.stereotype.Component; +import javax.ejb.Local; +import javax.inject.Inject; +import javax.naming.ConfigurationException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +@Component @Local(value = { MockVmManager.class }) public class MockVmManagerImpl extends ManagerBase implements MockVmManager { private static final Logger s_logger = Logger.getLogger(MockVmManagerImpl.class); diff --git a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java index 41443572efd..c234cc5cb2e 100644 --- a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java +++ b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java @@ -16,73 +16,12 @@ // under the License. package com.cloud.agent.manager; -import java.util.HashMap; -import java.util.Map; - -import javax.ejb.Local; -import javax.inject.Inject; -import javax.naming.ConfigurationException; - -import org.apache.log4j.Logger; - -import com.cloud.agent.api.Answer; -import com.cloud.agent.api.AttachIsoCommand; -import com.cloud.agent.api.AttachVolumeCommand; -import com.cloud.agent.api.BackupSnapshotCommand; -import com.cloud.agent.api.BumpUpPriorityCommand; -import com.cloud.agent.api.CheckHealthCommand; -import com.cloud.agent.api.CheckNetworkCommand; -import com.cloud.agent.api.CheckRouterCommand; -import com.cloud.agent.api.CheckVirtualMachineCommand; -import com.cloud.agent.api.CleanupNetworkRulesCmd; -import com.cloud.agent.api.ClusterSyncCommand; -import com.cloud.agent.api.Command; -import com.cloud.agent.api.ComputeChecksumCommand; -import com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand; -import com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand; -import com.cloud.agent.api.CreateStoragePoolCommand; -import com.cloud.agent.api.CreateVolumeFromSnapshotCommand; -import com.cloud.agent.api.DeleteSnapshotBackupCommand; -import com.cloud.agent.api.DeleteStoragePoolCommand; -import com.cloud.agent.api.GetDomRVersionCmd; -import com.cloud.agent.api.GetHostStatsCommand; -import com.cloud.agent.api.GetStorageStatsCommand; -import com.cloud.agent.api.GetVmStatsCommand; -import com.cloud.agent.api.GetVncPortCommand; -import com.cloud.agent.api.MaintainCommand; -import com.cloud.agent.api.ManageSnapshotCommand; -import com.cloud.agent.api.MigrateCommand; -import com.cloud.agent.api.ModifyStoragePoolCommand; -import com.cloud.agent.api.NetworkUsageCommand; -import com.cloud.agent.api.PingTestCommand; -import com.cloud.agent.api.PrepareForMigrationCommand; -import com.cloud.agent.api.RebootCommand; -import com.cloud.agent.api.SecStorageSetupCommand; -import com.cloud.agent.api.SecStorageVMSetupCommand; -import com.cloud.agent.api.SecurityGroupRulesCmd; -import com.cloud.agent.api.StartCommand; -import com.cloud.agent.api.StopCommand; -import com.cloud.agent.api.StoragePoolInfo; +import com.cloud.agent.api.*; import com.cloud.agent.api.check.CheckSshCommand; import com.cloud.agent.api.proxy.CheckConsoleProxyLoadCommand; import com.cloud.agent.api.proxy.WatchConsoleProxyLoadCommand; -import com.cloud.agent.api.routing.DhcpEntryCommand; -import com.cloud.agent.api.routing.IpAssocCommand; -import com.cloud.agent.api.routing.LoadBalancerConfigCommand; -import com.cloud.agent.api.routing.SavePasswordCommand; -import com.cloud.agent.api.routing.SetFirewallRulesCommand; -import com.cloud.agent.api.routing.SetPortForwardingRulesCommand; -import com.cloud.agent.api.routing.SetStaticNatRulesCommand; -import com.cloud.agent.api.routing.VmDataCommand; -import com.cloud.agent.api.storage.CopyVolumeCommand; -import com.cloud.agent.api.storage.CreateCommand; -import com.cloud.agent.api.storage.DeleteTemplateCommand; -import com.cloud.agent.api.storage.DestroyCommand; -import com.cloud.agent.api.storage.DownloadCommand; -import com.cloud.agent.api.storage.DownloadProgressCommand; -import com.cloud.agent.api.storage.ListTemplateCommand; -import com.cloud.agent.api.storage.ListVolumeCommand; -import com.cloud.agent.api.storage.PrimaryStorageDownloadCommand; +import com.cloud.agent.api.routing.*; +import com.cloud.agent.api.storage.*; import com.cloud.simulator.MockConfigurationVO; import com.cloud.simulator.MockHost; import com.cloud.simulator.MockVMVO; @@ -95,7 +34,16 @@ import com.cloud.utils.db.DB; import com.cloud.utils.db.Transaction; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.vm.VirtualMachine.State; +import org.apache.log4j.Logger; +import org.springframework.stereotype.Component; +import javax.ejb.Local; +import javax.inject.Inject; +import javax.naming.ConfigurationException; +import java.util.HashMap; +import java.util.Map; + +@Component @Local(value = { SimulatorManager.class }) public class SimulatorManagerImpl extends ManagerBase implements SimulatorManager { private static final Logger s_logger = Logger.getLogger(SimulatorManagerImpl.class); diff --git a/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorDiscoverer.java b/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorDiscoverer.java index 5cb094184ba..00fe356103b 100755 --- a/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorDiscoverer.java +++ b/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorDiscoverer.java @@ -53,7 +53,7 @@ import com.cloud.storage.VMTemplateZoneVO; import com.cloud.storage.dao.VMTemplateDao; import com.cloud.storage.dao.VMTemplateHostDao; import com.cloud.storage.dao.VMTemplateZoneDao; - +import org.springframework.stereotype.Component; @Local(value = Discoverer.class) public class SimulatorDiscoverer extends DiscovererBase implements Discoverer, Listener, ResourceStateAdapter { diff --git a/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorSecondaryDiscoverer.java b/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorSecondaryDiscoverer.java index cd0cd2725c9..1dd71c5c27f 100644 --- a/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorSecondaryDiscoverer.java +++ b/plugins/hypervisors/simulator/src/com/cloud/resource/SimulatorSecondaryDiscoverer.java @@ -42,7 +42,9 @@ import com.cloud.storage.SnapshotVO; import com.cloud.storage.dao.SnapshotDao; import com.cloud.storage.secondary.SecondaryStorageDiscoverer; import com.cloud.utils.exception.CloudRuntimeException; +import org.springframework.stereotype.Component; +@Component @Local(value=Discoverer.class) public class SimulatorSecondaryDiscoverer extends SecondaryStorageDiscoverer implements ResourceStateAdapter, Listener { private static final Logger s_logger = Logger.getLogger(SimulatorSecondaryDiscoverer.class); diff --git a/plugins/hypervisors/simulator/src/com/cloud/simulator/SimulatorGuru.java b/plugins/hypervisors/simulator/src/com/cloud/simulator/SimulatorGuru.java index c9d308023ed..57a38f1d3d8 100644 --- a/plugins/hypervisors/simulator/src/com/cloud/simulator/SimulatorGuru.java +++ b/plugins/hypervisors/simulator/src/com/cloud/simulator/SimulatorGuru.java @@ -16,9 +16,6 @@ // under the License. package com.cloud.simulator; -import javax.ejb.Local; -import javax.inject.Inject; - import com.cloud.agent.api.to.VirtualMachineTO; import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.hypervisor.HypervisorGuru; @@ -28,6 +25,10 @@ import com.cloud.storage.dao.GuestOSDao; import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachineProfile; +import javax.ejb.Local; +import javax.inject.Inject; + + @Local(value=HypervisorGuru.class) public class SimulatorGuru extends HypervisorGuruBase implements HypervisorGuru { @Inject GuestOSDao _guestOsDao; diff --git a/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockConfigurationDaoImpl.java b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockConfigurationDaoImpl.java index bd1b48dfde8..fd825b751ed 100644 --- a/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockConfigurationDaoImpl.java +++ b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockConfigurationDaoImpl.java @@ -16,18 +16,19 @@ // under the License. package com.cloud.simulator.dao; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.util.Formatter; - -import javax.ejb.Local; - import com.cloud.simulator.MockConfigurationVO; import com.cloud.utils.db.GenericDaoBase; import com.cloud.utils.db.SearchBuilder; import com.cloud.utils.db.SearchCriteria; import com.cloud.utils.db.Transaction; +import org.springframework.stereotype.Component; +import javax.ejb.Local; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.util.Formatter; + +@Component @Local(value={MockConfigurationDao.class}) public class MockConfigurationDaoImpl extends GenericDaoBase implements MockConfigurationDao { private SearchBuilder _searchByDcIdName; diff --git a/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockHostDaoImpl.java b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockHostDaoImpl.java index 8a566d79ed2..4b60bc02d47 100644 --- a/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockHostDaoImpl.java +++ b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockHostDaoImpl.java @@ -16,14 +16,16 @@ // under the License. package com.cloud.simulator.dao; -import javax.ejb.Local; - import com.cloud.simulator.MockHost; import com.cloud.simulator.MockHostVO; import com.cloud.utils.db.GenericDaoBase; import com.cloud.utils.db.SearchBuilder; import com.cloud.utils.db.SearchCriteria; +import org.springframework.stereotype.Component; +import javax.ejb.Local; + +@Component @Local(value={MockHostDao.class}) public class MockHostDaoImpl extends GenericDaoBase implements MockHostDao { protected final SearchBuilder GuidSearch; diff --git a/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockSecStorageDaoImpl.java b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockSecStorageDaoImpl.java index 65a375f5843..d4903244179 100644 --- a/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockSecStorageDaoImpl.java +++ b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockSecStorageDaoImpl.java @@ -16,13 +16,15 @@ // under the License. package com.cloud.simulator.dao; -import javax.ejb.Local; - import com.cloud.simulator.MockSecStorageVO; import com.cloud.utils.db.GenericDaoBase; import com.cloud.utils.db.SearchBuilder; import com.cloud.utils.db.SearchCriteria; +import org.springframework.stereotype.Component; +import javax.ejb.Local; + +@Component @Local(value={MockSecStorageDao.class}) public class MockSecStorageDaoImpl extends GenericDaoBase implements MockSecStorageDao { protected final SearchBuilder urlSearch; diff --git a/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockSecurityRulesDaoImpl.java b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockSecurityRulesDaoImpl.java index 8831efef2ec..d35607e0ebc 100644 --- a/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockSecurityRulesDaoImpl.java +++ b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockSecurityRulesDaoImpl.java @@ -16,16 +16,18 @@ // under the License. package com.cloud.simulator.dao; -import java.util.List; -import java.util.Map; - -import javax.ejb.Local; -import javax.naming.ConfigurationException; - import com.cloud.simulator.MockSecurityRulesVO; import com.cloud.utils.db.GenericDaoBase; import com.cloud.utils.db.SearchBuilder; import com.cloud.utils.db.SearchCriteria; +import org.springframework.stereotype.Component; + +import javax.ejb.Local; +import javax.naming.ConfigurationException; +import java.util.List; +import java.util.Map; + +@Component @Local(value={MockSecurityRulesDao.class}) public class MockSecurityRulesDaoImpl extends GenericDaoBase implements MockSecurityRulesDao { protected SearchBuilder vmIdSearch; diff --git a/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockStoragePoolDaoImpl.java b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockStoragePoolDaoImpl.java index 3a64d27e30d..0fc41abdc4c 100644 --- a/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockStoragePoolDaoImpl.java +++ b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockStoragePoolDaoImpl.java @@ -16,14 +16,16 @@ // under the License. package com.cloud.simulator.dao; -import javax.ejb.Local; - import com.cloud.simulator.MockStoragePoolVO; import com.cloud.storage.Storage.StoragePoolType; import com.cloud.utils.db.GenericDaoBase; import com.cloud.utils.db.SearchBuilder; import com.cloud.utils.db.SearchCriteria; +import org.springframework.stereotype.Component; +import javax.ejb.Local; + +@Component @Local(value={MockStoragePoolDao.class}) public class MockStoragePoolDaoImpl extends GenericDaoBase implements MockStoragePoolDao { protected final SearchBuilder uuidSearch; diff --git a/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockVMDaoImpl.java b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockVMDaoImpl.java index be7a98859e2..5a8c66d69ef 100644 --- a/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockVMDaoImpl.java +++ b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockVMDaoImpl.java @@ -16,14 +16,6 @@ // under the License. package com.cloud.simulator.dao; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import javax.ejb.Local; -import javax.inject.Inject; -import javax.naming.ConfigurationException; - import com.cloud.simulator.MockHostVO; import com.cloud.simulator.MockVMVO; import com.cloud.utils.db.GenericDaoBase; @@ -31,7 +23,16 @@ import com.cloud.utils.db.JoinBuilder; import com.cloud.utils.db.SearchBuilder; import com.cloud.utils.db.SearchCriteria; import com.cloud.vm.VirtualMachine; +import org.springframework.stereotype.Component; +import javax.ejb.Local; +import javax.inject.Inject; +import javax.naming.ConfigurationException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +@Component @Local(value={MockVMDao.class}) public class MockVMDaoImpl extends GenericDaoBase implements MockVMDao { protected SearchBuilder GuidSearch; diff --git a/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockVolumeDaoImpl.java b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockVolumeDaoImpl.java index a3a35179337..5d64a9fa246 100644 --- a/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockVolumeDaoImpl.java +++ b/plugins/hypervisors/simulator/src/com/cloud/simulator/dao/MockVolumeDaoImpl.java @@ -16,10 +16,6 @@ // under the License. package com.cloud.simulator.dao; -import java.util.List; - -import javax.ejb.Local; - import com.cloud.simulator.MockVolumeVO; import com.cloud.simulator.MockVolumeVO.MockVolumeType; import com.cloud.utils.db.GenericDaoBase; @@ -27,7 +23,12 @@ import com.cloud.utils.db.GenericSearchBuilder; import com.cloud.utils.db.SearchBuilder; import com.cloud.utils.db.SearchCriteria; import com.cloud.utils.db.SearchCriteria.Func; +import org.springframework.stereotype.Component; +import javax.ejb.Local; +import java.util.List; + +@Component @Local(value={MockVolumeDao.class}) public class MockVolumeDaoImpl extends GenericDaoBase implements MockVolumeDao { protected final SearchBuilder idTypeSearch;