Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/cloudstack
@ -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 and makes use of JSch - a java SSH2 implementation.
|
||||
|
||||
|
||||
|
||||
@ -16,9 +16,9 @@
|
||||
// under the License.
|
||||
package com.cloud.ha;
|
||||
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.utils.component.Adapter;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
public interface FenceBuilder extends Adapter {
|
||||
/**
|
||||
@ -27,5 +27,5 @@ public interface FenceBuilder extends Adapter {
|
||||
* @param vm vm
|
||||
* @param host host where the vm was running on.
|
||||
*/
|
||||
public Boolean fenceOff(VMInstanceVO vm, HostVO host);
|
||||
public Boolean fenceOff(VirtualMachine vm, Host host);
|
||||
}
|
||||
@ -16,10 +16,10 @@
|
||||
// under the License.
|
||||
package com.cloud.ha;
|
||||
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.utils.component.Adapter;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
public interface Investigator extends Adapter {
|
||||
/**
|
||||
@ -27,7 +27,7 @@ public interface Investigator extends Adapter {
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
@ -93,6 +93,9 @@ public interface Volume extends ControlledEntity, Identity, InternalIdentity, Ba
|
||||
s_fsm.addTransition(UploadOp, Event.OperationSucceeded, Uploaded);
|
||||
s_fsm.addTransition(UploadOp, Event.OperationFailed, Allocated);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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 {
|
||||
CreateRequested,
|
||||
@ -182,27 +182,28 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, I
|
||||
};
|
||||
|
||||
public enum Type {
|
||||
User,
|
||||
DomainRouter,
|
||||
ConsoleProxy,
|
||||
SecondaryStorageVm,
|
||||
ElasticIpVm,
|
||||
ElasticLoadBalancerVm,
|
||||
InternalLoadBalancerVm,
|
||||
User(false),
|
||||
DomainRouter(true),
|
||||
ConsoleProxy(true),
|
||||
SecondaryStorageVm(true),
|
||||
ElasticIpVm(true),
|
||||
ElasticLoadBalancerVm(true),
|
||||
InternalLoadBalancerVm(true),
|
||||
|
||||
/*
|
||||
* UserBareMetal is only used for selecting VirtualMachineGuru, there is no
|
||||
* VM with this type. UserBareMetal should treat exactly as User.
|
||||
*/
|
||||
UserBareMetal;
|
||||
UserBareMetal(false);
|
||||
|
||||
public static boolean isSystemVM(VirtualMachine.Type vmtype) {
|
||||
if (DomainRouter.equals(vmtype)
|
||||
|| ConsoleProxy.equals(vmtype)
|
||||
|| SecondaryStorageVm.equals(vmtype) || InternalLoadBalancerVm.equals(vmtype)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
boolean _isUsedBySystem;
|
||||
|
||||
private Type(boolean isUsedBySystem) {
|
||||
_isUsedBySystem = isUsedBySystem;
|
||||
}
|
||||
|
||||
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
|
||||
* 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
|
||||
* specify the host name when creating the virtual machine then it is
|
||||
* defaults to the instance name.
|
||||
*/
|
||||
public String getHostName();
|
||||
String getHostName();
|
||||
|
||||
/**
|
||||
* @return the ip address of the virtual machine.
|
||||
*/
|
||||
public String getPrivateIpAddress();
|
||||
String getPrivateIpAddress();
|
||||
|
||||
/**
|
||||
* @return mac address.
|
||||
*/
|
||||
public String getPrivateMacAddress();
|
||||
String getPrivateMacAddress();
|
||||
|
||||
/**
|
||||
* @return password of the host for vnc purposes.
|
||||
*/
|
||||
public String getVncPassword();
|
||||
String getVncPassword();
|
||||
|
||||
/**
|
||||
* @return the state of the virtual machine
|
||||
*/
|
||||
// public State getState();
|
||||
// State getState();
|
||||
|
||||
/**
|
||||
* @return template id.
|
||||
*/
|
||||
public long getTemplateId();
|
||||
long getTemplateId();
|
||||
|
||||
|
||||
|
||||
@ -252,49 +253,51 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, I
|
||||
*
|
||||
* @return guestOSId
|
||||
*/
|
||||
public long getGuestOSId();
|
||||
long getGuestOSId();
|
||||
|
||||
/**
|
||||
* @return pod id.
|
||||
*/
|
||||
public Long getPodIdToDeployIn();
|
||||
Long getPodIdToDeployIn();
|
||||
|
||||
/**
|
||||
* @return data center id.
|
||||
*/
|
||||
public long getDataCenterId();
|
||||
long getDataCenterId();
|
||||
|
||||
/**
|
||||
* @return id of the host it was assigned last time.
|
||||
*/
|
||||
public Long getLastHostId();
|
||||
Long getLastHostId();
|
||||
|
||||
@Override
|
||||
public Long getHostId();
|
||||
Long getHostId();
|
||||
|
||||
/**
|
||||
* @return should HA be enabled for this machine?
|
||||
*/
|
||||
public boolean isHaEnabled();
|
||||
boolean isHaEnabled();
|
||||
|
||||
/**
|
||||
* @return should limit CPU usage to the service offering?
|
||||
*/
|
||||
public boolean limitCpuUse();
|
||||
boolean limitCpuUse();
|
||||
|
||||
/**
|
||||
* @return date when machine was created
|
||||
*/
|
||||
public Date getCreated();
|
||||
Date getCreated();
|
||||
|
||||
public long getServiceOfferingId();
|
||||
long getServiceOfferingId();
|
||||
|
||||
public Long getDiskOfferingId();
|
||||
Long getDiskOfferingId();
|
||||
|
||||
Type getType();
|
||||
|
||||
HypervisorType getHypervisorType();
|
||||
|
||||
public Map<String, String> getDetails();
|
||||
Map<String, String> getDetails();
|
||||
|
||||
long getUpdated();
|
||||
|
||||
}
|
||||
|
||||
@ -22,6 +22,7 @@ label.disk.iops.min=Min IOPS
|
||||
label.disk.iops.max=Max IOPS
|
||||
label.disk.iops.total=IOPS Total
|
||||
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.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.
|
||||
|
||||
@ -729,7 +729,6 @@
|
||||
|
||||
<bean id="clusteredVirtualMachineManagerImpl" class="com.cloud.vm.ClusteredVirtualMachineManagerImpl" >
|
||||
<property name="HostAllocators" value="#{hostAllocators.Adapters}" />
|
||||
<property name="Planners" value="#{deploymentPlanners.Adapters}" />
|
||||
</bean>
|
||||
|
||||
<bean id="networkManagerImpl" class="com.cloud.network.NetworkManagerImpl" >
|
||||
|
||||
@ -11,9 +11,9 @@
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
@ -23,6 +23,317 @@
|
||||
-->
|
||||
|
||||
<section id="gsoc-midsummer-ian">
|
||||
<title>Mid-Summer Progress Updates</title>
|
||||
<para>This section describes ...</para>
|
||||
<title>Mid-Summer Progress Updates for Ian Duffy - "Ldap User Provisioning"</title>
|
||||
<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>
|
||||
|
||||
@ -11,9 +11,9 @@
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
|
||||
BIN
docs/en-US/images/add-ldap-configuration-failure.png
Normal file
|
After Width: | Height: | Size: 27 KiB |
BIN
docs/en-US/images/add-ldap-configuration.png
Normal file
|
After Width: | Height: | Size: 27 KiB |
BIN
docs/en-US/images/delete-ldap-configuration-failure.png
Normal file
|
After Width: | Height: | Size: 29 KiB |
BIN
docs/en-US/images/delete-ldap.png
Normal file
|
After Width: | Height: | Size: 27 KiB |
BIN
docs/en-US/images/jenkins-pipeline.png
Normal file
|
After Width: | Height: | Size: 28 KiB |
BIN
docs/en-US/images/ldap-account-addition.png
Normal file
|
After Width: | Height: | Size: 68 KiB |
BIN
docs/en-US/images/ldap-configuration.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
docs/en-US/images/ldap-global-settings.png
Normal file
|
After Width: | Height: | Size: 30 KiB |
BIN
docs/en-US/images/ldap-list-users.png
Normal file
|
After Width: | Height: | Size: 55 KiB |
BIN
docs/en-US/images/list-ldap-configuration.png
Normal file
|
After Width: | Height: | Size: 30 KiB |
144
docs/en-US/removed-api-4.2.xml
Normal 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>
|
||||
@ -25,6 +25,8 @@
|
||||
<section id="whats-new-in-api-4.2">
|
||||
<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="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 id="whats-new-in-api-4.1">
|
||||
<title>What's New in the API for 4.1</title>
|
||||
|
||||
@ -22,11 +22,16 @@ import com.cloud.utils.fsm.StateObject;
|
||||
|
||||
public interface ObjectInDataStoreStateMachine extends StateObject<ObjectInDataStoreStateMachine.State> {
|
||||
enum State {
|
||||
Allocated("The initial state"), Creating2("This is only used with createOnlyRequested event"), Creating(
|
||||
"The object is being creating on data store"), Created("The object is created"), 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");
|
||||
Allocated("The initial state"),
|
||||
Creating2("This is only used with createOnlyRequested event"),
|
||||
Creating("The object is being creating on data store"),
|
||||
Created("The object is created"),
|
||||
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;
|
||||
|
||||
private State(String description) {
|
||||
@ -39,7 +44,14 @@ public interface ObjectInDataStoreStateMachine extends StateObject<ObjectInDataS
|
||||
}
|
||||
|
||||
enum Event {
|
||||
CreateRequested, CreateOnlyRequested, DestroyRequested, OperationSuccessed, OperationFailed, CopyingRequested, MigrationRequested, ResizeRequested, ExpungeRequested
|
||||
|
||||
CreateRequested,
|
||||
CreateOnlyRequested,
|
||||
DestroyRequested,
|
||||
OperationSuccessed,
|
||||
OperationFailed,
|
||||
CopyingRequested,
|
||||
MigrationRequested,
|
||||
ResizeRequested,
|
||||
ExpungeRequested
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,10 +18,14 @@
|
||||
*/
|
||||
package org.apache.cloudstack.engine.subsystem.api.storage;
|
||||
|
||||
import com.cloud.storage.DataStoreRole;
|
||||
|
||||
public interface VolumeDataFactory {
|
||||
VolumeInfo getVolume(long volumeId, DataStore store);
|
||||
|
||||
VolumeInfo getVolume(DataObject volume, DataStore store);
|
||||
|
||||
VolumeInfo getVolume(long volumeId, DataStoreRole storeRole);
|
||||
|
||||
VolumeInfo getVolume(long volumeId);
|
||||
}
|
||||
|
||||
@ -245,17 +245,16 @@ public class VMEntityManagerImpl implements VMEntityManager {
|
||||
|
||||
@Override
|
||||
public boolean stopvirtualmachine(VMEntityVO vmEntityVO, String caller) throws ResourceUnavailableException {
|
||||
|
||||
VMInstanceVO vm = _vmDao.findByUuid(vmEntityVO.getUuid());
|
||||
return _itMgr.stop(vm, _userDao.findById(new Long(caller)), _accountDao.findById(vm.getAccountId()));
|
||||
|
||||
_itMgr.stop(vmEntityVO.getUuid());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean destroyVirtualMachine(VMEntityVO vmEntityVO, String caller) throws AgentUnavailableException, OperationTimedoutException, ConcurrentOperationException{
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -49,6 +49,8 @@ import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
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.DataStoreTO;
|
||||
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.StoragePool;
|
||||
import com.cloud.storage.VolumeManager;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
import com.cloud.storage.dao.DiskOfferingDao;
|
||||
import com.cloud.storage.dao.SnapshotDao;
|
||||
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
|
||||
public Void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback) {
|
||||
Answer answer = null;
|
||||
@ -347,7 +374,12 @@ public class AncientDataMotionStrategy implements DataMotionStrategy {
|
||||
} else if (destData.getType() == DataObjectType.VOLUME && srcData.getType() == DataObjectType.VOLUME
|
||||
&& srcData.getDataStore().getRole() == DataStoreRole.Primary
|
||||
&& destData.getDataStore().getRole() == DataStoreRole.Primary) {
|
||||
answer = copyVolumeBetweenPools(srcData, destData);
|
||||
if (srcData.getId() == destData.getId()) {
|
||||
// The volume has to be migrated across storage pools.
|
||||
answer = migrateVolumeToPool(srcData, destData);
|
||||
} else {
|
||||
answer = copyVolumeBetweenPools(srcData, destData);
|
||||
}
|
||||
} else if (srcData.getType() == DataObjectType.SNAPSHOT && destData.getType() == DataObjectType.SNAPSHOT) {
|
||||
answer = copySnapshot(srcData, destData);
|
||||
} else {
|
||||
|
||||
@ -51,6 +51,26 @@ public class VolumeDataFactoryImpl implements VolumeDataFactory {
|
||||
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
|
||||
public VolumeInfo getVolume(long volumeId) {
|
||||
VolumeVO volumeVO = volumeDao.findById(volumeId);
|
||||
|
||||
@ -109,7 +109,7 @@ public class VolumeObject implements VolumeInfo {
|
||||
|
||||
@Override
|
||||
public String get_iScsiName() {
|
||||
return volumeVO.get_iScsiName();
|
||||
return volumeVO.get_iScsiName();
|
||||
}
|
||||
|
||||
public void setSize(Long size) {
|
||||
@ -254,9 +254,8 @@ public class VolumeObject implements VolumeInfo {
|
||||
}
|
||||
if (this.dataStore.getRole() == DataStoreRole.Image) {
|
||||
objectInStoreMgr.update(this, event);
|
||||
if (this.volumeVO.getState() == Volume.State.Migrating
|
||||
|| this.volumeVO.getState() == Volume.State.Copying
|
||||
|| this.volumeVO.getState() == Volume.State.Uploaded) {
|
||||
if (this.volumeVO.getState() == Volume.State.Migrating || this.volumeVO.getState() == Volume.State.Copying || this.volumeVO.getState() == Volume.State.Uploaded
|
||||
|| this.volumeVO.getState() == Volume.State.Expunged) {
|
||||
return;
|
||||
}
|
||||
if (event == ObjectInDataStoreStateMachine.Event.CreateOnlyRequested) {
|
||||
@ -513,6 +512,7 @@ public class VolumeObject implements VolumeInfo {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void incRefCount() {
|
||||
if (this.dataStore == null) {
|
||||
return;
|
||||
|
||||
@ -75,6 +75,7 @@ import com.cloud.storage.StoragePool;
|
||||
import com.cloud.storage.VMTemplateStoragePoolVO;
|
||||
import com.cloud.storage.VMTemplateStorageResourceAssoc;
|
||||
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
|
||||
import com.cloud.storage.Volume.State;
|
||||
import com.cloud.storage.Volume;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
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
|
||||
@Override
|
||||
public AsyncCallFuture<VolumeApiResult> expungeVolumeAsync(VolumeInfo volume) {
|
||||
AsyncCallFuture<VolumeApiResult> future = new AsyncCallFuture<VolumeApiResult>();
|
||||
VolumeApiResult result = new VolumeApiResult(volume);
|
||||
if (volume.getDataStore() == null) {
|
||||
volDao.remove(volume.getId());
|
||||
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());
|
||||
}
|
||||
future.complete(result);
|
||||
return future;
|
||||
}
|
||||
@ -245,7 +267,11 @@ public class VolumeServiceImpl implements VolumeService {
|
||||
}
|
||||
VolumeObject vo = (VolumeObject) volume;
|
||||
|
||||
volume.processEvent(Event.ExpungeRequested);
|
||||
if (volume.getDataStore().getRole() == DataStoreRole.Image) {
|
||||
volume.processEvent(Event.DestroyRequested);
|
||||
} else if (volume.getDataStore().getRole() == DataStoreRole.Primary) {
|
||||
volume.processEvent(Event.ExpungeRequested);
|
||||
}
|
||||
|
||||
DeleteVolumeContext<VolumeApiResult> context = new DeleteVolumeContext<VolumeApiResult>(null, vo, future);
|
||||
AsyncCallbackDispatcher<VolumeServiceImpl, CommandResult> caller = AsyncCallbackDispatcher.create(this);
|
||||
@ -255,6 +281,7 @@ public class VolumeServiceImpl implements VolumeService {
|
||||
return future;
|
||||
}
|
||||
|
||||
|
||||
public Void deleteVolumeCallback(AsyncCallbackDispatcher<VolumeServiceImpl, CommandResult> callback,
|
||||
DeleteVolumeContext<VolumeApiResult> context) {
|
||||
CommandResult result = callback.getResult();
|
||||
@ -262,7 +289,10 @@ public class VolumeServiceImpl implements VolumeService {
|
||||
VolumeApiResult apiResult = new VolumeApiResult(vo);
|
||||
if (result.isSuccess()) {
|
||||
vo.processEvent(Event.OperationSuccessed);
|
||||
volDao.remove(vo.getId());
|
||||
if (canVolumeBeRemoved(vo.getId())) {
|
||||
s_logger.info("Volume " + vo.getId() + " is not referred anywhere, remove it from volumes table");
|
||||
volDao.remove(vo.getId());
|
||||
}
|
||||
} else {
|
||||
vo.processEvent(Event.OperationFailed);
|
||||
apiResult.setResult(result.getResult());
|
||||
|
||||
@ -96,18 +96,16 @@ wait_for_dnsmasq () {
|
||||
return 1
|
||||
}
|
||||
|
||||
if [ $ipv4 ]
|
||||
if [ $ipv6 ]
|
||||
then
|
||||
ip=$ipv4
|
||||
else
|
||||
ip=$ipv6
|
||||
no_dhcp_release=1
|
||||
fi
|
||||
|
||||
if [ $no_dhcp_release -eq 0 ]
|
||||
then
|
||||
#release previous dhcp lease if present
|
||||
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"
|
||||
fi
|
||||
|
||||
|
||||
@ -31,12 +31,13 @@ import com.cloud.agent.api.FenceCommand;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.ha.FenceBuilder;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
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.utils.component.AdapterBase;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
@Local(value=FenceBuilder.class)
|
||||
public class OvmFencer extends AdapterBase implements FenceBuilder {
|
||||
@ -66,7 +67,7 @@ public class OvmFencer extends AdapterBase implements FenceBuilder {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean fenceOff(VMInstanceVO vm, HostVO host) {
|
||||
public Boolean fenceOff(VirtualMachine vm, Host host) {
|
||||
if (host.getHypervisorType() != HypervisorType.Ovm) {
|
||||
s_logger.debug("Don't know how to fence non Ovm hosts " + host.getHypervisorType());
|
||||
return null;
|
||||
|
||||
@ -11,25 +11,22 @@
|
||||
// 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
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.ha;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
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.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
@Local(value=FenceBuilder.class)
|
||||
public class VmwareFencer extends AdapterBase implements FenceBuilder {
|
||||
|
||||
@Override
|
||||
public Boolean fenceOff(VMInstanceVO vm, HostVO host) {
|
||||
public Boolean fenceOff(VirtualMachine vm, Host host) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -11,18 +11,18 @@
|
||||
// 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
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.ha;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
@Local(value=Investigator.class)
|
||||
public class VmwareInvestigator extends AdapterBase implements Investigator {
|
||||
@ -30,7 +30,7 @@ public class VmwareInvestigator extends AdapterBase implements Investigator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Status isAgentAlive(HostVO agent) {
|
||||
public Status isAgentAlive(Host agent) {
|
||||
if(agent.getHypervisorType() == HypervisorType.VMware)
|
||||
return Status.Disconnected;
|
||||
|
||||
@ -38,7 +38,7 @@ public class VmwareInvestigator extends AdapterBase implements Investigator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isVmAlive(VMInstanceVO vm, HostVO host) {
|
||||
public Boolean isVmAlive(VirtualMachine vm, Host host) {
|
||||
if(vm.getHypervisorType() == HypervisorType.VMware)
|
||||
return true;
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
// 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
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.ha;
|
||||
@ -31,13 +31,14 @@ import com.cloud.agent.api.FenceAnswer;
|
||||
import com.cloud.agent.api.FenceCommand;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
@Local(value=FenceBuilder.class)
|
||||
public class XenServerFencer extends AdapterBase implements FenceBuilder {
|
||||
@ -49,7 +50,7 @@ public class XenServerFencer extends AdapterBase implements FenceBuilder {
|
||||
@Inject ResourceManager _resourceMgr;
|
||||
|
||||
@Override
|
||||
public Boolean fenceOff(VMInstanceVO vm, HostVO host) {
|
||||
public Boolean fenceOff(VirtualMachine vm, Host host) {
|
||||
if (host.getHypervisorType() != HypervisorType.XenServer) {
|
||||
s_logger.debug("Don't know how to fence non XenServer hosts " + host.getHypervisorType());
|
||||
return null;
|
||||
|
||||
@ -4885,8 +4885,10 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
||||
|
||||
} catch (XenAPIException 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) {
|
||||
s_logger.warn("Unable to create local link network", e);
|
||||
throw new CloudRuntimeException("Unable to create local link network due to " + e.toString(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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 {
|
||||
s_logger.debug("Stopping ELB vm " + elbVm);
|
||||
try {
|
||||
if (_itMgr.advanceStop( elbVm, forced, user, caller)) {
|
||||
return _routerDao.findById(elbVm.getId());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
_itMgr.advanceStop(elbVm.getUuid(), forced);
|
||||
return _routerDao.findById(elbVm.getId());
|
||||
} catch (OperationTimedoutException e) {
|
||||
throw new CloudRuntimeException("Unable to stop " + elbVm, e);
|
||||
}
|
||||
@ -736,7 +733,8 @@ public class ElasticLoadBalancerManagerImpl extends ManagerBase implements Elast
|
||||
if (gceed) {
|
||||
try {
|
||||
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) {
|
||||
s_logger.warn("Unable to destroy unused ELB vm " + elbVm + " due to ", e);
|
||||
gceed = false;
|
||||
|
||||
@ -513,7 +513,9 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
|
||||
|
||||
_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 {
|
||||
s_logger.debug("Stopping internal lb vm " + internalLbVm);
|
||||
try {
|
||||
if (_itMgr.advanceStop(internalLbVm, forced, _accountMgr.getActiveUser(callerUserId), caller)) {
|
||||
return _internalLbVmDao.findById(internalLbVm.getId());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
_itMgr.advanceStop(internalLbVm.getUuid(), forced);
|
||||
return _internalLbVmDao.findById(internalLbVm.getId());
|
||||
} catch (OperationTimedoutException e) {
|
||||
throw new CloudRuntimeException("Unable to stop " + internalLbVm, e);
|
||||
}
|
||||
|
||||
@ -24,13 +24,8 @@ import java.util.List;
|
||||
|
||||
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 org.apache.cloudstack.lb.ApplicationLoadBalancerRuleVO;
|
||||
import org.apache.cloudstack.network.lb.InternalLoadBalancerVMManager;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@ -38,6 +33,9 @@ import org.mockito.Mockito;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
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.api.Answer;
|
||||
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.rules.FirewallRule;
|
||||
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.dao.ServiceOfferingDao;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.AccountVO;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.utils.component.ComponentContext;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.net.Ip;
|
||||
@ -103,6 +101,7 @@ public class InternalLBVMManagerTest extends TestCase {
|
||||
long validVmId = 1L;
|
||||
long invalidVmId = 2L;
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void setUp() {
|
||||
//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);
|
||||
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(invalidVmId)).thenReturn(null);
|
||||
|
||||
@ -36,7 +36,6 @@ import org.apache.cloudstack.network.lb.InternalLoadBalancerVMService;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.exception.StorageUnavailableException;
|
||||
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.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.AccountVO;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.user.UserVO;
|
||||
import com.cloud.user.dao.AccountDao;
|
||||
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(nonExistingVmId)).thenReturn(null);
|
||||
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
|
||||
|
||||
@ -18,18 +18,18 @@
|
||||
|
||||
# Version @VERSION@
|
||||
#
|
||||
# A plugin for executing script needed by cloud stack
|
||||
from __future__ import with_statement
|
||||
|
||||
# A plugin for executing script needed by CloudStack
|
||||
from copy import copy
|
||||
from datetime import datetime
|
||||
from httplib import *
|
||||
from string import join
|
||||
from string import split
|
||||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import hashlib
|
||||
import md5 as md5mod
|
||||
import sha
|
||||
import base64
|
||||
import hmac
|
||||
import traceback
|
||||
@ -45,30 +45,57 @@ NULL = 'null'
|
||||
|
||||
|
||||
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):
|
||||
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):
|
||||
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):
|
||||
return value if is_not_blank(value) else default
|
||||
|
||||
if is_not_blank(value):
|
||||
return value
|
||||
return default
|
||||
|
||||
|
||||
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=''):
|
||||
return map[key] if key in map else default
|
||||
|
||||
if key in map:
|
||||
return map[key]
|
||||
return default
|
||||
|
||||
|
||||
def log(message):
|
||||
|
||||
util.SMlog('#### VMOPS %s ####' % message)
|
||||
|
||||
|
||||
@ -94,8 +121,8 @@ def retry(max_attempts, fn):
|
||||
|
||||
attempts = 1
|
||||
while attempts <= max_attempts:
|
||||
log("Attempting execution {0}/{1} of {2}".
|
||||
format(attempts, max_attempts, fn.__name__))
|
||||
log("Attempting execution " + str(attempts) + "/" + str(
|
||||
max_attempts) + " of " + fn.__name__)
|
||||
try:
|
||||
return fn()
|
||||
except:
|
||||
@ -106,15 +133,21 @@ def retry(max_attempts, fn):
|
||||
|
||||
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)
|
||||
while data != "":
|
||||
hasher.update(data)
|
||||
data = file.read(buffer_size)
|
||||
|
||||
return base64.encodestring(hasher.digest())[:-1]
|
||||
return base64.encodestring(hasher.digest())[:-1]
|
||||
|
||||
finally:
|
||||
|
||||
file.close()
|
||||
|
||||
|
||||
class S3Client(object):
|
||||
@ -146,10 +179,9 @@ class S3Client(object):
|
||||
max_error_retry, self.DEFAULT_MAX_ERROR_RETRY)
|
||||
|
||||
def build_canocialized_resource(self, bucket, key):
|
||||
return "/" + join([bucket, key], '/')
|
||||
|
||||
return '/{bucket}/{key}'.format(bucket=bucket, key=key)
|
||||
|
||||
def noop_send_body():
|
||||
def noop_send_body(connection):
|
||||
pass
|
||||
|
||||
def noop_read(response):
|
||||
@ -164,28 +196,41 @@ class S3Client(object):
|
||||
|
||||
uri = self.build_canocialized_resource(bucket, key)
|
||||
signature, request_date = self.sign_request(method, uri, headers)
|
||||
headers['Authorization'] = "AWS {0}:{1}".format(
|
||||
self.access_key, signature)
|
||||
headers['Authorization'] = "AWS " + self.access_key + ":" + signature
|
||||
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():
|
||||
print "method=", method, ", uri=", uri, ", headers=", headers,
|
||||
" endpoint=", self.end_point
|
||||
|
||||
connection.request(method, uri, fn_send_body(), headers)
|
||||
response = connection.getresponse()
|
||||
log("Sent {0} request to {1} {2} with headers {3}. \
|
||||
Got response status {4}: {5}".
|
||||
format(method, self.end_point, uri, headers,
|
||||
response.status, response.reason))
|
||||
return fn_read(response)
|
||||
connection = None
|
||||
if self.https_flag:
|
||||
connection = HTTPSConnection(self.end_point)
|
||||
else:
|
||||
connection = HTTPConnection(self.end_point)
|
||||
|
||||
try:
|
||||
return retry(self.max_error_retry, perform_request)
|
||||
finally:
|
||||
connection.close()
|
||||
try:
|
||||
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:
|
||||
connection.close()
|
||||
|
||||
return retry(self.max_error_retry, perform_request)
|
||||
|
||||
'''
|
||||
See http://bit.ly/MMC5de for more information regarding the creation of
|
||||
@ -205,7 +250,7 @@ class S3Client(object):
|
||||
|
||||
signature = base64.encodestring(
|
||||
hmac.new(self.secret_key, string_to_sign.encode('utf8'),
|
||||
hashlib.sha1).digest())[:-1]
|
||||
sha).digest())[:-1]
|
||||
|
||||
return signature, request_date
|
||||
|
||||
@ -217,8 +262,17 @@ class S3Client(object):
|
||||
self.HEADER_CONTENT_LENGTH: os.stat(src_filename).st_size,
|
||||
}
|
||||
|
||||
def send_body():
|
||||
return open(src_filename, 'rb')
|
||||
def send_body(connection):
|
||||
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)
|
||||
|
||||
@ -226,12 +280,18 @@ class S3Client(object):
|
||||
|
||||
def read(response):
|
||||
|
||||
with open(target_filename, 'wb') as file:
|
||||
file = open(target_filename, 'wb')
|
||||
|
||||
try:
|
||||
|
||||
while True:
|
||||
block = response.read(8192)
|
||||
if not block:
|
||||
break
|
||||
file.write(block)
|
||||
file.write(block)
|
||||
except:
|
||||
|
||||
file.close()
|
||||
|
||||
return self.do_operation('GET', bucket, key, fn_read=read)
|
||||
|
||||
@ -288,8 +348,8 @@ def s3(session, args):
|
||||
return 'true'
|
||||
|
||||
except:
|
||||
log("Operation {0} on file {1} from/in bucket {2} key {3}.".format(
|
||||
operation, filename, bucket, key))
|
||||
log("Operation " + operation + " on file " + filename +
|
||||
" from/in bucket " + bucket + " key " + key)
|
||||
log(traceback.format_exc())
|
||||
return 'false'
|
||||
|
||||
|
||||
@ -44,6 +44,7 @@ import com.cloud.agent.api.Command;
|
||||
import com.cloud.agent.api.MaintainCommand;
|
||||
import com.cloud.agent.api.MigrateCommand;
|
||||
import com.cloud.agent.api.PingTestCommand;
|
||||
import com.cloud.agent.api.PvlanSetupCommand;
|
||||
import com.cloud.agent.api.ReadyCommand;
|
||||
import com.cloud.agent.api.SetupCommand;
|
||||
import com.cloud.agent.api.ShutdownCommand;
|
||||
@ -109,7 +110,9 @@ public abstract class AgentAttache {
|
||||
protected AgentManagerImpl _agentMgr;
|
||||
|
||||
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 =
|
||||
new String[] { StartCommand.class.toString(), CreateCommand.class.toString() };
|
||||
static {
|
||||
|
||||
@ -111,8 +111,8 @@ public class VolumeJoinDaoImpl extends GenericDaoBase<VolumeJoinVO, Long> implem
|
||||
// com.cloud.storage.VolumeHostVO volumeHostRef =
|
||||
// ApiDBUtils.findVolumeHostRef(volume.getId(),
|
||||
// volume.getDataCenterId());
|
||||
volResponse.setSize(volume.getVolumeHostSize());
|
||||
volResponse.setCreated(volume.getVolumeHostCreated());
|
||||
volResponse.setSize(volume.getVolumeStoreSize());
|
||||
volResponse.setCreated(volume.getCreatedOnStore());
|
||||
|
||||
if (caller.getType() == Account.ACCOUNT_TYPE_ADMIN || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN)
|
||||
volResponse.setHypervisor(ApiDBUtils.getHypervisorTypeFromFormat(volume.getFormat()).toString());
|
||||
|
||||
@ -144,11 +144,11 @@ public class VolumeJoinVO extends BaseViewVO implements ControlledViewEntity {
|
||||
@Enumerated(value=EnumType.STRING)
|
||||
protected VirtualMachine.Type vmType;
|
||||
|
||||
@Column (name="volume_host_size")
|
||||
private long volumeHostSize;
|
||||
@Column(name = "volume_store_size")
|
||||
private long volumeStoreSize;
|
||||
|
||||
@Column(name="volume_host_created")
|
||||
private Date volumeHostCreated;
|
||||
@Column(name = "created_on_store")
|
||||
private Date createdOnStore;
|
||||
|
||||
@Column(name="format")
|
||||
private Storage.ImageFormat format;
|
||||
@ -625,32 +625,22 @@ public class VolumeJoinVO extends BaseViewVO implements ControlledViewEntity {
|
||||
this.vmType = vmType;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public long getVolumeHostSize() {
|
||||
return volumeHostSize;
|
||||
public long getVolumeStoreSize() {
|
||||
return volumeStoreSize;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setVolumeHostSize(long volumeHostSize) {
|
||||
this.volumeHostSize = volumeHostSize;
|
||||
public void setVolumeStoreSize(long volumeStoreSize) {
|
||||
this.volumeStoreSize = volumeStoreSize;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Date getVolumeHostCreated() {
|
||||
return volumeHostCreated;
|
||||
public Date getCreatedOnStore() {
|
||||
return createdOnStore;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setVolumeHostCreated(Date volumeHostCreated) {
|
||||
this.volumeHostCreated = volumeHostCreated;
|
||||
public void setCreatedOnStore(Date createdOnStore) {
|
||||
this.createdOnStore = createdOnStore;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Storage.ImageFormat getFormat() {
|
||||
return format;
|
||||
}
|
||||
|
||||
@ -1025,9 +1025,13 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
|
||||
}
|
||||
|
||||
try {
|
||||
return _itMgr.stop(proxy, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
|
||||
_itMgr.stop(proxy.getUuid());
|
||||
return true;
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
@ -1148,17 +1152,16 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
|
||||
ConsoleProxyVO proxy = _consoleProxyDao.findById(vmId);
|
||||
try {
|
||||
//expunge the vm
|
||||
boolean result = _itMgr.expunge(proxy, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
|
||||
if (result) {
|
||||
HostVO host = _hostDao.findByTypeNameAndZoneId(proxy.getDataCenterId(), proxy.getHostName(),
|
||||
Host.Type.ConsoleProxy);
|
||||
if (host != null) {
|
||||
s_logger.debug("Removing host entry for proxy id=" + vmId);
|
||||
result = result && _hostDao.remove(host.getId());
|
||||
}
|
||||
_itMgr.expunge(proxy.getUuid());
|
||||
_consoleProxyDao.remove(vmId);
|
||||
HostVO host = _hostDao.findByTypeNameAndZoneId(proxy.getDataCenterId(), proxy.getHostName(),
|
||||
Host.Type.ConsoleProxy);
|
||||
if (host != null) {
|
||||
s_logger.debug("Removing host entry for proxy id=" + vmId);
|
||||
return _hostDao.remove(host.getId());
|
||||
}
|
||||
|
||||
return result;
|
||||
return true;
|
||||
} catch (ResourceUnavailableException e) {
|
||||
s_logger.warn("Unable to expunge " + proxy, e);
|
||||
return false;
|
||||
|
||||
@ -27,4 +27,6 @@ public interface PlannerHostReservationDao extends GenericDao<PlannerHostReserva
|
||||
|
||||
List<PlannerHostReservationVO> listAllReservedHosts();
|
||||
|
||||
List<PlannerHostReservationVO> listAllDedicatedHosts();
|
||||
|
||||
}
|
||||
|
||||
@ -20,6 +20,8 @@ import java.util.List;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.ejb.Local;
|
||||
|
||||
import com.cloud.deploy.DeploymentPlanner.PlannerResourceUsage;
|
||||
import com.cloud.deploy.PlannerHostReservationVO;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
@ -31,6 +33,7 @@ public class PlannerHostReservationDaoImpl extends GenericDaoBase<PlannerHostRes
|
||||
|
||||
private SearchBuilder<PlannerHostReservationVO> _hostIdSearch;
|
||||
private SearchBuilder<PlannerHostReservationVO> _reservedHostSearch;
|
||||
private SearchBuilder<PlannerHostReservationVO> _dedicatedHostSearch;;
|
||||
|
||||
public PlannerHostReservationDaoImpl() {
|
||||
|
||||
@ -45,6 +48,10 @@ public class PlannerHostReservationDaoImpl extends GenericDaoBase<PlannerHostRes
|
||||
_reservedHostSearch = createSearchBuilder();
|
||||
_reservedHostSearch.and("usage", _reservedHostSearch.entity().getResourceUsage(), SearchCriteria.Op.NNULL);
|
||||
_reservedHostSearch.done();
|
||||
|
||||
_dedicatedHostSearch = createSearchBuilder();
|
||||
_dedicatedHostSearch.and("usage", _dedicatedHostSearch.entity().getResourceUsage(), SearchCriteria.Op.EQ);
|
||||
_dedicatedHostSearch.done();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -60,4 +67,10 @@ public class PlannerHostReservationDaoImpl extends GenericDaoBase<PlannerHostRes
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public List<PlannerHostReservationVO> listAllDedicatedHosts() {
|
||||
SearchCriteria<PlannerHostReservationVO> sc = _dedicatedHostSearch.create();
|
||||
sc.setParameters("usage", PlannerResourceUsage.Dedicated);
|
||||
return listBy(sc);
|
||||
}
|
||||
}
|
||||
@ -26,10 +26,10 @@ import com.cloud.agent.api.CheckVirtualMachineAnswer;
|
||||
import com.cloud.agent.api.CheckVirtualMachineCommand;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
|
||||
@Local(value=Investigator.class)
|
||||
@ -42,12 +42,12 @@ public class CheckOnAgentInvestigator extends AdapterBase implements Investigato
|
||||
}
|
||||
|
||||
@Override
|
||||
public Status isAgentAlive(HostVO agent) {
|
||||
public Status isAgentAlive(Host agent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isVmAlive(VMInstanceVO vm, HostVO host) {
|
||||
public Boolean isVmAlive(VirtualMachine vm, Host host) {
|
||||
CheckVirtualMachineCommand cmd = new CheckVirtualMachineCommand(vm.getInstanceName());
|
||||
try {
|
||||
CheckVirtualMachineAnswer answer = (CheckVirtualMachineAnswer)_agentMgr.send(vm.getHostId(), cmd);
|
||||
|
||||
@ -51,7 +51,6 @@ import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.InsufficientServerCapacityException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.exception.VirtualMachineMigrationException;
|
||||
import com.cloud.ha.dao.HighAvailabilityDao;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
@ -286,7 +285,7 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
|
||||
if (hostId == null) {
|
||||
try {
|
||||
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) {
|
||||
assert false : "How do we hit this when force is true?";
|
||||
throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
|
||||
@ -330,7 +329,7 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
|
||||
}
|
||||
|
||||
try {
|
||||
_itMgr.advanceStop(vm, true, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
|
||||
_itMgr.advanceStop(vm.getUuid(), true);
|
||||
} catch (ResourceUnavailableException e) {
|
||||
assert false : "How do we hit this when force is true?";
|
||||
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();
|
||||
|
||||
VMInstanceVO vm = _itMgr.findByIdAndType(work.getType(), work.getInstanceId());
|
||||
VirtualMachine vm = _itMgr.findById(work.getInstanceId());
|
||||
if (vm == null) {
|
||||
s_logger.info("Unable to find vm: " + vmId);
|
||||
return null;
|
||||
@ -475,7 +474,7 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
|
||||
}
|
||||
|
||||
try {
|
||||
_itMgr.advanceStop(vm, true, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
|
||||
_itMgr.advanceStop(vm.getUuid(), true);
|
||||
} catch (ResourceUnavailableException e) {
|
||||
assert false : "How do we hit this when force is true?";
|
||||
throw new CloudRuntimeException("Caught exception even though it should be handled.", e);
|
||||
@ -492,7 +491,7 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
|
||||
} else {
|
||||
s_logger.debug("How come that HA step is Investigating and the host is removed? Calling forced Stop on Vm anyways");
|
||||
try {
|
||||
_itMgr.advanceStop(vm, true, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
|
||||
_itMgr.advanceStop(vm.getUuid(), true);
|
||||
} catch (ResourceUnavailableException e) {
|
||||
assert false : "How do we hit this when force is true?";
|
||||
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 (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,
|
||||
"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.setPreviousState(vm.getState());
|
||||
return (System.currentTimeMillis() >> 10) + _restartRetryInterval;
|
||||
@ -573,20 +572,15 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
|
||||
try {
|
||||
work.setStep(Step.Migrating);
|
||||
_haDao.update(work.getId(), work);
|
||||
|
||||
VMInstanceVO vm = _instanceDao.findById(vmId);
|
||||
|
||||
if (!_itMgr.migrateAway(work.getType(), vmId, srcHostId)) {
|
||||
s_logger.warn("Unable to migrate vm from " + srcHostId);
|
||||
_resourceMgr.maintenanceFailed(srcHostId);
|
||||
}
|
||||
_itMgr.migrateAway(vm.getUuid(), srcHostId);
|
||||
return null;
|
||||
} catch (InsufficientServerCapacityException e) {
|
||||
s_logger.warn("Insufficient capacity for migrating a VM.");
|
||||
_resourceMgr.maintenanceFailed(srcHostId);
|
||||
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) {
|
||||
final VMInstanceVO vm = _itMgr.findByIdAndType(work.getType(), work.getInstanceId());
|
||||
final VirtualMachine vm = _itMgr.findById(work.getInstanceId());
|
||||
s_logger.info("Destroying " + vm.toString());
|
||||
try {
|
||||
if (vm.getState() != State.Destroyed) {
|
||||
@ -615,11 +609,9 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
|
||||
}
|
||||
|
||||
if (vm.getHostId() != null) {
|
||||
if (_itMgr.destroy(vm, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount())) {
|
||||
s_logger.info("Successfully destroy " + vm);
|
||||
return null;
|
||||
}
|
||||
s_logger.debug("Stop for " + vm + " was unsuccessful.");
|
||||
_itMgr.destroy(vm.getUuid());
|
||||
s_logger.info("Successfully destroy " + vm);
|
||||
return null;
|
||||
} else {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
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 {
|
||||
VMInstanceVO vm = _itMgr.findByIdAndType(work.getType(), work.getInstanceId());
|
||||
VirtualMachine vm = _itMgr.findById(work.getInstanceId());
|
||||
if (vm == null) {
|
||||
s_logger.info("No longer can find VM " + work.getInstanceId() + ". Throwing away " + work);
|
||||
work.setStep(Step.Done);
|
||||
@ -648,28 +640,25 @@ public class HighAvailabilityManagerImpl extends ManagerBase implements HighAvai
|
||||
s_logger.info("Stopping " + vm);
|
||||
try {
|
||||
if (work.getWorkType() == WorkType.Stop) {
|
||||
if (_itMgr.advanceStop(vm, false, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount())) {
|
||||
s_logger.info("Successfully stopped " + vm);
|
||||
return null;
|
||||
}
|
||||
_itMgr.advanceStop(vm.getUuid(), false);
|
||||
s_logger.info("Successfully stopped " + vm);
|
||||
return null;
|
||||
} else if (work.getWorkType() == WorkType.CheckStop) {
|
||||
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());
|
||||
return null;
|
||||
}
|
||||
if (_itMgr.advanceStop(vm, false, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount())) {
|
||||
s_logger.info("Stop for " + vm + " was successful");
|
||||
return null;
|
||||
}
|
||||
_itMgr.advanceStop(vm.getUuid(), false);
|
||||
s_logger.info("Stop for " + vm + " was successful");
|
||||
return null;
|
||||
} else if (work.getWorkType() == WorkType.ForceStop) {
|
||||
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());
|
||||
return null;
|
||||
}
|
||||
if (_itMgr.advanceStop(vm, true, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount())) {
|
||||
s_logger.info("Stop for " + vm + " was successful");
|
||||
return null;
|
||||
}
|
||||
_itMgr.advanceStop(vm.getUuid(), true);
|
||||
s_logger.info("Stop for " + vm + " was successful");
|
||||
return null;
|
||||
} else {
|
||||
assert false : "Who decided there's other steps but didn't modify the guy who does the work?";
|
||||
}
|
||||
|
||||
@ -17,7 +17,6 @@
|
||||
package com.cloud.ha;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.ejb.Local;
|
||||
@ -31,13 +30,14 @@ import com.cloud.agent.api.FenceAnswer;
|
||||
import com.cloud.agent.api.FenceCommand;
|
||||
import com.cloud.exception.AgentUnavailableException;
|
||||
import com.cloud.exception.OperationTimedoutException;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
@Local(value=FenceBuilder.class)
|
||||
public class KVMFencer extends AdapterBase implements FenceBuilder {
|
||||
@ -70,7 +70,7 @@ public class KVMFencer extends AdapterBase implements FenceBuilder {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean fenceOff(VMInstanceVO vm, HostVO host) {
|
||||
public Boolean fenceOff(VirtualMachine vm, Host host) {
|
||||
if (host.getHypervisorType() != HypervisorType.KVM) {
|
||||
s_logger.debug("Don't know how to fence non kvm hosts " + host.getHypervisorType());
|
||||
return null;
|
||||
|
||||
@ -25,13 +25,13 @@ import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.vm.Nic;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
@Local(value={Investigator.class})
|
||||
@ -39,13 +39,13 @@ public class ManagementIPSystemVMInvestigator extends AbstractInvestigatorImpl {
|
||||
private static final Logger s_logger = Logger.getLogger(ManagementIPSystemVMInvestigator.class);
|
||||
|
||||
private String _name = null;
|
||||
@Inject private HostDao _hostDao = null;
|
||||
@Inject private NetworkModel _networkMgr = null;
|
||||
@Inject private final HostDao _hostDao = null;
|
||||
@Inject private final NetworkModel _networkMgr = null;
|
||||
|
||||
|
||||
@Override
|
||||
public Boolean isVmAlive(VMInstanceVO vm, HostVO host) {
|
||||
if (!VirtualMachine.Type.isSystemVM(vm.getType())) {
|
||||
public Boolean isVmAlive(VirtualMachine vm, Host host) {
|
||||
if (!vm.getType().isUsedBySystem()) {
|
||||
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
|
||||
public Status isAgentAlive(HostVO agent) {
|
||||
public Status isAgentAlive(Host agent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -21,15 +21,15 @@ import java.util.List;
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
||||
import org.apache.log4j.Logger;
|
||||
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.dao.VolumeDao;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
@Component
|
||||
@ -44,7 +44,7 @@ public class RecreatableFencer extends AdapterBase implements FenceBuilder {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean fenceOff(VMInstanceVO vm, HostVO host) {
|
||||
public Boolean fenceOff(VirtualMachine vm, Host host) {
|
||||
VirtualMachine.Type type = vm.getType();
|
||||
if (type != VirtualMachine.Type.ConsoleProxy && type != VirtualMachine.Type.DomainRouter && type != VirtualMachine.Type.SecondaryStorageVm) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
|
||||
@ -29,7 +29,7 @@ import org.apache.log4j.Logger;
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.PingTestCommand;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.NetworkModel;
|
||||
@ -38,7 +38,6 @@ import com.cloud.network.router.VirtualRouter;
|
||||
import com.cloud.network.router.VpcVirtualNetworkApplianceManager;
|
||||
import com.cloud.vm.Nic;
|
||||
import com.cloud.vm.UserVmVO;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
|
||||
@ -53,7 +52,7 @@ public class UserVmDomRInvestigator extends AbstractInvestigatorImpl {
|
||||
@Inject private final VpcVirtualNetworkApplianceManager _vnaMgr = null;
|
||||
|
||||
@Override
|
||||
public Boolean isVmAlive(VMInstanceVO vm, HostVO host) {
|
||||
public Boolean isVmAlive(VirtualMachine vm, Host host) {
|
||||
if (vm.getType() != VirtualMachine.Type.User) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
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
|
||||
public Status isAgentAlive(HostVO agent) {
|
||||
public Status isAgentAlive(Host agent) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("checking if agent (" + agent.getId() + ") is alive");
|
||||
}
|
||||
@ -166,7 +165,7 @@ public class UserVmDomRInvestigator extends AbstractInvestigatorImpl {
|
||||
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 routerPrivateIp = router.getPrivateIpAddress();
|
||||
|
||||
|
||||
@ -23,17 +23,18 @@ import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.api.Answer;
|
||||
import com.cloud.agent.api.CheckOnHostAnswer;
|
||||
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.Status;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
|
||||
@Local(value=Investigator.class)
|
||||
public class XenServerInvestigator extends AdapterBase implements Investigator {
|
||||
@ -46,7 +47,7 @@ public class XenServerInvestigator extends AdapterBase implements Investigator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Status isAgentAlive(HostVO agent) {
|
||||
public Status isAgentAlive(Host agent) {
|
||||
if (agent.getHypervisorType() != HypervisorType.XenServer) {
|
||||
return null;
|
||||
}
|
||||
@ -72,7 +73,7 @@ public class XenServerInvestigator extends AdapterBase implements Investigator {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isVmAlive(VMInstanceVO vm, HostVO host) {
|
||||
public Boolean isVmAlive(VirtualMachine vm, Host host) {
|
||||
Status status = isAgentAlive(host);
|
||||
if (status == null) {
|
||||
return null;
|
||||
|
||||
@ -421,12 +421,9 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
|
||||
|
||||
_accountMgr.checkAccess(caller, null, true, router);
|
||||
|
||||
boolean result = _itMgr.expunge(router, _accountMgr.getActiveUser(callerUserId), _accountMgr.getAccount(router.getAccountId()));
|
||||
|
||||
if (result) {
|
||||
return router;
|
||||
}
|
||||
return null;
|
||||
_itMgr.expunge(router.getUuid());
|
||||
_routerDao.remove(router.getId());
|
||||
return router;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -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 {
|
||||
s_logger.debug("Stopping router " + router);
|
||||
try {
|
||||
if (_itMgr.advanceStop((DomainRouterVO) router, forced, user, caller)) {
|
||||
return _routerDao.findById(router.getId());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
_itMgr.advanceStop(router.getUuid(), forced);
|
||||
return _routerDao.findById(router.getId());
|
||||
} catch (OperationTimedoutException e) {
|
||||
throw new CloudRuntimeException("Unable to stop " + router, e);
|
||||
}
|
||||
|
||||
@ -2043,8 +2043,6 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
||||
s_logger.debug("Deleting Host: " + host.getId() + " Guid:" + host.getGuid());
|
||||
}
|
||||
|
||||
User caller = _accountMgr.getActiveUser(CallContext.current().getCallingUserId());
|
||||
|
||||
if (forceDestroyStorage) {
|
||||
// put local storage into mainenance mode, will set all the VMs on
|
||||
// this local storage into stopped state
|
||||
@ -2067,11 +2065,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
||||
List<VMInstanceVO> vmsOnLocalStorage = _storageMgr.listByStoragePool(storagePool.getId());
|
||||
for (VMInstanceVO vm : vmsOnLocalStorage) {
|
||||
try {
|
||||
if (!_vmMgr.destroy(vm, caller, _accountMgr.getAccount(vm.getAccountId()))) {
|
||||
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);
|
||||
}
|
||||
_vmMgr.destroy(vm.getUuid());
|
||||
} catch (Exception e) {
|
||||
String errorMsg = "There was an error Destory the vm: " + vm + " as a part of hostDelete id=" + host.getId();
|
||||
s_logger.debug(errorMsg, e);
|
||||
@ -2090,11 +2084,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
|
||||
if (!vm.isHaEnabled() || vm.getState() == State.Stopping) {
|
||||
s_logger.debug("Stopping vm: " + vm + " as a part of deleteHost id=" + host.getId());
|
||||
try {
|
||||
if (!_vmMgr.advanceStop(vm, true, caller, _accountMgr.getAccount(vm.getAccountId()))) {
|
||||
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);
|
||||
}
|
||||
_vmMgr.advanceStop(vm.getUuid(), false);
|
||||
} catch (Exception e) {
|
||||
String errorMsg = "There was an error stopping the vm: " + vm + " as a part of hostDelete id=" + host.getId();
|
||||
s_logger.debug(errorMsg, e);
|
||||
|
||||
@ -1299,8 +1299,8 @@ public class ConfigurationServerImpl extends ManagerBase implements Configuratio
|
||||
@DB
|
||||
public void updateResourceCount() {
|
||||
ResourceType[] resourceTypes = Resource.ResourceType.values();
|
||||
List<AccountVO> accounts = _accountDao.listAllIncludingRemoved();
|
||||
List<DomainVO> domains = _domainDao.listAllIncludingRemoved();
|
||||
List<AccountVO> accounts = _accountDao.listAll();
|
||||
List<DomainVO> domains = _domainDao.listAll();
|
||||
List<ResourceCountVO> domainResourceCount = _resourceCountDao.listResourceCountByOwnerType(ResourceOwnerType.Domain);
|
||||
List<ResourceCountVO> accountResourceCount = _resourceCountDao.listResourceCountByOwnerType(ResourceOwnerType.Account);
|
||||
|
||||
|
||||
@ -39,23 +39,15 @@ import javax.crypto.spec.SecretKeySpec;
|
||||
import javax.inject.Inject;
|
||||
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.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.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.DeleteAccountCmd;
|
||||
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.UpdateClusterCmd;
|
||||
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.UpdateCfgCmd;
|
||||
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.ListPodsByCmd;
|
||||
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.CleanVMReservationsCmd;
|
||||
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.PreparePrimaryStorageForMaintenanceCmd;
|
||||
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.usage.AddTrafficMonitorCmd;
|
||||
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.DeleteGlobalLoadBalancerRuleCmd;
|
||||
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.UpdateGlobalLoadBalancerRuleCmd;
|
||||
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.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.ListVMSnapshotCmd;
|
||||
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.CreateVPCCmd;
|
||||
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.UpdateVpnCustomerGatewayCmd;
|
||||
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.StoragePoolAllocator;
|
||||
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.dao.DomainDao;
|
||||
import com.cloud.event.ActionEvent;
|
||||
import com.cloud.event.ActionEventUtils;
|
||||
import com.cloud.event.EventTypes;
|
||||
import com.cloud.event.EventVO;
|
||||
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.host.DetailVO;
|
||||
import com.cloud.host.Host;
|
||||
@ -491,9 +518,9 @@ import com.cloud.storage.GuestOSCategoryVO;
|
||||
import com.cloud.storage.GuestOSVO;
|
||||
import com.cloud.storage.GuestOsCategory;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.Storage.TemplateType;
|
||||
import com.cloud.storage.StorageManager;
|
||||
import com.cloud.storage.StoragePool;
|
||||
import com.cloud.storage.Storage.TemplateType;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.Volume;
|
||||
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.NetUtils;
|
||||
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.VirtualMachineManager;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
import com.cloud.vm.VirtualMachineProfileImpl;
|
||||
import com.cloud.vm.dao.ConsoleProxyDao;
|
||||
import com.cloud.vm.dao.DomainRouterDao;
|
||||
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.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 static final Logger s_logger = Logger.getLogger(ManagementServerImpl.class.getName());
|
||||
@ -725,7 +757,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
||||
return _affinityProcessors;
|
||||
}
|
||||
public void setAffinityGroupProcessors(List<AffinityGroupProcessor> affinityProcessors) {
|
||||
this._affinityProcessors = affinityProcessors;
|
||||
_affinityProcessors = affinityProcessors;
|
||||
}
|
||||
|
||||
public ManagementServerImpl() {
|
||||
@ -1272,7 +1304,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
||||
storagePools.remove(srcVolumePool);
|
||||
for (StoragePoolVO pool : storagePools) {
|
||||
if (pool.isShared()) {
|
||||
allPools.add((StoragePool)this.dataStoreMgr.getPrimaryDataStore(pool.getId()));
|
||||
allPools.add((StoragePool)dataStoreMgr.getPrimaryDataStore(pool.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -2060,12 +2092,8 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
||||
private ConsoleProxyVO stopConsoleProxy(VMInstanceVO systemVm, boolean isForced) throws ResourceUnavailableException, OperationTimedoutException,
|
||||
ConcurrentOperationException {
|
||||
|
||||
User caller = _userDao.findById(CallContext.current().getCallingUserId());
|
||||
|
||||
if (_itMgr.advanceStop(systemVm, isForced, caller, CallContext.current().getCallingAccount())) {
|
||||
return _consoleProxyDao.findById(systemVm.getId());
|
||||
}
|
||||
return null;
|
||||
_itMgr.advanceStop(systemVm.getUuid(), isForced);
|
||||
return _consoleProxyDao.findById(systemVm.getId());
|
||||
}
|
||||
|
||||
@ActionEvent(eventType = EventTypes.EVENT_PROXY_REBOOT, eventDescription = "rebooting console proxy Vm", async = true)
|
||||
@ -2949,12 +2977,8 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
|
||||
private SecondaryStorageVmVO stopSecondaryStorageVm(VMInstanceVO systemVm, boolean isForced) throws ResourceUnavailableException,
|
||||
OperationTimedoutException, ConcurrentOperationException {
|
||||
|
||||
User caller = _userDao.findById(CallContext.current().getCallingUserId());
|
||||
|
||||
if (_itMgr.advanceStop(systemVm, isForced, caller, CallContext.current().getCallingAccount())) {
|
||||
return _secStorageVmDao.findById(systemVm.getId());
|
||||
}
|
||||
return null;
|
||||
_itMgr.advanceStop(systemVm.getUuid(), isForced);
|
||||
return _secStorageVmDao.findById(systemVm.getId());
|
||||
}
|
||||
|
||||
@ActionEvent(eventType = EventTypes.EVENT_SSVM_REBOOT, eventDescription = "rebooting secondary storage Vm", async = true)
|
||||
|
||||
@ -35,12 +35,16 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.cloudstack.api.IdentityService;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
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.host.HostVO;
|
||||
import com.cloud.server.ManagementServer;
|
||||
@ -51,12 +55,10 @@ import com.cloud.user.User;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.Ternary;
|
||||
import com.cloud.utils.db.EntityManager;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
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
|
||||
@ -74,10 +76,12 @@ public class ConsoleProxyServlet extends HttpServlet {
|
||||
@Inject VirtualMachineManager _vmMgr;
|
||||
@Inject ManagementServer _ms;
|
||||
@Inject IdentityService _identityService;
|
||||
@Inject
|
||||
EntityManager _entityMgr;
|
||||
|
||||
static ManagementServer s_ms;
|
||||
|
||||
private Gson _gson = new GsonBuilder().create();
|
||||
private final Gson _gson = new GsonBuilder().create();
|
||||
|
||||
public ConsoleProxyServlet() {
|
||||
}
|
||||
@ -179,7 +183,7 @@ public class ConsoleProxyServlet extends HttpServlet {
|
||||
}
|
||||
|
||||
private void handleThumbnailRequest(HttpServletRequest req, HttpServletResponse resp, long vmId) {
|
||||
VMInstanceVO vm = _vmMgr.findById(vmId);
|
||||
VirtualMachine vm = _vmMgr.findById(vmId);
|
||||
if(vm == null) {
|
||||
s_logger.warn("VM " + vmId + " does not exist, sending blank response for thumbnail request");
|
||||
sendResponse(resp, "");
|
||||
@ -230,7 +234,7 @@ public class ConsoleProxyServlet extends HttpServlet {
|
||||
}
|
||||
|
||||
private void handleAccessRequest(HttpServletRequest req, HttpServletResponse resp, long vmId) {
|
||||
VMInstanceVO vm = _vmMgr.findById(vmId);
|
||||
VirtualMachine vm = _vmMgr.findById(vmId);
|
||||
if(vm == null) {
|
||||
s_logger.warn("VM " + vmId + " does not exist, sending blank response for console access request");
|
||||
sendResponse(resp, "");
|
||||
@ -258,7 +262,7 @@ public class ConsoleProxyServlet extends HttpServlet {
|
||||
|
||||
String vmName = vm.getHostName();
|
||||
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();
|
||||
if(displayName != null && !displayName.isEmpty() && !displayName.equals(vmName)) {
|
||||
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,
|
||||
// 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) {
|
||||
s_logger.warn("VM " + vmId + " does not exist, sending failed response for authentication request from console proxy");
|
||||
sendResponse(resp, "failed");
|
||||
@ -339,7 +343,7 @@ public class ConsoleProxyServlet extends HttpServlet {
|
||||
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);
|
||||
|
||||
String host = hostVo.getPrivateIpAddress();
|
||||
@ -374,7 +378,7 @@ public class ConsoleProxyServlet extends HttpServlet {
|
||||
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);
|
||||
String host = hostVo.getPrivateIpAddress();
|
||||
|
||||
@ -454,7 +458,7 @@ public class ConsoleProxyServlet extends HttpServlet {
|
||||
|
||||
private boolean checkSessionPermision(HttpServletRequest req, long vmId, Account accountObj) {
|
||||
|
||||
VMInstanceVO vm = _vmMgr.findById(vmId);
|
||||
VirtualMachine vm = _vmMgr.findById(vmId);
|
||||
if(vm == null) {
|
||||
s_logger.debug("Console/thumbnail access denied. VM " + vmId + " does not exist in system any more");
|
||||
return false;
|
||||
|
||||
@ -234,19 +234,11 @@ public class StoragePoolAutomationImpl implements StoragePoolAutomation {
|
||||
if (vmInstance.getType().equals(
|
||||
VirtualMachine.Type.ConsoleProxy)) {
|
||||
// call the consoleproxymanager
|
||||
ConsoleProxyVO consoleProxy = _consoleProxyDao
|
||||
.findById(vmInstance.getId());
|
||||
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
|
||||
work.setStoppedForMaintenance(true);
|
||||
_storagePoolWorkDao.update(work.getId(), work);
|
||||
}
|
||||
ConsoleProxyVO consoleProxy = _consoleProxyDao.findById(vmInstance.getId());
|
||||
vmMgr.advanceStop(consoleProxy.getUuid(), false);
|
||||
// update work status
|
||||
work.setStoppedForMaintenance(true);
|
||||
_storagePoolWorkDao.update(work.getId(), work);
|
||||
|
||||
if (restart) {
|
||||
|
||||
@ -260,36 +252,21 @@ public class StoragePoolAutomationImpl implements StoragePoolAutomation {
|
||||
// if the instance is of type uservm, call the user vm manager
|
||||
if (vmInstance.getType() == VirtualMachine.Type.User) {
|
||||
UserVmVO userVm = userVmDao.findById(vmInstance.getId());
|
||||
if (!vmMgr.advanceStop(userVm, true, user, account)) {
|
||||
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
|
||||
work.setStoppedForMaintenance(true);
|
||||
_storagePoolWorkDao.update(work.getId(), work);
|
||||
}
|
||||
vmMgr.advanceStop(userVm.getUuid(), false);
|
||||
// update work status
|
||||
work.setStoppedForMaintenance(true);
|
||||
_storagePoolWorkDao.update(work.getId(), work);
|
||||
}
|
||||
|
||||
// if the instance is of type secondary storage vm, call the
|
||||
// secondary storage vm manager
|
||||
if (vmInstance.getType().equals(
|
||||
VirtualMachine.Type.SecondaryStorageVm)) {
|
||||
SecondaryStorageVmVO secStrgVm = _secStrgDao
|
||||
.findById(vmInstance.getId());
|
||||
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
|
||||
work.setStoppedForMaintenance(true);
|
||||
_storagePoolWorkDao.update(work.getId(), work);
|
||||
}
|
||||
SecondaryStorageVmVO secStrgVm = _secStrgDao.findById(vmInstance.getId());
|
||||
vmMgr.advanceStop(secStrgVm.getUuid(), false);
|
||||
// update work status
|
||||
work.setStoppedForMaintenance(true);
|
||||
_storagePoolWorkDao.update(work.getId(), work);
|
||||
|
||||
if (restart) {
|
||||
vmMgr.advanceStart(secStrgVm.getUuid(), null);
|
||||
@ -304,17 +281,10 @@ public class StoragePoolAutomationImpl implements StoragePoolAutomation {
|
||||
if (vmInstance.getType().equals(
|
||||
VirtualMachine.Type.DomainRouter)) {
|
||||
DomainRouterVO domR = _domrDao.findById(vmInstance.getId());
|
||||
if (!vmMgr.advanceStop(domR, true, user, account)) {
|
||||
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
|
||||
work.setStoppedForMaintenance(true);
|
||||
_storagePoolWorkDao.update(work.getId(), work);
|
||||
}
|
||||
vmMgr.advanceStop(domR.getUuid(), false);
|
||||
// update work status
|
||||
work.setStoppedForMaintenance(true);
|
||||
_storagePoolWorkDao.update(work.getId(), work);
|
||||
|
||||
if (restart) {
|
||||
vmMgr.advanceStart(domR.getUuid(), null);
|
||||
|
||||
@ -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.UploadVolumeCmd;
|
||||
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.deploy.DeployDestination;
|
||||
@ -41,6 +40,7 @@ import com.cloud.storage.Volume.Type;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.vm.DiskProfile;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
|
||||
public interface VolumeManager extends VolumeApiService {
|
||||
@ -91,8 +91,8 @@ public interface VolumeManager extends VolumeApiService {
|
||||
@Override
|
||||
Volume migrateVolume(MigrateVolumeCmd cmd);
|
||||
|
||||
<T extends VMInstanceVO> void migrateVolumes(T vm, VirtualMachineTO vmTo, Host srcHost, Host destHost,
|
||||
Map<VolumeVO, StoragePoolVO> volumeToPool);
|
||||
void migrateVolumes(VirtualMachine vm, VirtualMachineTO vmTo, Host srcHost, Host destHost,
|
||||
Map<Volume, StoragePool> volumeToPool);
|
||||
|
||||
boolean storageMigration(VirtualMachineProfile vm, StoragePool destPool);
|
||||
|
||||
|
||||
@ -351,7 +351,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
|
||||
public VolumeInfo moveVolume(VolumeInfo volume, long destPoolDcId,
|
||||
Long destPoolPodId, Long destPoolClusterId,
|
||||
HypervisorType dataDiskHyperType)
|
||||
throws ConcurrentOperationException {
|
||||
throws ConcurrentOperationException {
|
||||
|
||||
// Find a destination storage pool with the specified criteria
|
||||
DiskOfferingVO diskOffering = _diskOfferingDao.findById(volume
|
||||
@ -413,7 +413,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
|
||||
|
||||
private boolean validateVolume(Account caller, long ownerId, Long zoneId,
|
||||
String volumeName, String url, String format)
|
||||
throws ResourceAllocationException {
|
||||
throws ResourceAllocationException {
|
||||
|
||||
// permission check
|
||||
_accountMgr.checkAccess(caller, null, true,
|
||||
@ -482,17 +482,17 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
|
||||
&& !url.toLowerCase().endsWith("qcow2.zip")
|
||||
&& !url.toLowerCase().endsWith("qcow2.bz2") && !url
|
||||
.toLowerCase().endsWith("qcow2.gz")))
|
||||
|| (format.equalsIgnoreCase("ova") && (!url.toLowerCase()
|
||||
.endsWith(".ova")
|
||||
&& !url.toLowerCase().endsWith("ova.zip")
|
||||
&& !url.toLowerCase().endsWith("ova.bz2") && !url
|
||||
.toLowerCase().endsWith("ova.gz")))
|
||||
|| (format.equalsIgnoreCase("raw") && (!url.toLowerCase()
|
||||
.endsWith(".img") && !url.toLowerCase().endsWith("raw")))) {
|
||||
|| (format.equalsIgnoreCase("ova") && (!url.toLowerCase()
|
||||
.endsWith(".ova")
|
||||
&& !url.toLowerCase().endsWith("ova.zip")
|
||||
&& !url.toLowerCase().endsWith("ova.bz2") && !url
|
||||
.toLowerCase().endsWith("ova.gz")))
|
||||
|| (format.equalsIgnoreCase("raw") && (!url.toLowerCase()
|
||||
.endsWith(".img") && !url.toLowerCase().endsWith("raw")))) {
|
||||
throw new InvalidParameterValueException(
|
||||
"Please specify a valid URL. URL:" + url
|
||||
+ " is an invalid for the format "
|
||||
+ format.toLowerCase());
|
||||
+ " is an invalid for the format "
|
||||
+ format.toLowerCase());
|
||||
}
|
||||
UriUtils.validateUrl(url);
|
||||
|
||||
@ -907,26 +907,26 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
|
||||
|
||||
if (isCustomizedIops != null) {
|
||||
if (isCustomizedIops) {
|
||||
minIops = cmd.getMinIops();
|
||||
maxIops = cmd.getMaxIops();
|
||||
minIops = cmd.getMinIops();
|
||||
maxIops = cmd.getMaxIops();
|
||||
|
||||
if (minIops == null && maxIops == null) {
|
||||
minIops = 0L;
|
||||
maxIops = 0L;
|
||||
}
|
||||
else {
|
||||
if (minIops == null && maxIops == null) {
|
||||
minIops = 0L;
|
||||
maxIops = 0L;
|
||||
}
|
||||
else {
|
||||
if (minIops == null || minIops <= 0) {
|
||||
throw new InvalidParameterValueException("The min IOPS must be greater than 0.");
|
||||
}
|
||||
|
||||
if (maxIops == null) {
|
||||
maxIops = 0L;
|
||||
}
|
||||
if (maxIops == null) {
|
||||
maxIops = 0L;
|
||||
}
|
||||
|
||||
if (minIops > maxIops) {
|
||||
throw new InvalidParameterValueException("The min IOPS must be less than or equal to the max IOPS.");
|
||||
}
|
||||
}
|
||||
if (minIops > maxIops) {
|
||||
throw new InvalidParameterValueException("The min IOPS must be less than or equal to the max IOPS.");
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
minIops = diskOffering.getMinIops();
|
||||
@ -935,10 +935,10 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
|
||||
}
|
||||
|
||||
if (!validateVolumeSizeRange(size)) {// convert size from mb to gb
|
||||
// for validation
|
||||
// for validation
|
||||
throw new InvalidParameterValueException(
|
||||
"Invalid size for custom volume creation: " + size
|
||||
+ " ,max volume size is:" + _maxVolumeSizeInGb);
|
||||
+ " ,max volume size is:" + _maxVolumeSizeInGb);
|
||||
}
|
||||
} else { // create volume from snapshot
|
||||
Long snapshotId = cmd.getSnapshotId();
|
||||
@ -959,7 +959,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
|
||||
diskOffering = _diskOfferingDao.findById(diskOfferingId);
|
||||
zoneId = snapshotCheck.getDataCenterId();
|
||||
size = snapshotCheck.getSize(); // ; disk offering is used for tags
|
||||
// purposes
|
||||
// purposes
|
||||
|
||||
// check snapshot permissions
|
||||
_accountMgr.checkAccess(caller, null, true, snapshotCheck);
|
||||
@ -1313,7 +1313,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
|
||||
|
||||
_accountMgr.checkAccess(caller, null, true, volume);
|
||||
|
||||
if (volume.getInstanceId() != null) {
|
||||
if (volume.getInstanceId() != null) {
|
||||
throw new InvalidParameterValueException(
|
||||
"Please specify a volume that is not attached to any VM.");
|
||||
}
|
||||
@ -1357,9 +1357,20 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
|
||||
_usageEventDao.persist(usageEvent);
|
||||
}
|
||||
}
|
||||
AsyncCallFuture<VolumeApiResult> future = volService.expungeVolumeAsync(volFactory.getVolume(volume.getId()));
|
||||
future.get();
|
||||
|
||||
// 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();
|
||||
}
|
||||
// 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) {
|
||||
s_logger.warn("Failed to expunge volume:", e);
|
||||
return false;
|
||||
@ -1646,7 +1657,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
|
||||
volumeToAttach = _volsDao.findById(volumeToAttach.getId());
|
||||
|
||||
if (volumeToAttachStoragePool.isManaged() &&
|
||||
volumeToAttach.getPath() == null) {
|
||||
volumeToAttach.getPath() == null) {
|
||||
volumeToAttach.setPath(answer.getDisk().getVdiUuid());
|
||||
|
||||
_volsDao.update(volumeToAttach.getId(), volumeToAttach);
|
||||
@ -1658,8 +1669,8 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
|
||||
// insert record for disk I/O statistics
|
||||
VmDiskStatisticsVO diskstats = _vmDiskStatsDao.findBy(vm.getAccountId(), vm.getDataCenterId(),vm.getId(), volumeToAttach.getId());
|
||||
if (diskstats == null) {
|
||||
diskstats = new VmDiskStatisticsVO(vm.getAccountId(), vm.getDataCenterId(),vm.getId(), volumeToAttach.getId());
|
||||
_vmDiskStatsDao.persist(diskstats);
|
||||
diskstats = new VmDiskStatisticsVO(vm.getAccountId(), vm.getDataCenterId(),vm.getId(), volumeToAttach.getId());
|
||||
_vmDiskStatsDao.persist(diskstats);
|
||||
}
|
||||
|
||||
return _volsDao.findById(volumeToAttach.getId());
|
||||
@ -2032,7 +2043,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
|
||||
@DB
|
||||
protected VolumeVO switchVolume(VolumeVO existingVolume,
|
||||
VirtualMachineProfile vm)
|
||||
throws StorageUnavailableException {
|
||||
throws StorageUnavailableException {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
|
||||
Long templateIdToUse = null;
|
||||
@ -2087,10 +2098,14 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
|
||||
txn.start();
|
||||
for (VolumeVO vol : volumesForVm) {
|
||||
if (vol.getVolumeType().equals(Type.ROOT)) {
|
||||
// This check is for VM in Error state (volume is already
|
||||
// destroyed)
|
||||
if (!vol.getState().equals(Volume.State.Destroy)) {
|
||||
// Destroy volume if not already destroyed
|
||||
boolean volumeAlreadyDestroyed = (vol.getState() == Volume.State.Destroy ||
|
||||
vol.getState() == Volume.State.Expunged ||
|
||||
vol.getState() == Volume.State.Expunging);
|
||||
if (!volumeAlreadyDestroyed) {
|
||||
volService.destroyVolume(vol.getId());
|
||||
} else {
|
||||
s_logger.debug("Skipping destroy for the volume " + vol + " as its in state " + vol.getState().toString());
|
||||
}
|
||||
toBeExpunged.add(vol);
|
||||
} else {
|
||||
@ -2228,15 +2243,15 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> void migrateVolumes(T vm, VirtualMachineTO vmTo, Host srcHost, Host destHost,
|
||||
Map<VolumeVO, StoragePoolVO> volumeToPool) {
|
||||
public void migrateVolumes(VirtualMachine vm, VirtualMachineTO vmTo, Host srcHost, Host destHost,
|
||||
Map<Volume, StoragePool> volumeToPool) {
|
||||
// Check if all the vms being migrated belong to the vm.
|
||||
// Check if the storage pool is of the right type.
|
||||
// Create a VolumeInfo to DataStore map too.
|
||||
Map<VolumeInfo, DataStore> volumeMap = new HashMap<VolumeInfo, DataStore>();
|
||||
for (Map.Entry<VolumeVO, StoragePoolVO> entry : volumeToPool.entrySet()) {
|
||||
VolumeVO volume = entry.getKey();
|
||||
StoragePoolVO storagePool = entry.getValue();
|
||||
for (Map.Entry<Volume, StoragePool> entry : volumeToPool.entrySet()) {
|
||||
Volume volume = entry.getKey();
|
||||
StoragePool storagePool = entry.getValue();
|
||||
StoragePool destPool = (StoragePool)dataStoreMgr.getDataStore(storagePool.getId(),
|
||||
DataStoreRole.Primary);
|
||||
|
||||
@ -2320,13 +2335,10 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
|
||||
vm.addDisk(disk);
|
||||
}
|
||||
|
||||
if (vm.getType() == VirtualMachine.Type.User) {
|
||||
UserVmVO userVM = (UserVmVO) vm.getVirtualMachine();
|
||||
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);
|
||||
vm.addDisk(iso);
|
||||
}
|
||||
if (vm.getType() == VirtualMachine.Type.User && vm.getTemplate().getFormat() == ImageFormat.ISO) {
|
||||
DataTO dataTO = tmplFactory.getTemplate(vm.getTemplate().getId(), DataStoreRole.Image, vm.getVirtualMachine().getDataCenterId()).getTO();
|
||||
DiskTO iso = new DiskTO(dataTO, 3L, null, Volume.Type.ISO);
|
||||
vm.addDisk(iso);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2338,14 +2350,14 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
|
||||
MIGRATE
|
||||
}
|
||||
private static class VolumeTask {
|
||||
final VolumeTaskType type;
|
||||
final StoragePoolVO pool;
|
||||
final VolumeVO volume;
|
||||
VolumeTask(VolumeTaskType type, VolumeVO volume, StoragePoolVO pool) {
|
||||
this.type = type;
|
||||
this.pool = pool;
|
||||
this.volume = volume;
|
||||
}
|
||||
final VolumeTaskType type;
|
||||
final StoragePoolVO pool;
|
||||
final VolumeVO volume;
|
||||
VolumeTask(VolumeTaskType type, VolumeVO volume, StoragePoolVO pool) {
|
||||
this.type = type;
|
||||
this.pool = pool;
|
||||
this.volume = volume;
|
||||
}
|
||||
}
|
||||
|
||||
private List<VolumeTask> getTasks(List<VolumeVO> vols, Map<Volume, StoragePool> destVols) throws StorageUnavailableException {
|
||||
@ -2446,7 +2458,7 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
|
||||
DataStore destPool = null;
|
||||
if (recreate
|
||||
&& (dest.getStorageForDisks() == null || dest
|
||||
.getStorageForDisks().get(vol) == null)) {
|
||||
.getStorageForDisks().get(vol) == null)) {
|
||||
destPool = dataStoreMgr.getDataStore(vol.getPoolId(), DataStoreRole.Primary);
|
||||
s_logger.debug("existing pool: " + destPool.getId());
|
||||
} else {
|
||||
@ -2603,8 +2615,8 @@ public class VolumeManagerImpl extends ManagerBase implements VolumeManager {
|
||||
.getValue(Config.CustomDiskOfferingMinSize.toString());
|
||||
_customDiskOfferingMinSize = NumbersUtil.parseInt(
|
||||
_customDiskOfferingMinSizeStr, Integer
|
||||
.parseInt(Config.CustomDiskOfferingMinSize
|
||||
.getDefaultValue()));
|
||||
.parseInt(Config.CustomDiskOfferingMinSize
|
||||
.getDefaultValue()));
|
||||
|
||||
String maxVolumeSizeInGbString = _configDao
|
||||
.getValue("storage.max.volume.size");
|
||||
|
||||
@ -905,11 +905,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
|
||||
try {
|
||||
if (secStorageVmLock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_SYNC)) {
|
||||
try {
|
||||
boolean result = _itMgr.stop(secStorageVm, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
|
||||
if (result) {
|
||||
}
|
||||
|
||||
return result;
|
||||
_itMgr.stop(secStorageVm.getUuid());
|
||||
return true;
|
||||
} finally {
|
||||
secStorageVmLock.unlock();
|
||||
}
|
||||
@ -971,17 +968,16 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
|
||||
SecondaryStorageVmVO ssvm = _secStorageVmDao.findById(vmId);
|
||||
|
||||
try {
|
||||
boolean result = _itMgr.expunge(ssvm, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
|
||||
if (result) {
|
||||
HostVO host = _hostDao.findByTypeNameAndZoneId(ssvm.getDataCenterId(), ssvm.getHostName(),
|
||||
Host.Type.SecondaryStorageVM);
|
||||
if (host != null) {
|
||||
s_logger.debug("Removing host entry for ssvm id=" + vmId);
|
||||
result = result && _hostDao.remove(host.getId());
|
||||
}
|
||||
_itMgr.expunge(ssvm.getUuid());
|
||||
_secStorageVmDao.remove(ssvm.getId());
|
||||
HostVO host = _hostDao.findByTypeNameAndZoneId(ssvm.getDataCenterId(), ssvm.getHostName(),
|
||||
Host.Type.SecondaryStorageVM);
|
||||
if (host != null) {
|
||||
s_logger.debug("Removing host entry for ssvm id=" + vmId);
|
||||
_hostDao.remove(host.getId());
|
||||
}
|
||||
|
||||
return result;
|
||||
return true;
|
||||
} catch (ResourceUnavailableException e) {
|
||||
s_logger.warn("Unable to expunge " + ssvm, e);
|
||||
return false;
|
||||
|
||||
@ -26,9 +26,6 @@ import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
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.DeleteSnapshotPoliciesCmd;
|
||||
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.SnapshotDataStoreDao;
|
||||
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.api.Answer;
|
||||
@ -80,6 +80,7 @@ import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.server.ResourceTag.TaggedResourceType;
|
||||
import com.cloud.storage.CreateSnapshotPayload;
|
||||
import com.cloud.storage.DataStoreRole;
|
||||
import com.cloud.storage.ScopeType;
|
||||
import com.cloud.storage.Snapshot;
|
||||
import com.cloud.storage.Snapshot.Type;
|
||||
import com.cloud.storage.SnapshotPolicyVO;
|
||||
@ -1145,7 +1146,14 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
|
||||
}
|
||||
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,
|
||||
(short) snapshotType.ordinal(), snapshotType.name(), volume.getSize(), hypervisorType);
|
||||
|
||||
|
||||
@ -608,7 +608,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
||||
@Override
|
||||
@DB
|
||||
public boolean copy(long userId, VMTemplateVO template, DataStore srcSecStore, DataCenterVO dstZone) throws StorageUnavailableException,
|
||||
ResourceAllocationException {
|
||||
ResourceAllocationException {
|
||||
long tmpltId = template.getId();
|
||||
long dstZoneId = dstZone.getId();
|
||||
// find all eligible image stores for the destination zone
|
||||
@ -910,7 +910,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
||||
}
|
||||
|
||||
boolean result = attachISOToVM(vmId, userId, isoId, false); // attach=false
|
||||
// => detach
|
||||
// => detach
|
||||
if (result) {
|
||||
return result;
|
||||
} else {
|
||||
@ -1253,14 +1253,14 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
||||
}
|
||||
|
||||
if (isExtractable != null && caller.getType() == Account.ACCOUNT_TYPE_ADMIN) {// Only
|
||||
// ROOT
|
||||
// admins
|
||||
// allowed
|
||||
// to
|
||||
// change
|
||||
// this
|
||||
// powerful
|
||||
// attribute
|
||||
// ROOT
|
||||
// admins
|
||||
// allowed
|
||||
// to
|
||||
// change
|
||||
// this
|
||||
// powerful
|
||||
// attribute
|
||||
updatedTemplate.setExtractable(isExtractable.booleanValue());
|
||||
} else if (isExtractable != null && caller.getType() != Account.ACCOUNT_TYPE_ADMIN) {
|
||||
throw new InvalidParameterValueException("Only ROOT admins are allowed to modify this attribute.");
|
||||
@ -1276,7 +1276,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
||||
if (permittedAccount != null) {
|
||||
if (permittedAccount.getId() == caller.getId()) {
|
||||
continue; // don't grant permission to the template
|
||||
// owner, they implicitly have permission
|
||||
// owner, they implicitly have permission
|
||||
}
|
||||
LaunchPermissionVO existingPermission = _launchPermissionDao.findByTemplateAndAccount(id, permittedAccount.getId());
|
||||
if (existingPermission == null) {
|
||||
@ -1333,7 +1333,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
||||
|
||||
try {
|
||||
TemplateInfo tmplInfo = this._tmplFactory.getTemplate(templateId, DataStoreRole.Image);
|
||||
Long zoneId = null;
|
||||
long zoneId = 0;
|
||||
if (snapshotId != null) {
|
||||
snapshot = _snapshotDao.findById(snapshotId);
|
||||
zoneId = snapshot.getDataCenterId();
|
||||
@ -1341,18 +1341,17 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
||||
volume = _volumeDao.findById(volumeId);
|
||||
zoneId = volume.getDataCenterId();
|
||||
}
|
||||
ZoneScope scope = new ZoneScope(zoneId);
|
||||
List<DataStore> store = this._dataStoreMgr.getImageStoresByScope(scope);
|
||||
if (store.size() > 1) {
|
||||
throw new CloudRuntimeException("muliple image data store, don't know which one to use");
|
||||
DataStore store = this._dataStoreMgr.getImageStore(zoneId);
|
||||
if (store == null) {
|
||||
throw new CloudRuntimeException("cannot find an image store for zone " + zoneId);
|
||||
}
|
||||
AsyncCallFuture<TemplateApiResult> future = null;
|
||||
if (snapshotId != null) {
|
||||
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) {
|
||||
VolumeInfo volInfo = this._volFactory.getVolume(volumeId);
|
||||
future = this._tmpltSvr.createTemplateFromVolumeAsync(volInfo, tmplInfo, store.get(0));
|
||||
future = this._tmpltSvr.createTemplateFromVolumeAsync(volInfo, tmplInfo, store);
|
||||
} else {
|
||||
throw new CloudRuntimeException("Creating private Template need to specify snapshotId or volumeId");
|
||||
}
|
||||
@ -1553,8 +1552,8 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
||||
if (template != null) {
|
||||
sourceTemplateId = template.getId();
|
||||
} else if (volume.getVolumeType() == Volume.Type.ROOT) { // vm
|
||||
// created
|
||||
// out
|
||||
// created
|
||||
// out
|
||||
// of blank
|
||||
// template
|
||||
UserVm userVm = ApiDBUtils.findUserVmById(volume.getInstanceId());
|
||||
|
||||
@ -822,11 +822,11 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
|
||||
try {
|
||||
try {
|
||||
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) {
|
||||
success = (success && _itMgr.advanceStop(_routerDao.findById(vm.getId()), false, getSystemUser(), getSystemAccount()));
|
||||
_itMgr.advanceStop(vm.getUuid(), false);
|
||||
} else {
|
||||
success = (success && _itMgr.advanceStop(vm, false, getSystemUser(), getSystemAccount()));
|
||||
_itMgr.advanceStop(vm.getUuid(), false);
|
||||
}
|
||||
} catch (OperationTimedoutException ote) {
|
||||
s_logger.warn("Operation for stopping vm timed out, unable to stop vm " + vm.getHostName(), ote);
|
||||
|
||||
@ -20,17 +20,19 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.cluster.ClusterManager;
|
||||
import com.cloud.cluster.ClusterManagerListener;
|
||||
import com.cloud.cluster.ManagementServerHostVO;
|
||||
|
||||
@Local(value=VirtualMachineManager.class)
|
||||
public class ClusteredVirtualMachineManagerImpl extends VirtualMachineManagerImpl implements ClusterManagerListener {
|
||||
|
||||
@Inject
|
||||
ClusterManager _clusterMgr;
|
||||
|
||||
protected ClusteredVirtualMachineManagerImpl() {
|
||||
}
|
||||
|
||||
|
||||
@ -17,12 +17,10 @@
|
||||
package com.cloud.vm;
|
||||
|
||||
import com.cloud.domain.Domain;
|
||||
import com.cloud.domain.dao.DomainDao;
|
||||
import com.cloud.user.Account;
|
||||
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.db.EntityManager;
|
||||
|
||||
public class ReservationContextImpl implements ReservationContext {
|
||||
User _caller;
|
||||
@ -66,16 +64,16 @@ public class ReservationContextImpl implements ReservationContext {
|
||||
@Override
|
||||
public Account getAccount() {
|
||||
if (_account == null) {
|
||||
_account = s_accountDao.findByIdIncludingRemoved(_caller.getId());
|
||||
_account = s_entityMgr.findById(Account.class, _caller.getId());
|
||||
}
|
||||
return _account;
|
||||
return _account;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Domain getDomain() {
|
||||
if (_domain == null) {
|
||||
getAccount();
|
||||
_domain = s_domainDao.findByIdIncludingRemoved(_account.getDomainId());
|
||||
_domain = s_entityMgr.findById(Domain.class, _account.getDomainId());
|
||||
}
|
||||
return _domain;
|
||||
}
|
||||
@ -90,13 +88,9 @@ public class ReservationContextImpl implements ReservationContext {
|
||||
return _reservationId;
|
||||
}
|
||||
|
||||
static UserDao s_userDao;
|
||||
static DomainDao s_domainDao;
|
||||
static AccountDao s_accountDao;
|
||||
static EntityManager s_entityMgr;
|
||||
|
||||
static public void setComponents(UserDao userDao, DomainDao domainDao, AccountDao accountDao) {
|
||||
s_userDao = userDao;
|
||||
s_domainDao = domainDao;
|
||||
s_accountDao = accountDao;
|
||||
static public void init(EntityManager entityMgr) {
|
||||
s_entityMgr = entityMgr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,6 +107,8 @@ import com.cloud.dc.dao.HostPodDao;
|
||||
import com.cloud.deploy.DataCenterDeployment;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
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.dao.DomainDao;
|
||||
import com.cloud.event.ActionEvent;
|
||||
@ -178,6 +180,7 @@ import com.cloud.server.ConfigurationServer;
|
||||
import com.cloud.server.Criteria;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.service.dao.ServiceOfferingDetailsDao;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
import com.cloud.storage.GuestOSCategoryVO;
|
||||
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.VmDiskStatisticsDao;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.utils.DateUtil;
|
||||
import com.cloud.utils.Journal;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.Pair;
|
||||
@ -418,11 +422,16 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
ConfigurationServer _configServer;
|
||||
@Inject
|
||||
AffinityGroupService _affinityGroupService;
|
||||
@Inject
|
||||
PlannerHostReservationDao _plannerHostReservationDao;
|
||||
@Inject
|
||||
private ServiceOfferingDetailsDao serviceOfferingDetailsDao;
|
||||
|
||||
protected ScheduledExecutorService _executor = null;
|
||||
protected int _expungeInterval;
|
||||
protected int _expungeDelay;
|
||||
protected boolean _dailyOrHourly = false;
|
||||
private int capacityReleaseInterval;
|
||||
|
||||
protected String _name;
|
||||
protected String _instance;
|
||||
@ -727,8 +736,6 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
private UserVm rebootVirtualMachine(long userId, long vmId)
|
||||
throws InsufficientCapacityException, ResourceUnavailableException {
|
||||
UserVmVO vm = _vmDao.findById(vmId);
|
||||
User caller = _accountMgr.getActiveUser(userId);
|
||||
Account owner = _accountMgr.getAccount(vm.getAccountId());
|
||||
|
||||
if (vm == null || vm.getState() == State.Destroyed
|
||||
|| 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) {
|
||||
collectVmDiskStatistics(vm);
|
||||
return _itMgr.reboot(vm, null, caller, owner);
|
||||
_itMgr.reboot(vm.getUuid(), null);
|
||||
return _vmDao.findById(vmId);
|
||||
} else {
|
||||
s_logger.error("Vm id=" + vmId
|
||||
+ " is not in Running state, failed to reboot");
|
||||
s_logger.error("Vm id=" + vmId + " is not in Running state, failed to reboot");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -1424,6 +1431,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
|
||||
String workers = configs.get("expunge.workers");
|
||||
int wrks = NumbersUtil.parseInt(workers, 10);
|
||||
capacityReleaseInterval = NumbersUtil.parseInt(_configDao.getValue(Config.CapacitySkipcountingHours.key()), 3600);
|
||||
|
||||
String time = configs.get("expunge.interval");
|
||||
_expungeInterval = NumbersUtil.parseInt(time, 86400);
|
||||
@ -1494,10 +1502,14 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
@Override
|
||||
public boolean expunge(UserVmVO vm, long callerUserId, Account caller) {
|
||||
try {
|
||||
List<VolumeVO> rootVol = _volsDao.findByInstanceAndType(vm.getId(), Volume.Type.ROOT);
|
||||
// expunge the vm
|
||||
if (!_itMgr.advanceExpunge(vm, _accountMgr.getSystemUser(), caller)) {
|
||||
s_logger.info("Did not expunge " + vm);
|
||||
return false;
|
||||
_itMgr.advanceExpunge(vm.getUuid());
|
||||
// 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()));
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
_itMgr.remove(vm, _accountMgr.getSystemUser(), caller);
|
||||
_vmDao.remove(vm.getId());
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -3833,22 +3845,9 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
+ destinationHost.getResourceState());
|
||||
}
|
||||
|
||||
HostVO srcHost = _hostDao.findById(srcHostId);
|
||||
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);
|
||||
}
|
||||
checkHostsDedication(vm, srcHostId, destinationHost.getId());
|
||||
|
||||
// call to core process
|
||||
// call to core process
|
||||
DataCenterVO dcVO = _dcDao.findById(destinationHost.getDataCenterId());
|
||||
HostPodVO pod = _podDao.findById(destinationHost.getPodId());
|
||||
Cluster cluster = _clusterDao.findById(destinationHost.getClusterId());
|
||||
@ -3875,8 +3874,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
if (uservm != null) {
|
||||
collectVmDiskStatistics(uservm);
|
||||
}
|
||||
VMInstanceVO migratedVm = _itMgr.migrate(vm, srcHostId, dest);
|
||||
return migratedVm;
|
||||
_itMgr.migrate(vm.getUuid(), srcHostId, dest);
|
||||
return _vmDao.findById(vmId);
|
||||
}
|
||||
|
||||
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
|
||||
@ActionEvent(eventType = EventTypes.EVENT_VM_MIGRATE, eventDescription = "migrating VM", async = true)
|
||||
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());
|
||||
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 (volumeToPool.isEmpty()) {
|
||||
// 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");
|
||||
}
|
||||
|
||||
VMInstanceVO migratedVm = _itMgr.migrateWithStorage(vm, srcHostId, destinationHost.getId(), volToPoolObjectMap);
|
||||
return migratedVm;
|
||||
checkHostsDedication(vm, srcHostId, destinationHost.getId());
|
||||
|
||||
_itMgr.migrateWithStorage(vm.getUuid(), srcHostId, destinationHost.getId(), volToPoolObjectMap);
|
||||
return _vmDao.findById(vm.getId());
|
||||
}
|
||||
|
||||
@DB
|
||||
@ -4201,9 +4406,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
|
||||
txn.commit();
|
||||
|
||||
VMInstanceVO vmoi = _itMgr.findByIdAndType(vm.getType(), vm.getId());
|
||||
VirtualMachineProfileImpl vmOldProfile = new VirtualMachineProfileImpl(
|
||||
vmoi);
|
||||
VirtualMachine vmoi = _itMgr.findById(vm.getId());
|
||||
VirtualMachineProfileImpl vmOldProfile = new VirtualMachineProfileImpl(vmoi);
|
||||
|
||||
// OS 3: update the network
|
||||
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),
|
||||
profile));
|
||||
|
||||
VMInstanceVO vmi = _itMgr.findByIdAndType(vm.getType(), vm.getId());
|
||||
VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl(
|
||||
vmi);
|
||||
VirtualMachine vmi = _itMgr.findById(vm.getId());
|
||||
VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl(vmi);
|
||||
_networkMgr.allocate(vmProfile, networks);
|
||||
|
||||
_securityGroupMgr.addInstanceToGroups(vm.getId(),
|
||||
@ -4413,10 +4616,8 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
networks.add(new Pair<NetworkVO, NicProfile>(appNet,
|
||||
defaultNic));
|
||||
}
|
||||
VMInstanceVO vmi = _itMgr.findByIdAndType(vm.getType(),
|
||||
vm.getId());
|
||||
VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl(
|
||||
vmi);
|
||||
VirtualMachine vmi = _itMgr.findById(vm.getId());
|
||||
VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl(vmi);
|
||||
_networkMgr.allocate(vmProfile, networks);
|
||||
s_logger.debug("AssignVM: Advance virtual, adding networks no "
|
||||
+ networks.size() + " to " + vm.getInstanceName());
|
||||
@ -4527,7 +4728,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
|
||||
if (needRestart) {
|
||||
try {
|
||||
_itMgr.stop(vm, user, caller);
|
||||
_itMgr.stop(vm.getUuid());
|
||||
} catch (ResourceUnavailableException e) {
|
||||
s_logger.debug("Stop vm " + vm.getUuid() + " failed", e);
|
||||
CloudRuntimeException ex = new CloudRuntimeException(
|
||||
|
||||
@ -20,8 +20,6 @@ import java.net.URI;
|
||||
import java.util.List;
|
||||
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.VirtualMachineTO;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
@ -43,9 +41,7 @@ import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
import com.cloud.storage.StoragePool;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.User;
|
||||
import com.cloud.storage.Volume;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.component.Manager;
|
||||
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);
|
||||
|
||||
<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);
|
||||
|
||||
@ -90,25 +86,22 @@ public interface VirtualMachineManager extends Manager {
|
||||
void advanceStart(String vmUuid, Map<VirtualMachineProfile.Param, Object> params, DeploymentPlan planToDeploy) throws InsufficientCapacityException,
|
||||
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;
|
||||
|
||||
<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);
|
||||
void advanceReboot(String vmUuid, Map<VirtualMachineProfile.Param, Object> params) throws InsufficientCapacityException, ResourceUnavailableException,
|
||||
ConcurrentOperationException, OperationTimedoutException;
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
VMInstanceVO findById(long vmId);
|
||||
VirtualMachine findById(long vmId);
|
||||
|
||||
<T extends VMInstanceVO> T storageMigration(T vm, StoragePool storagePoolId);
|
||||
|
||||
|
||||
@ -41,9 +41,9 @@ import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
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.VolumeDataFactory;
|
||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
||||
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.OnError;
|
||||
@ -81,10 +81,8 @@ import com.cloud.agent.manager.Commands;
|
||||
import com.cloud.agent.manager.allocator.HostAllocator;
|
||||
import com.cloud.alert.AlertManager;
|
||||
import com.cloud.capacity.CapacityManager;
|
||||
import com.cloud.cluster.ClusterManager;
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.ConfigurationManager;
|
||||
import com.cloud.configuration.Resource.ResourceType;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.dc.ClusterDetailsDao;
|
||||
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.DataCenterDao;
|
||||
import com.cloud.dc.dao.HostPodDao;
|
||||
import com.cloud.dc.dao.VlanDao;
|
||||
import com.cloud.deploy.DataCenterDeployment;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.deploy.DeploymentPlan;
|
||||
import com.cloud.deploy.DeploymentPlanner;
|
||||
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
|
||||
import com.cloud.deploy.DeploymentPlanningManager;
|
||||
import com.cloud.domain.dao.DomainDao;
|
||||
@ -145,7 +141,6 @@ import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.StorageManager;
|
||||
import com.cloud.storage.StoragePool;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.Volume;
|
||||
@ -164,7 +159,6 @@ import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.ResourceLimitService;
|
||||
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.NumbersUtil;
|
||||
import com.cloud.utils.Pair;
|
||||
@ -197,8 +191,6 @@ import com.cloud.vm.snapshot.dao.VMSnapshotDao;
|
||||
public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMachineManager, Listener {
|
||||
private static final Logger s_logger = Logger.getLogger(VirtualMachineManagerImpl.class);
|
||||
|
||||
@Inject
|
||||
protected StorageManager _storageMgr;
|
||||
@Inject
|
||||
DataStoreManager dataStoreMgr;
|
||||
@Inject
|
||||
@ -216,14 +208,10 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
@Inject
|
||||
protected VMTemplateDao _templateDao;
|
||||
@Inject
|
||||
protected UserDao _userDao;
|
||||
@Inject
|
||||
protected AccountDao _accountDao;
|
||||
@Inject
|
||||
protected DomainDao _domainDao;
|
||||
@Inject
|
||||
protected ClusterManager _clusterMgr;
|
||||
@Inject
|
||||
protected ItWorkDao _workDao;
|
||||
@Inject
|
||||
protected UserVmDao _userVmDao;
|
||||
@ -264,8 +252,6 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
@Inject
|
||||
protected VMSnapshotDao _vmSnapshotDao;
|
||||
@Inject
|
||||
protected VolumeDataFactory volFactory;
|
||||
@Inject
|
||||
protected ResourceLimitService _resourceLimitMgr;
|
||||
@Inject
|
||||
protected RulesManager rulesMgr;
|
||||
@ -278,20 +264,10 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
@Inject
|
||||
protected IPAddressDao _publicIpAddressDao;
|
||||
@Inject
|
||||
protected VlanDao _vlanDao;
|
||||
@Inject
|
||||
protected NicIpAliasDao _nicIpAliasDao;
|
||||
@Inject
|
||||
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;
|
||||
public List<HostAllocator> getHostAllocators() {
|
||||
return _hostAllocators;
|
||||
@ -418,16 +394,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> boolean expunge(T vm, User caller, Account account) throws ResourceUnavailableException {
|
||||
public void expunge(String vmUuid) throws ResourceUnavailableException {
|
||||
try {
|
||||
if (advanceExpunge(vm, caller, account)) {
|
||||
// Mark vms as removed
|
||||
remove(vm, caller, account);
|
||||
return true;
|
||||
} else {
|
||||
s_logger.info("Did not expunge " + vm);
|
||||
return false;
|
||||
}
|
||||
advanceExpunge(vmUuid);
|
||||
} catch (OperationTimedoutException e) {
|
||||
throw new CloudRuntimeException("Operation timed out", e);
|
||||
} catch (ConcurrentOperationException e) {
|
||||
@ -436,28 +405,30 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
}
|
||||
|
||||
@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 (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Unable to find vm or vm is destroyed: " + vm);
|
||||
}
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.advanceStop(vm, false, caller, account)) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Unable to stop the VM so we can't expunge it.");
|
||||
}
|
||||
}
|
||||
advanceStop(vm, false);
|
||||
|
||||
try {
|
||||
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);
|
||||
return false;
|
||||
throw new CloudRuntimeException("Unable to destroy " + vm);
|
||||
|
||||
}
|
||||
} catch (NoTransitionException e) {
|
||||
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()) {
|
||||
@ -477,7 +448,6 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
_networkMgr.cleanupNics(profile);
|
||||
|
||||
// Clean up volumes based on the vm's instance id
|
||||
List<VolumeVO> rootVol = _volsDao.findByInstanceAndType(vm.getId(), Volume.Type.ROOT);
|
||||
volumeMgr.cleanupVolumes(vm.getId());
|
||||
|
||||
VirtualMachineGuru guru = getVmGuru(vm);
|
||||
@ -502,12 +472,11 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
_agentMgr.send(hostId, cmds);
|
||||
if(!cmds.isSuccessful()){
|
||||
for (Answer answer : cmds.getAnswers()){
|
||||
if(answer != null && !answer.getResult()){
|
||||
if (!answer.getResult()) {
|
||||
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);
|
||||
}
|
||||
|
||||
// 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
|
||||
@ -578,8 +540,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
|
||||
_retry = NumbersUtil.parseInt(params.get(Config.StartRetry.key()), 10);
|
||||
|
||||
ReservationContextImpl.setComponents(_userDao, _domainDao, _accountDao);
|
||||
VirtualMachineProfileImpl.setComponents(_offeringDao, _templateDao, _accountDao);
|
||||
ReservationContextImpl.init(_entityMgr);
|
||||
VirtualMachineProfileImpl.init(_entityMgr);
|
||||
|
||||
_cancelWait = NumbersUtil.parseLong(params.get(Config.VmOpCancelInterval.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()));
|
||||
|
||||
_executor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("Vm-Operations-Cleanup"));
|
||||
_nodeId = _clusterMgr.getManagementNodeId();
|
||||
_nodeId = ManagementServerNode.getManagementServerId();
|
||||
|
||||
_agentMgr.registerForHostEvents(this, true, true, true);
|
||||
|
||||
@ -1014,10 +976,10 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
_workDao.updateStep(work, Step.Release);
|
||||
// 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
|
||||
cleanup(vmGuru, vmProfile, work, Event.OperationFailed, false, caller, account);
|
||||
cleanup(vmGuru, vmProfile, work, Event.OperationFailed, false);
|
||||
} else {
|
||||
//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
|
||||
public <T extends VMInstanceVO> boolean stop(T vm, User user, Account account) throws ResourceUnavailableException {
|
||||
public void stop(String vmUuid) throws ResourceUnavailableException {
|
||||
try {
|
||||
return advanceStop(vm, false, user, account);
|
||||
advanceStop(vmUuid, false);
|
||||
} 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) {
|
||||
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;
|
||||
}
|
||||
|
||||
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();
|
||||
State state = vm.getState();
|
||||
s_logger.debug("Cleaning up resources for the vm " + vm + " in " + state + " state");
|
||||
if (state == State.Starting) {
|
||||
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);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (step == Step.Started || step == Step.Starting || step == Step.Release) {
|
||||
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");
|
||||
return false;
|
||||
}
|
||||
@ -1105,33 +1067,33 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
}
|
||||
} else if (state == State.Stopping) {
|
||||
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");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else if (state == State.Migrating) {
|
||||
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");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
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");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} 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");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
_networkMgr.release(profile, force);
|
||||
_networkMgr.release(profile, cleanUpEvenIfUnableToStop);
|
||||
s_logger.debug("Successfully released network resources for the vm " + vm);
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("Unable to release some network resources.", e);
|
||||
@ -1143,20 +1105,26 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
}
|
||||
|
||||
@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();
|
||||
if (state == State.Stopped) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("VM is already stopped: " + vm);
|
||||
}
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (state == State.Destroyed || state == State.Expunging || state == State.Error) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Stopped called on " + vm + " but the state is " + state);
|
||||
}
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
// grab outstanding work item if any
|
||||
ItWorkVO work = _workDao.findByOutstandingWork(vm.getId(), vm.getState());
|
||||
@ -1167,11 +1135,11 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
}
|
||||
Long hostId = vm.getHostId();
|
||||
if (hostId == null) {
|
||||
if (!forced) {
|
||||
if (!cleanUpEvenIfUnableToStop) {
|
||||
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());
|
||||
}
|
||||
return false;
|
||||
throw new CloudRuntimeException("Unable to stop " + vm);
|
||||
}
|
||||
try {
|
||||
stateTransitTo(vm, Event.AgentReportStopped, null, null);
|
||||
@ -1186,7 +1154,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
work.setStep(Step.Done);
|
||||
_workDao.update(work.getId(), work);
|
||||
}
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
VirtualMachineGuru vmGuru = getVmGuru(vm);
|
||||
@ -1197,7 +1165,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
throw new ConcurrentOperationException("VM is being operated on.");
|
||||
}
|
||||
} catch (NoTransitionException e1) {
|
||||
if (!forced) {
|
||||
if (!cleanUpEvenIfUnableToStop) {
|
||||
throw new CloudRuntimeException("We cannot stop " + vm + " when it is in state " + vm.getState());
|
||||
}
|
||||
boolean doCleanup = false;
|
||||
@ -1218,15 +1186,17 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
}
|
||||
|
||||
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 {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
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) {
|
||||
s_logger.warn("Unable to cleanup " + vm);
|
||||
return false;
|
||||
throw new CloudRuntimeException("Unable to stop " + vm, e);
|
||||
}
|
||||
} else {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
@ -1271,14 +1241,14 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
throw e;
|
||||
} finally {
|
||||
if (!stopped) {
|
||||
if (!forced) {
|
||||
if (!cleanUpEvenIfUnableToStop) {
|
||||
s_logger.warn("Unable to stop vm " + vm);
|
||||
try {
|
||||
stateTransitTo(vm, Event.OperationFailed, vm.getHostId());
|
||||
} catch (NoTransitionException e) {
|
||||
s_logger.warn("Unable to transition the state " + vm);
|
||||
}
|
||||
return false;
|
||||
throw new CloudRuntimeException("Unable to stop " + vm);
|
||||
} else {
|
||||
s_logger.warn("Unable to actually stop " + vm + " but continue with release because it's a force stop");
|
||||
vmGuru.finalizeStop(profile, answer);
|
||||
@ -1291,7 +1261,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
}
|
||||
|
||||
try {
|
||||
_networkMgr.release(profile, forced);
|
||||
_networkMgr.release(profile, cleanUpEvenIfUnableToStop);
|
||||
s_logger.debug("Successfully released network resources for the vm " + vm);
|
||||
} catch (Exception 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);
|
||||
}
|
||||
|
||||
return stateTransitTo(vm, Event.OperationSucceeded, null);
|
||||
if (!stateTransitTo(vm, Event.OperationSucceeded, null)) {
|
||||
throw new CloudRuntimeException("unable to stop " + vm);
|
||||
}
|
||||
} catch (NoTransitionException e) {
|
||||
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
|
||||
public <T extends VMInstanceVO> boolean remove(T vm, User user, Account caller) {
|
||||
return _vmDao.remove(vm.getId());
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
public void destroy(String vmUuid) throws AgentUnavailableException, OperationTimedoutException, ConcurrentOperationException {
|
||||
VMInstanceVO vm = _vmDao.findByUuid(vmUuid);
|
||||
if (vm == null || vm.getState() == State.Destroyed || vm.getState() == State.Expunging || vm.getRemoved() != null) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Unable to find vm or vm is destroyed: " + vm);
|
||||
}
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!advanceStop(vm, _forceStop, user, caller)) {
|
||||
s_logger.debug("Unable to stop " + vm);
|
||||
return false;
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Destroying vm " + vm);
|
||||
}
|
||||
|
||||
advanceStop(vm, _forceStop);
|
||||
|
||||
if (!_vmSnapshotMgr.deleteAllVMSnapshots(vm.getId(),null)){
|
||||
s_logger.debug("Unable to delete all snapshots for " + vm);
|
||||
return false;
|
||||
throw new CloudRuntimeException("Unable to delete vm snapshots for " + vm);
|
||||
}
|
||||
|
||||
try {
|
||||
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);
|
||||
return false;
|
||||
throw new CloudRuntimeException("Unable to destroy " + vm);
|
||||
}
|
||||
} catch (NoTransitionException e) {
|
||||
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.
|
||||
@ -1479,17 +1443,18 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> T migrate(T vmm, long srcHostId, DeployDestination dest) throws ResourceUnavailableException, ConcurrentOperationException,
|
||||
ManagementServerException,
|
||||
VirtualMachineMigrationException {
|
||||
VMInstanceVO vm = _vmDao.findByUuid(vmm.getUuid());
|
||||
public void migrate(String vmUuid, long srcHostId, DeployDestination dest) throws ResourceUnavailableException, ConcurrentOperationException {
|
||||
VMInstanceVO vm = _vmDao.findByUuid(vmUuid);
|
||||
if (vm == null) {
|
||||
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);
|
||||
|
||||
long dstHostId = dest.getHost().getId();
|
||||
@ -1510,7 +1475,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
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;
|
||||
@ -1578,8 +1543,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
try {
|
||||
MigrateAnswer ma = (MigrateAnswer) _agentMgr.send(vm.getLastHostId(), mc);
|
||||
if (!ma.getResult()) {
|
||||
s_logger.error("Unable to migrate due to " + ma.getDetails());
|
||||
return null;
|
||||
throw new CloudRuntimeException("Unable to migrate due to " + ma.getDetails());
|
||||
}
|
||||
} catch (OperationTimedoutException e) {
|
||||
if (e.isActive()) {
|
||||
@ -1605,14 +1569,13 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
} catch (AgentUnavailableException e) {
|
||||
s_logger.error("AgentUnavailableException while cleanup on source host: " + srcHostId);
|
||||
}
|
||||
cleanup(vmGuru, new VirtualMachineProfileImpl(vm), work, Event.AgentReportStopped, true, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
|
||||
return null;
|
||||
cleanup(vmGuru, new VirtualMachineProfileImpl(vm), work, Event.AgentReportStopped, true);
|
||||
throw new CloudRuntimeException("Unable to complete migration for " + vm);
|
||||
}
|
||||
} catch (OperationTimedoutException e) {
|
||||
}
|
||||
|
||||
migrated = true;
|
||||
return vmm;
|
||||
} finally {
|
||||
if (!migrated) {
|
||||
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,
|
||||
Host host, Map<VolumeVO, StoragePoolVO> volumeToPool) {
|
||||
private Map<Volume, StoragePool> getPoolListForVolumesForMigration(VirtualMachineProfile profile, Host host, Map<Volume, StoragePool> volumeToPool) {
|
||||
List<VolumeVO> allVolumes = _volsDao.findUsableVolumesForInstance(profile.getId());
|
||||
for (VolumeVO volume : allVolumes) {
|
||||
StoragePoolVO pool = volumeToPool.get(volume);
|
||||
StoragePool pool = volumeToPool.get(volume);
|
||||
DiskOfferingVO diskOffering = _diskOfferingDao.findById(volume.getDiskOfferingId());
|
||||
StoragePoolVO currentPool = _storagePoolDao.findById(volume.getPoolId());
|
||||
if (pool != null) {
|
||||
@ -1728,10 +1690,9 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> T migrateWithStorage(T vmm, long srcHostId, long destHostId,
|
||||
Map<VolumeVO, StoragePoolVO> volumeToPool) throws ResourceUnavailableException, ConcurrentOperationException,
|
||||
ManagementServerException, VirtualMachineMigrationException {
|
||||
VMInstanceVO vm = _vmDao.findByUuid(vmm.getUuid());
|
||||
public void migrateWithStorage(String vmUuid, long srcHostId, long destHostId, Map<Volume, StoragePool> volumeToPool) throws ResourceUnavailableException,
|
||||
ConcurrentOperationException {
|
||||
VMInstanceVO vm = _vmDao.findByUuid(vmUuid);
|
||||
|
||||
HostVO srcHost = _hostDao.findById(srcHostId);
|
||||
HostVO destHost = _hostDao.findById(destHostId);
|
||||
@ -1791,16 +1752,14 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
} catch (AgentUnavailableException e) {
|
||||
s_logger.error("AgentUnavailableException while cleanup on source host: " + srcHostId);
|
||||
}
|
||||
cleanup(vmGuru, new VirtualMachineProfileImpl(vm), work, Event.AgentReportStopped, true,
|
||||
_accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
|
||||
return null;
|
||||
cleanup(vmGuru, new VirtualMachineProfileImpl(vm), work, Event.AgentReportStopped, true);
|
||||
throw new CloudRuntimeException("VM not found on desintation host. Unable to complete migration for " + vm);
|
||||
}
|
||||
} catch (OperationTimedoutException e) {
|
||||
s_logger.warn("Error while checking the vm " + vm + " is on host " + destHost, e);
|
||||
}
|
||||
|
||||
migrated = true;
|
||||
return vmm;
|
||||
} finally {
|
||||
if (!migrated) {
|
||||
s_logger.info("Migration was unsuccessful. Cleaning up: " + vm);
|
||||
@ -1869,11 +1828,11 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean migrateAway(VirtualMachine.Type vmType, long vmId, long srcHostId) throws InsufficientServerCapacityException, VirtualMachineMigrationException {
|
||||
VMInstanceVO vm = _vmDao.findById(vmId);
|
||||
public void migrateAway(String vmUuid, long srcHostId) throws InsufficientServerCapacityException {
|
||||
VMInstanceVO vm = _vmDao.findByUuid(vmUuid);
|
||||
if (vm == null) {
|
||||
s_logger.debug("Unable to find a VM for " + vmId);
|
||||
return true;
|
||||
s_logger.debug("Unable to find a VM for " + vmUuid);
|
||||
throw new CloudRuntimeException("Unable to find " + vmUuid);
|
||||
}
|
||||
|
||||
VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm);
|
||||
@ -1881,7 +1840,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
Long hostId = vm.getHostId();
|
||||
if (hostId == null) {
|
||||
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);
|
||||
@ -1913,38 +1872,28 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
}
|
||||
|
||||
excludes.addHost(dest.getHost().getId());
|
||||
VMInstanceVO vmInstance = null;
|
||||
try {
|
||||
vmInstance = migrate(vm, srcHostId, dest);
|
||||
migrate(vm, srcHostId, dest);
|
||||
return;
|
||||
} catch (ResourceUnavailableException e) {
|
||||
s_logger.debug("Unable to migrate to unavailable " + dest);
|
||||
} catch (ConcurrentOperationException e) {
|
||||
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 {
|
||||
boolean result = advanceStop(vm, true, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
|
||||
return result;
|
||||
advanceStop(vm, true);
|
||||
throw new CloudRuntimeException("Unable to migrate " + vm);
|
||||
} catch (ResourceUnavailableException e) {
|
||||
s_logger.debug("Unable to stop VM due to " + e.getMessage());
|
||||
throw new CloudRuntimeException("Unable to migrate " + vm);
|
||||
} catch (ConcurrentOperationException e) {
|
||||
s_logger.debug("Unable to stop VM due to " + e.getMessage());
|
||||
throw new CloudRuntimeException("Unable to migrate " + vm);
|
||||
} catch (OperationTimedoutException e) {
|
||||
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
|
||||
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 {
|
||||
return advanceReboot(vm, params, caller, account);
|
||||
advanceReboot(vmUuid, params);
|
||||
} catch (ConcurrentOperationException e) {
|
||||
throw new CloudRuntimeException("Unable to reboot a VM due to concurrent operation", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends VMInstanceVO> T advanceReboot(T vm, Map<VirtualMachineProfile.Param, Object> params, User caller, Account account) throws InsufficientCapacityException,
|
||||
ConcurrentOperationException, ResourceUnavailableException {
|
||||
T rebootedVm = null;
|
||||
public void advanceReboot(String vmUuid, Map<VirtualMachineProfile.Param, Object> params) throws InsufficientCapacityException, ConcurrentOperationException,
|
||||
ResourceUnavailableException {
|
||||
VMInstanceVO vm = _vmDao.findByUuid(vmUuid);
|
||||
|
||||
DataCenter dc = _configMgr.getZone(vm.getDataCenterId());
|
||||
Host host = _hostDao.findById(vm.getHostId());
|
||||
@ -2005,21 +1954,13 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
|
||||
Answer rebootAnswer = cmds.getAnswer(RebootAnswer.class);
|
||||
if (rebootAnswer != null && rebootAnswer.getResult()) {
|
||||
rebootedVm = vm;
|
||||
return rebootedVm;
|
||||
return;
|
||||
}
|
||||
s_logger.info("Unable to reboot VM " + vm + " on " + dest.getHost() + " due to " + (rebootAnswer == null ? " no reboot answer" : rebootAnswer.getDetails()));
|
||||
} 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);
|
||||
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) {
|
||||
@ -2301,7 +2242,6 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
if (vm != null) {
|
||||
map.put(vm.getId(), new AgentVmInfo(entry.getKey(), vm, entry.getValue().second(), entry.getValue().first()));
|
||||
is_alien_vm = false;
|
||||
break;
|
||||
}
|
||||
// alien VMs
|
||||
if (is_alien_vm){
|
||||
@ -2466,7 +2406,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
if (agentState == State.Shutdowned) {
|
||||
if (serverState == State.Running || serverState == State.Starting || serverState == State.Stopping) {
|
||||
try {
|
||||
advanceStop(vm, true, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount());
|
||||
advanceStop(vm, true);
|
||||
} catch (AgentUnavailableException e) {
|
||||
assert (false) : "How do we hit this with forced on?";
|
||||
return null;
|
||||
@ -2858,17 +2798,11 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
ResourceUnavailableException, InsufficientCapacityException {
|
||||
|
||||
s_logger.debug("Adding vm " + vm + " to network " + network + "; requested nic profile " + requested);
|
||||
VMInstanceVO vmVO;
|
||||
if (vm.getType() == VirtualMachine.Type.User) {
|
||||
vmVO = _userVmDao.findById(vm.getId());
|
||||
} else {
|
||||
vmVO = _vmDao.findById(vm.getId());
|
||||
}
|
||||
VMInstanceVO vmVO = _vmDao.findById(vm.getId());
|
||||
ReservationContext context = new ReservationContextImpl(null, null, _accountMgr.getActiveUser(User.UID_SYSTEM),
|
||||
_accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM));
|
||||
|
||||
VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl(vmVO, null,
|
||||
null, null, null);
|
||||
VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl(vmVO, null, null, null, null);
|
||||
|
||||
DataCenter dc = _configMgr.getZone(network.getDataCenterId());
|
||||
Host host = _hostDao.findById(vm.getHostId());
|
||||
@ -3246,7 +3180,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
||||
} catch (AgentUnavailableException e) {
|
||||
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;
|
||||
}
|
||||
} catch (OperationTimedoutException e) {
|
||||
|
||||
@ -25,13 +25,11 @@ import com.cloud.agent.api.to.DiskTO;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.template.VirtualMachineTemplate;
|
||||
import com.cloud.template.VirtualMachineTemplate.BootloaderType;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.utils.db.EntityManager;
|
||||
|
||||
/**
|
||||
* Implementation of VirtualMachineProfile.
|
||||
@ -40,8 +38,8 @@ import com.cloud.user.dao.AccountDao;
|
||||
public class VirtualMachineProfileImpl implements VirtualMachineProfile {
|
||||
|
||||
VirtualMachine _vm;
|
||||
ServiceOfferingVO _offering;
|
||||
VMTemplateVO _template;
|
||||
ServiceOffering _offering;
|
||||
VirtualMachineTemplate _template;
|
||||
UserVmDetailVO _userVmDetails;
|
||||
Map<Param, Object> _params;
|
||||
List<NicProfile> _nics = new ArrayList<NicProfile>();
|
||||
@ -88,7 +86,7 @@ public class VirtualMachineProfileImpl implements VirtualMachineProfile {
|
||||
@Override
|
||||
public ServiceOffering getServiceOffering() {
|
||||
if (_offering == null) {
|
||||
_offering = s_offeringDao.findByIdIncludingRemoved(_vm.getServiceOfferingId());
|
||||
_offering = s_entityMgr.findById(ServiceOffering.class, _vm.getServiceOfferingId());
|
||||
}
|
||||
return _offering;
|
||||
}
|
||||
@ -106,7 +104,7 @@ public class VirtualMachineProfileImpl implements VirtualMachineProfile {
|
||||
@Override
|
||||
public VirtualMachineTemplate getTemplate() {
|
||||
if (_template == null && _vm != null) {
|
||||
_template = s_templateDao.findByIdIncludingRemoved(_vm.getTemplateId());
|
||||
_template = s_entityMgr.findById(VirtualMachineTemplate.class, _vm.getTemplateId());
|
||||
}
|
||||
return _template;
|
||||
}
|
||||
@ -184,7 +182,7 @@ public class VirtualMachineProfileImpl implements VirtualMachineProfile {
|
||||
@Override
|
||||
public Account getOwner() {
|
||||
if (_owner == null) {
|
||||
_owner = s_accountDao.findByIdIncludingRemoved(_vm.getAccountId());
|
||||
_owner = s_entityMgr.findById(Account.class, _vm.getAccountId());
|
||||
}
|
||||
return _owner;
|
||||
}
|
||||
@ -194,13 +192,10 @@ public class VirtualMachineProfileImpl implements VirtualMachineProfile {
|
||||
return _bootArgs.toString();
|
||||
}
|
||||
|
||||
static ServiceOfferingDao s_offeringDao;
|
||||
static VMTemplateDao s_templateDao;
|
||||
static AccountDao s_accountDao;
|
||||
static void setComponents(ServiceOfferingDao offeringDao, VMTemplateDao templateDao, AccountDao accountDao) {
|
||||
s_offeringDao = offeringDao;
|
||||
s_templateDao = templateDao;
|
||||
s_accountDao = accountDao;
|
||||
static EntityManager s_entityMgr;
|
||||
|
||||
static void init(EntityManager entityMgr) {
|
||||
s_entityMgr = entityMgr;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -74,7 +74,6 @@ import com.cloud.storage.dao.SnapshotDao;
|
||||
import com.cloud.storage.dao.VolumeDao;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.UserVO;
|
||||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.user.dao.UserDao;
|
||||
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.");
|
||||
}
|
||||
|
||||
UserVO callerUser = _userDao.findById(CallContext.current().getCallingUserId());
|
||||
|
||||
UserVmVO vm = 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
|
||||
if(userVm.getState() == VirtualMachine.State.Stopped && vmSnapshotVo.getType() == VMSnapshot.Type.DiskAndMemory){
|
||||
@ -683,7 +679,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
|
||||
}else {
|
||||
if(userVm.getState() == VirtualMachine.State.Running && vmSnapshotVo.getType() == VMSnapshot.Type.Disk){
|
||||
try {
|
||||
_itMgr.advanceStop(userVm, true, callerUser, owner);
|
||||
_itMgr.advanceStop(userVm.getUuid(), true);
|
||||
} catch (Exception e) {
|
||||
s_logger.error("Stop VM " + userVm.getInstanceName() + " before reverting failed due to " + e.getMessage());
|
||||
throw new CloudRuntimeException(e.getMessage());
|
||||
|
||||
@ -197,7 +197,6 @@ public class UserVmManagerTest {
|
||||
when(_rootVols.get(eq(0))).thenReturn(_volumeMock);
|
||||
doReturn(3L).when(_volumeMock).getTemplateId();
|
||||
when(_templateDao.findById(anyLong())).thenReturn(_templateMock);
|
||||
when(_itMgr.stop(_vmMock, _userMock, _account)).thenReturn(true);
|
||||
when(_storageMgr.allocateDuplicateVolume(_volumeMock, null)).thenReturn(_volumeMock);
|
||||
doNothing().when(_volsDao).attachVolume(anyLong(), anyLong(), anyLong());
|
||||
when(_volumeMock.getId()).thenReturn(3L);
|
||||
@ -230,7 +229,6 @@ public class UserVmManagerTest {
|
||||
doReturn(ImageFormat.VHD).when(_templateMock).getFormat();
|
||||
when(_templateDao.findById(anyLong())).thenReturn(_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(_templateMock.getGuestOSId()).thenReturn(5L);
|
||||
doNothing().when(_vmMock).setGuestOSId(anyLong());
|
||||
@ -269,7 +267,6 @@ public class UserVmManagerTest {
|
||||
doReturn(ImageFormat.ISO).when(_templateMock).getFormat();
|
||||
when(_templateDao.findById(anyLong())).thenReturn(_templateMock);
|
||||
doNothing().when(_accountMgr).checkAccess(_account, null, true, _templateMock);
|
||||
when(_itMgr.stop(_vmMock, _userMock, _account)).thenReturn(true);
|
||||
when(_storageMgr.allocateDuplicateVolume(_volumeMock, null)).thenReturn(_volumeMock);
|
||||
doNothing().when(_vmMock).setIsoId(14L);
|
||||
when(_templateMock.getGuestOSId()).thenReturn(5L);
|
||||
|
||||
@ -79,8 +79,10 @@ import com.cloud.network.NetworkManager;
|
||||
import com.cloud.server.ConfigurationServer;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
import com.cloud.storage.StoragePool;
|
||||
import com.cloud.storage.StoragePoolHostVO;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.Volume;
|
||||
import com.cloud.storage.VolumeManager;
|
||||
import com.cloud.storage.VolumeVO;
|
||||
import com.cloud.storage.dao.DiskOfferingDao;
|
||||
@ -104,135 +106,149 @@ import com.cloud.vm.snapshot.VMSnapshotManager;
|
||||
|
||||
public class VirtualMachineManagerImplTest {
|
||||
|
||||
@Spy VirtualMachineManagerImpl _vmMgr = new VirtualMachineManagerImpl();
|
||||
@Mock
|
||||
VolumeManager _storageMgr;
|
||||
@Mock
|
||||
Account _account;
|
||||
@Mock
|
||||
AccountManager _accountMgr;
|
||||
@Mock
|
||||
ConfigurationManager _configMgr;
|
||||
@Mock
|
||||
CapacityManager _capacityMgr;
|
||||
@Mock
|
||||
AgentManager _agentMgr;
|
||||
@Mock
|
||||
AccountDao _accountDao;
|
||||
@Mock
|
||||
ConfigurationDao _configDao;
|
||||
@Mock
|
||||
HostDao _hostDao;
|
||||
@Mock
|
||||
UserDao _userDao;
|
||||
@Mock
|
||||
UserVmDao _vmDao;
|
||||
@Mock
|
||||
ItWorkDao _workDao;
|
||||
@Mock
|
||||
VMInstanceDao _vmInstanceDao;
|
||||
@Mock
|
||||
VMTemplateDao _templateDao;
|
||||
@Mock
|
||||
VolumeDao _volsDao;
|
||||
@Mock
|
||||
RestoreVMCmd _restoreVMCmd;
|
||||
@Mock
|
||||
AccountVO _accountMock;
|
||||
@Mock
|
||||
UserVO _userMock;
|
||||
@Mock
|
||||
UserVmVO _vmMock;
|
||||
@Mock
|
||||
VMInstanceVO _vmInstance;
|
||||
@Mock
|
||||
HostVO _host;
|
||||
@Mock
|
||||
VMTemplateVO _templateMock;
|
||||
@Mock
|
||||
VolumeVO _volumeMock;
|
||||
@Mock
|
||||
List<VolumeVO> _rootVols;
|
||||
@Mock
|
||||
ItWorkVO _work;
|
||||
@Mock
|
||||
ConfigurationServer _configServer;
|
||||
@Mock
|
||||
HostVO hostVO;
|
||||
@Mock
|
||||
UserVmDetailVO _vmDetailVO;
|
||||
@Spy
|
||||
VirtualMachineManagerImpl _vmMgr = new VirtualMachineManagerImpl();
|
||||
@Mock
|
||||
VolumeManager _storageMgr;
|
||||
@Mock
|
||||
Account _account;
|
||||
@Mock
|
||||
AccountManager _accountMgr;
|
||||
@Mock
|
||||
ConfigurationManager _configMgr;
|
||||
@Mock
|
||||
CapacityManager _capacityMgr;
|
||||
@Mock
|
||||
AgentManager _agentMgr;
|
||||
@Mock
|
||||
AccountDao _accountDao;
|
||||
@Mock
|
||||
ConfigurationDao _configDao;
|
||||
@Mock
|
||||
HostDao _hostDao;
|
||||
@Mock
|
||||
UserDao _userDao;
|
||||
@Mock
|
||||
UserVmDao _vmDao;
|
||||
@Mock
|
||||
ItWorkDao _workDao;
|
||||
@Mock
|
||||
VMInstanceDao _vmInstanceDao;
|
||||
@Mock
|
||||
VMTemplateDao _templateDao;
|
||||
@Mock
|
||||
VolumeDao _volsDao;
|
||||
@Mock
|
||||
RestoreVMCmd _restoreVMCmd;
|
||||
@Mock
|
||||
AccountVO _accountMock;
|
||||
@Mock
|
||||
UserVO _userMock;
|
||||
@Mock
|
||||
UserVmVO _vmMock;
|
||||
@Mock
|
||||
VMInstanceVO _vmInstance;
|
||||
@Mock
|
||||
HostVO _host;
|
||||
@Mock
|
||||
VMTemplateVO _templateMock;
|
||||
@Mock
|
||||
VolumeVO _volumeMock;
|
||||
@Mock
|
||||
List<VolumeVO> _rootVols;
|
||||
@Mock
|
||||
ItWorkVO _work;
|
||||
@Mock
|
||||
ConfigurationServer _configServer;
|
||||
@Mock
|
||||
HostVO hostVO;
|
||||
@Mock
|
||||
UserVmDetailVO _vmDetailVO;
|
||||
|
||||
@Mock ClusterDao _clusterDao;
|
||||
@Mock HostPodDao _podDao;
|
||||
@Mock DataCenterDao _dcDao;
|
||||
@Mock DiskOfferingDao _diskOfferingDao;
|
||||
@Mock PrimaryDataStoreDao _storagePoolDao;
|
||||
@Mock UserVmDetailsDao _vmDetailsDao;
|
||||
@Mock StoragePoolHostDao _poolHostDao;
|
||||
@Mock NetworkManager _networkMgr;
|
||||
@Mock HypervisorGuruManager _hvGuruMgr;
|
||||
@Mock VMSnapshotManager _vmSnapshotMgr;
|
||||
@Mock
|
||||
ClusterDao _clusterDao;
|
||||
@Mock
|
||||
HostPodDao _podDao;
|
||||
@Mock
|
||||
DataCenterDao _dcDao;
|
||||
@Mock
|
||||
DiskOfferingDao _diskOfferingDao;
|
||||
@Mock
|
||||
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 DiskOfferingVO _diskOfferingMock;
|
||||
@Mock StoragePoolVO _srcStoragePoolMock;
|
||||
@Mock StoragePoolVO _destStoragePoolMock;
|
||||
@Mock HostVO _srcHostMock;
|
||||
@Mock HostVO _destHostMock;
|
||||
@Mock Map<VolumeVO, StoragePoolVO> _volumeToPoolMock;
|
||||
// Mock objects for vm migration with storage test.
|
||||
@Mock
|
||||
DiskOfferingVO _diskOfferingMock;
|
||||
@Mock
|
||||
StoragePoolVO _srcStoragePoolMock;
|
||||
@Mock
|
||||
StoragePoolVO _destStoragePoolMock;
|
||||
@Mock
|
||||
HostVO _srcHostMock;
|
||||
@Mock
|
||||
HostVO _destHostMock;
|
||||
@Mock
|
||||
Map<Volume, StoragePool> _volumeToPoolMock;
|
||||
|
||||
@Before
|
||||
public void setup(){
|
||||
MockitoAnnotations.initMocks(this);
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
_vmMgr._templateDao = _templateDao;
|
||||
_vmMgr._volsDao = _volsDao;
|
||||
_vmMgr.volumeMgr = _storageMgr;
|
||||
_vmMgr._accountDao = _accountDao;
|
||||
_vmMgr._userDao = _userDao;
|
||||
_vmMgr._accountMgr = _accountMgr;
|
||||
_vmMgr._configMgr = _configMgr;
|
||||
_vmMgr._capacityMgr = _capacityMgr;
|
||||
_vmMgr._hostDao = _hostDao;
|
||||
_vmMgr._nodeId = 1L;
|
||||
_vmMgr._workDao = _workDao;
|
||||
_vmMgr._agentMgr = _agentMgr;
|
||||
_vmMgr._podDao = _podDao;
|
||||
_vmMgr._clusterDao = _clusterDao;
|
||||
_vmMgr._dcDao = _dcDao;
|
||||
_vmMgr._diskOfferingDao = _diskOfferingDao;
|
||||
_vmMgr._storagePoolDao = _storagePoolDao;
|
||||
_vmMgr._poolHostDao= _poolHostDao;
|
||||
_vmMgr._networkMgr = _networkMgr;
|
||||
_vmMgr._hvGuruMgr = _hvGuruMgr;
|
||||
_vmMgr._vmSnapshotMgr = _vmSnapshotMgr;
|
||||
_vmMgr._vmDao = _vmInstanceDao;
|
||||
_vmMgr._configServer = _configServer;
|
||||
_vmMgr._uservmDetailsDao = _vmDetailsDao;
|
||||
_vmMgr._templateDao = _templateDao;
|
||||
_vmMgr._volsDao = _volsDao;
|
||||
_vmMgr.volumeMgr = _storageMgr;
|
||||
_vmMgr._accountDao = _accountDao;
|
||||
_vmMgr._accountMgr = _accountMgr;
|
||||
_vmMgr._configMgr = _configMgr;
|
||||
_vmMgr._capacityMgr = _capacityMgr;
|
||||
_vmMgr._hostDao = _hostDao;
|
||||
_vmMgr._nodeId = 1L;
|
||||
_vmMgr._workDao = _workDao;
|
||||
_vmMgr._agentMgr = _agentMgr;
|
||||
_vmMgr._podDao = _podDao;
|
||||
_vmMgr._clusterDao = _clusterDao;
|
||||
_vmMgr._dcDao = _dcDao;
|
||||
_vmMgr._diskOfferingDao = _diskOfferingDao;
|
||||
_vmMgr._storagePoolDao = _storagePoolDao;
|
||||
_vmMgr._poolHostDao = _poolHostDao;
|
||||
_vmMgr._networkMgr = _networkMgr;
|
||||
_vmMgr._hvGuruMgr = _hvGuruMgr;
|
||||
_vmMgr._vmSnapshotMgr = _vmSnapshotMgr;
|
||||
_vmMgr._vmDao = _vmInstanceDao;
|
||||
_vmMgr._configServer = _configServer;
|
||||
_vmMgr._uservmDetailsDao = _vmDetailsDao;
|
||||
|
||||
when(_vmMock.getId()).thenReturn(314l);
|
||||
when(_vmInstance.getId()).thenReturn(1L);
|
||||
when(_vmInstance.getServiceOfferingId()).thenReturn(2L);
|
||||
when(_vmInstance.getInstanceName()).thenReturn("myVm");
|
||||
when(_vmInstance.getHostId()).thenReturn(2L);
|
||||
when(_vmInstance.getType()).thenReturn(VirtualMachine.Type.User);
|
||||
when(_host.getId()).thenReturn(1L);
|
||||
when(_hostDao.findById(anyLong())).thenReturn(null);
|
||||
when(_configMgr.getServiceOffering(anyLong())).thenReturn(getSvcoffering(512));
|
||||
when(_workDao.persist(_work)).thenReturn(_work);
|
||||
when(_workDao.update("1", _work)).thenReturn(true);
|
||||
when(_work.getId()).thenReturn("1");
|
||||
doNothing().when(_work).setStep(ItWorkVO.Step.Done);
|
||||
when(_vmMock.getId()).thenReturn(314l);
|
||||
when(_vmInstance.getId()).thenReturn(1L);
|
||||
when(_vmInstance.getServiceOfferingId()).thenReturn(2L);
|
||||
when(_vmInstance.getInstanceName()).thenReturn("myVm");
|
||||
when(_vmInstance.getHostId()).thenReturn(2L);
|
||||
when(_vmInstance.getType()).thenReturn(VirtualMachine.Type.User);
|
||||
when(_host.getId()).thenReturn(1L);
|
||||
when(_hostDao.findById(anyLong())).thenReturn(null);
|
||||
when(_configMgr.getServiceOffering(anyLong())).thenReturn(getSvcoffering(512));
|
||||
when(_workDao.persist(_work)).thenReturn(_work);
|
||||
when(_workDao.update("1", _work)).thenReturn(true);
|
||||
when(_work.getId()).thenReturn("1");
|
||||
doNothing().when(_work).setStep(ItWorkVO.Step.Done);
|
||||
when(_vmInstanceDao.findByUuid(any(String.class))).thenReturn(_vmMock);
|
||||
//doNothing().when(_volsDao).detachVolume(anyLong());
|
||||
//when(_work.setStep(ItWorkVO.Step.Done)).thenReturn("1");
|
||||
//doNothing().when(_volsDao).detachVolume(anyLong());
|
||||
//when(_work.setStep(ItWorkVO.Step.Done)).thenReturn("1");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test(expected=CloudRuntimeException.class)
|
||||
public void testScaleVM1() throws Exception {
|
||||
}
|
||||
|
||||
@Test(expected = CloudRuntimeException.class)
|
||||
public void testScaleVM1() throws Exception {
|
||||
|
||||
DeployDestination dest = new DeployDestination(null, null, null, _host);
|
||||
long l = 1L;
|
||||
@ -242,8 +258,8 @@ public class VirtualMachineManagerImplTest {
|
||||
|
||||
}
|
||||
|
||||
@Test (expected=CloudRuntimeException.class)
|
||||
public void testScaleVM2() throws Exception {
|
||||
@Test(expected = CloudRuntimeException.class)
|
||||
public void testScaleVM2() throws Exception {
|
||||
|
||||
DeployDestination dest = new DeployDestination(null, null, null, _host);
|
||||
long l = 1L;
|
||||
@ -261,15 +277,16 @@ public class VirtualMachineManagerImplTest {
|
||||
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");
|
||||
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");
|
||||
when(_agentMgr.send(2l, reconfigureCmd)).thenReturn(null);
|
||||
_vmMgr.reConfigureVm(_vmInstance, getSvcoffering(256), false);
|
||||
|
||||
}
|
||||
|
||||
@Test (expected=CloudRuntimeException.class)
|
||||
public void testScaleVM3() throws Exception {
|
||||
@Test(expected = CloudRuntimeException.class)
|
||||
public void testScaleVM3() throws Exception {
|
||||
|
||||
/*VirtualMachineProfile profile = new VirtualMachineProfileImpl(vm);
|
||||
|
||||
@ -286,10 +303,9 @@ public class VirtualMachineManagerImplTest {
|
||||
|
||||
}
|
||||
|
||||
private ServiceOfferingVO getSvcoffering(int ramSize) {
|
||||
|
||||
private ServiceOfferingVO getSvcoffering(int ramSize){
|
||||
|
||||
long id = 4L;
|
||||
long id = 4L;
|
||||
String name = "name";
|
||||
String displayText = "displayText";
|
||||
int cpu = 1;
|
||||
@ -304,7 +320,7 @@ public class VirtualMachineManagerImplTest {
|
||||
}
|
||||
|
||||
private void initializeMockConfigForMigratingVmWithVolumes() throws OperationTimedoutException,
|
||||
ResourceUnavailableException {
|
||||
ResourceUnavailableException {
|
||||
|
||||
// Mock the source and destination hosts.
|
||||
when(_srcHostMock.getId()).thenReturn(5L);
|
||||
@ -316,7 +332,7 @@ public class VirtualMachineManagerImplTest {
|
||||
when(_vmMock.getId()).thenReturn(1L);
|
||||
when(_vmMock.getHypervisorType()).thenReturn(HypervisorType.XenServer);
|
||||
when(_vmMock.getState()).thenReturn(State.Running).thenReturn(State.Running).thenReturn(State.Migrating)
|
||||
.thenReturn(State.Migrating);
|
||||
.thenReturn(State.Migrating);
|
||||
when(_vmMock.getHostId()).thenReturn(5L);
|
||||
when(_vmInstance.getId()).thenReturn(1L);
|
||||
when(_vmInstance.getServiceOfferingId()).thenReturn(2L);
|
||||
@ -324,7 +340,7 @@ public class VirtualMachineManagerImplTest {
|
||||
when(_vmInstance.getHostId()).thenReturn(5L);
|
||||
when(_vmInstance.getType()).thenReturn(VirtualMachine.Type.User);
|
||||
when(_vmInstance.getState()).thenReturn(State.Running).thenReturn(State.Running).thenReturn(State.Migrating)
|
||||
.thenReturn(State.Migrating);
|
||||
.thenReturn(State.Migrating);
|
||||
|
||||
// Mock the work item.
|
||||
when(_workDao.persist(any(ItWorkVO.class))).thenReturn(_work);
|
||||
@ -392,43 +408,43 @@ public class VirtualMachineManagerImplTest {
|
||||
when(_agentMgr.send(anyLong(), isA(CheckVirtualMachineCommand.class))).thenReturn(checkVmAnswerMock);
|
||||
|
||||
// Mock the state transitions of vm.
|
||||
Pair<Long, Long> opaqueMock = new Pair<Long, Long> (_vmMock.getHostId(), _destHostMock.getId());
|
||||
Pair<Long, Long> opaqueMock = new Pair<Long, Long>(_vmMock.getHostId(), _destHostMock.getId());
|
||||
when(_vmSnapshotMgr.hasActiveVMSnapshotTasks(anyLong())).thenReturn(false);
|
||||
when(_vmInstanceDao.updateState(State.Running, Event.MigrationRequested, State.Migrating, _vmMock, opaqueMock))
|
||||
.thenReturn(true);
|
||||
.thenReturn(true);
|
||||
when(_vmInstanceDao.updateState(State.Migrating, Event.OperationSucceeded, State.Running, _vmMock, opaqueMock))
|
||||
.thenReturn(true);
|
||||
.thenReturn(true);
|
||||
}
|
||||
|
||||
// Check migration of a vm with its volumes within a cluster.
|
||||
@Test
|
||||
public void testMigrateWithVolumeWithinCluster() throws ResourceUnavailableException, ConcurrentOperationException,
|
||||
ManagementServerException, VirtualMachineMigrationException, OperationTimedoutException {
|
||||
ManagementServerException, VirtualMachineMigrationException, OperationTimedoutException {
|
||||
|
||||
initializeMockConfigForMigratingVmWithVolumes();
|
||||
when(_srcHostMock.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.
|
||||
@Test
|
||||
public void testMigrateWithVolumeAcrossCluster() throws ResourceUnavailableException, ConcurrentOperationException,
|
||||
ManagementServerException, VirtualMachineMigrationException, OperationTimedoutException {
|
||||
ManagementServerException, VirtualMachineMigrationException, OperationTimedoutException {
|
||||
|
||||
initializeMockConfigForMigratingVmWithVolumes();
|
||||
when(_srcHostMock.getClusterId()).thenReturn(3L);
|
||||
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
|
||||
// other is local.
|
||||
@Test(expected=CloudRuntimeException.class)
|
||||
@Test(expected = CloudRuntimeException.class)
|
||||
public void testMigrateWithVolumeFail1() throws ResourceUnavailableException, ConcurrentOperationException,
|
||||
ManagementServerException, VirtualMachineMigrationException, OperationTimedoutException {
|
||||
ManagementServerException, VirtualMachineMigrationException, OperationTimedoutException {
|
||||
|
||||
initializeMockConfigForMigratingVmWithVolumes();
|
||||
when(_srcHostMock.getClusterId()).thenReturn(3L);
|
||||
@ -437,13 +453,13 @@ public class VirtualMachineManagerImplTest {
|
||||
when(_destStoragePoolMock.isLocal()).thenReturn(true);
|
||||
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.
|
||||
@Test(expected=ConcurrentOperationException.class)
|
||||
@Test(expected = ConcurrentOperationException.class)
|
||||
public void testMigrateWithVolumeFail2() throws ResourceUnavailableException, ConcurrentOperationException,
|
||||
ManagementServerException, VirtualMachineMigrationException, OperationTimedoutException {
|
||||
ManagementServerException, VirtualMachineMigrationException, OperationTimedoutException {
|
||||
|
||||
initializeMockConfigForMigratingVmWithVolumes();
|
||||
when(_srcHostMock.getClusterId()).thenReturn(3L);
|
||||
@ -451,6 +467,6 @@ public class VirtualMachineManagerImplTest {
|
||||
|
||||
when(_vmMock.getState()).thenReturn(State.Stopped);
|
||||
|
||||
_vmMgr.migrateWithStorage(_vmInstance, _srcHostMock.getId(), _destHostMock.getId(), _volumeToPoolMock);
|
||||
_vmMgr.migrateWithStorage(_vmInstance.getUuid(), _srcHostMock.getId(), _destHostMock.getId(), _volumeToPoolMock);
|
||||
}
|
||||
}
|
||||
|
||||
@ -892,114 +892,6 @@ CREATE VIEW `cloud`.`host_view` AS
|
||||
and async_job.instance_type = 'Host'
|
||||
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`;
|
||||
CREATE VIEW `cloud`.`storage_pool_view` AS
|
||||
select
|
||||
@ -1780,6 +1672,7 @@ CREATE VIEW `cloud`.`volume_view` AS
|
||||
volumes.removed,
|
||||
volumes.pod_id,
|
||||
volumes.display_volume,
|
||||
volumes.format,
|
||||
account.id account_id,
|
||||
account.uuid account_uuid,
|
||||
account.account_name account_name,
|
||||
@ -1801,12 +1694,11 @@ CREATE VIEW `cloud`.`volume_view` AS
|
||||
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,
|
||||
volume_store_ref.size volume_store_size,
|
||||
volume_store_ref.download_pct,
|
||||
volume_store_ref.download_state,
|
||||
volume_store_ref.error_str,
|
||||
volume_store_ref.created created_on_store,
|
||||
disk_offering.id disk_offering_id,
|
||||
disk_offering.uuid disk_offering_uuid,
|
||||
disk_offering.name disk_offering_name,
|
||||
@ -1854,8 +1746,7 @@ CREATE VIEW `cloud`.`volume_view` AS
|
||||
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
|
||||
`cloud`.`volume_store_ref` ON volumes.id = volume_store_ref.volume_id
|
||||
left join
|
||||
`cloud`.`disk_offering` ON volumes.disk_offering_id = disk_offering.id
|
||||
left join
|
||||
|
||||
@ -876,10 +876,17 @@ class TestTemplateHierarchy(cloudstackTestCase):
|
||||
account=cls.account_1.name,
|
||||
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.account_2,
|
||||
cls.domain_2,
|
||||
cls.template,
|
||||
cls.template,
|
||||
cls.account_1,
|
||||
cls.domain_1,
|
||||
]
|
||||
@ -945,7 +952,8 @@ class TestTemplateHierarchy(cloudstackTestCase):
|
||||
# Verify private service offering is not visible to other domain
|
||||
templates = list_templates(
|
||||
self.apiclient,
|
||||
templatefilter='self',
|
||||
id=self.template.id,
|
||||
templatefilter='all',
|
||||
account=self.account_2.name,
|
||||
domainid=self.domain_2.id
|
||||
)
|
||||
@ -1819,7 +1827,7 @@ class TestDomainForceRemove(cloudstackTestCase):
|
||||
self.services["domain"],
|
||||
parentdomainid=self.domain.id
|
||||
)
|
||||
self._cleanup.append(domain)
|
||||
self.cleanup.append(domain)
|
||||
self.debug("Domain: %s is created successfully." % domain.name)
|
||||
self.debug(
|
||||
"Checking if the created domain is listed in list domains API")
|
||||
|
||||
@ -107,13 +107,13 @@ class TestASASetup(cloudstackTestCase):
|
||||
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.cleanup = []
|
||||
return
|
||||
|
||||
def tearDown(self):
|
||||
try:
|
||||
self.debug("Cleaning up the resources")
|
||||
# Cleanup
|
||||
cleanup_resources(self.apiclient, self._cleanup)
|
||||
cleanup_resources(self.apiclient, self.cleanup)
|
||||
self.debug("Cleanup complete!")
|
||||
except Exception as e:
|
||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||
|
||||
@ -103,9 +103,7 @@ class TestTemplate(cloudstackTestCase):
|
||||
|
||||
def tearDown(self):
|
||||
try:
|
||||
#Clean up, terminate the created templates
|
||||
cleanup_resources(self.apiclient, self.cleanup)
|
||||
|
||||
except Exception as e:
|
||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||
return
|
||||
@ -285,6 +283,13 @@ class TestNATRules(cloudstackTestCase):
|
||||
self.cleanup = []
|
||||
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
|
||||
def tearDownClass(cls):
|
||||
try:
|
||||
@ -293,10 +298,6 @@ class TestNATRules(cloudstackTestCase):
|
||||
except Exception as e:
|
||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||
|
||||
def tearDown(self):
|
||||
cleanup_resources(self.apiclient, self.cleanup)
|
||||
return
|
||||
|
||||
@attr(tags = ["advanced"])
|
||||
def test_01_firewall_rules_port_fw(self):
|
||||
""""Checking firewall rules deletion after static NAT disable"""
|
||||
@ -493,7 +494,6 @@ class TestRouters(cloudstackTestCase):
|
||||
|
||||
def tearDown(self):
|
||||
try:
|
||||
#Clean up, terminate the created instance, users etc
|
||||
cleanup_resources(self.apiclient, self.cleanup)
|
||||
except Exception as e:
|
||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||
@ -610,6 +610,10 @@ class TestRouterRestart(cloudstackTestCase):
|
||||
self.apiclient = self.testClient.getApiClient()
|
||||
return
|
||||
|
||||
def tearDown(self):
|
||||
# No need
|
||||
return
|
||||
|
||||
@attr(tags = ["advanced", "basic", "sg", "advancedns", "eip"])
|
||||
def test_01_restart_network_cleanup(self):
|
||||
"""TS_BUG_008-Test restart network
|
||||
|
||||
@ -1264,7 +1264,7 @@ class TestMultipleAccountsEgressRuleNeg(cloudstackTestCase):
|
||||
cls.services["account"],
|
||||
domainid=cls.domain.id
|
||||
)
|
||||
cls.services["account"] = cls.accountA.account.name
|
||||
cls.services["account"] = cls.accountA.name
|
||||
cls._cleanup = [
|
||||
cls.accountA,
|
||||
cls.accountB,
|
||||
@ -1308,16 +1308,16 @@ class TestMultipleAccountsEgressRuleNeg(cloudstackTestCase):
|
||||
security_group = SecurityGroup.create(
|
||||
self.apiclient,
|
||||
self.services["security_group"],
|
||||
account=self.accountA.account.name,
|
||||
domainid=self.accountA.account.domainid
|
||||
account=self.accountA.name,
|
||||
domainid=self.accountA.domainid
|
||||
)
|
||||
self.debug("Created security group with ID: %s" % security_group.id)
|
||||
|
||||
# Default Security group should not have any ingress rule
|
||||
sercurity_groups = SecurityGroup.list(
|
||||
self.apiclient,
|
||||
account=self.accountA.account.name,
|
||||
domainid=self.accountA.account.domainid
|
||||
account=self.accountA.name,
|
||||
domainid=self.accountA.domainid
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(sercurity_groups, list),
|
||||
@ -1335,13 +1335,13 @@ class TestMultipleAccountsEgressRuleNeg(cloudstackTestCase):
|
||||
"Authorizing egress rule for sec group ID: %s for ssh access"
|
||||
% security_group.id)
|
||||
# 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(
|
||||
self.apiclient,
|
||||
self.services["sg_account"],
|
||||
account=self.accountA.account.name,
|
||||
domainid=self.accountA.account.domainid,
|
||||
account=self.accountA.name,
|
||||
domainid=self.accountA.domainid,
|
||||
user_secgrp_list=user_secgrp_list
|
||||
)
|
||||
|
||||
@ -1359,8 +1359,8 @@ class TestMultipleAccountsEgressRuleNeg(cloudstackTestCase):
|
||||
ingress_rule = security_group.authorize(
|
||||
self.apiclient,
|
||||
self.services["security_group"],
|
||||
account=self.accountA.account.name,
|
||||
domainid=self.accountA.account.domainid
|
||||
account=self.accountA.name,
|
||||
domainid=self.accountA.domainid
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
@ -1374,13 +1374,13 @@ class TestMultipleAccountsEgressRuleNeg(cloudstackTestCase):
|
||||
self.virtual_machineA = VirtualMachine.create(
|
||||
self.apiclient,
|
||||
self.services["virtual_machine"],
|
||||
accountid=self.accountA.account.name,
|
||||
domainid=self.accountA.account.domainid,
|
||||
accountid=self.accountA.name,
|
||||
domainid=self.accountA.domainid,
|
||||
serviceofferingid=self.service_offering.id,
|
||||
securitygroupids=[security_group.id]
|
||||
)
|
||||
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(
|
||||
self.apiclient,
|
||||
id=self.virtual_machineA.id,
|
||||
@ -1402,12 +1402,12 @@ class TestMultipleAccountsEgressRuleNeg(cloudstackTestCase):
|
||||
self.virtual_machineB = VirtualMachine.create(
|
||||
self.apiclient,
|
||||
self.services["virtual_machine"],
|
||||
accountid=self.accountB.account.name,
|
||||
domainid=self.accountB.account.domainid,
|
||||
accountid=self.accountB.name,
|
||||
domainid=self.accountB.domainid,
|
||||
serviceofferingid=self.service_offering.id
|
||||
)
|
||||
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(
|
||||
self.apiclient,
|
||||
@ -1512,7 +1512,7 @@ class TestMultipleAccountsEgressRule(cloudstackTestCase):
|
||||
cls.services["account"],
|
||||
domainid=cls.domain.id
|
||||
)
|
||||
cls.services["account"] = cls.accountA.account.name
|
||||
cls.services["account"] = cls.accountA.name
|
||||
cls._cleanup = [
|
||||
cls.accountA,
|
||||
cls.accountB,
|
||||
@ -1556,16 +1556,16 @@ class TestMultipleAccountsEgressRule(cloudstackTestCase):
|
||||
security_groupA = SecurityGroup.create(
|
||||
self.apiclient,
|
||||
self.services["security_group"],
|
||||
account=self.accountA.account.name,
|
||||
domainid=self.accountA.account.domainid
|
||||
account=self.accountA.name,
|
||||
domainid=self.accountA.domainid
|
||||
)
|
||||
self.debug("Created security group with ID: %s" % security_groupA.id)
|
||||
|
||||
# Default Security group should not have any ingress rule
|
||||
sercurity_groups = SecurityGroup.list(
|
||||
self.apiclient,
|
||||
account=self.accountA.account.name,
|
||||
domainid=self.accountA.account.domainid
|
||||
account=self.accountA.name,
|
||||
domainid=self.accountA.domainid
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(sercurity_groups, list),
|
||||
@ -1582,16 +1582,16 @@ class TestMultipleAccountsEgressRule(cloudstackTestCase):
|
||||
security_groupB = SecurityGroup.create(
|
||||
self.apiclient,
|
||||
self.services["security_group"],
|
||||
account=self.accountB.account.name,
|
||||
domainid=self.accountB.account.domainid
|
||||
account=self.accountB.name,
|
||||
domainid=self.accountB.domainid
|
||||
)
|
||||
self.debug("Created security group with ID: %s" % security_groupB.id)
|
||||
|
||||
# Default Security group should not have any ingress rule
|
||||
sercurity_groups = SecurityGroup.list(
|
||||
self.apiclient,
|
||||
account=self.accountB.account.name,
|
||||
domainid=self.accountB.account.domainid
|
||||
account=self.accountB.name,
|
||||
domainid=self.accountB.domainid
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(sercurity_groups, list),
|
||||
@ -1610,13 +1610,13 @@ class TestMultipleAccountsEgressRule(cloudstackTestCase):
|
||||
"Authorizing egress rule for sec group ID: %s for ssh access"
|
||||
% security_groupA.id)
|
||||
# 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(
|
||||
self.apiclient,
|
||||
self.services["sg_account"],
|
||||
account=self.accountA.account.name,
|
||||
domainid=self.accountA.account.domainid,
|
||||
account=self.accountA.name,
|
||||
domainid=self.accountA.domainid,
|
||||
user_secgrp_list=user_secgrp_list
|
||||
)
|
||||
|
||||
@ -1634,8 +1634,8 @@ class TestMultipleAccountsEgressRule(cloudstackTestCase):
|
||||
ingress_ruleA = security_groupA.authorize(
|
||||
self.apiclient,
|
||||
self.services["security_group"],
|
||||
account=self.accountA.account.name,
|
||||
domainid=self.accountA.account.domainid
|
||||
account=self.accountA.name,
|
||||
domainid=self.accountA.domainid
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
@ -1649,13 +1649,13 @@ class TestMultipleAccountsEgressRule(cloudstackTestCase):
|
||||
self.virtual_machineA = VirtualMachine.create(
|
||||
self.apiclient,
|
||||
self.services["virtual_machine"],
|
||||
accountid=self.accountA.account.name,
|
||||
domainid=self.accountA.account.domainid,
|
||||
accountid=self.accountA.name,
|
||||
domainid=self.accountA.domainid,
|
||||
serviceofferingid=self.service_offering.id,
|
||||
securitygroupids=[security_groupA.id]
|
||||
)
|
||||
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(
|
||||
self.apiclient,
|
||||
@ -1682,8 +1682,8 @@ class TestMultipleAccountsEgressRule(cloudstackTestCase):
|
||||
ingress_ruleB = security_groupB.authorize(
|
||||
self.apiclient,
|
||||
self.services["security_group"],
|
||||
account=self.accountB.account.name,
|
||||
domainid=self.accountB.account.domainid
|
||||
account=self.accountB.name,
|
||||
domainid=self.accountB.domainid
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
@ -1697,13 +1697,13 @@ class TestMultipleAccountsEgressRule(cloudstackTestCase):
|
||||
self.virtual_machineB = VirtualMachine.create(
|
||||
self.apiclient,
|
||||
self.services["virtual_machine"],
|
||||
accountid=self.accountB.account.name,
|
||||
domainid=self.accountB.account.domainid,
|
||||
accountid=self.accountB.name,
|
||||
domainid=self.accountB.domainid,
|
||||
serviceofferingid=self.service_offering.id,
|
||||
securitygroupids=[security_groupB.id]
|
||||
)
|
||||
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(
|
||||
self.apiclient,
|
||||
|
||||
@ -783,21 +783,21 @@ class TestNetScalerSharedMode(cloudstackTestCase):
|
||||
self.network_3 = Network.create(
|
||||
self.apiclient,
|
||||
self.services["network"],
|
||||
accountid=self.account_3.account.name,
|
||||
domainid=self.account_3.account.domainid,
|
||||
accountid=self.account_3.name,
|
||||
domainid=self.account_3.domainid,
|
||||
networkofferingid=self.network_offering.id,
|
||||
zoneid=self.zone.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):
|
||||
# Spawn an instance in that network
|
||||
virtual_machine_3 = VirtualMachine.create(
|
||||
self.apiclient,
|
||||
self.services["virtual_machine"],
|
||||
accountid=self.account_3.account.name,
|
||||
domainid=self.account_3.account.domainid,
|
||||
accountid=self.account_3.name,
|
||||
domainid=self.account_3.domainid,
|
||||
serviceofferingid=self.service_offering.id,
|
||||
networkids=[str(self.network_3.id)]
|
||||
)
|
||||
@ -857,8 +857,8 @@ class TestNetScalerSharedMode(cloudstackTestCase):
|
||||
self.network_offering.id)
|
||||
networks = Network.list(
|
||||
self.apiclient,
|
||||
account=self.account_3.account.name,
|
||||
domainid=self.account_3.account.domainid,
|
||||
account=self.account_3.name,
|
||||
domainid=self.account_3.domainid,
|
||||
zoneid=self.zone.id,
|
||||
listall=True
|
||||
)
|
||||
@ -866,19 +866,19 @@ class TestNetScalerSharedMode(cloudstackTestCase):
|
||||
isinstance(networks, list),
|
||||
True,
|
||||
"Network should be present for the account: %s" %
|
||||
self.account_3.account.name
|
||||
self.account_3.name
|
||||
)
|
||||
self.network_3 = networks[0]
|
||||
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
|
||||
virtual_machine_3 = VirtualMachine.create(
|
||||
self.apiclient,
|
||||
self.services["virtual_machine"],
|
||||
accountid=self.account_3.account.name,
|
||||
domainid=self.account_3.account.domainid,
|
||||
accountid=self.account_3.name,
|
||||
domainid=self.account_3.domainid,
|
||||
serviceofferingid=self.service_offering.id,
|
||||
networkids=[str(self.network_3.id)]
|
||||
)
|
||||
@ -923,21 +923,21 @@ class TestNetScalerSharedMode(cloudstackTestCase):
|
||||
self.network_4 = Network.create(
|
||||
self.apiclient,
|
||||
self.services["network"],
|
||||
accountid=self.account_4.account.name,
|
||||
domainid=self.account_4.account.domainid,
|
||||
accountid=self.account_4.name,
|
||||
domainid=self.account_4.domainid,
|
||||
networkofferingid=self.network_offering.id,
|
||||
zoneid=self.zone.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
|
||||
virtual_machine_4 = VirtualMachine.create(
|
||||
self.apiclient,
|
||||
self.services["virtual_machine"],
|
||||
accountid=self.account_4.account.name,
|
||||
domainid=self.account_4.account.domainid,
|
||||
accountid=self.account_4.name,
|
||||
domainid=self.account_4.domainid,
|
||||
serviceofferingid=self.service_offering.id,
|
||||
networkids=[str(self.network_4.id)]
|
||||
)
|
||||
@ -970,22 +970,22 @@ class TestNetScalerSharedMode(cloudstackTestCase):
|
||||
self.network_5 = Network.create(
|
||||
self.apiclient,
|
||||
self.services["network"],
|
||||
accountid=self.account_5.account.name,
|
||||
domainid=self.account_5.account.domainid,
|
||||
accountid=self.account_5.name,
|
||||
domainid=self.account_5.domainid,
|
||||
networkofferingid=self.network_offering.id,
|
||||
zoneid=self.zone.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):
|
||||
# Spawn an instance in that network
|
||||
virtual_machine_5 = VirtualMachine.create(
|
||||
self.apiclient,
|
||||
self.services["virtual_machine"],
|
||||
accountid=self.account_5.account.name,
|
||||
domainid=self.account_5.account.domainid,
|
||||
accountid=self.account_5.name,
|
||||
domainid=self.account_5.domainid,
|
||||
serviceofferingid=self.service_offering.id,
|
||||
networkids=[str(self.network_5.id)]
|
||||
)
|
||||
@ -1005,9 +1005,9 @@ class TestNetScalerSharedMode(cloudstackTestCase):
|
||||
# 2. Create an instance from another account
|
||||
# 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.debug("Account: %s is deleted" % self.account_4.account.name)
|
||||
self.debug("Account: %s is deleted" % self.account_4.name)
|
||||
|
||||
interval = list_configurations(
|
||||
self.apiclient,
|
||||
@ -1027,21 +1027,21 @@ class TestNetScalerSharedMode(cloudstackTestCase):
|
||||
self.network_5 = Network.create(
|
||||
self.apiclient,
|
||||
self.services["network"],
|
||||
accountid=self.account_5.account.name,
|
||||
domainid=self.account_5.account.domainid,
|
||||
accountid=self.account_5.name,
|
||||
domainid=self.account_5.domainid,
|
||||
networkofferingid=self.network_offering.id,
|
||||
zoneid=self.zone.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
|
||||
virtual_machine_5 = VirtualMachine.create(
|
||||
self.apiclient,
|
||||
self.services["virtual_machine"],
|
||||
accountid=self.account_5.account.name,
|
||||
domainid=self.account_5.account.domainid,
|
||||
accountid=self.account_5.name,
|
||||
domainid=self.account_5.domainid,
|
||||
serviceofferingid=self.service_offering.id,
|
||||
networkids=[str(self.network_5.id)]
|
||||
)
|
||||
@ -1504,21 +1504,21 @@ class TestNwOffNetscaler(cloudstackTestCase):
|
||||
self.network_3 = Network.create(
|
||||
self.apiclient,
|
||||
self.services["network"],
|
||||
accountid=self.account_3.account.name,
|
||||
domainid=self.account_3.account.domainid,
|
||||
accountid=self.account_3.name,
|
||||
domainid=self.account_3.domainid,
|
||||
networkofferingid=self.network_offering_shared.id,
|
||||
zoneid=self.zone.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
|
||||
virtual_machine_3 = VirtualMachine.create(
|
||||
self.apiclient,
|
||||
self.services["virtual_machine"],
|
||||
accountid=self.account_3.account.name,
|
||||
domainid=self.account_3.account.domainid,
|
||||
accountid=self.account_3.name,
|
||||
domainid=self.account_3.domainid,
|
||||
serviceofferingid=self.service_offering.id,
|
||||
networkids=[str(self.network_3.id)]
|
||||
)
|
||||
@ -1803,20 +1803,20 @@ class TestNwOffSToDUpgrade(cloudstackTestCase):
|
||||
self.network_3 = Network.create(
|
||||
self.apiclient,
|
||||
self.services["network"],
|
||||
accountid=self.account_3.account.name,
|
||||
domainid=self.account_3.account.domainid,
|
||||
accountid=self.account_3.name,
|
||||
domainid=self.account_3.domainid,
|
||||
networkofferingid=self.network_offering_dedicated.id,
|
||||
zoneid=self.zone.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
|
||||
virtual_machine_3 = VirtualMachine.create(
|
||||
self.apiclient,
|
||||
self.services["virtual_machine"],
|
||||
accountid=self.account_3.account.name,
|
||||
domainid=self.account_3.account.domainid,
|
||||
accountid=self.account_3.name,
|
||||
domainid=self.account_3.domainid,
|
||||
serviceofferingid=self.service_offering.id,
|
||||
networkids=[str(self.network_3.id)]
|
||||
)
|
||||
@ -2220,20 +2220,20 @@ class TestNwOffDToSUpgrade(cloudstackTestCase):
|
||||
self.network_3 = Network.create(
|
||||
self.apiclient,
|
||||
self.services["network"],
|
||||
accountid=self.account_3.account.name,
|
||||
domainid=self.account_3.account.domainid,
|
||||
accountid=self.account_3.name,
|
||||
domainid=self.account_3.domainid,
|
||||
networkofferingid=self.network_offering_dedicated.id,
|
||||
zoneid=self.zone.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
|
||||
virtual_machine_3 = VirtualMachine.create(
|
||||
self.apiclient,
|
||||
self.services["virtual_machine"],
|
||||
accountid=self.account_3.account.name,
|
||||
domainid=self.account_3.account.domainid,
|
||||
accountid=self.account_3.name,
|
||||
domainid=self.account_3.domainid,
|
||||
serviceofferingid=self.service_offering.id,
|
||||
networkids=[str(self.network_3.id)]
|
||||
)
|
||||
@ -2261,7 +2261,7 @@ class TestNwOffDToSUpgrade(cloudstackTestCase):
|
||||
"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)
|
||||
|
||||
list_vm_response = VirtualMachine.list(
|
||||
@ -2314,7 +2314,7 @@ class TestNwOffDToSUpgrade(cloudstackTestCase):
|
||||
self.network_offering_shared.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)
|
||||
|
||||
list_vm_response = VirtualMachine.list(
|
||||
@ -2346,9 +2346,9 @@ class TestNwOffDToSUpgrade(cloudstackTestCase):
|
||||
|
||||
public_ip = PublicIPAddress.create(
|
||||
self.apiclient,
|
||||
accountid=self.account_3.account.name,
|
||||
accountid=self.account_3.name,
|
||||
zoneid=self.zone.id,
|
||||
domainid=self.account_3.account.domainid,
|
||||
domainid=self.account_3.domainid,
|
||||
networkid=self.network_3.id
|
||||
)
|
||||
self.debug(
|
||||
@ -2359,7 +2359,7 @@ class TestNwOffDToSUpgrade(cloudstackTestCase):
|
||||
self.apiclient,
|
||||
self.services["lbrule"],
|
||||
ipaddressid=public_ip.ipaddress.id,
|
||||
accountid=self.account_3.account.name,
|
||||
accountid=self.account_3.name,
|
||||
networkid=self.network_3.id
|
||||
)
|
||||
self.debug("Created the load balancing rule for public IP: %s" %
|
||||
|
||||
@ -485,7 +485,7 @@ class TestNetwork(cloudstackTestCase):
|
||||
networkofferingid=network_offering.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)
|
||||
|
||||
virtual_machine = VirtualMachine.create(
|
||||
@ -1044,7 +1044,6 @@ class TestPublicIpAddress(cloudstackTestCase):
|
||||
public_ip.ipaddress.id,
|
||||
projectid=self.project.id
|
||||
)
|
||||
self.cleanup.append(lb_rule)
|
||||
self.debug("Assigning VM: %s to LB rule: %s" % (
|
||||
self.virtual_machine.name,
|
||||
lb_rule.id
|
||||
|
||||
@ -165,7 +165,6 @@ class TestCreateRvRNetworkOffering(cloudstackTestCase):
|
||||
|
||||
def tearDown(self):
|
||||
try:
|
||||
#Clean up, terminate the created network offerings
|
||||
cleanup_resources(self.apiclient, self.cleanup)
|
||||
except Exception as e:
|
||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||
@ -284,7 +283,15 @@ class TestCreateRvRNetwork(cloudstackTestCase):
|
||||
admin=True,
|
||||
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
|
||||
|
||||
@attr(tags=["advanced", "advancedns", "ssh"])
|
||||
@ -475,7 +482,15 @@ class TestCreateRvRNetworkNonDefaultGuestCidr(cloudstackTestCase):
|
||||
admin=True,
|
||||
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
|
||||
|
||||
@attr(tags=["advanced", "advancedns"])
|
||||
@ -675,7 +690,15 @@ class TestRVRInternals(cloudstackTestCase):
|
||||
admin=True,
|
||||
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
|
||||
|
||||
@attr(tags=["advanced", "advancedns", "ssh"])
|
||||
@ -988,11 +1011,20 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
networkids=[str(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
|
||||
|
||||
@attr(tags=["advanced", "advancedns", "ssh"])
|
||||
def test_stopMasterRvR(self):
|
||||
def test_01_stopMasterRvR(self):
|
||||
"""Test stop master RVR
|
||||
"""
|
||||
|
||||
@ -1048,6 +1080,9 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
except Exception as 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)
|
||||
routers = Router.list(
|
||||
self.apiclient,
|
||||
@ -1089,6 +1124,9 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
except Exception as 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)
|
||||
routers = Router.list(
|
||||
self.apiclient,
|
||||
@ -1113,7 +1151,7 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
return
|
||||
|
||||
@attr(tags=["advanced", "advancedns", "ssh"])
|
||||
def test_stopBackupRvR(self):
|
||||
def test_02_stopBackupRvR(self):
|
||||
"""Test stop backup RVR
|
||||
"""
|
||||
|
||||
@ -1168,6 +1206,9 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
except Exception as 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)
|
||||
routers = Router.list(
|
||||
self.apiclient,
|
||||
@ -1209,6 +1250,9 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
except Exception as 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)
|
||||
routers = Router.list(
|
||||
self.apiclient,
|
||||
@ -1233,7 +1277,7 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
return
|
||||
|
||||
@attr(tags=["advanced", "advancedns", "ssh"])
|
||||
def test_rebootMasterRvR(self):
|
||||
def test_03_rebootMasterRvR(self):
|
||||
"""Test reboot master RVR
|
||||
"""
|
||||
|
||||
@ -1282,6 +1326,9 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
except Exception as 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)
|
||||
routers = Router.list(
|
||||
self.apiclient,
|
||||
@ -1323,7 +1370,7 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
return
|
||||
|
||||
@attr(tags=["advanced", "advancedns", "ssh"])
|
||||
def test_rebootBackupRvR(self):
|
||||
def test_04_rebootBackupRvR(self):
|
||||
"""Test reboot backup RVR
|
||||
"""
|
||||
|
||||
@ -1372,6 +1419,9 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
except Exception as 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)
|
||||
routers = Router.list(
|
||||
self.apiclient,
|
||||
@ -1413,7 +1463,7 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
return
|
||||
|
||||
@attr(tags=["advanced", "advancedns", "ssh"])
|
||||
def test_stopBackupRvR_startInstance(self):
|
||||
def test_05_stopBackupRvR_startInstance(self):
|
||||
"""Test stop backup RVR and start instance
|
||||
"""
|
||||
|
||||
@ -1462,6 +1512,9 @@ class TestRvRRedundancy(cloudstackTestCase):
|
||||
except Exception as 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)
|
||||
routers = Router.list(
|
||||
self.apiclient,
|
||||
|
||||
@ -189,7 +189,16 @@ class TestRedundantRouterNetworkCleanups(cloudstackTestCase):
|
||||
admin=True,
|
||||
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
|
||||
|
||||
@attr(tags=["advanced", "advancedns", "ssh"])
|
||||
@ -672,4 +681,4 @@ class TestRedundantRouterNetworkCleanups(cloudstackTestCase):
|
||||
"Stopped",
|
||||
"Router should be in stopped state"
|
||||
)
|
||||
return
|
||||
return
|
||||
|
||||
@ -188,7 +188,16 @@ class TestRvRDeploymentPlanning(cloudstackTestCase):
|
||||
admin=True,
|
||||
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
|
||||
|
||||
@attr(tags=["advanced", "advancedns"])
|
||||
@ -1003,4 +1012,4 @@ class TestRvRDeploymentPlanning(cloudstackTestCase):
|
||||
cmd.id = cluster.id
|
||||
cmd.allocationstate = 'Enabled'
|
||||
self.apiclient.updateCluster(cmd)
|
||||
return
|
||||
return
|
||||
|
||||
@ -188,7 +188,16 @@ class TestRedundantRouterRulesLifeCycle(cloudstackTestCase):
|
||||
admin=True,
|
||||
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
|
||||
|
||||
@attr(tags=["advanced", "advancedns", "ssh"])
|
||||
@ -1413,4 +1422,4 @@ class TestRedundantRouterRulesLifeCycle(cloudstackTestCase):
|
||||
"Running",
|
||||
"Router state should be running"
|
||||
)
|
||||
return
|
||||
return
|
||||
|
||||
@ -190,7 +190,14 @@ class TestEnableVPNOverRvR(cloudstackTestCase):
|
||||
admin=True,
|
||||
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
|
||||
|
||||
@attr(tags=["advanced", "advancedns", "ssh"])
|
||||
|
||||
@ -189,7 +189,15 @@ class TestRvRUpgradeDowngrade(cloudstackTestCase):
|
||||
admin=True,
|
||||
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
|
||||
|
||||
@attr(tags=["advanced", "advancedns", "ssh"])
|
||||
|
||||
@ -139,7 +139,7 @@ class TestRouterServices(cloudstackTestCase):
|
||||
domainid=cls.account.domainid,
|
||||
serviceofferingid=cls.service_offering.id
|
||||
)
|
||||
cls.cleanup = [
|
||||
cls._cleanup = [
|
||||
cls.account,
|
||||
cls.service_offering
|
||||
]
|
||||
@ -150,7 +150,7 @@ class TestRouterServices(cloudstackTestCase):
|
||||
try:
|
||||
cls.api_client = super(TestRouterServices, cls).getClsTestClient().getApiClient()
|
||||
#Clean up, terminate the created templates
|
||||
cleanup_resources(cls.api_client, cls.cleanup)
|
||||
cleanup_resources(cls.api_client, cls._cleanup)
|
||||
|
||||
except Exception as e:
|
||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||
@ -158,14 +158,14 @@ class TestRouterServices(cloudstackTestCase):
|
||||
|
||||
def tearDown(self):
|
||||
try:
|
||||
cleanup_resources(self.apiclient, self._cleanup)
|
||||
cleanup_resources(self.apiclient, self.cleanup)
|
||||
except Exception as e:
|
||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||
return
|
||||
|
||||
def setUp(self):
|
||||
self.apiclient = self.testClient.getApiClient()
|
||||
self._cleanup = []
|
||||
self.cleanup = []
|
||||
return
|
||||
|
||||
@attr(tags = ["advanced"])
|
||||
@ -470,7 +470,7 @@ class TestRouterServices(cloudstackTestCase):
|
||||
router.state
|
||||
))
|
||||
# Cleanup Vm_2 - Not required for further tests
|
||||
self._cleanup.append(self.vm_2)
|
||||
self.cleanup.append(self.vm_2)
|
||||
return
|
||||
|
||||
@attr(tags = ["advanced"])
|
||||
@ -619,7 +619,7 @@ class TestRouterStopCreatePF(cloudstackTestCase):
|
||||
domainid=cls.account.domainid,
|
||||
serviceofferingid=cls.service_offering.id
|
||||
)
|
||||
cls.cleanup = [
|
||||
cls._cleanup = [
|
||||
cls.account,
|
||||
cls.service_offering
|
||||
]
|
||||
@ -630,7 +630,7 @@ class TestRouterStopCreatePF(cloudstackTestCase):
|
||||
try:
|
||||
cls.api_client = super(TestRouterStopCreatePF, cls).getClsTestClient().getApiClient()
|
||||
# Clean up, terminate the created resources
|
||||
cleanup_resources(cls.api_client, cls.cleanup)
|
||||
cleanup_resources(cls.api_client, cls._cleanup)
|
||||
|
||||
except Exception as e:
|
||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||
@ -639,14 +639,14 @@ class TestRouterStopCreatePF(cloudstackTestCase):
|
||||
def tearDown(self):
|
||||
try:
|
||||
# Clean up, terminate the created resources
|
||||
cleanup_resources(self.apiclient, self._cleanup)
|
||||
cleanup_resources(self.apiclient, self.cleanup)
|
||||
except Exception as e:
|
||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||
return
|
||||
|
||||
def setUp(self):
|
||||
self.apiclient = self.testClient.getApiClient()
|
||||
self._cleanup = []
|
||||
self.cleanup = []
|
||||
return
|
||||
|
||||
@attr(tags = ["advanced", "advancedns"])
|
||||
@ -831,7 +831,7 @@ class TestRouterStopCreateLB(cloudstackTestCase):
|
||||
domainid=cls.account.domainid,
|
||||
serviceofferingid=cls.service_offering.id
|
||||
)
|
||||
cls.cleanup = [
|
||||
cls._cleanup = [
|
||||
cls.account,
|
||||
cls.service_offering
|
||||
]
|
||||
@ -842,7 +842,7 @@ class TestRouterStopCreateLB(cloudstackTestCase):
|
||||
try:
|
||||
cls.api_client = super(TestRouterStopCreateLB, cls).getClsTestClient().getApiClient()
|
||||
#Clean up, terminate the created resources
|
||||
cleanup_resources(cls.api_client, cls.cleanup)
|
||||
cleanup_resources(cls.api_client, cls._cleanup)
|
||||
|
||||
except Exception as e:
|
||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||
@ -850,14 +850,14 @@ class TestRouterStopCreateLB(cloudstackTestCase):
|
||||
|
||||
def tearDown(self):
|
||||
try:
|
||||
cleanup_resources(self.apiclient, self._cleanup)
|
||||
cleanup_resources(self.apiclient, self.cleanup)
|
||||
except Exception as e:
|
||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||
return
|
||||
|
||||
def setUp(self):
|
||||
self.apiclient = self.testClient.getApiClient()
|
||||
self._cleanup = []
|
||||
self.cleanup = []
|
||||
return
|
||||
|
||||
@attr(tags = ["advanced", "advancedns"])
|
||||
@ -1042,7 +1042,7 @@ class TestRouterStopCreateFW(cloudstackTestCase):
|
||||
domainid=cls.account.domainid,
|
||||
serviceofferingid=cls.service_offering.id
|
||||
)
|
||||
cls.cleanup = [
|
||||
cls._cleanup = [
|
||||
cls.account,
|
||||
cls.service_offering
|
||||
]
|
||||
@ -1053,7 +1053,7 @@ class TestRouterStopCreateFW(cloudstackTestCase):
|
||||
try:
|
||||
cls.api_client = super(TestRouterStopCreateFW, cls).getClsTestClient().getApiClient()
|
||||
#Clean up, terminate the created templates
|
||||
cleanup_resources(cls.api_client, cls.cleanup)
|
||||
cleanup_resources(cls.api_client, cls._cleanup)
|
||||
|
||||
except Exception as e:
|
||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||
@ -1061,14 +1061,14 @@ class TestRouterStopCreateFW(cloudstackTestCase):
|
||||
|
||||
def tearDown(self):
|
||||
try:
|
||||
cleanup_resources(self.apiclient, self._cleanup)
|
||||
cleanup_resources(self.apiclient, self.cleanup)
|
||||
except Exception as e:
|
||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||
return
|
||||
|
||||
def setUp(self):
|
||||
self.apiclient = self.testClient.getApiClient()
|
||||
self._cleanup = []
|
||||
self.cleanup = []
|
||||
return
|
||||
|
||||
@attr(tags = ["advanced", "advancedns"])
|
||||
|
||||
@ -136,7 +136,6 @@ class Services:
|
||||
},
|
||||
"ostype": 'CentOS 5.3 (64-bit)',
|
||||
# Cent OS 5.3 (64 bit)
|
||||
"sleep": 90,
|
||||
"timeout": 10,
|
||||
"mode": 'advanced'
|
||||
}
|
||||
@ -207,33 +206,35 @@ class TestSharedNetworks(cloudstackTestCase):
|
||||
vm.delete(self.api_client)
|
||||
except Exception as e:
|
||||
raise Exception("Warning: Exception during virtual machines cleanup : %s" % e)
|
||||
|
||||
|
||||
try:
|
||||
for project in self.cleanup_projects:
|
||||
project.delete(self.api_client)
|
||||
except Exception as e:
|
||||
raise Exception("Warning: Exception during project cleanup : %s" % e)
|
||||
|
||||
|
||||
try:
|
||||
for account in self.cleanup_accounts:
|
||||
account.delete(self.api_client)
|
||||
except Exception as e:
|
||||
raise Exception("Warning: Exception during account cleanup : %s" % e)
|
||||
|
||||
#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:
|
||||
for domain in self.cleanup_domains:
|
||||
domain.delete(self.api_client)
|
||||
except Exception as 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
|
||||
|
||||
@attr(tags=["advanced", "advancedns"])
|
||||
@ -322,9 +323,7 @@ class TestSharedNetworks(cloudstackTestCase):
|
||||
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(
|
||||
self.api_client,
|
||||
id=self.shared_network_offering.id
|
||||
@ -565,7 +564,7 @@ class TestSharedNetworks(cloudstackTestCase):
|
||||
# - conservemode = false
|
||||
# - specifyVlan = true
|
||||
# - specifyIpRanges = true
|
||||
# 4. Enable network offering - updateNetworkOffering - state=Enabled
|
||||
# 4. Create network offering - updateNetworkOffering - state=Enabled
|
||||
# 5. createNetwork
|
||||
# - name = mysharednetwork, displaytext = mysharednetwork
|
||||
# - vlan = 123 (say)
|
||||
@ -683,8 +682,8 @@ class TestSharedNetworks(cloudstackTestCase):
|
||||
conservemode=False
|
||||
)
|
||||
|
||||
self.cleanup.append(self.shared_network_offering)
|
||||
|
||||
|
||||
|
||||
#Verify that the network offering got created
|
||||
list_network_offerings_response = NetworkOffering.list(
|
||||
self.api_client,
|
||||
@ -750,7 +749,7 @@ class TestSharedNetworks(cloudstackTestCase):
|
||||
)
|
||||
|
||||
self.cleanup_networks.append(self.network)
|
||||
|
||||
|
||||
list_networks_response = Network.list(
|
||||
self.api_client,
|
||||
id=self.network.id
|
||||
@ -836,7 +835,7 @@ class TestSharedNetworks(cloudstackTestCase):
|
||||
|
||||
@attr(tags=["advanced", "advancedns"])
|
||||
def test_createSharedNetwork_accountSpecific(self):
|
||||
""" Test Shared Networm with scope account """
|
||||
""" Test Shared Network with scope account """
|
||||
|
||||
# Steps,
|
||||
# 1. create an Admin Account - admin-XABU1
|
||||
@ -966,9 +965,7 @@ class TestSharedNetworks(cloudstackTestCase):
|
||||
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(
|
||||
self.api_client,
|
||||
id=self.shared_network_offering.id
|
||||
@ -1292,8 +1289,7 @@ class TestSharedNetworks(cloudstackTestCase):
|
||||
conservemode=False
|
||||
)
|
||||
|
||||
self.cleanup.append(self.shared_network_offering)
|
||||
|
||||
|
||||
#Verify that the network offering got created
|
||||
list_network_offerings_response = NetworkOffering.list(
|
||||
self.api_client,
|
||||
@ -1354,6 +1350,7 @@ class TestSharedNetworks(cloudstackTestCase):
|
||||
self.network = Network.create(
|
||||
self.api_client,
|
||||
self.services["network"],
|
||||
accountid=self.domain_admin_account.name,
|
||||
domainid=self.dom_domain.id,
|
||||
networkofferingid=self.shared_network_offering.id,
|
||||
zoneid=self.zone.id
|
||||
@ -1405,6 +1402,7 @@ class TestSharedNetworks(cloudstackTestCase):
|
||||
networkids=self.network.id,
|
||||
serviceofferingid=self.service_offering.id
|
||||
)
|
||||
self.cleanup_vms.append(self.domain_user_account_virtual_machine)
|
||||
vms = VirtualMachine.list(
|
||||
self.api_client,
|
||||
id=self.domain_user_account_virtual_machine.id,
|
||||
@ -1433,6 +1431,7 @@ class TestSharedNetworks(cloudstackTestCase):
|
||||
networkids=self.network.id,
|
||||
serviceofferingid=self.service_offering.id
|
||||
)
|
||||
self.cleanup_vms.append(self.domain_admin_account_virtual_machine)
|
||||
vms = VirtualMachine.list(
|
||||
self.api_client,
|
||||
id=self.domain_admin_account_virtual_machine.id,
|
||||
@ -1612,8 +1611,7 @@ class TestSharedNetworks(cloudstackTestCase):
|
||||
conservemode=False
|
||||
)
|
||||
|
||||
self.cleanup.append(self.shared_network_offering)
|
||||
|
||||
|
||||
#Verify that the network offering got created
|
||||
list_network_offerings_response = NetworkOffering.list(
|
||||
self.api_client,
|
||||
@ -1836,8 +1834,7 @@ class TestSharedNetworks(cloudstackTestCase):
|
||||
conservemode=False
|
||||
)
|
||||
|
||||
self.cleanup.append(self.shared_network_offering)
|
||||
|
||||
|
||||
#Verify that the network offering got created
|
||||
list_network_offerings_response = NetworkOffering.list(
|
||||
self.api_client,
|
||||
@ -1996,8 +1993,7 @@ class TestSharedNetworks(cloudstackTestCase):
|
||||
conservemode=False
|
||||
)
|
||||
|
||||
self.cleanup.append(self.shared_network_offering)
|
||||
|
||||
|
||||
#Verify that the network offering got created
|
||||
list_network_offerings_response = NetworkOffering.list(
|
||||
self.api_client,
|
||||
@ -2115,7 +2111,7 @@ class TestSharedNetworks(cloudstackTestCase):
|
||||
# Validations,
|
||||
# 1. shared networks should be created successfully
|
||||
# 2. a. VM should deploy successfully
|
||||
# b. VM should bedeployed in both networks and have IP in both the networks
|
||||
# b. VM should be deployed in both networks and have IP in both the networks
|
||||
|
||||
#Create admin account
|
||||
self.admin_account = Account.create(
|
||||
@ -2181,8 +2177,7 @@ class TestSharedNetworks(cloudstackTestCase):
|
||||
conservemode=False
|
||||
)
|
||||
|
||||
self.cleanup.append(self.shared_network_offering)
|
||||
|
||||
|
||||
#Verify that the network offering got created
|
||||
list_network_offerings_response = NetworkOffering.list(
|
||||
self.api_client,
|
||||
@ -2377,7 +2372,7 @@ class TestSharedNetworks(cloudstackTestCase):
|
||||
# 2. isolated network should be created successfully
|
||||
# 3.
|
||||
# a. VM should deploy successfully
|
||||
# b. VM should bedeployed in both networks and have IP in both the networks
|
||||
# b. VM should be deployed in both networks and have IP in both the networks
|
||||
# 4. FW and PF should apply successfully, ssh into the VM should work over isolated network
|
||||
|
||||
#Create admin account
|
||||
@ -2394,7 +2389,7 @@ class TestSharedNetworks(cloudstackTestCase):
|
||||
list_accounts_response = Account.list(
|
||||
self.api_client,
|
||||
id=self.admin_account.id,
|
||||
liistall=True
|
||||
listall=True
|
||||
)
|
||||
self.assertEqual(
|
||||
isinstance(list_accounts_response, list),
|
||||
@ -2424,8 +2419,7 @@ class TestSharedNetworks(cloudstackTestCase):
|
||||
conservemode=False
|
||||
)
|
||||
|
||||
self.cleanup.append(self.shared_network_offering)
|
||||
|
||||
|
||||
#Verify that the network offering got created
|
||||
list_network_offerings_response = NetworkOffering.list(
|
||||
self.api_client,
|
||||
@ -2484,8 +2478,7 @@ class TestSharedNetworks(cloudstackTestCase):
|
||||
conservemode=False
|
||||
)
|
||||
|
||||
self.cleanup.append(self.isolated_network_offering)
|
||||
|
||||
|
||||
#Update network offering state from disabled to enabled.
|
||||
network_offering_update_response = NetworkOffering.update(
|
||||
self.isolated_network_offering,
|
||||
@ -2534,13 +2527,14 @@ class TestSharedNetworks(cloudstackTestCase):
|
||||
|
||||
physical_network = list_physical_networks_response[0]
|
||||
|
||||
#create network using the shared network offering created
|
||||
#create network using the shared network offering created
|
||||
self.services["network"]["acltype"] = "domain"
|
||||
self.services["network"]["networkofferingid"] = self.shared_network_offering.id
|
||||
self.services["network"]["physicalnetworkid"] = physical_network.id
|
||||
self.shared_network = Network.create(
|
||||
self.api_client,
|
||||
self.services["network"],
|
||||
accountid=self.admin_account.name,
|
||||
domainid=self.admin_account.domainid,
|
||||
networkofferingid=self.shared_network_offering.id,
|
||||
zoneid=self.zone.id
|
||||
@ -2597,15 +2591,16 @@ class TestSharedNetworks(cloudstackTestCase):
|
||||
)
|
||||
|
||||
self.debug("Isolated Network created: %s" % self.isolated_network.id)
|
||||
|
||||
self.shared_network_admin_account_virtual_machine = VirtualMachine.create(
|
||||
self.api_client,
|
||||
self.services["virtual_machine"],
|
||||
accountid=self.admin_account.name,
|
||||
domainid=self.admin_account.domainid,
|
||||
networkids=self.shared_network.id,
|
||||
serviceofferingid=self.service_offering.id
|
||||
)
|
||||
|
||||
self.shared_network_admin_account_virtual_machine =\
|
||||
VirtualMachine.create(
|
||||
self.api_client,
|
||||
self.services["virtual_machine"],
|
||||
accountid=self.admin_account.name,
|
||||
domainid=self.admin_account.domainid,
|
||||
networkids=self.shared_network.id,
|
||||
serviceofferingid=self.service_offering.id
|
||||
)
|
||||
vms = VirtualMachine.list(
|
||||
self.api_client,
|
||||
id=self.shared_network_admin_account_virtual_machine.id,
|
||||
@ -2623,16 +2618,18 @@ class TestSharedNetworks(cloudstackTestCase):
|
||||
)
|
||||
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.isolated_network_admin_account_virtual_machine = VirtualMachine.create(
|
||||
self.api_client,
|
||||
self.services["virtual_machine"],
|
||||
accountid=self.admin_account.name,
|
||||
domainid=self.admin_account.domainid,
|
||||
networkids=self.isolated_network.id,
|
||||
serviceofferingid=self.service_offering.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.isolated_network_admin_account_virtual_machine = \
|
||||
VirtualMachine.create(
|
||||
self.api_client,
|
||||
self.services["virtual_machine"],
|
||||
accountid=self.admin_account.name,
|
||||
domainid=self.admin_account.domainid,
|
||||
networkids=self.isolated_network.id,
|
||||
serviceofferingid=self.service_offering.id
|
||||
)
|
||||
vms = VirtualMachine.list(
|
||||
self.api_client,
|
||||
id=self.isolated_network_admin_account_virtual_machine.id,
|
||||
@ -2678,7 +2675,7 @@ class TestSharedNetworks(cloudstackTestCase):
|
||||
#Create Firewall rule on source NAT
|
||||
fw_rule = FireWallRule.create(
|
||||
self.api_client,
|
||||
ipaddressid=self.public_ip.ipaddress,
|
||||
ipaddressid=self.public_ip.ipaddress.id,
|
||||
protocol='TCP',
|
||||
cidrlist=[self.services["fw_rule"]["cidr"]],
|
||||
startport=self.services["fw_rule"]["startport"],
|
||||
@ -2782,8 +2779,7 @@ class TestSharedNetworks(cloudstackTestCase):
|
||||
conservemode=False
|
||||
)
|
||||
|
||||
self.cleanup.append(self.shared_network_offering)
|
||||
|
||||
|
||||
#Verify that the network offering got created
|
||||
list_network_offerings_response = NetworkOffering.list(
|
||||
self.api_client,
|
||||
@ -2927,9 +2923,7 @@ class TestSharedNetworks(cloudstackTestCase):
|
||||
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(
|
||||
self.api_client,
|
||||
id=self.shared_network_offering.id
|
||||
|
||||
@ -375,8 +375,8 @@ class TestSnapshots(cloudstackTestCase):
|
||||
#6. Mount/Attach volume to another server
|
||||
#7. Compare data
|
||||
|
||||
random_data_0 = random_gen(100)
|
||||
random_data_1 = random_gen(100)
|
||||
random_data_0 = random_gen(size=100)
|
||||
random_data_1 = random_gen(size=100)
|
||||
|
||||
volume = Volume.create(
|
||||
self.apiclient,
|
||||
@ -644,8 +644,8 @@ class TestSnapshots(cloudstackTestCase):
|
||||
"Check list response returns a valid list"
|
||||
)
|
||||
volume = volumes[0]
|
||||
random_data_0 = random_gen(100)
|
||||
random_data_1 = random_gen(100)
|
||||
random_data_0 = random_gen(size=100)
|
||||
random_data_1 = random_gen(size=100)
|
||||
try:
|
||||
ssh_client = self.virtual_machine.get_ssh_client()
|
||||
|
||||
@ -838,8 +838,8 @@ class TestSnapshots(cloudstackTestCase):
|
||||
#5. Login to newly created virtual machine
|
||||
#6. Compare data
|
||||
|
||||
random_data_0 = random_gen(100)
|
||||
random_data_1 = random_gen(100)
|
||||
random_data_0 = random_gen(size=100)
|
||||
random_data_1 = random_gen(size=100)
|
||||
|
||||
try:
|
||||
#Login to virtual machine
|
||||
|
||||
@ -240,7 +240,7 @@ class TestResourceTags(cloudstackTestCase):
|
||||
try:
|
||||
#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:
|
||||
raise Exception("Warning: Exception during cleanup : %s" % e)
|
||||
return
|
||||
|
||||
@ -160,6 +160,22 @@ class TestAttachVolume(cloudstackTestCase):
|
||||
self.dbclient = self.testClient.getDbConnection()
|
||||
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"])
|
||||
def test_01_volume_attach(self):
|
||||
"""Test Attach volumes (max capacity)
|
||||
@ -362,20 +378,6 @@ class TestAttachVolume(cloudstackTestCase):
|
||||
)
|
||||
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):
|
||||
|
||||
@classmethod
|
||||
|
||||
@ -223,7 +223,16 @@ class TestVPC(cloudstackTestCase):
|
||||
admin=True,
|
||||
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
|
||||
|
||||
def validate_vpc_offering(self, vpc_offering):
|
||||
@ -517,7 +526,7 @@ class TestVPC(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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]
|
||||
# Split the cidr to retrieve gateway
|
||||
@ -546,7 +555,7 @@ class TestVPC(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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
|
||||
self.debug("Creating network with network offering: %s" %
|
||||
@ -644,7 +653,7 @@ class TestVPC(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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]
|
||||
# Split the cidr to retrieve gateway
|
||||
@ -673,7 +682,7 @@ class TestVPC(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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
|
||||
self.debug("Creating network with network offering: %s" %
|
||||
@ -757,7 +766,7 @@ class TestVPC(cloudstackTestCase):
|
||||
self.apiclient,
|
||||
self.services["account"],
|
||||
)
|
||||
self._cleanup.append(self.user)
|
||||
self.cleanup.append(self.user)
|
||||
|
||||
self.services["vpc"]["cidr"] = "10.1.1.1/16"
|
||||
self.debug("creating a VPC network in the account: %s" %
|
||||
@ -833,7 +842,7 @@ class TestVPC(cloudstackTestCase):
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self._cleanup.append(vpc_off)
|
||||
self.cleanup.append(vpc_off)
|
||||
self.validate_vpc_offering(vpc_off)
|
||||
|
||||
self.debug("Enabling the VPC offering created")
|
||||
@ -859,7 +868,7 @@ class TestVPC(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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.apiclient,
|
||||
@ -868,7 +877,7 @@ class TestVPC(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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
|
||||
self.debug("Creating network with network offering: %s" %
|
||||
@ -1178,7 +1187,7 @@ class TestVPC(cloudstackTestCase):
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self._cleanup.append(vpc_off)
|
||||
self.cleanup.append(vpc_off)
|
||||
self.validate_vpc_offering(vpc_off)
|
||||
|
||||
self.debug("Enabling the VPC offering created")
|
||||
@ -1204,7 +1213,7 @@ class TestVPC(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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.apiclient,
|
||||
@ -1213,7 +1222,7 @@ class TestVPC(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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
|
||||
self.debug("Creating network with network offering: %s" %
|
||||
@ -1666,7 +1675,7 @@ class TestVPC(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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]
|
||||
# Split the cidr to retrieve gateway
|
||||
@ -1813,7 +1822,7 @@ class TestVPC(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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]
|
||||
# Split the cidr to retrieve gateway
|
||||
@ -1869,7 +1878,7 @@ class TestVPC(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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]
|
||||
# Split the cidr to retrieve gateway
|
||||
@ -1918,7 +1927,7 @@ class TestVPC(cloudstackTestCase):
|
||||
self.services["account"]
|
||||
)
|
||||
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.debug("creating a VPC network in the account: %s" %
|
||||
@ -1945,7 +1954,7 @@ class TestVPC(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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]
|
||||
# Split the cidr to retrieve gateway
|
||||
@ -1999,7 +2008,7 @@ class TestVPC(cloudstackTestCase):
|
||||
self.services["account"]
|
||||
)
|
||||
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.debug("creating a VPC network in the account: %s" %
|
||||
@ -2026,7 +2035,7 @@ class TestVPC(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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]
|
||||
# Split the cidr to retrieve gateway
|
||||
@ -2075,7 +2084,7 @@ class TestVPC(cloudstackTestCase):
|
||||
self.services["account"]
|
||||
)
|
||||
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.debug("creating a VPC network in the account: %s" %
|
||||
@ -2103,7 +2112,7 @@ class TestVPC(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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]
|
||||
# Split the cidr to retrieve gateway
|
||||
@ -2159,7 +2168,7 @@ class TestVPC(cloudstackTestCase):
|
||||
self.services["domain_admin"]
|
||||
)
|
||||
self.debug("Created account: %s" % domain_admin.name)
|
||||
self._cleanup.append(domain_admin)
|
||||
self.cleanup.append(domain_admin)
|
||||
da_apiclient = self.testClient.getUserApiClient(
|
||||
account=domain_admin.name,
|
||||
domain=domain_admin.domain,
|
||||
@ -2170,7 +2179,7 @@ class TestVPC(cloudstackTestCase):
|
||||
self.services["account"]
|
||||
)
|
||||
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.debug("creating a VPC network in the account: %s" %
|
||||
@ -2210,7 +2219,7 @@ class TestVPC(cloudstackTestCase):
|
||||
self.services["domain_admin"]
|
||||
)
|
||||
self.debug("Created account: %s" % domain_admin.name)
|
||||
self._cleanup.append(domain_admin)
|
||||
self.cleanup.append(domain_admin)
|
||||
da_apiclient = self.testClient.getUserApiClient(
|
||||
account=domain_admin.name,
|
||||
domain=self.services["domain"]["name"],
|
||||
@ -2221,7 +2230,7 @@ class TestVPC(cloudstackTestCase):
|
||||
self.services["account"]
|
||||
)
|
||||
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.debug("creating a VPC network in the account: %s" %
|
||||
@ -2248,7 +2257,7 @@ class TestVPC(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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]
|
||||
# Split the cidr to retrieve gateway
|
||||
@ -2359,7 +2368,7 @@ class TestVPC(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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]
|
||||
# Split the cidr to retrieve gateway
|
||||
|
||||
@ -227,7 +227,16 @@ class TestVPCNetwork(cloudstackTestCase):
|
||||
admin=True,
|
||||
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
|
||||
|
||||
def validate_vpc_offering(self, vpc_offering):
|
||||
@ -303,7 +312,7 @@ class TestVPCNetwork(cloudstackTestCase):
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self._cleanup.append(vpc_off)
|
||||
self.cleanup.append(vpc_off)
|
||||
self.validate_vpc_offering(vpc_off)
|
||||
|
||||
self.debug("Enabling the VPC offering created")
|
||||
@ -329,7 +338,7 @@ class TestVPCNetwork(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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
|
||||
self.debug("Creating network with network offering: %s" %
|
||||
@ -396,7 +405,7 @@ class TestVPCNetwork(cloudstackTestCase):
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self._cleanup.append(vpc_off)
|
||||
self.cleanup.append(vpc_off)
|
||||
self.validate_vpc_offering(vpc_off)
|
||||
|
||||
self.debug("Enabling the VPC offering created")
|
||||
@ -426,7 +435,7 @@ class TestVPCNetwork(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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
|
||||
self.debug("Creating network with network offering: %s" %
|
||||
@ -466,7 +475,7 @@ class TestVPCNetwork(cloudstackTestCase):
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self._cleanup.append(vpc_off)
|
||||
self.cleanup.append(vpc_off)
|
||||
self.validate_vpc_offering(vpc_off)
|
||||
|
||||
self.debug("Enabling the VPC offering created")
|
||||
@ -492,7 +501,7 @@ class TestVPCNetwork(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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
|
||||
self.debug("Creating network with network offering: %s" %
|
||||
@ -557,7 +566,7 @@ class TestVPCNetwork(cloudstackTestCase):
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self._cleanup.append(vpc_off)
|
||||
self.cleanup.append(vpc_off)
|
||||
self.validate_vpc_offering(vpc_off)
|
||||
|
||||
self.debug("Enabling the VPC offering created")
|
||||
@ -583,7 +592,7 @@ class TestVPCNetwork(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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
|
||||
self.debug("Creating network with network offering: %s" %
|
||||
@ -662,7 +671,7 @@ class TestVPCNetwork(cloudstackTestCase):
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self._cleanup.append(vpc_off)
|
||||
self.cleanup.append(vpc_off)
|
||||
self.validate_vpc_offering(vpc_off)
|
||||
|
||||
self.debug("Enabling the VPC offering created")
|
||||
@ -713,7 +722,7 @@ class TestVPCNetwork(cloudstackTestCase):
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self._cleanup.append(vpc_off)
|
||||
self.cleanup.append(vpc_off)
|
||||
self.validate_vpc_offering(vpc_off)
|
||||
|
||||
self.debug("Enabling the VPC offering created")
|
||||
@ -746,7 +755,7 @@ class TestVPCNetwork(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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
|
||||
self.debug("Creating network with network offering: %s" %
|
||||
@ -790,7 +799,7 @@ class TestVPCNetwork(cloudstackTestCase):
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self._cleanup.append(vpc_off)
|
||||
self.cleanup.append(vpc_off)
|
||||
self.validate_vpc_offering(vpc_off)
|
||||
|
||||
self.debug("Enabling the VPC offering created")
|
||||
@ -816,7 +825,7 @@ class TestVPCNetwork(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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
|
||||
self.debug("Creating network with network offering: %s" %
|
||||
@ -859,7 +868,7 @@ class TestVPCNetwork(cloudstackTestCase):
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self._cleanup.append(vpc_off)
|
||||
self.cleanup.append(vpc_off)
|
||||
self.validate_vpc_offering(vpc_off)
|
||||
|
||||
self.debug("Enabling the VPC offering created")
|
||||
@ -921,7 +930,7 @@ class TestVPCNetwork(cloudstackTestCase):
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self._cleanup.append(vpc_off)
|
||||
self.cleanup.append(vpc_off)
|
||||
self.validate_vpc_offering(vpc_off)
|
||||
|
||||
self.debug("Enabling the VPC offering created")
|
||||
@ -949,7 +958,7 @@ class TestVPCNetwork(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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
|
||||
self.debug(
|
||||
@ -991,7 +1000,7 @@ class TestVPCNetwork(cloudstackTestCase):
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self._cleanup.append(vpc_off)
|
||||
self.cleanup.append(vpc_off)
|
||||
self.validate_vpc_offering(vpc_off)
|
||||
|
||||
self.debug("Enabling the VPC offering created")
|
||||
@ -1075,7 +1084,16 @@ class TestVPCNetworkRanges(cloudstackTestCase):
|
||||
admin=True,
|
||||
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
|
||||
|
||||
def validate_vpc_offering(self, vpc_offering):
|
||||
@ -1144,7 +1162,7 @@ class TestVPCNetworkRanges(cloudstackTestCase):
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self._cleanup.append(vpc_off)
|
||||
self.cleanup.append(vpc_off)
|
||||
self.validate_vpc_offering(vpc_off)
|
||||
|
||||
self.debug("Enabling the VPC offering created")
|
||||
@ -1171,7 +1189,7 @@ class TestVPCNetworkRanges(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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
|
||||
self.debug("Creating network outside of the VPC's network")
|
||||
@ -1206,7 +1224,7 @@ class TestVPCNetworkRanges(cloudstackTestCase):
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self._cleanup.append(vpc_off)
|
||||
self.cleanup.append(vpc_off)
|
||||
self.validate_vpc_offering(vpc_off)
|
||||
|
||||
self.debug("Enabling the VPC offering created")
|
||||
@ -1233,7 +1251,7 @@ class TestVPCNetworkRanges(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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
|
||||
self.debug("Creating network outside of the VPC's network")
|
||||
@ -1268,7 +1286,7 @@ class TestVPCNetworkRanges(cloudstackTestCase):
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self._cleanup.append(vpc_off)
|
||||
self.cleanup.append(vpc_off)
|
||||
self.validate_vpc_offering(vpc_off)
|
||||
|
||||
self.debug("Enabling the VPC offering created")
|
||||
@ -1295,7 +1313,7 @@ class TestVPCNetworkRanges(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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
|
||||
self.debug("Creating network inside of the VPC's network")
|
||||
@ -1336,7 +1354,7 @@ class TestVPCNetworkRanges(cloudstackTestCase):
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self._cleanup.append(vpc_off)
|
||||
self.cleanup.append(vpc_off)
|
||||
self.validate_vpc_offering(vpc_off)
|
||||
|
||||
self.debug("Enabling the VPC offering created")
|
||||
@ -1363,7 +1381,7 @@ class TestVPCNetworkRanges(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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
|
||||
self.debug("Creating network with network offering: %s" %
|
||||
@ -1457,7 +1475,7 @@ class TestVPCNetworkRanges(cloudstackTestCase):
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self._cleanup.append(vpc_off)
|
||||
self.cleanup.append(vpc_off)
|
||||
self.validate_vpc_offering(vpc_off)
|
||||
|
||||
self.debug("Enabling the VPC offering created")
|
||||
@ -1484,7 +1502,7 @@ class TestVPCNetworkRanges(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
self.network_offering.update(self.apiclient, state='Enabled')
|
||||
self._cleanup.append(self.network_offering)
|
||||
self.cleanup.append(self.network_offering)
|
||||
|
||||
self.debug(
|
||||
"Creating the new account to create new network in VPC: %s" %
|
||||
@ -1570,7 +1588,16 @@ class TestVPCNetworkUpgrade(cloudstackTestCase):
|
||||
admin=True,
|
||||
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
|
||||
|
||||
def validate_vpc_offering(self, vpc_offering):
|
||||
@ -1647,7 +1674,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase):
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self._cleanup.append(vpc_off)
|
||||
self.cleanup.append(vpc_off)
|
||||
self.validate_vpc_offering(vpc_off)
|
||||
|
||||
self.debug("Enabling the VPC offering created")
|
||||
@ -1673,7 +1700,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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"]["serviceProviderList"] = {
|
||||
@ -1694,7 +1721,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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
|
||||
self.debug("Creating network with network offering: %s" %
|
||||
@ -1995,7 +2022,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase):
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self._cleanup.append(vpc_off)
|
||||
self.cleanup.append(vpc_off)
|
||||
self.validate_vpc_offering(vpc_off)
|
||||
|
||||
self.debug("Enabling the VPC offering created")
|
||||
@ -2021,7 +2048,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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"]["serviceProviderList"] = {
|
||||
@ -2042,7 +2069,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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
|
||||
self.debug("Creating network with network offering: %s" % nw_off.id)
|
||||
|
||||
@ -42,6 +42,7 @@ from marvin.integration.lib.common import (get_domain,
|
||||
get_template,
|
||||
cleanup_resources,
|
||||
list_routers)
|
||||
import socket
|
||||
|
||||
class Services:
|
||||
"""Test VPC network services Load Balancing Rules Test data
|
||||
@ -179,6 +180,9 @@ class TestVPCNetworkLBRules(cloudstackTestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
# We want to fail quicker if it's failure
|
||||
socket.setdefaulttimeout(60)
|
||||
|
||||
cls.api_client = super(
|
||||
TestVPCNetworkLBRules,
|
||||
cls
|
||||
@ -221,14 +225,14 @@ class TestVPCNetworkLBRules(cloudstackTestCase):
|
||||
admin=True,
|
||||
domainid=self.domain.id
|
||||
)
|
||||
self._cleanup = [self.account]
|
||||
self.cleanup = [self.account]
|
||||
self.debug("Creating a VPC offering..")
|
||||
self.vpc_off = VpcOffering.create(
|
||||
self.apiclient,
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self._cleanup.append(self.vpc_off)
|
||||
self.cleanup.append(self.vpc_off)
|
||||
self.debug("Enabling the VPC offering created")
|
||||
self.vpc_off.update(self.apiclient, state='Enabled')
|
||||
|
||||
@ -247,7 +251,7 @@ class TestVPCNetworkLBRules(cloudstackTestCase):
|
||||
def tearDown(self):
|
||||
try:
|
||||
#Clean up, terminate the created network offerings
|
||||
cleanup_resources(self.apiclient, self._cleanup)
|
||||
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)
|
||||
@ -294,6 +298,7 @@ class TestVPCNetworkLBRules(cloudstackTestCase):
|
||||
|
||||
def start_VPC_VRouter(self, router):
|
||||
# Start the VPC Router
|
||||
self.debug("Starting router ID: %s" % router.id)
|
||||
cmd = startRouter.startRouterCmd()
|
||||
cmd.id = router.id
|
||||
self.apiclient.startRouter(cmd)
|
||||
@ -400,7 +405,7 @@ class TestVPCNetworkLBRules(cloudstackTestCase):
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self._cleanup.append(vpc_off)
|
||||
self.cleanup.append(vpc_off)
|
||||
self.debug("Enabling the VPC offering created")
|
||||
vpc_off.update(self.apiclient, state='Enabled')
|
||||
|
||||
@ -426,7 +431,7 @@ class TestVPCNetworkLBRules(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
nw_off.update(self.apiclient, state='Enabled')
|
||||
self._cleanup.append(nw_off)
|
||||
self.cleanup.append(nw_off)
|
||||
self.debug('Created and Enabled NetworkOffering')
|
||||
|
||||
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.check_wget_from_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)
|
||||
return
|
||||
|
||||
@ -696,7 +701,7 @@ class TestVPCNetworkLBRules(cloudstackTestCase):
|
||||
self.debug('lb_rule_http=%s' % lb_rule_http.__dict__)
|
||||
self.check_wget_from_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)
|
||||
return
|
||||
|
||||
@ -727,8 +732,8 @@ class TestVPCNetworkLBRules(cloudstackTestCase):
|
||||
self.debug('lb_rule_http=%s' % lb_rule_http.__dict__)
|
||||
self.check_wget_from_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_http.delete()
|
||||
lb_rule_nat.delete(self.apiclient)
|
||||
lb_rule_http.delete(self.apiclient)
|
||||
self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=True)
|
||||
self.check_wget_from_vm(vm_1, public_ip_1, testnegative=True)
|
||||
return
|
||||
@ -760,8 +765,8 @@ class TestVPCNetworkLBRules(cloudstackTestCase):
|
||||
self.debug('lb_rule_http=%s' % lb_rule_http.__dict__)
|
||||
self.check_wget_from_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_http.delete()
|
||||
lb_rule_nat.delete(self.apiclient)
|
||||
lb_rule_http.delete(self.apiclient)
|
||||
self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=True)
|
||||
self.check_wget_from_vm(vm_1, public_ip_1, testnegative=True)
|
||||
return
|
||||
|
||||
@ -38,6 +38,7 @@ from marvin.integration.lib.common import (get_domain,
|
||||
get_template,
|
||||
cleanup_resources,
|
||||
list_routers)
|
||||
import socket
|
||||
|
||||
|
||||
class Services:
|
||||
@ -179,6 +180,9 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
# We want to fail quicker if it's failure
|
||||
socket.setdefaulttimeout(60)
|
||||
|
||||
cls.api_client = super(
|
||||
TestVPCNetworkPFRules,
|
||||
cls
|
||||
@ -294,6 +298,7 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
|
||||
|
||||
def start_vpcrouter(self, router):
|
||||
# Start the VPC Router
|
||||
self.debug("Starting router ID: %s" % router.id)
|
||||
cmd = startRouter.startRouterCmd()
|
||||
cmd.id = router.id
|
||||
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_wget_from_vm(vm_1, public_ip_1, testnegative=False)
|
||||
router = self.stop_vpcrouter()
|
||||
http_rule.delete()
|
||||
http_rule.delete(self.apiclient)
|
||||
self.start_vpcrouter(router)
|
||||
self.check_wget_from_vm(vm_1, public_ip_1, testnegative=True)
|
||||
return
|
||||
@ -663,7 +668,7 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
|
||||
#http_rule = self.create_egress_Internet_Rule(network_1)
|
||||
self.check_ssh_into_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)
|
||||
return
|
||||
|
||||
@ -695,8 +700,8 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
|
||||
self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=False)
|
||||
self.check_wget_from_vm(vm_1, public_ip_1, testnegative=False)
|
||||
router = self.stop_vpcrouter()
|
||||
http_rule.delete()
|
||||
nat_rule.delete()
|
||||
http_rule.delete(self.apiclient)
|
||||
nat_rule.delete(self.apiclient)
|
||||
self.start_vpcrouter(router)
|
||||
self.check_ssh_into_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)
|
||||
self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=False)
|
||||
self.check_wget_from_vm(vm_1, public_ip_1, testnegative=False)
|
||||
http_rule.delete()
|
||||
nat_rule.delete()
|
||||
http_rule.delete(self.apiclient)
|
||||
nat_rule.delete(self.apiclient)
|
||||
self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=True)
|
||||
self.check_wget_from_vm(vm_1, public_ip_1, testnegative=True)
|
||||
return
|
||||
@ -764,34 +769,40 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
|
||||
public_ip_2 = self.acquire_publicip(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)
|
||||
http_rule1 = self.open_egress_to_world(network_1)
|
||||
nat_rule3 = self.create_natrule(vm_3, public_ip_1, network_2)
|
||||
nat_rule4 = self.create_natrule(vm_4, public_ip_2, network_2)
|
||||
http_rule2 = self.open_egress_to_world(network_2)
|
||||
http_rule1 = self.create_natrule(vm_1, public_ip_1, network_1, self.services["http_rule"])
|
||||
http_rule2 = self.create_natrule(vm_2, public_ip_2, network_1, self.services["http_rule"])
|
||||
public_ip_3 = self.acquire_publicip(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_2, public_ip_2, testnegative=False)
|
||||
self.check_ssh_into_vm(vm_3, public_ip_1, testnegative=False)
|
||||
self.check_ssh_into_vm(vm_4, public_ip_2, testnegative=False)
|
||||
self.check_ssh_into_vm(vm_3, public_ip_3, 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_2, public_ip_2, 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_3, public_ip_3, testnegative=False)
|
||||
self.check_wget_from_vm(vm_4, public_ip_4, testnegative=False)
|
||||
router = self.stop_vpcrouter()
|
||||
nat_rule1.delete()
|
||||
nat_rule2.delete()
|
||||
nat_rule3.delete()
|
||||
nat_rule4.delete()
|
||||
http_rule1.delete()
|
||||
http_rule2.delete()
|
||||
nat_rule1.delete(self.apiclient)
|
||||
nat_rule2.delete(self.apiclient)
|
||||
nat_rule3.delete(self.apiclient)
|
||||
nat_rule4.delete(self.apiclient)
|
||||
http_rule1.delete(self.apiclient)
|
||||
http_rule2.delete(self.apiclient)
|
||||
http_rule3.delete(self.apiclient)
|
||||
http_rule4.delete(self.apiclient)
|
||||
self.start_vpcrouter(router)
|
||||
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_3, public_ip_1, testnegative=True)
|
||||
self.check_ssh_into_vm(vm_4, public_ip_2, testnegative=True)
|
||||
self.check_ssh_into_vm(vm_3, public_ip_3, 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_2, public_ip_2, testnegative=True)
|
||||
self.check_wget_from_vm(vm_3, public_ip_1, testnegative=True)
|
||||
self.check_wget_from_vm(vm_4, public_ip_2, testnegative=True)
|
||||
self.check_wget_from_vm(vm_3, public_ip_3, testnegative=True)
|
||||
self.check_wget_from_vm(vm_4, public_ip_4, testnegative=True)
|
||||
return
|
||||
|
||||
@attr(tags=["advanced", "intervlan"])
|
||||
@ -822,30 +833,36 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
|
||||
public_ip_2 = self.acquire_publicip(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)
|
||||
http_rule1 = self.open_egress_to_world(network_1)
|
||||
nat_rule3 = self.create_natrule(vm_3, public_ip_1, network_2)
|
||||
nat_rule4 = self.create_natrule(vm_4, public_ip_2, network_2)
|
||||
http_rule2 = self.open_egress_to_world(network_2)
|
||||
http_rule1 = self.create_natrule(vm_1, public_ip_1, network_1, self.services["http_rule"])
|
||||
http_rule2 = self.create_natrule(vm_2, public_ip_2, network_1, self.services["http_rule"])
|
||||
public_ip_3 = self.acquire_publicip(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_2, public_ip_2, testnegative=False)
|
||||
self.check_ssh_into_vm(vm_3, public_ip_1, testnegative=False)
|
||||
self.check_ssh_into_vm(vm_4, public_ip_2, testnegative=False)
|
||||
self.check_ssh_into_vm(vm_3, public_ip_3, 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_2, public_ip_2, 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)
|
||||
nat_rule1.delete()
|
||||
nat_rule2.delete()
|
||||
nat_rule3.delete()
|
||||
nat_rule4.delete()
|
||||
http_rule1.delete()
|
||||
http_rule2.delete()
|
||||
self.check_wget_from_vm(vm_3, public_ip_3, testnegative=False)
|
||||
self.check_wget_from_vm(vm_4, public_ip_4, testnegative=False)
|
||||
nat_rule1.delete(self.apiclient)
|
||||
nat_rule2.delete(self.apiclient)
|
||||
nat_rule3.delete(self.apiclient)
|
||||
nat_rule4.delete(self.apiclient)
|
||||
http_rule1.delete(self.apiclient)
|
||||
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_2, public_ip_2, testnegative=True)
|
||||
self.check_ssh_into_vm(vm_3, public_ip_1, testnegative=True)
|
||||
self.check_ssh_into_vm(vm_4, public_ip_2, testnegative=True)
|
||||
self.check_ssh_into_vm(vm_3, public_ip_3, 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_2, public_ip_2, testnegative=True)
|
||||
self.check_wget_from_vm(vm_3, public_ip_1, testnegative=True)
|
||||
self.check_wget_from_vm(vm_4, public_ip_2, testnegative=True)
|
||||
self.check_wget_from_vm(vm_3, public_ip_3, testnegative=True)
|
||||
self.check_wget_from_vm(vm_4, public_ip_4, testnegative=True)
|
||||
return
|
||||
|
||||
@ -38,6 +38,7 @@ from marvin.integration.lib.common import (get_domain,
|
||||
get_template,
|
||||
cleanup_resources,
|
||||
list_routers)
|
||||
import socket
|
||||
|
||||
|
||||
class Services:
|
||||
@ -178,6 +179,9 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
# We want to fail quicker if it's failure
|
||||
socket.setdefaulttimeout(60)
|
||||
|
||||
cls.api_client = super(
|
||||
TestVPCNetworkPFRules,
|
||||
cls
|
||||
@ -220,14 +224,14 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
|
||||
admin=True,
|
||||
domainid=self.domain.id
|
||||
)
|
||||
self._cleanup = [self.account]
|
||||
self.cleanup = [self.account]
|
||||
self.debug("Creating a VPC offering..")
|
||||
self.vpc_off = VpcOffering.create(
|
||||
self.apiclient,
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self._cleanup.append(self.vpc_off)
|
||||
self.cleanup.append(self.vpc_off)
|
||||
self.debug("Enabling the VPC offering created")
|
||||
self.vpc_off.update(self.apiclient, state='Enabled')
|
||||
|
||||
@ -246,7 +250,7 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
|
||||
def tearDown(self):
|
||||
try:
|
||||
#Clean up, terminate the created network offerings
|
||||
cleanup_resources(self.apiclient, self._cleanup)
|
||||
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)
|
||||
@ -401,7 +405,7 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self._cleanup.append(self.vpc_off)
|
||||
self.cleanup.append(self.vpc_off)
|
||||
self.debug("Enabling the VPC offering created")
|
||||
vpc_off.update(self.apiclient, state='Enabled')
|
||||
|
||||
@ -427,7 +431,7 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
nw_off.update(self.apiclient, state='Enabled')
|
||||
self._cleanup.append(nw_off)
|
||||
self.cleanup.append(nw_off)
|
||||
self.debug('Created and Enabled NetworkOffering')
|
||||
|
||||
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"])
|
||||
self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=False)
|
||||
self.check_wget_from_vm(vm_1, public_ip_1, testnegative=False)
|
||||
http_rule.delete()
|
||||
nat_rule.delete()
|
||||
http_rule.delete(self.apiclient)
|
||||
nat_rule.delete(self.apiclient)
|
||||
self.check_ssh_into_vm(vm_1, public_ip_1, testnegative=True)
|
||||
self.check_wget_from_vm(vm_1, public_ip_1, testnegative=True)
|
||||
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_3, public_ip_1, testnegative=False)
|
||||
self.check_wget_from_vm(vm_4, public_ip_2, testnegative=False)
|
||||
nat_rule1.delete()
|
||||
nat_rule2.delete()
|
||||
nat_rule3.delete()
|
||||
nat_rule4.delete()
|
||||
http_rule1.delete()
|
||||
http_rule2.delete()
|
||||
nat_rule1.delete(self.apiclient)
|
||||
nat_rule2.delete(self.apiclient)
|
||||
nat_rule3.delete(self.apiclient)
|
||||
nat_rule4.delete(self.apiclient)
|
||||
http_rule1.delete(self.apiclient)
|
||||
http_rule2.delete(self.apiclient)
|
||||
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_3, public_ip_1, testnegative=True)
|
||||
|
||||
@ -180,7 +180,15 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
admin=True,
|
||||
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
|
||||
|
||||
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._cleanup.append(vpc_off)
|
||||
self.cleanup.append(vpc_off)
|
||||
self.validate_vpc_offering(vpc_off)
|
||||
return
|
||||
|
||||
@ -270,7 +278,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self._cleanup.append(vpc_off)
|
||||
self.cleanup.append(vpc_off)
|
||||
self.validate_vpc_offering(vpc_off)
|
||||
|
||||
self.debug("Enabling the VPC offering created")
|
||||
@ -295,7 +303,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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]
|
||||
# Split the cidr to retrieve gateway
|
||||
@ -544,14 +552,14 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
self.network_offering.update(self.apiclient, state='Enabled')
|
||||
self._cleanup.append(self.network_offering)
|
||||
self.cleanup.append(self.network_offering)
|
||||
|
||||
vpc_off = VpcOffering.create(
|
||||
self.apiclient,
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self._cleanup.append(vpc_off)
|
||||
self.cleanup.append(vpc_off)
|
||||
self.validate_vpc_offering(vpc_off)
|
||||
|
||||
self.debug("Enabling the VPC offering created")
|
||||
@ -663,14 +671,14 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
self.network_offering.update(self.apiclient, state='Enabled')
|
||||
self._cleanup.append(self.network_offering)
|
||||
self.cleanup.append(self.network_offering)
|
||||
|
||||
vpc_off = VpcOffering.create(
|
||||
self.apiclient,
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self._cleanup.append(vpc_off)
|
||||
self.cleanup.append(vpc_off)
|
||||
self.validate_vpc_offering(vpc_off)
|
||||
|
||||
self.debug("Enabling the VPC offering created")
|
||||
@ -784,14 +792,14 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
self.network_offering.update(self.apiclient, state='Enabled')
|
||||
self._cleanup.append(self.network_offering)
|
||||
self.cleanup.append(self.network_offering)
|
||||
|
||||
vpc_off = VpcOffering.create(
|
||||
self.apiclient,
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self._cleanup.append(vpc_off)
|
||||
self.cleanup.append(vpc_off)
|
||||
self.validate_vpc_offering(vpc_off)
|
||||
|
||||
self.debug("Enabling the VPC offering created")
|
||||
@ -904,7 +912,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
)
|
||||
self.validate_vpc_offering(vpc_off)
|
||||
# Appending to cleanup to delete after test
|
||||
self._cleanup.append(vpc_off)
|
||||
self.cleanup.append(vpc_off)
|
||||
except Exception as e:
|
||||
self.fail("Failed to create the VPC offering - %s" % e)
|
||||
return
|
||||
@ -928,7 +936,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self._cleanup.append(vpc_off)
|
||||
self.cleanup.append(vpc_off)
|
||||
self.validate_vpc_offering(vpc_off)
|
||||
|
||||
self.debug("Enabling the VPC offering created")
|
||||
@ -1024,7 +1032,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
self.apiclient,
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
self._cleanup.append(vpc_off_1)
|
||||
self.cleanup.append(vpc_off_1)
|
||||
self.validate_vpc_offering(vpc_off_1)
|
||||
self.debug("Disabling the VPC offering created")
|
||||
vpc_off_1.update(self.apiclient, state='Disabled')
|
||||
@ -1034,7 +1042,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self._cleanup.append(vpc_off_2)
|
||||
self.cleanup.append(vpc_off_2)
|
||||
self.validate_vpc_offering(vpc_off_2)
|
||||
self.debug("Enabling the VPC offering created")
|
||||
vpc_off_2.update(self.apiclient, state='Enabled')
|
||||
@ -1044,7 +1052,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
|
||||
self._cleanup.append(vpc_off_3)
|
||||
self.cleanup.append(vpc_off_3)
|
||||
self.validate_vpc_offering(vpc_off_3)
|
||||
self.debug("Enabling the VPC offering created")
|
||||
vpc_off_3.update(self.apiclient, state='Enabled')
|
||||
@ -1053,7 +1061,7 @@ class TestVPCOffering(cloudstackTestCase):
|
||||
self.apiclient,
|
||||
self.services["vpc_offering"]
|
||||
)
|
||||
self._cleanup.append(vpc_off_4)
|
||||
self.cleanup.append(vpc_off_4)
|
||||
self.debug("Enabling the VPC offering created")
|
||||
vpc_off_4.update(self.apiclient, state='Enabled')
|
||||
|
||||
|
||||
@ -354,7 +354,7 @@ class TestVMDeployVPC(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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
|
||||
self.debug("Creating network with network offering: %s" %
|
||||
@ -569,7 +569,7 @@ class TestVMDeployVPC(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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
|
||||
self.debug("Creating network with network offering: %s" %
|
||||
@ -822,7 +822,7 @@ class TestVMDeployVPC(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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
|
||||
self.debug("Creating network with network offering: %s" %
|
||||
@ -1091,7 +1091,7 @@ class TestVMDeployVPC(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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
|
||||
self.debug("Creating network with network offering: %s" %
|
||||
@ -1375,7 +1375,7 @@ class TestVMDeployVPC(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
nw_off_no_lb.update(self.apiclient, state='Enabled')
|
||||
self._cleanup.append(nw_off)
|
||||
self._cleanup.append(nw_off_no_lb)
|
||||
|
||||
configs = Configurations.list(
|
||||
self.apiclient,
|
||||
@ -1546,7 +1546,7 @@ class TestVMDeployVPC(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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
|
||||
self.debug("Creating network with network offering: %s" %
|
||||
@ -1810,7 +1810,7 @@ class TestVMDeployVPC(cloudstackTestCase):
|
||||
)
|
||||
# Enable Network offering
|
||||
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
|
||||
self.debug("Creating network with network offering: %s" %
|
||||
|
||||
@ -120,7 +120,7 @@ class TestVmSnapshot(cloudstackTestCase):
|
||||
serviceofferingid=cls.service_offering.id,
|
||||
mode=cls.services["mode"]
|
||||
)
|
||||
cls.random_data_0 = random_gen(100)
|
||||
cls.random_data_0 = random_gen(size=100)
|
||||
cls._cleanup = [
|
||||
cls.service_offering,
|
||||
cls.account,
|
||||
|
||||