Merge branch 'master' into ui-cisco-asa1000v-support

This commit is contained in:
Brian Federle 2013-04-18 10:50:07 -07:00
commit 9a876ca9ce
13 changed files with 343 additions and 96 deletions

View File

@ -64,7 +64,6 @@ public class AffinityGroupResponse extends BaseResponse implements ControlledVie
private List<String> vmIdList;
public AffinityGroupResponse() {
this.vmIdList = new ArrayList<String>();
}
@Override
@ -149,6 +148,10 @@ public class AffinityGroupResponse extends BaseResponse implements ControlledVie
}
public void addVMId(String vmId) {
if (this.vmIdList == null) {
this.vmIdList = new ArrayList<String>();
}
this.vmIdList.add(vmId);
}

View File

@ -230,7 +230,7 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
for (String groupName : securityGroupNameList) {
Long groupId = _responseGenerator.getSecurityGroupId(groupName, getEntityOwnerId());
if (groupId == null) {
throw new InvalidParameterValueException("Unable to find group by name " + groupName + " for account " + getEntityOwnerId());
throw new InvalidParameterValueException("Unable to find group by name " + groupName);
} else {
securityGroupIds.add(groupId);
}
@ -344,8 +344,7 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
for (String groupName : affinityGroupNameList) {
Long groupId = _responseGenerator.getAffinityGroupId(groupName, getEntityOwnerId());
if (groupId == null) {
throw new InvalidParameterValueException("Unable to find group by name " + groupName
+ " for account " + getEntityOwnerId());
throw new InvalidParameterValueException("Unable to find affinity group by name " + groupName);
} else {
affinityGroupIds.add(groupId);
}

View File

@ -4181,17 +4181,17 @@ under the License.
<listitem>
<para>Restart the agent:</para>
<programlisting language="Bash">
service cloud-agent stop
killall jsvc
service cloudstack-agent start
service cloud-agent stop
killall jsvc
service cloudstack-agent start
</programlisting>
</listitem>
<listitem>
<para>During the upgrade, <filename>log4j-cloud.xml</filename> was simply copied over, so the logs will continue to be added to <filename>/var/log/cloud/agent/agent.log</filename>. There's nothing <emphasis>wrong</emphasis> with this, but if you prefer to be consistent, you can change this by copying over the sample configuration file:</para>
<programlisting language="Bash">
cd /etc/cloudstack/agent
mv log4j-cloud.xml.dpkg-dist log4j-cloud.xml
service cloudstack-agent restart
cd /etc/cloudstack/agent
mv log4j-cloud.xml.dpkg-dist log4j-cloud.xml
service cloudstack-agent restart
</programlisting>
</listitem>
<listitem>
@ -4201,22 +4201,63 @@ under the License.
</orderedlist>
</listitem>
<listitem id="upgrade-rpm-packages">
<para>The package names have changed between 4.0 and 4.1, so upgrading the packages won't happen automatically with a <command>yum update</command></para>
<para>If you are using CentOS or RHEL, follow this procedure to upgrade your packages. If not, skip to step <xref linkend="restart-system-vms" />.</para>
<note><title>Community Packages</title>
<para>This section assumes you're using the community supplied packages for &PRODUCT;. If you've created your own packages and yum repository, substitute your own URL for the ones used in these examples.</para>
</note>
<orderedlist id="rpmsteps">
<listitem>
<para>The first order of business will be to change the yum repository for each system with &PRODUCT; packages. This means all management servers, and any hosts that have the KVM agent. (No changes should be necessary for hosts that are running VMware or Xen.)</para>
<para>Start by opening <filename>/etc/yum.repos.d/cloudstack.repo</filename> on any systems that have &PRODUCT; packages installed.</para>
<para>This file should have content similar to the following:</para>
<programlisting language="Bash">
[apache-cloudstack]
name=Apache CloudStack
baseurl=http://cloudstack.apt-get.eu/rhel/4.0/
enabled=1
gpgcheck=0
</programlisting>
<para>If you are using the community provided package repository, change the baseurl to http://cloudstack.apt-get.eu/rhel/4.1/</para>
<para>If you're using your own package repository, change this line to read as appropriate for your 4.1.0 repository.</para>
</listitem>
<listitem id="rpm-master">
<para>Now that you have the repository configured, it's time to install the <filename>cloudstack-management</filename> package by upgrading the older <filename>cloud-client</filename> package.</para>
<programlisting language="Bash">$ sudo yum upgrade cloud-client</programlisting>
</listitem>
<listitem id="kvm-agent-rpm">
<para>For KVM hosts, you will need to upgrade the <filename>cloud-agent</filename> package, similarly installing the new version as <filename>cloudstack-agent</filename>.</para>
<programlisting language="Bash">$ sudo yum upgrade cloud-agent</programlisting>
<para>During the installation of <filename>cloudstack-agent</filename>, the RPM will copy your <filename>agent.properties</filename>, <filename>log4j-cloud.xml</filename>, and <filename>environment.properties</filename> from <filename>/etc/cloud/agent</filename> to <filename>/etc/cloudstack/agent</filename>.</para>
</listitem>
<listitem>
<para>Verify that the file <filename>/etc/cloudstack/agent/environment.properties</filename> has a line that reads:</para>
<programlisting language="Bash">paths.script=/usr/share/cloudstack-common</programlisting>
<para>If not, add the line.</para>
</listitem>
<listitem>
<para>Restart the agent:</para>
<programlisting language="Bash">
service cloud-agent stop
killall jsvc
service cloudstack-agent start
</programlisting>
</listitem>
</orderedlist>
</listitem>
<listitem id="restart-system-vms">
<para>Once you've upgraded the packages on your management servers, you'll need to restart the system VMs. Make sure port 8096 is open <!-- [FIXME, where?] --> to do this.</para>
<para>Once you've upgraded the packages on your management servers, you'll need to restart the system VMs. Make sure port 8096 is open in your local host firewall to do this.</para>
<para>There is a script that will do this for you, all you need to do is run the script and supply the IP address for your MySQL instance and your MySQL credentials:</para>
<programlisting language="Bash"><prompt>#</prompt> nohup cloudstack-sysvmadm -d <replaceable>IP address</replaceable> -u cloud -p -a &gt; sysvm.log 2&gt;&amp;1 &amp;</programlisting>
<para>You can monitor the log for progress. The process of restarting the system VMs can take an hour or more.</para>
<programlisting language="Bash"><prompt>#</prompt> tail -f sysvm.log</programlisting>
<para>The output to <filename>sysvm.log</filename> will look something like this:</para>
<programlisting language="Bash">
Stopping and starting 1 secondary storage vm(s)...
Done stopping and starting secondary storage vm(s)
Stopping and starting 1 console proxy vm(s)...
Done stopping and starting console proxy vm(s).
Stopping and starting 4 running routing vm(s)...
Done restarting router(s).
Stopping and starting 1 secondary storage vm(s)...
Done stopping and starting secondary storage vm(s)
Stopping and starting 1 console proxy vm(s)...
Done stopping and starting console proxy vm(s).
Stopping and starting 4 running routing vm(s)...
Done restarting router(s).
</programlisting>
</listitem>
<listitem>
@ -4231,15 +4272,6 @@ under the License.
<title>Upgrade from 3.0.2 to 4.1.0</title>
<para>This section will guide you from Citrix CloudStack 3.0.2 to Apache CloudStack 4.1.0. Sections that are hypervisor-specific will be called out with a note.</para>
<orderedlist>
<listitem>
<para>Ensure that you query your IP address usage records and process them or make a
backup. During the upgrade you will lose the old IP address usage records.</para>
<para>Starting in 3.0.2, the usage record format for IP addresses is the same as the rest
of the usage types. Instead of a single record with the assignment and release dates,
separate records are generated per aggregation period with start and end dates. After
upgrading, any existing IP address usage records in the old format will no longer be
available.</para>
</listitem>
<listitem>
<note>
<para>The following upgrade instructions apply only if you're using VMware hosts. If
@ -4350,23 +4382,107 @@ under the License.
the community provided yum/apt repositories to gain access to the &PRODUCT;
binaries.</para>
</listitem>
<listitem>
<para>After you have configured an appropriate yum or apt repository, you may execute the
one of the following commands as appropriate for your environment in order to upgrade
&PRODUCT;: <programlisting><prompt>#</prompt> <command>yum</command> update cloud-*</programlisting>
<programlisting><prompt>#</prompt> <command>apt-get</command> update
<prompt>#</prompt> <command>apt-get</command> upgrade cloud-*</programlisting>
</para>
<para>You will, of course, have to agree to the changes suggested by Yum or APT.</para>
<note>
<para>If the upgrade output includes a message similar to the following, then some
custom content was found in your old components.xml, and you need to merge the two
files:</para>
<programlisting>warning: /etc/cloud/management/components.xml created as /etc/cloud/management/components.xml.rpmnew </programlisting>
<para>Instructions follow in the next step.</para>
<listitem id="upgrade-deb-packages-302">
<para>If you are using Ubuntu, follow this procedure to upgrade your packages. If not, skip to step <xref linkend="upgrade-rpm-packages-302" />.</para>
<note><title>Community Packages</title>
<para>This section assumes you're using the community supplied packages for &PRODUCT;. If you've created your own packages and APT repository, substitute your own URL for the ones used in these examples.</para>
</note>
<orderedlist id="debsteps-302">
<listitem>
<para>The first order of business will be to change the sources list for each system with &PRODUCT; packages. This means all management servers, and any hosts that have the KVM agent. (No changes should be necessary for hosts that are running VMware or Xen.)</para>
<para>Start by opening <filename>/etc/apt/sources.list.d/cloudstack.list</filename> on any systems that have &PRODUCT; packages installed.</para>
<para>This file should have one line, which contains:</para>
<programlisting language="Bash">deb http://cloudstack.apt-get.eu/ubuntu precise 4.0</programlisting>
<para>We'll change it to point to the new package repository:</para>
<programlisting language="Bash">deb http://cloudstack.apt-get.eu/ubuntu precise 4.1</programlisting>
<para>If you're using your own package repository, change this line to read as appropriate for your 4.1.0 repository.</para>
</listitem>
<listitem>
<para>Now update your apt package list:</para>
<programlisting language="Bash">$ sudo apt-get update</programlisting>
</listitem>
<listitem id="deb-master-302">
<para>Now that you have the repository configured, it's time to install the <filename>cloudstack-management</filename> package. This will pull in any other dependencies you need.</para>
<programlisting language="Bash">$ sudo apt-get install cloudstack-management</programlisting>
</listitem>
<listitem id="kvm-agent-deb-302">
<para>You will need to manually install the <filename>cloudstack-agent</filename> package:</para>
<programlisting language="Bash">$ sudo apt-get install cloudstack-agent</programlisting>
<para>During the installation of <filename>cloudstack-agent</filename>, APT will copy your <filename>agent.properties</filename>, <filename>log4j-cloud.xml</filename>, and <filename>environment.properties</filename> from <filename>/etc/cloud/agent</filename> to <filename>/etc/cloudstack/agent</filename>.</para>
<para>When prompted whether you wish to keep your configuration, say Yes.</para>
</listitem>
<listitem>
<para>Verify that the file <filename>/etc/cloudstack/agent/environment.properties</filename> has a line that reads:</para>
<programlisting language="Bash">paths.script=/usr/share/cloudstack-common</programlisting>
<para>If not, add the line.</para>
</listitem>
<listitem>
<para>Restart the agent:</para>
<programlisting language="Bash">
service cloud-agent stop
killall jsvc
service cloudstack-agent start
</programlisting>
</listitem>
<listitem>
<para>During the upgrade, <filename>log4j-cloud.xml</filename> was simply copied over, so the logs will continue to be added to <filename>/var/log/cloud/agent/agent.log</filename>. There's nothing <emphasis>wrong</emphasis> with this, but if you prefer to be consistent, you can change this by copying over the sample configuration file:</para>
<programlisting language="Bash">
cd /etc/cloudstack/agent
mv log4j-cloud.xml.dpkg-dist log4j-cloud.xml
service cloudstack-agent restart
</programlisting>
</listitem>
<listitem>
<para>Once the agent is running, you can uninstall the old cloud-* packages from your system:</para>
<programlisting language="Bash">sudo dpkg --purge cloud-agent</programlisting>
</listitem>
</orderedlist>
</listitem>
<listitem>
<listitem id="upgrade-rpm-packages-302">
<para>If you are using CentOS or RHEL, follow this procedure to upgrade your packages. If not, skip to step <xref linkend="correct-components-xml-302" />.</para>
<note><title>Community Packages</title>
<para>This section assumes you're using the community supplied packages for &PRODUCT;. If you've created your own packages and yum repository, substitute your own URL for the ones used in these examples.</para>
</note>
<orderedlist id="rpmsteps-302">
<listitem>
<para>The first order of business will be to change the yum repository for each system with &PRODUCT; packages. This means all management servers, and any hosts that have the KVM agent. (No changes should be necessary for hosts that are running VMware or Xen.)</para>
<para>Start by opening <filename>/etc/yum.repos.d/cloudstack.repo</filename> on any systems that have &PRODUCT; packages installed.</para>
<para>This file should have content similar to the following:</para>
<programlisting language="Bash">
[apache-cloudstack]
name=Apache CloudStack
baseurl=http://cloudstack.apt-get.eu/rhel/4.0/
enabled=1
gpgcheck=0
</programlisting>
<para>If you are using the community provided package repository, change the baseurl to http://cloudstack.apt-get.eu/rhel/4.1/</para>
<para>If you're using your own package repository, change this line to read as appropriate for your 4.1.0 repository.</para>
</listitem>
<listitem id="rpm-master-302">
<para>Now that you have the repository configured, it's time to install the <filename>cloudstack-management</filename> package by upgrading the older <filename>cloud-client</filename> package.</para>
<programlisting language="Bash">$ sudo yum upgrade cloud-client</programlisting>
</listitem>
<listitem id="kvm-agent-rpm-302">
<para>For KVM hosts, you will need to upgrade the <filename>cloud-agent</filename> package, similarly installing the new version as <filename>cloudstack-agent</filename>.</para>
<programlisting language="Bash">$ sudo yum upgrade cloud-agent</programlisting>
<para>During the installation of <filename>cloudstack-agent</filename>, the RPM will copy your <filename>agent.properties</filename>, <filename>log4j-cloud.xml</filename>, and <filename>environment.properties</filename> from <filename>/etc/cloud/agent</filename> to <filename>/etc/cloudstack/agent</filename>.</para>
</listitem>
<listitem>
<para>Verify that the file <filename>/etc/cloudstack/agent/environment.properties</filename> has a line that reads:</para>
<programlisting language="Bash">paths.script=/usr/share/cloudstack-common</programlisting>
<para>If not, add the line.</para>
</listitem>
<listitem>
<para>Restart the agent:</para>
<programlisting language="Bash">
service cloud-agent stop
killall jsvc
service cloudstack-agent start
</programlisting>
</listitem>
</orderedlist>
</listitem>
<listitem id="correct-components-xml-302">
<para>If you have made changes to your copy of
<filename>/etc/cloud/management/components.xml</filename> the changes will be
preserved in the upgrade. However, you need to do the following steps to place these
@ -4796,16 +4912,107 @@ under the License.
the community provided yum/apt repositories to gain access to the &PRODUCT; binaries.
</para>
</listitem>
<listitem>
<para> After you have configured an appropriate yum or apt repository, you may execute the
one of the following commands as appropriate for your environment in order to upgrade
&PRODUCT;: <programlisting><prompt>#</prompt> <command>yum</command> update cloud-*</programlisting>
<programlisting><prompt>#</prompt> <command>apt-get</command> update
<prompt>#</prompt> <command>apt-get</command> upgrade cloud-*</programlisting>
</para>
<para>You will, of course, have to agree to the changes suggested by Yum or APT.</para>
<listitem id="upgrade-deb-packages-22">
<para>If you are using Ubuntu, follow this procedure to upgrade your packages. If not, skip to step <xref linkend="upgrade-rpm-packages-22" />.</para>
<note><title>Community Packages</title>
<para>This section assumes you're using the community supplied packages for &PRODUCT;. If you've created your own packages and APT repository, substitute your own URL for the ones used in these examples.</para>
</note>
<orderedlist id="debsteps-22">
<listitem>
<para>The first order of business will be to change the sources list for each system with &PRODUCT; packages. This means all management servers, and any hosts that have the KVM agent. (No changes should be necessary for hosts that are running VMware or Xen.)</para>
<para>Start by opening <filename>/etc/apt/sources.list.d/cloudstack.list</filename> on any systems that have &PRODUCT; packages installed.</para>
<para>This file should have one line, which contains:</para>
<programlisting language="Bash">deb http://cloudstack.apt-get.eu/ubuntu precise 4.0</programlisting>
<para>We'll change it to point to the new package repository:</para>
<programlisting language="Bash">deb http://cloudstack.apt-get.eu/ubuntu precise 4.1</programlisting>
<para>If you're using your own package repository, change this line to read as appropriate for your 4.1.0 repository.</para>
</listitem>
<listitem>
<para>Now update your apt package list:</para>
<programlisting language="Bash">$ sudo apt-get update</programlisting>
</listitem>
<listitem id="deb-master-22">
<para>Now that you have the repository configured, it's time to install the <filename>cloudstack-management</filename> package. This will pull in any other dependencies you need.</para>
<programlisting language="Bash">$ sudo apt-get install cloudstack-management</programlisting>
</listitem>
<listitem id="kvm-agent-deb-22">
<para>You will need to manually install the <filename>cloudstack-agent</filename> package:</para>
<programlisting language="Bash">$ sudo apt-get install cloudstack-agent</programlisting>
<para>During the installation of <filename>cloudstack-agent</filename>, APT will copy your <filename>agent.properties</filename>, <filename>log4j-cloud.xml</filename>, and <filename>environment.properties</filename> from <filename>/etc/cloud/agent</filename> to <filename>/etc/cloudstack/agent</filename>.</para>
<para>When prompted whether you wish to keep your configuration, say Yes.</para>
</listitem>
<listitem>
<para>Verify that the file <filename>/etc/cloudstack/agent/environment.properties</filename> has a line that reads:</para>
<programlisting language="Bash">paths.script=/usr/share/cloudstack-common</programlisting>
<para>If not, add the line.</para>
</listitem>
<listitem>
<para>Restart the agent:</para>
<programlisting language="Bash">
service cloud-agent stop
killall jsvc
service cloudstack-agent start
</programlisting>
</listitem>
<listitem>
<para>During the upgrade, <filename>log4j-cloud.xml</filename> was simply copied over, so the logs will continue to be added to <filename>/var/log/cloud/agent/agent.log</filename>. There's nothing <emphasis>wrong</emphasis> with this, but if you prefer to be consistent, you can change this by copying over the sample configuration file:</para>
<programlisting language="Bash">
cd /etc/cloudstack/agent
mv log4j-cloud.xml.dpkg-dist log4j-cloud.xml
service cloudstack-agent restart
</programlisting>
</listitem>
<listitem>
<para>Once the agent is running, you can uninstall the old cloud-* packages from your system:</para>
<programlisting language="Bash">sudo dpkg --purge cloud-agent</programlisting>
</listitem>
</orderedlist>
</listitem>
<listitem>
<listitem id="upgrade-rpm-packages-22">
<para>If you are using CentOS or RHEL, follow this procedure to upgrade your packages. If not, skip to step <xref linkend="correct-components-xml-22" />.</para>
<note><title>Community Packages</title>
<para>This section assumes you're using the community supplied packages for &PRODUCT;. If you've created your own packages and yum repository, substitute your own URL for the ones used in these examples.</para>
</note>
<orderedlist id="rpmsteps-22">
<listitem>
<para>The first order of business will be to change the yum repository for each system with &PRODUCT; packages. This means all management servers, and any hosts that have the KVM agent. (No changes should be necessary for hosts that are running VMware or Xen.)</para>
<para>Start by opening <filename>/etc/yum.repos.d/cloudstack.repo</filename> on any systems that have &PRODUCT; packages installed.</para>
<para>This file should have content similar to the following:</para>
<programlisting language="Bash">
[apache-cloudstack]
name=Apache CloudStack
baseurl=http://cloudstack.apt-get.eu/rhel/4.0/
enabled=1
gpgcheck=0
</programlisting>
<para>If you are using the community provided package repository, change the baseurl to http://cloudstack.apt-get.eu/rhel/4.1/</para>
<para>If you're using your own package repository, change this line to read as appropriate for your 4.1.0 repository.</para>
</listitem>
<listitem id="rpm-master-22">
<para>Now that you have the repository configured, it's time to install the <filename>cloudstack-management</filename> package by upgrading the older <filename>cloud-client</filename> package.</para>
<programlisting language="Bash">$ sudo yum upgrade cloud-client</programlisting>
</listitem>
<listitem id="kvm-agent-rpm-22">
<para>For KVM hosts, you will need to upgrade the <filename>cloud-agent</filename> package, similarly installing the new version as <filename>cloudstack-agent</filename>.</para>
<programlisting language="Bash">$ sudo yum upgrade cloud-agent</programlisting>
<para>During the installation of <filename>cloudstack-agent</filename>, the RPM will copy your <filename>agent.properties</filename>, <filename>log4j-cloud.xml</filename>, and <filename>environment.properties</filename> from <filename>/etc/cloud/agent</filename> to <filename>/etc/cloudstack/agent</filename>.</para>
</listitem>
<listitem>
<para>Verify that the file <filename>/etc/cloudstack/agent/environment.properties</filename> has a line that reads:</para>
<programlisting language="Bash">paths.script=/usr/share/cloudstack-common</programlisting>
<para>If not, add the line.</para>
</listitem>
<listitem>
<para>Restart the agent:</para>
<programlisting language="Bash">
service cloud-agent stop
killall jsvc
service cloudstack-agent start
</programlisting>
</listitem>
</orderedlist>
</listitem>
<listitem id="correct-components-xml-22">
<para>If you have made changes to your existing copy of the file components.xml in your
previous-version CloudStack installation, the changes will be preserved in the upgrade.
However, you need to do the following steps to place these changes in a new version of

View File

@ -57,6 +57,6 @@ SYSCONFDIR=/etc
SYSTEMCLASSPATH=
SYSTEMJARS=
USAGECLASSPATH=
USAGELOG=/var/log/cloudstack/usage
USAGELOG=/var/log/cloudstack/usage/usage.log
USAGESYSCONFDIR=/etc/cloudstack/usage
PACKAGE=cloudstack

View File

@ -379,7 +379,7 @@ public class ApiResponseHelper implements ResponseGenerator {
populateDomain(resourceLimitResponse, accountTemp.getDomainId());
}
resourceLimitResponse.setResourceType(Integer.valueOf(limit.getType().getOrdinal()).toString());
if(limit.getType() == ResourceType.primary_storage || limit.getType() == ResourceType.secondary_storage) {
if((limit.getType() == ResourceType.primary_storage || limit.getType() == ResourceType.secondary_storage) && limit.getMax() >= 0) {
resourceLimitResponse.setMax((long) Math.ceil(limit.getMax()/ResourceType.bytesToGiB));
} else {
resourceLimitResponse.setMax(limit.getMax());
@ -3664,8 +3664,13 @@ public class ApiResponseHelper implements ResponseGenerator {
response.setName(group.getName());
response.setType(group.getType());
response.setDescription(group.getDescription());
// response.setDomainId(account.)
Domain domain = ApiDBUtils.findDomainById(account.getDomainId());
if (domain != null) {
response.setDomainId(domain.getUuid());
response.setDomainName(domain.getName());
}
response.setObjectName("affinitygroup");
return response;
}

View File

@ -63,6 +63,7 @@ public class AffinityGroupJoinDaoImpl extends GenericDaoBase<AffinityGroupJoinVO
agResponse.setId(vag.getUuid());
agResponse.setName(vag.getName());
agResponse.setDescription(vag.getDescription());
agResponse.setType(vag.getType());
ApiResponseHelper.populateOwner(agResponse, vag);

View File

@ -36,6 +36,9 @@ public class AffinityGroupJoinVO extends BaseViewVO implements ControlledViewEnt
@Column(name="name")
private String name;
@Column(name = "type")
private String type;
@Column(name = "description")
private String description;
@ -114,6 +117,14 @@ public class AffinityGroupJoinVO extends BaseViewVO implements ControlledViewEnt
this.name = name;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@Override
public long getAccountId() {
return accountId;

View File

@ -2445,10 +2445,6 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
network.setVnet(vnetString);
}
_physicalNetworkDao.update(id, network);
for (Pair<Integer, Integer> vnetToAdd : vnetsToAdd) {
s_logger.debug("Adding vnet range " + vnetToAdd.first() + "-" + vnetToAdd.second() + " for the physicalNetwork id= " + id + " and zone id=" + network.getDataCenterId()
+ " as a part of updatePhysicalNetwork call");
@ -2456,6 +2452,8 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
}
}
_physicalNetworkDao.update(id, network);
return network;
}

View File

@ -876,8 +876,8 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
if (publicNetwork) {
routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER);
} else {
Long podId = dest.getPod().getId();
if (isPodBased) {
Long podId = dest.getPod().getId();
routers = _routerDao.listByNetworkAndPodAndRole(network.getId(), podId, Role.VIRTUAL_ROUTER);
} else {
routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER);

View File

@ -107,7 +107,7 @@ public class AffinityGroupVO implements AffinityGroup {
@Override
public String toString() {
StringBuilder buf = new StringBuilder("AffinityGroup[");
buf.append(id).append("|").append(name).append("|").append(type).append("]");
buf.append(uuid).append("]");
return buf.toString();
}

View File

@ -512,6 +512,7 @@ CREATE VIEW `cloud`.`affinity_group_view` AS
select
affinity_group.id id,
affinity_group.name name,
affinity_group.type type,
affinity_group.description description,
affinity_group.uuid uuid,
account.id account_id,

View File

@ -49,7 +49,7 @@ class Services:
"endip": "10.102.197.73",
"zoneid": "1",
"podid": "",
"vlan": "101",
"vlan": "4444",
}
class TesDedicatePublicIPRange(cloudstackTestCase):

View File

@ -5,9 +5,9 @@
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@ -22,16 +22,20 @@ import hmac
import hashlib
import time
import cloudstackException
from cloudstackAPI import *
from cloudstackAPI import *
import jsonHelper
from requests import ConnectionError
from requests import HTTPError
from requests import Timeout
from requests import RequestException
class cloudConnection(object):
def __init__(self, mgtSvr, port=8096, apiKey=None, securityKey=None, asyncTimeout=3600, logging=None,
scheme='http', path='client/api'):
""" Connections to make API calls to the cloudstack management server
"""
def __init__(self, mgtSvr, port=8096, apiKey=None, securityKey=None,
asyncTimeout=3600, logging=None, scheme='http',
path='client/api'):
self.apiKey = apiKey
self.securityKey = securityKey
self.mgtSvr = mgtSvr
@ -42,16 +46,18 @@ class cloudConnection(object):
self.asyncTimeout = asyncTimeout
self.auth = True
if port == 8096 or \
(self.apiKey == None and self.securityKey == None):
(self.apiKey is None and self.securityKey is None):
self.auth = False
if scheme not in ['http', 'https']:
raise RequestException("Protocol must be HTTP")
self.protocol = scheme
self.baseurl = "%s://%s:%d/%s"%(self.protocol, self.mgtSvr, self.port, self.path)
self.baseurl = "%s://%s:%d/%s"\
% (self.protocol, self.mgtSvr, self.port, self.path)
def __copy__(self):
return cloudConnection(self.mgtSvr, self.port, self.apiKey, self.securityKey, self.asyncTimeout,
self.logging, self.protocol, self.path)
return cloudConnection(self.mgtSvr, self.port, self.apiKey,
self.securityKey, self.asyncTimeout,
self.logging, self.protocol, self.path)
def poll(self, jobid, response):
"""
@ -68,16 +74,19 @@ class cloudConnection(object):
asyncResonse = self.marvin_request(cmd, response_type=response)
if asyncResonse.jobstatus == 2:
raise cloudstackException.cloudstackAPIException("asyncquery", asyncResonse.jobresult)
raise cloudstackException.cloudstackAPIException(
"asyncquery", asyncResonse.jobresult)
elif asyncResonse.jobstatus == 1:
return asyncResonse
time.sleep(5)
if self.logging is not None:
self.logging.debug("job: %s still processing, will timeout in %ds"%(jobid, timeout))
self.logging.debug("job: %s still processing,"
" will timeout in %ds" % (jobid, timeout))
timeout = timeout - 5
raise cloudstackException.cloudstackAPIException("asyncquery", "Async job timeout %s"%jobid)
raise cloudstackException.cloudstackAPIException(
"asyncquery", "Async job timeout %s" % jobid)
def sign(self, payload):
"""
@ -90,19 +99,26 @@ class cloudConnection(object):
params.sort(key=lambda k: str.lower(k[0]))
hashStr = "&".join(
["=".join(
[str.lower(r[0]), str.lower(urllib.quote_plus(str(r[1]))).replace("+", "%20")]
[str.lower(r[0]),
str.lower(
urllib.quote_plus(str(r[1]))
).replace("+", "%20")]
) for r in params]
)
signature = base64.encodestring(hmac.new(self.securityKey, hashStr, hashlib.sha1).digest()).strip()
self.logging.info("Computed Signature by Marvin: %s"%signature)
signature = base64.encodestring(hmac.new(
self.securityKey, hashStr, hashlib.sha1).digest()).strip()
self.logging.info("Computed Signature by Marvin: %s" % signature)
return signature
def request(self, command, auth=True, payload={}, data={}):
"""
Makes requests on the `integration.api.port`
@param command: cloudstack API command name eg: deployVirtualMachineCommand
@param auth: Authentication (apikey,secretKey) => True, else False
@param payload: GET param data composed as a dictionary of key,value pairs
Makes requests using auth or over integration port
@param command: cloudstack API command name
eg: deployVirtualMachineCommand
@param auth: Authentication (apikey,secretKey) => True
else False for integration.api.port
@param payload: GET param data composed as a dictionary
of key,value pairs
@param data: POST data as a dictionary
@return:
"""
@ -114,23 +130,24 @@ class cloudConnection(object):
signature = self.sign(payload)
payload["signature"] = signature
try:
if data:
response = requests.get(self.baseurl, params=payload, data=data)
response = requests.get(self.baseurl, params=payload,
data=data)
else:
response = requests.get(self.baseurl, params=payload)
except ConnectionError, c:
self.logging.debug("Connection refused. Reason: %s"%(self.baseurl, c))
self.logging.debug("Connection refused. Reason: %s" %
(self.baseurl, c))
raise c
except HTTPError, h:
self.logging.debug("Server returned error code: %s"%h)
self.logging.debug("Server returned error code: %s" % h)
raise h
except Timeout, t:
self.logging.debug("Connection timed out with %s"%t)
self.logging.debug("Connection timed out with %s" % t)
raise t
except RequestException,r:
self.logging.debug("Error returned by server %s"%r)
except RequestException, r:
self.logging.debug("Error returned by server %s" % r)
raise r
else:
return response
@ -144,7 +161,8 @@ class cloudConnection(object):
requests = {}
required = []
for attribute in dir(cmd):
if attribute != "__doc__" and attribute != "__init__" and attribute != "__module__":
if attribute != "__doc__" and attribute != "__init__" and \
attribute != "__module__":
if attribute == "isAsync":
isAsync = getattr(cmd, attribute)
elif attribute == "required":
@ -155,7 +173,8 @@ class cloudConnection(object):
cmdname = cmd.__class__.__name__.replace("Cmd", "")
for requiredPara in required:
if requests[requiredPara] is None:
raise cloudstackException.cloudstackAPIException(cmdname, "%s is required"%requiredPara)
raise cloudstackException.cloudstackAPIException(
cmdname, "%s is required" % requiredPara)
for param, value in requests.items():
if value is None:
requests.pop(param)
@ -169,8 +188,8 @@ class cloudConnection(object):
requests.pop(param)
i = 0
for val in value:
for k,v in val.iteritems():
requests["%s[%d].%s"%(param,i,k)] = v
for k, v in val.iteritems():
requests["%s[%d].%s" % (param, i, k)] = v
i = i + 1
return cmdname, isAsync, requests
@ -184,14 +203,17 @@ class cloudConnection(object):
@return:
"""
cmdname, isAsync, payload = self.sanitize_command(cmd)
self.logging.info("sending command: %s %s"%(cmdname, str(payload)))
self.logging.info("sending command: %s %s" % (cmdname, str(payload)))
if self.auth:
response = self.request(cmdname, auth=True, payload=payload, data=data)
response = self.request(
cmdname, auth=True, payload=payload, data=data)
else:
response = self.request(cmdname, auth=False, payload=payload, data=data)
response = self.request(
cmdname, auth=False, payload=payload, data=data)
self.logging.info("Request: %s Response: %s"%(response.url, response.text))
response = jsonHelper.getResultObj(response.json, response_type)
self.logging.info("Request: %s Response: %s" %
(response.url, response.text))
response = jsonHelper.getResultObj(response.json(), response_type)
if isAsync == "false":
return response