This commit is contained in:
Isaac Chiang 2013-07-24 16:38:41 +08:00
commit 11f134c246
109 changed files with 3883 additions and 2021 deletions

View File

@ -80,3 +80,5 @@ The following provides more details on the included cryptographic software:
CloudStack has a dependency on Apache WSS4J as part of the AWSAPI implementation. CloudStack has a dependency on Apache WSS4J as part of the AWSAPI implementation.
CloudStack has a dependency on and makes use of JSch - a java SSH2 implementation. CloudStack has a dependency on and makes use of JSch - a java SSH2 implementation.

View File

@ -16,9 +16,9 @@
// under the License. // under the License.
package com.cloud.ha; package com.cloud.ha;
import com.cloud.host.HostVO; import com.cloud.host.Host;
import com.cloud.utils.component.Adapter; import com.cloud.utils.component.Adapter;
import com.cloud.vm.VMInstanceVO; import com.cloud.vm.VirtualMachine;
public interface FenceBuilder extends Adapter { public interface FenceBuilder extends Adapter {
/** /**
@ -27,5 +27,5 @@ public interface FenceBuilder extends Adapter {
* @param vm vm * @param vm vm
* @param host host where the vm was running on. * @param host host where the vm was running on.
*/ */
public Boolean fenceOff(VMInstanceVO vm, HostVO host); public Boolean fenceOff(VirtualMachine vm, Host host);
} }

View File

@ -16,10 +16,10 @@
// under the License. // under the License.
package com.cloud.ha; package com.cloud.ha;
import com.cloud.host.HostVO; import com.cloud.host.Host;
import com.cloud.host.Status; import com.cloud.host.Status;
import com.cloud.utils.component.Adapter; import com.cloud.utils.component.Adapter;
import com.cloud.vm.VMInstanceVO; import com.cloud.vm.VirtualMachine;
public interface Investigator extends Adapter { public interface Investigator extends Adapter {
/** /**
@ -27,7 +27,7 @@ public interface Investigator extends Adapter {
* *
* @param vm to work on. * @param vm to work on.
*/ */
public Boolean isVmAlive(VMInstanceVO vm, HostVO host); public Boolean isVmAlive(VirtualMachine vm, Host host);
public Status isAgentAlive(HostVO agent); public Status isAgentAlive(Host agent);
} }

View File

@ -93,6 +93,9 @@ public interface Volume extends ControlledEntity, Identity, InternalIdentity, Ba
s_fsm.addTransition(UploadOp, Event.OperationSucceeded, Uploaded); s_fsm.addTransition(UploadOp, Event.OperationSucceeded, Uploaded);
s_fsm.addTransition(UploadOp, Event.OperationFailed, Allocated); s_fsm.addTransition(UploadOp, Event.OperationFailed, Allocated);
s_fsm.addTransition(Uploaded, Event.DestroyRequested, Destroy); s_fsm.addTransition(Uploaded, Event.DestroyRequested, Destroy);
s_fsm.addTransition(Expunged, Event.ExpungingRequested, Expunged);
s_fsm.addTransition(Expunged, Event.OperationSucceeded, Expunged);
s_fsm.addTransition(Expunged, Event.OperationFailed, Expunged);
} }
} }

View File

@ -158,7 +158,7 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, I
} }
} }
public static final String IsDynamicScalingEnabled = "enable.dynamic.scaling"; static final String IsDynamicScalingEnabled = "enable.dynamic.scaling";
public enum Event { public enum Event {
CreateRequested, CreateRequested,
@ -182,27 +182,28 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, I
}; };
public enum Type { public enum Type {
User, User(false),
DomainRouter, DomainRouter(true),
ConsoleProxy, ConsoleProxy(true),
SecondaryStorageVm, SecondaryStorageVm(true),
ElasticIpVm, ElasticIpVm(true),
ElasticLoadBalancerVm, ElasticLoadBalancerVm(true),
InternalLoadBalancerVm, InternalLoadBalancerVm(true),
/* /*
* UserBareMetal is only used for selecting VirtualMachineGuru, there is no * UserBareMetal is only used for selecting VirtualMachineGuru, there is no
* VM with this type. UserBareMetal should treat exactly as User. * VM with this type. UserBareMetal should treat exactly as User.
*/ */
UserBareMetal; UserBareMetal(false);
public static boolean isSystemVM(VirtualMachine.Type vmtype) { boolean _isUsedBySystem;
if (DomainRouter.equals(vmtype)
|| ConsoleProxy.equals(vmtype) private Type(boolean isUsedBySystem) {
|| SecondaryStorageVm.equals(vmtype) || InternalLoadBalancerVm.equals(vmtype)) { _isUsedBySystem = isUsedBySystem;
return true;
} }
return false;
public boolean isUsedBySystem() {
return _isUsedBySystem;
} }
} }
@ -211,39 +212,39 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, I
* reference this VM. You can build names that starts with this name and it * reference this VM. You can build names that starts with this name and it
* guarantees uniqueness for things related to the VM. * guarantees uniqueness for things related to the VM.
*/ */
public String getInstanceName(); String getInstanceName();
/** /**
* @return the host name of the virtual machine. If the user did not * @return the host name of the virtual machine. If the user did not
* specify the host name when creating the virtual machine then it is * specify the host name when creating the virtual machine then it is
* defaults to the instance name. * defaults to the instance name.
*/ */
public String getHostName(); String getHostName();
/** /**
* @return the ip address of the virtual machine. * @return the ip address of the virtual machine.
*/ */
public String getPrivateIpAddress(); String getPrivateIpAddress();
/** /**
* @return mac address. * @return mac address.
*/ */
public String getPrivateMacAddress(); String getPrivateMacAddress();
/** /**
* @return password of the host for vnc purposes. * @return password of the host for vnc purposes.
*/ */
public String getVncPassword(); String getVncPassword();
/** /**
* @return the state of the virtual machine * @return the state of the virtual machine
*/ */
// public State getState(); // State getState();
/** /**
* @return template id. * @return template id.
*/ */
public long getTemplateId(); long getTemplateId();
@ -252,49 +253,51 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, I
* *
* @return guestOSId * @return guestOSId
*/ */
public long getGuestOSId(); long getGuestOSId();
/** /**
* @return pod id. * @return pod id.
*/ */
public Long getPodIdToDeployIn(); Long getPodIdToDeployIn();
/** /**
* @return data center id. * @return data center id.
*/ */
public long getDataCenterId(); long getDataCenterId();
/** /**
* @return id of the host it was assigned last time. * @return id of the host it was assigned last time.
*/ */
public Long getLastHostId(); Long getLastHostId();
@Override @Override
public Long getHostId(); Long getHostId();
/** /**
* @return should HA be enabled for this machine? * @return should HA be enabled for this machine?
*/ */
public boolean isHaEnabled(); boolean isHaEnabled();
/** /**
* @return should limit CPU usage to the service offering? * @return should limit CPU usage to the service offering?
*/ */
public boolean limitCpuUse(); boolean limitCpuUse();
/** /**
* @return date when machine was created * @return date when machine was created
*/ */
public Date getCreated(); Date getCreated();
public long getServiceOfferingId(); long getServiceOfferingId();
public Long getDiskOfferingId(); Long getDiskOfferingId();
Type getType(); Type getType();
HypervisorType getHypervisorType(); HypervisorType getHypervisorType();
public Map<String, String> getDetails(); Map<String, String> getDetails();
long getUpdated();
} }

View File

@ -22,6 +22,7 @@ label.disk.iops.min=Min IOPS
label.disk.iops.max=Max IOPS label.disk.iops.max=Max IOPS
label.disk.iops.total=IOPS Total label.disk.iops.total=IOPS Total
label.view.secondary.ips=View secondary IPs label.view.secondary.ips=View secondary IPs
message.validate.invalid.characters=Invalid characters found; please correct.
message.acquire.ip.nic=Please confirm that you would like to acquire a new secondary IP for this NIC.<br/>NOTE: You need to manually configure the newly-acquired secondary IP inside the virtual machine. message.acquire.ip.nic=Please confirm that you would like to acquire a new secondary IP for this NIC.<br/>NOTE: You need to manually configure the newly-acquired secondary IP inside the virtual machine.
message.select.affinity.groups=Please select any affinity groups you want this VM to belong to: message.select.affinity.groups=Please select any affinity groups you want this VM to belong to:
message.no.affinity.groups=You do not have any affinity groups. Please continue to the next step. message.no.affinity.groups=You do not have any affinity groups. Please continue to the next step.

View File

@ -729,7 +729,6 @@
<bean id="clusteredVirtualMachineManagerImpl" class="com.cloud.vm.ClusteredVirtualMachineManagerImpl" > <bean id="clusteredVirtualMachineManagerImpl" class="com.cloud.vm.ClusteredVirtualMachineManagerImpl" >
<property name="HostAllocators" value="#{hostAllocators.Adapters}" /> <property name="HostAllocators" value="#{hostAllocators.Adapters}" />
<property name="Planners" value="#{deploymentPlanners.Adapters}" />
</bean> </bean>
<bean id="networkManagerImpl" class="com.cloud.network.NetworkManagerImpl" > <bean id="networkManagerImpl" class="com.cloud.network.NetworkManagerImpl" >

File diff suppressed because it is too large Load Diff

View File

@ -23,6 +23,317 @@
--> -->
<section id="gsoc-midsummer-ian"> <section id="gsoc-midsummer-ian">
<title>Mid-Summer Progress Updates</title> <title>Mid-Summer Progress Updates for Ian Duffy - "Ldap User Provisioning"</title>
<para>This section describes ...</para> <para>This section describes my progress with the project titled "LDAP User Provisioning".</para>
<section id="introduction">
<title>Introduction</title>
<para>
Progress on my project is moving along smoothly. The Cloudstack community along with my mentor Abhi have been very accomodating. Since the community bonding period communication has been consistent and the expectations have been clear. Sebastien, head mentor has given us great guidance. I have enjoyed their teaching style. I found it was a nice gradual build up starting with creating a simple document update patch to eventually submitting a new Cloudstack Plugin.
</para>
<para>
I am pleased with my progress on the project to date. I feel as if the goals set out in my proposal are very doable and that they should be achieved.
</para>
</section>
<section id="jenkins">
<title>Continuous Integration with Jenkins</title>
<para>
In order to try deliver working solutions of good quality I felt it would be a good idea to implement a continuous integration environment using Jenkins. The idea of this would be to automatically build and test my code. This was welcomed and aided by community members greatly.
</para>
<para>
The pipeline for this is as follows:
</para>
<mediaobject>
<imageobject>
<imagedata fileref="./images/jenkins-pipeline.png"/>
</imageobject>
<textobject>
<phrase>jenkins-pipeline.png: Screenshot of the build pipeline.</phrase>
</textobject>
</mediaobject>
<itemizedlist>
<listitem>
<para>
Acquire Code Base - This pulls down the latest Cloudstack codebase and builds it executing all unit tests.
</para>
</listitem>
<listitem>
<para>
Static Analysis - This runs tests on my code to ensure quality and good practice. This is being achieved with sonar source.
</para>
</listitem>
<listitem>
<para>
Integration Tests - This deploys the Cloudstack database. Brings up the Cloudstack Manager with jetty and their simulator. All checkin/integration tests are ran and then the jetty server is shutdown.
</para>
</listitem>
<listitem>
<para>
Package(Only exists on my local Jenkins) - The codebase is packaged up into an RPM and placed onto a local yum repo. If the time allows this will be used for future automated acceptance testing.
</para>
</listitem>
</itemizedlist>
<para>
If your are interested in this I have created a screencast on youtube which walks through it: <ulink url="http://www.youtube.com/watch?v=8k9IS3wMRok"><citetitle>Continuous testing environment</citetitle></ulink>
</para>
</section>
<section id="ldap-plugin-implementation">
<title>Ldap Plugin implementation</title>
<para>
At the start of the coding stage I began to review the current LDAP implementation. This includes:
</para>
<itemizedlist>
<listitem>
<para>
The user authenticator - This enables LDAP users to login to Cloudstack once the user exists within the internal Cloudstack database.
</para>
</listitem>
<listitem>
<para>
LDAPConfig -This allows for adding LDAP configuration. This is detailed over here: <ulink url="https://cloudstack.apache.org/docs/api/apidocs-4.1/root_admin/ldapConfig.html"><citetitle>ldapConfig API reference</citetitle></ulink> This did not allow multiple configurations.
</para>
</listitem>
<listitem>
<para>
LDAPRemove - This allows for removing the LDAP configuration
</para>
</listitem>
<listitem>
<para>
UI features. Global settings -> LDAP configuration allowed for the addition of a single LDAP server using the LDAPConfig command and the removal of an LDAP server using the LDAPRemove command.
</para>
</listitem>
</itemizedlist>
<para>
After reviewing this code and implementation for some time I realised that it wasn't the most maintainable code. I realised I could extend it if required. But it would involve creating more unmaintainable code and it would be messy. This goes against my own principles of developing quality. This made me make the steep but justified decision to completely redo the LDAP implementation within Cloudstack. By doing this I did expanded the scope of the project.
</para>
<para>
I began to research the most appropriate way of structuring this. I started of by redoing the implementation. This meant creating the following classes(Excluding DAOs):
</para>
<itemizedlist>
<listitem>
<para>
LdapManager: Manages all LDAP connections.
</para>
</listitem>
<listitem>
<para>
LdapConfiguration: Supplies all configuration from within the Cloudstack database or defaults where required.
</para>
</listitem>
<listitem>
<para>
LdapUserManager: Handles any interaction with LDAP user information.
</para>
</listitem>
<listitem>
<para>
LdapUtils: Supplies static helpers, e.g. escape search queries, get attributes from search queries.
</para>
</listitem>
<listitem>
<para>
LdapContextFactory: Manages the creation of contexts.
</para>
</listitem>
<listitem>
<para>
LdapAuthenticator: Supplies an authenticator to Cloudstack using the LdapManager.
</para>
</listitem>
</itemizedlist>
<para>
From this I had a solid foundation for creating API commands to allow the user to interact with an LDAP server. I went on to create the following commands:
</para>
<itemizedlist>
<listitem>
<para>
LdapAddConfiguration - This allows for adding multiple LDAP configurations. Each configuration is just seen as a hostname and port.
</para>
<mediaobject>
<imageobject>
<imagedata fileref="./images/add-ldap-configuration.png"/>
</imageobject>
<textobject>
<phrase>add-ldap-configuration.png: Screenshot of API response.</phrase>
</textobject>
</mediaobject>
<mediaobject>
<imageobject>
<imagedata fileref="./images/add-ldap-configuration-failure.png"/>
</imageobject>
<textobject>
<phrase>add-ldap-configuration-failure.png: Screenshot of API response.</phrase>
</textobject>
</mediaobject>
</listitem>
<listitem>
<para>
LdapDeleteConfiguration - This allows for the deletion of an LDAP configuration based on its hostname.
</para>
<mediaobject>
<imageobject>
<imagedata fileref="./images/delete-ldap-configuration.png"/>
</imageobject>
<textobject>
<phrase>delete-ldap-configuration.png: Screenshot of API response.</phrase>
</textobject>
</mediaobject>
<mediaobject>
<imageobject>
<imagedata fileref="./images/delete-ldap-configuration-failure.png"/>
</imageobject>
<textobject>
<phrase>delete-ldap-configuration-failure.png: Screenshot of API response.</phrase>
</textobject>
</mediaobject>
</listitem>
<listitem>
<para>
LdapListConfiguration - This lists all of the LDAP configurations that exist within the database.
</para>
<mediaobject>
<imageobject>
<imagedata fileref="./images/list-ldap-configuration.png"/>
</imageobject>
<textobject>
<phrase>list-ldap-configuration.png: Screenshot of the build pipeline.</phrase>
</textobject>
</mediaobject>
</listitem>
<listitem>
<para>
LdapListAllUsers - This lists all the users within LDAP.
</para>
<mediaobject>
<imageobject>
<imagedata fileref="./images/ldap-list-users.png"/>
</imageobject>
<textobject>
<phrase>ldap-list-users.png: Screenshot of the build pipeline.</phrase>
</textobject>
</mediaobject>
</listitem>
</itemizedlist>
<para>
Along with this global configuration options were added, this includes:
</para>
<itemizedlist>
<listitem>
<para>
LDAP basedn: This allows the user to set the basedn for their LDAP configuration
</para>
</listitem>
<listitem>
<para>
LDAP bind password: This allows the user to set the password to use for binding to LDAP for creating the system context. If this is left blank along with bind principal then anonymous binding is used.
</para>
</listitem>
<listitem>
<para>
LDAP bind principal: This allows the user to set the principle to use for binding with LDAP for creating the system context. If this is left blank along with the bind password then anonymous binding is used.
</para>
</listitem>
<listitem>
<para>
LDAP email attribute: This sets out the attribute to use for getting the users email address. Within both OpenLDAP and ActiveDirectory this is mail. For this reason this is set to mail by default.
</para>
</listitem>
<listitem>
<para>
LDAP realname attribute: This sets out the attribute to use for getting the users realname. Within both OpenLDAP and ActiveDiretory this is cn. For this reason this is set to cn by default.
</para>
</listitem>
<listitem>
<para>
LDAP username attribute: This sets out the attribute to use for getting the users username. Within OpenLDAP this is uid and within ActiveDirectory this is samAccountName. In order to comply with posix standards this is set as uid by default.
</para>
</listitem>
<listitem>
<para>
LDAP user object: This sets out the object type of user accounts within LDAP. Within OpenLDAP this is inetOrgPerson and within ActiveDirectory this is user. Again, in order to comply with posix standards this is set as inetOrgperson by default.
</para>
</listitem>
</itemizedlist>
<para>
With this implementation I believe it allows for a much more extendable and flexible approach. The whole implementation is abstracted from the Cloudstack codebase using the "plugin" model. This allows all of the LDAP features to be contained within one place. Along with this the implementation supplies a good foundation. A side affect of redoing the implementation allowed me to add support for multiple LDAP servers. This means failover is support, so for example, if you have a standard ActiveDirectory with primary and secondary domain controller. Both can be added to Cloudstack which will allow it to failover to either one assume one of them is down.
</para>
<para>
The API changes required me to update the UI interface within Cloudstack. With the improved API implementation this was easier. The Global Settings -> Ldap Configuration page has support for multiple LDAP servers however it only requires a hostname and port. All "global" ldap settings are set within the global settings page.
</para>
<mediaobject>
<imageobject>
<imagedata fileref="./images/ldap-global-settings.png"/>
</imageobject>
<textobject>
<phrase>ldap-global-settings.png: Screenshot the LDAP related settings within global settings.</phrase>
</textobject>
</mediaobject>
<mediaobject>
<imageobject>
<imagedata fileref="./images/ldap-configuration.png"/>
</imageobject>
<textobject>
<phrase>ldap-configuration.png: Screenshot of the LDAP configuration page.</phrase>
</textobject>
</mediaobject>
</section>
<section id="accounts-ui">
<title>Add accounts UI</title>
<para>
Extending the UI to allow for easy provisioning of LDAP users is currently a work in progress. At the moment I have a 'working' implementation, see below screenshot. I am in need of assistance with it and am waiting on a review to be looked at.
</para>
<mediaobject>
<imageobject>
<imagedata fileref="./images/ldap-account-addition.png"/>
</imageobject>
<textobject>
<phrase>ldap-account-addition.png: Screenshot of add user screen when LDAP is enabled.</phrase>
</textobject>
</mediaobject>
</section>
<section id="testing">
<title>Testing</title>
<para>
Unit tests have 92% code coverage within the LDAP Plugin. The unit tests were wrote in groovy using the spock framework. This allowed for a BDD style of of testing.
</para>
<para>
Integration tests have been wrote in python using the marvin test framework for Cloudstack. This test configures a LDAP server and attempts to login as an LDAP user. The plugin comes with an embedded LDAP server for testing purposes.
</para>
<para>Execute integration tests:</para>
<programlisting>nosetests --with-marvin --marvin-config=setup/dev/local.cfg test/integration/component/test_ldap.py --loa</programlisting>
<para>Start embedded LDAP server:</para>
<programlisting>mvn -pl :cloud-plugin-user-authenticator-ldap ldap:run</programlisting>
</section>
<section id="conclusion">
<title>Conclusion</title>
<para>
I am very pleased with the learning outcomes of this project so far. I have been exposed to many things that my college's computer science curriculum does not cover. This includes:
</para>
<itemizedlist>
<listitem>
<para>Usage of source control management tools(git) and dealing with code collaboration</para>
</listitem>
<listitem>
<para>Usage of a dependency manager and build tool(maven)</para>
</listitem>
<listitem>
<para>Usage of continous testing environments(jenkins)</para>
</listitem>
<listitem>
<para>Usage of an IDE(eclipse)</para>
</listitem>
<listitem>
<para>Exposure to testing, both unit and integration tests</para>
</listitem>
<listitem>
<para>Exposure to a functional programming language(groovy)</para>
</listitem>
<listitem>
<para>Exposure to web development libraries(jQuery)</para>
</listitem>
</itemizedlist>
<para>
The experience gained from this project is invalueable and it is great that the Google Summer Of Code program exist.
</para>
</section>
</section> </section>

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

View File

@ -0,0 +1,144 @@
<?xml version='1.0' encoding='utf-8' ?>
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
<!ENTITY % BOOK_ENTITIES SYSTEM "cloudstack.ent">
%BOOK_ENTITIES;
]>
<!-- 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.
-->
<section id="removed-api-4.2">
<title>Removed APIs</title>
<itemizedlist>
<listitem>
<para>deleteCiscoNexusVSM (Deletes a Cisco Nexus VSM device) </para>
</listitem>
<listitem>
<para>enableCiscoNexusVSM (Enables a Cisco Nexus VSM device) </para>
</listitem>
<listitem>
<para>disableCiscoNexusVSM (Disables a Cisco Nexus VSM device) </para>
</listitem>
<listitem>
<para>listCiscoNexusVSMs (Retrieves a Cisco Nexus 1000v Virtual Switch Manager device
associated with a Cluster) </para>
</listitem>
<listitem>
<para>addBaremetalHost (Adds a new host.) </para>
</listitem>
<listitem>
<para>addExternalFirewall (Adds an external firewall appliance) </para>
</listitem>
<listitem>
<para>deleteExternalFirewall (Deletes an external firewall appliance.) </para>
</listitem>
<listitem>
<para>listExternalFirewalls (Lists external firewall appliances.) </para>
</listitem>
<listitem>
<para>addExternalLoadBalancer (Adds F5 external load balancer appliance.) </para>
</listitem>
<listitem>
<para>deleteExternalLoadBalancer (Deletes a F5 external load balancer appliance added in a
zone.) </para>
</listitem>
<listitem>
<para>listExternalLoadBalancers (Lists F5 external load balancer appliances added in a
zone.) </para>
</listitem>
<listitem>
<para>createVolumeOnFiler (Creates a volume.) </para>
</listitem>
<listitem>
<para>destroyVolumeOnFiler (Destroys a volume.) </para>
</listitem>
<listitem>
<para>listVolumesOnFiler (Lists volumes.) </para>
</listitem>
<listitem>
<para>createLunOnFiler (Creates a LUN from a pool.) </para>
</listitem>
<listitem>
<para>destroyLunOnFiler (Destroys a LUN.) </para>
</listitem>
<listitem>
<para>listLunsOnFiler (Lists LUN.) </para>
</listitem>
<listitem>
<para>associateLun (Associates a LUN with a guest IQN.) </para>
</listitem>
<listitem>
<para>dissociateLun (Dissociates a LUN.) </para>
</listitem>
<listitem>
<para>createPool (Creates a pool.) </para>
</listitem>
<listitem>
<para>deletePool (Deletes a pool.) </para>
</listitem>
<listitem>
<para>modifyPool (Modifies pool.) </para>
</listitem>
<listitem>
<para>listPools (Lists pool.) </para>
</listitem>
<listitem>
<para>addF5LoadBalancer (Adds a F5 BigIP load balancer device.) </para>
</listitem>
<listitem>
<para>configureF5LoadBalancer (Configures a F5 load balancer device.) </para>
</listitem>
<listitem>
<para>deleteF5LoadBalancer (Deletes a F5 load balancer device.) </para>
</listitem>
<listitem>
<para>listF5LoadBalancers (Lists F5 load balancer devices.) </para>
</listitem>
<listitem>
<para>listF5LoadBalancerNetworks (Lists network that are using a F5 load balancer device.)
</para>
</listitem>
<listitem>
<para>addSrxFirewall (Adds a SRX firewall device.) </para>
</listitem>
<listitem>
<para>deleteSrxFirewall (Deletes a SRX firewall device.) </para>
</listitem>
<listitem>
<para>configureSrxFirewall (Configures a SRX firewall device) </para>
</listitem>
<listitem>
<para>listSrxFirewalls (Lists SRX firewall devices in a physical network) </para>
</listitem>
<listitem>
<para>listSrxFirewallNetworks (Lists network that are using SRX firewall device) </para>
</listitem>
<listitem>
<para>addNetscalerLoadBalancer (Adds a netscaler load balancer device) </para>
</listitem>
<listitem>
<para>deleteNetscalerLoadBalancer (Deletes a netscaler load balancer device) </para>
</listitem>
<listitem>
<para>configureNetscalerLoadBalancer (Configures a netscaler load balancer device) </para>
</listitem>
<listitem>
<para>listNetscalerLoadBalancers (Lists netscaler load balancer devices) </para>
</listitem>
<listitem>
<para>listNetscalerLoadBalancerNetworks (Lists network that are using a netscaler load
balancer device) </para>
</listitem>
</itemizedlist>
</section>

View File

@ -25,6 +25,8 @@
<section id="whats-new-in-api-4.2"> <section id="whats-new-in-api-4.2">
<title>What's New in the API for 4.2</title> <title>What's New in the API for 4.2</title>
<xi:include href="added-API-commands-4.2.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> <xi:include href="added-API-commands-4.2.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="changed-API-commands-4.2.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
<xi:include href="removed-api-4.2.xml.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
</section> </section>
<section id="whats-new-in-api-4.1"> <section id="whats-new-in-api-4.1">
<title>What's New in the API for 4.1</title> <title>What's New in the API for 4.1</title>

View File

@ -22,11 +22,16 @@ import com.cloud.utils.fsm.StateObject;
public interface ObjectInDataStoreStateMachine extends StateObject<ObjectInDataStoreStateMachine.State> { public interface ObjectInDataStoreStateMachine extends StateObject<ObjectInDataStoreStateMachine.State> {
enum State { enum State {
Allocated("The initial state"), Creating2("This is only used with createOnlyRequested event"), Creating( Allocated("The initial state"),
"The object is being creating on data store"), Created("The object is created"), Ready( Creating2("This is only used with createOnlyRequested event"),
"Template downloading is accomplished"), Copying("The object is being coping"), Migrating( Creating("The object is being creating on data store"),
"The object is being migrated"), Destroying("Template is destroying"), Destroyed( Created("The object is created"),
"Template is destroyed"), Failed("Failed to download template"); Ready("Template downloading is accomplished"),
Copying("The object is being coping"),
Migrating("The object is being migrated"),
Destroying("Template is destroying"),
Destroyed("Template is destroyed"),
Failed("Failed to download template");
String _description; String _description;
private State(String description) { private State(String description) {
@ -39,7 +44,14 @@ public interface ObjectInDataStoreStateMachine extends StateObject<ObjectInDataS
} }
enum Event { enum Event {
CreateRequested, CreateOnlyRequested, DestroyRequested, OperationSuccessed, OperationFailed, CopyingRequested, MigrationRequested, ResizeRequested, ExpungeRequested CreateRequested,
CreateOnlyRequested,
DestroyRequested,
OperationSuccessed,
OperationFailed,
CopyingRequested,
MigrationRequested,
ResizeRequested,
ExpungeRequested
} }
} }

View File

@ -18,10 +18,14 @@
*/ */
package org.apache.cloudstack.engine.subsystem.api.storage; package org.apache.cloudstack.engine.subsystem.api.storage;
import com.cloud.storage.DataStoreRole;
public interface VolumeDataFactory { public interface VolumeDataFactory {
VolumeInfo getVolume(long volumeId, DataStore store); VolumeInfo getVolume(long volumeId, DataStore store);
VolumeInfo getVolume(DataObject volume, DataStore store); VolumeInfo getVolume(DataObject volume, DataStore store);
VolumeInfo getVolume(long volumeId, DataStoreRole storeRole);
VolumeInfo getVolume(long volumeId); VolumeInfo getVolume(long volumeId);
} }

View File

@ -245,17 +245,16 @@ public class VMEntityManagerImpl implements VMEntityManager {
@Override @Override
public boolean stopvirtualmachine(VMEntityVO vmEntityVO, String caller) throws ResourceUnavailableException { public boolean stopvirtualmachine(VMEntityVO vmEntityVO, String caller) throws ResourceUnavailableException {
_itMgr.stop(vmEntityVO.getUuid());
VMInstanceVO vm = _vmDao.findByUuid(vmEntityVO.getUuid()); return true;
return _itMgr.stop(vm, _userDao.findById(new Long(caller)), _accountDao.findById(vm.getAccountId()));
} }
@Override @Override
public boolean destroyVirtualMachine(VMEntityVO vmEntityVO, String caller) throws AgentUnavailableException, OperationTimedoutException, ConcurrentOperationException{ public boolean destroyVirtualMachine(VMEntityVO vmEntityVO, String caller) throws AgentUnavailableException, OperationTimedoutException, ConcurrentOperationException{
VMInstanceVO vm = _vmDao.findByUuid(vmEntityVO.getUuid()); VMInstanceVO vm = _vmDao.findByUuid(vmEntityVO.getUuid());
return _itMgr.destroy(vm, _userDao.findById(new Long(caller)), _accountDao.findById(vm.getAccountId())); _itMgr.destroy(vm.getUuid());
return true;
} }
} }

View File

@ -49,6 +49,8 @@ import org.apache.log4j.Logger;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.cloud.agent.api.Answer; import com.cloud.agent.api.Answer;
import com.cloud.agent.api.storage.MigrateVolumeAnswer;
import com.cloud.agent.api.storage.MigrateVolumeCommand;
import com.cloud.agent.api.to.DataObjectType; import com.cloud.agent.api.to.DataObjectType;
import com.cloud.agent.api.to.DataStoreTO; import com.cloud.agent.api.to.DataStoreTO;
import com.cloud.agent.api.to.DataTO; import com.cloud.agent.api.to.DataTO;
@ -64,6 +66,7 @@ import com.cloud.storage.DataStoreRole;
import com.cloud.storage.StorageManager; import com.cloud.storage.StorageManager;
import com.cloud.storage.StoragePool; import com.cloud.storage.StoragePool;
import com.cloud.storage.VolumeManager; import com.cloud.storage.VolumeManager;
import com.cloud.storage.VolumeVO;
import com.cloud.storage.dao.DiskOfferingDao; import com.cloud.storage.dao.DiskOfferingDao;
import com.cloud.storage.dao.SnapshotDao; import com.cloud.storage.dao.SnapshotDao;
import com.cloud.storage.dao.VMTemplateDao; import com.cloud.storage.dao.VMTemplateDao;
@ -330,6 +333,30 @@ public class AncientDataMotionStrategy implements DataMotionStrategy {
} }
protected Answer migrateVolumeToPool(DataObject srcData, DataObject destData) {
VolumeInfo volume = (VolumeInfo)srcData;
StoragePool destPool = (StoragePool)this.dataStoreMgr.getDataStore(destData.getDataStore().getId(), DataStoreRole.Primary);
MigrateVolumeCommand command = new MigrateVolumeCommand(volume.getId(), volume.getPath(), destPool);
EndPoint ep = selector.select(volume.getDataStore());
MigrateVolumeAnswer answer = (MigrateVolumeAnswer) ep.sendMessage(command);
if (answer == null || !answer.getResult()) {
throw new CloudRuntimeException("Failed to migrate volume " + volume + " to storage pool " + destPool);
} else {
// Update the volume details after migration.
VolumeVO volumeVo = this.volDao.findById(volume.getId());
Long oldPoolId = volume.getPoolId();
volumeVo.setPath(answer.getVolumePath());
volumeVo.setFolder(destPool.getPath());
volumeVo.setPodId(destPool.getPodId());
volumeVo.setPoolId(destPool.getId());
volumeVo.setLastPoolId(oldPoolId);
this.volDao.update(volume.getId(), volumeVo);
}
return answer;
}
@Override @Override
public Void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback) { public Void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback) {
Answer answer = null; Answer answer = null;
@ -347,7 +374,12 @@ public class AncientDataMotionStrategy implements DataMotionStrategy {
} else if (destData.getType() == DataObjectType.VOLUME && srcData.getType() == DataObjectType.VOLUME } else if (destData.getType() == DataObjectType.VOLUME && srcData.getType() == DataObjectType.VOLUME
&& srcData.getDataStore().getRole() == DataStoreRole.Primary && srcData.getDataStore().getRole() == DataStoreRole.Primary
&& destData.getDataStore().getRole() == DataStoreRole.Primary) { && destData.getDataStore().getRole() == DataStoreRole.Primary) {
if (srcData.getId() == destData.getId()) {
// The volume has to be migrated across storage pools.
answer = migrateVolumeToPool(srcData, destData);
} else {
answer = copyVolumeBetweenPools(srcData, destData); answer = copyVolumeBetweenPools(srcData, destData);
}
} else if (srcData.getType() == DataObjectType.SNAPSHOT && destData.getType() == DataObjectType.SNAPSHOT) { } else if (srcData.getType() == DataObjectType.SNAPSHOT && destData.getType() == DataObjectType.SNAPSHOT) {
answer = copySnapshot(srcData, destData); answer = copySnapshot(srcData, destData);
} else { } else {

View File

@ -51,6 +51,26 @@ public class VolumeDataFactoryImpl implements VolumeDataFactory {
return vol; return vol;
} }
@Override
public VolumeInfo getVolume(long volumeId, DataStoreRole storeRole) {
VolumeVO volumeVO = volumeDao.findById(volumeId);
VolumeObject vol = null;
if (storeRole == DataStoreRole.Image) {
VolumeDataStoreVO volumeStore = volumeStoreDao.findByVolume(volumeId);
if (volumeStore != null) {
DataStore store = this.storeMgr.getDataStore(volumeStore.getDataStoreId(), DataStoreRole.Image);
vol = VolumeObject.getVolumeObject(store, volumeVO);
}
} else {
// Primary data store
if (volumeVO.getPoolId() != null) {
DataStore store = this.storeMgr.getDataStore(volumeVO.getPoolId(), DataStoreRole.Primary);
vol = VolumeObject.getVolumeObject(store, volumeVO);
}
}
return vol;
}
@Override @Override
public VolumeInfo getVolume(long volumeId) { public VolumeInfo getVolume(long volumeId) {
VolumeVO volumeVO = volumeDao.findById(volumeId); VolumeVO volumeVO = volumeDao.findById(volumeId);

View File

@ -254,9 +254,8 @@ public class VolumeObject implements VolumeInfo {
} }
if (this.dataStore.getRole() == DataStoreRole.Image) { if (this.dataStore.getRole() == DataStoreRole.Image) {
objectInStoreMgr.update(this, event); objectInStoreMgr.update(this, event);
if (this.volumeVO.getState() == Volume.State.Migrating if (this.volumeVO.getState() == Volume.State.Migrating || this.volumeVO.getState() == Volume.State.Copying || this.volumeVO.getState() == Volume.State.Uploaded
|| this.volumeVO.getState() == Volume.State.Copying || this.volumeVO.getState() == Volume.State.Expunged) {
|| this.volumeVO.getState() == Volume.State.Uploaded) {
return; return;
} }
if (event == ObjectInDataStoreStateMachine.Event.CreateOnlyRequested) { if (event == ObjectInDataStoreStateMachine.Event.CreateOnlyRequested) {
@ -513,6 +512,7 @@ public class VolumeObject implements VolumeInfo {
} }
@Override
public void incRefCount() { public void incRefCount() {
if (this.dataStore == null) { if (this.dataStore == null) {
return; return;

View File

@ -75,6 +75,7 @@ import com.cloud.storage.StoragePool;
import com.cloud.storage.VMTemplateStoragePoolVO; import com.cloud.storage.VMTemplateStoragePoolVO;
import com.cloud.storage.VMTemplateStorageResourceAssoc; import com.cloud.storage.VMTemplateStorageResourceAssoc;
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status; import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
import com.cloud.storage.Volume.State;
import com.cloud.storage.Volume; import com.cloud.storage.Volume;
import com.cloud.storage.VolumeVO; import com.cloud.storage.VolumeVO;
import com.cloud.storage.dao.VMTemplatePoolDao; import com.cloud.storage.dao.VMTemplatePoolDao;
@ -210,13 +211,34 @@ public class VolumeServiceImpl implements VolumeService {
} }
} }
// check if a volume is expunged on both primary and secondary
private boolean canVolumeBeRemoved(long volumeId) {
VolumeVO vol = volDao.findById(volumeId);
if (vol == null) {
// already removed from volumes table
return false;
}
VolumeDataStoreVO volumeStore = _volumeStoreDao.findByVolume(volumeId);
if (vol.getState() == State.Expunged && volumeStore == null) {
// volume is expunged from primary, as well as on secondary
return true;
} else {
return false;
}
}
@DB @DB
@Override @Override
public AsyncCallFuture<VolumeApiResult> expungeVolumeAsync(VolumeInfo volume) { public AsyncCallFuture<VolumeApiResult> expungeVolumeAsync(VolumeInfo volume) {
AsyncCallFuture<VolumeApiResult> future = new AsyncCallFuture<VolumeApiResult>(); AsyncCallFuture<VolumeApiResult> future = new AsyncCallFuture<VolumeApiResult>();
VolumeApiResult result = new VolumeApiResult(volume); VolumeApiResult result = new VolumeApiResult(volume);
if (volume.getDataStore() == null) { if (volume.getDataStore() == null) {
s_logger.info("Expunge volume with no data store specified");
if (canVolumeBeRemoved(volume.getId())) {
s_logger.info("Volume " + volume.getId() + " is not referred anywhere, remove it from volumes table");
volDao.remove(volume.getId()); volDao.remove(volume.getId());
}
future.complete(result); future.complete(result);
return future; return future;
} }
@ -245,7 +267,11 @@ public class VolumeServiceImpl implements VolumeService {
} }
VolumeObject vo = (VolumeObject) volume; VolumeObject vo = (VolumeObject) volume;
if (volume.getDataStore().getRole() == DataStoreRole.Image) {
volume.processEvent(Event.DestroyRequested);
} else if (volume.getDataStore().getRole() == DataStoreRole.Primary) {
volume.processEvent(Event.ExpungeRequested); volume.processEvent(Event.ExpungeRequested);
}
DeleteVolumeContext<VolumeApiResult> context = new DeleteVolumeContext<VolumeApiResult>(null, vo, future); DeleteVolumeContext<VolumeApiResult> context = new DeleteVolumeContext<VolumeApiResult>(null, vo, future);
AsyncCallbackDispatcher<VolumeServiceImpl, CommandResult> caller = AsyncCallbackDispatcher.create(this); AsyncCallbackDispatcher<VolumeServiceImpl, CommandResult> caller = AsyncCallbackDispatcher.create(this);
@ -255,6 +281,7 @@ public class VolumeServiceImpl implements VolumeService {
return future; return future;
} }
public Void deleteVolumeCallback(AsyncCallbackDispatcher<VolumeServiceImpl, CommandResult> callback, public Void deleteVolumeCallback(AsyncCallbackDispatcher<VolumeServiceImpl, CommandResult> callback,
DeleteVolumeContext<VolumeApiResult> context) { DeleteVolumeContext<VolumeApiResult> context) {
CommandResult result = callback.getResult(); CommandResult result = callback.getResult();
@ -262,7 +289,10 @@ public class VolumeServiceImpl implements VolumeService {
VolumeApiResult apiResult = new VolumeApiResult(vo); VolumeApiResult apiResult = new VolumeApiResult(vo);
if (result.isSuccess()) { if (result.isSuccess()) {
vo.processEvent(Event.OperationSuccessed); vo.processEvent(Event.OperationSuccessed);
if (canVolumeBeRemoved(vo.getId())) {
s_logger.info("Volume " + vo.getId() + " is not referred anywhere, remove it from volumes table");
volDao.remove(vo.getId()); volDao.remove(vo.getId());
}
} else { } else {
vo.processEvent(Event.OperationFailed); vo.processEvent(Event.OperationFailed);
apiResult.setResult(result.getResult()); apiResult.setResult(result.getResult());

View File

@ -96,18 +96,16 @@ wait_for_dnsmasq () {
return 1 return 1
} }
if [ $ipv4 ] if [ $ipv6 ]
then then
ip=$ipv4 no_dhcp_release=1
else
ip=$ipv6
fi fi
if [ $no_dhcp_release -eq 0 ] if [ $no_dhcp_release -eq 0 ]
then then
#release previous dhcp lease if present #release previous dhcp lease if present
logger -t cloud "edithosts: releasing $ipv4" logger -t cloud "edithosts: releasing $ipv4"
dhcp_release eth0 $ip $(grep $ip $DHCP_LEASES | awk '{print $2}') > /dev/null 2>&1 dhcp_release eth0 $ipv4 $(grep "$ipv4 " $DHCP_LEASES | awk '{print $2}') > /dev/null 2>&1
logger -t cloud "edithosts: released $ipv4" logger -t cloud "edithosts: released $ipv4"
fi fi

View File

@ -31,12 +31,13 @@ import com.cloud.agent.api.FenceCommand;
import com.cloud.exception.AgentUnavailableException; import com.cloud.exception.AgentUnavailableException;
import com.cloud.exception.OperationTimedoutException; import com.cloud.exception.OperationTimedoutException;
import com.cloud.ha.FenceBuilder; import com.cloud.ha.FenceBuilder;
import com.cloud.host.Host;
import com.cloud.host.HostVO; import com.cloud.host.HostVO;
import com.cloud.host.Status; import com.cloud.host.Status;
import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.utils.component.AdapterBase;
import com.cloud.vm.VMInstanceVO;
import com.cloud.resource.ResourceManager; import com.cloud.resource.ResourceManager;
import com.cloud.utils.component.AdapterBase;
import com.cloud.vm.VirtualMachine;
@Local(value=FenceBuilder.class) @Local(value=FenceBuilder.class)
public class OvmFencer extends AdapterBase implements FenceBuilder { public class OvmFencer extends AdapterBase implements FenceBuilder {
@ -66,7 +67,7 @@ public class OvmFencer extends AdapterBase implements FenceBuilder {
} }
@Override @Override
public Boolean fenceOff(VMInstanceVO vm, HostVO host) { public Boolean fenceOff(VirtualMachine vm, Host host) {
if (host.getHypervisorType() != HypervisorType.Ovm) { if (host.getHypervisorType() != HypervisorType.Ovm) {
s_logger.debug("Don't know how to fence non Ovm hosts " + host.getHypervisorType()); s_logger.debug("Don't know how to fence non Ovm hosts " + host.getHypervisorType());
return null; return null;

View File

@ -16,20 +16,17 @@
// under the License. // under the License.
package com.cloud.ha; package com.cloud.ha;
import java.util.Map;
import javax.ejb.Local; import javax.ejb.Local;
import javax.naming.ConfigurationException;
import com.cloud.host.HostVO; import com.cloud.host.Host;
import com.cloud.utils.component.AdapterBase; import com.cloud.utils.component.AdapterBase;
import com.cloud.vm.VMInstanceVO; import com.cloud.vm.VirtualMachine;
@Local(value=FenceBuilder.class) @Local(value=FenceBuilder.class)
public class VmwareFencer extends AdapterBase implements FenceBuilder { public class VmwareFencer extends AdapterBase implements FenceBuilder {
@Override @Override
public Boolean fenceOff(VMInstanceVO vm, HostVO host) { public Boolean fenceOff(VirtualMachine vm, Host host) {
return null; return null;
} }

View File

@ -18,11 +18,11 @@ package com.cloud.ha;
import javax.ejb.Local; import javax.ejb.Local;
import com.cloud.host.HostVO; import com.cloud.host.Host;
import com.cloud.host.Status; import com.cloud.host.Status;
import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.utils.component.AdapterBase; import com.cloud.utils.component.AdapterBase;
import com.cloud.vm.VMInstanceVO; import com.cloud.vm.VirtualMachine;
@Local(value=Investigator.class) @Local(value=Investigator.class)
public class VmwareInvestigator extends AdapterBase implements Investigator { public class VmwareInvestigator extends AdapterBase implements Investigator {
@ -30,7 +30,7 @@ public class VmwareInvestigator extends AdapterBase implements Investigator {
} }
@Override @Override
public Status isAgentAlive(HostVO agent) { public Status isAgentAlive(Host agent) {
if(agent.getHypervisorType() == HypervisorType.VMware) if(agent.getHypervisorType() == HypervisorType.VMware)
return Status.Disconnected; return Status.Disconnected;
@ -38,7 +38,7 @@ public class VmwareInvestigator extends AdapterBase implements Investigator {
} }
@Override @Override
public Boolean isVmAlive(VMInstanceVO vm, HostVO host) { public Boolean isVmAlive(VirtualMachine vm, Host host) {
if(vm.getHypervisorType() == HypervisorType.VMware) if(vm.getHypervisorType() == HypervisorType.VMware)
return true; return true;

View File

@ -31,13 +31,14 @@ import com.cloud.agent.api.FenceAnswer;
import com.cloud.agent.api.FenceCommand; import com.cloud.agent.api.FenceCommand;
import com.cloud.exception.AgentUnavailableException; import com.cloud.exception.AgentUnavailableException;
import com.cloud.exception.OperationTimedoutException; import com.cloud.exception.OperationTimedoutException;
import com.cloud.host.Host;
import com.cloud.host.HostVO; import com.cloud.host.HostVO;
import com.cloud.host.Status; import com.cloud.host.Status;
import com.cloud.host.dao.HostDao; import com.cloud.host.dao.HostDao;
import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.resource.ResourceManager; import com.cloud.resource.ResourceManager;
import com.cloud.utils.component.AdapterBase; import com.cloud.utils.component.AdapterBase;
import com.cloud.vm.VMInstanceVO; import com.cloud.vm.VirtualMachine;
@Local(value=FenceBuilder.class) @Local(value=FenceBuilder.class)
public class XenServerFencer extends AdapterBase implements FenceBuilder { public class XenServerFencer extends AdapterBase implements FenceBuilder {
@ -49,7 +50,7 @@ public class XenServerFencer extends AdapterBase implements FenceBuilder {
@Inject ResourceManager _resourceMgr; @Inject ResourceManager _resourceMgr;
@Override @Override
public Boolean fenceOff(VMInstanceVO vm, HostVO host) { public Boolean fenceOff(VirtualMachine vm, Host host) {
if (host.getHypervisorType() != HypervisorType.XenServer) { if (host.getHypervisorType() != HypervisorType.XenServer) {
s_logger.debug("Don't know how to fence non XenServer hosts " + host.getHypervisorType()); s_logger.debug("Don't know how to fence non XenServer hosts " + host.getHypervisorType());
return null; return null;

View File

@ -4885,8 +4885,10 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
} catch (XenAPIException e) { } catch (XenAPIException e) {
s_logger.warn("Unable to create local link network", e); s_logger.warn("Unable to create local link network", e);
throw new CloudRuntimeException("Unable to create local link network due to " + e.toString(), e);
} catch (XmlRpcException e) { } catch (XmlRpcException e) {
s_logger.warn("Unable to create local link network", e); s_logger.warn("Unable to create local link network", e);
throw new CloudRuntimeException("Unable to create local link network due to " + e.toString(), e);
} }
} }

View File

@ -542,11 +542,8 @@ public class ElasticLoadBalancerManagerImpl extends ManagerBase implements Elast
private DomainRouterVO stop(DomainRouterVO elbVm, boolean forced, User user, Account caller) throws ConcurrentOperationException, ResourceUnavailableException { private DomainRouterVO stop(DomainRouterVO elbVm, boolean forced, User user, Account caller) throws ConcurrentOperationException, ResourceUnavailableException {
s_logger.debug("Stopping ELB vm " + elbVm); s_logger.debug("Stopping ELB vm " + elbVm);
try { try {
if (_itMgr.advanceStop( elbVm, forced, user, caller)) { _itMgr.advanceStop(elbVm.getUuid(), forced);
return _routerDao.findById(elbVm.getId()); return _routerDao.findById(elbVm.getId());
} else {
return null;
}
} catch (OperationTimedoutException e) { } catch (OperationTimedoutException e) {
throw new CloudRuntimeException("Unable to stop " + elbVm, e); throw new CloudRuntimeException("Unable to stop " + elbVm, e);
} }
@ -736,7 +733,8 @@ public class ElasticLoadBalancerManagerImpl extends ManagerBase implements Elast
if (gceed) { if (gceed) {
try { try {
s_logger.info("Attempting to destroy ELB VM: " + elbVm); s_logger.info("Attempting to destroy ELB VM: " + elbVm);
_itMgr.expunge(elbVm, user, _systemAcct); _itMgr.expunge(elbVm.getUuid());
_routerDao.remove(elbVm.getId());
} catch (ResourceUnavailableException e) { } catch (ResourceUnavailableException e) {
s_logger.warn("Unable to destroy unused ELB vm " + elbVm + " due to ", e); s_logger.warn("Unable to destroy unused ELB vm " + elbVm + " due to ", e);
gceed = false; gceed = false;

View File

@ -513,7 +513,9 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
_accountMgr.checkAccess(caller, null, true, internalLbVm); _accountMgr.checkAccess(caller, null, true, internalLbVm);
return _itMgr.expunge(internalLbVm, _accountMgr.getActiveUser(callerUserId), caller); _itMgr.expunge(internalLbVm.getUuid());
_internalLbVmDao.remove(internalLbVm.getId());
return true;
} }
@ -534,11 +536,8 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
protected VirtualRouter stopInternalLbVm(DomainRouterVO internalLbVm, boolean forced, Account caller, long callerUserId) throws ResourceUnavailableException, ConcurrentOperationException { protected VirtualRouter stopInternalLbVm(DomainRouterVO internalLbVm, boolean forced, Account caller, long callerUserId) throws ResourceUnavailableException, ConcurrentOperationException {
s_logger.debug("Stopping internal lb vm " + internalLbVm); s_logger.debug("Stopping internal lb vm " + internalLbVm);
try { try {
if (_itMgr.advanceStop(internalLbVm, forced, _accountMgr.getActiveUser(callerUserId), caller)) { _itMgr.advanceStop(internalLbVm.getUuid(), forced);
return _internalLbVmDao.findById(internalLbVm.getId()); return _internalLbVmDao.findById(internalLbVm.getId());
} else {
return null;
}
} catch (OperationTimedoutException e) { } catch (OperationTimedoutException e) {
throw new CloudRuntimeException("Unable to stop " + internalLbVm, e); throw new CloudRuntimeException("Unable to stop " + internalLbVm, e);
} }

View File

@ -24,13 +24,8 @@ import java.util.List;
import javax.inject.Inject; import javax.inject.Inject;
import com.cloud.offering.NetworkOffering;
import com.cloud.offerings.NetworkOfferingVO;
import com.cloud.offerings.dao.NetworkOfferingDao;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.cloudstack.lb.ApplicationLoadBalancerRuleVO;
import org.apache.cloudstack.network.lb.InternalLoadBalancerVMManager;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -38,6 +33,9 @@ import org.mockito.Mockito;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.apache.cloudstack.lb.ApplicationLoadBalancerRuleVO;
import org.apache.cloudstack.network.lb.InternalLoadBalancerVMManager;
import com.cloud.agent.AgentManager; import com.cloud.agent.AgentManager;
import com.cloud.agent.api.Answer; import com.cloud.agent.api.Answer;
import com.cloud.agent.manager.Commands; import com.cloud.agent.manager.Commands;
@ -56,12 +54,12 @@ import com.cloud.network.router.VirtualRouter;
import com.cloud.network.router.VirtualRouter.Role; import com.cloud.network.router.VirtualRouter.Role;
import com.cloud.network.rules.FirewallRule; import com.cloud.network.rules.FirewallRule;
import com.cloud.network.rules.LoadBalancerContainer.Scheme; import com.cloud.network.rules.LoadBalancerContainer.Scheme;
import com.cloud.offerings.NetworkOfferingVO;
import com.cloud.offerings.dao.NetworkOfferingDao;
import com.cloud.service.ServiceOfferingVO; import com.cloud.service.ServiceOfferingVO;
import com.cloud.service.dao.ServiceOfferingDao; import com.cloud.service.dao.ServiceOfferingDao;
import com.cloud.user.Account;
import com.cloud.user.AccountManager; import com.cloud.user.AccountManager;
import com.cloud.user.AccountVO; import com.cloud.user.AccountVO;
import com.cloud.user.User;
import com.cloud.utils.component.ComponentContext; import com.cloud.utils.component.ComponentContext;
import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.net.Ip; import com.cloud.utils.net.Ip;
@ -103,6 +101,7 @@ public class InternalLBVMManagerTest extends TestCase {
long validVmId = 1L; long validVmId = 1L;
long invalidVmId = 2L; long invalidVmId = 2L;
@Override
@Before @Before
public void setUp() { public void setUp() {
//mock system offering creation as it's used by configure() method called by initComponentsLifeCycle //mock system offering creation as it's used by configure() method called by initComponentsLifeCycle
@ -160,12 +159,6 @@ public class InternalLBVMManagerTest extends TestCase {
networkOfferingVO.setConcurrentConnections(500); networkOfferingVO.setConcurrentConnections(500);
Mockito.when(_offeringDao.findById(Mockito.anyLong())).thenReturn(networkOfferingVO); Mockito.when(_offeringDao.findById(Mockito.anyLong())).thenReturn(networkOfferingVO);
try {
Mockito.when(_itMgr.expunge(Mockito.any(DomainRouterVO.class), Mockito.any(User.class), Mockito.any(Account.class))).thenReturn(true);
} catch (ResourceUnavailableException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Mockito.when(_domainRouterDao.findById(validVmId)).thenReturn(vm); Mockito.when(_domainRouterDao.findById(validVmId)).thenReturn(vm);
Mockito.when(_domainRouterDao.findById(invalidVmId)).thenReturn(null); Mockito.when(_domainRouterDao.findById(invalidVmId)).thenReturn(null);

View File

@ -36,7 +36,6 @@ import org.apache.cloudstack.network.lb.InternalLoadBalancerVMService;
import com.cloud.exception.ConcurrentOperationException; import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException; import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.OperationTimedoutException;
import com.cloud.exception.ResourceUnavailableException; import com.cloud.exception.ResourceUnavailableException;
import com.cloud.exception.StorageUnavailableException; import com.cloud.exception.StorageUnavailableException;
import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.hypervisor.Hypervisor.HypervisorType;
@ -44,10 +43,8 @@ import com.cloud.network.router.VirtualRouter;
import com.cloud.network.router.VirtualRouter.Role; import com.cloud.network.router.VirtualRouter.Role;
import com.cloud.service.ServiceOfferingVO; import com.cloud.service.ServiceOfferingVO;
import com.cloud.service.dao.ServiceOfferingDao; import com.cloud.service.dao.ServiceOfferingDao;
import com.cloud.user.Account;
import com.cloud.user.AccountManager; import com.cloud.user.AccountManager;
import com.cloud.user.AccountVO; import com.cloud.user.AccountVO;
import com.cloud.user.User;
import com.cloud.user.UserVO; import com.cloud.user.UserVO;
import com.cloud.user.dao.AccountDao; import com.cloud.user.dao.AccountDao;
import com.cloud.utils.component.ComponentContext; import com.cloud.utils.component.ComponentContext;
@ -110,20 +107,6 @@ public class InternalLBVMServiceTest extends TestCase {
Mockito.when(_domainRouterDao.findById(validVmId)).thenReturn(validVm); Mockito.when(_domainRouterDao.findById(validVmId)).thenReturn(validVm);
Mockito.when(_domainRouterDao.findById(nonExistingVmId)).thenReturn(null); Mockito.when(_domainRouterDao.findById(nonExistingVmId)).thenReturn(null);
Mockito.when(_domainRouterDao.findById(nonInternalLbVmId)).thenReturn(nonInternalLbVm); Mockito.when(_domainRouterDao.findById(nonInternalLbVmId)).thenReturn(nonInternalLbVm);
try {
Mockito.when(_itMgr.advanceStop(Mockito.any(DomainRouterVO.class), Mockito.any(Boolean.class), Mockito.any(User.class), Mockito.any(Account.class))).thenReturn(true);
} catch (ResourceUnavailableException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (OperationTimedoutException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ConcurrentOperationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} }
@Override @Override

View File

@ -18,18 +18,18 @@
# Version @VERSION@ # Version @VERSION@
# #
# A plugin for executing script needed by cloud stack # A plugin for executing script needed by CloudStack
from __future__ import with_statement
from copy import copy from copy import copy
from datetime import datetime from datetime import datetime
from httplib import * from httplib import *
from string import join from string import join
from string import split
import os import os
import sys import sys
import time import time
import hashlib import md5 as md5mod
import sha
import base64 import base64
import hmac import hmac
import traceback import traceback
@ -45,30 +45,57 @@ NULL = 'null'
def to_none(value): def to_none(value):
return value if value is not None and value.strip() != NULL else None
if value is None:
return None
if isinstance(value, basestring) and value.strip().lower() == NULL:
return None
return value
def to_bool(value): def to_bool(value):
return True if to_none(value) in ['true', 'True', None] else False
if to_none(value) is None:
return False
if isinstance(value, basestring) and value.strip().lower() == 'true':
return True
if isinstance(value, int) and value:
return True
return False
def to_integer(value, default): def to_integer(value, default):
return int(value) if to_none(value) is not None else default
if to_none(value) is None or not isinstance(value, int):
return default
return int(value)
def optional_str_value(value, default): def optional_str_value(value, default):
return value if is_not_blank(value) else default
if is_not_blank(value):
return value
return default
def is_not_blank(value): def is_not_blank(value):
return True if to_none(value) is not None and value.strip != '' else False
if to_none(value) is None or not isinstance(value, basestring):
return True
if value.strip == '':
return False
return True
def get_optional_key(map, key, default=''): def get_optional_key(map, key, default=''):
return map[key] if key in map else default
if key in map:
return map[key]
return default
def log(message): def log(message):
util.SMlog('#### VMOPS %s ####' % message) util.SMlog('#### VMOPS %s ####' % message)
@ -94,8 +121,8 @@ def retry(max_attempts, fn):
attempts = 1 attempts = 1
while attempts <= max_attempts: while attempts <= max_attempts:
log("Attempting execution {0}/{1} of {2}". log("Attempting execution " + str(attempts) + "/" + str(
format(attempts, max_attempts, fn.__name__)) max_attempts) + " of " + fn.__name__)
try: try:
return fn() return fn()
except: except:
@ -106,9 +133,11 @@ def retry(max_attempts, fn):
def compute_md5(filename, buffer_size=8192): def compute_md5(filename, buffer_size=8192):
hasher = hashlib.md5() hasher = md5mod.md5()
file = open(filename, 'rb')
try:
with open(filename, 'rb') as file:
data = file.read(buffer_size) data = file.read(buffer_size)
while data != "": while data != "":
hasher.update(data) hasher.update(data)
@ -116,6 +145,10 @@ def compute_md5(filename, buffer_size=8192):
return base64.encodestring(hasher.digest())[:-1] return base64.encodestring(hasher.digest())[:-1]
finally:
file.close()
class S3Client(object): class S3Client(object):
@ -146,10 +179,9 @@ class S3Client(object):
max_error_retry, self.DEFAULT_MAX_ERROR_RETRY) max_error_retry, self.DEFAULT_MAX_ERROR_RETRY)
def build_canocialized_resource(self, bucket, key): def build_canocialized_resource(self, bucket, key):
return "/" + join([bucket, key], '/')
return '/{bucket}/{key}'.format(bucket=bucket, key=key) def noop_send_body(connection):
def noop_send_body():
pass pass
def noop_read(response): def noop_read(response):
@ -164,29 +196,42 @@ class S3Client(object):
uri = self.build_canocialized_resource(bucket, key) uri = self.build_canocialized_resource(bucket, key)
signature, request_date = self.sign_request(method, uri, headers) signature, request_date = self.sign_request(method, uri, headers)
headers['Authorization'] = "AWS {0}:{1}".format( headers['Authorization'] = "AWS " + self.access_key + ":" + signature
self.access_key, signature)
headers['Date'] = request_date headers['Date'] = request_date
connection = HTTPSConnection(self.end_point) \
if self.https_flag else HTTPConnection(self.end_point)
connection.timeout = self.socket_timeout
def perform_request(): def perform_request():
print "method=", method, ", uri=", uri, ", headers=", headers,
" endpoint=", self.end_point
connection.request(method, uri, fn_send_body(), headers) connection = None
response = connection.getresponse() if self.https_flag:
log("Sent {0} request to {1} {2} with headers {3}. \ connection = HTTPSConnection(self.end_point)
Got response status {4}: {5}". else:
format(method, self.end_point, uri, headers, connection = HTTPConnection(self.end_point)
response.status, response.reason))
return fn_read(response)
try: try:
return retry(self.max_error_retry, perform_request) connection.timeout = self.socket_timeout
connection.putrequest(method, uri)
for k, v in headers.items():
connection.putheader(k, v)
connection.endheaders()
fn_send_body(connection)
response = connection.getresponse()
log("Sent " + method + " request to " + self.end_point + "/" +
uri + " with headers " + str(headers) +
". Received response status " + str(response.status) +
": " + response.reason)
return fn_read(response)
finally: finally:
connection.close() connection.close()
return retry(self.max_error_retry, perform_request)
''' '''
See http://bit.ly/MMC5de for more information regarding the creation of See http://bit.ly/MMC5de for more information regarding the creation of
AWS authorization tokens and header signing AWS authorization tokens and header signing
@ -205,7 +250,7 @@ class S3Client(object):
signature = base64.encodestring( signature = base64.encodestring(
hmac.new(self.secret_key, string_to_sign.encode('utf8'), hmac.new(self.secret_key, string_to_sign.encode('utf8'),
hashlib.sha1).digest())[:-1] sha).digest())[:-1]
return signature, request_date return signature, request_date
@ -217,8 +262,17 @@ class S3Client(object):
self.HEADER_CONTENT_LENGTH: os.stat(src_filename).st_size, self.HEADER_CONTENT_LENGTH: os.stat(src_filename).st_size,
} }
def send_body(): def send_body(connection):
return open(src_filename, 'rb') src_file = open(src_filename, 'rb')
try:
while True:
block = src_file.read(8192)
if not block:
break
connection.send(block)
except:
src_file.close()
self.do_operation('PUT', bucket, key, headers, send_body) self.do_operation('PUT', bucket, key, headers, send_body)
@ -226,12 +280,18 @@ class S3Client(object):
def read(response): def read(response):
with open(target_filename, 'wb') as file: file = open(target_filename, 'wb')
try:
while True: while True:
block = response.read(8192) block = response.read(8192)
if not block: if not block:
break break
file.write(block) file.write(block)
except:
file.close()
return self.do_operation('GET', bucket, key, fn_read=read) return self.do_operation('GET', bucket, key, fn_read=read)
@ -288,8 +348,8 @@ def s3(session, args):
return 'true' return 'true'
except: except:
log("Operation {0} on file {1} from/in bucket {2} key {3}.".format( log("Operation " + operation + " on file " + filename +
operation, filename, bucket, key)) " from/in bucket " + bucket + " key " + key)
log(traceback.format_exc()) log(traceback.format_exc())
return 'false' return 'false'

View File

@ -44,6 +44,7 @@ import com.cloud.agent.api.Command;
import com.cloud.agent.api.MaintainCommand; import com.cloud.agent.api.MaintainCommand;
import com.cloud.agent.api.MigrateCommand; import com.cloud.agent.api.MigrateCommand;
import com.cloud.agent.api.PingTestCommand; import com.cloud.agent.api.PingTestCommand;
import com.cloud.agent.api.PvlanSetupCommand;
import com.cloud.agent.api.ReadyCommand; import com.cloud.agent.api.ReadyCommand;
import com.cloud.agent.api.SetupCommand; import com.cloud.agent.api.SetupCommand;
import com.cloud.agent.api.ShutdownCommand; import com.cloud.agent.api.ShutdownCommand;
@ -109,7 +110,9 @@ public abstract class AgentAttache {
protected AgentManagerImpl _agentMgr; protected AgentManagerImpl _agentMgr;
public final static String[] s_commandsAllowedInMaintenanceMode = public final static String[] s_commandsAllowedInMaintenanceMode =
new String[] { MaintainCommand.class.toString(), MigrateCommand.class.toString(), StopCommand.class.toString(), CheckVirtualMachineCommand.class.toString(), PingTestCommand.class.toString(), CheckHealthCommand.class.toString(), ReadyCommand.class.toString(), ShutdownCommand.class.toString(), SetupCommand.class.toString(), ClusterSyncCommand.class.toString(), CleanupNetworkRulesCmd.class.toString(), CheckNetworkCommand.class.toString() }; new String[] { MaintainCommand.class.toString(), MigrateCommand.class.toString(), StopCommand.class.toString(), CheckVirtualMachineCommand.class.toString(), PingTestCommand.class.toString(),
CheckHealthCommand.class.toString(), ReadyCommand.class.toString(), ShutdownCommand.class.toString(), SetupCommand.class.toString(), ClusterSyncCommand.class.toString(),
CleanupNetworkRulesCmd.class.toString(), CheckNetworkCommand.class.toString(), PvlanSetupCommand.class.toString() };
protected final static String[] s_commandsNotAllowedInConnectingMode = protected final static String[] s_commandsNotAllowedInConnectingMode =
new String[] { StartCommand.class.toString(), CreateCommand.class.toString() }; new String[] { StartCommand.class.toString(), CreateCommand.class.toString() };
static { static {

View File

@ -111,8 +111,8 @@ public class VolumeJoinDaoImpl extends GenericDaoBase<VolumeJoinVO, Long> implem
// com.cloud.storage.VolumeHostVO volumeHostRef = // com.cloud.storage.VolumeHostVO volumeHostRef =
// ApiDBUtils.findVolumeHostRef(volume.getId(), // ApiDBUtils.findVolumeHostRef(volume.getId(),
// volume.getDataCenterId()); // volume.getDataCenterId());
volResponse.setSize(volume.getVolumeHostSize()); volResponse.setSize(volume.getVolumeStoreSize());
volResponse.setCreated(volume.getVolumeHostCreated()); volResponse.setCreated(volume.getCreatedOnStore());
if (caller.getType() == Account.ACCOUNT_TYPE_ADMIN || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) if (caller.getType() == Account.ACCOUNT_TYPE_ADMIN || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN)
volResponse.setHypervisor(ApiDBUtils.getHypervisorTypeFromFormat(volume.getFormat()).toString()); volResponse.setHypervisor(ApiDBUtils.getHypervisorTypeFromFormat(volume.getFormat()).toString());

View File

@ -144,11 +144,11 @@ public class VolumeJoinVO extends BaseViewVO implements ControlledViewEntity {
@Enumerated(value=EnumType.STRING) @Enumerated(value=EnumType.STRING)
protected VirtualMachine.Type vmType; protected VirtualMachine.Type vmType;
@Column (name="volume_host_size") @Column(name = "volume_store_size")
private long volumeHostSize; private long volumeStoreSize;
@Column(name="volume_host_created") @Column(name = "created_on_store")
private Date volumeHostCreated; private Date createdOnStore;
@Column(name="format") @Column(name="format")
private Storage.ImageFormat format; private Storage.ImageFormat format;
@ -625,32 +625,22 @@ public class VolumeJoinVO extends BaseViewVO implements ControlledViewEntity {
this.vmType = vmType; this.vmType = vmType;
} }
public long getVolumeStoreSize() {
return volumeStoreSize;
public long getVolumeHostSize() {
return volumeHostSize;
} }
public void setVolumeStoreSize(long volumeStoreSize) {
this.volumeStoreSize = volumeStoreSize;
public void setVolumeHostSize(long volumeHostSize) {
this.volumeHostSize = volumeHostSize;
} }
public Date getCreatedOnStore() {
return createdOnStore;
public Date getVolumeHostCreated() {
return volumeHostCreated;
} }
public void setCreatedOnStore(Date createdOnStore) {
this.createdOnStore = createdOnStore;
public void setVolumeHostCreated(Date volumeHostCreated) {
this.volumeHostCreated = volumeHostCreated;
} }
public Storage.ImageFormat getFormat() { public Storage.ImageFormat getFormat() {
return format; return format;
} }

View File

@ -1025,9 +1025,13 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
} }
try { try {
return _itMgr.stop(proxy, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount()); _itMgr.stop(proxy.getUuid());
return true;
} catch (ResourceUnavailableException e) { } catch (ResourceUnavailableException e) {
s_logger.warn("Stopping console proxy " + proxy.getHostName() + " failed : exception " + e.toString()); s_logger.warn("Stopping console proxy " + proxy.getHostName() + " failed : exception ", e);
return false;
} catch (CloudRuntimeException e) {
s_logger.warn("Unable to stop proxy ", e);
return false; return false;
} }
} }
@ -1148,17 +1152,16 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
ConsoleProxyVO proxy = _consoleProxyDao.findById(vmId); ConsoleProxyVO proxy = _consoleProxyDao.findById(vmId);
try { try {
//expunge the vm //expunge the vm
boolean result = _itMgr.expunge(proxy, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount()); _itMgr.expunge(proxy.getUuid());
if (result) { _consoleProxyDao.remove(vmId);
HostVO host = _hostDao.findByTypeNameAndZoneId(proxy.getDataCenterId(), proxy.getHostName(), HostVO host = _hostDao.findByTypeNameAndZoneId(proxy.getDataCenterId(), proxy.getHostName(),
Host.Type.ConsoleProxy); Host.Type.ConsoleProxy);
if (host != null) { if (host != null) {
s_logger.debug("Removing host entry for proxy id=" + vmId); s_logger.debug("Removing host entry for proxy id=" + vmId);
result = result && _hostDao.remove(host.getId()); return _hostDao.remove(host.getId());
}
} }
return result; return true;
} catch (ResourceUnavailableException e) { } catch (ResourceUnavailableException e) {
s_logger.warn("Unable to expunge " + proxy, e); s_logger.warn("Unable to expunge " + proxy, e);
return false; return false;

View File

@ -27,4 +27,6 @@ public interface PlannerHostReservationDao extends GenericDao<PlannerHostReserva
List<PlannerHostReservationVO> listAllReservedHosts(); List<PlannerHostReservationVO> listAllReservedHosts();
List<PlannerHostReservationVO> listAllDedicatedHosts();
} }

View File

@ -20,6 +20,8 @@ import java.util.List;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.ejb.Local; import javax.ejb.Local;
import com.cloud.deploy.DeploymentPlanner.PlannerResourceUsage;
import com.cloud.deploy.PlannerHostReservationVO; import com.cloud.deploy.PlannerHostReservationVO;
import com.cloud.utils.db.GenericDaoBase; import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchBuilder; import com.cloud.utils.db.SearchBuilder;
@ -31,6 +33,7 @@ public class PlannerHostReservationDaoImpl extends GenericDaoBase<PlannerHostRes
private SearchBuilder<PlannerHostReservationVO> _hostIdSearch; private SearchBuilder<PlannerHostReservationVO> _hostIdSearch;
private SearchBuilder<PlannerHostReservationVO> _reservedHostSearch; private SearchBuilder<PlannerHostReservationVO> _reservedHostSearch;
private SearchBuilder<PlannerHostReservationVO> _dedicatedHostSearch;;
public PlannerHostReservationDaoImpl() { public PlannerHostReservationDaoImpl() {
@ -45,6 +48,10 @@ public class PlannerHostReservationDaoImpl extends GenericDaoBase<PlannerHostRes
_reservedHostSearch = createSearchBuilder(); _reservedHostSearch = createSearchBuilder();
_reservedHostSearch.and("usage", _reservedHostSearch.entity().getResourceUsage(), SearchCriteria.Op.NNULL); _reservedHostSearch.and("usage", _reservedHostSearch.entity().getResourceUsage(), SearchCriteria.Op.NNULL);
_reservedHostSearch.done(); _reservedHostSearch.done();
_dedicatedHostSearch = createSearchBuilder();
_dedicatedHostSearch.and("usage", _dedicatedHostSearch.entity().getResourceUsage(), SearchCriteria.Op.EQ);
_dedicatedHostSearch.done();
} }
@Override @Override
@ -60,4 +67,10 @@ public class PlannerHostReservationDaoImpl extends GenericDaoBase<PlannerHostRes
return listBy(sc); return listBy(sc);
} }
@Override
public List<PlannerHostReservationVO> listAllDedicatedHosts() {
SearchCriteria<PlannerHostReservationVO> sc = _dedicatedHostSearch.create();
sc.setParameters("usage", PlannerResourceUsage.Dedicated);
return listBy(sc);
}
} }

View File

@ -26,10 +26,10 @@ import com.cloud.agent.api.CheckVirtualMachineAnswer;
import com.cloud.agent.api.CheckVirtualMachineCommand; import com.cloud.agent.api.CheckVirtualMachineCommand;
import com.cloud.exception.AgentUnavailableException; import com.cloud.exception.AgentUnavailableException;
import com.cloud.exception.OperationTimedoutException; import com.cloud.exception.OperationTimedoutException;
import com.cloud.host.HostVO; import com.cloud.host.Host;
import com.cloud.host.Status; import com.cloud.host.Status;
import com.cloud.utils.component.AdapterBase; import com.cloud.utils.component.AdapterBase;
import com.cloud.vm.VMInstanceVO; import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachine.State; import com.cloud.vm.VirtualMachine.State;
@Local(value=Investigator.class) @Local(value=Investigator.class)
@ -42,12 +42,12 @@ public class CheckOnAgentInvestigator extends AdapterBase implements Investigato
} }
@Override @Override
public Status isAgentAlive(HostVO agent) { public Status isAgentAlive(Host agent) {
return null; return null;
} }
@Override @Override
public Boolean isVmAlive(VMInstanceVO vm, HostVO host) { public Boolean isVmAlive(VirtualMachine vm, Host host) {
CheckVirtualMachineCommand cmd = new CheckVirtualMachineCommand(vm.getInstanceName()); CheckVirtualMachineCommand cmd = new CheckVirtualMachineCommand(vm.getInstanceName());
try { try {
CheckVirtualMachineAnswer answer = (CheckVirtualMachineAnswer)_agentMgr.send(vm.getHostId(), cmd); CheckVirtualMachineAnswer answer = (CheckVirtualMachineAnswer)_agentMgr.send(vm.getHostId(), cmd);

View File

@ -51,7 +51,6 @@ import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InsufficientServerCapacityException; import com.cloud.exception.InsufficientServerCapacityException;
import com.cloud.exception.OperationTimedoutException; import com.cloud.exception.OperationTimedoutException;
import com.cloud.exception.ResourceUnavailableException; import com.cloud.exception.ResourceUnavailableException;
import com.cloud.exception.VirtualMachineMigrationException;
import com.cloud.ha.dao.HighAvailabilityDao; import com.cloud.ha.dao.HighAvailabilityDao;
import com.cloud.host.Host; import com.cloud.host.Host;
import com.cloud.host.HostVO; import com.cloud.host.HostVO;
@ -286,7 +285,7 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
if (hostId == null) { if (hostId == null) {
try { try {
s_logger.debug("Found a vm that is scheduled to be restarted but has no host id: " + vm); s_logger.debug("Found a vm that is scheduled to be restarted but has no host id: " + vm);
_itMgr.advanceStop(vm, true, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount()); _itMgr.advanceStop(vm.getUuid(), true);
} catch (ResourceUnavailableException e) { } catch (ResourceUnavailableException e) {
assert false : "How do we hit this when force is true?"; assert false : "How do we hit this when force is true?";
throw new CloudRuntimeException("Caught exception even though it should be handled.", e); throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
@ -330,7 +329,7 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
} }
try { try {
_itMgr.advanceStop(vm, true, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount()); _itMgr.advanceStop(vm.getUuid(), true);
} catch (ResourceUnavailableException e) { } catch (ResourceUnavailableException e) {
assert false : "How do we hit this when force is true?"; assert false : "How do we hit this when force is true?";
throw new CloudRuntimeException("Caught exception even though it should be handled.", e); throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
@ -388,7 +387,7 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
long vmId = work.getInstanceId(); long vmId = work.getInstanceId();
VMInstanceVO vm = _itMgr.findByIdAndType(work.getType(), work.getInstanceId()); VirtualMachine vm = _itMgr.findById(work.getInstanceId());
if (vm == null) { if (vm == null) {
s_logger.info("Unable to find vm: " + vmId); s_logger.info("Unable to find vm: " + vmId);
return null; return null;
@ -475,7 +474,7 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
} }
try { try {
_itMgr.advanceStop(vm, true, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount()); _itMgr.advanceStop(vm.getUuid(), true);
} catch (ResourceUnavailableException e) { } catch (ResourceUnavailableException e) {
assert false : "How do we hit this when force is true?"; assert false : "How do we hit this when force is true?";
throw new CloudRuntimeException("Caught exception even though it should be handled.", e); throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
@ -492,7 +491,7 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
} else { } else {
s_logger.debug("How come that HA step is Investigating and the host is removed? Calling forced Stop on Vm anyways"); s_logger.debug("How come that HA step is Investigating and the host is removed? Calling forced Stop on Vm anyways");
try { try {
_itMgr.advanceStop(vm, true, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount()); _itMgr.advanceStop(vm.getUuid(), true);
} catch (ResourceUnavailableException e) { } catch (ResourceUnavailableException e) {
assert false : "How do we hit this when force is true?"; assert false : "How do we hit this when force is true?";
throw new CloudRuntimeException("Caught exception even though it should be handled.", e); throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
@ -506,7 +505,7 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
} }
} }
vm = _itMgr.findByIdAndType(vm.getType(), vm.getId()); vm = _itMgr.findById(vm.getId());
if (!_forceHA && !vm.isHaEnabled()) { if (!_forceHA && !vm.isHaEnabled()) {
if (s_logger.isDebugEnabled()) { if (s_logger.isDebugEnabled()) {
@ -560,7 +559,7 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
_alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodIdToDeployIn(), "Unable to restart " + vm.getHostName() + " which was running on host " + hostDesc, _alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodIdToDeployIn(), "Unable to restart " + vm.getHostName() + " which was running on host " + hostDesc,
"The Storage is unavailable for trying to restart VM, name: " + vm.getHostName() + ", id: " + vmId + " which was running on host " + hostDesc); "The Storage is unavailable for trying to restart VM, name: " + vm.getHostName() + ", id: " + vmId + " which was running on host " + hostDesc);
} }
vm = _itMgr.findByIdAndType(vm.getType(), vm.getId()); vm = _itMgr.findById(vm.getId());
work.setUpdateTime(vm.getUpdated()); work.setUpdateTime(vm.getUpdated());
work.setPreviousState(vm.getState()); work.setPreviousState(vm.getState());
return (System.currentTimeMillis() >> 10) + _restartRetryInterval; return (System.currentTimeMillis() >> 10) + _restartRetryInterval;
@ -574,19 +573,14 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
work.setStep(Step.Migrating); work.setStep(Step.Migrating);
_haDao.update(work.getId(), work); _haDao.update(work.getId(), work);
if (!_itMgr.migrateAway(work.getType(), vmId, srcHostId)) { VMInstanceVO vm = _instanceDao.findById(vmId);
s_logger.warn("Unable to migrate vm from " + srcHostId);
_resourceMgr.maintenanceFailed(srcHostId); _itMgr.migrateAway(vm.getUuid(), srcHostId);
}
return null; return null;
} catch (InsufficientServerCapacityException e) { } catch (InsufficientServerCapacityException e) {
s_logger.warn("Insufficient capacity for migrating a VM."); s_logger.warn("Insufficient capacity for migrating a VM.");
_resourceMgr.maintenanceFailed(srcHostId); _resourceMgr.maintenanceFailed(srcHostId);
return (System.currentTimeMillis() >> 10) + _migrateRetryInterval; return (System.currentTimeMillis() >> 10) + _migrateRetryInterval;
} catch (VirtualMachineMigrationException e) {
s_logger.warn("Looks like VM is still starting, we need to retry migrating the VM later.");
_resourceMgr.maintenanceFailed(srcHostId);
return (System.currentTimeMillis() >> 10) + _migrateRetryInterval;
} }
} }
@ -606,7 +600,7 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
} }
protected Long destroyVM(HaWorkVO work) { protected Long destroyVM(HaWorkVO work) {
final VMInstanceVO vm = _itMgr.findByIdAndType(work.getType(), work.getInstanceId()); final VirtualMachine vm = _itMgr.findById(work.getInstanceId());
s_logger.info("Destroying " + vm.toString()); s_logger.info("Destroying " + vm.toString());
try { try {
if (vm.getState() != State.Destroyed) { if (vm.getState() != State.Destroyed) {
@ -615,11 +609,9 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
} }
if (vm.getHostId() != null) { if (vm.getHostId() != null) {
if (_itMgr.destroy(vm, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount())) { _itMgr.destroy(vm.getUuid());
s_logger.info("Successfully destroy " + vm); s_logger.info("Successfully destroy " + vm);
return null; return null;
}
s_logger.debug("Stop for " + vm + " was unsuccessful.");
} else { } else {
if (s_logger.isDebugEnabled()) { if (s_logger.isDebugEnabled()) {
s_logger.debug(vm + " has already been stopped"); s_logger.debug(vm + " has already been stopped");
@ -639,7 +631,7 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
} }
protected Long stopVM(final HaWorkVO work) throws ConcurrentOperationException { protected Long stopVM(final HaWorkVO work) throws ConcurrentOperationException {
VMInstanceVO vm = _itMgr.findByIdAndType(work.getType(), work.getInstanceId()); VirtualMachine vm = _itMgr.findById(work.getInstanceId());
if (vm == null) { if (vm == null) {
s_logger.info("No longer can find VM " + work.getInstanceId() + ". Throwing away " + work); s_logger.info("No longer can find VM " + work.getInstanceId() + ". Throwing away " + work);
work.setStep(Step.Done); work.setStep(Step.Done);
@ -648,28 +640,25 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
s_logger.info("Stopping " + vm); s_logger.info("Stopping " + vm);
try { try {
if (work.getWorkType() == WorkType.Stop) { if (work.getWorkType() == WorkType.Stop) {
if (_itMgr.advanceStop(vm, false, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount())) { _itMgr.advanceStop(vm.getUuid(), false);
s_logger.info("Successfully stopped " + vm); s_logger.info("Successfully stopped " + vm);
return null; return null;
}
} else if (work.getWorkType() == WorkType.CheckStop) { } else if (work.getWorkType() == WorkType.CheckStop) {
if ((vm.getState() != work.getPreviousState()) || vm.getUpdated() != work.getUpdateTime() || vm.getHostId() == null || vm.getHostId().longValue() != work.getHostId()) { if ((vm.getState() != work.getPreviousState()) || vm.getUpdated() != work.getUpdateTime() || vm.getHostId() == null || vm.getHostId().longValue() != work.getHostId()) {
s_logger.info(vm + " is different now. Scheduled Host: " + work.getHostId() + " Current Host: " + (vm.getHostId() != null ? vm.getHostId() : "none") + " State: " + vm.getState()); s_logger.info(vm + " is different now. Scheduled Host: " + work.getHostId() + " Current Host: " + (vm.getHostId() != null ? vm.getHostId() : "none") + " State: " + vm.getState());
return null; return null;
} }
if (_itMgr.advanceStop(vm, false, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount())) { _itMgr.advanceStop(vm.getUuid(), false);
s_logger.info("Stop for " + vm + " was successful"); s_logger.info("Stop for " + vm + " was successful");
return null; return null;
}
} else if (work.getWorkType() == WorkType.ForceStop) { } else if (work.getWorkType() == WorkType.ForceStop) {
if ((vm.getState() != work.getPreviousState()) || vm.getUpdated() != work.getUpdateTime() || vm.getHostId() == null || vm.getHostId().longValue() != work.getHostId()) { if ((vm.getState() != work.getPreviousState()) || vm.getUpdated() != work.getUpdateTime() || vm.getHostId() == null || vm.getHostId().longValue() != work.getHostId()) {
s_logger.info(vm + " is different now. Scheduled Host: " + work.getHostId() + " Current Host: " + (vm.getHostId() != null ? vm.getHostId() : "none") + " State: " + vm.getState()); s_logger.info(vm + " is different now. Scheduled Host: " + work.getHostId() + " Current Host: " + (vm.getHostId() != null ? vm.getHostId() : "none") + " State: " + vm.getState());
return null; return null;
} }
if (_itMgr.advanceStop(vm, true, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount())) { _itMgr.advanceStop(vm.getUuid(), true);
s_logger.info("Stop for " + vm + " was successful"); s_logger.info("Stop for " + vm + " was successful");
return null; return null;
}
} else { } else {
assert false : "Who decided there's other steps but didn't modify the guy who does the work?"; assert false : "Who decided there's other steps but didn't modify the guy who does the work?";
} }

View File

@ -17,7 +17,6 @@
package com.cloud.ha; package com.cloud.ha;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.ejb.Local; import javax.ejb.Local;
@ -31,13 +30,14 @@ import com.cloud.agent.api.FenceAnswer;
import com.cloud.agent.api.FenceCommand; import com.cloud.agent.api.FenceCommand;
import com.cloud.exception.AgentUnavailableException; import com.cloud.exception.AgentUnavailableException;
import com.cloud.exception.OperationTimedoutException; import com.cloud.exception.OperationTimedoutException;
import com.cloud.host.Host;
import com.cloud.host.HostVO; import com.cloud.host.HostVO;
import com.cloud.host.Status; import com.cloud.host.Status;
import com.cloud.host.dao.HostDao; import com.cloud.host.dao.HostDao;
import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.resource.ResourceManager; import com.cloud.resource.ResourceManager;
import com.cloud.utils.component.AdapterBase; import com.cloud.utils.component.AdapterBase;
import com.cloud.vm.VMInstanceVO; import com.cloud.vm.VirtualMachine;
@Local(value=FenceBuilder.class) @Local(value=FenceBuilder.class)
public class KVMFencer extends AdapterBase implements FenceBuilder { public class KVMFencer extends AdapterBase implements FenceBuilder {
@ -70,7 +70,7 @@ public class KVMFencer extends AdapterBase implements FenceBuilder {
} }
@Override @Override
public Boolean fenceOff(VMInstanceVO vm, HostVO host) { public Boolean fenceOff(VirtualMachine vm, Host host) {
if (host.getHypervisorType() != HypervisorType.KVM) { if (host.getHypervisorType() != HypervisorType.KVM) {
s_logger.debug("Don't know how to fence non kvm hosts " + host.getHypervisorType()); s_logger.debug("Don't know how to fence non kvm hosts " + host.getHypervisorType());
return null; return null;

View File

@ -25,13 +25,13 @@ import javax.naming.ConfigurationException;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import com.cloud.host.Host;
import com.cloud.host.HostVO; import com.cloud.host.HostVO;
import com.cloud.host.Status; import com.cloud.host.Status;
import com.cloud.host.dao.HostDao; import com.cloud.host.dao.HostDao;
import com.cloud.network.NetworkModel; import com.cloud.network.NetworkModel;
import com.cloud.network.Networks.TrafficType; import com.cloud.network.Networks.TrafficType;
import com.cloud.vm.Nic; import com.cloud.vm.Nic;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachine;
@Local(value={Investigator.class}) @Local(value={Investigator.class})
@ -39,13 +39,13 @@ public class ManagementIPSystemVMInvestigator extends AbstractInvestigatorImpl {
private static final Logger s_logger = Logger.getLogger(ManagementIPSystemVMInvestigator.class); private static final Logger s_logger = Logger.getLogger(ManagementIPSystemVMInvestigator.class);
private String _name = null; private String _name = null;
@Inject private HostDao _hostDao = null; @Inject private final HostDao _hostDao = null;
@Inject private NetworkModel _networkMgr = null; @Inject private final NetworkModel _networkMgr = null;
@Override @Override
public Boolean isVmAlive(VMInstanceVO vm, HostVO host) { public Boolean isVmAlive(VirtualMachine vm, Host host) {
if (!VirtualMachine.Type.isSystemVM(vm.getType())) { if (!vm.getType().isUsedBySystem()) {
s_logger.debug("Not a System Vm, unable to determine state of " + vm + " returning null"); s_logger.debug("Not a System Vm, unable to determine state of " + vm + " returning null");
} }
@ -110,7 +110,7 @@ public class ManagementIPSystemVMInvestigator extends AbstractInvestigatorImpl {
} }
@Override @Override
public Status isAgentAlive(HostVO agent) { public Status isAgentAlive(Host agent) {
return null; return null;
} }

View File

@ -21,15 +21,15 @@ import java.util.List;
import javax.ejb.Local; import javax.ejb.Local;
import javax.inject.Inject; import javax.inject.Inject;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.cloud.host.HostVO; import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import com.cloud.host.Host;
import com.cloud.storage.VolumeVO; import com.cloud.storage.VolumeVO;
import com.cloud.storage.dao.VolumeDao; import com.cloud.storage.dao.VolumeDao;
import com.cloud.utils.component.AdapterBase; import com.cloud.utils.component.AdapterBase;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachine;
@Component @Component
@ -44,7 +44,7 @@ public class RecreatableFencer extends AdapterBase implements FenceBuilder {
} }
@Override @Override
public Boolean fenceOff(VMInstanceVO vm, HostVO host) { public Boolean fenceOff(VirtualMachine vm, Host host) {
VirtualMachine.Type type = vm.getType(); VirtualMachine.Type type = vm.getType();
if (type != VirtualMachine.Type.ConsoleProxy && type != VirtualMachine.Type.DomainRouter && type != VirtualMachine.Type.SecondaryStorageVm) { if (type != VirtualMachine.Type.ConsoleProxy && type != VirtualMachine.Type.DomainRouter && type != VirtualMachine.Type.SecondaryStorageVm) {
if (s_logger.isDebugEnabled()) { if (s_logger.isDebugEnabled()) {

View File

@ -29,7 +29,7 @@ import org.apache.log4j.Logger;
import com.cloud.agent.AgentManager; import com.cloud.agent.AgentManager;
import com.cloud.agent.api.Answer; import com.cloud.agent.api.Answer;
import com.cloud.agent.api.PingTestCommand; import com.cloud.agent.api.PingTestCommand;
import com.cloud.host.HostVO; import com.cloud.host.Host;
import com.cloud.host.Status; import com.cloud.host.Status;
import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.network.NetworkModel; import com.cloud.network.NetworkModel;
@ -38,7 +38,6 @@ import com.cloud.network.router.VirtualRouter;
import com.cloud.network.router.VpcVirtualNetworkApplianceManager; import com.cloud.network.router.VpcVirtualNetworkApplianceManager;
import com.cloud.vm.Nic; import com.cloud.vm.Nic;
import com.cloud.vm.UserVmVO; import com.cloud.vm.UserVmVO;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachine;
import com.cloud.vm.dao.UserVmDao; import com.cloud.vm.dao.UserVmDao;
@ -53,7 +52,7 @@ public class UserVmDomRInvestigator extends AbstractInvestigatorImpl {
@Inject private final VpcVirtualNetworkApplianceManager _vnaMgr = null; @Inject private final VpcVirtualNetworkApplianceManager _vnaMgr = null;
@Override @Override
public Boolean isVmAlive(VMInstanceVO vm, HostVO host) { public Boolean isVmAlive(VirtualMachine vm, Host host) {
if (vm.getType() != VirtualMachine.Type.User) { if (vm.getType() != VirtualMachine.Type.User) {
if (s_logger.isDebugEnabled()) { if (s_logger.isDebugEnabled()) {
s_logger.debug("Not a User Vm, unable to determine state of " + vm + " returning null"); s_logger.debug("Not a User Vm, unable to determine state of " + vm + " returning null");
@ -104,7 +103,7 @@ public class UserVmDomRInvestigator extends AbstractInvestigatorImpl {
} }
@Override @Override
public Status isAgentAlive(HostVO agent) { public Status isAgentAlive(Host agent) {
if (s_logger.isDebugEnabled()) { if (s_logger.isDebugEnabled()) {
s_logger.debug("checking if agent (" + agent.getId() + ") is alive"); s_logger.debug("checking if agent (" + agent.getId() + ") is alive");
} }
@ -166,7 +165,7 @@ public class UserVmDomRInvestigator extends AbstractInvestigatorImpl {
return true; return true;
} }
private Boolean testUserVM(VMInstanceVO vm, Nic nic, VirtualRouter router) { private Boolean testUserVM(VirtualMachine vm, Nic nic, VirtualRouter router) {
String privateIp = nic.getIp4Address(); String privateIp = nic.getIp4Address();
String routerPrivateIp = router.getPrivateIpAddress(); String routerPrivateIp = router.getPrivateIpAddress();

View File

@ -23,17 +23,18 @@ import javax.inject.Inject;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import com.cloud.agent.AgentManager;
import com.cloud.agent.api.Answer; import com.cloud.agent.api.Answer;
import com.cloud.agent.api.CheckOnHostAnswer; import com.cloud.agent.api.CheckOnHostAnswer;
import com.cloud.agent.api.CheckOnHostCommand; import com.cloud.agent.api.CheckOnHostCommand;
import com.cloud.agent.AgentManager; import com.cloud.host.Host;
import com.cloud.host.HostVO; import com.cloud.host.HostVO;
import com.cloud.host.Status; import com.cloud.host.Status;
import com.cloud.host.dao.HostDao; import com.cloud.host.dao.HostDao;
import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.resource.ResourceManager; import com.cloud.resource.ResourceManager;
import com.cloud.utils.component.AdapterBase; import com.cloud.utils.component.AdapterBase;
import com.cloud.vm.VMInstanceVO; import com.cloud.vm.VirtualMachine;
@Local(value=Investigator.class) @Local(value=Investigator.class)
public class XenServerInvestigator extends AdapterBase implements Investigator { public class XenServerInvestigator extends AdapterBase implements Investigator {
@ -46,7 +47,7 @@ public class XenServerInvestigator extends AdapterBase implements Investigator {
} }
@Override @Override
public Status isAgentAlive(HostVO agent) { public Status isAgentAlive(Host agent) {
if (agent.getHypervisorType() != HypervisorType.XenServer) { if (agent.getHypervisorType() != HypervisorType.XenServer) {
return null; return null;
} }
@ -72,7 +73,7 @@ public class XenServerInvestigator extends AdapterBase implements Investigator {
} }
@Override @Override
public Boolean isVmAlive(VMInstanceVO vm, HostVO host) { public Boolean isVmAlive(VirtualMachine vm, Host host) {
Status status = isAgentAlive(host); Status status = isAgentAlive(host);
if (status == null) { if (status == null) {
return null; return null;

View File

@ -421,13 +421,10 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
_accountMgr.checkAccess(caller, null, true, router); _accountMgr.checkAccess(caller, null, true, router);
boolean result = _itMgr.expunge(router, _accountMgr.getActiveUser(callerUserId), _accountMgr.getAccount(router.getAccountId())); _itMgr.expunge(router.getUuid());
_routerDao.remove(router.getId());
if (result) {
return router; return router;
} }
return null;
}
@Override @Override
@DB @DB
@ -2755,11 +2752,8 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
public DomainRouterVO stop(VirtualRouter router, boolean forced, User user, Account caller) throws ConcurrentOperationException, ResourceUnavailableException { public DomainRouterVO stop(VirtualRouter router, boolean forced, User user, Account caller) throws ConcurrentOperationException, ResourceUnavailableException {
s_logger.debug("Stopping router " + router); s_logger.debug("Stopping router " + router);
try { try {
if (_itMgr.advanceStop((DomainRouterVO) router, forced, user, caller)) { _itMgr.advanceStop(router.getUuid(), forced);
return _routerDao.findById(router.getId()); return _routerDao.findById(router.getId());
} else {
return null;
}
} catch (OperationTimedoutException e) { } catch (OperationTimedoutException e) {
throw new CloudRuntimeException("Unable to stop " + router, e); throw new CloudRuntimeException("Unable to stop " + router, e);
} }

View File

@ -2043,8 +2043,6 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
s_logger.debug("Deleting Host: " + host.getId() + " Guid:" + host.getGuid()); s_logger.debug("Deleting Host: " + host.getId() + " Guid:" + host.getGuid());
} }
User caller = _accountMgr.getActiveUser(CallContext.current().getCallingUserId());
if (forceDestroyStorage) { if (forceDestroyStorage) {
// put local storage into mainenance mode, will set all the VMs on // put local storage into mainenance mode, will set all the VMs on
// this local storage into stopped state // this local storage into stopped state
@ -2067,11 +2065,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
List<VMInstanceVO> vmsOnLocalStorage = _storageMgr.listByStoragePool(storagePool.getId()); List<VMInstanceVO> vmsOnLocalStorage = _storageMgr.listByStoragePool(storagePool.getId());
for (VMInstanceVO vm : vmsOnLocalStorage) { for (VMInstanceVO vm : vmsOnLocalStorage) {
try { try {
if (!_vmMgr.destroy(vm, caller, _accountMgr.getAccount(vm.getAccountId()))) { _vmMgr.destroy(vm.getUuid());
String errorMsg = "There was an error Destory the vm: " + vm + " as a part of hostDelete id=" + host.getId();
s_logger.warn(errorMsg);
throw new UnableDeleteHostException(errorMsg);
}
} catch (Exception e) { } catch (Exception e) {
String errorMsg = "There was an error Destory the vm: " + vm + " as a part of hostDelete id=" + host.getId(); String errorMsg = "There was an error Destory the vm: " + vm + " as a part of hostDelete id=" + host.getId();
s_logger.debug(errorMsg, e); s_logger.debug(errorMsg, e);
@ -2090,11 +2084,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
if (!vm.isHaEnabled() || vm.getState() == State.Stopping) { if (!vm.isHaEnabled() || vm.getState() == State.Stopping) {
s_logger.debug("Stopping vm: " + vm + " as a part of deleteHost id=" + host.getId()); s_logger.debug("Stopping vm: " + vm + " as a part of deleteHost id=" + host.getId());
try { try {
if (!_vmMgr.advanceStop(vm, true, caller, _accountMgr.getAccount(vm.getAccountId()))) { _vmMgr.advanceStop(vm.getUuid(), false);
String errorMsg = "There was an error stopping the vm: " + vm + " as a part of hostDelete id=" + host.getId();
s_logger.warn(errorMsg);
throw new UnableDeleteHostException(errorMsg);
}
} catch (Exception e) { } catch (Exception e) {
String errorMsg = "There was an error stopping the vm: " + vm + " as a part of hostDelete id=" + host.getId(); String errorMsg = "There was an error stopping the vm: " + vm + " as a part of hostDelete id=" + host.getId();
s_logger.debug(errorMsg, e); s_logger.debug(errorMsg, e);

View File

@ -1299,8 +1299,8 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
@DB @DB
public void updateResourceCount() { public void updateResourceCount() {
ResourceType[] resourceTypes = Resource.ResourceType.values(); ResourceType[] resourceTypes = Resource.ResourceType.values();
List<AccountVO> accounts = _accountDao.listAllIncludingRemoved(); List<AccountVO> accounts = _accountDao.listAll();
List<DomainVO> domains = _domainDao.listAllIncludingRemoved(); List<DomainVO> domains = _domainDao.listAll();
List<ResourceCountVO> domainResourceCount = _resourceCountDao.listResourceCountByOwnerType(ResourceOwnerType.Domain); List<ResourceCountVO> domainResourceCount = _resourceCountDao.listResourceCountByOwnerType(ResourceOwnerType.Domain);
List<ResourceCountVO> accountResourceCount = _resourceCountDao.listResourceCountByOwnerType(ResourceOwnerType.Account); List<ResourceCountVO> accountResourceCount = _resourceCountDao.listResourceCountByOwnerType(ResourceOwnerType.Account);

View File

@ -39,23 +39,15 @@ import javax.crypto.spec.SecretKeySpec;
import javax.inject.Inject; import javax.inject.Inject;
import javax.naming.ConfigurationException; import javax.naming.ConfigurationException;
import com.cloud.exception.*;
import com.cloud.vm.*;
import org.apache.cloudstack.acl.ControlledEntity;
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
import org.apache.cloudstack.api.ApiConstants;
import com.cloud.event.ActionEventUtils;
import org.apache.cloudstack.api.BaseUpdateTemplateOrIsoCmd;
import org.apache.cloudstack.api.command.admin.region.*;
import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Base64;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.apache.cloudstack.acl.ControlledEntity;
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
import org.apache.cloudstack.affinity.AffinityGroupProcessor; import org.apache.cloudstack.affinity.AffinityGroupProcessor;
import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao; import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseUpdateTemplateOrIsoCmd;
import org.apache.cloudstack.api.command.admin.account.CreateAccountCmd; import org.apache.cloudstack.api.command.admin.account.CreateAccountCmd;
import org.apache.cloudstack.api.command.admin.account.DeleteAccountCmd; import org.apache.cloudstack.api.command.admin.account.DeleteAccountCmd;
import org.apache.cloudstack.api.command.admin.account.DisableAccountCmd; import org.apache.cloudstack.api.command.admin.account.DisableAccountCmd;
@ -69,6 +61,7 @@ import org.apache.cloudstack.api.command.admin.cluster.DeleteClusterCmd;
import org.apache.cloudstack.api.command.admin.cluster.ListClustersCmd; import org.apache.cloudstack.api.command.admin.cluster.ListClustersCmd;
import org.apache.cloudstack.api.command.admin.cluster.UpdateClusterCmd; import org.apache.cloudstack.api.command.admin.cluster.UpdateClusterCmd;
import org.apache.cloudstack.api.command.admin.config.ListCfgsByCmd; import org.apache.cloudstack.api.command.admin.config.ListCfgsByCmd;
import org.apache.cloudstack.api.command.admin.config.ListDeploymentPlannersCmd;
import org.apache.cloudstack.api.command.admin.config.ListHypervisorCapabilitiesCmd; import org.apache.cloudstack.api.command.admin.config.ListHypervisorCapabilitiesCmd;
import org.apache.cloudstack.api.command.admin.config.UpdateCfgCmd; import org.apache.cloudstack.api.command.admin.config.UpdateCfgCmd;
import org.apache.cloudstack.api.command.admin.config.UpdateHypervisorCapabilitiesCmd; import org.apache.cloudstack.api.command.admin.config.UpdateHypervisorCapabilitiesCmd;
@ -129,6 +122,12 @@ import org.apache.cloudstack.api.command.admin.pod.CreatePodCmd;
import org.apache.cloudstack.api.command.admin.pod.DeletePodCmd; import org.apache.cloudstack.api.command.admin.pod.DeletePodCmd;
import org.apache.cloudstack.api.command.admin.pod.ListPodsByCmd; import org.apache.cloudstack.api.command.admin.pod.ListPodsByCmd;
import org.apache.cloudstack.api.command.admin.pod.UpdatePodCmd; import org.apache.cloudstack.api.command.admin.pod.UpdatePodCmd;
import org.apache.cloudstack.api.command.admin.region.AddRegionCmd;
import org.apache.cloudstack.api.command.admin.region.CreatePortableIpRangeCmd;
import org.apache.cloudstack.api.command.admin.region.DeletePortableIpRangeCmd;
import org.apache.cloudstack.api.command.admin.region.ListPortableIpRangesCmd;
import org.apache.cloudstack.api.command.admin.region.RemoveRegionCmd;
import org.apache.cloudstack.api.command.admin.region.UpdateRegionCmd;
import org.apache.cloudstack.api.command.admin.resource.ArchiveAlertsCmd; import org.apache.cloudstack.api.command.admin.resource.ArchiveAlertsCmd;
import org.apache.cloudstack.api.command.admin.resource.CleanVMReservationsCmd; import org.apache.cloudstack.api.command.admin.resource.CleanVMReservationsCmd;
import org.apache.cloudstack.api.command.admin.resource.DeleteAlertsCmd; import org.apache.cloudstack.api.command.admin.resource.DeleteAlertsCmd;
@ -159,7 +158,14 @@ import org.apache.cloudstack.api.command.admin.storage.ListStoragePoolsCmd;
import org.apache.cloudstack.api.command.admin.storage.ListStorageProvidersCmd; import org.apache.cloudstack.api.command.admin.storage.ListStorageProvidersCmd;
import org.apache.cloudstack.api.command.admin.storage.PreparePrimaryStorageForMaintenanceCmd; import org.apache.cloudstack.api.command.admin.storage.PreparePrimaryStorageForMaintenanceCmd;
import org.apache.cloudstack.api.command.admin.storage.UpdateStoragePoolCmd; import org.apache.cloudstack.api.command.admin.storage.UpdateStoragePoolCmd;
import org.apache.cloudstack.api.command.admin.systemvm.*; import org.apache.cloudstack.api.command.admin.systemvm.DestroySystemVmCmd;
import org.apache.cloudstack.api.command.admin.systemvm.ListSystemVMsCmd;
import org.apache.cloudstack.api.command.admin.systemvm.MigrateSystemVMCmd;
import org.apache.cloudstack.api.command.admin.systemvm.RebootSystemVmCmd;
import org.apache.cloudstack.api.command.admin.systemvm.ScaleSystemVMCmd;
import org.apache.cloudstack.api.command.admin.systemvm.StartSystemVMCmd;
import org.apache.cloudstack.api.command.admin.systemvm.StopSystemVmCmd;
import org.apache.cloudstack.api.command.admin.systemvm.UpgradeSystemVMCmd;
import org.apache.cloudstack.api.command.admin.template.PrepareTemplateCmd; import org.apache.cloudstack.api.command.admin.template.PrepareTemplateCmd;
import org.apache.cloudstack.api.command.admin.usage.AddTrafficMonitorCmd; import org.apache.cloudstack.api.command.admin.usage.AddTrafficMonitorCmd;
import org.apache.cloudstack.api.command.admin.usage.AddTrafficTypeCmd; import org.apache.cloudstack.api.command.admin.usage.AddTrafficTypeCmd;
@ -309,8 +315,8 @@ import org.apache.cloudstack.api.command.user.region.ha.gslb.AssignToGlobalLoadB
import org.apache.cloudstack.api.command.user.region.ha.gslb.CreateGlobalLoadBalancerRuleCmd; import org.apache.cloudstack.api.command.user.region.ha.gslb.CreateGlobalLoadBalancerRuleCmd;
import org.apache.cloudstack.api.command.user.region.ha.gslb.DeleteGlobalLoadBalancerRuleCmd; import org.apache.cloudstack.api.command.user.region.ha.gslb.DeleteGlobalLoadBalancerRuleCmd;
import org.apache.cloudstack.api.command.user.region.ha.gslb.ListGlobalLoadBalancerRuleCmd; import org.apache.cloudstack.api.command.user.region.ha.gslb.ListGlobalLoadBalancerRuleCmd;
import org.apache.cloudstack.api.command.user.region.ha.gslb.UpdateGlobalLoadBalancerRuleCmd;
import org.apache.cloudstack.api.command.user.region.ha.gslb.RemoveFromGlobalLoadBalancerRuleCmd; import org.apache.cloudstack.api.command.user.region.ha.gslb.RemoveFromGlobalLoadBalancerRuleCmd;
import org.apache.cloudstack.api.command.user.region.ha.gslb.UpdateGlobalLoadBalancerRuleCmd;
import org.apache.cloudstack.api.command.user.resource.GetCloudIdentifierCmd; import org.apache.cloudstack.api.command.user.resource.GetCloudIdentifierCmd;
import org.apache.cloudstack.api.command.user.resource.ListHypervisorsCmd; import org.apache.cloudstack.api.command.user.resource.ListHypervisorsCmd;
import org.apache.cloudstack.api.command.user.resource.ListResourceLimitsCmd; import org.apache.cloudstack.api.command.user.resource.ListResourceLimitsCmd;
@ -372,7 +378,19 @@ import org.apache.cloudstack.api.command.user.vmsnapshot.CreateVMSnapshotCmd;
import org.apache.cloudstack.api.command.user.vmsnapshot.DeleteVMSnapshotCmd; import org.apache.cloudstack.api.command.user.vmsnapshot.DeleteVMSnapshotCmd;
import org.apache.cloudstack.api.command.user.vmsnapshot.ListVMSnapshotCmd; import org.apache.cloudstack.api.command.user.vmsnapshot.ListVMSnapshotCmd;
import org.apache.cloudstack.api.command.user.vmsnapshot.RevertToVMSnapshotCmd; import org.apache.cloudstack.api.command.user.vmsnapshot.RevertToVMSnapshotCmd;
import org.apache.cloudstack.api.command.user.volume.*; import org.apache.cloudstack.api.command.user.volume.AddResourceDetailCmd;
import org.apache.cloudstack.api.command.user.volume.AttachVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.CreateVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.DeleteVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.DetachVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.ExtractVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.ListResourceDetailsCmd;
import org.apache.cloudstack.api.command.user.volume.ListVolumesCmd;
import org.apache.cloudstack.api.command.user.volume.MigrateVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.RemoveResourceDetailCmd;
import org.apache.cloudstack.api.command.user.volume.ResizeVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.UpdateVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.UploadVolumeCmd;
import org.apache.cloudstack.api.command.user.vpc.CreateStaticRouteCmd; import org.apache.cloudstack.api.command.user.vpc.CreateStaticRouteCmd;
import org.apache.cloudstack.api.command.user.vpc.CreateVPCCmd; import org.apache.cloudstack.api.command.user.vpc.CreateVPCCmd;
import org.apache.cloudstack.api.command.user.vpc.DeleteStaticRouteCmd; import org.apache.cloudstack.api.command.user.vpc.DeleteStaticRouteCmd;
@ -401,6 +419,7 @@ import org.apache.cloudstack.api.command.user.vpn.RemoveVpnUserCmd;
import org.apache.cloudstack.api.command.user.vpn.ResetVpnConnectionCmd; import org.apache.cloudstack.api.command.user.vpn.ResetVpnConnectionCmd;
import org.apache.cloudstack.api.command.user.vpn.UpdateVpnCustomerGatewayCmd; import org.apache.cloudstack.api.command.user.vpn.UpdateVpnCustomerGatewayCmd;
import org.apache.cloudstack.api.command.user.zone.ListZonesByCmd; import org.apache.cloudstack.api.command.user.zone.ListZonesByCmd;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator; import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory; import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
@ -451,9 +470,17 @@ import com.cloud.deploy.DeploymentPlanningManager;
import com.cloud.domain.DomainVO; import com.cloud.domain.DomainVO;
import com.cloud.domain.dao.DomainDao; import com.cloud.domain.dao.DomainDao;
import com.cloud.event.ActionEvent; import com.cloud.event.ActionEvent;
import com.cloud.event.ActionEventUtils;
import com.cloud.event.EventTypes; import com.cloud.event.EventTypes;
import com.cloud.event.EventVO; import com.cloud.event.EventVO;
import com.cloud.event.dao.EventDao; import com.cloud.event.dao.EventDao;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ManagementServerException;
import com.cloud.exception.OperationTimedoutException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.exception.VirtualMachineMigrationException;
import com.cloud.ha.HighAvailabilityManager; import com.cloud.ha.HighAvailabilityManager;
import com.cloud.host.DetailVO; import com.cloud.host.DetailVO;
import com.cloud.host.Host; import com.cloud.host.Host;
@ -491,9 +518,9 @@ import com.cloud.storage.GuestOSCategoryVO;
import com.cloud.storage.GuestOSVO; import com.cloud.storage.GuestOSVO;
import com.cloud.storage.GuestOsCategory; import com.cloud.storage.GuestOsCategory;
import com.cloud.storage.Storage.ImageFormat; import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.Storage.TemplateType;
import com.cloud.storage.StorageManager; import com.cloud.storage.StorageManager;
import com.cloud.storage.StoragePool; import com.cloud.storage.StoragePool;
import com.cloud.storage.Storage.TemplateType;
import com.cloud.storage.VMTemplateVO; import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.Volume; import com.cloud.storage.Volume;
import com.cloud.storage.VolumeManager; import com.cloud.storage.VolumeManager;
@ -542,7 +569,18 @@ import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.net.MacAddress; import com.cloud.utils.net.MacAddress;
import com.cloud.utils.net.NetUtils; import com.cloud.utils.net.NetUtils;
import com.cloud.utils.ssh.SSHKeysHelper; import com.cloud.utils.ssh.SSHKeysHelper;
import com.cloud.vm.ConsoleProxyVO;
import com.cloud.vm.DiskProfile;
import com.cloud.vm.InstanceGroupVO;
import com.cloud.vm.SecondaryStorageVmVO;
import com.cloud.vm.UserVmManager;
import com.cloud.vm.UserVmVO;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachine.State; import com.cloud.vm.VirtualMachine.State;
import com.cloud.vm.VirtualMachineManager;
import com.cloud.vm.VirtualMachineProfile;
import com.cloud.vm.VirtualMachineProfileImpl;
import com.cloud.vm.dao.ConsoleProxyDao; import com.cloud.vm.dao.ConsoleProxyDao;
import com.cloud.vm.dao.DomainRouterDao; import com.cloud.vm.dao.DomainRouterDao;
import com.cloud.vm.dao.InstanceGroupDao; import com.cloud.vm.dao.InstanceGroupDao;
@ -553,12 +591,6 @@ import com.cloud.vm.dao.VMInstanceDao;
import edu.emory.mathcs.backport.java.util.Arrays; import edu.emory.mathcs.backport.java.util.Arrays;
import edu.emory.mathcs.backport.java.util.Collections; import edu.emory.mathcs.backport.java.util.Collections;
import org.apache.cloudstack.api.command.admin.region.AddRegionCmd;
import org.apache.cloudstack.api.command.admin.region.RemoveRegionCmd;
import org.apache.cloudstack.api.command.admin.region.UpdateRegionCmd;
import org.apache.cloudstack.api.command.admin.config.ListDeploymentPlannersCmd;
import org.apache.cloudstack.context.CallContext;
public class ManagementServerImpl extends ManagerBase implements ManagementServer { public class ManagementServerImpl extends ManagerBase implements ManagementServer {
public static final Logger s_logger = Logger.getLogger(ManagementServerImpl.class.getName()); public static final Logger s_logger = Logger.getLogger(ManagementServerImpl.class.getName());
@ -725,7 +757,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
return _affinityProcessors; return _affinityProcessors;
} }
public void setAffinityGroupProcessors(List<AffinityGroupProcessor> affinityProcessors) { public void setAffinityGroupProcessors(List<AffinityGroupProcessor> affinityProcessors) {
this._affinityProcessors = affinityProcessors; _affinityProcessors = affinityProcessors;
} }
public ManagementServerImpl() { public ManagementServerImpl() {
@ -1272,7 +1304,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
storagePools.remove(srcVolumePool); storagePools.remove(srcVolumePool);
for (StoragePoolVO pool : storagePools) { for (StoragePoolVO pool : storagePools) {
if (pool.isShared()) { if (pool.isShared()) {
allPools.add((StoragePool)this.dataStoreMgr.getPrimaryDataStore(pool.getId())); allPools.add((StoragePool)dataStoreMgr.getPrimaryDataStore(pool.getId()));
} }
} }
@ -2060,13 +2092,9 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
private ConsoleProxyVO stopConsoleProxy(VMInstanceVO systemVm, boolean isForced) throws ResourceUnavailableException, OperationTimedoutException, private ConsoleProxyVO stopConsoleProxy(VMInstanceVO systemVm, boolean isForced) throws ResourceUnavailableException, OperationTimedoutException,
ConcurrentOperationException { ConcurrentOperationException {
User caller = _userDao.findById(CallContext.current().getCallingUserId()); _itMgr.advanceStop(systemVm.getUuid(), isForced);
if (_itMgr.advanceStop(systemVm, isForced, caller, CallContext.current().getCallingAccount())) {
return _consoleProxyDao.findById(systemVm.getId()); return _consoleProxyDao.findById(systemVm.getId());
} }
return null;
}
@ActionEvent(eventType = EventTypes.EVENT_PROXY_REBOOT, eventDescription = "rebooting console proxy Vm", async = true) @ActionEvent(eventType = EventTypes.EVENT_PROXY_REBOOT, eventDescription = "rebooting console proxy Vm", async = true)
private ConsoleProxyVO rebootConsoleProxy(long instanceId) { private ConsoleProxyVO rebootConsoleProxy(long instanceId) {
@ -2949,13 +2977,9 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
private SecondaryStorageVmVO stopSecondaryStorageVm(VMInstanceVO systemVm, boolean isForced) throws ResourceUnavailableException, private SecondaryStorageVmVO stopSecondaryStorageVm(VMInstanceVO systemVm, boolean isForced) throws ResourceUnavailableException,
OperationTimedoutException, ConcurrentOperationException { OperationTimedoutException, ConcurrentOperationException {
User caller = _userDao.findById(CallContext.current().getCallingUserId()); _itMgr.advanceStop(systemVm.getUuid(), isForced);
if (_itMgr.advanceStop(systemVm, isForced, caller, CallContext.current().getCallingAccount())) {
return _secStorageVmDao.findById(systemVm.getId()); return _secStorageVmDao.findById(systemVm.getId());
} }
return null;
}
@ActionEvent(eventType = EventTypes.EVENT_SSVM_REBOOT, eventDescription = "rebooting secondary storage Vm", async = true) @ActionEvent(eventType = EventTypes.EVENT_SSVM_REBOOT, eventDescription = "rebooting secondary storage Vm", async = true)
public SecondaryStorageVmVO rebootSecondaryStorageVm(long instanceId) { public SecondaryStorageVmVO rebootSecondaryStorageVm(long instanceId) {

View File

@ -35,12 +35,16 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import org.apache.cloudstack.api.IdentityService;
import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Base64;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.context.support.SpringBeanAutowiringSupport; import org.springframework.web.context.support.SpringBeanAutowiringSupport;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import org.apache.cloudstack.api.IdentityService;
import com.cloud.exception.PermissionDeniedException; import com.cloud.exception.PermissionDeniedException;
import com.cloud.host.HostVO; import com.cloud.host.HostVO;
import com.cloud.server.ManagementServer; import com.cloud.server.ManagementServer;
@ -51,12 +55,10 @@ import com.cloud.user.User;
import com.cloud.uservm.UserVm; import com.cloud.uservm.UserVm;
import com.cloud.utils.Pair; import com.cloud.utils.Pair;
import com.cloud.utils.Ternary; import com.cloud.utils.Ternary;
import com.cloud.utils.db.EntityManager;
import com.cloud.utils.db.Transaction; import com.cloud.utils.db.Transaction;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachineManager; import com.cloud.vm.VirtualMachineManager;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
/** /**
* Thumbnail access : /console?cmd=thumbnail&vm=xxx&w=xxx&h=xxx * Thumbnail access : /console?cmd=thumbnail&vm=xxx&w=xxx&h=xxx
@ -74,10 +76,12 @@ public class ConsoleProxyServlet extends HttpServlet {
@Inject VirtualMachineManager _vmMgr; @Inject VirtualMachineManager _vmMgr;
@Inject ManagementServer _ms; @Inject ManagementServer _ms;
@Inject IdentityService _identityService; @Inject IdentityService _identityService;
@Inject
EntityManager _entityMgr;
static ManagementServer s_ms; static ManagementServer s_ms;
private Gson _gson = new GsonBuilder().create(); private final Gson _gson = new GsonBuilder().create();
public ConsoleProxyServlet() { public ConsoleProxyServlet() {
} }
@ -179,7 +183,7 @@ public class ConsoleProxyServlet extends HttpServlet {
} }
private void handleThumbnailRequest(HttpServletRequest req, HttpServletResponse resp, long vmId) { private void handleThumbnailRequest(HttpServletRequest req, HttpServletResponse resp, long vmId) {
VMInstanceVO vm = _vmMgr.findById(vmId); VirtualMachine vm = _vmMgr.findById(vmId);
if(vm == null) { if(vm == null) {
s_logger.warn("VM " + vmId + " does not exist, sending blank response for thumbnail request"); s_logger.warn("VM " + vmId + " does not exist, sending blank response for thumbnail request");
sendResponse(resp, ""); sendResponse(resp, "");
@ -230,7 +234,7 @@ public class ConsoleProxyServlet extends HttpServlet {
} }
private void handleAccessRequest(HttpServletRequest req, HttpServletResponse resp, long vmId) { private void handleAccessRequest(HttpServletRequest req, HttpServletResponse resp, long vmId) {
VMInstanceVO vm = _vmMgr.findById(vmId); VirtualMachine vm = _vmMgr.findById(vmId);
if(vm == null) { if(vm == null) {
s_logger.warn("VM " + vmId + " does not exist, sending blank response for console access request"); s_logger.warn("VM " + vmId + " does not exist, sending blank response for console access request");
sendResponse(resp, ""); sendResponse(resp, "");
@ -258,7 +262,7 @@ public class ConsoleProxyServlet extends HttpServlet {
String vmName = vm.getHostName(); String vmName = vm.getHostName();
if(vm.getType() == VirtualMachine.Type.User) { if(vm.getType() == VirtualMachine.Type.User) {
UserVm userVm = (UserVm)_vmMgr.findByIdAndType(VirtualMachine.Type.User, vmId); UserVm userVm = _entityMgr.findById(UserVm.class, vmId);
String displayName = userVm.getDisplayName(); String displayName = userVm.getDisplayName();
if(displayName != null && !displayName.isEmpty() && !displayName.equals(vmName)) { if(displayName != null && !displayName.isEmpty() && !displayName.equals(vmName)) {
vmName += "(" + displayName + ")"; vmName += "(" + displayName + ")";
@ -276,7 +280,7 @@ public class ConsoleProxyServlet extends HttpServlet {
// TODO authentication channel between console proxy VM and management server needs to be secured, // TODO authentication channel between console proxy VM and management server needs to be secured,
// the data is now being sent through private network, but this is apparently not enough // the data is now being sent through private network, but this is apparently not enough
VMInstanceVO vm = _vmMgr.findById(vmId); VirtualMachine vm = _vmMgr.findById(vmId);
if(vm == null) { if(vm == null) {
s_logger.warn("VM " + vmId + " does not exist, sending failed response for authentication request from console proxy"); s_logger.warn("VM " + vmId + " does not exist, sending failed response for authentication request from console proxy");
sendResponse(resp, "failed"); sendResponse(resp, "failed");
@ -339,7 +343,7 @@ public class ConsoleProxyServlet extends HttpServlet {
return _gson.toJson(keyIvPair); return _gson.toJson(keyIvPair);
} }
private String composeThumbnailUrl(String rootUrl, VMInstanceVO vm, HostVO hostVo, int w, int h) { private String composeThumbnailUrl(String rootUrl, VirtualMachine vm, HostVO hostVo, int w, int h) {
StringBuffer sb = new StringBuffer(rootUrl); StringBuffer sb = new StringBuffer(rootUrl);
String host = hostVo.getPrivateIpAddress(); String host = hostVo.getPrivateIpAddress();
@ -374,7 +378,7 @@ public class ConsoleProxyServlet extends HttpServlet {
return sb.toString(); return sb.toString();
} }
private String composeConsoleAccessUrl(String rootUrl, VMInstanceVO vm, HostVO hostVo) { private String composeConsoleAccessUrl(String rootUrl, VirtualMachine vm, HostVO hostVo) {
StringBuffer sb = new StringBuffer(rootUrl); StringBuffer sb = new StringBuffer(rootUrl);
String host = hostVo.getPrivateIpAddress(); String host = hostVo.getPrivateIpAddress();
@ -454,7 +458,7 @@ public class ConsoleProxyServlet extends HttpServlet {
private boolean checkSessionPermision(HttpServletRequest req, long vmId, Account accountObj) { private boolean checkSessionPermision(HttpServletRequest req, long vmId, Account accountObj) {
VMInstanceVO vm = _vmMgr.findById(vmId); VirtualMachine vm = _vmMgr.findById(vmId);
if(vm == null) { if(vm == null) {
s_logger.debug("Console/thumbnail access denied. VM " + vmId + " does not exist in system any more"); s_logger.debug("Console/thumbnail access denied. VM " + vmId + " does not exist in system any more");
return false; return false;

View File

@ -234,19 +234,11 @@ public class StoragePoolAutomationImpl implements StoragePoolAutomation {
if (vmInstance.getType().equals( if (vmInstance.getType().equals(
VirtualMachine.Type.ConsoleProxy)) { VirtualMachine.Type.ConsoleProxy)) {
// call the consoleproxymanager // call the consoleproxymanager
ConsoleProxyVO consoleProxy = _consoleProxyDao ConsoleProxyVO consoleProxy = _consoleProxyDao.findById(vmInstance.getId());
.findById(vmInstance.getId()); vmMgr.advanceStop(consoleProxy.getUuid(), false);
if (!vmMgr.advanceStop(consoleProxy, true, user, account)) {
String errorMsg = "There was an error stopping the console proxy id: "
+ vmInstance.getId()
+ " ,cannot enable storage maintenance";
s_logger.warn(errorMsg);
throw new CloudRuntimeException(errorMsg);
} else {
// update work status // update work status
work.setStoppedForMaintenance(true); work.setStoppedForMaintenance(true);
_storagePoolWorkDao.update(work.getId(), work); _storagePoolWorkDao.update(work.getId(), work);
}
if (restart) { if (restart) {
@ -260,36 +252,21 @@ public class StoragePoolAutomationImpl implements StoragePoolAutomation {
// if the instance is of type uservm, call the user vm manager // if the instance is of type uservm, call the user vm manager
if (vmInstance.getType() == VirtualMachine.Type.User) { if (vmInstance.getType() == VirtualMachine.Type.User) {
UserVmVO userVm = userVmDao.findById(vmInstance.getId()); UserVmVO userVm = userVmDao.findById(vmInstance.getId());
if (!vmMgr.advanceStop(userVm, true, user, account)) { vmMgr.advanceStop(userVm.getUuid(), false);
String errorMsg = "There was an error stopping the user vm id: "
+ vmInstance.getId()
+ " ,cannot enable storage maintenance";
s_logger.warn(errorMsg);
throw new CloudRuntimeException(errorMsg);
} else {
// update work status // update work status
work.setStoppedForMaintenance(true); work.setStoppedForMaintenance(true);
_storagePoolWorkDao.update(work.getId(), work); _storagePoolWorkDao.update(work.getId(), work);
} }
}
// if the instance is of type secondary storage vm, call the // if the instance is of type secondary storage vm, call the
// secondary storage vm manager // secondary storage vm manager
if (vmInstance.getType().equals( if (vmInstance.getType().equals(
VirtualMachine.Type.SecondaryStorageVm)) { VirtualMachine.Type.SecondaryStorageVm)) {
SecondaryStorageVmVO secStrgVm = _secStrgDao SecondaryStorageVmVO secStrgVm = _secStrgDao.findById(vmInstance.getId());
.findById(vmInstance.getId()); vmMgr.advanceStop(secStrgVm.getUuid(), false);
if (!vmMgr.advanceStop(secStrgVm, true, user, account)) {
String errorMsg = "There was an error stopping the ssvm id: "
+ vmInstance.getId()
+ " ,cannot enable storage maintenance";
s_logger.warn(errorMsg);
throw new CloudRuntimeException(errorMsg);
} else {
// update work status // update work status
work.setStoppedForMaintenance(true); work.setStoppedForMaintenance(true);
_storagePoolWorkDao.update(work.getId(), work); _storagePoolWorkDao.update(work.getId(), work);
}
if (restart) { if (restart) {
vmMgr.advanceStart(secStrgVm.getUuid(), null); vmMgr.advanceStart(secStrgVm.getUuid(), null);
@ -304,17 +281,10 @@ public class StoragePoolAutomationImpl implements StoragePoolAutomation {
if (vmInstance.getType().equals( if (vmInstance.getType().equals(
VirtualMachine.Type.DomainRouter)) { VirtualMachine.Type.DomainRouter)) {
DomainRouterVO domR = _domrDao.findById(vmInstance.getId()); DomainRouterVO domR = _domrDao.findById(vmInstance.getId());
if (!vmMgr.advanceStop(domR, true, user, account)) { vmMgr.advanceStop(domR.getUuid(), false);
String errorMsg = "There was an error stopping the domain router id: "
+ vmInstance.getId()
+ " ,cannot enable primary storage maintenance";
s_logger.warn(errorMsg);
throw new CloudRuntimeException(errorMsg);
} else {
// update work status // update work status
work.setStoppedForMaintenance(true); work.setStoppedForMaintenance(true);
_storagePoolWorkDao.update(work.getId(), work); _storagePoolWorkDao.update(work.getId(), work);
}
if (restart) { if (restart) {
vmMgr.advanceStart(domR.getUuid(), null); vmMgr.advanceStart(domR.getUuid(), null);

View File

@ -27,7 +27,6 @@ import org.apache.cloudstack.api.command.user.volume.MigrateVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.ResizeVolumeCmd; import org.apache.cloudstack.api.command.user.volume.ResizeVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.UploadVolumeCmd; import org.apache.cloudstack.api.command.user.volume.UploadVolumeCmd;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo; import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import com.cloud.agent.api.to.VirtualMachineTO; import com.cloud.agent.api.to.VirtualMachineTO;
import com.cloud.deploy.DeployDestination; import com.cloud.deploy.DeployDestination;
@ -41,6 +40,7 @@ import com.cloud.storage.Volume.Type;
import com.cloud.user.Account; import com.cloud.user.Account;
import com.cloud.vm.DiskProfile; import com.cloud.vm.DiskProfile;
import com.cloud.vm.VMInstanceVO; import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachineProfile; import com.cloud.vm.VirtualMachineProfile;
public interface VolumeManager extends VolumeApiService { public interface VolumeManager extends VolumeApiService {
@ -91,8 +91,8 @@ public interface VolumeManager extends VolumeApiService {
@Override @Override
Volume migrateVolume(MigrateVolumeCmd cmd); Volume migrateVolume(MigrateVolumeCmd cmd);
<T extends VMInstanceVO> void migrateVolumes(T vm, VirtualMachineTO vmTo, Host srcHost, Host destHost, void migrateVolumes(VirtualMachine vm, VirtualMachineTO vmTo, Host srcHost, Host destHost,
Map<VolumeVO, StoragePoolVO> volumeToPool); Map<Volume, StoragePool> volumeToPool);
boolean storageMigration(VirtualMachineProfile vm, StoragePool destPool); boolean storageMigration(VirtualMachineProfile vm, StoragePool destPool);

View File

@ -1357,9 +1357,20 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
_usageEventDao.persist(usageEvent); _usageEventDao.persist(usageEvent);
} }
} }
AsyncCallFuture<VolumeApiResult> future = volService.expungeVolumeAsync(volFactory.getVolume(volume.getId())); // expunge volume from primary if volume is on primary
VolumeInfo volOnPrimary = volFactory.getVolume(volume.getId(), DataStoreRole.Primary);
if (volOnPrimary != null) {
s_logger.info("Expunging volume " + volume.getId() + " from primary data store");
AsyncCallFuture<VolumeApiResult> future = volService.expungeVolumeAsync(volOnPrimary);
future.get(); future.get();
}
// expunge volume from secondary if volume is on image store
VolumeInfo volOnSecondary = volFactory.getVolume(volume.getId(), DataStoreRole.Image);
if (volOnSecondary != null) {
s_logger.info("Expunging volume " + volume.getId() + " from secondary data store");
AsyncCallFuture<VolumeApiResult> future2 = volService.expungeVolumeAsync(volOnSecondary);
future2.get();
}
} catch (Exception e) { } catch (Exception e) {
s_logger.warn("Failed to expunge volume:", e); s_logger.warn("Failed to expunge volume:", e);
return false; return false;
@ -2087,10 +2098,14 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
txn.start(); txn.start();
for (VolumeVO vol : volumesForVm) { for (VolumeVO vol : volumesForVm) {
if (vol.getVolumeType().equals(Type.ROOT)) { if (vol.getVolumeType().equals(Type.ROOT)) {
// This check is for VM in Error state (volume is already // Destroy volume if not already destroyed
// destroyed) boolean volumeAlreadyDestroyed = (vol.getState() == Volume.State.Destroy ||
if (!vol.getState().equals(Volume.State.Destroy)) { vol.getState() == Volume.State.Expunged ||
vol.getState() == Volume.State.Expunging);
if (!volumeAlreadyDestroyed) {
volService.destroyVolume(vol.getId()); volService.destroyVolume(vol.getId());
} else {
s_logger.debug("Skipping destroy for the volume " + vol + " as its in state " + vol.getState().toString());
} }
toBeExpunged.add(vol); toBeExpunged.add(vol);
} else { } else {
@ -2228,15 +2243,15 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
} }
@Override @Override
public <T extends VMInstanceVO> void migrateVolumes(T vm, VirtualMachineTO vmTo, Host srcHost, Host destHost, public void migrateVolumes(VirtualMachine vm, VirtualMachineTO vmTo, Host srcHost, Host destHost,
Map<VolumeVO, StoragePoolVO> volumeToPool) { Map<Volume, StoragePool> volumeToPool) {
// Check if all the vms being migrated belong to the vm. // Check if all the vms being migrated belong to the vm.
// Check if the storage pool is of the right type. // Check if the storage pool is of the right type.
// Create a VolumeInfo to DataStore map too. // Create a VolumeInfo to DataStore map too.
Map<VolumeInfo, DataStore> volumeMap = new HashMap<VolumeInfo, DataStore>(); Map<VolumeInfo, DataStore> volumeMap = new HashMap<VolumeInfo, DataStore>();
for (Map.Entry<VolumeVO, StoragePoolVO> entry : volumeToPool.entrySet()) { for (Map.Entry<Volume, StoragePool> entry : volumeToPool.entrySet()) {
VolumeVO volume = entry.getKey(); Volume volume = entry.getKey();
StoragePoolVO storagePool = entry.getValue(); StoragePool storagePool = entry.getValue();
StoragePool destPool = (StoragePool)dataStoreMgr.getDataStore(storagePool.getId(), StoragePool destPool = (StoragePool)dataStoreMgr.getDataStore(storagePool.getId(),
DataStoreRole.Primary); DataStoreRole.Primary);
@ -2320,15 +2335,12 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
vm.addDisk(disk); vm.addDisk(disk);
} }
if (vm.getType() == VirtualMachine.Type.User) { if (vm.getType() == VirtualMachine.Type.User && vm.getTemplate().getFormat() == ImageFormat.ISO) {
UserVmVO userVM = (UserVmVO) vm.getVirtualMachine(); DataTO dataTO = tmplFactory.getTemplate(vm.getTemplate().getId(), DataStoreRole.Image, vm.getVirtualMachine().getDataCenterId()).getTO();
if (userVM.getIsoId() != null) {
DataTO dataTO = tmplFactory.getTemplate(userVM.getIsoId(), DataStoreRole.Image, userVM.getDataCenterId()).getTO();
DiskTO iso = new DiskTO(dataTO, 3L, null, Volume.Type.ISO); DiskTO iso = new DiskTO(dataTO, 3L, null, Volume.Type.ISO);
vm.addDisk(iso); vm.addDisk(iso);
} }
} }
}

View File

@ -905,11 +905,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
try { try {
if (secStorageVmLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) { if (secStorageVmLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) {
try { try {
boolean result = _itMgr.stop(secStorageVm, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount()); _itMgr.stop(secStorageVm.getUuid());
if (result) { return true;
}
return result;
} finally { } finally {
secStorageVmLock.unlock(); secStorageVmLock.unlock();
} }
@ -971,17 +968,16 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
SecondaryStorageVmVO ssvm = _secStorageVmDao.findById(vmId); SecondaryStorageVmVO ssvm = _secStorageVmDao.findById(vmId);
try { try {
boolean result = _itMgr.expunge(ssvm, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount()); _itMgr.expunge(ssvm.getUuid());
if (result) { _secStorageVmDao.remove(ssvm.getId());
HostVO host = _hostDao.findByTypeNameAndZoneId(ssvm.getDataCenterId(), ssvm.getHostName(), HostVO host = _hostDao.findByTypeNameAndZoneId(ssvm.getDataCenterId(), ssvm.getHostName(),
Host.Type.SecondaryStorageVM); Host.Type.SecondaryStorageVM);
if (host != null) { if (host != null) {
s_logger.debug("Removing host entry for ssvm id=" + vmId); s_logger.debug("Removing host entry for ssvm id=" + vmId);
result = result && _hostDao.remove(host.getId()); _hostDao.remove(host.getId());
}
} }
return result; return true;
} catch (ResourceUnavailableException e) { } catch (ResourceUnavailableException e) {
s_logger.warn("Unable to expunge " + ssvm, e); s_logger.warn("Unable to expunge " + ssvm, e);
return false; return false;

View File

@ -26,9 +26,6 @@ import javax.ejb.Local;
import javax.inject.Inject; import javax.inject.Inject;
import javax.naming.ConfigurationException; import javax.naming.ConfigurationException;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import org.apache.cloudstack.api.command.user.snapshot.CreateSnapshotPolicyCmd; import org.apache.cloudstack.api.command.user.snapshot.CreateSnapshotPolicyCmd;
import org.apache.cloudstack.api.command.user.snapshot.DeleteSnapshotPoliciesCmd; import org.apache.cloudstack.api.command.user.snapshot.DeleteSnapshotPoliciesCmd;
import org.apache.cloudstack.api.command.user.snapshot.ListSnapshotPoliciesCmd; import org.apache.cloudstack.api.command.user.snapshot.ListSnapshotPoliciesCmd;
@ -48,6 +45,9 @@ import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreDao; import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO; import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Component;
import com.cloud.agent.AgentManager; import com.cloud.agent.AgentManager;
import com.cloud.agent.api.Answer; import com.cloud.agent.api.Answer;
@ -80,6 +80,7 @@ import com.cloud.resource.ResourceManager;
import com.cloud.server.ResourceTag.TaggedResourceType; import com.cloud.server.ResourceTag.TaggedResourceType;
import com.cloud.storage.CreateSnapshotPayload; import com.cloud.storage.CreateSnapshotPayload;
import com.cloud.storage.DataStoreRole; import com.cloud.storage.DataStoreRole;
import com.cloud.storage.ScopeType;
import com.cloud.storage.Snapshot; import com.cloud.storage.Snapshot;
import com.cloud.storage.Snapshot.Type; import com.cloud.storage.Snapshot.Type;
import com.cloud.storage.SnapshotPolicyVO; import com.cloud.storage.SnapshotPolicyVO;
@ -1145,7 +1146,14 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
} }
String snapshotName = vmDisplayName + "_" + volume.getName() + "_" + timeString; String snapshotName = vmDisplayName + "_" + volume.getName() + "_" + timeString;
HypervisorType hypervisorType = volume.getHypervisorType(); HypervisorType hypervisorType = HypervisorType.None;
StoragePoolVO storagePool = _storagePoolDao.findById(volume.getDataStore().getId());
if (storagePool.getScope() == ScopeType.ZONE) {
hypervisorType = storagePool.getHypervisor();
} else {
hypervisorType = volume.getHypervisorType();
}
SnapshotVO snapshotVO = new SnapshotVO(volume.getDataCenterId(), volume.getAccountId(), volume.getDomainId(), volume.getId(), volume.getDiskOfferingId(), snapshotName, SnapshotVO snapshotVO = new SnapshotVO(volume.getDataCenterId(), volume.getAccountId(), volume.getDomainId(), volume.getId(), volume.getDiskOfferingId(), snapshotName,
(short) snapshotType.ordinal(), snapshotType.name(), volume.getSize(), hypervisorType); (short) snapshotType.ordinal(), snapshotType.name(), volume.getSize(), hypervisorType);

View File

@ -1333,7 +1333,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
try { try {
TemplateInfo tmplInfo = this._tmplFactory.getTemplate(templateId, DataStoreRole.Image); TemplateInfo tmplInfo = this._tmplFactory.getTemplate(templateId, DataStoreRole.Image);
Long zoneId = null; long zoneId = 0;
if (snapshotId != null) { if (snapshotId != null) {
snapshot = _snapshotDao.findById(snapshotId); snapshot = _snapshotDao.findById(snapshotId);
zoneId = snapshot.getDataCenterId(); zoneId = snapshot.getDataCenterId();
@ -1341,18 +1341,17 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
volume = _volumeDao.findById(volumeId); volume = _volumeDao.findById(volumeId);
zoneId = volume.getDataCenterId(); zoneId = volume.getDataCenterId();
} }
ZoneScope scope = new ZoneScope(zoneId); DataStore store = this._dataStoreMgr.getImageStore(zoneId);
List<DataStore> store = this._dataStoreMgr.getImageStoresByScope(scope); if (store == null) {
if (store.size() > 1) { throw new CloudRuntimeException("cannot find an image store for zone " + zoneId);
throw new CloudRuntimeException("muliple image data store, don't know which one to use");
} }
AsyncCallFuture<TemplateApiResult> future = null; AsyncCallFuture<TemplateApiResult> future = null;
if (snapshotId != null) { if (snapshotId != null) {
SnapshotInfo snapInfo = this._snapshotFactory.getSnapshot(snapshotId, DataStoreRole.Image); SnapshotInfo snapInfo = this._snapshotFactory.getSnapshot(snapshotId, DataStoreRole.Image);
future = this._tmpltSvr.createTemplateFromSnapshotAsync(snapInfo, tmplInfo, store.get(0)); future = this._tmpltSvr.createTemplateFromSnapshotAsync(snapInfo, tmplInfo, store);
} else if (volumeId != null) { } else if (volumeId != null) {
VolumeInfo volInfo = this._volFactory.getVolume(volumeId); VolumeInfo volInfo = this._volFactory.getVolume(volumeId);
future = this._tmpltSvr.createTemplateFromVolumeAsync(volInfo, tmplInfo, store.get(0)); future = this._tmpltSvr.createTemplateFromVolumeAsync(volInfo, tmplInfo, store);
} else { } else {
throw new CloudRuntimeException("Creating private Template need to specify snapshotId or volumeId"); throw new CloudRuntimeException("Creating private Template need to specify snapshotId or volumeId");
} }

View File

@ -822,11 +822,11 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
try { try {
try { try {
if (vm.getType() == Type.User) { if (vm.getType() == Type.User) {
success = (success && _itMgr.advanceStop(_userVmDao.findById(vm.getId()), false, getSystemUser(), getSystemAccount())); _itMgr.advanceStop(vm.getUuid(), false);
} else if (vm.getType() == Type.DomainRouter) { } else if (vm.getType() == Type.DomainRouter) {
success = (success && _itMgr.advanceStop(_routerDao.findById(vm.getId()), false, getSystemUser(), getSystemAccount())); _itMgr.advanceStop(vm.getUuid(), false);
} else { } else {
success = (success && _itMgr.advanceStop(vm, false, getSystemUser(), getSystemAccount())); _itMgr.advanceStop(vm.getUuid(), false);
} }
} catch (OperationTimedoutException ote) { } catch (OperationTimedoutException ote) {
s_logger.warn("Operation for stopping vm timed out, unable to stop vm " + vm.getHostName(), ote); s_logger.warn("Operation for stopping vm timed out, unable to stop vm " + vm.getHostName(), ote);

View File

@ -20,17 +20,19 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import javax.ejb.Local; import javax.ejb.Local;
import javax.inject.Inject;
import javax.naming.ConfigurationException; import javax.naming.ConfigurationException;
import org.springframework.context.annotation.Primary; import com.cloud.cluster.ClusterManager;
import org.springframework.stereotype.Component;
import com.cloud.cluster.ClusterManagerListener; import com.cloud.cluster.ClusterManagerListener;
import com.cloud.cluster.ManagementServerHostVO; import com.cloud.cluster.ManagementServerHostVO;
@Local(value=VirtualMachineManager.class) @Local(value=VirtualMachineManager.class)
public class ClusteredVirtualMachineManagerImpl extends VirtualMachineManagerImpl implements ClusterManagerListener { public class ClusteredVirtualMachineManagerImpl extends VirtualMachineManagerImpl implements ClusterManagerListener {
@Inject
ClusterManager _clusterMgr;
protected ClusteredVirtualMachineManagerImpl() { protected ClusteredVirtualMachineManagerImpl() {
} }

View File

@ -17,12 +17,10 @@
package com.cloud.vm; package com.cloud.vm;
import com.cloud.domain.Domain; import com.cloud.domain.Domain;
import com.cloud.domain.dao.DomainDao;
import com.cloud.user.Account; import com.cloud.user.Account;
import com.cloud.user.User; import com.cloud.user.User;
import com.cloud.user.dao.AccountDao;
import com.cloud.user.dao.UserDao;
import com.cloud.utils.Journal; import com.cloud.utils.Journal;
import com.cloud.utils.db.EntityManager;
public class ReservationContextImpl implements ReservationContext { public class ReservationContextImpl implements ReservationContext {
User _caller; User _caller;
@ -66,7 +64,7 @@ public class ReservationContextImpl implements ReservationContext {
@Override @Override
public Account getAccount() { public Account getAccount() {
if (_account == null) { if (_account == null) {
_account = s_accountDao.findByIdIncludingRemoved(_caller.getId()); _account = s_entityMgr.findById(Account.class, _caller.getId());
} }
return _account; return _account;
} }
@ -75,7 +73,7 @@ public class ReservationContextImpl implements ReservationContext {
public Domain getDomain() { public Domain getDomain() {
if (_domain == null) { if (_domain == null) {
getAccount(); getAccount();
_domain = s_domainDao.findByIdIncludingRemoved(_account.getDomainId()); _domain = s_entityMgr.findById(Domain.class, _account.getDomainId());
} }
return _domain; return _domain;
} }
@ -90,13 +88,9 @@ public class ReservationContextImpl implements ReservationContext {
return _reservationId; return _reservationId;
} }
static UserDao s_userDao; static EntityManager s_entityMgr;
static DomainDao s_domainDao;
static AccountDao s_accountDao;
static public void setComponents(UserDao userDao, DomainDao domainDao, AccountDao accountDao) { static public void init(EntityManager entityMgr) {
s_userDao = userDao; s_entityMgr = entityMgr;
s_domainDao = domainDao;
s_accountDao = accountDao;
} }
} }

View File

@ -107,6 +107,8 @@ import com.cloud.dc.dao.HostPodDao;
import com.cloud.deploy.DataCenterDeployment; import com.cloud.deploy.DataCenterDeployment;
import com.cloud.deploy.DeployDestination; import com.cloud.deploy.DeployDestination;
import com.cloud.deploy.DeploymentPlanner.ExcludeList; import com.cloud.deploy.DeploymentPlanner.ExcludeList;
import com.cloud.deploy.PlannerHostReservationVO;
import com.cloud.deploy.dao.PlannerHostReservationDao;
import com.cloud.domain.DomainVO; import com.cloud.domain.DomainVO;
import com.cloud.domain.dao.DomainDao; import com.cloud.domain.dao.DomainDao;
import com.cloud.event.ActionEvent; import com.cloud.event.ActionEvent;
@ -178,6 +180,7 @@ import com.cloud.server.ConfigurationServer;
import com.cloud.server.Criteria; import com.cloud.server.Criteria;
import com.cloud.service.ServiceOfferingVO; import com.cloud.service.ServiceOfferingVO;
import com.cloud.service.dao.ServiceOfferingDao; import com.cloud.service.dao.ServiceOfferingDao;
import com.cloud.service.dao.ServiceOfferingDetailsDao;
import com.cloud.storage.DiskOfferingVO; import com.cloud.storage.DiskOfferingVO;
import com.cloud.storage.GuestOSCategoryVO; import com.cloud.storage.GuestOSCategoryVO;
import com.cloud.storage.GuestOSVO; import com.cloud.storage.GuestOSVO;
@ -221,6 +224,7 @@ import com.cloud.user.dao.SSHKeyPairDao;
import com.cloud.user.dao.UserDao; import com.cloud.user.dao.UserDao;
import com.cloud.user.dao.VmDiskStatisticsDao; import com.cloud.user.dao.VmDiskStatisticsDao;
import com.cloud.uservm.UserVm; import com.cloud.uservm.UserVm;
import com.cloud.utils.DateUtil;
import com.cloud.utils.Journal; import com.cloud.utils.Journal;
import com.cloud.utils.NumbersUtil; import com.cloud.utils.NumbersUtil;
import com.cloud.utils.Pair; import com.cloud.utils.Pair;
@ -418,11 +422,16 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
ConfigurationServer _configServer; ConfigurationServer _configServer;
@Inject @Inject
AffinityGroupService _affinityGroupService; AffinityGroupService _affinityGroupService;
@Inject
PlannerHostReservationDao _plannerHostReservationDao;
@Inject
private ServiceOfferingDetailsDao serviceOfferingDetailsDao;
protected ScheduledExecutorService _executor = null; protected ScheduledExecutorService _executor = null;
protected int _expungeInterval; protected int _expungeInterval;
protected int _expungeDelay; protected int _expungeDelay;
protected boolean _dailyOrHourly = false; protected boolean _dailyOrHourly = false;
private int capacityReleaseInterval;
protected String _name; protected String _name;
protected String _instance; protected String _instance;
@ -727,8 +736,6 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
private UserVm rebootVirtualMachine(long userId, long vmId) private UserVm rebootVirtualMachine(long userId, long vmId)
throws InsufficientCapacityException, ResourceUnavailableException { throws InsufficientCapacityException, ResourceUnavailableException {
UserVmVO vm = _vmDao.findById(vmId); UserVmVO vm = _vmDao.findById(vmId);
User caller = _accountMgr.getActiveUser(userId);
Account owner = _accountMgr.getAccount(vm.getAccountId());
if (vm == null || vm.getState() == State.Destroyed if (vm == null || vm.getState() == State.Destroyed
|| vm.getState() == State.Expunging || vm.getRemoved() != null) { || vm.getState() == State.Expunging || vm.getRemoved() != null) {
@ -738,10 +745,10 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
if (vm.getState() == State.Running && vm.getHostId() != null) { if (vm.getState() == State.Running && vm.getHostId() != null) {
collectVmDiskStatistics(vm); collectVmDiskStatistics(vm);
return _itMgr.reboot(vm, null, caller, owner); _itMgr.reboot(vm.getUuid(), null);
return _vmDao.findById(vmId);
} else { } else {
s_logger.error("Vm id=" + vmId s_logger.error("Vm id=" + vmId + " is not in Running state, failed to reboot");
+ " is not in Running state, failed to reboot");
return null; return null;
} }
} }
@ -1424,6 +1431,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
String workers = configs.get("expunge.workers"); String workers = configs.get("expunge.workers");
int wrks = NumbersUtil.parseInt(workers, 10); int wrks = NumbersUtil.parseInt(workers, 10);
capacityReleaseInterval = NumbersUtil.parseInt(_configDao.getValue(Config.CapacitySkipcountingHours.key()), 3600);
String time = configs.get("expunge.interval"); String time = configs.get("expunge.interval");
_expungeInterval = NumbersUtil.parseInt(time, 86400); _expungeInterval = NumbersUtil.parseInt(time, 86400);
@ -1494,10 +1502,14 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
@Override @Override
public boolean expunge(UserVmVO vm, long callerUserId, Account caller) { public boolean expunge(UserVmVO vm, long callerUserId, Account caller) {
try { try {
List<VolumeVO> rootVol = _volsDao.findByInstanceAndType(vm.getId(), Volume.Type.ROOT);
// expunge the vm // expunge the vm
if (!_itMgr.advanceExpunge(vm, _accountMgr.getSystemUser(), caller)) { _itMgr.advanceExpunge(vm.getUuid());
s_logger.info("Did not expunge " + vm); // Update Resource count
return false; if (vm.getAccountId() != Account.ACCOUNT_ID_SYSTEM && !rootVol.isEmpty()) {
_resourceLimitMgr.decrementResourceCount(vm.getAccountId(), ResourceType.volume);
_resourceLimitMgr.decrementResourceCount(vm.getAccountId(), ResourceType.primary_storage,
new Long(rootVol.get(0).getSize()));
} }
// Only if vm is not expunged already, cleanup it's resources // Only if vm is not expunged already, cleanup it's resources
@ -1515,7 +1527,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
return false; return false;
} }
_itMgr.remove(vm, _accountMgr.getSystemUser(), caller); _vmDao.remove(vm.getId());
} }
return true; return true;
@ -3833,20 +3845,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
+ destinationHost.getResourceState()); + destinationHost.getResourceState());
} }
HostVO srcHost = _hostDao.findById(srcHostId); checkHostsDedication(vm, srcHostId, destinationHost.getId());
HostVO destHost = _hostDao.findById(destinationHost.getId());
//if srcHost is dedicated and destination Host is not
if (checkIfHostIsDedicated(srcHost) && !checkIfHostIsDedicated(destHost)) {
//raise an alert
String msg = "VM is migrated on a non-dedicated host " + destinationHost.getName();
_alertMgr.sendAlert(AlertManager.ALERT_TYPE_USERVM, vm.getDataCenterId(), vm.getPodIdToDeployIn(), msg, msg);
}
//if srcHost is non dedicated but destination Host is.
if (!checkIfHostIsDedicated(srcHost) && checkIfHostIsDedicated(destHost)) {
//raise an alert
String msg = "VM is migrated on a dedicated host " + destinationHost.getName();
_alertMgr.sendAlert(AlertManager.ALERT_TYPE_USERVM, vm.getDataCenterId(), vm.getPodIdToDeployIn(), msg, msg);
}
// call to core process // call to core process
DataCenterVO dcVO = _dcDao.findById(destinationHost.getDataCenterId()); DataCenterVO dcVO = _dcDao.findById(destinationHost.getDataCenterId());
@ -3875,8 +3874,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
if (uservm != null) { if (uservm != null) {
collectVmDiskStatistics(uservm); collectVmDiskStatistics(uservm);
} }
VMInstanceVO migratedVm = _itMgr.migrate(vm, srcHostId, dest); _itMgr.migrate(vm.getUuid(), srcHostId, dest);
return migratedVm; return _vmDao.findById(vmId);
} }
private boolean checkIfHostIsDedicated(HostVO host) { private boolean checkIfHostIsDedicated(HostVO host) {
@ -3891,6 +3890,210 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
} }
} }
private Long accountOfDedicatedHost(HostVO host) {
long hostId = host.getId();
DedicatedResourceVO dedicatedHost = _dedicatedDao.findByHostId(hostId);
DedicatedResourceVO dedicatedClusterOfHost = _dedicatedDao.findByClusterId(host.getClusterId());
DedicatedResourceVO dedicatedPodOfHost = _dedicatedDao.findByPodId(host.getPodId());
if(dedicatedHost != null) {
return dedicatedHost.getAccountId();
}
if(dedicatedClusterOfHost != null) {
return dedicatedClusterOfHost.getAccountId();
}
if(dedicatedPodOfHost != null) {
return dedicatedPodOfHost.getAccountId();
}
return null;
}
private Long domainOfDedicatedHost(HostVO host) {
long hostId = host.getId();
DedicatedResourceVO dedicatedHost = _dedicatedDao.findByHostId(hostId);
DedicatedResourceVO dedicatedClusterOfHost = _dedicatedDao.findByClusterId(host.getClusterId());
DedicatedResourceVO dedicatedPodOfHost = _dedicatedDao.findByPodId(host.getPodId());
if(dedicatedHost != null) {
return dedicatedHost.getDomainId();
}
if(dedicatedClusterOfHost != null) {
return dedicatedClusterOfHost.getDomainId();
}
if(dedicatedPodOfHost != null) {
return dedicatedPodOfHost.getDomainId();
}
return null;
}
public void checkHostsDedication (VMInstanceVO vm, long srcHostId, long destHostId) {
HostVO srcHost = _hostDao.findById(srcHostId);
HostVO destHost = _hostDao.findById(destHostId);
boolean srcExplDedicated = checkIfHostIsDedicated(srcHost);
boolean destExplDedicated = checkIfHostIsDedicated(destHost);
//if srcHost is explicitly dedicated and destination Host is not
if (srcExplDedicated && !destExplDedicated) {
//raise an alert
String msg = "VM is being migrated from a explicitly dedicated host " + srcHost.getName() +" to non-dedicated host " + destHost.getName();
_alertMgr.sendAlert(AlertManager.ALERT_TYPE_USERVM, vm.getDataCenterId(), vm.getPodIdToDeployIn(), msg, msg);
s_logger.warn(msg);
}
//if srcHost is non dedicated but destination Host is explicitly dedicated
if (!srcExplDedicated && destExplDedicated) {
//raise an alert
String msg = "VM is being migrated from a non dedicated host " + srcHost.getName() + " to a explicitly dedicated host "+ destHost.getName();
_alertMgr.sendAlert(AlertManager.ALERT_TYPE_USERVM, vm.getDataCenterId(), vm.getPodIdToDeployIn(), msg, msg);
s_logger.warn(msg);
}
//if hosts are dedicated to different account/domains, raise an alert
if (srcExplDedicated && destExplDedicated) {
if((accountOfDedicatedHost(srcHost) != null) && (accountOfDedicatedHost(srcHost)!= accountOfDedicatedHost(destHost))) {
String msg = "VM is being migrated from host " + srcHost.getName() + " explicitly dedicated to account " + accountOfDedicatedHost(srcHost) +
" to host " + destHost.getName() + " explicitly dedicated to account " + accountOfDedicatedHost(destHost);
_alertMgr.sendAlert(AlertManager.ALERT_TYPE_USERVM, vm.getDataCenterId(), vm.getPodIdToDeployIn(), msg, msg);
s_logger.warn(msg);
}
if((domainOfDedicatedHost(srcHost) != null) && (domainOfDedicatedHost(srcHost)!= domainOfDedicatedHost(destHost))) {
String msg = "VM is being migrated from host " + srcHost.getName() + " explicitly dedicated to domain " + domainOfDedicatedHost(srcHost) +
" to host " + destHost.getName() + " explicitly dedicated to domain " + domainOfDedicatedHost(destHost);
_alertMgr.sendAlert(AlertManager.ALERT_TYPE_USERVM, vm.getDataCenterId(), vm.getPodIdToDeployIn(), msg, msg);
s_logger.warn(msg);
}
}
// Checks for implicitly dedicated hosts
ServiceOfferingVO deployPlanner = _offeringDao.findById(vm.getServiceOfferingId());
if(deployPlanner.getDeploymentPlanner() != null && deployPlanner.getDeploymentPlanner().equals("ImplicitDedicationPlanner")) {
//VM is deployed using implicit planner
long accountOfVm = vm.getAccountId();
String msg = "VM of account " + accountOfVm + " with implicit deployment planner being migrated to host " + destHost.getName();
//Get all vms on destination host
boolean emptyDestination = false;
List<VMInstanceVO> vmsOnDest= getVmsOnHost(destHostId);
if (vmsOnDest == null || vmsOnDest.isEmpty()) {
emptyDestination = true;
}
if (!emptyDestination) {
//Check if vm is deployed using strict implicit planner
if(!isServiceOfferingUsingPlannerInPreferredMode(vm.getServiceOfferingId())) {
//Check if all vms on destination host are created using strict implicit mode
if(!checkIfAllVmsCreatedInStrictMode(accountOfVm, vmsOnDest)) {
msg = "VM of account " + accountOfVm + " with strict implicit deployment planner being migrated to host " + destHost.getName() +
" not having all vms strict implicitly dedicated to account " + accountOfVm;
}
} else {
//If vm is deployed using preferred implicit planner, check if all vms on destination host must be
//using implicit planner and must belong to same account
for (VMInstanceVO vmsDest : vmsOnDest) {
ServiceOfferingVO destPlanner = _offeringDao.findById(vmsDest.getServiceOfferingId());
if (!((destPlanner.getDeploymentPlanner() != null && destPlanner.getDeploymentPlanner().equals("ImplicitDedicationPlanner")) &&
vmsDest.getAccountId()==accountOfVm)) {
msg = "VM of account " + accountOfVm + " with preffered implicit deployment planner being migrated to host " + destHost.getName() +
" not having all vms implicitly dedicated to account " + accountOfVm;
}
}
}
}
_alertMgr.sendAlert(AlertManager.ALERT_TYPE_USERVM, vm.getDataCenterId(), vm.getPodIdToDeployIn(), msg, msg);
s_logger.warn(msg);
} else {
//VM is not deployed using implicit planner, check if it migrated between dedicated hosts
List<PlannerHostReservationVO> reservedHosts = _plannerHostReservationDao.listAllDedicatedHosts();
boolean srcImplDedicated = false;
boolean destImplDedicated = false;
String msg = null;
for (PlannerHostReservationVO reservedHost : reservedHosts) {
if(reservedHost.getHostId() == srcHostId) {
srcImplDedicated = true;
}
if(reservedHost.getHostId() == destHostId) {
destImplDedicated = true;
}
}
if(srcImplDedicated) {
if(destImplDedicated){
msg = "VM is being migrated from implicitly dedicated host " + srcHost.getName() + " to another implicitly dedicated host " + destHost.getName();
} else {
msg = "VM is being migrated from implicitly dedicated host " + srcHost.getName() + " to shared host " + destHost.getName();
}
_alertMgr.sendAlert(AlertManager.ALERT_TYPE_USERVM, vm.getDataCenterId(), vm.getPodIdToDeployIn(), msg, msg);
s_logger.warn(msg);
} else {
if (destImplDedicated) {
msg = "VM is being migrated from shared host " + srcHost.getName() + " to implicitly dedicated host " + destHost.getName();
_alertMgr.sendAlert(AlertManager.ALERT_TYPE_USERVM, vm.getDataCenterId(), vm.getPodIdToDeployIn(), msg, msg);
s_logger.warn(msg);
}
}
}
}
private List<VMInstanceVO> getVmsOnHost(long hostId) {
List<VMInstanceVO> vms = _vmInstanceDao.listUpByHostId(hostId);
List<VMInstanceVO> vmsByLastHostId = _vmInstanceDao.listByLastHostId(hostId);
if (vmsByLastHostId.size() > 0) {
// check if any VMs are within skip.counting.hours, if yes we have to consider the host.
for (VMInstanceVO stoppedVM : vmsByLastHostId) {
long secondsSinceLastUpdate = (DateUtil.currentGMTTime().getTime() - stoppedVM.getUpdateTime()
.getTime()) / 1000;
if (secondsSinceLastUpdate < capacityReleaseInterval) {
vms.add(stoppedVM);
}
}
}
return vms;
}
private boolean isServiceOfferingUsingPlannerInPreferredMode(long serviceOfferingId) {
boolean preferred = false;
Map<String, String> details = serviceOfferingDetailsDao.findDetails(serviceOfferingId);
if (details != null && !details.isEmpty()) {
String preferredAttribute = details.get("ImplicitDedicationMode");
if (preferredAttribute != null && preferredAttribute.equals("Preferred")) {
preferred = true;
}
}
return preferred;
}
private boolean checkIfAllVmsCreatedInStrictMode(Long accountId, List<VMInstanceVO> allVmsOnHost) {
boolean createdByImplicitStrict = true;
if (allVmsOnHost.isEmpty())
return false;
for (VMInstanceVO vm : allVmsOnHost) {
if (!isImplicitPlannerUsedByOffering(vm.getServiceOfferingId()) || vm.getAccountId()!= accountId) {
s_logger.info("Host " + vm.getHostId() + " found to be running a vm created by a planner other" +
" than implicit, or running vms of other account");
createdByImplicitStrict = false;
break;
} else if (isServiceOfferingUsingPlannerInPreferredMode(vm.getServiceOfferingId()) || vm.getAccountId()!= accountId) {
s_logger.info("Host " + vm.getHostId() + " found to be running a vm created by an implicit planner" +
" in preferred mode, or running vms of other account");
createdByImplicitStrict = false;
break;
}
}
return createdByImplicitStrict;
}
private boolean isImplicitPlannerUsedByOffering(long offeringId) {
boolean implicitPlannerUsed = false;
ServiceOfferingVO offering = _serviceOfferingDao.findByIdIncludingRemoved(offeringId);
if (offering == null) {
s_logger.error("Couldn't retrieve the offering by the given id : " + offeringId);
} else {
String plannerName = offering.getDeploymentPlanner();
if (plannerName != null) {
if(plannerName.equals("ImplicitDedicationPlanner")) {
implicitPlannerUsed = true;
}
}
}
return implicitPlannerUsed;
}
@Override @Override
@ActionEvent(eventType = EventTypes.EVENT_VM_MIGRATE, eventDescription = "migrating VM", async = true) @ActionEvent(eventType = EventTypes.EVENT_VM_MIGRATE, eventDescription = "migrating VM", async = true)
public VirtualMachine migrateVirtualMachineWithVolume(Long vmId, Host destinationHost, public VirtualMachine migrateVirtualMachineWithVolume(Long vmId, Host destinationHost,
@ -3960,7 +4163,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
} }
List<VolumeVO> vmVolumes = _volsDao.findUsableVolumesForInstance(vm.getId()); List<VolumeVO> vmVolumes = _volsDao.findUsableVolumesForInstance(vm.getId());
Map<VolumeVO, StoragePoolVO> volToPoolObjectMap = new HashMap<VolumeVO, StoragePoolVO>(); Map<Volume, StoragePool> volToPoolObjectMap = new HashMap<Volume, StoragePool>();
if (!isVMUsingLocalStorage(vm) && destinationHost.getClusterId().equals(srcHost.getClusterId())) { if (!isVMUsingLocalStorage(vm) && destinationHost.getClusterId().equals(srcHost.getClusterId())) {
if (volumeToPool.isEmpty()) { if (volumeToPool.isEmpty()) {
// If the destination host is in the same cluster and volumes do not have to be migrated across pools // If the destination host is in the same cluster and volumes do not have to be migrated across pools
@ -4008,8 +4211,10 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
" migrate to this host"); " migrate to this host");
} }
VMInstanceVO migratedVm = _itMgr.migrateWithStorage(vm, srcHostId, destinationHost.getId(), volToPoolObjectMap); checkHostsDedication(vm, srcHostId, destinationHost.getId());
return migratedVm;
_itMgr.migrateWithStorage(vm.getUuid(), srcHostId, destinationHost.getId(), volToPoolObjectMap);
return _vmDao.findById(vm.getId());
} }
@DB @DB
@ -4201,9 +4406,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
txn.commit(); txn.commit();
VMInstanceVO vmoi = _itMgr.findByIdAndType(vm.getType(), vm.getId()); VirtualMachine vmoi = _itMgr.findById(vm.getId());
VirtualMachineProfileImpl vmOldProfile = new VirtualMachineProfileImpl( VirtualMachineProfileImpl vmOldProfile = new VirtualMachineProfileImpl(vmoi);
vmoi);
// OS 3: update the network // OS 3: update the network
List<Long> networkIdList = cmd.getNetworkIds(); List<Long> networkIdList = cmd.getNetworkIds();
@ -4279,9 +4483,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
networks.add(new Pair<NetworkVO, NicProfile>(networkList.get(0), networks.add(new Pair<NetworkVO, NicProfile>(networkList.get(0),
profile)); profile));
VMInstanceVO vmi = _itMgr.findByIdAndType(vm.getType(), vm.getId()); VirtualMachine vmi = _itMgr.findById(vm.getId());
VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl( VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl(vmi);
vmi);
_networkMgr.allocate(vmProfile, networks); _networkMgr.allocate(vmProfile, networks);
_securityGroupMgr.addInstanceToGroups(vm.getId(), _securityGroupMgr.addInstanceToGroups(vm.getId(),
@ -4413,10 +4616,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
networks.add(new Pair<NetworkVO, NicProfile>(appNet, networks.add(new Pair<NetworkVO, NicProfile>(appNet,
defaultNic)); defaultNic));
} }
VMInstanceVO vmi = _itMgr.findByIdAndType(vm.getType(), VirtualMachine vmi = _itMgr.findById(vm.getId());
vm.getId()); VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl(vmi);
VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl(
vmi);
_networkMgr.allocate(vmProfile, networks); _networkMgr.allocate(vmProfile, networks);
s_logger.debug("AssignVM: Advance virtual, adding networks no " s_logger.debug("AssignVM: Advance virtual, adding networks no "
+ networks.size() + " to " + vm.getInstanceName()); + networks.size() + " to " + vm.getInstanceName());
@ -4527,7 +4728,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
if (needRestart) { if (needRestart) {
try { try {
_itMgr.stop(vm, user, caller); _itMgr.stop(vm.getUuid());
} catch (ResourceUnavailableException e) { } catch (ResourceUnavailableException e) {
s_logger.debug("Stop vm " + vm.getUuid() + " failed", e); s_logger.debug("Stop vm " + vm.getUuid() + " failed", e);
CloudRuntimeException ex = new CloudRuntimeException( CloudRuntimeException ex = new CloudRuntimeException(

View File

@ -20,8 +20,6 @@ import java.net.URI;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import com.cloud.agent.api.to.NicTO; import com.cloud.agent.api.to.NicTO;
import com.cloud.agent.api.to.VirtualMachineTO; import com.cloud.agent.api.to.VirtualMachineTO;
import com.cloud.deploy.DeployDestination; import com.cloud.deploy.DeployDestination;
@ -43,9 +41,7 @@ import com.cloud.service.ServiceOfferingVO;
import com.cloud.storage.DiskOfferingVO; import com.cloud.storage.DiskOfferingVO;
import com.cloud.storage.StoragePool; import com.cloud.storage.StoragePool;
import com.cloud.storage.VMTemplateVO; import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.VolumeVO; import com.cloud.storage.Volume;
import com.cloud.user.Account;
import com.cloud.user.User;
import com.cloud.utils.Pair; import com.cloud.utils.Pair;
import com.cloud.utils.component.Manager; import com.cloud.utils.component.Manager;
import com.cloud.utils.fsm.NoTransitionException; import com.cloud.utils.fsm.NoTransitionException;
@ -76,9 +72,9 @@ public interface VirtualMachineManager extends Manager {
void start(String vmUuid, Map<VirtualMachineProfile.Param, Object> params, DeploymentPlan planToDeploy); void start(String vmUuid, Map<VirtualMachineProfile.Param, Object> params, DeploymentPlan planToDeploy);
<T extends VMInstanceVO> boolean stop(T vm, User caller, Account account) throws ResourceUnavailableException; void stop(String vmUuid) throws ResourceUnavailableException;
<T extends VMInstanceVO> boolean expunge(T vm, User caller, Account account) throws ResourceUnavailableException; void expunge(String vmUuid) throws ResourceUnavailableException;
void registerGuru(VirtualMachine.Type type, VirtualMachineGuru guru); void registerGuru(VirtualMachine.Type type, VirtualMachineGuru guru);
@ -90,25 +86,22 @@ public interface VirtualMachineManager extends Manager {
void advanceStart(String vmUuid, Map<VirtualMachineProfile.Param, Object> params, DeploymentPlan planToDeploy) throws InsufficientCapacityException, void advanceStart(String vmUuid, Map<VirtualMachineProfile.Param, Object> params, DeploymentPlan planToDeploy) throws InsufficientCapacityException,
ResourceUnavailableException, ConcurrentOperationException, OperationTimedoutException; ResourceUnavailableException, ConcurrentOperationException, OperationTimedoutException;
<T extends VMInstanceVO> boolean advanceStop(T vm, boolean forced, User caller, Account account) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException; void advanceStop(String vmUuid, boolean cleanupEvenIfUnableToStop) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException;
<T extends VMInstanceVO> boolean advanceExpunge(T vm, User caller, Account account) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException; void advanceExpunge(String vmUuid) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException;
<T extends VMInstanceVO> boolean remove(T vm, User caller, Account account); void destroy(String vmUuid) throws AgentUnavailableException, OperationTimedoutException, ConcurrentOperationException;
<T extends VMInstanceVO> boolean destroy(T vm, User caller, Account account) throws AgentUnavailableException, OperationTimedoutException, ConcurrentOperationException; void migrateAway(String vmUuid, long hostId) throws InsufficientServerCapacityException;
boolean migrateAway(VirtualMachine.Type type, long vmid, long hostId) throws InsufficientServerCapacityException, VirtualMachineMigrationException; void migrate(String vmUuid, long srcHostId, DeployDestination dest) throws ResourceUnavailableException, ConcurrentOperationException;
<T extends VMInstanceVO> T migrate(T vm, long srcHostId, DeployDestination dest) throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException, VirtualMachineMigrationException; void migrateWithStorage(String vmUuid, long srcId, long destId, Map<Volume, StoragePool> volumeToPool) throws ResourceUnavailableException, ConcurrentOperationException;
<T extends VMInstanceVO> T migrateWithStorage(T vm, long srcId, long destId, Map<VolumeVO, StoragePoolVO> volumeToPool) throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException, VirtualMachineMigrationException; void reboot(String vmUuid, Map<VirtualMachineProfile.Param, Object> params) throws InsufficientCapacityException, ResourceUnavailableException;
<T extends VMInstanceVO> T reboot(T vm, Map<VirtualMachineProfile.Param, Object> params, User caller, Account account) throws InsufficientCapacityException, ResourceUnavailableException; void advanceReboot(String vmUuid, Map<VirtualMachineProfile.Param, Object> params) throws InsufficientCapacityException, ResourceUnavailableException,
ConcurrentOperationException, OperationTimedoutException;
<T extends VMInstanceVO> T advanceReboot(T vm, Map<VirtualMachineProfile.Param, Object> params, User caller, Account account) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException, OperationTimedoutException;
VMInstanceVO findByIdAndType(VirtualMachine.Type type, long vmId);
/** /**
* Check to see if a virtual machine can be upgraded to the given service offering * Check to see if a virtual machine can be upgraded to the given service offering
@ -119,7 +112,7 @@ public interface VirtualMachineManager extends Manager {
*/ */
boolean isVirtualMachineUpgradable(final VirtualMachine vm, final ServiceOffering offering); boolean isVirtualMachineUpgradable(final VirtualMachine vm, final ServiceOffering offering);
VMInstanceVO findById(long vmId); VirtualMachine findById(long vmId);
<T extends VMInstanceVO> T storageMigration(T vm, StoragePool storagePoolId); <T extends VMInstanceVO> T storageMigration(T vm, StoragePool storagePoolId);

View File

@ -41,9 +41,9 @@ import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator; import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator;
import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
import org.apache.cloudstack.utils.identity.ManagementServerNode;
import com.cloud.agent.AgentManager; import com.cloud.agent.AgentManager;
import com.cloud.agent.AgentManager.OnError; import com.cloud.agent.AgentManager.OnError;
@ -81,10 +81,8 @@ import com.cloud.agent.manager.Commands;
import com.cloud.agent.manager.allocator.HostAllocator; import com.cloud.agent.manager.allocator.HostAllocator;
import com.cloud.alert.AlertManager; import com.cloud.alert.AlertManager;
import com.cloud.capacity.CapacityManager; import com.cloud.capacity.CapacityManager;
import com.cloud.cluster.ClusterManager;
import com.cloud.configuration.Config; import com.cloud.configuration.Config;
import com.cloud.configuration.ConfigurationManager; import com.cloud.configuration.ConfigurationManager;
import com.cloud.configuration.Resource.ResourceType;
import com.cloud.configuration.dao.ConfigurationDao; import com.cloud.configuration.dao.ConfigurationDao;
import com.cloud.dc.ClusterDetailsDao; import com.cloud.dc.ClusterDetailsDao;
import com.cloud.dc.ClusterDetailsVO; import com.cloud.dc.ClusterDetailsVO;
@ -94,11 +92,9 @@ import com.cloud.dc.HostPodVO;
import com.cloud.dc.dao.ClusterDao; import com.cloud.dc.dao.ClusterDao;
import com.cloud.dc.dao.DataCenterDao; import com.cloud.dc.dao.DataCenterDao;
import com.cloud.dc.dao.HostPodDao; import com.cloud.dc.dao.HostPodDao;
import com.cloud.dc.dao.VlanDao;
import com.cloud.deploy.DataCenterDeployment; import com.cloud.deploy.DataCenterDeployment;
import com.cloud.deploy.DeployDestination; import com.cloud.deploy.DeployDestination;
import com.cloud.deploy.DeploymentPlan; import com.cloud.deploy.DeploymentPlan;
import com.cloud.deploy.DeploymentPlanner;
import com.cloud.deploy.DeploymentPlanner.ExcludeList; import com.cloud.deploy.DeploymentPlanner.ExcludeList;
import com.cloud.deploy.DeploymentPlanningManager; import com.cloud.deploy.DeploymentPlanningManager;
import com.cloud.domain.dao.DomainDao; import com.cloud.domain.dao.DomainDao;
@ -145,7 +141,6 @@ import com.cloud.service.ServiceOfferingVO;
import com.cloud.service.dao.ServiceOfferingDao; import com.cloud.service.dao.ServiceOfferingDao;
import com.cloud.storage.DiskOfferingVO; import com.cloud.storage.DiskOfferingVO;
import com.cloud.storage.Storage.ImageFormat; import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.StorageManager;
import com.cloud.storage.StoragePool; import com.cloud.storage.StoragePool;
import com.cloud.storage.VMTemplateVO; import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.Volume; import com.cloud.storage.Volume;
@ -164,7 +159,6 @@ import com.cloud.user.AccountManager;
import com.cloud.user.ResourceLimitService; import com.cloud.user.ResourceLimitService;
import com.cloud.user.User; import com.cloud.user.User;
import com.cloud.user.dao.AccountDao; import com.cloud.user.dao.AccountDao;
import com.cloud.user.dao.UserDao;
import com.cloud.utils.Journal; import com.cloud.utils.Journal;
import com.cloud.utils.NumbersUtil; import com.cloud.utils.NumbersUtil;
import com.cloud.utils.Pair; import com.cloud.utils.Pair;
@ -197,8 +191,6 @@ import com.cloud.vm.snapshot.dao.VMSnapshotDao;
public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMachineManager, Listener { public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMachineManager, Listener {
private static final Logger s_logger = Logger.getLogger(VirtualMachineManagerImpl.class); private static final Logger s_logger = Logger.getLogger(VirtualMachineManagerImpl.class);
@Inject
protected StorageManager _storageMgr;
@Inject @Inject
DataStoreManager dataStoreMgr; DataStoreManager dataStoreMgr;
@Inject @Inject
@ -216,14 +208,10 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
@Inject @Inject
protected VMTemplateDao _templateDao; protected VMTemplateDao _templateDao;
@Inject @Inject
protected UserDao _userDao;
@Inject
protected AccountDao _accountDao; protected AccountDao _accountDao;
@Inject @Inject
protected DomainDao _domainDao; protected DomainDao _domainDao;
@Inject @Inject
protected ClusterManager _clusterMgr;
@Inject
protected ItWorkDao _workDao; protected ItWorkDao _workDao;
@Inject @Inject
protected UserVmDao _userVmDao; protected UserVmDao _userVmDao;
@ -264,8 +252,6 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
@Inject @Inject
protected VMSnapshotDao _vmSnapshotDao; protected VMSnapshotDao _vmSnapshotDao;
@Inject @Inject
protected VolumeDataFactory volFactory;
@Inject
protected ResourceLimitService _resourceLimitMgr; protected ResourceLimitService _resourceLimitMgr;
@Inject @Inject
protected RulesManager rulesMgr; protected RulesManager rulesMgr;
@ -278,20 +264,10 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
@Inject @Inject
protected IPAddressDao _publicIpAddressDao; protected IPAddressDao _publicIpAddressDao;
@Inject @Inject
protected VlanDao _vlanDao;
@Inject
protected NicIpAliasDao _nicIpAliasDao; protected NicIpAliasDao _nicIpAliasDao;
@Inject @Inject
protected EntityManager _entityMgr; protected EntityManager _entityMgr;
protected List<DeploymentPlanner> _planners;
public List<DeploymentPlanner> getPlanners() {
return _planners;
}
public void setPlanners(List<DeploymentPlanner> _planners) {
this._planners = _planners;
}
protected List<HostAllocator> _hostAllocators; protected List<HostAllocator> _hostAllocators;
public List<HostAllocator> getHostAllocators() { public List<HostAllocator> getHostAllocators() {
return _hostAllocators; return _hostAllocators;
@ -418,16 +394,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
} }
@Override @Override
public <T extends VMInstanceVO> boolean expunge(T vm, User caller, Account account) throws ResourceUnavailableException { public void expunge(String vmUuid) throws ResourceUnavailableException {
try { try {
if (advanceExpunge(vm, caller, account)) { advanceExpunge(vmUuid);
// Mark vms as removed
remove(vm, caller, account);
return true;
} else {
s_logger.info("Did not expunge " + vm);
return false;
}
} catch (OperationTimedoutException e) { } catch (OperationTimedoutException e) {
throw new CloudRuntimeException("Operation timed out", e); throw new CloudRuntimeException("Operation timed out", e);
} catch (ConcurrentOperationException e) { } catch (ConcurrentOperationException e) {
@ -436,28 +405,30 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
} }
@Override @Override
public <T extends VMInstanceVO> boolean advanceExpunge(T vm, User caller, Account account) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException { public void advanceExpunge(String vmUuid) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException {
VMInstanceVO vm = _vmDao.findByUuid(vmUuid);
advanceExpunge(vm);
}
protected void advanceExpunge(VMInstanceVO vm) throws ResourceUnavailableException, OperationTimedoutException, ConcurrentOperationException {
if (vm == null || vm.getRemoved() != null) { if (vm == null || vm.getRemoved() != null) {
if (s_logger.isDebugEnabled()) { if (s_logger.isDebugEnabled()) {
s_logger.debug("Unable to find vm or vm is destroyed: " + vm); s_logger.debug("Unable to find vm or vm is destroyed: " + vm);
} }
return true; return;
} }
if (!this.advanceStop(vm, false, caller, account)) { advanceStop(vm, false);
if (s_logger.isDebugEnabled()) {
s_logger.debug("Unable to stop the VM so we can't expunge it.");
}
}
try { try {
if (!stateTransitTo(vm, VirtualMachine.Event.ExpungeOperation, vm.getHostId())) { if (!stateTransitTo(vm, VirtualMachine.Event.ExpungeOperation, vm.getHostId())) {
s_logger.debug("Unable to destroy the vm because it is not in the correct state: " + vm); s_logger.debug("Unable to destroy the vm because it is not in the correct state: " + vm);
return false; throw new CloudRuntimeException("Unable to destroy " + vm);
} }
} catch (NoTransitionException e) { } catch (NoTransitionException e) {
s_logger.debug("Unable to destroy the vm because it is not in the correct state: " + vm); s_logger.debug("Unable to destroy the vm because it is not in the correct state: " + vm);
return false; throw new CloudRuntimeException("Unable to destroy " + vm, e);
} }
if (s_logger.isDebugEnabled()) { if (s_logger.isDebugEnabled()) {
@ -477,7 +448,6 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
_networkMgr.cleanupNics(profile); _networkMgr.cleanupNics(profile);
// Clean up volumes based on the vm's instance id // Clean up volumes based on the vm's instance id
List<VolumeVO> rootVol = _volsDao.findByInstanceAndType(vm.getId(), Volume.Type.ROOT);
volumeMgr.cleanupVolumes(vm.getId()); volumeMgr.cleanupVolumes(vm.getId());
VirtualMachineGuru guru = getVmGuru(vm); VirtualMachineGuru guru = getVmGuru(vm);
@ -502,12 +472,11 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
_agentMgr.send(hostId, cmds); _agentMgr.send(hostId, cmds);
if(!cmds.isSuccessful()){ if(!cmds.isSuccessful()){
for (Answer answer : cmds.getAnswers()){ for (Answer answer : cmds.getAnswers()){
if(answer != null && !answer.getResult()){ if (!answer.getResult()) {
s_logger.warn("Failed to expunge vm due to: " + answer.getDetails()); s_logger.warn("Failed to expunge vm due to: " + answer.getDetails());
break; throw new CloudRuntimeException("Unable to expunge " + vm + " due to " + answer.getDetails());
} }
} }
return false;
} }
} }
} }
@ -516,13 +485,6 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
s_logger.debug("Expunged " + vm); s_logger.debug("Expunged " + vm);
} }
// Update Resource count
if (vm.getAccountId() != Account.ACCOUNT_ID_SYSTEM && !rootVol.isEmpty()) {
_resourceLimitMgr.decrementResourceCount(vm.getAccountId(), ResourceType.volume);
_resourceLimitMgr.decrementResourceCount(vm.getAccountId(), ResourceType.primary_storage,
new Long(rootVol.get(0).getSize()));
}
return true;
} }
@DB @DB
@ -578,8 +540,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
_retry = NumbersUtil.parseInt(params.get(Config.StartRetry.key()), 10); _retry = NumbersUtil.parseInt(params.get(Config.StartRetry.key()), 10);
ReservationContextImpl.setComponents(_userDao, _domainDao, _accountDao); ReservationContextImpl.init(_entityMgr);
VirtualMachineProfileImpl.setComponents(_offeringDao, _templateDao, _accountDao); VirtualMachineProfileImpl.init(_entityMgr);
_cancelWait = NumbersUtil.parseLong(params.get(Config.VmOpCancelInterval.key()), 3600); _cancelWait = NumbersUtil.parseLong(params.get(Config.VmOpCancelInterval.key()), 3600);
_cleanupWait = NumbersUtil.parseLong(params.get(Config.VmOpCleanupWait.key()), 3600); _cleanupWait = NumbersUtil.parseLong(params.get(Config.VmOpCleanupWait.key()), 3600);
@ -590,7 +552,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
_forceStop = Boolean.parseBoolean(params.get(Config.VmDestroyForcestop.key())); _forceStop = Boolean.parseBoolean(params.get(Config.VmDestroyForcestop.key()));
_executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("Vm-Operations-Cleanup")); _executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("Vm-Operations-Cleanup"));
_nodeId = _clusterMgr.getManagementNodeId(); _nodeId = ManagementServerNode.getManagementServerId();
_agentMgr.registerForHostEvents(this, true, true, true); _agentMgr.registerForHostEvents(this, true, true, true);
@ -1014,10 +976,10 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
_workDao.updateStep(work, Step.Release); _workDao.updateStep(work, Step.Release);
// If previous step was started/ing && we got a valid answer // If previous step was started/ing && we got a valid answer
if((prevStep == Step.Started || prevStep == Step.Starting) && (startAnswer != null && startAnswer.getResult())){ //TODO check the response of cleanup and record it in DB for retry if((prevStep == Step.Started || prevStep == Step.Starting) && (startAnswer != null && startAnswer.getResult())){ //TODO check the response of cleanup and record it in DB for retry
cleanup(vmGuru, vmProfile, work, Event.OperationFailed, false, caller, account); cleanup(vmGuru, vmProfile, work, Event.OperationFailed, false);
} else { } else {
//if step is not starting/started, send cleanup command with force=true //if step is not starting/started, send cleanup command with force=true
cleanup(vmGuru, vmProfile, work, Event.OperationFailed, true, caller, account); cleanup(vmGuru, vmProfile, work, Event.OperationFailed, true);
} }
} }
} }
@ -1045,11 +1007,11 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
} }
@Override @Override
public <T extends VMInstanceVO> boolean stop(T vm, User user, Account account) throws ResourceUnavailableException { public void stop(String vmUuid) throws ResourceUnavailableException {
try { try {
return advanceStop(vm, false, user, account); advanceStop(vmUuid, false);
} catch (OperationTimedoutException e) { } catch (OperationTimedoutException e) {
throw new AgentUnavailableException("Unable to stop vm because the operation to stop timed out", vm.getHostId(), e); throw new AgentUnavailableException("Unable to stop vm because the operation to stop timed out", e.getAgentId(), e);
} catch (ConcurrentOperationException e) { } catch (ConcurrentOperationException e) {
throw new CloudRuntimeException("Unable to stop vm because of a concurrent operation", e); throw new CloudRuntimeException("Unable to stop vm because of a concurrent operation", e);
} }
@ -1079,20 +1041,20 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
return true; return true;
} }
protected boolean cleanup(VirtualMachineGuru guru, VirtualMachineProfile profile, ItWorkVO work, Event event, boolean force, User user, Account account) { protected boolean cleanup(VirtualMachineGuru guru, VirtualMachineProfile profile, ItWorkVO work, Event event, boolean cleanUpEvenIfUnableToStop) {
VirtualMachine vm = profile.getVirtualMachine(); VirtualMachine vm = profile.getVirtualMachine();
State state = vm.getState(); State state = vm.getState();
s_logger.debug("Cleaning up resources for the vm " + vm + " in " + state + " state"); s_logger.debug("Cleaning up resources for the vm " + vm + " in " + state + " state");
if (state == State.Starting) { if (state == State.Starting) {
Step step = work.getStep(); Step step = work.getStep();
if (step == Step.Starting && !force) { if (step == Step.Starting && !cleanUpEvenIfUnableToStop) {
s_logger.warn("Unable to cleanup vm " + vm + "; work state is incorrect: " + step); s_logger.warn("Unable to cleanup vm " + vm + "; work state is incorrect: " + step);
return false; return false;
} }
if (step == Step.Started || step == Step.Starting || step == Step.Release) { if (step == Step.Started || step == Step.Starting || step == Step.Release) {
if (vm.getHostId() != null) { if (vm.getHostId() != null) {
if (!sendStop(guru, profile, force)) { if (!sendStop(guru, profile, cleanUpEvenIfUnableToStop)) {
s_logger.warn("Failed to stop vm " + vm + " in " + State.Starting + " state as a part of cleanup process"); s_logger.warn("Failed to stop vm " + vm + " in " + State.Starting + " state as a part of cleanup process");
return false; return false;
} }
@ -1105,33 +1067,33 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
} }
} else if (state == State.Stopping) { } else if (state == State.Stopping) {
if (vm.getHostId() != null) { if (vm.getHostId() != null) {
if (!sendStop(guru, profile, force)) { if (!sendStop(guru, profile, cleanUpEvenIfUnableToStop)) {
s_logger.warn("Failed to stop vm " + vm + " in " + State.Stopping + " state as a part of cleanup process"); s_logger.warn("Failed to stop vm " + vm + " in " + State.Stopping + " state as a part of cleanup process");
return false; return false;
} }
} }
} else if (state == State.Migrating) { } else if (state == State.Migrating) {
if (vm.getHostId() != null) { if (vm.getHostId() != null) {
if (!sendStop(guru, profile, force)) { if (!sendStop(guru, profile, cleanUpEvenIfUnableToStop)) {
s_logger.warn("Failed to stop vm " + vm + " in " + State.Migrating + " state as a part of cleanup process"); s_logger.warn("Failed to stop vm " + vm + " in " + State.Migrating + " state as a part of cleanup process");
return false; return false;
} }
} }
if (vm.getLastHostId() != null) { if (vm.getLastHostId() != null) {
if (!sendStop(guru, profile, force)) { if (!sendStop(guru, profile, cleanUpEvenIfUnableToStop)) {
s_logger.warn("Failed to stop vm " + vm + " in " + State.Migrating + " state as a part of cleanup process"); s_logger.warn("Failed to stop vm " + vm + " in " + State.Migrating + " state as a part of cleanup process");
return false; return false;
} }
} }
} else if (state == State.Running) { } else if (state == State.Running) {
if (!sendStop(guru, profile, force)) { if (!sendStop(guru, profile, cleanUpEvenIfUnableToStop)) {
s_logger.warn("Failed to stop vm " + vm + " in " + State.Running + " state as a part of cleanup process"); s_logger.warn("Failed to stop vm " + vm + " in " + State.Running + " state as a part of cleanup process");
return false; return false;
} }
} }
try { try {
_networkMgr.release(profile, force); _networkMgr.release(profile, cleanUpEvenIfUnableToStop);
s_logger.debug("Successfully released network resources for the vm " + vm); s_logger.debug("Successfully released network resources for the vm " + vm);
} catch (Exception e) { } catch (Exception e) {
s_logger.warn("Unable to release some network resources.", e); s_logger.warn("Unable to release some network resources.", e);
@ -1143,20 +1105,26 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
} }
@Override @Override
public <T extends VMInstanceVO> boolean advanceStop(T vm, boolean forced, User user, Account account) throws AgentUnavailableException, OperationTimedoutException, ConcurrentOperationException { public void advanceStop(String vmUuid, boolean cleanUpEvenIfUnableToStop) throws AgentUnavailableException, OperationTimedoutException, ConcurrentOperationException {
VMInstanceVO vm = _vmDao.findByUuid(vmUuid);
advanceStop(vm, cleanUpEvenIfUnableToStop);
}
private void advanceStop(VMInstanceVO vm, boolean cleanUpEvenIfUnableToStop) throws AgentUnavailableException, OperationTimedoutException, ConcurrentOperationException {
State state = vm.getState(); State state = vm.getState();
if (state == State.Stopped) { if (state == State.Stopped) {
if (s_logger.isDebugEnabled()) { if (s_logger.isDebugEnabled()) {
s_logger.debug("VM is already stopped: " + vm); s_logger.debug("VM is already stopped: " + vm);
} }
return true; return;
} }
if (state == State.Destroyed || state == State.Expunging || state == State.Error) { if (state == State.Destroyed || state == State.Expunging || state == State.Error) {
if (s_logger.isDebugEnabled()) { if (s_logger.isDebugEnabled()) {
s_logger.debug("Stopped called on " + vm + " but the state is " + state); s_logger.debug("Stopped called on " + vm + " but the state is " + state);
} }
return true; return;
} }
// grab outstanding work item if any // grab outstanding work item if any
ItWorkVO work = _workDao.findByOutstandingWork(vm.getId(), vm.getState()); ItWorkVO work = _workDao.findByOutstandingWork(vm.getId(), vm.getState());
@ -1167,11 +1135,11 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
} }
Long hostId = vm.getHostId(); Long hostId = vm.getHostId();
if (hostId == null) { if (hostId == null) {
if (!forced) { if (!cleanUpEvenIfUnableToStop) {
if (s_logger.isDebugEnabled()) { if (s_logger.isDebugEnabled()) {
s_logger.debug("HostId is null but this is not a forced stop, cannot stop vm " + vm + " with state:" + vm.getState()); s_logger.debug("HostId is null but this is not a forced stop, cannot stop vm " + vm + " with state:" + vm.getState());
} }
return false; throw new CloudRuntimeException("Unable to stop " + vm);
} }
try { try {
stateTransitTo(vm, Event.AgentReportStopped, null, null); stateTransitTo(vm, Event.AgentReportStopped, null, null);
@ -1186,7 +1154,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
work.setStep(Step.Done); work.setStep(Step.Done);
_workDao.update(work.getId(), work); _workDao.update(work.getId(), work);
} }
return true; return;
} }
VirtualMachineGuru vmGuru = getVmGuru(vm); VirtualMachineGuru vmGuru = getVmGuru(vm);
@ -1197,7 +1165,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
throw new ConcurrentOperationException("VM is being operated on."); throw new ConcurrentOperationException("VM is being operated on.");
} }
} catch (NoTransitionException e1) { } catch (NoTransitionException e1) {
if (!forced) { if (!cleanUpEvenIfUnableToStop) {
throw new CloudRuntimeException("We cannot stop " + vm + " when it is in state " + vm.getState()); throw new CloudRuntimeException("We cannot stop " + vm + " when it is in state " + vm.getState());
} }
boolean doCleanup = false; boolean doCleanup = false;
@ -1218,15 +1186,17 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
} }
if (doCleanup) { if (doCleanup) {
if (cleanup(vmGuru, new VirtualMachineProfileImpl(vm), work, Event.StopRequested, forced, user, account)) { if (cleanup(vmGuru, new VirtualMachineProfileImpl(vm), work, Event.StopRequested, cleanUpEvenIfUnableToStop)) {
try { try {
if (s_logger.isDebugEnabled()) { if (s_logger.isDebugEnabled()) {
s_logger.debug("Updating work item to Done, id:" + work.getId()); s_logger.debug("Updating work item to Done, id:" + work.getId());
} }
return changeState(vm, Event.AgentReportStopped, null, work, Step.Done); if (!changeState(vm, Event.AgentReportStopped, null, work, Step.Done)) {
throw new CloudRuntimeException("Unable to stop " + vm);
}
} catch (NoTransitionException e) { } catch (NoTransitionException e) {
s_logger.warn("Unable to cleanup " + vm); s_logger.warn("Unable to cleanup " + vm);
return false; throw new CloudRuntimeException("Unable to stop " + vm, e);
} }
} else { } else {
if (s_logger.isDebugEnabled()) { if (s_logger.isDebugEnabled()) {
@ -1271,14 +1241,14 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
throw e; throw e;
} finally { } finally {
if (!stopped) { if (!stopped) {
if (!forced) { if (!cleanUpEvenIfUnableToStop) {
s_logger.warn("Unable to stop vm " + vm); s_logger.warn("Unable to stop vm " + vm);
try { try {
stateTransitTo(vm, Event.OperationFailed, vm.getHostId()); stateTransitTo(vm, Event.OperationFailed, vm.getHostId());
} catch (NoTransitionException e) { } catch (NoTransitionException e) {
s_logger.warn("Unable to transition the state " + vm); s_logger.warn("Unable to transition the state " + vm);
} }
return false; throw new CloudRuntimeException("Unable to stop " + vm);
} else { } else {
s_logger.warn("Unable to actually stop " + vm + " but continue with release because it's a force stop"); s_logger.warn("Unable to actually stop " + vm + " but continue with release because it's a force stop");
vmGuru.finalizeStop(profile, answer); vmGuru.finalizeStop(profile, answer);
@ -1291,7 +1261,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
} }
try { try {
_networkMgr.release(profile, forced); _networkMgr.release(profile, cleanUpEvenIfUnableToStop);
s_logger.debug("Successfully released network resources for the vm " + vm); s_logger.debug("Successfully released network resources for the vm " + vm);
} catch (Exception e) { } catch (Exception e) {
s_logger.warn("Unable to release some network resources.", e); s_logger.warn("Unable to release some network resources.", e);
@ -1315,10 +1285,12 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
_workDao.update(work.getId(), work); _workDao.update(work.getId(), work);
} }
return stateTransitTo(vm, Event.OperationSucceeded, null); if (!stateTransitTo(vm, Event.OperationSucceeded, null)) {
throw new CloudRuntimeException("unable to stop " + vm);
}
} catch (NoTransitionException e) { } catch (NoTransitionException e) {
s_logger.warn(e.getMessage()); s_logger.warn(e.getMessage());
return false; throw new CloudRuntimeException("Unable to stop " + vm);
} }
} }
@ -1353,43 +1325,35 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
} }
@Override @Override
public <T extends VMInstanceVO> boolean remove(T vm, User user, Account caller) { public void destroy(String vmUuid) throws AgentUnavailableException, OperationTimedoutException, ConcurrentOperationException {
return _vmDao.remove(vm.getId()); VMInstanceVO vm = _vmDao.findByUuid(vmUuid);
}
@Override
public <T extends VMInstanceVO> boolean destroy(T vm, User user, Account caller) throws AgentUnavailableException, OperationTimedoutException, ConcurrentOperationException {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Destroying vm " + vm);
}
if (vm == null || vm.getState() == State.Destroyed || vm.getState() == State.Expunging || vm.getRemoved() != null) { if (vm == null || vm.getState() == State.Destroyed || vm.getState() == State.Expunging || vm.getRemoved() != null) {
if (s_logger.isDebugEnabled()) { if (s_logger.isDebugEnabled()) {
s_logger.debug("Unable to find vm or vm is destroyed: " + vm); s_logger.debug("Unable to find vm or vm is destroyed: " + vm);
} }
return true; return;
} }
if (!advanceStop(vm, _forceStop, user, caller)) { if (s_logger.isDebugEnabled()) {
s_logger.debug("Unable to stop " + vm); s_logger.debug("Destroying vm " + vm);
return false;
} }
advanceStop(vm, _forceStop);
if (!_vmSnapshotMgr.deleteAllVMSnapshots(vm.getId(),null)){ if (!_vmSnapshotMgr.deleteAllVMSnapshots(vm.getId(),null)){
s_logger.debug("Unable to delete all snapshots for " + vm); s_logger.debug("Unable to delete all snapshots for " + vm);
return false; throw new CloudRuntimeException("Unable to delete vm snapshots for " + vm);
} }
try { try {
if (!stateTransitTo(vm, VirtualMachine.Event.DestroyRequested, vm.getHostId())) { if (!stateTransitTo(vm, VirtualMachine.Event.DestroyRequested, vm.getHostId())) {
s_logger.debug("Unable to destroy the vm because it is not in the correct state: " + vm); s_logger.debug("Unable to destroy the vm because it is not in the correct state: " + vm);
return false; throw new CloudRuntimeException("Unable to destroy " + vm);
} }
} catch (NoTransitionException e) { } catch (NoTransitionException e) {
s_logger.debug(e.getMessage()); s_logger.debug(e.getMessage());
return false; throw new CloudRuntimeException("Unable to destroy " + vm, e);
} }
return true;
} }
//list all the nics which belong to this vm and are the last nics in the subnets. //list all the nics which belong to this vm and are the last nics in the subnets.
@ -1479,17 +1443,18 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
} }
@Override @Override
public <T extends VMInstanceVO> T migrate(T vmm, long srcHostId, DeployDestination dest) throws ResourceUnavailableException, ConcurrentOperationException, public void migrate(String vmUuid, long srcHostId, DeployDestination dest) throws ResourceUnavailableException, ConcurrentOperationException {
ManagementServerException, VMInstanceVO vm = _vmDao.findByUuid(vmUuid);
VirtualMachineMigrationException {
VMInstanceVO vm = _vmDao.findByUuid(vmm.getUuid());
if (vm == null) { if (vm == null) {
if (s_logger.isDebugEnabled()) { if (s_logger.isDebugEnabled()) {
s_logger.debug("Unable to find the vm " + vm); s_logger.debug("Unable to find the vm " + vmUuid);
} }
throw new CloudRuntimeException("Unable to find a virtual machine with id " + vmm.getUuid()); throw new CloudRuntimeException("Unable to find a virtual machine with id " + vmUuid);
}
migrate(vm, srcHostId, dest);
} }
protected void migrate(VMInstanceVO vm, long srcHostId, DeployDestination dest) throws ResourceUnavailableException, ConcurrentOperationException {
s_logger.info("Migrating " + vm + " to " + dest); s_logger.info("Migrating " + vm + " to " + dest);
long dstHostId = dest.getHost().getId(); long dstHostId = dest.getHost().getId();
@ -1510,7 +1475,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
if (s_logger.isDebugEnabled()) { if (s_logger.isDebugEnabled()) {
s_logger.debug("VM is not Running, unable to migrate the vm " + vm); s_logger.debug("VM is not Running, unable to migrate the vm " + vm);
} }
throw new VirtualMachineMigrationException("VM is not Running, unable to migrate the vm currently " + vm + " , current state: " + vm.getState().toString()); throw new CloudRuntimeException("VM is not Running, unable to migrate the vm currently " + vm + " , current state: " + vm.getState().toString());
} }
short alertType = AlertManager.ALERT_TYPE_USERVM_MIGRATE; short alertType = AlertManager.ALERT_TYPE_USERVM_MIGRATE;
@ -1578,8 +1543,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
try { try {
MigrateAnswer ma = (MigrateAnswer) _agentMgr.send(vm.getLastHostId(), mc); MigrateAnswer ma = (MigrateAnswer) _agentMgr.send(vm.getLastHostId(), mc);
if (!ma.getResult()) { if (!ma.getResult()) {
s_logger.error("Unable to migrate due to " + ma.getDetails()); throw new CloudRuntimeException("Unable to migrate due to " + ma.getDetails());
return null;
} }
} catch (OperationTimedoutException e) { } catch (OperationTimedoutException e) {
if (e.isActive()) { if (e.isActive()) {
@ -1605,14 +1569,13 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
} catch (AgentUnavailableException e) { } catch (AgentUnavailableException e) {
s_logger.error("AgentUnavailableException while cleanup on source host: " + srcHostId); s_logger.error("AgentUnavailableException while cleanup on source host: " + srcHostId);
} }
cleanup(vmGuru, new VirtualMachineProfileImpl(vm), work, Event.AgentReportStopped, true, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount()); cleanup(vmGuru, new VirtualMachineProfileImpl(vm), work, Event.AgentReportStopped, true);
return null; throw new CloudRuntimeException("Unable to complete migration for " + vm);
} }
} catch (OperationTimedoutException e) { } catch (OperationTimedoutException e) {
} }
migrated = true; migrated = true;
return vmm;
} finally { } finally {
if (!migrated) { if (!migrated) {
s_logger.info("Migration was unsuccessful. Cleaning up: " + vm); s_logger.info("Migration was unsuccessful. Cleaning up: " + vm);
@ -1640,11 +1603,10 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
} }
} }
private Map<VolumeVO, StoragePoolVO> getPoolListForVolumesForMigration(VirtualMachineProfile profile, private Map<Volume, StoragePool> getPoolListForVolumesForMigration(VirtualMachineProfile profile, Host host, Map<Volume, StoragePool> volumeToPool) {
Host host, Map<VolumeVO, StoragePoolVO> volumeToPool) {
List<VolumeVO> allVolumes = _volsDao.findUsableVolumesForInstance(profile.getId()); List<VolumeVO> allVolumes = _volsDao.findUsableVolumesForInstance(profile.getId());
for (VolumeVO volume : allVolumes) { for (VolumeVO volume : allVolumes) {
StoragePoolVO pool = volumeToPool.get(volume); StoragePool pool = volumeToPool.get(volume);
DiskOfferingVO diskOffering = _diskOfferingDao.findById(volume.getDiskOfferingId()); DiskOfferingVO diskOffering = _diskOfferingDao.findById(volume.getDiskOfferingId());
StoragePoolVO currentPool = _storagePoolDao.findById(volume.getPoolId()); StoragePoolVO currentPool = _storagePoolDao.findById(volume.getPoolId());
if (pool != null) { if (pool != null) {
@ -1728,10 +1690,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
} }
@Override @Override
public <T extends VMInstanceVO> T migrateWithStorage(T vmm, long srcHostId, long destHostId, public void migrateWithStorage(String vmUuid, long srcHostId, long destHostId, Map<Volume, StoragePool> volumeToPool) throws ResourceUnavailableException,
Map<VolumeVO, StoragePoolVO> volumeToPool) throws ResourceUnavailableException, ConcurrentOperationException, ConcurrentOperationException {
ManagementServerException, VirtualMachineMigrationException { VMInstanceVO vm = _vmDao.findByUuid(vmUuid);
VMInstanceVO vm = _vmDao.findByUuid(vmm.getUuid());
HostVO srcHost = _hostDao.findById(srcHostId); HostVO srcHost = _hostDao.findById(srcHostId);
HostVO destHost = _hostDao.findById(destHostId); HostVO destHost = _hostDao.findById(destHostId);
@ -1791,16 +1752,14 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
} catch (AgentUnavailableException e) { } catch (AgentUnavailableException e) {
s_logger.error("AgentUnavailableException while cleanup on source host: " + srcHostId); s_logger.error("AgentUnavailableException while cleanup on source host: " + srcHostId);
} }
cleanup(vmGuru, new VirtualMachineProfileImpl(vm), work, Event.AgentReportStopped, true, cleanup(vmGuru, new VirtualMachineProfileImpl(vm), work, Event.AgentReportStopped, true);
_accountMgr.getSystemUser(), _accountMgr.getSystemAccount()); throw new CloudRuntimeException("VM not found on desintation host. Unable to complete migration for " + vm);
return null;
} }
} catch (OperationTimedoutException e) { } catch (OperationTimedoutException e) {
s_logger.warn("Error while checking the vm " + vm + " is on host " + destHost, e); s_logger.warn("Error while checking the vm " + vm + " is on host " + destHost, e);
} }
migrated = true; migrated = true;
return vmm;
} finally { } finally {
if (!migrated) { if (!migrated) {
s_logger.info("Migration was unsuccessful. Cleaning up: " + vm); s_logger.info("Migration was unsuccessful. Cleaning up: " + vm);
@ -1869,11 +1828,11 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
} }
@Override @Override
public boolean migrateAway(VirtualMachine.Type vmType, long vmId, long srcHostId) throws InsufficientServerCapacityException, VirtualMachineMigrationException { public void migrateAway(String vmUuid, long srcHostId) throws InsufficientServerCapacityException {
VMInstanceVO vm = _vmDao.findById(vmId); VMInstanceVO vm = _vmDao.findByUuid(vmUuid);
if (vm == null) { if (vm == null) {
s_logger.debug("Unable to find a VM for " + vmId); s_logger.debug("Unable to find a VM for " + vmUuid);
return true; throw new CloudRuntimeException("Unable to find " + vmUuid);
} }
VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm); VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm);
@ -1881,7 +1840,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
Long hostId = vm.getHostId(); Long hostId = vm.getHostId();
if (hostId == null) { if (hostId == null) {
s_logger.debug("Unable to migrate because the VM doesn't have a host id: " + vm); s_logger.debug("Unable to migrate because the VM doesn't have a host id: " + vm);
return true; throw new CloudRuntimeException("Unable to migrate " + vmUuid);
} }
Host host = _hostDao.findById(hostId); Host host = _hostDao.findById(hostId);
@ -1913,38 +1872,28 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
} }
excludes.addHost(dest.getHost().getId()); excludes.addHost(dest.getHost().getId());
VMInstanceVO vmInstance = null;
try { try {
vmInstance = migrate(vm, srcHostId, dest); migrate(vm, srcHostId, dest);
return;
} catch (ResourceUnavailableException e) { } catch (ResourceUnavailableException e) {
s_logger.debug("Unable to migrate to unavailable " + dest); s_logger.debug("Unable to migrate to unavailable " + dest);
} catch (ConcurrentOperationException e) { } catch (ConcurrentOperationException e) {
s_logger.debug("Unable to migrate VM due to: " + e.getMessage()); s_logger.debug("Unable to migrate VM due to: " + e.getMessage());
} catch (ManagementServerException e) {
s_logger.debug("Unable to migrate VM: " + e.getMessage());
} catch (VirtualMachineMigrationException e) {
s_logger.debug("Got VirtualMachineMigrationException, Unable to migrate: " + e.getMessage());
if (vm.getState() == State.Starting) {
s_logger.debug("VM seems to be still Starting, we should retry migration later");
throw e;
} else {
s_logger.debug("Unable to migrate VM, VM is not in Running or even Starting state, current state: " + vm.getState().toString());
}
}
if (vmInstance != null) {
return true;
} }
try { try {
boolean result = advanceStop(vm, true, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount()); advanceStop(vm, true);
return result; throw new CloudRuntimeException("Unable to migrate " + vm);
} catch (ResourceUnavailableException e) { } catch (ResourceUnavailableException e) {
s_logger.debug("Unable to stop VM due to " + e.getMessage()); s_logger.debug("Unable to stop VM due to " + e.getMessage());
throw new CloudRuntimeException("Unable to migrate " + vm);
} catch (ConcurrentOperationException e) { } catch (ConcurrentOperationException e) {
s_logger.debug("Unable to stop VM due to " + e.getMessage()); s_logger.debug("Unable to stop VM due to " + e.getMessage());
throw new CloudRuntimeException("Unable to migrate " + vm);
} catch (OperationTimedoutException e) { } catch (OperationTimedoutException e) {
s_logger.debug("Unable to stop VM due to " + e.getMessage()); s_logger.debug("Unable to stop VM due to " + e.getMessage());
throw new CloudRuntimeException("Unable to migrate " + vm);
} }
return false;
} }
} }
@ -1975,18 +1924,18 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
} }
@Override @Override
public <T extends VMInstanceVO> T reboot(T vm, Map<VirtualMachineProfile.Param, Object> params, User caller, Account account) throws InsufficientCapacityException, ResourceUnavailableException { public void reboot(String vmUuid, Map<VirtualMachineProfile.Param, Object> params) throws InsufficientCapacityException, ResourceUnavailableException {
try { try {
return advanceReboot(vm, params, caller, account); advanceReboot(vmUuid, params);
} catch (ConcurrentOperationException e) { } catch (ConcurrentOperationException e) {
throw new CloudRuntimeException("Unable to reboot a VM due to concurrent operation", e); throw new CloudRuntimeException("Unable to reboot a VM due to concurrent operation", e);
} }
} }
@Override @Override
public <T extends VMInstanceVO> T advanceReboot(T vm, Map<VirtualMachineProfile.Param, Object> params, User caller, Account account) throws InsufficientCapacityException, public void advanceReboot(String vmUuid, Map<VirtualMachineProfile.Param, Object> params) throws InsufficientCapacityException, ConcurrentOperationException,
ConcurrentOperationException, ResourceUnavailableException { ResourceUnavailableException {
T rebootedVm = null; VMInstanceVO vm = _vmDao.findByUuid(vmUuid);
DataCenter dc = _configMgr.getZone(vm.getDataCenterId()); DataCenter dc = _configMgr.getZone(vm.getDataCenterId());
Host host = _hostDao.findById(vm.getHostId()); Host host = _hostDao.findById(vm.getHostId());
@ -2005,21 +1954,13 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
Answer rebootAnswer = cmds.getAnswer(RebootAnswer.class); Answer rebootAnswer = cmds.getAnswer(RebootAnswer.class);
if (rebootAnswer != null && rebootAnswer.getResult()) { if (rebootAnswer != null && rebootAnswer.getResult()) {
rebootedVm = vm; return;
return rebootedVm;
} }
s_logger.info("Unable to reboot VM " + vm + " on " + dest.getHost() + " due to " + (rebootAnswer == null ? " no reboot answer" : rebootAnswer.getDetails())); s_logger.info("Unable to reboot VM " + vm + " on " + dest.getHost() + " due to " + (rebootAnswer == null ? " no reboot answer" : rebootAnswer.getDetails()));
} catch (OperationTimedoutException e) { } catch (OperationTimedoutException e) {
s_logger.warn("Unable to send the reboot command to host " + dest.getHost() + " for the vm " + vm + " due to operation timeout", e); s_logger.warn("Unable to send the reboot command to host " + dest.getHost() + " for the vm " + vm + " due to operation timeout", e);
throw new CloudRuntimeException("Failed to reboot the vm on host " + dest.getHost()); throw new CloudRuntimeException("Failed to reboot the vm on host " + dest.getHost());
} }
return rebootedVm;
}
@Override
public VMInstanceVO findByIdAndType(VirtualMachine.Type type, long vmId) {
return _vmDao.findById(vmId);
} }
public Command cleanup(VirtualMachine vm) { public Command cleanup(VirtualMachine vm) {
@ -2301,7 +2242,6 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
if (vm != null) { if (vm != null) {
map.put(vm.getId(), new AgentVmInfo(entry.getKey(), vm, entry.getValue().second(), entry.getValue().first())); map.put(vm.getId(), new AgentVmInfo(entry.getKey(), vm, entry.getValue().second(), entry.getValue().first()));
is_alien_vm = false; is_alien_vm = false;
break;
} }
// alien VMs // alien VMs
if (is_alien_vm){ if (is_alien_vm){
@ -2466,7 +2406,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
if (agentState == State.Shutdowned) { if (agentState == State.Shutdowned) {
if (serverState == State.Running || serverState == State.Starting || serverState == State.Stopping) { if (serverState == State.Running || serverState == State.Starting || serverState == State.Stopping) {
try { try {
advanceStop(vm, true, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount()); advanceStop(vm, true);
} catch (AgentUnavailableException e) { } catch (AgentUnavailableException e) {
assert (false) : "How do we hit this with forced on?"; assert (false) : "How do we hit this with forced on?";
return null; return null;
@ -2858,17 +2798,11 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
ResourceUnavailableException, InsufficientCapacityException { ResourceUnavailableException, InsufficientCapacityException {
s_logger.debug("Adding vm " + vm + " to network " + network + "; requested nic profile " + requested); s_logger.debug("Adding vm " + vm + " to network " + network + "; requested nic profile " + requested);
VMInstanceVO vmVO; VMInstanceVO vmVO = _vmDao.findById(vm.getId());
if (vm.getType() == VirtualMachine.Type.User) {
vmVO = _userVmDao.findById(vm.getId());
} else {
vmVO = _vmDao.findById(vm.getId());
}
ReservationContext context = new ReservationContextImpl(null, null, _accountMgr.getActiveUser(User.UID_SYSTEM), ReservationContext context = new ReservationContextImpl(null, null, _accountMgr.getActiveUser(User.UID_SYSTEM),
_accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM)); _accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM));
VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl(vmVO, null, VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl(vmVO, null, null, null, null);
null, null, null);
DataCenter dc = _configMgr.getZone(network.getDataCenterId()); DataCenter dc = _configMgr.getZone(network.getDataCenterId());
Host host = _hostDao.findById(vm.getHostId()); Host host = _hostDao.findById(vm.getHostId());
@ -3246,7 +3180,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
} catch (AgentUnavailableException e) { } catch (AgentUnavailableException e) {
s_logger.error("AgentUnavailableException while cleanup on source host: " + srcHostId); s_logger.error("AgentUnavailableException while cleanup on source host: " + srcHostId);
} }
cleanup(vmGuru, new VirtualMachineProfileImpl(vm), work, Event.AgentReportStopped, true, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount()); cleanup(vmGuru, new VirtualMachineProfileImpl(vm), work, Event.AgentReportStopped, true);
return null; return null;
} }
} catch (OperationTimedoutException e) { } catch (OperationTimedoutException e) {

View File

@ -25,13 +25,11 @@ import com.cloud.agent.api.to.DiskTO;
import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.offering.ServiceOffering; import com.cloud.offering.ServiceOffering;
import com.cloud.service.ServiceOfferingVO; import com.cloud.service.ServiceOfferingVO;
import com.cloud.service.dao.ServiceOfferingDao;
import com.cloud.storage.VMTemplateVO; import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.dao.VMTemplateDao;
import com.cloud.template.VirtualMachineTemplate; import com.cloud.template.VirtualMachineTemplate;
import com.cloud.template.VirtualMachineTemplate.BootloaderType; import com.cloud.template.VirtualMachineTemplate.BootloaderType;
import com.cloud.user.Account; import com.cloud.user.Account;
import com.cloud.user.dao.AccountDao; import com.cloud.utils.db.EntityManager;
/** /**
* Implementation of VirtualMachineProfile. * Implementation of VirtualMachineProfile.
@ -40,8 +38,8 @@ import com.cloud.user.dao.AccountDao;
public class VirtualMachineProfileImpl implements VirtualMachineProfile { public class VirtualMachineProfileImpl implements VirtualMachineProfile {
VirtualMachine _vm; VirtualMachine _vm;
ServiceOfferingVO _offering; ServiceOffering _offering;
VMTemplateVO _template; VirtualMachineTemplate _template;
UserVmDetailVO _userVmDetails; UserVmDetailVO _userVmDetails;
Map<Param, Object> _params; Map<Param, Object> _params;
List<NicProfile> _nics = new ArrayList<NicProfile>(); List<NicProfile> _nics = new ArrayList<NicProfile>();
@ -88,7 +86,7 @@ public class VirtualMachineProfileImpl implements VirtualMachineProfile {
@Override @Override
public ServiceOffering getServiceOffering() { public ServiceOffering getServiceOffering() {
if (_offering == null) { if (_offering == null) {
_offering = s_offeringDao.findByIdIncludingRemoved(_vm.getServiceOfferingId()); _offering = s_entityMgr.findById(ServiceOffering.class, _vm.getServiceOfferingId());
} }
return _offering; return _offering;
} }
@ -106,7 +104,7 @@ public class VirtualMachineProfileImpl implements VirtualMachineProfile {
@Override @Override
public VirtualMachineTemplate getTemplate() { public VirtualMachineTemplate getTemplate() {
if (_template == null && _vm != null) { if (_template == null && _vm != null) {
_template = s_templateDao.findByIdIncludingRemoved(_vm.getTemplateId()); _template = s_entityMgr.findById(VirtualMachineTemplate.class, _vm.getTemplateId());
} }
return _template; return _template;
} }
@ -184,7 +182,7 @@ public class VirtualMachineProfileImpl implements VirtualMachineProfile {
@Override @Override
public Account getOwner() { public Account getOwner() {
if (_owner == null) { if (_owner == null) {
_owner = s_accountDao.findByIdIncludingRemoved(_vm.getAccountId()); _owner = s_entityMgr.findById(Account.class, _vm.getAccountId());
} }
return _owner; return _owner;
} }
@ -194,13 +192,10 @@ public class VirtualMachineProfileImpl implements VirtualMachineProfile {
return _bootArgs.toString(); return _bootArgs.toString();
} }
static ServiceOfferingDao s_offeringDao; static EntityManager s_entityMgr;
static VMTemplateDao s_templateDao;
static AccountDao s_accountDao; static void init(EntityManager entityMgr) {
static void setComponents(ServiceOfferingDao offeringDao, VMTemplateDao templateDao, AccountDao accountDao) { s_entityMgr = entityMgr;
s_offeringDao = offeringDao;
s_templateDao = templateDao;
s_accountDao = accountDao;
} }
@Override @Override

View File

@ -74,7 +74,6 @@ import com.cloud.storage.dao.SnapshotDao;
import com.cloud.storage.dao.VolumeDao; import com.cloud.storage.dao.VolumeDao;
import com.cloud.user.Account; import com.cloud.user.Account;
import com.cloud.user.AccountManager; import com.cloud.user.AccountManager;
import com.cloud.user.UserVO;
import com.cloud.user.dao.AccountDao; import com.cloud.user.dao.AccountDao;
import com.cloud.user.dao.UserDao; import com.cloud.user.dao.UserDao;
import com.cloud.uservm.UserVm; import com.cloud.uservm.UserVm;
@ -664,11 +663,8 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
"VM Snapshot reverting failed due to vm snapshot is not in the state of Created."); "VM Snapshot reverting failed due to vm snapshot is not in the state of Created.");
} }
UserVO callerUser = _userDao.findById(CallContext.current().getCallingUserId());
UserVmVO vm = null; UserVmVO vm = null;
Long hostId = null; Long hostId = null;
Account owner = _accountDao.findById(vmSnapshotVo.getAccountId());
// start or stop VM first, if revert from stopped state to running state, or from running to stopped // start or stop VM first, if revert from stopped state to running state, or from running to stopped
if(userVm.getState() == VirtualMachine.State.Stopped && vmSnapshotVo.getType() == VMSnapshot.Type.DiskAndMemory){ if(userVm.getState() == VirtualMachine.State.Stopped && vmSnapshotVo.getType() == VMSnapshot.Type.DiskAndMemory){
@ -683,7 +679,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
}else { }else {
if(userVm.getState() == VirtualMachine.State.Running && vmSnapshotVo.getType() == VMSnapshot.Type.Disk){ if(userVm.getState() == VirtualMachine.State.Running && vmSnapshotVo.getType() == VMSnapshot.Type.Disk){
try { try {
_itMgr.advanceStop(userVm, true, callerUser, owner); _itMgr.advanceStop(userVm.getUuid(), true);
} catch (Exception e) { } catch (Exception e) {
s_logger.error("Stop VM " + userVm.getInstanceName() + " before reverting failed due to " + e.getMessage()); s_logger.error("Stop VM " + userVm.getInstanceName() + " before reverting failed due to " + e.getMessage());
throw new CloudRuntimeException(e.getMessage()); throw new CloudRuntimeException(e.getMessage());

View File

@ -197,7 +197,6 @@ public class UserVmManagerTest {
when(_rootVols.get(eq(0))).thenReturn(_volumeMock); when(_rootVols.get(eq(0))).thenReturn(_volumeMock);
doReturn(3L).when(_volumeMock).getTemplateId(); doReturn(3L).when(_volumeMock).getTemplateId();
when(_templateDao.findById(anyLong())).thenReturn(_templateMock); when(_templateDao.findById(anyLong())).thenReturn(_templateMock);
when(_itMgr.stop(_vmMock, _userMock, _account)).thenReturn(true);
when(_storageMgr.allocateDuplicateVolume(_volumeMock, null)).thenReturn(_volumeMock); when(_storageMgr.allocateDuplicateVolume(_volumeMock, null)).thenReturn(_volumeMock);
doNothing().when(_volsDao).attachVolume(anyLong(), anyLong(), anyLong()); doNothing().when(_volsDao).attachVolume(anyLong(), anyLong(), anyLong());
when(_volumeMock.getId()).thenReturn(3L); when(_volumeMock.getId()).thenReturn(3L);
@ -230,7 +229,6 @@ public class UserVmManagerTest {
doReturn(ImageFormat.VHD).when(_templateMock).getFormat(); doReturn(ImageFormat.VHD).when(_templateMock).getFormat();
when(_templateDao.findById(anyLong())).thenReturn(_templateMock); when(_templateDao.findById(anyLong())).thenReturn(_templateMock);
doNothing().when(_accountMgr).checkAccess(_account, null, true, _templateMock); doNothing().when(_accountMgr).checkAccess(_account, null, true, _templateMock);
when(_itMgr.stop(_vmMock, _userMock, _account)).thenReturn(true);
when(_storageMgr.allocateDuplicateVolume(_volumeMock, 14L)).thenReturn(_volumeMock); when(_storageMgr.allocateDuplicateVolume(_volumeMock, 14L)).thenReturn(_volumeMock);
when(_templateMock.getGuestOSId()).thenReturn(5L); when(_templateMock.getGuestOSId()).thenReturn(5L);
doNothing().when(_vmMock).setGuestOSId(anyLong()); doNothing().when(_vmMock).setGuestOSId(anyLong());
@ -269,7 +267,6 @@ public class UserVmManagerTest {
doReturn(ImageFormat.ISO).when(_templateMock).getFormat(); doReturn(ImageFormat.ISO).when(_templateMock).getFormat();
when(_templateDao.findById(anyLong())).thenReturn(_templateMock); when(_templateDao.findById(anyLong())).thenReturn(_templateMock);
doNothing().when(_accountMgr).checkAccess(_account, null, true, _templateMock); doNothing().when(_accountMgr).checkAccess(_account, null, true, _templateMock);
when(_itMgr.stop(_vmMock, _userMock, _account)).thenReturn(true);
when(_storageMgr.allocateDuplicateVolume(_volumeMock, null)).thenReturn(_volumeMock); when(_storageMgr.allocateDuplicateVolume(_volumeMock, null)).thenReturn(_volumeMock);
doNothing().when(_vmMock).setIsoId(14L); doNothing().when(_vmMock).setIsoId(14L);
when(_templateMock.getGuestOSId()).thenReturn(5L); when(_templateMock.getGuestOSId()).thenReturn(5L);

View File

@ -79,8 +79,10 @@ import com.cloud.network.NetworkManager;
import com.cloud.server.ConfigurationServer; import com.cloud.server.ConfigurationServer;
import com.cloud.service.ServiceOfferingVO; import com.cloud.service.ServiceOfferingVO;
import com.cloud.storage.DiskOfferingVO; import com.cloud.storage.DiskOfferingVO;
import com.cloud.storage.StoragePool;
import com.cloud.storage.StoragePoolHostVO; import com.cloud.storage.StoragePoolHostVO;
import com.cloud.storage.VMTemplateVO; import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.Volume;
import com.cloud.storage.VolumeManager; import com.cloud.storage.VolumeManager;
import com.cloud.storage.VolumeVO; import com.cloud.storage.VolumeVO;
import com.cloud.storage.dao.DiskOfferingDao; import com.cloud.storage.dao.DiskOfferingDao;
@ -104,7 +106,8 @@ import com.cloud.vm.snapshot.VMSnapshotManager;
public class VirtualMachineManagerImplTest { public class VirtualMachineManagerImplTest {
@Spy VirtualMachineManagerImpl _vmMgr = new VirtualMachineManagerImpl(); @Spy
VirtualMachineManagerImpl _vmMgr = new VirtualMachineManagerImpl();
@Mock @Mock
VolumeManager _storageMgr; VolumeManager _storageMgr;
@Mock @Mock
@ -162,24 +165,40 @@ public class VirtualMachineManagerImplTest {
@Mock @Mock
UserVmDetailVO _vmDetailVO; UserVmDetailVO _vmDetailVO;
@Mock ClusterDao _clusterDao; @Mock
@Mock HostPodDao _podDao; ClusterDao _clusterDao;
@Mock DataCenterDao _dcDao; @Mock
@Mock DiskOfferingDao _diskOfferingDao; HostPodDao _podDao;
@Mock PrimaryDataStoreDao _storagePoolDao; @Mock
@Mock UserVmDetailsDao _vmDetailsDao; DataCenterDao _dcDao;
@Mock StoragePoolHostDao _poolHostDao; @Mock
@Mock NetworkManager _networkMgr; DiskOfferingDao _diskOfferingDao;
@Mock HypervisorGuruManager _hvGuruMgr; @Mock
@Mock VMSnapshotManager _vmSnapshotMgr; PrimaryDataStoreDao _storagePoolDao;
@Mock
UserVmDetailsDao _vmDetailsDao;
@Mock
StoragePoolHostDao _poolHostDao;
@Mock
NetworkManager _networkMgr;
@Mock
HypervisorGuruManager _hvGuruMgr;
@Mock
VMSnapshotManager _vmSnapshotMgr;
// Mock objects for vm migration with storage test. // Mock objects for vm migration with storage test.
@Mock DiskOfferingVO _diskOfferingMock; @Mock
@Mock StoragePoolVO _srcStoragePoolMock; DiskOfferingVO _diskOfferingMock;
@Mock StoragePoolVO _destStoragePoolMock; @Mock
@Mock HostVO _srcHostMock; StoragePoolVO _srcStoragePoolMock;
@Mock HostVO _destHostMock; @Mock
@Mock Map<VolumeVO, StoragePoolVO> _volumeToPoolMock; StoragePoolVO _destStoragePoolMock;
@Mock
HostVO _srcHostMock;
@Mock
HostVO _destHostMock;
@Mock
Map<Volume, StoragePool> _volumeToPoolMock;
@Before @Before
public void setup() { public void setup() {
@ -189,7 +208,6 @@ public class VirtualMachineManagerImplTest {
_vmMgr._volsDao = _volsDao; _vmMgr._volsDao = _volsDao;
_vmMgr.volumeMgr = _storageMgr; _vmMgr.volumeMgr = _storageMgr;
_vmMgr._accountDao = _accountDao; _vmMgr._accountDao = _accountDao;
_vmMgr._userDao = _userDao;
_vmMgr._accountMgr = _accountMgr; _vmMgr._accountMgr = _accountMgr;
_vmMgr._configMgr = _configMgr; _vmMgr._configMgr = _configMgr;
_vmMgr._capacityMgr = _capacityMgr; _vmMgr._capacityMgr = _capacityMgr;
@ -229,11 +247,9 @@ public class VirtualMachineManagerImplTest {
} }
@Test(expected = CloudRuntimeException.class) @Test(expected = CloudRuntimeException.class)
public void testScaleVM1() throws Exception { public void testScaleVM1() throws Exception {
DeployDestination dest = new DeployDestination(null, null, null, _host); DeployDestination dest = new DeployDestination(null, null, null, _host);
long l = 1L; long l = 1L;
@ -261,7 +277,8 @@ public class VirtualMachineManagerImplTest {
when(_configServer.getConfigValue(Config.MemOverprovisioningFactor.key(), Config.ConfigurationParameterScope.cluster.toString(), 1L)).thenReturn("1.0"); when(_configServer.getConfigValue(Config.MemOverprovisioningFactor.key(), Config.ConfigurationParameterScope.cluster.toString(), 1L)).thenReturn("1.0");
when(_configServer.getConfigValue(Config.CPUOverprovisioningFactor.key(), Config.ConfigurationParameterScope.cluster.toString(), 1L)).thenReturn("1.0"); when(_configServer.getConfigValue(Config.CPUOverprovisioningFactor.key(), Config.ConfigurationParameterScope.cluster.toString(), 1L)).thenReturn("1.0");
ScaleVmCommand reconfigureCmd = new ScaleVmCommand("myVmName", newServiceOffering.getCpu(), ScaleVmCommand reconfigureCmd = new ScaleVmCommand("myVmName", newServiceOffering.getCpu(),
newServiceOffering.getSpeed(), newServiceOffering.getSpeed(), newServiceOffering.getRamSize(), newServiceOffering.getRamSize(), newServiceOffering.getLimitCpuUse(), true); newServiceOffering.getSpeed(), newServiceOffering.getSpeed(), newServiceOffering.getRamSize(), newServiceOffering.getRamSize(),
newServiceOffering.getLimitCpuUse(), true);
Answer answer = new ScaleVmAnswer(reconfigureCmd, true, "details"); Answer answer = new ScaleVmAnswer(reconfigureCmd, true, "details");
when(_agentMgr.send(2l, reconfigureCmd)).thenReturn(null); when(_agentMgr.send(2l, reconfigureCmd)).thenReturn(null);
_vmMgr.reConfigureVm(_vmInstance, getSvcoffering(256), false); _vmMgr.reConfigureVm(_vmInstance, getSvcoffering(256), false);
@ -286,7 +303,6 @@ public class VirtualMachineManagerImplTest {
} }
private ServiceOfferingVO getSvcoffering(int ramSize) { private ServiceOfferingVO getSvcoffering(int ramSize) {
long id = 4L; long id = 4L;
@ -409,7 +425,7 @@ public class VirtualMachineManagerImplTest {
when(_srcHostMock.getClusterId()).thenReturn(3L); when(_srcHostMock.getClusterId()).thenReturn(3L);
when(_destHostMock.getClusterId()).thenReturn(3L); when(_destHostMock.getClusterId()).thenReturn(3L);
_vmMgr.migrateWithStorage(_vmInstance, _srcHostMock.getId(), _destHostMock.getId(), _volumeToPoolMock); _vmMgr.migrateWithStorage(_vmInstance.getUuid(), _srcHostMock.getId(), _destHostMock.getId(), _volumeToPoolMock);
} }
// Check migration of a vm with its volumes across a cluster. // Check migration of a vm with its volumes across a cluster.
@ -421,7 +437,7 @@ public class VirtualMachineManagerImplTest {
when(_srcHostMock.getClusterId()).thenReturn(3L); when(_srcHostMock.getClusterId()).thenReturn(3L);
when(_destHostMock.getClusterId()).thenReturn(4L); when(_destHostMock.getClusterId()).thenReturn(4L);
_vmMgr.migrateWithStorage(_vmInstance, _srcHostMock.getId(), _destHostMock.getId(), _volumeToPoolMock); _vmMgr.migrateWithStorage(_vmInstance.getUuid(), _srcHostMock.getId(), _destHostMock.getId(), _volumeToPoolMock);
} }
// Check migration of a vm fails when src and destination pool are not of same type; that is, one is shared and // Check migration of a vm fails when src and destination pool are not of same type; that is, one is shared and
@ -437,7 +453,7 @@ public class VirtualMachineManagerImplTest {
when(_destStoragePoolMock.isLocal()).thenReturn(true); when(_destStoragePoolMock.isLocal()).thenReturn(true);
when(_diskOfferingMock.getUseLocalStorage()).thenReturn(false); when(_diskOfferingMock.getUseLocalStorage()).thenReturn(false);
_vmMgr.migrateWithStorage(_vmInstance, _srcHostMock.getId(), _destHostMock.getId(), _volumeToPoolMock); _vmMgr.migrateWithStorage(_vmInstance.getUuid(), _srcHostMock.getId(), _destHostMock.getId(), _volumeToPoolMock);
} }
// Check migration of a vm fails when vm is not in Running state. // Check migration of a vm fails when vm is not in Running state.
@ -451,6 +467,6 @@ public class VirtualMachineManagerImplTest {
when(_vmMock.getState()).thenReturn(State.Stopped); when(_vmMock.getState()).thenReturn(State.Stopped);
_vmMgr.migrateWithStorage(_vmInstance, _srcHostMock.getId(), _destHostMock.getId(), _volumeToPoolMock); _vmMgr.migrateWithStorage(_vmInstance.getUuid(), _srcHostMock.getId(), _destHostMock.getId(), _volumeToPoolMock);
} }
} }

View File

@ -892,114 +892,6 @@ CREATE VIEW `cloud`.`host_view` AS
and async_job.instance_type = 'Host' and async_job.instance_type = 'Host'
and async_job.job_status = 0; and async_job.job_status = 0;
DROP VIEW IF EXISTS `cloud`.`volume_view`;
CREATE VIEW `cloud`.`volume_view` AS
select
volumes.id,
volumes.uuid,
volumes.name,
volumes.device_id,
volumes.volume_type,
volumes.size,
volumes.min_iops,
volumes.max_iops,
volumes.created,
volumes.state,
volumes.attached,
volumes.removed,
volumes.pod_id,
account.id account_id,
account.uuid account_uuid,
account.account_name account_name,
account.type account_type,
domain.id domain_id,
domain.uuid domain_uuid,
domain.name domain_name,
domain.path domain_path,
projects.id project_id,
projects.uuid project_uuid,
projects.name project_name,
data_center.id data_center_id,
data_center.uuid data_center_uuid,
data_center.name data_center_name,
data_center.networktype data_center_type,
vm_instance.id vm_id,
vm_instance.uuid vm_uuid,
vm_instance.name vm_name,
vm_instance.state vm_state,
vm_instance.vm_type,
user_vm.display_name vm_display_name,
volume_host_ref.size volume_host_size,
volume_host_ref.created volume_host_created,
volume_host_ref.format,
volume_host_ref.download_pct,
volume_host_ref.download_state,
volume_host_ref.error_str,
disk_offering.id disk_offering_id,
disk_offering.uuid disk_offering_uuid,
disk_offering.name disk_offering_name,
disk_offering.display_text disk_offering_display_text,
disk_offering.use_local_storage,
disk_offering.system_use,
disk_offering.bytes_read_rate,
disk_offering.bytes_write_rate,
disk_offering.iops_read_rate,
disk_offering.iops_write_rate,
storage_pool.id pool_id,
storage_pool.uuid pool_uuid,
storage_pool.name pool_name,
cluster.hypervisor_type,
vm_template.id template_id,
vm_template.uuid template_uuid,
vm_template.extractable,
vm_template.type template_type,
resource_tags.id tag_id,
resource_tags.uuid tag_uuid,
resource_tags.key tag_key,
resource_tags.value tag_value,
resource_tags.domain_id tag_domain_id,
resource_tags.account_id tag_account_id,
resource_tags.resource_id tag_resource_id,
resource_tags.resource_uuid tag_resource_uuid,
resource_tags.resource_type tag_resource_type,
resource_tags.customer tag_customer,
async_job.id job_id,
async_job.uuid job_uuid,
async_job.job_status job_status,
async_job.account_id job_account_id
from
`cloud`.`volumes`
inner join
`cloud`.`account` ON volumes.account_id = account.id
inner join
`cloud`.`domain` ON volumes.domain_id = domain.id
left join
`cloud`.`projects` ON projects.project_account_id = account.id
left join
`cloud`.`data_center` ON volumes.data_center_id = data_center.id
left join
`cloud`.`vm_instance` ON volumes.instance_id = vm_instance.id
left join
`cloud`.`user_vm` ON user_vm.id = vm_instance.id
left join
`cloud`.`volume_host_ref` ON volumes.id = volume_host_ref.volume_id
and volumes.data_center_id = volume_host_ref.zone_id
left join
`cloud`.`disk_offering` ON volumes.disk_offering_id = disk_offering.id
left join
`cloud`.`storage_pool` ON volumes.pool_id = storage_pool.id
left join
`cloud`.`cluster` ON storage_pool.cluster_id = cluster.id
left join
`cloud`.`vm_template` ON volumes.template_id = vm_template.id
left join
`cloud`.`resource_tags` ON resource_tags.resource_id = volumes.id
and resource_tags.resource_type = 'Volume'
left join
`cloud`.`async_job` ON async_job.instance_id = volumes.id
and async_job.instance_type = 'Volume'
and async_job.job_status = 0;
DROP VIEW IF EXISTS `cloud`.`storage_pool_view`; DROP VIEW IF EXISTS `cloud`.`storage_pool_view`;
CREATE VIEW `cloud`.`storage_pool_view` AS CREATE VIEW `cloud`.`storage_pool_view` AS
select select
@ -1780,6 +1672,7 @@ CREATE VIEW `cloud`.`volume_view` AS
volumes.removed, volumes.removed,
volumes.pod_id, volumes.pod_id,
volumes.display_volume, volumes.display_volume,
volumes.format,
account.id account_id, account.id account_id,
account.uuid account_uuid, account.uuid account_uuid,
account.account_name account_name, account.account_name account_name,
@ -1801,12 +1694,11 @@ CREATE VIEW `cloud`.`volume_view` AS
vm_instance.state vm_state, vm_instance.state vm_state,
vm_instance.vm_type, vm_instance.vm_type,
user_vm.display_name vm_display_name, user_vm.display_name vm_display_name,
volume_host_ref.size volume_host_size, volume_store_ref.size volume_store_size,
volume_host_ref.created volume_host_created, volume_store_ref.download_pct,
volume_host_ref.format, volume_store_ref.download_state,
volume_host_ref.download_pct, volume_store_ref.error_str,
volume_host_ref.download_state, volume_store_ref.created created_on_store,
volume_host_ref.error_str,
disk_offering.id disk_offering_id, disk_offering.id disk_offering_id,
disk_offering.uuid disk_offering_uuid, disk_offering.uuid disk_offering_uuid,
disk_offering.name disk_offering_name, disk_offering.name disk_offering_name,
@ -1854,8 +1746,7 @@ CREATE VIEW `cloud`.`volume_view` AS
left join left join
`cloud`.`user_vm` ON user_vm.id = vm_instance.id `cloud`.`user_vm` ON user_vm.id = vm_instance.id
left join left join
`cloud`.`volume_host_ref` ON volumes.id = volume_host_ref.volume_id `cloud`.`volume_store_ref` ON volumes.id = volume_store_ref.volume_id
and volumes.data_center_id = volume_host_ref.zone_id
left join left join
`cloud`.`disk_offering` ON volumes.disk_offering_id = disk_offering.id `cloud`.`disk_offering` ON volumes.disk_offering_id = disk_offering.id
left join left join

View File

@ -876,6 +876,13 @@ class TestTemplateHierarchy(cloudstackTestCase):
account=cls.account_1.name, account=cls.account_1.name,
domainid=cls.domain_1.id domainid=cls.domain_1.id
) )
# Wait for template to download
cls.template.download(cls.api_client)
# Wait for template status to be changed across
time.sleep(60)
cls._cleanup = [ cls._cleanup = [
cls.account_2, cls.account_2,
cls.domain_2, cls.domain_2,
@ -945,7 +952,8 @@ class TestTemplateHierarchy(cloudstackTestCase):
# Verify private service offering is not visible to other domain # Verify private service offering is not visible to other domain
templates = list_templates( templates = list_templates(
self.apiclient, self.apiclient,
templatefilter='self', id=self.template.id,
templatefilter='all',
account=self.account_2.name, account=self.account_2.name,
domainid=self.domain_2.id domainid=self.domain_2.id
) )
@ -1819,7 +1827,7 @@ class TestDomainForceRemove(cloudstackTestCase):
self.services["domain"], self.services["domain"],
parentdomainid=self.domain.id parentdomainid=self.domain.id
) )
self._cleanup.append(domain) self.cleanup.append(domain)
self.debug("Domain: %s is created successfully." % domain.name) self.debug("Domain: %s is created successfully." % domain.name)
self.debug( self.debug(
"Checking if the created domain is listed in list domains API") "Checking if the created domain is listed in list domains API")

View File

@ -107,13 +107,13 @@ class TestASASetup(cloudstackTestCase):
self.clusters = Cluster.list(self.apiclient, hypervisor='VMware') self.clusters = Cluster.list(self.apiclient, hypervisor='VMware')
self.assertNotEqual(len(self.clusters), 0, "Check if the list cluster API returns a non-empty response") self.assertNotEqual(len(self.clusters), 0, "Check if the list cluster API returns a non-empty response")
self.cleanup = []
return return
def tearDown(self): def tearDown(self):
try: try:
self.debug("Cleaning up the resources") self.debug("Cleaning up the resources")
# Cleanup cleanup_resources(self.apiclient, self.cleanup)
cleanup_resources(self.apiclient, self._cleanup)
self.debug("Cleanup complete!") self.debug("Cleanup complete!")
except Exception as e: except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e) raise Exception("Warning: Exception during cleanup : %s" % e)

View File

@ -103,9 +103,7 @@ class TestTemplate(cloudstackTestCase):
def tearDown(self): def tearDown(self):
try: try:
#Clean up, terminate the created templates
cleanup_resources(self.apiclient, self.cleanup) cleanup_resources(self.apiclient, self.cleanup)
except Exception as e: except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e) raise Exception("Warning: Exception during cleanup : %s" % e)
return return
@ -285,6 +283,13 @@ class TestNATRules(cloudstackTestCase):
self.cleanup = [] self.cleanup = []
return return
def tearDown(self):
try:
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
try: try:
@ -293,10 +298,6 @@ class TestNATRules(cloudstackTestCase):
except Exception as e: except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e) raise Exception("Warning: Exception during cleanup : %s" % e)
def tearDown(self):
cleanup_resources(self.apiclient, self.cleanup)
return
@attr(tags = ["advanced"]) @attr(tags = ["advanced"])
def test_01_firewall_rules_port_fw(self): def test_01_firewall_rules_port_fw(self):
""""Checking firewall rules deletion after static NAT disable""" """"Checking firewall rules deletion after static NAT disable"""
@ -493,7 +494,6 @@ class TestRouters(cloudstackTestCase):
def tearDown(self): def tearDown(self):
try: try:
#Clean up, terminate the created instance, users etc
cleanup_resources(self.apiclient, self.cleanup) cleanup_resources(self.apiclient, self.cleanup)
except Exception as e: except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e) raise Exception("Warning: Exception during cleanup : %s" % e)
@ -610,6 +610,10 @@ class TestRouterRestart(cloudstackTestCase):
self.apiclient = self.testClient.getApiClient() self.apiclient = self.testClient.getApiClient()
return return
def tearDown(self):
# No need
return
@attr(tags = ["advanced", "basic", "sg", "advancedns", "eip"]) @attr(tags = ["advanced", "basic", "sg", "advancedns", "eip"])
def test_01_restart_network_cleanup(self): def test_01_restart_network_cleanup(self):
"""TS_BUG_008-Test restart network """TS_BUG_008-Test restart network

View File

@ -1264,7 +1264,7 @@ class TestMultipleAccountsEgressRuleNeg(cloudstackTestCase):
cls.services["account"], cls.services["account"],
domainid=cls.domain.id domainid=cls.domain.id
) )
cls.services["account"] = cls.accountA.account.name cls.services["account"] = cls.accountA.name
cls._cleanup = [ cls._cleanup = [
cls.accountA, cls.accountA,
cls.accountB, cls.accountB,
@ -1308,16 +1308,16 @@ class TestMultipleAccountsEgressRuleNeg(cloudstackTestCase):
security_group = SecurityGroup.create( security_group = SecurityGroup.create(
self.apiclient, self.apiclient,
self.services["security_group"], self.services["security_group"],
account=self.accountA.account.name, account=self.accountA.name,
domainid=self.accountA.account.domainid domainid=self.accountA.domainid
) )
self.debug("Created security group with ID: %s" % security_group.id) self.debug("Created security group with ID: %s" % security_group.id)
# Default Security group should not have any ingress rule # Default Security group should not have any ingress rule
sercurity_groups = SecurityGroup.list( sercurity_groups = SecurityGroup.list(
self.apiclient, self.apiclient,
account=self.accountA.account.name, account=self.accountA.name,
domainid=self.accountA.account.domainid domainid=self.accountA.domainid
) )
self.assertEqual( self.assertEqual(
isinstance(sercurity_groups, list), isinstance(sercurity_groups, list),
@ -1335,13 +1335,13 @@ class TestMultipleAccountsEgressRuleNeg(cloudstackTestCase):
"Authorizing egress rule for sec group ID: %s for ssh access" "Authorizing egress rule for sec group ID: %s for ssh access"
% security_group.id) % security_group.id)
# Authorize to only account not CIDR # Authorize to only account not CIDR
user_secgrp_list = {self.accountB.account.name: 'default'} user_secgrp_list = {self.accountB.name: 'default'}
egress_rule = security_group.authorizeEgress( egress_rule = security_group.authorizeEgress(
self.apiclient, self.apiclient,
self.services["sg_account"], self.services["sg_account"],
account=self.accountA.account.name, account=self.accountA.name,
domainid=self.accountA.account.domainid, domainid=self.accountA.domainid,
user_secgrp_list=user_secgrp_list user_secgrp_list=user_secgrp_list
) )
@ -1359,8 +1359,8 @@ class TestMultipleAccountsEgressRuleNeg(cloudstackTestCase):
ingress_rule = security_group.authorize( ingress_rule = security_group.authorize(
self.apiclient, self.apiclient,
self.services["security_group"], self.services["security_group"],
account=self.accountA.account.name, account=self.accountA.name,
domainid=self.accountA.account.domainid domainid=self.accountA.domainid
) )
self.assertEqual( self.assertEqual(
@ -1374,13 +1374,13 @@ class TestMultipleAccountsEgressRuleNeg(cloudstackTestCase):
self.virtual_machineA = VirtualMachine.create( self.virtual_machineA = VirtualMachine.create(
self.apiclient, self.apiclient,
self.services["virtual_machine"], self.services["virtual_machine"],
accountid=self.accountA.account.name, accountid=self.accountA.name,
domainid=self.accountA.account.domainid, domainid=self.accountA.domainid,
serviceofferingid=self.service_offering.id, serviceofferingid=self.service_offering.id,
securitygroupids=[security_group.id] securitygroupids=[security_group.id]
) )
self.cleanup.append(self.virtual_machineA) self.cleanup.append(self.virtual_machineA)
self.debug("Deploying VM in account: %s" % self.accountA.account.name) self.debug("Deploying VM in account: %s" % self.accountA.name)
vms = VirtualMachine.list( vms = VirtualMachine.list(
self.apiclient, self.apiclient,
id=self.virtual_machineA.id, id=self.virtual_machineA.id,
@ -1402,12 +1402,12 @@ class TestMultipleAccountsEgressRuleNeg(cloudstackTestCase):
self.virtual_machineB = VirtualMachine.create( self.virtual_machineB = VirtualMachine.create(
self.apiclient, self.apiclient,
self.services["virtual_machine"], self.services["virtual_machine"],
accountid=self.accountB.account.name, accountid=self.accountB.name,
domainid=self.accountB.account.domainid, domainid=self.accountB.domainid,
serviceofferingid=self.service_offering.id serviceofferingid=self.service_offering.id
) )
self.cleanup.append(self.virtual_machineB) self.cleanup.append(self.virtual_machineB)
self.debug("Deploying VM in account: %s" % self.accountB.account.name) self.debug("Deploying VM in account: %s" % self.accountB.name)
vms = VirtualMachine.list( vms = VirtualMachine.list(
self.apiclient, self.apiclient,
@ -1512,7 +1512,7 @@ class TestMultipleAccountsEgressRule(cloudstackTestCase):
cls.services["account"], cls.services["account"],
domainid=cls.domain.id domainid=cls.domain.id
) )
cls.services["account"] = cls.accountA.account.name cls.services["account"] = cls.accountA.name
cls._cleanup = [ cls._cleanup = [
cls.accountA, cls.accountA,
cls.accountB, cls.accountB,
@ -1556,16 +1556,16 @@ class TestMultipleAccountsEgressRule(cloudstackTestCase):
security_groupA = SecurityGroup.create( security_groupA = SecurityGroup.create(
self.apiclient, self.apiclient,
self.services["security_group"], self.services["security_group"],
account=self.accountA.account.name, account=self.accountA.name,
domainid=self.accountA.account.domainid domainid=self.accountA.domainid
) )
self.debug("Created security group with ID: %s" % security_groupA.id) self.debug("Created security group with ID: %s" % security_groupA.id)
# Default Security group should not have any ingress rule # Default Security group should not have any ingress rule
sercurity_groups = SecurityGroup.list( sercurity_groups = SecurityGroup.list(
self.apiclient, self.apiclient,
account=self.accountA.account.name, account=self.accountA.name,
domainid=self.accountA.account.domainid domainid=self.accountA.domainid
) )
self.assertEqual( self.assertEqual(
isinstance(sercurity_groups, list), isinstance(sercurity_groups, list),
@ -1582,16 +1582,16 @@ class TestMultipleAccountsEgressRule(cloudstackTestCase):
security_groupB = SecurityGroup.create( security_groupB = SecurityGroup.create(
self.apiclient, self.apiclient,
self.services["security_group"], self.services["security_group"],
account=self.accountB.account.name, account=self.accountB.name,
domainid=self.accountB.account.domainid domainid=self.accountB.domainid
) )
self.debug("Created security group with ID: %s" % security_groupB.id) self.debug("Created security group with ID: %s" % security_groupB.id)
# Default Security group should not have any ingress rule # Default Security group should not have any ingress rule
sercurity_groups = SecurityGroup.list( sercurity_groups = SecurityGroup.list(
self.apiclient, self.apiclient,
account=self.accountB.account.name, account=self.accountB.name,
domainid=self.accountB.account.domainid domainid=self.accountB.domainid
) )
self.assertEqual( self.assertEqual(
isinstance(sercurity_groups, list), isinstance(sercurity_groups, list),
@ -1610,13 +1610,13 @@ class TestMultipleAccountsEgressRule(cloudstackTestCase):
"Authorizing egress rule for sec group ID: %s for ssh access" "Authorizing egress rule for sec group ID: %s for ssh access"
% security_groupA.id) % security_groupA.id)
# Authorize to only account not CIDR # Authorize to only account not CIDR
user_secgrp_list = {self.accountB.account.name: security_groupB.name} user_secgrp_list = {self.accountB.name: security_groupB.name}
egress_rule = security_groupA.authorizeEgress( egress_rule = security_groupA.authorizeEgress(
self.apiclient, self.apiclient,
self.services["sg_account"], self.services["sg_account"],
account=self.accountA.account.name, account=self.accountA.name,
domainid=self.accountA.account.domainid, domainid=self.accountA.domainid,
user_secgrp_list=user_secgrp_list user_secgrp_list=user_secgrp_list
) )
@ -1634,8 +1634,8 @@ class TestMultipleAccountsEgressRule(cloudstackTestCase):
ingress_ruleA = security_groupA.authorize( ingress_ruleA = security_groupA.authorize(
self.apiclient, self.apiclient,
self.services["security_group"], self.services["security_group"],
account=self.accountA.account.name, account=self.accountA.name,
domainid=self.accountA.account.domainid domainid=self.accountA.domainid
) )
self.assertEqual( self.assertEqual(
@ -1649,13 +1649,13 @@ class TestMultipleAccountsEgressRule(cloudstackTestCase):
self.virtual_machineA = VirtualMachine.create( self.virtual_machineA = VirtualMachine.create(
self.apiclient, self.apiclient,
self.services["virtual_machine"], self.services["virtual_machine"],
accountid=self.accountA.account.name, accountid=self.accountA.name,
domainid=self.accountA.account.domainid, domainid=self.accountA.domainid,
serviceofferingid=self.service_offering.id, serviceofferingid=self.service_offering.id,
securitygroupids=[security_groupA.id] securitygroupids=[security_groupA.id]
) )
self.cleanup.append(self.virtual_machineA) self.cleanup.append(self.virtual_machineA)
self.debug("Deploying VM in account: %s" % self.accountA.account.name) self.debug("Deploying VM in account: %s" % self.accountA.name)
vms = VirtualMachine.list( vms = VirtualMachine.list(
self.apiclient, self.apiclient,
@ -1682,8 +1682,8 @@ class TestMultipleAccountsEgressRule(cloudstackTestCase):
ingress_ruleB = security_groupB.authorize( ingress_ruleB = security_groupB.authorize(
self.apiclient, self.apiclient,
self.services["security_group"], self.services["security_group"],
account=self.accountB.account.name, account=self.accountB.name,
domainid=self.accountB.account.domainid domainid=self.accountB.domainid
) )
self.assertEqual( self.assertEqual(
@ -1697,13 +1697,13 @@ class TestMultipleAccountsEgressRule(cloudstackTestCase):
self.virtual_machineB = VirtualMachine.create( self.virtual_machineB = VirtualMachine.create(
self.apiclient, self.apiclient,
self.services["virtual_machine"], self.services["virtual_machine"],
accountid=self.accountB.account.name, accountid=self.accountB.name,
domainid=self.accountB.account.domainid, domainid=self.accountB.domainid,
serviceofferingid=self.service_offering.id, serviceofferingid=self.service_offering.id,
securitygroupids=[security_groupB.id] securitygroupids=[security_groupB.id]
) )
self.cleanup.append(self.virtual_machineB) self.cleanup.append(self.virtual_machineB)
self.debug("Deploying VM in account: %s" % self.accountB.account.name) self.debug("Deploying VM in account: %s" % self.accountB.name)
vms = VirtualMachine.list( vms = VirtualMachine.list(
self.apiclient, self.apiclient,

View File

@ -783,21 +783,21 @@ class TestNetScalerSharedMode(cloudstackTestCase):
self.network_3 = Network.create( self.network_3 = Network.create(
self.apiclient, self.apiclient,
self.services["network"], self.services["network"],
accountid=self.account_3.account.name, accountid=self.account_3.name,
domainid=self.account_3.account.domainid, domainid=self.account_3.domainid,
networkofferingid=self.network_offering.id, networkofferingid=self.network_offering.id,
zoneid=self.zone.id zoneid=self.zone.id
) )
self.debug("Created network with ID: %s" % self.network_3.id) self.debug("Created network with ID: %s" % self.network_3.id)
self.debug("Deploying VM in account: %s" % self.account_3.account.name) self.debug("Deploying VM in account: %s" % self.account_3.name)
with self.assertRaises(Exception): with self.assertRaises(Exception):
# Spawn an instance in that network # Spawn an instance in that network
virtual_machine_3 = VirtualMachine.create( virtual_machine_3 = VirtualMachine.create(
self.apiclient, self.apiclient,
self.services["virtual_machine"], self.services["virtual_machine"],
accountid=self.account_3.account.name, accountid=self.account_3.name,
domainid=self.account_3.account.domainid, domainid=self.account_3.domainid,
serviceofferingid=self.service_offering.id, serviceofferingid=self.service_offering.id,
networkids=[str(self.network_3.id)] networkids=[str(self.network_3.id)]
) )
@ -857,8 +857,8 @@ class TestNetScalerSharedMode(cloudstackTestCase):
self.network_offering.id) self.network_offering.id)
networks = Network.list( networks = Network.list(
self.apiclient, self.apiclient,
account=self.account_3.account.name, account=self.account_3.name,
domainid=self.account_3.account.domainid, domainid=self.account_3.domainid,
zoneid=self.zone.id, zoneid=self.zone.id,
listall=True listall=True
) )
@ -866,19 +866,19 @@ class TestNetScalerSharedMode(cloudstackTestCase):
isinstance(networks, list), isinstance(networks, list),
True, True,
"Network should be present for the account: %s" % "Network should be present for the account: %s" %
self.account_3.account.name self.account_3.name
) )
self.network_3 = networks[0] self.network_3 = networks[0]
self.debug("Created network with ID: %s" % self.network_3.id) self.debug("Created network with ID: %s" % self.network_3.id)
self.debug("Deploying VM in account: %s" % self.account_3.account.name) self.debug("Deploying VM in account: %s" % self.account_3.name)
# Spawn an instance in that network # Spawn an instance in that network
virtual_machine_3 = VirtualMachine.create( virtual_machine_3 = VirtualMachine.create(
self.apiclient, self.apiclient,
self.services["virtual_machine"], self.services["virtual_machine"],
accountid=self.account_3.account.name, accountid=self.account_3.name,
domainid=self.account_3.account.domainid, domainid=self.account_3.domainid,
serviceofferingid=self.service_offering.id, serviceofferingid=self.service_offering.id,
networkids=[str(self.network_3.id)] networkids=[str(self.network_3.id)]
) )
@ -923,21 +923,21 @@ class TestNetScalerSharedMode(cloudstackTestCase):
self.network_4 = Network.create( self.network_4 = Network.create(
self.apiclient, self.apiclient,
self.services["network"], self.services["network"],
accountid=self.account_4.account.name, accountid=self.account_4.name,
domainid=self.account_4.account.domainid, domainid=self.account_4.domainid,
networkofferingid=self.network_offering.id, networkofferingid=self.network_offering.id,
zoneid=self.zone.id zoneid=self.zone.id
) )
self.debug("Created network with ID: %s" % self.network_4.id) self.debug("Created network with ID: %s" % self.network_4.id)
self.debug("Deploying VM in account: %s" % self.account_4.account.name) self.debug("Deploying VM in account: %s" % self.account_4.name)
# Spawn an instance in that network # Spawn an instance in that network
virtual_machine_4 = VirtualMachine.create( virtual_machine_4 = VirtualMachine.create(
self.apiclient, self.apiclient,
self.services["virtual_machine"], self.services["virtual_machine"],
accountid=self.account_4.account.name, accountid=self.account_4.name,
domainid=self.account_4.account.domainid, domainid=self.account_4.domainid,
serviceofferingid=self.service_offering.id, serviceofferingid=self.service_offering.id,
networkids=[str(self.network_4.id)] networkids=[str(self.network_4.id)]
) )
@ -970,22 +970,22 @@ class TestNetScalerSharedMode(cloudstackTestCase):
self.network_5 = Network.create( self.network_5 = Network.create(
self.apiclient, self.apiclient,
self.services["network"], self.services["network"],
accountid=self.account_5.account.name, accountid=self.account_5.name,
domainid=self.account_5.account.domainid, domainid=self.account_5.domainid,
networkofferingid=self.network_offering.id, networkofferingid=self.network_offering.id,
zoneid=self.zone.id zoneid=self.zone.id
) )
self.debug("Created network with ID: %s" % self.network_5.id) self.debug("Created network with ID: %s" % self.network_5.id)
self.debug("Deploying VM in account: %s" % self.account_5.account.name) self.debug("Deploying VM in account: %s" % self.account_5.name)
with self.assertRaises(Exception): with self.assertRaises(Exception):
# Spawn an instance in that network # Spawn an instance in that network
virtual_machine_5 = VirtualMachine.create( virtual_machine_5 = VirtualMachine.create(
self.apiclient, self.apiclient,
self.services["virtual_machine"], self.services["virtual_machine"],
accountid=self.account_5.account.name, accountid=self.account_5.name,
domainid=self.account_5.account.domainid, domainid=self.account_5.domainid,
serviceofferingid=self.service_offering.id, serviceofferingid=self.service_offering.id,
networkids=[str(self.network_5.id)] networkids=[str(self.network_5.id)]
) )
@ -1005,9 +1005,9 @@ class TestNetScalerSharedMode(cloudstackTestCase):
# 2. Create an instance from another account # 2. Create an instance from another account
# 3. Deploy instance should succeed # 3. Deploy instance should succeed
self.debug("Delete account: %s" % self.account_4.account.name) self.debug("Delete account: %s" % self.account_4.name)
self.account_4.delete(self.apiclient) self.account_4.delete(self.apiclient)
self.debug("Account: %s is deleted" % self.account_4.account.name) self.debug("Account: %s is deleted" % self.account_4.name)
interval = list_configurations( interval = list_configurations(
self.apiclient, self.apiclient,
@ -1027,21 +1027,21 @@ class TestNetScalerSharedMode(cloudstackTestCase):
self.network_5 = Network.create( self.network_5 = Network.create(
self.apiclient, self.apiclient,
self.services["network"], self.services["network"],
accountid=self.account_5.account.name, accountid=self.account_5.name,
domainid=self.account_5.account.domainid, domainid=self.account_5.domainid,
networkofferingid=self.network_offering.id, networkofferingid=self.network_offering.id,
zoneid=self.zone.id zoneid=self.zone.id
) )
self.debug("Created network with ID: %s" % self.network_5.id) self.debug("Created network with ID: %s" % self.network_5.id)
self.debug("Deploying VM in account: %s" % self.account_5.account.name) self.debug("Deploying VM in account: %s" % self.account_5.name)
# Spawn an instance in that network # Spawn an instance in that network
virtual_machine_5 = VirtualMachine.create( virtual_machine_5 = VirtualMachine.create(
self.apiclient, self.apiclient,
self.services["virtual_machine"], self.services["virtual_machine"],
accountid=self.account_5.account.name, accountid=self.account_5.name,
domainid=self.account_5.account.domainid, domainid=self.account_5.domainid,
serviceofferingid=self.service_offering.id, serviceofferingid=self.service_offering.id,
networkids=[str(self.network_5.id)] networkids=[str(self.network_5.id)]
) )
@ -1504,21 +1504,21 @@ class TestNwOffNetscaler(cloudstackTestCase):
self.network_3 = Network.create( self.network_3 = Network.create(
self.apiclient, self.apiclient,
self.services["network"], self.services["network"],
accountid=self.account_3.account.name, accountid=self.account_3.name,
domainid=self.account_3.account.domainid, domainid=self.account_3.domainid,
networkofferingid=self.network_offering_shared.id, networkofferingid=self.network_offering_shared.id,
zoneid=self.zone.id zoneid=self.zone.id
) )
self.debug("Created network with ID: %s" % self.network_3.id) self.debug("Created network with ID: %s" % self.network_3.id)
self.debug("Deploying VM in account: %s" % self.account_3.account.name) self.debug("Deploying VM in account: %s" % self.account_3.name)
# Spawn an instance in that network # Spawn an instance in that network
virtual_machine_3 = VirtualMachine.create( virtual_machine_3 = VirtualMachine.create(
self.apiclient, self.apiclient,
self.services["virtual_machine"], self.services["virtual_machine"],
accountid=self.account_3.account.name, accountid=self.account_3.name,
domainid=self.account_3.account.domainid, domainid=self.account_3.domainid,
serviceofferingid=self.service_offering.id, serviceofferingid=self.service_offering.id,
networkids=[str(self.network_3.id)] networkids=[str(self.network_3.id)]
) )
@ -1803,20 +1803,20 @@ class TestNwOffSToDUpgrade(cloudstackTestCase):
self.network_3 = Network.create( self.network_3 = Network.create(
self.apiclient, self.apiclient,
self.services["network"], self.services["network"],
accountid=self.account_3.account.name, accountid=self.account_3.name,
domainid=self.account_3.account.domainid, domainid=self.account_3.domainid,
networkofferingid=self.network_offering_dedicated.id, networkofferingid=self.network_offering_dedicated.id,
zoneid=self.zone.id zoneid=self.zone.id
) )
self.debug("Created network with ID: %s" % self.network_3.id) self.debug("Created network with ID: %s" % self.network_3.id)
self.debug("Deploying VM in account: %s" % self.account_3.account.name) self.debug("Deploying VM in account: %s" % self.account_3.name)
# Spawn an instance in that network # Spawn an instance in that network
virtual_machine_3 = VirtualMachine.create( virtual_machine_3 = VirtualMachine.create(
self.apiclient, self.apiclient,
self.services["virtual_machine"], self.services["virtual_machine"],
accountid=self.account_3.account.name, accountid=self.account_3.name,
domainid=self.account_3.account.domainid, domainid=self.account_3.domainid,
serviceofferingid=self.service_offering.id, serviceofferingid=self.service_offering.id,
networkids=[str(self.network_3.id)] networkids=[str(self.network_3.id)]
) )
@ -2220,20 +2220,20 @@ class TestNwOffDToSUpgrade(cloudstackTestCase):
self.network_3 = Network.create( self.network_3 = Network.create(
self.apiclient, self.apiclient,
self.services["network"], self.services["network"],
accountid=self.account_3.account.name, accountid=self.account_3.name,
domainid=self.account_3.account.domainid, domainid=self.account_3.domainid,
networkofferingid=self.network_offering_dedicated.id, networkofferingid=self.network_offering_dedicated.id,
zoneid=self.zone.id zoneid=self.zone.id
) )
self.debug("Created network with ID: %s" % self.network_3.id) self.debug("Created network with ID: %s" % self.network_3.id)
self.debug("Deploying VM in account: %s" % self.account_3.account.name) self.debug("Deploying VM in account: %s" % self.account_3.name)
# Spawn an instance in that network # Spawn an instance in that network
virtual_machine_3 = VirtualMachine.create( virtual_machine_3 = VirtualMachine.create(
self.apiclient, self.apiclient,
self.services["virtual_machine"], self.services["virtual_machine"],
accountid=self.account_3.account.name, accountid=self.account_3.name,
domainid=self.account_3.account.domainid, domainid=self.account_3.domainid,
serviceofferingid=self.service_offering.id, serviceofferingid=self.service_offering.id,
networkids=[str(self.network_3.id)] networkids=[str(self.network_3.id)]
) )
@ -2261,7 +2261,7 @@ class TestNwOffDToSUpgrade(cloudstackTestCase):
"VM state should be running after deployment" "VM state should be running after deployment"
) )
self.debug("Stopping all VMs in account: %s" % self.account_3.account.name) self.debug("Stopping all VMs in account: %s" % self.account_3.name)
virtual_machine_3.stop(self.apiclient) virtual_machine_3.stop(self.apiclient)
list_vm_response = VirtualMachine.list( list_vm_response = VirtualMachine.list(
@ -2314,7 +2314,7 @@ class TestNwOffDToSUpgrade(cloudstackTestCase):
self.network_offering_shared.id, self.network_offering_shared.id,
"Network offering ID should match with new offering ID" "Network offering ID should match with new offering ID"
) )
self.debug("Starting instances in account: %s" % self.account_3.account.name) self.debug("Starting instances in account: %s" % self.account_3.name)
virtual_machine_3.start(self.apiclient) virtual_machine_3.start(self.apiclient)
list_vm_response = VirtualMachine.list( list_vm_response = VirtualMachine.list(
@ -2346,9 +2346,9 @@ class TestNwOffDToSUpgrade(cloudstackTestCase):
public_ip = PublicIPAddress.create( public_ip = PublicIPAddress.create(
self.apiclient, self.apiclient,
accountid=self.account_3.account.name, accountid=self.account_3.name,
zoneid=self.zone.id, zoneid=self.zone.id,
domainid=self.account_3.account.domainid, domainid=self.account_3.domainid,
networkid=self.network_3.id networkid=self.network_3.id
) )
self.debug( self.debug(
@ -2359,7 +2359,7 @@ class TestNwOffDToSUpgrade(cloudstackTestCase):
self.apiclient, self.apiclient,
self.services["lbrule"], self.services["lbrule"],
ipaddressid=public_ip.ipaddress.id, ipaddressid=public_ip.ipaddress.id,
accountid=self.account_3.account.name, accountid=self.account_3.name,
networkid=self.network_3.id networkid=self.network_3.id
) )
self.debug("Created the load balancing rule for public IP: %s" % self.debug("Created the load balancing rule for public IP: %s" %

View File

@ -485,7 +485,7 @@ class TestNetwork(cloudstackTestCase):
networkofferingid=network_offering.id, networkofferingid=network_offering.id,
zoneid=self.zone.id zoneid=self.zone.id
) )
self._cleanup.append(domain_network) self.cleanup.append(domain_network)
self.debug("Created network with ID: %s" % domain_network.id) self.debug("Created network with ID: %s" % domain_network.id)
virtual_machine = VirtualMachine.create( virtual_machine = VirtualMachine.create(
@ -1044,7 +1044,6 @@ class TestPublicIpAddress(cloudstackTestCase):
public_ip.ipaddress.id, public_ip.ipaddress.id,
projectid=self.project.id projectid=self.project.id
) )
self.cleanup.append(lb_rule)
self.debug("Assigning VM: %s to LB rule: %s" % ( self.debug("Assigning VM: %s to LB rule: %s" % (
self.virtual_machine.name, self.virtual_machine.name,
lb_rule.id lb_rule.id

View File

@ -165,7 +165,6 @@ class TestCreateRvRNetworkOffering(cloudstackTestCase):
def tearDown(self): def tearDown(self):
try: try:
#Clean up, terminate the created network offerings
cleanup_resources(self.apiclient, self.cleanup) cleanup_resources(self.apiclient, self.cleanup)
except Exception as e: except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e) raise Exception("Warning: Exception during cleanup : %s" % e)
@ -284,7 +283,15 @@ class TestCreateRvRNetwork(cloudstackTestCase):
admin=True, admin=True,
domainid=self.domain.id domainid=self.domain.id
) )
self._cleanup.insert(0, self.account) self.cleanup = []
self.cleanup.insert(0, self.account)
return
def tearDown(self):
try:
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return return
@attr(tags=["advanced", "advancedns", "ssh"]) @attr(tags=["advanced", "advancedns", "ssh"])
@ -475,7 +482,15 @@ class TestCreateRvRNetworkNonDefaultGuestCidr(cloudstackTestCase):
admin=True, admin=True,
domainid=self.domain.id domainid=self.domain.id
) )
self._cleanup.insert(0, self.account) self.cleanup = []
self.cleanup.insert(0, self.account)
return
def tearDown(self):
try:
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return return
@attr(tags=["advanced", "advancedns"]) @attr(tags=["advanced", "advancedns"])
@ -675,7 +690,15 @@ class TestRVRInternals(cloudstackTestCase):
admin=True, admin=True,
domainid=self.domain.id domainid=self.domain.id
) )
self._cleanup.insert(0, self.account) self.cleanup = []
self.cleanup.insert(0, self.account)
return
def tearDown(self):
try:
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return return
@attr(tags=["advanced", "advancedns", "ssh"]) @attr(tags=["advanced", "advancedns", "ssh"])
@ -988,11 +1011,20 @@ class TestRvRRedundancy(cloudstackTestCase):
networkids=[str(self.network.id)] networkids=[str(self.network.id)]
) )
self.debug("Deployed VM in network: %s" % self.network.id) self.debug("Deployed VM in network: %s" % self.network.id)
self._cleanup.insert(0, self.account) self.cleanup = []
self.cleanup.insert(0, self.account)
self.update_waiting_time = 60;
return
def tearDown(self):
try:
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return return
@attr(tags=["advanced", "advancedns", "ssh"]) @attr(tags=["advanced", "advancedns", "ssh"])
def test_stopMasterRvR(self): def test_01_stopMasterRvR(self):
"""Test stop master RVR """Test stop master RVR
""" """
@ -1048,6 +1080,9 @@ class TestRvRRedundancy(cloudstackTestCase):
except Exception as e: except Exception as e:
self.fail("Failed to stop master router: %s" % e) self.fail("Failed to stop master router: %s" % e)
# wait for VR to update state
time.sleep(self.update_waiting_time)
self.debug("Listing routers for network: %s" % self.network.name) self.debug("Listing routers for network: %s" % self.network.name)
routers = Router.list( routers = Router.list(
self.apiclient, self.apiclient,
@ -1089,6 +1124,9 @@ class TestRvRRedundancy(cloudstackTestCase):
except Exception as e: except Exception as e:
self.fail("Failed to start master router: %s" % e) self.fail("Failed to start master router: %s" % e)
# wait for VR to update state
time.sleep(self.update_waiting_time)
self.debug("Checking state of the master router in %s" % self.network.name) self.debug("Checking state of the master router in %s" % self.network.name)
routers = Router.list( routers = Router.list(
self.apiclient, self.apiclient,
@ -1113,7 +1151,7 @@ class TestRvRRedundancy(cloudstackTestCase):
return return
@attr(tags=["advanced", "advancedns", "ssh"]) @attr(tags=["advanced", "advancedns", "ssh"])
def test_stopBackupRvR(self): def test_02_stopBackupRvR(self):
"""Test stop backup RVR """Test stop backup RVR
""" """
@ -1168,6 +1206,9 @@ class TestRvRRedundancy(cloudstackTestCase):
except Exception as e: except Exception as e:
self.fail("Failed to stop backup router: %s" % e) self.fail("Failed to stop backup router: %s" % e)
# wait for VR update state
time.sleep(self.update_waiting_time)
self.debug("Checking state of the backup router in %s" % self.network.name) self.debug("Checking state of the backup router in %s" % self.network.name)
routers = Router.list( routers = Router.list(
self.apiclient, self.apiclient,
@ -1209,6 +1250,9 @@ class TestRvRRedundancy(cloudstackTestCase):
except Exception as e: except Exception as e:
self.fail("Failed to stop master router: %s" % e) self.fail("Failed to stop master router: %s" % e)
# wait for VR to start and update state
time.sleep(self.update_waiting_time)
self.debug("Checking state of the backup router in %s" % self.network.name) self.debug("Checking state of the backup router in %s" % self.network.name)
routers = Router.list( routers = Router.list(
self.apiclient, self.apiclient,
@ -1233,7 +1277,7 @@ class TestRvRRedundancy(cloudstackTestCase):
return return
@attr(tags=["advanced", "advancedns", "ssh"]) @attr(tags=["advanced", "advancedns", "ssh"])
def test_rebootMasterRvR(self): def test_03_rebootMasterRvR(self):
"""Test reboot master RVR """Test reboot master RVR
""" """
@ -1282,6 +1326,9 @@ class TestRvRRedundancy(cloudstackTestCase):
except Exception as e: except Exception as e:
self.fail("Failed to reboot MASTER router: %s" % e) self.fail("Failed to reboot MASTER router: %s" % e)
# wait for VR to update state
time.sleep(self.update_waiting_time)
self.debug("Checking state of the master router in %s" % self.network.name) self.debug("Checking state of the master router in %s" % self.network.name)
routers = Router.list( routers = Router.list(
self.apiclient, self.apiclient,
@ -1323,7 +1370,7 @@ class TestRvRRedundancy(cloudstackTestCase):
return return
@attr(tags=["advanced", "advancedns", "ssh"]) @attr(tags=["advanced", "advancedns", "ssh"])
def test_rebootBackupRvR(self): def test_04_rebootBackupRvR(self):
"""Test reboot backup RVR """Test reboot backup RVR
""" """
@ -1372,6 +1419,9 @@ class TestRvRRedundancy(cloudstackTestCase):
except Exception as e: except Exception as e:
self.fail("Failed to reboot BACKUP router: %s" % e) self.fail("Failed to reboot BACKUP router: %s" % e)
# wait for VR to update state
time.sleep(self.update_waiting_time)
self.debug("Checking state of the backup router in %s" % self.network.name) self.debug("Checking state of the backup router in %s" % self.network.name)
routers = Router.list( routers = Router.list(
self.apiclient, self.apiclient,
@ -1413,7 +1463,7 @@ class TestRvRRedundancy(cloudstackTestCase):
return return
@attr(tags=["advanced", "advancedns", "ssh"]) @attr(tags=["advanced", "advancedns", "ssh"])
def test_stopBackupRvR_startInstance(self): def test_05_stopBackupRvR_startInstance(self):
"""Test stop backup RVR and start instance """Test stop backup RVR and start instance
""" """
@ -1462,6 +1512,9 @@ class TestRvRRedundancy(cloudstackTestCase):
except Exception as e: except Exception as e:
self.fail("Failed to stop BACKUP router: %s" % e) self.fail("Failed to stop BACKUP router: %s" % e)
# wait for VR to update state
time.sleep(self.update_waiting_time)
self.debug("Checking state of the backup router in %s" % self.network.name) self.debug("Checking state of the backup router in %s" % self.network.name)
routers = Router.list( routers = Router.list(
self.apiclient, self.apiclient,

View File

@ -189,7 +189,16 @@ class TestRedundantRouterNetworkCleanups(cloudstackTestCase):
admin=True, admin=True,
domainid=self.domain.id domainid=self.domain.id
) )
self._cleanup.insert(0, self.account) self.cleanup=[]
self.cleanup.insert(0, self.account)
return
def tearDown(self):
try:
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
self.debug("Warning: Exception during cleanup : %s" % e)
#raise Exception("Warning: Exception during cleanup : %s" % e)
return return
@attr(tags=["advanced", "advancedns", "ssh"]) @attr(tags=["advanced", "advancedns", "ssh"])

View File

@ -188,7 +188,16 @@ class TestRvRDeploymentPlanning(cloudstackTestCase):
admin=True, admin=True,
domainid=self.domain.id domainid=self.domain.id
) )
self._cleanup.insert(0, self.account) self.cleanup = []
self.cleanup.insert(0, self.account)
return
def tearDown(self):
try:
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
self.debug("Warning: Exception during cleanup : %s" % e)
#raise Exception("Warning: Exception during cleanup : %s" % e)
return return
@attr(tags=["advanced", "advancedns"]) @attr(tags=["advanced", "advancedns"])

View File

@ -188,7 +188,16 @@ class TestRedundantRouterRulesLifeCycle(cloudstackTestCase):
admin=True, admin=True,
domainid=self.domain.id domainid=self.domain.id
) )
self._clean.insert(0, self.account) self.cleanup = []
self.cleanup.insert(0, self.account)
return
def tearDown(self):
try:
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
self.debug("Warning: Exception during cleanup : %s" % e)
#raise Exception("Warning: Exception during cleanup : %s" % e)
return return
@attr(tags=["advanced", "advancedns", "ssh"]) @attr(tags=["advanced", "advancedns", "ssh"])

View File

@ -190,7 +190,14 @@ class TestEnableVPNOverRvR(cloudstackTestCase):
admin=True, admin=True,
domainid=self.domain.id domainid=self.domain.id
) )
self._cleanup.insert(0, self.account) self.cleanup.insert(0, self.account)
return
def tearDown(self):
try:
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return return
@attr(tags=["advanced", "advancedns", "ssh"]) @attr(tags=["advanced", "advancedns", "ssh"])

View File

@ -189,7 +189,15 @@ class TestRvRUpgradeDowngrade(cloudstackTestCase):
admin=True, admin=True,
domainid=self.domain.id domainid=self.domain.id
) )
self._cleanup.insert(0, self.account) self.cleanup = []
self.cleanup.insert(0, self.account)
return
def tearDown(self):
try:
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return return
@attr(tags=["advanced", "advancedns", "ssh"]) @attr(tags=["advanced", "advancedns", "ssh"])

View File

@ -139,7 +139,7 @@ class TestRouterServices(cloudstackTestCase):
domainid=cls.account.domainid, domainid=cls.account.domainid,
serviceofferingid=cls.service_offering.id serviceofferingid=cls.service_offering.id
) )
cls.cleanup = [ cls._cleanup = [
cls.account, cls.account,
cls.service_offering cls.service_offering
] ]
@ -150,7 +150,7 @@ class TestRouterServices(cloudstackTestCase):
try: try:
cls.api_client = super(TestRouterServices, cls).getClsTestClient().getApiClient() cls.api_client = super(TestRouterServices, cls).getClsTestClient().getApiClient()
#Clean up, terminate the created templates #Clean up, terminate the created templates
cleanup_resources(cls.api_client, cls.cleanup) cleanup_resources(cls.api_client, cls._cleanup)
except Exception as e: except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e) raise Exception("Warning: Exception during cleanup : %s" % e)
@ -158,14 +158,14 @@ class TestRouterServices(cloudstackTestCase):
def tearDown(self): def tearDown(self):
try: try:
cleanup_resources(self.apiclient, self._cleanup) cleanup_resources(self.apiclient, self.cleanup)
except Exception as e: except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e) raise Exception("Warning: Exception during cleanup : %s" % e)
return return
def setUp(self): def setUp(self):
self.apiclient = self.testClient.getApiClient() self.apiclient = self.testClient.getApiClient()
self._cleanup = [] self.cleanup = []
return return
@attr(tags = ["advanced"]) @attr(tags = ["advanced"])
@ -470,7 +470,7 @@ class TestRouterServices(cloudstackTestCase):
router.state router.state
)) ))
# Cleanup Vm_2 - Not required for further tests # Cleanup Vm_2 - Not required for further tests
self._cleanup.append(self.vm_2) self.cleanup.append(self.vm_2)
return return
@attr(tags = ["advanced"]) @attr(tags = ["advanced"])
@ -619,7 +619,7 @@ class TestRouterStopCreatePF(cloudstackTestCase):
domainid=cls.account.domainid, domainid=cls.account.domainid,
serviceofferingid=cls.service_offering.id serviceofferingid=cls.service_offering.id
) )
cls.cleanup = [ cls._cleanup = [
cls.account, cls.account,
cls.service_offering cls.service_offering
] ]
@ -630,7 +630,7 @@ class TestRouterStopCreatePF(cloudstackTestCase):
try: try:
cls.api_client = super(TestRouterStopCreatePF, cls).getClsTestClient().getApiClient() cls.api_client = super(TestRouterStopCreatePF, cls).getClsTestClient().getApiClient()
# Clean up, terminate the created resources # Clean up, terminate the created resources
cleanup_resources(cls.api_client, cls.cleanup) cleanup_resources(cls.api_client, cls._cleanup)
except Exception as e: except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e) raise Exception("Warning: Exception during cleanup : %s" % e)
@ -639,14 +639,14 @@ class TestRouterStopCreatePF(cloudstackTestCase):
def tearDown(self): def tearDown(self):
try: try:
# Clean up, terminate the created resources # Clean up, terminate the created resources
cleanup_resources(self.apiclient, self._cleanup) cleanup_resources(self.apiclient, self.cleanup)
except Exception as e: except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e) raise Exception("Warning: Exception during cleanup : %s" % e)
return return
def setUp(self): def setUp(self):
self.apiclient = self.testClient.getApiClient() self.apiclient = self.testClient.getApiClient()
self._cleanup = [] self.cleanup = []
return return
@attr(tags = ["advanced", "advancedns"]) @attr(tags = ["advanced", "advancedns"])
@ -831,7 +831,7 @@ class TestRouterStopCreateLB(cloudstackTestCase):
domainid=cls.account.domainid, domainid=cls.account.domainid,
serviceofferingid=cls.service_offering.id serviceofferingid=cls.service_offering.id
) )
cls.cleanup = [ cls._cleanup = [
cls.account, cls.account,
cls.service_offering cls.service_offering
] ]
@ -842,7 +842,7 @@ class TestRouterStopCreateLB(cloudstackTestCase):
try: try:
cls.api_client = super(TestRouterStopCreateLB, cls).getClsTestClient().getApiClient() cls.api_client = super(TestRouterStopCreateLB, cls).getClsTestClient().getApiClient()
#Clean up, terminate the created resources #Clean up, terminate the created resources
cleanup_resources(cls.api_client, cls.cleanup) cleanup_resources(cls.api_client, cls._cleanup)
except Exception as e: except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e) raise Exception("Warning: Exception during cleanup : %s" % e)
@ -850,14 +850,14 @@ class TestRouterStopCreateLB(cloudstackTestCase):
def tearDown(self): def tearDown(self):
try: try:
cleanup_resources(self.apiclient, self._cleanup) cleanup_resources(self.apiclient, self.cleanup)
except Exception as e: except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e) raise Exception("Warning: Exception during cleanup : %s" % e)
return return
def setUp(self): def setUp(self):
self.apiclient = self.testClient.getApiClient() self.apiclient = self.testClient.getApiClient()
self._cleanup = [] self.cleanup = []
return return
@attr(tags = ["advanced", "advancedns"]) @attr(tags = ["advanced", "advancedns"])
@ -1042,7 +1042,7 @@ class TestRouterStopCreateFW(cloudstackTestCase):
domainid=cls.account.domainid, domainid=cls.account.domainid,
serviceofferingid=cls.service_offering.id serviceofferingid=cls.service_offering.id
) )
cls.cleanup = [ cls._cleanup = [
cls.account, cls.account,
cls.service_offering cls.service_offering
] ]
@ -1053,7 +1053,7 @@ class TestRouterStopCreateFW(cloudstackTestCase):
try: try:
cls.api_client = super(TestRouterStopCreateFW, cls).getClsTestClient().getApiClient() cls.api_client = super(TestRouterStopCreateFW, cls).getClsTestClient().getApiClient()
#Clean up, terminate the created templates #Clean up, terminate the created templates
cleanup_resources(cls.api_client, cls.cleanup) cleanup_resources(cls.api_client, cls._cleanup)
except Exception as e: except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e) raise Exception("Warning: Exception during cleanup : %s" % e)
@ -1061,14 +1061,14 @@ class TestRouterStopCreateFW(cloudstackTestCase):
def tearDown(self): def tearDown(self):
try: try:
cleanup_resources(self.apiclient, self._cleanup) cleanup_resources(self.apiclient, self.cleanup)
except Exception as e: except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e) raise Exception("Warning: Exception during cleanup : %s" % e)
return return
def setUp(self): def setUp(self):
self.apiclient = self.testClient.getApiClient() self.apiclient = self.testClient.getApiClient()
self._cleanup = [] self.cleanup = []
return return
@attr(tags = ["advanced", "advancedns"]) @attr(tags = ["advanced", "advancedns"])

View File

@ -136,7 +136,6 @@ class Services:
}, },
"ostype": 'CentOS 5.3 (64-bit)', "ostype": 'CentOS 5.3 (64-bit)',
# Cent OS 5.3 (64 bit) # Cent OS 5.3 (64 bit)
"sleep": 90,
"timeout": 10, "timeout": 10,
"mode": 'advanced' "mode": 'advanced'
} }
@ -220,20 +219,22 @@ class TestSharedNetworks(cloudstackTestCase):
except Exception as e: 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_for_cleanup(self.api_client, ["account.cleanup.interval"])
try:
for network in self.cleanup_networks:
network.delete(self.api_client)
except Exception:
self.debug("Network %s failed to delete. Moving on" % network.id)
pass #because domain/account deletion will get rid of the network
try: try:
for domain in self.cleanup_domains: for domain in self.cleanup_domains:
domain.delete(self.api_client) domain.delete(self.api_client)
except Exception as e: except Exception as e:
raise Exception("Warning: Exception during domain cleanup : %s" % e) raise Exception("Warning: Exception during domain cleanup : %s" % e)
#Wait till all resources created are cleaned up completely and then attempt to delete Network
time.sleep(self.services["sleep"])
try:
for network in self.cleanup_networks:
network.delete(self.api_client)
except Exception as e:
raise Exception("Warning: Exception during network cleanup : %s" % e)
return return
@attr(tags=["advanced", "advancedns"]) @attr(tags=["advanced", "advancedns"])
@ -322,8 +323,6 @@ class TestSharedNetworks(cloudstackTestCase):
conservemode=False conservemode=False
) )
self.cleanup.append(self.shared_network_offering)
#Verify that the network offering got created #Verify that the network offering got created
list_network_offerings_response = NetworkOffering.list( list_network_offerings_response = NetworkOffering.list(
self.api_client, self.api_client,
@ -565,7 +564,7 @@ class TestSharedNetworks(cloudstackTestCase):
# - conservemode = false # - conservemode = false
# - specifyVlan = true # - specifyVlan = true
# - specifyIpRanges = true # - specifyIpRanges = true
# 4. Enable network offering - updateNetworkOffering - state=Enabled # 4. Create network offering - updateNetworkOffering - state=Enabled
# 5. createNetwork # 5. createNetwork
# - name = mysharednetwork, displaytext = mysharednetwork # - name = mysharednetwork, displaytext = mysharednetwork
# - vlan = 123 (say) # - vlan = 123 (say)
@ -683,7 +682,7 @@ class TestSharedNetworks(cloudstackTestCase):
conservemode=False conservemode=False
) )
self.cleanup.append(self.shared_network_offering)
#Verify that the network offering got created #Verify that the network offering got created
list_network_offerings_response = NetworkOffering.list( list_network_offerings_response = NetworkOffering.list(
@ -836,7 +835,7 @@ class TestSharedNetworks(cloudstackTestCase):
@attr(tags=["advanced", "advancedns"]) @attr(tags=["advanced", "advancedns"])
def test_createSharedNetwork_accountSpecific(self): def test_createSharedNetwork_accountSpecific(self):
""" Test Shared Networm with scope account """ """ Test Shared Network with scope account """
# Steps, # Steps,
# 1. create an Admin Account - admin-XABU1 # 1. create an Admin Account - admin-XABU1
@ -966,8 +965,6 @@ class TestSharedNetworks(cloudstackTestCase):
conservemode=False conservemode=False
) )
self.cleanup.append(self.shared_network_offering)
#Verify that the network offering got created #Verify that the network offering got created
list_network_offerings_response = NetworkOffering.list( list_network_offerings_response = NetworkOffering.list(
self.api_client, self.api_client,
@ -1292,7 +1289,6 @@ class TestSharedNetworks(cloudstackTestCase):
conservemode=False conservemode=False
) )
self.cleanup.append(self.shared_network_offering)
#Verify that the network offering got created #Verify that the network offering got created
list_network_offerings_response = NetworkOffering.list( list_network_offerings_response = NetworkOffering.list(
@ -1354,6 +1350,7 @@ class TestSharedNetworks(cloudstackTestCase):
self.network = Network.create( self.network = Network.create(
self.api_client, self.api_client,
self.services["network"], self.services["network"],
accountid=self.domain_admin_account.name,
domainid=self.dom_domain.id, domainid=self.dom_domain.id,
networkofferingid=self.shared_network_offering.id, networkofferingid=self.shared_network_offering.id,
zoneid=self.zone.id zoneid=self.zone.id
@ -1405,6 +1402,7 @@ class TestSharedNetworks(cloudstackTestCase):
networkids=self.network.id, networkids=self.network.id,
serviceofferingid=self.service_offering.id serviceofferingid=self.service_offering.id
) )
self.cleanup_vms.append(self.domain_user_account_virtual_machine)
vms = VirtualMachine.list( vms = VirtualMachine.list(
self.api_client, self.api_client,
id=self.domain_user_account_virtual_machine.id, id=self.domain_user_account_virtual_machine.id,
@ -1433,6 +1431,7 @@ class TestSharedNetworks(cloudstackTestCase):
networkids=self.network.id, networkids=self.network.id,
serviceofferingid=self.service_offering.id serviceofferingid=self.service_offering.id
) )
self.cleanup_vms.append(self.domain_admin_account_virtual_machine)
vms = VirtualMachine.list( vms = VirtualMachine.list(
self.api_client, self.api_client,
id=self.domain_admin_account_virtual_machine.id, id=self.domain_admin_account_virtual_machine.id,
@ -1612,7 +1611,6 @@ class TestSharedNetworks(cloudstackTestCase):
conservemode=False conservemode=False
) )
self.cleanup.append(self.shared_network_offering)
#Verify that the network offering got created #Verify that the network offering got created
list_network_offerings_response = NetworkOffering.list( list_network_offerings_response = NetworkOffering.list(
@ -1836,7 +1834,6 @@ class TestSharedNetworks(cloudstackTestCase):
conservemode=False conservemode=False
) )
self.cleanup.append(self.shared_network_offering)
#Verify that the network offering got created #Verify that the network offering got created
list_network_offerings_response = NetworkOffering.list( list_network_offerings_response = NetworkOffering.list(
@ -1996,7 +1993,6 @@ class TestSharedNetworks(cloudstackTestCase):
conservemode=False conservemode=False
) )
self.cleanup.append(self.shared_network_offering)
#Verify that the network offering got created #Verify that the network offering got created
list_network_offerings_response = NetworkOffering.list( list_network_offerings_response = NetworkOffering.list(
@ -2181,7 +2177,6 @@ class TestSharedNetworks(cloudstackTestCase):
conservemode=False conservemode=False
) )
self.cleanup.append(self.shared_network_offering)
#Verify that the network offering got created #Verify that the network offering got created
list_network_offerings_response = NetworkOffering.list( list_network_offerings_response = NetworkOffering.list(
@ -2394,7 +2389,7 @@ class TestSharedNetworks(cloudstackTestCase):
list_accounts_response = Account.list( list_accounts_response = Account.list(
self.api_client, self.api_client,
id=self.admin_account.id, id=self.admin_account.id,
liistall=True listall=True
) )
self.assertEqual( self.assertEqual(
isinstance(list_accounts_response, list), isinstance(list_accounts_response, list),
@ -2424,7 +2419,6 @@ class TestSharedNetworks(cloudstackTestCase):
conservemode=False conservemode=False
) )
self.cleanup.append(self.shared_network_offering)
#Verify that the network offering got created #Verify that the network offering got created
list_network_offerings_response = NetworkOffering.list( list_network_offerings_response = NetworkOffering.list(
@ -2484,7 +2478,6 @@ class TestSharedNetworks(cloudstackTestCase):
conservemode=False conservemode=False
) )
self.cleanup.append(self.isolated_network_offering)
#Update network offering state from disabled to enabled. #Update network offering state from disabled to enabled.
network_offering_update_response = NetworkOffering.update( network_offering_update_response = NetworkOffering.update(
@ -2541,6 +2534,7 @@ class TestSharedNetworks(cloudstackTestCase):
self.shared_network = Network.create( self.shared_network = Network.create(
self.api_client, self.api_client,
self.services["network"], self.services["network"],
accountid=self.admin_account.name,
domainid=self.admin_account.domainid, domainid=self.admin_account.domainid,
networkofferingid=self.shared_network_offering.id, networkofferingid=self.shared_network_offering.id,
zoneid=self.zone.id zoneid=self.zone.id
@ -2598,7 +2592,8 @@ class TestSharedNetworks(cloudstackTestCase):
self.debug("Isolated Network created: %s" % self.isolated_network.id) self.debug("Isolated Network created: %s" % self.isolated_network.id)
self.shared_network_admin_account_virtual_machine = VirtualMachine.create( self.shared_network_admin_account_virtual_machine =\
VirtualMachine.create(
self.api_client, self.api_client,
self.services["virtual_machine"], self.services["virtual_machine"],
accountid=self.admin_account.name, accountid=self.admin_account.name,
@ -2623,9 +2618,11 @@ class TestSharedNetworks(cloudstackTestCase):
) )
self.debug("Virtual Machine created: %s" % self.shared_network_admin_account_virtual_machine.id) self.debug("Virtual Machine created: %s" % self.shared_network_admin_account_virtual_machine.id)
self.assertTrue(self.shared_network_admin_account_virtual_machine.nic[0].ipaddress is not None, "ip should be assigned to running virtual machine") self.assertTrue(self.shared_network_admin_account_virtual_machine.nic[0].ipaddress is not None,
"ip should be assigned to running virtual machine")
self.isolated_network_admin_account_virtual_machine = VirtualMachine.create( self.isolated_network_admin_account_virtual_machine = \
VirtualMachine.create(
self.api_client, self.api_client,
self.services["virtual_machine"], self.services["virtual_machine"],
accountid=self.admin_account.name, accountid=self.admin_account.name,
@ -2678,7 +2675,7 @@ class TestSharedNetworks(cloudstackTestCase):
#Create Firewall rule on source NAT #Create Firewall rule on source NAT
fw_rule = FireWallRule.create( fw_rule = FireWallRule.create(
self.api_client, self.api_client,
ipaddressid=self.public_ip.ipaddress, ipaddressid=self.public_ip.ipaddress.id,
protocol='TCP', protocol='TCP',
cidrlist=[self.services["fw_rule"]["cidr"]], cidrlist=[self.services["fw_rule"]["cidr"]],
startport=self.services["fw_rule"]["startport"], startport=self.services["fw_rule"]["startport"],
@ -2782,7 +2779,6 @@ class TestSharedNetworks(cloudstackTestCase):
conservemode=False conservemode=False
) )
self.cleanup.append(self.shared_network_offering)
#Verify that the network offering got created #Verify that the network offering got created
list_network_offerings_response = NetworkOffering.list( list_network_offerings_response = NetworkOffering.list(
@ -2927,8 +2923,6 @@ class TestSharedNetworks(cloudstackTestCase):
conservemode=False conservemode=False
) )
self.cleanup.append(self.shared_network_offering)
#Verify that the network offering got created #Verify that the network offering got created
list_network_offerings_response = NetworkOffering.list( list_network_offerings_response = NetworkOffering.list(
self.api_client, self.api_client,

View File

@ -375,8 +375,8 @@ class TestSnapshots(cloudstackTestCase):
#6. Mount/Attach volume to another server #6. Mount/Attach volume to another server
#7. Compare data #7. Compare data
random_data_0 = random_gen(100) random_data_0 = random_gen(size=100)
random_data_1 = random_gen(100) random_data_1 = random_gen(size=100)
volume = Volume.create( volume = Volume.create(
self.apiclient, self.apiclient,
@ -644,8 +644,8 @@ class TestSnapshots(cloudstackTestCase):
"Check list response returns a valid list" "Check list response returns a valid list"
) )
volume = volumes[0] volume = volumes[0]
random_data_0 = random_gen(100) random_data_0 = random_gen(size=100)
random_data_1 = random_gen(100) random_data_1 = random_gen(size=100)
try: try:
ssh_client = self.virtual_machine.get_ssh_client() ssh_client = self.virtual_machine.get_ssh_client()
@ -838,8 +838,8 @@ class TestSnapshots(cloudstackTestCase):
#5. Login to newly created virtual machine #5. Login to newly created virtual machine
#6. Compare data #6. Compare data
random_data_0 = random_gen(100) random_data_0 = random_gen(size=100)
random_data_1 = random_gen(100) random_data_1 = random_gen(size=100)
try: try:
#Login to virtual machine #Login to virtual machine

View File

@ -240,7 +240,7 @@ class TestResourceTags(cloudstackTestCase):
try: try:
#Cleanup resources used #Cleanup resources used
print("Cleanup resources used") print("Cleanup resources used")
#cleanup_resources(cls.api_client, cls._cleanup) cleanup_resources(cls.api_client, cls._cleanup)
except Exception as e: except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e) raise Exception("Warning: Exception during cleanup : %s" % e)
return return

View File

@ -160,6 +160,22 @@ class TestAttachVolume(cloudstackTestCase):
self.dbclient = self.testClient.getDbConnection() self.dbclient = self.testClient.getDbConnection()
self.cleanup = [] self.cleanup = []
def tearDown(self):
try:
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
self.debug("Warning: Exception during cleanup : %s" % e)
#raise Exception("Warning: Exception during cleanup : %s" % e)
return
@classmethod
def tearDownClass(cls):
try:
cls.api_client = super(TestAttachVolume, cls).getClsTestClient().getApiClient()
cleanup_resources(cls.api_client, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
@attr(tags = ["advanced", "advancedns"]) @attr(tags = ["advanced", "advancedns"])
def test_01_volume_attach(self): def test_01_volume_attach(self):
"""Test Attach volumes (max capacity) """Test Attach volumes (max capacity)
@ -362,20 +378,6 @@ class TestAttachVolume(cloudstackTestCase):
) )
return return
def tearDown(self):
#Clean up, terminate the created volumes
cleanup_resources(self.apiclient, self.cleanup)
return
@classmethod
def tearDownClass(cls):
try:
cls.api_client = super(TestAttachVolume, cls).getClsTestClient().getApiClient()
cleanup_resources(cls.api_client, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
class TestAttachDetachVolume(cloudstackTestCase): class TestAttachDetachVolume(cloudstackTestCase):
@classmethod @classmethod

View File

@ -223,7 +223,16 @@ class TestVPC(cloudstackTestCase):
admin=True, admin=True,
domainid=self.domain.id domainid=self.domain.id
) )
self._cleanup.insert(0, self.account) self.cleanup = []
self.cleanup.insert(0, self.account)
return
def tearDown(self):
try:
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
self.debug("Warning: Exception during cleanup : %s" % e)
#raise Exception("Warning: Exception during cleanup : %s" % e)
return return
def validate_vpc_offering(self, vpc_offering): def validate_vpc_offering(self, vpc_offering):
@ -517,7 +526,7 @@ class TestVPC(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
self.network_offering.update(self.apiclient, state='Enabled') self.network_offering.update(self.apiclient, state='Enabled')
self._cleanup.append(self.network_offering) self.cleanup.append(self.network_offering)
gateway = vpc.cidr.split('/')[0] gateway = vpc.cidr.split('/')[0]
# Split the cidr to retrieve gateway # Split the cidr to retrieve gateway
@ -546,7 +555,7 @@ class TestVPC(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
self.network_offering_no_lb.update(self.apiclient, state='Enabled') self.network_offering_no_lb.update(self.apiclient, state='Enabled')
self._cleanup.append(self.network_offering_no_lb) self.cleanup.append(self.network_offering_no_lb)
gateway = '10.1.2.1' # New network -> different gateway gateway = '10.1.2.1' # New network -> different gateway
self.debug("Creating network with network offering: %s" % self.debug("Creating network with network offering: %s" %
@ -644,7 +653,7 @@ class TestVPC(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
self.network_offering.update(self.apiclient, state='Enabled') self.network_offering.update(self.apiclient, state='Enabled')
self._cleanup.append(self.network_offering) self.cleanup.append(self.network_offering)
gateway = vpc.cidr.split('/')[0] gateway = vpc.cidr.split('/')[0]
# Split the cidr to retrieve gateway # Split the cidr to retrieve gateway
@ -673,7 +682,7 @@ class TestVPC(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
self.network_offering_no_lb.update(self.apiclient, state='Enabled') self.network_offering_no_lb.update(self.apiclient, state='Enabled')
self._cleanup.append(self.network_offering_no_lb) self.cleanup.append(self.network_offering_no_lb)
gateway = '10.1.2.1' # New network -> different gateway gateway = '10.1.2.1' # New network -> different gateway
self.debug("Creating network with network offering: %s" % self.debug("Creating network with network offering: %s" %
@ -757,7 +766,7 @@ class TestVPC(cloudstackTestCase):
self.apiclient, self.apiclient,
self.services["account"], self.services["account"],
) )
self._cleanup.append(self.user) self.cleanup.append(self.user)
self.services["vpc"]["cidr"] = "10.1.1.1/16" self.services["vpc"]["cidr"] = "10.1.1.1/16"
self.debug("creating a VPC network in the account: %s" % self.debug("creating a VPC network in the account: %s" %
@ -833,7 +842,7 @@ class TestVPC(cloudstackTestCase):
self.services["vpc_offering"] self.services["vpc_offering"]
) )
self._cleanup.append(vpc_off) self.cleanup.append(vpc_off)
self.validate_vpc_offering(vpc_off) self.validate_vpc_offering(vpc_off)
self.debug("Enabling the VPC offering created") self.debug("Enabling the VPC offering created")
@ -859,7 +868,7 @@ class TestVPC(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
self.network_offering.update(self.apiclient, state='Enabled') self.network_offering.update(self.apiclient, state='Enabled')
self._cleanup.append(self.network_offering) self.cleanup.append(self.network_offering)
self.network_offering_no_lb = NetworkOffering.create( self.network_offering_no_lb = NetworkOffering.create(
self.apiclient, self.apiclient,
@ -868,7 +877,7 @@ class TestVPC(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
self.network_offering_no_lb.update(self.apiclient, state='Enabled') self.network_offering_no_lb.update(self.apiclient, state='Enabled')
self._cleanup.append(self.network_offering_no_lb) self.cleanup.append(self.network_offering_no_lb)
# Creating network using the network offering created # Creating network using the network offering created
self.debug("Creating network with network offering: %s" % self.debug("Creating network with network offering: %s" %
@ -1178,7 +1187,7 @@ class TestVPC(cloudstackTestCase):
self.services["vpc_offering"] self.services["vpc_offering"]
) )
self._cleanup.append(vpc_off) self.cleanup.append(vpc_off)
self.validate_vpc_offering(vpc_off) self.validate_vpc_offering(vpc_off)
self.debug("Enabling the VPC offering created") self.debug("Enabling the VPC offering created")
@ -1204,7 +1213,7 @@ class TestVPC(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
self.network_offering.update(self.apiclient, state='Enabled') self.network_offering.update(self.apiclient, state='Enabled')
self._cleanup.append(self.network_offering) self.cleanup.append(self.network_offering)
self.network_offering_no_lb = NetworkOffering.create( self.network_offering_no_lb = NetworkOffering.create(
self.apiclient, self.apiclient,
@ -1213,7 +1222,7 @@ class TestVPC(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
self.network_offering_no_lb.update(self.apiclient, state='Enabled') self.network_offering_no_lb.update(self.apiclient, state='Enabled')
self._cleanup.append(self.network_offering_no_lb) self.cleanup.append(self.network_offering_no_lb)
# Creating network using the network offering created # Creating network using the network offering created
self.debug("Creating network with network offering: %s" % self.debug("Creating network with network offering: %s" %
@ -1666,7 +1675,7 @@ class TestVPC(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
self.network_offering.update(self.apiclient, state='Enabled') self.network_offering.update(self.apiclient, state='Enabled')
self._cleanup.append(self.network_offering) self.cleanup.append(self.network_offering)
gateway = vpc.cidr.split('/')[0] gateway = vpc.cidr.split('/')[0]
# Split the cidr to retrieve gateway # Split the cidr to retrieve gateway
@ -1813,7 +1822,7 @@ class TestVPC(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
self.network_offering.update(self.apiclient, state='Enabled') self.network_offering.update(self.apiclient, state='Enabled')
self._cleanup.append(self.network_offering) self.cleanup.append(self.network_offering)
gateway = vpc.cidr.split('/')[0] gateway = vpc.cidr.split('/')[0]
# Split the cidr to retrieve gateway # Split the cidr to retrieve gateway
@ -1869,7 +1878,7 @@ class TestVPC(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
self.network_offering.update(self.apiclient, state='Enabled') self.network_offering.update(self.apiclient, state='Enabled')
self._cleanup.append(self.network_offering) self.cleanup.append(self.network_offering)
gateway = vpc.cidr.split('/')[0] gateway = vpc.cidr.split('/')[0]
# Split the cidr to retrieve gateway # Split the cidr to retrieve gateway
@ -1918,7 +1927,7 @@ class TestVPC(cloudstackTestCase):
self.services["account"] self.services["account"]
) )
self.debug("Created account: %s" % user.name) self.debug("Created account: %s" % user.name)
self._cleanup.append(user) self.cleanup.append(user)
self.services["vpc"]["cidr"] = "10.1.1.1/16" self.services["vpc"]["cidr"] = "10.1.1.1/16"
self.debug("creating a VPC network in the account: %s" % self.debug("creating a VPC network in the account: %s" %
@ -1945,7 +1954,7 @@ class TestVPC(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
self.network_offering.update(self.apiclient, state='Enabled') self.network_offering.update(self.apiclient, state='Enabled')
self._cleanup.append(self.network_offering) self.cleanup.append(self.network_offering)
gateway = vpc.cidr.split('/')[0] gateway = vpc.cidr.split('/')[0]
# Split the cidr to retrieve gateway # Split the cidr to retrieve gateway
@ -1999,7 +2008,7 @@ class TestVPC(cloudstackTestCase):
self.services["account"] self.services["account"]
) )
self.debug("Created account: %s" % user.name) self.debug("Created account: %s" % user.name)
self._cleanup.append(user) self.cleanup.append(user)
self.services["vpc"]["cidr"] = "10.1.1.1/16" self.services["vpc"]["cidr"] = "10.1.1.1/16"
self.debug("creating a VPC network in the account: %s" % self.debug("creating a VPC network in the account: %s" %
@ -2026,7 +2035,7 @@ class TestVPC(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
self.network_offering.update(self.apiclient, state='Enabled') self.network_offering.update(self.apiclient, state='Enabled')
self._cleanup.append(self.network_offering) self.cleanup.append(self.network_offering)
gateway = vpc.cidr.split('/')[0] gateway = vpc.cidr.split('/')[0]
# Split the cidr to retrieve gateway # Split the cidr to retrieve gateway
@ -2075,7 +2084,7 @@ class TestVPC(cloudstackTestCase):
self.services["account"] self.services["account"]
) )
self.debug("Created account: %s" % user.name) self.debug("Created account: %s" % user.name)
self._cleanup.append(user) self.cleanup.append(user)
self.services["vpc"]["cidr"] = "10.1.1.1/16" self.services["vpc"]["cidr"] = "10.1.1.1/16"
self.debug("creating a VPC network in the account: %s" % self.debug("creating a VPC network in the account: %s" %
@ -2103,7 +2112,7 @@ class TestVPC(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
self.network_offering.update(self.apiclient, state='Enabled') self.network_offering.update(self.apiclient, state='Enabled')
self._cleanup.append(self.network_offering) self.cleanup.append(self.network_offering)
gateway = vpc.cidr.split('/')[0] gateway = vpc.cidr.split('/')[0]
# Split the cidr to retrieve gateway # Split the cidr to retrieve gateway
@ -2159,7 +2168,7 @@ class TestVPC(cloudstackTestCase):
self.services["domain_admin"] self.services["domain_admin"]
) )
self.debug("Created account: %s" % domain_admin.name) self.debug("Created account: %s" % domain_admin.name)
self._cleanup.append(domain_admin) self.cleanup.append(domain_admin)
da_apiclient = self.testClient.getUserApiClient( da_apiclient = self.testClient.getUserApiClient(
account=domain_admin.name, account=domain_admin.name,
domain=domain_admin.domain, domain=domain_admin.domain,
@ -2170,7 +2179,7 @@ class TestVPC(cloudstackTestCase):
self.services["account"] self.services["account"]
) )
self.debug("Created account: %s" % user.name) self.debug("Created account: %s" % user.name)
self._cleanup.append(user) self.cleanup.append(user)
self.services["vpc"]["cidr"] = "10.1.1.1/16" self.services["vpc"]["cidr"] = "10.1.1.1/16"
self.debug("creating a VPC network in the account: %s" % self.debug("creating a VPC network in the account: %s" %
@ -2210,7 +2219,7 @@ class TestVPC(cloudstackTestCase):
self.services["domain_admin"] self.services["domain_admin"]
) )
self.debug("Created account: %s" % domain_admin.name) self.debug("Created account: %s" % domain_admin.name)
self._cleanup.append(domain_admin) self.cleanup.append(domain_admin)
da_apiclient = self.testClient.getUserApiClient( da_apiclient = self.testClient.getUserApiClient(
account=domain_admin.name, account=domain_admin.name,
domain=self.services["domain"]["name"], domain=self.services["domain"]["name"],
@ -2221,7 +2230,7 @@ class TestVPC(cloudstackTestCase):
self.services["account"] self.services["account"]
) )
self.debug("Created account: %s" % user.name) self.debug("Created account: %s" % user.name)
self._cleanup.append(user) self.cleanup.append(user)
self.services["vpc"]["cidr"] = "10.1.1.1/16" self.services["vpc"]["cidr"] = "10.1.1.1/16"
self.debug("creating a VPC network in the account: %s" % self.debug("creating a VPC network in the account: %s" %
@ -2248,7 +2257,7 @@ class TestVPC(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
self.network_offering.update(self.apiclient, state='Enabled') self.network_offering.update(self.apiclient, state='Enabled')
self._cleanup.append(self.network_offering) self.cleanup.append(self.network_offering)
gateway = vpc.cidr.split('/')[0] gateway = vpc.cidr.split('/')[0]
# Split the cidr to retrieve gateway # Split the cidr to retrieve gateway
@ -2359,7 +2368,7 @@ class TestVPC(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
self.network_offering.update(self.apiclient, state='Enabled') self.network_offering.update(self.apiclient, state='Enabled')
self._cleanup.append(self.network_offering) self.cleanup.append(self.network_offering)
gateway = vpc.cidr.split('/')[0] gateway = vpc.cidr.split('/')[0]
# Split the cidr to retrieve gateway # Split the cidr to retrieve gateway

View File

@ -227,7 +227,16 @@ class TestVPCNetwork(cloudstackTestCase):
admin=True, admin=True,
domainid=self.domain.id domainid=self.domain.id
) )
self._cleanup.insert(0, self.account) self.cleanup = []
self.cleanup.insert(0, self.account)
return
def tearDown(self):
try:
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
self.debug("Warning: Exception during cleanup : %s" % e)
#raise Exception("Warning: Exception during cleanup : %s" % e)
return return
def validate_vpc_offering(self, vpc_offering): def validate_vpc_offering(self, vpc_offering):
@ -303,7 +312,7 @@ class TestVPCNetwork(cloudstackTestCase):
self.services["vpc_offering"] self.services["vpc_offering"]
) )
self._cleanup.append(vpc_off) self.cleanup.append(vpc_off)
self.validate_vpc_offering(vpc_off) self.validate_vpc_offering(vpc_off)
self.debug("Enabling the VPC offering created") self.debug("Enabling the VPC offering created")
@ -329,7 +338,7 @@ class TestVPCNetwork(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
self.network_offering.update(self.apiclient, state='Enabled') self.network_offering.update(self.apiclient, state='Enabled')
self._cleanup.append(self.network_offering) self.cleanup.append(self.network_offering)
# Creating network using the network offering created # Creating network using the network offering created
self.debug("Creating network with network offering: %s" % self.debug("Creating network with network offering: %s" %
@ -396,7 +405,7 @@ class TestVPCNetwork(cloudstackTestCase):
self.services["vpc_offering"] self.services["vpc_offering"]
) )
self._cleanup.append(vpc_off) self.cleanup.append(vpc_off)
self.validate_vpc_offering(vpc_off) self.validate_vpc_offering(vpc_off)
self.debug("Enabling the VPC offering created") self.debug("Enabling the VPC offering created")
@ -426,7 +435,7 @@ class TestVPCNetwork(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
self.network_offering.update(self.apiclient, state='Enabled') self.network_offering.update(self.apiclient, state='Enabled')
self._cleanup.append(self.network_offering) self.cleanup.append(self.network_offering)
# Creating network using the network offering created # Creating network using the network offering created
self.debug("Creating network with network offering: %s" % self.debug("Creating network with network offering: %s" %
@ -466,7 +475,7 @@ class TestVPCNetwork(cloudstackTestCase):
self.services["vpc_offering"] self.services["vpc_offering"]
) )
self._cleanup.append(vpc_off) self.cleanup.append(vpc_off)
self.validate_vpc_offering(vpc_off) self.validate_vpc_offering(vpc_off)
self.debug("Enabling the VPC offering created") self.debug("Enabling the VPC offering created")
@ -492,7 +501,7 @@ class TestVPCNetwork(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
self.network_offering.update(self.apiclient, state='Enabled') self.network_offering.update(self.apiclient, state='Enabled')
self._cleanup.append(self.network_offering) self.cleanup.append(self.network_offering)
# Creating network using the network offering created # Creating network using the network offering created
self.debug("Creating network with network offering: %s" % self.debug("Creating network with network offering: %s" %
@ -557,7 +566,7 @@ class TestVPCNetwork(cloudstackTestCase):
self.services["vpc_offering"] self.services["vpc_offering"]
) )
self._cleanup.append(vpc_off) self.cleanup.append(vpc_off)
self.validate_vpc_offering(vpc_off) self.validate_vpc_offering(vpc_off)
self.debug("Enabling the VPC offering created") self.debug("Enabling the VPC offering created")
@ -583,7 +592,7 @@ class TestVPCNetwork(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
self.network_offering.update(self.apiclient, state='Enabled') self.network_offering.update(self.apiclient, state='Enabled')
self._cleanup.append(self.network_offering) self.cleanup.append(self.network_offering)
# Creating network using the network offering created # Creating network using the network offering created
self.debug("Creating network with network offering: %s" % self.debug("Creating network with network offering: %s" %
@ -662,7 +671,7 @@ class TestVPCNetwork(cloudstackTestCase):
self.services["vpc_offering"] self.services["vpc_offering"]
) )
self._cleanup.append(vpc_off) self.cleanup.append(vpc_off)
self.validate_vpc_offering(vpc_off) self.validate_vpc_offering(vpc_off)
self.debug("Enabling the VPC offering created") self.debug("Enabling the VPC offering created")
@ -713,7 +722,7 @@ class TestVPCNetwork(cloudstackTestCase):
self.services["vpc_offering"] self.services["vpc_offering"]
) )
self._cleanup.append(vpc_off) self.cleanup.append(vpc_off)
self.validate_vpc_offering(vpc_off) self.validate_vpc_offering(vpc_off)
self.debug("Enabling the VPC offering created") self.debug("Enabling the VPC offering created")
@ -746,7 +755,7 @@ class TestVPCNetwork(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
self.network_offering.update(self.apiclient, state='Enabled') self.network_offering.update(self.apiclient, state='Enabled')
self._cleanup.append(self.network_offering) self.cleanup.append(self.network_offering)
# Creating network using the network offering created # Creating network using the network offering created
self.debug("Creating network with network offering: %s" % self.debug("Creating network with network offering: %s" %
@ -790,7 +799,7 @@ class TestVPCNetwork(cloudstackTestCase):
self.services["vpc_offering"] self.services["vpc_offering"]
) )
self._cleanup.append(vpc_off) self.cleanup.append(vpc_off)
self.validate_vpc_offering(vpc_off) self.validate_vpc_offering(vpc_off)
self.debug("Enabling the VPC offering created") self.debug("Enabling the VPC offering created")
@ -816,7 +825,7 @@ class TestVPCNetwork(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
self.network_offering.update(self.apiclient, state='Enabled') self.network_offering.update(self.apiclient, state='Enabled')
self._cleanup.append(self.network_offering) self.cleanup.append(self.network_offering)
# Creating network using the network offering created # Creating network using the network offering created
self.debug("Creating network with network offering: %s" % self.debug("Creating network with network offering: %s" %
@ -859,7 +868,7 @@ class TestVPCNetwork(cloudstackTestCase):
self.services["vpc_offering"] self.services["vpc_offering"]
) )
self._cleanup.append(vpc_off) self.cleanup.append(vpc_off)
self.validate_vpc_offering(vpc_off) self.validate_vpc_offering(vpc_off)
self.debug("Enabling the VPC offering created") self.debug("Enabling the VPC offering created")
@ -921,7 +930,7 @@ class TestVPCNetwork(cloudstackTestCase):
self.services["vpc_offering"] self.services["vpc_offering"]
) )
self._cleanup.append(vpc_off) self.cleanup.append(vpc_off)
self.validate_vpc_offering(vpc_off) self.validate_vpc_offering(vpc_off)
self.debug("Enabling the VPC offering created") self.debug("Enabling the VPC offering created")
@ -949,7 +958,7 @@ class TestVPCNetwork(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
self.network_offering.update(self.apiclient, state='Enabled') self.network_offering.update(self.apiclient, state='Enabled')
self._cleanup.append(self.network_offering) self.cleanup.append(self.network_offering)
# Creating network using the network offering created # Creating network using the network offering created
self.debug( self.debug(
@ -991,7 +1000,7 @@ class TestVPCNetwork(cloudstackTestCase):
self.services["vpc_offering"] self.services["vpc_offering"]
) )
self._cleanup.append(vpc_off) self.cleanup.append(vpc_off)
self.validate_vpc_offering(vpc_off) self.validate_vpc_offering(vpc_off)
self.debug("Enabling the VPC offering created") self.debug("Enabling the VPC offering created")
@ -1075,7 +1084,16 @@ class TestVPCNetworkRanges(cloudstackTestCase):
admin=True, admin=True,
domainid=self.domain.id domainid=self.domain.id
) )
self._cleanup.insert(0, self.account) self.cleanup = []
self.cleanup.insert(0, self.account)
return
def tearDown(self):
try:
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
self.debug("Warning: Exception during cleanup : %s" % e)
#raise Exception("Warning: Exception during cleanup : %s" % e)
return return
def validate_vpc_offering(self, vpc_offering): def validate_vpc_offering(self, vpc_offering):
@ -1144,7 +1162,7 @@ class TestVPCNetworkRanges(cloudstackTestCase):
self.services["vpc_offering"] self.services["vpc_offering"]
) )
self._cleanup.append(vpc_off) self.cleanup.append(vpc_off)
self.validate_vpc_offering(vpc_off) self.validate_vpc_offering(vpc_off)
self.debug("Enabling the VPC offering created") self.debug("Enabling the VPC offering created")
@ -1171,7 +1189,7 @@ class TestVPCNetworkRanges(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
self.network_offering.update(self.apiclient, state='Enabled') self.network_offering.update(self.apiclient, state='Enabled')
self._cleanup.append(self.network_offering) self.cleanup.append(self.network_offering)
# Creating network using the network offering created # Creating network using the network offering created
self.debug("Creating network outside of the VPC's network") self.debug("Creating network outside of the VPC's network")
@ -1206,7 +1224,7 @@ class TestVPCNetworkRanges(cloudstackTestCase):
self.services["vpc_offering"] self.services["vpc_offering"]
) )
self._cleanup.append(vpc_off) self.cleanup.append(vpc_off)
self.validate_vpc_offering(vpc_off) self.validate_vpc_offering(vpc_off)
self.debug("Enabling the VPC offering created") self.debug("Enabling the VPC offering created")
@ -1233,7 +1251,7 @@ class TestVPCNetworkRanges(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
self.network_offering.update(self.apiclient, state='Enabled') self.network_offering.update(self.apiclient, state='Enabled')
self._cleanup.append(self.network_offering) self.cleanup.append(self.network_offering)
# Creating network using the network offering created # Creating network using the network offering created
self.debug("Creating network outside of the VPC's network") self.debug("Creating network outside of the VPC's network")
@ -1268,7 +1286,7 @@ class TestVPCNetworkRanges(cloudstackTestCase):
self.services["vpc_offering"] self.services["vpc_offering"]
) )
self._cleanup.append(vpc_off) self.cleanup.append(vpc_off)
self.validate_vpc_offering(vpc_off) self.validate_vpc_offering(vpc_off)
self.debug("Enabling the VPC offering created") self.debug("Enabling the VPC offering created")
@ -1295,7 +1313,7 @@ class TestVPCNetworkRanges(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
self.network_offering.update(self.apiclient, state='Enabled') self.network_offering.update(self.apiclient, state='Enabled')
self._cleanup.append(self.network_offering) self.cleanup.append(self.network_offering)
# Creating network using the network offering created # Creating network using the network offering created
self.debug("Creating network inside of the VPC's network") self.debug("Creating network inside of the VPC's network")
@ -1336,7 +1354,7 @@ class TestVPCNetworkRanges(cloudstackTestCase):
self.services["vpc_offering"] self.services["vpc_offering"]
) )
self._cleanup.append(vpc_off) self.cleanup.append(vpc_off)
self.validate_vpc_offering(vpc_off) self.validate_vpc_offering(vpc_off)
self.debug("Enabling the VPC offering created") self.debug("Enabling the VPC offering created")
@ -1363,7 +1381,7 @@ class TestVPCNetworkRanges(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
self.network_offering.update(self.apiclient, state='Enabled') self.network_offering.update(self.apiclient, state='Enabled')
self._cleanup.append(self.network_offering) self.cleanup.append(self.network_offering)
# Creating network using the network offering created # Creating network using the network offering created
self.debug("Creating network with network offering: %s" % self.debug("Creating network with network offering: %s" %
@ -1457,7 +1475,7 @@ class TestVPCNetworkRanges(cloudstackTestCase):
self.services["vpc_offering"] self.services["vpc_offering"]
) )
self._cleanup.append(vpc_off) self.cleanup.append(vpc_off)
self.validate_vpc_offering(vpc_off) self.validate_vpc_offering(vpc_off)
self.debug("Enabling the VPC offering created") self.debug("Enabling the VPC offering created")
@ -1484,7 +1502,7 @@ class TestVPCNetworkRanges(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
self.network_offering.update(self.apiclient, state='Enabled') self.network_offering.update(self.apiclient, state='Enabled')
self._cleanup.append(self.network_offering) self.cleanup.append(self.network_offering)
self.debug( self.debug(
"Creating the new account to create new network in VPC: %s" % "Creating the new account to create new network in VPC: %s" %
@ -1570,7 +1588,16 @@ class TestVPCNetworkUpgrade(cloudstackTestCase):
admin=True, admin=True,
domainid=self.domain.id domainid=self.domain.id
) )
self._cleanup.insert(0, self.account) self.cleanup = []
self.cleanup.insert(0, self.account)
return
def tearDown(self):
try:
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
self.debug("Warning: Exception during cleanup : %s" % e)
#raise Exception("Warning: Exception during cleanup : %s" % e)
return return
def validate_vpc_offering(self, vpc_offering): def validate_vpc_offering(self, vpc_offering):
@ -1647,7 +1674,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase):
self.services["vpc_offering"] self.services["vpc_offering"]
) )
self._cleanup.append(vpc_off) self.cleanup.append(vpc_off)
self.validate_vpc_offering(vpc_off) self.validate_vpc_offering(vpc_off)
self.debug("Enabling the VPC offering created") self.debug("Enabling the VPC offering created")
@ -1673,7 +1700,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
nw_off.update(self.apiclient, state='Enabled') nw_off.update(self.apiclient, state='Enabled')
self._cleanup.append(nw_off) self.cleanup.append(nw_off)
self.services["network_offering"]["supportedservices"] = 'Vpn,Dhcp,Dns,SourceNat,UserData,Lb,StaticNat,NetworkACL' self.services["network_offering"]["supportedservices"] = 'Vpn,Dhcp,Dns,SourceNat,UserData,Lb,StaticNat,NetworkACL'
self.services["network_offering"]["serviceProviderList"] = { self.services["network_offering"]["serviceProviderList"] = {
@ -1694,7 +1721,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
nw_off_no_pf.update(self.apiclient, state='Enabled') nw_off_no_pf.update(self.apiclient, state='Enabled')
self._cleanup.append(nw_off_no_pf) self.cleanup.append(nw_off_no_pf)
# Creating network using the network offering created # Creating network using the network offering created
self.debug("Creating network with network offering: %s" % self.debug("Creating network with network offering: %s" %
@ -1995,7 +2022,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase):
self.services["vpc_offering"] self.services["vpc_offering"]
) )
self._cleanup.append(vpc_off) self.cleanup.append(vpc_off)
self.validate_vpc_offering(vpc_off) self.validate_vpc_offering(vpc_off)
self.debug("Enabling the VPC offering created") self.debug("Enabling the VPC offering created")
@ -2021,7 +2048,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
nw_off.update(self.apiclient, state='Enabled') nw_off.update(self.apiclient, state='Enabled')
self._cleanup.append(nw_off) self.cleanup.append(nw_off)
self.services["network_offering"]["supportedservices"] = 'Vpn,Dhcp,Dns,SourceNat,PortForwarding,UserData,Lb,StaticNat' self.services["network_offering"]["supportedservices"] = 'Vpn,Dhcp,Dns,SourceNat,PortForwarding,UserData,Lb,StaticNat'
self.services["network_offering"]["serviceProviderList"] = { self.services["network_offering"]["serviceProviderList"] = {
@ -2042,7 +2069,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
nw_off_vr.update(self.apiclient, state='Enabled') nw_off_vr.update(self.apiclient, state='Enabled')
self._cleanup.append(nw_off_vr) self.cleanup.append(nw_off_vr)
# Creating network using the network offering created # Creating network using the network offering created
self.debug("Creating network with network offering: %s" % nw_off.id) self.debug("Creating network with network offering: %s" % nw_off.id)

View File

@ -42,6 +42,7 @@ from marvin.integration.lib.common import (get_domain,
get_template, get_template,
cleanup_resources, cleanup_resources,
list_routers) list_routers)
import socket
class Services: class Services:
"""Test VPC network services Load Balancing Rules Test data """Test VPC network services Load Balancing Rules Test data
@ -179,6 +180,9 @@ class TestVPCNetworkLBRules(cloudstackTestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
# We want to fail quicker if it's failure
socket.setdefaulttimeout(60)
cls.api_client = super( cls.api_client = super(
TestVPCNetworkLBRules, TestVPCNetworkLBRules,
cls cls
@ -221,14 +225,14 @@ class TestVPCNetworkLBRules(cloudstackTestCase):
admin=True, admin=True,
domainid=self.domain.id domainid=self.domain.id
) )
self._cleanup = [self.account] self.cleanup = [self.account]
self.debug("Creating a VPC offering..") self.debug("Creating a VPC offering..")
self.vpc_off = VpcOffering.create( self.vpc_off = VpcOffering.create(
self.apiclient, self.apiclient,
self.services["vpc_offering"] self.services["vpc_offering"]
) )
self._cleanup.append(self.vpc_off) self.cleanup.append(self.vpc_off)
self.debug("Enabling the VPC offering created") self.debug("Enabling the VPC offering created")
self.vpc_off.update(self.apiclient, state='Enabled') self.vpc_off.update(self.apiclient, state='Enabled')
@ -247,7 +251,7 @@ class TestVPCNetworkLBRules(cloudstackTestCase):
def tearDown(self): def tearDown(self):
try: try:
#Clean up, terminate the created network offerings #Clean up, terminate the created network offerings
cleanup_resources(self.apiclient, self._cleanup) cleanup_resources(self.apiclient, self.cleanup)
except Exception as e: except Exception as e:
self.debug("Warning: Exception during cleanup : %s" % e) self.debug("Warning: Exception during cleanup : %s" % e)
#raise Exception("Warning: Exception during cleanup : %s" % e) #raise Exception("Warning: Exception during cleanup : %s" % e)
@ -294,6 +298,7 @@ class TestVPCNetworkLBRules(cloudstackTestCase):
def start_VPC_VRouter(self, router): def start_VPC_VRouter(self, router):
# Start the VPC Router # Start the VPC Router
self.debug("Starting router ID: %s" % router.id)
cmd = startRouter.startRouterCmd() cmd = startRouter.startRouterCmd()
cmd.id = router.id cmd.id = router.id
self.apiclient.startRouter(cmd) self.apiclient.startRouter(cmd)
@ -400,7 +405,7 @@ class TestVPCNetworkLBRules(cloudstackTestCase):
self.services["vpc_offering"] self.services["vpc_offering"]
) )
self._cleanup.append(vpc_off) self.cleanup.append(vpc_off)
self.debug("Enabling the VPC offering created") self.debug("Enabling the VPC offering created")
vpc_off.update(self.apiclient, state='Enabled') vpc_off.update(self.apiclient, state='Enabled')
@ -426,7 +431,7 @@ class TestVPCNetworkLBRules(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
nw_off.update(self.apiclient, state='Enabled') nw_off.update(self.apiclient, state='Enabled')
self._cleanup.append(nw_off) self.cleanup.append(nw_off)
self.debug('Created and Enabled NetworkOffering') self.debug('Created and Enabled NetworkOffering')
self.services["network"]["name"] = "NETWORK-" + str(gateway) self.services["network"]["name"] = "NETWORK-" + str(gateway)
@ -665,7 +670,7 @@ class TestVPCNetworkLBRules(cloudstackTestCase):
self.debug('lb_rule_http=%s' % lb_rule_http.__dict__) self.debug('lb_rule_http=%s' % lb_rule_http.__dict__)
self.check_wget_from_vm(vm_1, public_ip_1, testnegative=False) self.check_wget_from_vm(vm_1, public_ip_1, testnegative=False)
self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=False) self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=False)
lb_rule_nat.delete() lb_rule_nat.delete(self.apiclient)
self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=True) self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=True)
return return
@ -696,7 +701,7 @@ class TestVPCNetworkLBRules(cloudstackTestCase):
self.debug('lb_rule_http=%s' % lb_rule_http.__dict__) self.debug('lb_rule_http=%s' % lb_rule_http.__dict__)
self.check_wget_from_vm(vm_1, public_ip_1, testnegative=False) self.check_wget_from_vm(vm_1, public_ip_1, testnegative=False)
self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=False) self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=False)
lb_rule_nat.delete() lb_rule_nat.delete(self.apiclient)
self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=True) self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=True)
return return
@ -727,8 +732,8 @@ class TestVPCNetworkLBRules(cloudstackTestCase):
self.debug('lb_rule_http=%s' % lb_rule_http.__dict__) self.debug('lb_rule_http=%s' % lb_rule_http.__dict__)
self.check_wget_from_vm(vm_1, public_ip_1, testnegative=False) self.check_wget_from_vm(vm_1, public_ip_1, testnegative=False)
self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=False) self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=False)
lb_rule_nat.delete() lb_rule_nat.delete(self.apiclient)
lb_rule_http.delete() lb_rule_http.delete(self.apiclient)
self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=True) self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=True)
self.check_wget_from_vm(vm_1, public_ip_1, testnegative=True) self.check_wget_from_vm(vm_1, public_ip_1, testnegative=True)
return return
@ -760,8 +765,8 @@ class TestVPCNetworkLBRules(cloudstackTestCase):
self.debug('lb_rule_http=%s' % lb_rule_http.__dict__) self.debug('lb_rule_http=%s' % lb_rule_http.__dict__)
self.check_wget_from_vm(vm_1, public_ip_1, testnegative=False) self.check_wget_from_vm(vm_1, public_ip_1, testnegative=False)
self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=False) self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=False)
lb_rule_nat.delete() lb_rule_nat.delete(self.apiclient)
lb_rule_http.delete() lb_rule_http.delete(self.apiclient)
self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=True) self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=True)
self.check_wget_from_vm(vm_1, public_ip_1, testnegative=True) self.check_wget_from_vm(vm_1, public_ip_1, testnegative=True)
return return

View File

@ -38,6 +38,7 @@ from marvin.integration.lib.common import (get_domain,
get_template, get_template,
cleanup_resources, cleanup_resources,
list_routers) list_routers)
import socket
class Services: class Services:
@ -179,6 +180,9 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
# We want to fail quicker if it's failure
socket.setdefaulttimeout(60)
cls.api_client = super( cls.api_client = super(
TestVPCNetworkPFRules, TestVPCNetworkPFRules,
cls cls
@ -294,6 +298,7 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
def start_vpcrouter(self, router): def start_vpcrouter(self, router):
# Start the VPC Router # Start the VPC Router
self.debug("Starting router ID: %s" % router.id)
cmd = startRouter.startRouterCmd() cmd = startRouter.startRouterCmd()
cmd.id = router.id cmd.id = router.id
self.apiclient.startRouter(cmd) self.apiclient.startRouter(cmd)
@ -634,7 +639,7 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=False) self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=False)
self.check_wget_from_vm(vm_1, public_ip_1, testnegative=False) self.check_wget_from_vm(vm_1, public_ip_1, testnegative=False)
router = self.stop_vpcrouter() router = self.stop_vpcrouter()
http_rule.delete() http_rule.delete(self.apiclient)
self.start_vpcrouter(router) self.start_vpcrouter(router)
self.check_wget_from_vm(vm_1, public_ip_1, testnegative=True) self.check_wget_from_vm(vm_1, public_ip_1, testnegative=True)
return return
@ -663,7 +668,7 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
#http_rule = self.create_egress_Internet_Rule(network_1) #http_rule = self.create_egress_Internet_Rule(network_1)
self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=False) self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=False)
self.check_wget_from_vm(vm_1, public_ip_1, testnegative=False) self.check_wget_from_vm(vm_1, public_ip_1, testnegative=False)
http_rule.delete() http_rule.delete(self.apiclient)
self.check_wget_from_vm(vm_1, public_ip_1, testnegative=True) self.check_wget_from_vm(vm_1, public_ip_1, testnegative=True)
return return
@ -695,8 +700,8 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=False) self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=False)
self.check_wget_from_vm(vm_1, public_ip_1, testnegative=False) self.check_wget_from_vm(vm_1, public_ip_1, testnegative=False)
router = self.stop_vpcrouter() router = self.stop_vpcrouter()
http_rule.delete() http_rule.delete(self.apiclient)
nat_rule.delete() nat_rule.delete(self.apiclient)
self.start_vpcrouter(router) self.start_vpcrouter(router)
self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=True) self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=True)
self.check_wget_from_vm(vm_1, public_ip_1, testnegative=True) self.check_wget_from_vm(vm_1, public_ip_1, testnegative=True)
@ -727,8 +732,8 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
#http_rule = self.create_egress_Internet_Rule(network_1) #http_rule = self.create_egress_Internet_Rule(network_1)
self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=False) self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=False)
self.check_wget_from_vm(vm_1, public_ip_1, testnegative=False) self.check_wget_from_vm(vm_1, public_ip_1, testnegative=False)
http_rule.delete() http_rule.delete(self.apiclient)
nat_rule.delete() nat_rule.delete(self.apiclient)
self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=True) self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=True)
self.check_wget_from_vm(vm_1, public_ip_1, testnegative=True) self.check_wget_from_vm(vm_1, public_ip_1, testnegative=True)
return return
@ -764,34 +769,40 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
public_ip_2 = self.acquire_publicip(network_1) public_ip_2 = self.acquire_publicip(network_1)
nat_rule1 = self.create_natrule(vm_1, public_ip_1, network_1) nat_rule1 = self.create_natrule(vm_1, public_ip_1, network_1)
nat_rule2 = self.create_natrule(vm_2, public_ip_2, network_1) nat_rule2 = self.create_natrule(vm_2, public_ip_2, network_1)
http_rule1 = self.open_egress_to_world(network_1) http_rule1 = self.create_natrule(vm_1, public_ip_1, network_1, self.services["http_rule"])
nat_rule3 = self.create_natrule(vm_3, public_ip_1, network_2) http_rule2 = self.create_natrule(vm_2, public_ip_2, network_1, self.services["http_rule"])
nat_rule4 = self.create_natrule(vm_4, public_ip_2, network_2) public_ip_3 = self.acquire_publicip(network_2)
http_rule2 = self.open_egress_to_world(network_2) public_ip_4 = self.acquire_publicip(network_2)
nat_rule3 = self.create_natrule(vm_3, public_ip_3, network_2)
nat_rule4 = self.create_natrule(vm_4, public_ip_4, network_2)
http_rule3 = self.create_natrule(vm_3, public_ip_3, network_2, self.services["http_rule"])
http_rule4 = self.create_natrule(vm_4, public_ip_4, network_2, self.services["http_rule"])
self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=False) self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=False)
self.check_ssh_into_vm(vm_2, public_ip_2, testnegative=False) self.check_ssh_into_vm(vm_2, public_ip_2, testnegative=False)
self.check_ssh_into_vm(vm_3, public_ip_1, testnegative=False) self.check_ssh_into_vm(vm_3, public_ip_3, testnegative=False)
self.check_ssh_into_vm(vm_4, public_ip_2, testnegative=False) self.check_ssh_into_vm(vm_4, public_ip_4, testnegative=False)
self.check_wget_from_vm(vm_1, public_ip_1, testnegative=False) self.check_wget_from_vm(vm_1, public_ip_1, testnegative=False)
self.check_wget_from_vm(vm_2, public_ip_2, testnegative=False) self.check_wget_from_vm(vm_2, public_ip_2, testnegative=False)
self.check_wget_from_vm(vm_3, public_ip_1, testnegative=False) self.check_wget_from_vm(vm_3, public_ip_3, testnegative=False)
self.check_wget_from_vm(vm_4, public_ip_2, testnegative=False) self.check_wget_from_vm(vm_4, public_ip_4, testnegative=False)
router = self.stop_vpcrouter() router = self.stop_vpcrouter()
nat_rule1.delete() nat_rule1.delete(self.apiclient)
nat_rule2.delete() nat_rule2.delete(self.apiclient)
nat_rule3.delete() nat_rule3.delete(self.apiclient)
nat_rule4.delete() nat_rule4.delete(self.apiclient)
http_rule1.delete() http_rule1.delete(self.apiclient)
http_rule2.delete() http_rule2.delete(self.apiclient)
http_rule3.delete(self.apiclient)
http_rule4.delete(self.apiclient)
self.start_vpcrouter(router) self.start_vpcrouter(router)
self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=True) self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=True)
self.check_ssh_into_vm(vm_2, public_ip_2, testnegative=True) self.check_ssh_into_vm(vm_2, public_ip_2, testnegative=True)
self.check_ssh_into_vm(vm_3, public_ip_1, testnegative=True) self.check_ssh_into_vm(vm_3, public_ip_3, testnegative=True)
self.check_ssh_into_vm(vm_4, public_ip_2, testnegative=True) self.check_ssh_into_vm(vm_4, public_ip_4, testnegative=True)
self.check_wget_from_vm(vm_1, public_ip_1, testnegative=True) self.check_wget_from_vm(vm_1, public_ip_1, testnegative=True)
self.check_wget_from_vm(vm_2, public_ip_2, testnegative=True) self.check_wget_from_vm(vm_2, public_ip_2, testnegative=True)
self.check_wget_from_vm(vm_3, public_ip_1, testnegative=True) self.check_wget_from_vm(vm_3, public_ip_3, testnegative=True)
self.check_wget_from_vm(vm_4, public_ip_2, testnegative=True) self.check_wget_from_vm(vm_4, public_ip_4, testnegative=True)
return return
@attr(tags=["advanced", "intervlan"]) @attr(tags=["advanced", "intervlan"])
@ -822,30 +833,36 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
public_ip_2 = self.acquire_publicip(network_1) public_ip_2 = self.acquire_publicip(network_1)
nat_rule1 = self.create_natrule(vm_1, public_ip_1, network_1) nat_rule1 = self.create_natrule(vm_1, public_ip_1, network_1)
nat_rule2 = self.create_natrule(vm_2, public_ip_2, network_1) nat_rule2 = self.create_natrule(vm_2, public_ip_2, network_1)
http_rule1 = self.open_egress_to_world(network_1) http_rule1 = self.create_natrule(vm_1, public_ip_1, network_1, self.services["http_rule"])
nat_rule3 = self.create_natrule(vm_3, public_ip_1, network_2) http_rule2 = self.create_natrule(vm_2, public_ip_2, network_1, self.services["http_rule"])
nat_rule4 = self.create_natrule(vm_4, public_ip_2, network_2) public_ip_3 = self.acquire_publicip(network_2)
http_rule2 = self.open_egress_to_world(network_2) public_ip_4 = self.acquire_publicip(network_2)
nat_rule3 = self.create_natrule(vm_3, public_ip_3, network_2)
nat_rule4 = self.create_natrule(vm_4, public_ip_4, network_2)
http_rule3 = self.create_natrule(vm_3, public_ip_3, network_2, self.services["http_rule"])
http_rule4 = self.create_natrule(vm_4, public_ip_4, network_2, self.services["http_rule"])
self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=False) self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=False)
self.check_ssh_into_vm(vm_2, public_ip_2, testnegative=False) self.check_ssh_into_vm(vm_2, public_ip_2, testnegative=False)
self.check_ssh_into_vm(vm_3, public_ip_1, testnegative=False) self.check_ssh_into_vm(vm_3, public_ip_3, testnegative=False)
self.check_ssh_into_vm(vm_4, public_ip_2, testnegative=False) self.check_ssh_into_vm(vm_4, public_ip_4, testnegative=False)
self.check_wget_from_vm(vm_1, public_ip_1, testnegative=False) self.check_wget_from_vm(vm_1, public_ip_1, testnegative=False)
self.check_wget_from_vm(vm_2, public_ip_2, testnegative=False) self.check_wget_from_vm(vm_2, public_ip_2, testnegative=False)
self.check_wget_from_vm(vm_3, public_ip_1, testnegative=False) self.check_wget_from_vm(vm_3, public_ip_3, testnegative=False)
self.check_wget_from_vm(vm_4, public_ip_2, testnegative=False) self.check_wget_from_vm(vm_4, public_ip_4, testnegative=False)
nat_rule1.delete() nat_rule1.delete(self.apiclient)
nat_rule2.delete() nat_rule2.delete(self.apiclient)
nat_rule3.delete() nat_rule3.delete(self.apiclient)
nat_rule4.delete() nat_rule4.delete(self.apiclient)
http_rule1.delete() http_rule1.delete(self.apiclient)
http_rule2.delete() http_rule2.delete(self.apiclient)
http_rule3.delete(self.apiclient)
http_rule4.delete(self.apiclient)
self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=True) self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=True)
self.check_ssh_into_vm(vm_2, public_ip_2, testnegative=True) self.check_ssh_into_vm(vm_2, public_ip_2, testnegative=True)
self.check_ssh_into_vm(vm_3, public_ip_1, testnegative=True) self.check_ssh_into_vm(vm_3, public_ip_3, testnegative=True)
self.check_ssh_into_vm(vm_4, public_ip_2, testnegative=True) self.check_ssh_into_vm(vm_4, public_ip_4, testnegative=True)
self.check_wget_from_vm(vm_1, public_ip_1, testnegative=True) self.check_wget_from_vm(vm_1, public_ip_1, testnegative=True)
self.check_wget_from_vm(vm_2, public_ip_2, testnegative=True) self.check_wget_from_vm(vm_2, public_ip_2, testnegative=True)
self.check_wget_from_vm(vm_3, public_ip_1, testnegative=True) self.check_wget_from_vm(vm_3, public_ip_3, testnegative=True)
self.check_wget_from_vm(vm_4, public_ip_2, testnegative=True) self.check_wget_from_vm(vm_4, public_ip_4, testnegative=True)
return return

View File

@ -38,6 +38,7 @@ from marvin.integration.lib.common import (get_domain,
get_template, get_template,
cleanup_resources, cleanup_resources,
list_routers) list_routers)
import socket
class Services: class Services:
@ -178,6 +179,9 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
# We want to fail quicker if it's failure
socket.setdefaulttimeout(60)
cls.api_client = super( cls.api_client = super(
TestVPCNetworkPFRules, TestVPCNetworkPFRules,
cls cls
@ -220,14 +224,14 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
admin=True, admin=True,
domainid=self.domain.id domainid=self.domain.id
) )
self._cleanup = [self.account] self.cleanup = [self.account]
self.debug("Creating a VPC offering..") self.debug("Creating a VPC offering..")
self.vpc_off = VpcOffering.create( self.vpc_off = VpcOffering.create(
self.apiclient, self.apiclient,
self.services["vpc_offering"] self.services["vpc_offering"]
) )
self._cleanup.append(self.vpc_off) self.cleanup.append(self.vpc_off)
self.debug("Enabling the VPC offering created") self.debug("Enabling the VPC offering created")
self.vpc_off.update(self.apiclient, state='Enabled') self.vpc_off.update(self.apiclient, state='Enabled')
@ -246,7 +250,7 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
def tearDown(self): def tearDown(self):
try: try:
#Clean up, terminate the created network offerings #Clean up, terminate the created network offerings
cleanup_resources(self.apiclient, self._cleanup) cleanup_resources(self.apiclient, self.cleanup)
except Exception as e: except Exception as e:
self.debug("Warning: Exception during cleanup : %s" % e) self.debug("Warning: Exception during cleanup : %s" % e)
#raise Exception("Warning: Exception during cleanup : %s" % e) #raise Exception("Warning: Exception during cleanup : %s" % e)
@ -401,7 +405,7 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
self.services["vpc_offering"] self.services["vpc_offering"]
) )
self._cleanup.append(self.vpc_off) self.cleanup.append(self.vpc_off)
self.debug("Enabling the VPC offering created") self.debug("Enabling the VPC offering created")
vpc_off.update(self.apiclient, state='Enabled') vpc_off.update(self.apiclient, state='Enabled')
@ -427,7 +431,7 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
nw_off.update(self.apiclient, state='Enabled') nw_off.update(self.apiclient, state='Enabled')
self._cleanup.append(nw_off) self.cleanup.append(nw_off)
self.debug('Created and Enabled NetworkOffering') self.debug('Created and Enabled NetworkOffering')
self.services["network"]["name"] = "NETWORK-" + str(gateway) self.services["network"]["name"] = "NETWORK-" + str(gateway)
@ -634,8 +638,8 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
http_rule = self.create_NatRule_For_VM(vm_1, public_ip_1, network_1, self.services["http_rule"]) http_rule = self.create_NatRule_For_VM(vm_1, public_ip_1, network_1, self.services["http_rule"])
self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=False) self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=False)
self.check_wget_from_vm(vm_1, public_ip_1, testnegative=False) self.check_wget_from_vm(vm_1, public_ip_1, testnegative=False)
http_rule.delete() http_rule.delete(self.apiclient)
nat_rule.delete() nat_rule.delete(self.apiclient)
self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=True) self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=True)
self.check_wget_from_vm(vm_1, public_ip_1, testnegative=True) self.check_wget_from_vm(vm_1, public_ip_1, testnegative=True)
return return
@ -682,12 +686,12 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
self.check_wget_from_vm(vm_2, public_ip_2, testnegative=False) self.check_wget_from_vm(vm_2, public_ip_2, testnegative=False)
self.check_wget_from_vm(vm_3, public_ip_1, testnegative=False) self.check_wget_from_vm(vm_3, public_ip_1, testnegative=False)
self.check_wget_from_vm(vm_4, public_ip_2, testnegative=False) self.check_wget_from_vm(vm_4, public_ip_2, testnegative=False)
nat_rule1.delete() nat_rule1.delete(self.apiclient)
nat_rule2.delete() nat_rule2.delete(self.apiclient)
nat_rule3.delete() nat_rule3.delete(self.apiclient)
nat_rule4.delete() nat_rule4.delete(self.apiclient)
http_rule1.delete() http_rule1.delete(self.apiclient)
http_rule2.delete() http_rule2.delete(self.apiclient)
self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=True) self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=True)
self.check_ssh_into_vm(vm_2, public_ip_2, testnegative=True) self.check_ssh_into_vm(vm_2, public_ip_2, testnegative=True)
self.check_ssh_into_vm(vm_3, public_ip_1, testnegative=True) self.check_ssh_into_vm(vm_3, public_ip_1, testnegative=True)

View File

@ -180,7 +180,15 @@ class TestVPCOffering(cloudstackTestCase):
admin=True, admin=True,
domainid=self.domain.id domainid=self.domain.id
) )
self._cleanup.insert(0, self.account) self.cleanup = []
self.cleanup.insert(0, self.account)
return
def tearDown(self):
try:
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return return
def validate_vpc_offering(self, vpc_offering): def validate_vpc_offering(self, vpc_offering):
@ -243,7 +251,7 @@ class TestVPCOffering(cloudstackTestCase):
) )
self.debug("Check if the VPC offering is created successfully?") self.debug("Check if the VPC offering is created successfully?")
self._cleanup.append(vpc_off) self.cleanup.append(vpc_off)
self.validate_vpc_offering(vpc_off) self.validate_vpc_offering(vpc_off)
return return
@ -270,7 +278,7 @@ class TestVPCOffering(cloudstackTestCase):
self.services["vpc_offering"] self.services["vpc_offering"]
) )
self._cleanup.append(vpc_off) self.cleanup.append(vpc_off)
self.validate_vpc_offering(vpc_off) self.validate_vpc_offering(vpc_off)
self.debug("Enabling the VPC offering created") self.debug("Enabling the VPC offering created")
@ -295,7 +303,7 @@ class TestVPCOffering(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
self.network_offering.update(self.apiclient, state='Enabled') self.network_offering.update(self.apiclient, state='Enabled')
self._cleanup.append(self.network_offering) self.cleanup.append(self.network_offering)
gateway = vpc.cidr.split('/')[0] gateway = vpc.cidr.split('/')[0]
# Split the cidr to retrieve gateway # Split the cidr to retrieve gateway
@ -544,14 +552,14 @@ class TestVPCOffering(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
self.network_offering.update(self.apiclient, state='Enabled') self.network_offering.update(self.apiclient, state='Enabled')
self._cleanup.append(self.network_offering) self.cleanup.append(self.network_offering)
vpc_off = VpcOffering.create( vpc_off = VpcOffering.create(
self.apiclient, self.apiclient,
self.services["vpc_offering"] self.services["vpc_offering"]
) )
self._cleanup.append(vpc_off) self.cleanup.append(vpc_off)
self.validate_vpc_offering(vpc_off) self.validate_vpc_offering(vpc_off)
self.debug("Enabling the VPC offering created") self.debug("Enabling the VPC offering created")
@ -663,14 +671,14 @@ class TestVPCOffering(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
self.network_offering.update(self.apiclient, state='Enabled') self.network_offering.update(self.apiclient, state='Enabled')
self._cleanup.append(self.network_offering) self.cleanup.append(self.network_offering)
vpc_off = VpcOffering.create( vpc_off = VpcOffering.create(
self.apiclient, self.apiclient,
self.services["vpc_offering"] self.services["vpc_offering"]
) )
self._cleanup.append(vpc_off) self.cleanup.append(vpc_off)
self.validate_vpc_offering(vpc_off) self.validate_vpc_offering(vpc_off)
self.debug("Enabling the VPC offering created") self.debug("Enabling the VPC offering created")
@ -784,14 +792,14 @@ class TestVPCOffering(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
self.network_offering.update(self.apiclient, state='Enabled') self.network_offering.update(self.apiclient, state='Enabled')
self._cleanup.append(self.network_offering) self.cleanup.append(self.network_offering)
vpc_off = VpcOffering.create( vpc_off = VpcOffering.create(
self.apiclient, self.apiclient,
self.services["vpc_offering"] self.services["vpc_offering"]
) )
self._cleanup.append(vpc_off) self.cleanup.append(vpc_off)
self.validate_vpc_offering(vpc_off) self.validate_vpc_offering(vpc_off)
self.debug("Enabling the VPC offering created") self.debug("Enabling the VPC offering created")
@ -904,7 +912,7 @@ class TestVPCOffering(cloudstackTestCase):
) )
self.validate_vpc_offering(vpc_off) self.validate_vpc_offering(vpc_off)
# Appending to cleanup to delete after test # Appending to cleanup to delete after test
self._cleanup.append(vpc_off) self.cleanup.append(vpc_off)
except Exception as e: except Exception as e:
self.fail("Failed to create the VPC offering - %s" % e) self.fail("Failed to create the VPC offering - %s" % e)
return return
@ -928,7 +936,7 @@ class TestVPCOffering(cloudstackTestCase):
self.services["vpc_offering"] self.services["vpc_offering"]
) )
self._cleanup.append(vpc_off) self.cleanup.append(vpc_off)
self.validate_vpc_offering(vpc_off) self.validate_vpc_offering(vpc_off)
self.debug("Enabling the VPC offering created") self.debug("Enabling the VPC offering created")
@ -1024,7 +1032,7 @@ class TestVPCOffering(cloudstackTestCase):
self.apiclient, self.apiclient,
self.services["vpc_offering"] self.services["vpc_offering"]
) )
self._cleanup.append(vpc_off_1) self.cleanup.append(vpc_off_1)
self.validate_vpc_offering(vpc_off_1) self.validate_vpc_offering(vpc_off_1)
self.debug("Disabling the VPC offering created") self.debug("Disabling the VPC offering created")
vpc_off_1.update(self.apiclient, state='Disabled') vpc_off_1.update(self.apiclient, state='Disabled')
@ -1034,7 +1042,7 @@ class TestVPCOffering(cloudstackTestCase):
self.services["vpc_offering"] self.services["vpc_offering"]
) )
self._cleanup.append(vpc_off_2) self.cleanup.append(vpc_off_2)
self.validate_vpc_offering(vpc_off_2) self.validate_vpc_offering(vpc_off_2)
self.debug("Enabling the VPC offering created") self.debug("Enabling the VPC offering created")
vpc_off_2.update(self.apiclient, state='Enabled') vpc_off_2.update(self.apiclient, state='Enabled')
@ -1044,7 +1052,7 @@ class TestVPCOffering(cloudstackTestCase):
self.services["vpc_offering"] self.services["vpc_offering"]
) )
self._cleanup.append(vpc_off_3) self.cleanup.append(vpc_off_3)
self.validate_vpc_offering(vpc_off_3) self.validate_vpc_offering(vpc_off_3)
self.debug("Enabling the VPC offering created") self.debug("Enabling the VPC offering created")
vpc_off_3.update(self.apiclient, state='Enabled') vpc_off_3.update(self.apiclient, state='Enabled')
@ -1053,7 +1061,7 @@ class TestVPCOffering(cloudstackTestCase):
self.apiclient, self.apiclient,
self.services["vpc_offering"] self.services["vpc_offering"]
) )
self._cleanup.append(vpc_off_4) self.cleanup.append(vpc_off_4)
self.debug("Enabling the VPC offering created") self.debug("Enabling the VPC offering created")
vpc_off_4.update(self.apiclient, state='Enabled') vpc_off_4.update(self.apiclient, state='Enabled')

View File

@ -354,7 +354,7 @@ class TestVMDeployVPC(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
nw_off_no_lb.update(self.apiclient, state='Enabled') nw_off_no_lb.update(self.apiclient, state='Enabled')
self._cleanup.append(nw_off) self._cleanup.append(nw_off_no_lb)
# Creating network using the network offering created # Creating network using the network offering created
self.debug("Creating network with network offering: %s" % self.debug("Creating network with network offering: %s" %
@ -569,7 +569,7 @@ class TestVMDeployVPC(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
nw_off_no_lb.update(self.apiclient, state='Enabled') nw_off_no_lb.update(self.apiclient, state='Enabled')
self._cleanup.append(nw_off) self._cleanup.append(nw_off_no_lb)
# Creating network using the network offering created # Creating network using the network offering created
self.debug("Creating network with network offering: %s" % self.debug("Creating network with network offering: %s" %
@ -822,7 +822,7 @@ class TestVMDeployVPC(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
nw_off_no_lb.update(self.apiclient, state='Enabled') nw_off_no_lb.update(self.apiclient, state='Enabled')
self._cleanup.append(nw_off) self._cleanup.append(nw_off_no_lb)
# Creating network using the network offering created # Creating network using the network offering created
self.debug("Creating network with network offering: %s" % self.debug("Creating network with network offering: %s" %
@ -1091,7 +1091,7 @@ class TestVMDeployVPC(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
nw_off_no_lb.update(self.apiclient, state='Enabled') nw_off_no_lb.update(self.apiclient, state='Enabled')
self._cleanup.append(nw_off) self._cleanup.append(nw_off_no_lb)
# Creating network using the network offering created # Creating network using the network offering created
self.debug("Creating network with network offering: %s" % self.debug("Creating network with network offering: %s" %
@ -1375,7 +1375,7 @@ class TestVMDeployVPC(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
nw_off_no_lb.update(self.apiclient, state='Enabled') nw_off_no_lb.update(self.apiclient, state='Enabled')
self._cleanup.append(nw_off) self._cleanup.append(nw_off_no_lb)
configs = Configurations.list( configs = Configurations.list(
self.apiclient, self.apiclient,
@ -1546,7 +1546,7 @@ class TestVMDeployVPC(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
nw_off_no_lb.update(self.apiclient, state='Enabled') nw_off_no_lb.update(self.apiclient, state='Enabled')
self._cleanup.append(nw_off) self._cleanup.append(nw_off_no_lb)
# Creating network using the network offering created # Creating network using the network offering created
self.debug("Creating network with network offering: %s" % self.debug("Creating network with network offering: %s" %
@ -1810,7 +1810,7 @@ class TestVMDeployVPC(cloudstackTestCase):
) )
# Enable Network offering # Enable Network offering
nw_off_no_lb.update(self.apiclient, state='Enabled') nw_off_no_lb.update(self.apiclient, state='Enabled')
self._cleanup.append(nw_off) self._cleanup.append(nw_off_no_lb)
# Creating network using the network offering created # Creating network using the network offering created
self.debug("Creating network with network offering: %s" % self.debug("Creating network with network offering: %s" %

View File

@ -120,7 +120,7 @@ class TestVmSnapshot(cloudstackTestCase):
serviceofferingid=cls.service_offering.id, serviceofferingid=cls.service_offering.id,
mode=cls.services["mode"] mode=cls.services["mode"]
) )
cls.random_data_0 = random_gen(100) cls.random_data_0 = random_gen(size=100)
cls._cleanup = [ cls._cleanup = [
cls.service_offering, cls.service_offering,
cls.account, cls.account,

View File

@ -25,6 +25,7 @@ under the License.
<% long now = System.currentTimeMillis(); %> <% long now = System.currentTimeMillis(); %>
<script language="javascript"> <script language="javascript">
dictionary = { dictionary = {
'message.validate.invalid.characters': '<fmt:message key="message.validate.invalid.characters" />',
'label.about': '<fmt:message key="label.about" />', 'label.about': '<fmt:message key="label.about" />',
'label.about.app': '<fmt:message key="label.about.app" />', 'label.about.app': '<fmt:message key="label.about.app" />',
'label.app.name': '<fmt:message key="label.app.name" />', 'label.app.name': '<fmt:message key="label.app.name" />',

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