mirror of https://github.com/apache/cloudstack.git
Merge branch 'master' into entity
This commit is contained in:
commit
e8b2aaf3f5
|
|
@ -33,7 +33,7 @@ import com.cloud.user.Account;
|
|||
@APICommand(name = "removeRegion", description="Removes specified region", responseObject=SuccessResponse.class)
|
||||
public class RemoveRegionCmd extends BaseCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(RemoveRegionCmd.class.getName());
|
||||
private static final String s_name = "updateregionresponse";
|
||||
private static final String s_name = "removeregionresponse";
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
//////////////// API parameters /////////////////////
|
||||
|
|
|
|||
|
|
@ -48,6 +48,8 @@ public class VpnUsersResponse extends BaseResponse implements ControlledEntityRe
|
|||
@SerializedName(ApiConstants.PROJECT) @Param(description="the project name of the vpn")
|
||||
private String projectName;
|
||||
|
||||
@SerializedName(ApiConstants.STATE) @Param(description="the state of the Vpn User")
|
||||
private String state;
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
|
|
@ -80,4 +82,12 @@ public class VpnUsersResponse extends BaseResponse implements ControlledEntityRe
|
|||
this.projectName = projectName;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,5 +57,6 @@
|
|||
<xi:include href="aws-interface-compatibility.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
<xi:include href="network-setup.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
<xi:include href="networks.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
<xi:include href="best-practices.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
<xi:include href="Revision_History_Install_Guide.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
</book>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,82 @@
|
|||
<?xml version='1.0' encoding='utf-8' ?>
|
||||
<!DOCTYPE chapter 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.
|
||||
-->
|
||||
|
||||
<chapter id="best-practices">
|
||||
<title>Best Practices</title>
|
||||
<para>Deploying a cloud is challenging. There are many different technology choices to make, and &PRODUCT; is flexible enough in its configuration that there are many possible ways to combine and configure the chosen technology. This section contains suggestions and requirements about cloud deployments.</para>
|
||||
<para>These should be treated as suggestions and not absolutes. However, we do encourage anyone planning to build a cloud outside of these guidelines to seek guidance and advice on the project mailing lists.</para>
|
||||
<section id="process-best-practices">
|
||||
<title>Process Best Practices</title>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>A staging system that models the production environment is strongly advised. It is critical if customizations have been applied to &PRODUCT;.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Allow adequate time for installation, a beta, and learning the system. Installs with basic networking can be done in hours. Installs with advanced networking usually take several days for the first attempt, with complicated installations taking longer. For a full production system, allow at least 4-8 weeks for a beta to work through all of the integration issues. You can get help from fellow users on the cloudstack-users mailing list.</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
<section id="setup-best-practices">
|
||||
<title>Setup Best Practices</title>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>Each host should be configured to accept connections only from well-known entities such as the &PRODUCT; Management Server or your network monitoring software.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Use multiple clusters per pod if you need to achieve a certain switch density.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Primary storage mountpoints or LUNs should not exceed 6 TB in size. It is better to have multiple smaller primary storage elements per cluster than one large one.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>When exporting shares on primary storage, avoid data loss by restricting the range of IP addresses that can access the storage. See "Linux NFS on Local Disks and DAS" or "Linux NFS on iSCSI".</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>NIC bonding is straightforward to implement and provides increased reliability.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>10G networks are generally recommended for storage access when larger servers that can support relatively more VMs are used.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Host capacity should generally be modeled in terms of RAM for the guests. Storage and CPU may be overprovisioned. RAM may not. RAM is usually the limiting factor in capacity designs.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>(XenServer) Configure the XenServer dom0 settings to allocate more memory to dom0. This can enable XenServer to handle larger numbers of virtual machines. We recommend 2940 MB of RAM for XenServer dom0. For instructions on how to do this, see <ulink url="http://support.citrix.com/article/CTX126531">http://support.citrix.com/article/CTX126531</ulink>. The article refers to XenServer 5.6, but the same information applies to XenServer 6.0.</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
<section id="maintenance-best-practices">
|
||||
<title>Maintenance Best Practices</title>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>Monitor host disk space. Many host failures occur because the host's root disk fills up from logs that were not rotated adequately.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Monitor the total number of VM instances in each cluster, and disable allocation to the cluster if the total is approaching the maximum that the hypervisor can handle. Be sure to leave a safety margin to allow for the possibility of one or more hosts failing, which would increase the VM load on the other hosts as the VMs are redeployed. Consult the documentation for your chosen hypervisor to find the maximum permitted number of VMs per host, then use &PRODUCT; global configuration settings to set this as the default limit. Monitor the VM activity in each cluster and keep the total number of VMs below a safe level that allows for the occasional host failure. For example, if there are N hosts in the cluster, and you want to allow for one host in the cluster to be down at any given time, the total number of VM instances you can permit in the cluster is at most (N-1) * (per-host-limit). Once a cluster reaches this number of VMs, use the &PRODUCT; UI to disable allocation to the cluster.</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
<warning><para>The lack of up-do-date hotfixes can lead to data corruption and lost VMs.</para></warning>
|
||||
<para>Be sure all the hotfixes provided by the hypervisor vendor are applied. Track the release of hypervisor patches through your hypervisor vendor’s support channel, and apply patches as soon as possible after they are released. &PRODUCT; will not track or notify you of required hypervisor patches. It is essential that your hosts are completely up to date with the provided hypervisor patches. The hypervisor vendor is likely to refuse to support any system that is not up to date with patches.</para>
|
||||
</section>
|
||||
</chapter>
|
||||
|
|
@ -34,15 +34,139 @@
|
|||
<row>
|
||||
<entry>
|
||||
<para>createNetworkOffering</para>
|
||||
</entry>
|
||||
<entry>
|
||||
<para>The following request parameters have been added:</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>isPersistent</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>startipv6</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>endipv6</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>ip6gateway</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>ip6cidr</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>
|
||||
<para>listNetworkOfferings</para>
|
||||
<para>listNetworks</para>
|
||||
</entry>
|
||||
<entry>
|
||||
<para>The following request parameters is added: isPersistent.</para>
|
||||
<para>This parameter determines if the network or network offering created or listed by
|
||||
using this offering are persistent or not.</para>
|
||||
<para>The following request parameters has been added: isPersistent</para>
|
||||
<para>This parameter determines if the network or network offering listed by using this
|
||||
offering are persistent or not.</para>
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>
|
||||
<para>createVlanIpRange</para>
|
||||
</entry>
|
||||
<entry>
|
||||
<para>The following request parameters have been added:</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>startipv6</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>endipv6</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>ip6gateway</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>ip6cidr</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>
|
||||
<para>deployVirtualMachine</para>
|
||||
</entry>
|
||||
<entry>
|
||||
<para>The following parameter has been added: ip6Address.</para>
|
||||
<para>The following parameter is updated to accept the IPv6 address:
|
||||
iptonetworklist.</para>
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>
|
||||
<para>CreateZoneCmd</para>
|
||||
</entry>
|
||||
<entry>
|
||||
<para>The following parameter are added: ip6dns1, ip6dns2.</para>
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>
|
||||
<para>listRouters</para>
|
||||
<para>listVirtualMachines</para>
|
||||
</entry>
|
||||
<entry>
|
||||
<para>For nic responses, the following fields has been added.</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>ip6address</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>ip6gateway</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>ip6cidr</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>
|
||||
<para>listVlanIpRanges</para>
|
||||
</entry>
|
||||
<entry>
|
||||
<para>For nic responses, the following fields has been added.</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>startipv6</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>endipv6</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>ip6gateway</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>ip6cidr</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>
|
||||
<para>listRouters</para>
|
||||
<para>listZones</para>
|
||||
</entry>
|
||||
<entry>
|
||||
<para>For DomainRouter and DataCenter response, the following fields have been
|
||||
added.</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>ip6dns1</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>ip6dns2</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>
|
||||
<para>addF5LoadBalancer</para>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,191 @@
|
|||
<?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="ipv6-support">
|
||||
<title>IPv6 Support in &PRODUCT;</title>
|
||||
<para>&PRODUCT;supports Internet Protocol version 6 (IPv6), the recent version of the Internet
|
||||
Protocol (IP) that defines routing the network traffic. IPv6 uses a 128-bit address that
|
||||
exponentially expands the current address space that is available to the users. IPv6 addresses
|
||||
consist of eight groups of four hexadecimal digits separated by colons, for example,
|
||||
5001:0dt8:83a3:1012:1000:8s2e:0870:7454. &PRODUCT; supports IPv6 for public IPs in shared
|
||||
networks. With IPv6 support, VMs in shared networks can obtain both IPv4 and IPv6 addresses from
|
||||
the DHCP server. You can deploy VMs either in a IPv6 or IPv4 network, or in a dual network
|
||||
environment. If IPv6 network is used, the VM generates a link-local IPv6 address by itself, and
|
||||
receives a stateful IPv6 address from the DHCPv6 server.</para>
|
||||
<para>IPv6 is supported only on KVM and XenServer hypervisors. The IPv6 support is only an
|
||||
experimental feature.</para>
|
||||
<para>Here's the sequence of events when IPv6 is used: </para>
|
||||
<orderedlist>
|
||||
<listitem>
|
||||
<para>The administrator creates an IPv6 shared network in an advanced zone.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>The user deploys a VM in an IPv6 shared network.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>The user VM generates an IPv6 link local address by itself, and gets an IPv6 global or
|
||||
site local address through DHCPv6.</para>
|
||||
<para>For information on API changes, see <xref linkend="changed-apicommands-4.1"/>.</para>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
<section id="guidelines-ipv6">
|
||||
<title>Prerequisites and Guidelines</title>
|
||||
<para>Consider the following:</para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>CIDR size must be 64 for IPv6 networks.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>The DHCP client of the guest VMs should support generating DUID based on Link-layer
|
||||
Address (DUID- LL). DUID-LL derives from the MAC address of guest VMs, and therefore the
|
||||
user VM can be identified by using DUID. See <ulink
|
||||
url="http://tools.ietf.org/html/rfc3315">Dynamic Host Configuration Protocol for IPv6
|
||||
</ulink>for more information.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>The gateway of the guest network generates Router Advisement and Response messages to
|
||||
Router Solicitation. The M (Managed Address Configuration) flag of Router Advisement
|
||||
should enable stateful IP address configuration. Set the M flag to where the end nodes
|
||||
receive their IPv6 addresses from the DHCPv6 server as opposed to the router or
|
||||
switch.</para>
|
||||
<note>
|
||||
<para>The M flag is the 1-bit Managed Address Configuration flag for Router Advisement.
|
||||
When set, Dynamic Host Configuration Protocol (DHCPv6) is available for address
|
||||
configuration in addition to any IPs set by using stateless address
|
||||
auto-configuration.</para>
|
||||
</note>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Use the System VM template exclusively designed to support IPv6. Download the System
|
||||
VM template from <ulink url="http://nfs1.lab.vmops.com/templates/routing/debian/ipv6/"
|
||||
>http://nfs1.lab.vmops.com/templates/routing/debian/ipv6/</ulink>.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>The concept of Default Network applies to IPv6 networks. However, unlike IPv4
|
||||
&PRODUCT; does not control the routing information of IPv6 in shared network; the choice
|
||||
of Default Network will not affect the routing in the user VM.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>In a multiple shared network, the default route is set by the rack router, rather than
|
||||
the DHCP server, which is out of &PRODUCT; control. Therefore, in order for the user VM to
|
||||
get only the default route from the default NIC, modify the configuration of the user VM,
|
||||
and set non-default NIC's <code>accept_ra</code> to 0 explicitly. The
|
||||
<code>accept_ra</code> parameter accepts Router Advertisements and auto-configure
|
||||
<code>/proc/sys/net/ipv6/conf/interface</code> with received data.</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</section>
|
||||
<section id="limitsipv6">
|
||||
<title>Limitations of IPv6 in &PRODUCT; </title>
|
||||
<para>The following are not yet supported:</para>
|
||||
<orderedlist>
|
||||
<listitem>
|
||||
<para>Security groups</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Userdata and metadata</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Passwords</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>The administrator cannot specify the IPv6 address of a VM.</para>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
</section>
|
||||
<section id="network-conf-dhcpv6">
|
||||
<title>Network Configuration for DHCPv6</title>
|
||||
<para>Use DUID-LL to get IPv6 address from DHCP server</para>
|
||||
<orderedlist>
|
||||
<listitem>
|
||||
<para>Set up dhclient by using DUID-LL.</para>
|
||||
<para>Perform the following for DHCP Client 4.2 and above:</para>
|
||||
<orderedlist numeration="loweralpha">
|
||||
<listitem>
|
||||
<para>Run the following command on the selected VM to get the dhcpv6 offer from
|
||||
VR:</para>
|
||||
<programlisting>dhclient -6 -D LL <dev></programlisting>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
<para>Perform the following for DHCP Client 4.1:</para>
|
||||
<orderedlist numeration="loweralpha">
|
||||
<listitem>
|
||||
<para>Open the following to the dhclient configuration file:</para>
|
||||
<programlisting>vi /etc/dhcp/dhclient.conf</programlisting>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Add the following to the dhclient configuration file:</para>
|
||||
<programlisting>send dhcp6.client-id = concat(00:03:00, hardware);</programlisting>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Get IPv6 address from DHCP server as part of the system or network restart.</para>
|
||||
<para>Based on the operating systems, perform the following:</para>
|
||||
<para>On CentOS 6.2:</para>
|
||||
<orderedlist numeration="loweralpha">
|
||||
<listitem>
|
||||
<para>Open the Ethernet interface configuration file:</para>
|
||||
<programlisting>vi /etc/sysconfig/network-scripts/ifcfg-eth0</programlisting>
|
||||
<para>The <code>ifcfg-eth0</code> file controls the first NIC in a system.</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Make the necessary configuration changes, as given below:</para>
|
||||
<programlisting>DEVICE=eth0
|
||||
HWADDR=06:A0:F0:00:00:38
|
||||
NM_CONTROLLED=no
|
||||
ONBOOT=yes
|
||||
BOOTPROTO=dhcp6
|
||||
TYPE=Ethernet
|
||||
USERCTL=no
|
||||
PEERDNS=yes
|
||||
IPV6INIT=yes
|
||||
DHCPV6C=yes</programlisting>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Open the following:</para>
|
||||
<programlisting>vi /etc/sysconfig/network</programlisting>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Make the necessary configuration changes, as given below:</para>
|
||||
<programlisting>NETWORKING=yes
|
||||
HOSTNAME=centos62mgmt.lab.vmops.com
|
||||
NETWORKING_IPV6=yes
|
||||
IPV6_AUTOCONF=no</programlisting>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
<para>On Ubuntu 12.10</para>
|
||||
<orderedlist numeration="loweralpha">
|
||||
<listitem>
|
||||
<para>Open the following:</para>
|
||||
<programlisting>etc/network/interfaces:</programlisting>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>Make the necessary configuration changes, as given below:</para>
|
||||
<programlisting>iface eth0 inet6 dhcp
|
||||
autoconf 0
|
||||
accept_ra 1</programlisting>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
</section>
|
||||
</section>
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
<?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" [
|
||||
<!DOCTYPE chapter 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;
|
||||
]>
|
||||
|
|
@ -25,6 +25,7 @@
|
|||
<section id="whats-new-in-api-4.1">
|
||||
<title>What's New in the API for 4.1</title>
|
||||
<xi:include href="add-remove-nic.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
|
||||
<xi:include href="ipv6-support.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
|
||||
<xi:include href="vmx-settings-dev.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
|
||||
<xi:include href="reset-ssh-key-dev.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
|
||||
<xi:include href="changed-apicommands-4.1.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
|
||||
|
|
|
|||
|
|
@ -684,13 +684,16 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||
String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl);
|
||||
String srcOVAFileName = secondaryMountPoint + "/" + secStorageDir + "/"
|
||||
+ backupName + "." + ImageFormat.OVA.getFileExtension();
|
||||
|
||||
String snapshotDir = "";
|
||||
if (backupName.contains("/")){
|
||||
snapshotDir = backupName.split("/")[0];
|
||||
}
|
||||
String srcFileName = getOVFFilePath(srcOVAFileName);
|
||||
if(srcFileName == null) {
|
||||
Script command = new Script("tar", 0, s_logger);
|
||||
command.add("--no-same-owner");
|
||||
command.add("-xf", srcOVAFileName);
|
||||
command.setWorkDir(secondaryMountPoint + "/" + secStorageDir);
|
||||
command.setWorkDir(secondaryMountPoint + "/" + secStorageDir + "/" + snapshotDir);
|
||||
s_logger.info("Executing command: " + command.toString());
|
||||
String result = command.execute();
|
||||
if(result != null) {
|
||||
|
|
@ -731,7 +734,7 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||
String backupUuid = UUID.randomUUID().toString();
|
||||
exportVolumeToSecondaryStroage(vmMo, volumePath, secStorageUrl,
|
||||
getSnapshotRelativeDirInSecStorage(accountId, volumeId), backupUuid, workerVmName);
|
||||
return backupUuid;
|
||||
return backupUuid + "/" + backupUuid;
|
||||
}
|
||||
|
||||
private void exportVolumeToSecondaryStroage(VirtualMachineMO vmMo, String volumePath,
|
||||
|
|
@ -739,8 +742,8 @@ public class VmwareStorageManagerImpl implements VmwareStorageManager {
|
|||
String workerVmName) throws Exception {
|
||||
|
||||
String secondaryMountPoint = _mountService.getMountPoint(secStorageUrl);
|
||||
String exportPath = secondaryMountPoint + "/" + secStorageDir;
|
||||
|
||||
String exportPath = secondaryMountPoint + "/" + secStorageDir + "/" + exportName;
|
||||
|
||||
synchronized(exportPath.intern()) {
|
||||
if(!new File(exportPath).exists()) {
|
||||
Script command = new Script(false, "mkdir", _timeout, s_logger);
|
||||
|
|
|
|||
|
|
@ -1108,6 +1108,7 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
VpnUsersResponse vpnResponse = new VpnUsersResponse();
|
||||
vpnResponse.setId(vpnUser.getUuid());
|
||||
vpnResponse.setUserName(vpnUser.getUsername());
|
||||
vpnResponse.setState(vpnUser.getState().toString());
|
||||
|
||||
populateOwner(vpnResponse, vpnUser);
|
||||
|
||||
|
|
|
|||
|
|
@ -19,22 +19,29 @@ package com.cloud.event;
|
|||
import java.lang.reflect.AnnotatedElement;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
|
||||
import com.cloud.user.UserContext;
|
||||
import com.cloud.utils.component.ComponentMethodProxyCache;
|
||||
|
||||
public class ActionEventInterceptor {
|
||||
private static final Logger s_logger = Logger.getLogger(ActionEventInterceptor.class);
|
||||
|
||||
public ActionEventInterceptor() {
|
||||
}
|
||||
|
||||
public Object AroundAnyMethod(ProceedingJoinPoint call) throws Throwable {
|
||||
MethodSignature methodSignature = (MethodSignature)call.getSignature();
|
||||
Method targetMethod = methodSignature.getMethod();
|
||||
if(needToIntercept(targetMethod)) {
|
||||
|
||||
// Note: AOP for ActionEvent is triggered annotation, no need to check the annotation on method again
|
||||
Method targetMethod = ComponentMethodProxyCache.getTargetMethod(
|
||||
methodSignature.getMethod(), call.getTarget());
|
||||
|
||||
if(targetMethod != null) {
|
||||
EventVO event = interceptStart(targetMethod);
|
||||
|
||||
|
||||
boolean success = true;
|
||||
Object ret = null;
|
||||
try {
|
||||
|
|
@ -49,6 +56,8 @@ public class ActionEventInterceptor {
|
|||
}
|
||||
}
|
||||
return ret;
|
||||
} else {
|
||||
s_logger.error("Unable to find the proxied method behind. Method: " + methodSignature.getMethod().getName());
|
||||
}
|
||||
return call.proceed();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -511,13 +511,13 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
|
|||
|
||||
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
|
||||
sb.and("username", sb.entity().getUsername(), SearchCriteria.Op.EQ);
|
||||
sb.and("state", sb.entity().getState(), SearchCriteria.Op.EQ);
|
||||
sb.and("state", sb.entity().getState(), Op.IN);
|
||||
|
||||
SearchCriteria<VpnUserVO> sc = sb.create();
|
||||
_accountMgr.buildACLSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
|
||||
|
||||
//list only active users
|
||||
sc.setParameters("state", State.Active);
|
||||
sc.setParameters("state", State.Active, State.Add);
|
||||
|
||||
if (id != null) {
|
||||
sc.setParameters("id", id);
|
||||
|
|
|
|||
|
|
@ -162,6 +162,10 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker {
|
|||
|
||||
_upgradeMap.put("4.0.0", new DbUpgrade[] { new Upgrade40to41(), new Upgrade410to420() });
|
||||
|
||||
_upgradeMap.put("4.0.1", new DbUpgrade[] { new Upgrade40to41(), new Upgrade410to420() });
|
||||
|
||||
_upgradeMap.put("4.0.2", new DbUpgrade[] { new Upgrade40to41(), new Upgrade410to420() });
|
||||
|
||||
_upgradeMap.put("4.1.0", new DbUpgrade[] { new Upgrade410to420() });
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public class ConsoleProxyHttpHandlerHelper {
|
|||
ConsoleProxyClientParam param = encryptor.decryptObject(ConsoleProxyClientParam.class, map.get("token"));
|
||||
|
||||
// make sure we get information from token only
|
||||
map.clear();
|
||||
guardUserInput(map);
|
||||
if(param != null) {
|
||||
if(param.getClientHostAddress() != null)
|
||||
map.put("host", param.getClientHostAddress());
|
||||
|
|
@ -72,9 +72,19 @@ public class ConsoleProxyHttpHandlerHelper {
|
|||
}
|
||||
} else {
|
||||
// we no longer accept information from parameter other than token
|
||||
map.clear();
|
||||
guardUserInput(map);
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
private static void guardUserInput(Map<String, String> map) {
|
||||
map.remove("host");
|
||||
map.remove("port");
|
||||
map.remove("tag");
|
||||
map.remove("sid");
|
||||
map.remove("consoleurl");
|
||||
map.remove("sessionref");
|
||||
map.remove("ticket");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -261,7 +261,7 @@ CREATE TABLE `cloud`.`region` (
|
|||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
INSERT INTO `cloud`.`region` values ('1','Local','http://localhost:8080/client/api');
|
||||
INSERT INTO `cloud`.`region` values ('1','Local','http://localhost:8080/client');
|
||||
|
||||
INSERT IGNORE INTO `cloud`.`configuration` VALUES ('Account Defaults', 'DEFAULT', 'management-server', 'max.account.cpus', '40', 'The default maximum number of cpu cores that can be used for an account');
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@
|
|||
# under the License.
|
||||
|
||||
try:
|
||||
from config import __version__
|
||||
from config import __version__, __description__
|
||||
from config import __maintainer__, __maintaineremail__
|
||||
from config import __project__, __projecturl__, __projectemail__
|
||||
except ImportError, e:
|
||||
print e
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ try:
|
|||
import os
|
||||
import types
|
||||
|
||||
from config import cache_file
|
||||
from config import config_fields
|
||||
except ImportError, e:
|
||||
import sys
|
||||
print "ImportError", e
|
||||
|
|
@ -168,6 +168,7 @@ def main(json_file):
|
|||
f.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
cache_file = config_fields['core']['cache_file']
|
||||
print "[cachemaker] Pre-caching using user's cloudmonkey cache", cache_file
|
||||
if os.path.exists(cache_file):
|
||||
main(cache_file)
|
||||
|
|
|
|||
|
|
@ -29,8 +29,9 @@ try:
|
|||
import types
|
||||
|
||||
from cachemaker import loadcache, savecache, monkeycache, splitverbsubject
|
||||
from config import __version__, cache_file
|
||||
from config import read_config, write_config
|
||||
from config import __version__, __description__, __projecturl__
|
||||
from config import read_config, write_config, config_file
|
||||
from optparse import OptionParser
|
||||
from prettytable import PrettyTable
|
||||
from printer import monkeyprint
|
||||
from requester import monkeyrequest
|
||||
|
|
@ -63,13 +64,14 @@ class CloudMonkeyShell(cmd.Cmd, object):
|
|||
intro = ("☁ Apache CloudStack 🐵 cloudmonkey " + __version__ +
|
||||
". Type help or ? to list commands.\n")
|
||||
ruler = "="
|
||||
cache_file = cache_file
|
||||
config_options = []
|
||||
verbs = []
|
||||
|
||||
def __init__(self, pname):
|
||||
def __init__(self, pname, cfile):
|
||||
self.program_name = pname
|
||||
self.config_options = read_config(self.get_attr, self.set_attr)
|
||||
self.config_file = cfile
|
||||
self.config_options = read_config(self.get_attr, self.set_attr,
|
||||
self.config_file)
|
||||
self.loadcache()
|
||||
self.prompt = self.prompt.strip() + " " # Cosmetic fix for prompt
|
||||
|
||||
|
|
@ -364,7 +366,7 @@ class CloudMonkeyShell(cmd.Cmd, object):
|
|||
key, value = (args[0], args[2])
|
||||
setattr(self, key, value) # keys and attributes should have same names
|
||||
self.prompt = self.prompt.strip() + " " # prompt fix
|
||||
write_config(self.get_attr)
|
||||
write_config(self.get_attr, self.config_file)
|
||||
|
||||
def complete_set(self, text, line, begidx, endidx):
|
||||
mline = line.partition(" ")[2]
|
||||
|
|
@ -458,10 +460,37 @@ class CloudMonkeyShell(cmd.Cmd, object):
|
|||
return self.do_EOF(args)
|
||||
|
||||
|
||||
class MonkeyParser(OptionParser):
|
||||
def format_help(self, formatter=None):
|
||||
if formatter is None:
|
||||
formatter = self.formatter
|
||||
result = []
|
||||
if self.usage:
|
||||
result.append("Usage: cloudmonkey [options] [cmds] [params]\n\n")
|
||||
if self.description:
|
||||
result.append(self.format_description(formatter) + "\n")
|
||||
result.append(self.format_option_help(formatter))
|
||||
result.append("\nTry cloudmonkey [help|?]\n")
|
||||
return "".join(result)
|
||||
|
||||
|
||||
def main():
|
||||
shell = CloudMonkeyShell(sys.argv[0])
|
||||
if len(sys.argv) > 1:
|
||||
shell.onecmd(' '.join(sys.argv[1:]))
|
||||
parser = MonkeyParser()
|
||||
parser.add_option("-c", "--config-file",
|
||||
dest="cfile", default=config_file,
|
||||
help="config file for cloudmonkey", metavar="FILE")
|
||||
parser.add_option("-v", "--version",
|
||||
action="store_true", dest="version", default=False,
|
||||
help="prints cloudmonkey version information")
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
if options.version:
|
||||
print "cloudmonkey", __version__
|
||||
print __description__, "(%s)" % __projecturl__
|
||||
|
||||
shell = CloudMonkeyShell(sys.argv[0], options.cfile)
|
||||
if len(args) > 1:
|
||||
shell.onecmd(' '.join(args))
|
||||
else:
|
||||
shell.cmdloop()
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,12 @@
|
|||
# Use following rules for versioning:
|
||||
# <cloudstack version>-<cli increment, starts from 0>
|
||||
__version__ = "4.1.0-0"
|
||||
__description__ = "Command Line Interface for Apache CloudStack"
|
||||
__maintainer__ = "Rohit Yadav"
|
||||
__maintaineremail__ = "bhaisaab@apache.org"
|
||||
__project__ = "The Apache CloudStack Team"
|
||||
__projectemail__ = "cloudstack-dev@incubator.apache.org"
|
||||
__projecturl__ = "http://incubator.apache.org/cloudstack"
|
||||
|
||||
try:
|
||||
import os
|
||||
|
|
@ -36,14 +42,14 @@ iterable_type = ['set', 'list', 'object']
|
|||
|
||||
config_dir = expanduser('~/.cloudmonkey')
|
||||
config_file = expanduser(config_dir + '/config')
|
||||
cache_file = expanduser(config_dir + '/cache')
|
||||
|
||||
# cloudmonkey config fields
|
||||
config_fields = {'core': {}, 'ui': {}, 'server': {}, 'user': {}}
|
||||
config_fields = {'core': {}, 'server': {}, 'user': {}, 'ui': {}}
|
||||
|
||||
# core
|
||||
config_fields['core']['asyncblock'] = 'true'
|
||||
config_fields['core']['paramcompletion'] = 'false'
|
||||
config_fields['core']['cache_file'] = expanduser(config_dir + '/cache')
|
||||
config_fields['core']['history_file'] = expanduser(config_dir + '/history')
|
||||
config_fields['core']['log_file'] = expanduser(config_dir + '/log')
|
||||
|
||||
|
|
@ -64,8 +70,8 @@ config_fields['user']['apikey'] = ''
|
|||
config_fields['user']['secretkey'] = ''
|
||||
|
||||
|
||||
def write_config(get_attr, first_time=False):
|
||||
global config_fields, config_file
|
||||
def write_config(get_attr, config_file, first_time=False):
|
||||
global config_fields
|
||||
config = ConfigParser()
|
||||
for section in config_fields.keys():
|
||||
config.add_section(section)
|
||||
|
|
@ -79,8 +85,8 @@ def write_config(get_attr, first_time=False):
|
|||
return config
|
||||
|
||||
|
||||
def read_config(get_attr, set_attr):
|
||||
global config_fields, config_dir, config_file
|
||||
def read_config(get_attr, set_attr, config_file):
|
||||
global config_fields, config_dir
|
||||
if not os.path.exists(config_dir):
|
||||
os.makedirs(config_dir)
|
||||
|
||||
|
|
@ -95,7 +101,7 @@ def read_config(get_attr, set_attr):
|
|||
except IOError, e:
|
||||
print "Error: config_file not found", e
|
||||
else:
|
||||
config = write_config(get_attr, True)
|
||||
config = write_config(get_attr, config_file, True)
|
||||
print "Welcome! Using `set` configure the necessary settings:"
|
||||
print " ".join(sorted(config_options))
|
||||
print "Config file:", config_file
|
||||
|
|
|
|||
|
|
@ -22,13 +22,9 @@ except ImportError:
|
|||
use_setuptools()
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
from cloudmonkey import __version__
|
||||
|
||||
name = 'cloudmonkey'
|
||||
version = __version__
|
||||
requires = ['Pygments>=1.5',
|
||||
'prettytable>=0.6',
|
||||
]
|
||||
from cloudmonkey import __version__, __description__
|
||||
from cloudmonkey import __maintainer__, __maintaineremail__
|
||||
from cloudmonkey import __project__, __projecturl__, __projectemail__
|
||||
|
||||
try:
|
||||
import readline
|
||||
|
|
@ -36,20 +32,22 @@ except ImportError:
|
|||
requires.append('readline')
|
||||
|
||||
setup(
|
||||
name = name,
|
||||
version = version,
|
||||
author = "The Apache CloudStack Team",
|
||||
author_email = "cloudstack-dev@incubator.apache.org",
|
||||
maintainer = "Rohit Yadav",
|
||||
maintainer_email = "bhaisaab@apache.org",
|
||||
url = "http://incubator.apache.org/cloudstack",
|
||||
description = "Command Line Interface for Apache CloudStack",
|
||||
long_description = "cloudmonkey is a command line interface for Apache "
|
||||
"CloudStack powered by CloudStack Marvin",
|
||||
name = 'cloudmonkey',
|
||||
version = __version__,
|
||||
author = __project__,
|
||||
author_email = __projectemail__,
|
||||
maintainer = __maintainer__,
|
||||
maintainer_email = __maintaineremail__,
|
||||
url = __projecturl__,
|
||||
description = __description__,
|
||||
long_description = "cloudmonkey is a CLI for Apache CloudStack",
|
||||
platforms = ("Any",),
|
||||
license = 'ASL 2.0',
|
||||
packages = find_packages(),
|
||||
install_requires = requires,
|
||||
install_requires = [
|
||||
'Pygments>=1.5',
|
||||
'prettytable>=0.6',
|
||||
],
|
||||
include_package_data = True,
|
||||
zip_safe = False,
|
||||
classifiers = [
|
||||
|
|
|
|||
|
|
@ -400,20 +400,28 @@ cloudStack.converters = {
|
|||
case 4 : return _l('label.public.ips');
|
||||
case 5 : return _l('label.management.ips');
|
||||
case 6 : return _l('label.secondary.storage');
|
||||
case 7 : return _l('label.vlan');
|
||||
case 8 : return _l('label.direct.ips');
|
||||
case 9 : return _l('label.local.storage');
|
||||
case 7 : return _l('label.host');
|
||||
case 9 : return _l('label.domain.router');
|
||||
case 10 : return _l('label.console.proxy');
|
||||
|
||||
// These are old values -- can be removed in the future
|
||||
case 10 : return "Routing Host";
|
||||
case 11 : return "Storage";
|
||||
case 12 : return "Usage Server";
|
||||
case 13 : return "Management Server";
|
||||
case 14 : return "Domain Router";
|
||||
case 15 : return "Console Proxy";
|
||||
case 16 : return "User VM";
|
||||
case 17 : return "VLAN";
|
||||
case 18 : return "Secondary Storage VM";
|
||||
// These are old values -- can be removed in the future
|
||||
case 8 : return "User VM";
|
||||
case 11 : return "Routing Host";
|
||||
case 12 : return "Storage";
|
||||
case 13 : return "Usage Server";
|
||||
case 14 : return "Management Server";
|
||||
case 15 : return "Domain Router";
|
||||
case 16 : return "Console Proxy";
|
||||
case 17 : return "User VM";
|
||||
case 18 : return "VLAN";
|
||||
case 19 : return "Secondary Storage VM";
|
||||
case 20 : return "Usage Server";
|
||||
case 21 : return "Storage";
|
||||
case 22 : return "Update Resource Count";
|
||||
case 23 : return "Usage Sanity Result";
|
||||
case 24 : return "Direct Attached Public IP";
|
||||
case 25 : return "Local Storage";
|
||||
case 26 : return "Resource Limit Exceeded";
|
||||
}
|
||||
},
|
||||
convertByType: function(alertCode, value) {
|
||||
|
|
|
|||
|
|
@ -7597,7 +7597,7 @@
|
|||
|
||||
if(vSwitchEnabled) {
|
||||
|
||||
items.push({ id:" nexusdvs" , description: "Cisco Nexus 1000v Distributed Virtual Switch"});
|
||||
items.push({ id:"nexusdvs" , description: "Cisco Nexus 1000v Distributed Virtual Switch"});
|
||||
items.push({id: "vmwaresvs", description: "VMware vNetwork Standard Virtual Switch"});
|
||||
items.push({id: "vmwaredvs", description: "VMware vNetwork Distributed Virtual Switch"});
|
||||
|
||||
|
|
@ -7610,7 +7610,7 @@
|
|||
else{
|
||||
items.push({id: "vmwaredvs", description: "VMware vNetwork Distributed Virtual Switch"});
|
||||
items.push({id: "vmwaresvs", description: "VMware vNetwork Standard Virtual Switch"});
|
||||
items.push({ id:" nexusdvs" , description: "Cisco Nexus 1000v Distributed Virtual Switch"});
|
||||
items.push({ id:"nexusdvs" , description: "Cisco Nexus 1000v Distributed Virtual Switch"});
|
||||
}
|
||||
|
||||
args.response.success({data: items});
|
||||
|
|
|
|||
|
|
@ -897,7 +897,7 @@
|
|||
|
||||
if(vSwitchEnabled) {
|
||||
|
||||
items.push({ id:" nexusdvs" , description: "Cisco Nexus 1000v Distributed Virtual Switch"});
|
||||
items.push({ id:"nexusdvs" , description: "Cisco Nexus 1000v Distributed Virtual Switch"});
|
||||
|
||||
items.push({id: "vmwaresvs", description: "VMware vNetwork Standard Virtual Switch"});
|
||||
items.push({id: "vmwaredvs", description: "VMware vNetwork Distributed Virtual Switch"});
|
||||
|
|
@ -909,9 +909,9 @@
|
|||
|
||||
// items.push({id: " ", description: " "});
|
||||
else{
|
||||
items.push({id: "vmwaredvs", description: "VMware vNetwork Distributed Virtual Switch"});
|
||||
items.push({id: "vmwaresvs", description: "VMware vNetwork Standard Virtual Switch"});
|
||||
items.push({ id:" nexusdvs" , description: "Cisco Nexus 1000v Distributed Virtual Switch"});
|
||||
items.push({id:"vmwaredvs", description: "VMware vNetwork Distributed Virtual Switch"});
|
||||
items.push({ id: "vmwaresvs", description: "VMware vNetwork Standard Virtual Switch"});
|
||||
items.push({ id:"nexusdvs" , description: "Cisco Nexus 1000v Distributed Virtual Switch"});
|
||||
|
||||
}
|
||||
args.response.success({data: items});
|
||||
|
|
|
|||
|
|
@ -0,0 +1,90 @@
|
|||
// 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
|
||||
// the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package com.cloud.utils.component;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
public class ComponentMethodProxyCache {
|
||||
|
||||
private static WeakHashMap<TargetKey, WeakReference<Method>> s_cache = new WeakHashMap<TargetKey, WeakReference<Method>>();
|
||||
|
||||
public ComponentMethodProxyCache() {
|
||||
}
|
||||
|
||||
public static Method getTargetMethod(Method method, Object target) {
|
||||
synchronized(s_cache) {
|
||||
WeakReference<Method> targetMethod = s_cache.get(new TargetKey(method, target));
|
||||
if(targetMethod != null && targetMethod.get() != null)
|
||||
return targetMethod.get();
|
||||
|
||||
Class<?> clazz = target.getClass();
|
||||
for(Method m : clazz.getMethods()) {
|
||||
if(isMethodMatched(method, m)) {
|
||||
s_cache.put(new TargetKey(method, target), new WeakReference<Method>(m));
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
return method;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isMethodMatched(Method m1, Method m2) {
|
||||
if(!m1.getName().equals(m2.getName()))
|
||||
return false;
|
||||
|
||||
Class<?>[] params1 = m1.getParameterTypes();
|
||||
Class<?>[] params2 = m2.getParameterTypes();
|
||||
|
||||
if(params1.length != params2.length)
|
||||
return false;
|
||||
|
||||
for(int i = 0; i < params1.length; i++) {
|
||||
if(!params1[i].isAssignableFrom(params2[i]))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static class TargetKey {
|
||||
Method _method;
|
||||
Object _target;
|
||||
|
||||
public TargetKey(Method method, Object target) {
|
||||
_method = method;
|
||||
_target = target;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if(!(obj instanceof TargetKey))
|
||||
return false;
|
||||
|
||||
// for target object, we just check the reference
|
||||
return _method.equals(((TargetKey)obj)._method) &&
|
||||
_target == ((TargetKey)obj)._target;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return _target.hashCode() ^ _target.hashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -38,5 +38,4 @@ public class SpringComponentScanUtils {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,9 +22,10 @@ import org.aopalliance.intercept.MethodInterceptor;
|
|||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.Signature;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
|
||||
import com.cloud.utils.component.ComponentMethodProxyCache;
|
||||
|
||||
public class TransactionContextBuilder implements MethodInterceptor {
|
||||
private static final Logger s_logger = Logger.getLogger(TransactionContextBuilder.class);
|
||||
public TransactionContextBuilder() {
|
||||
|
|
@ -72,14 +73,9 @@ public class TransactionContextBuilder implements MethodInterceptor {
|
|||
Class<?> clazz = method.getDeclaringClass();
|
||||
if(clazz.isInterface()) {
|
||||
clazz = target.getClass();
|
||||
for(Method m : clazz.getMethods()) {
|
||||
// it is supposed that we need to check against type arguments,
|
||||
// this can be simplified by just checking method name
|
||||
if(m.getName().equals(method.getName())) {
|
||||
if(m.getAnnotation(DB.class) != null)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Method targetMethod = ComponentMethodProxyCache.getTargetMethod(method, target);
|
||||
if(targetMethod != null && targetMethod.getAnnotation(DB.class) != null)
|
||||
return true;
|
||||
}
|
||||
|
||||
do {
|
||||
|
|
|
|||
Loading…
Reference in New Issue