Merge branch 'master' into ui-vpc-redesign

This commit is contained in:
Brian Federle 2013-05-16 10:12:11 -07:00
commit 8d9a8ca15e
81 changed files with 1544 additions and 412 deletions

View File

@ -0,0 +1,121 @@
// 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.
package com.cloud.agent.api;
import java.net.URI;
import com.cloud.utils.net.NetUtils;
public class PvlanSetupCommand extends Command {
public enum Type {
DHCP,
VM
}
private String op;
private String primary;
private String isolated;
private String vmMac;
private String dhcpName;
private String dhcpMac;
private String dhcpIp;
private Type type;
private String networkTag;
protected PvlanSetupCommand() {}
protected PvlanSetupCommand(Type type, String op, URI uri, String networkTag)
{
this.type = type;
this.op = op;
this.primary = NetUtils.getPrimaryPvlanFromUri(uri);
this.isolated = NetUtils.getIsolatedPvlanFromUri(uri);
this.networkTag = networkTag;
}
static public PvlanSetupCommand createDhcpSetup(String op, URI uri, String networkTag, String dhcpName, String dhcpMac, String dhcpIp)
{
PvlanSetupCommand cmd = new PvlanSetupCommand(Type.DHCP, op, uri, networkTag);
cmd.setDhcpName(dhcpName);
cmd.setDhcpMac(dhcpMac);
cmd.setDhcpIp(dhcpIp);
return cmd;
}
static public PvlanSetupCommand createVmSetup(String op, URI uri, String networkTag, String vmMac)
{
PvlanSetupCommand cmd = new PvlanSetupCommand(Type.VM, op, uri, networkTag);
cmd.setVmMac(vmMac);
return cmd;
}
@Override
public boolean executeInSequence() {
return true;
}
public String getOp() {
return op;
}
public String getPrimary() {
return primary;
}
public String getIsolated() {
return isolated;
}
public String getVmMac() {
return vmMac;
}
protected void setVmMac(String vmMac) {
this.vmMac = vmMac;
}
public String getDhcpMac() {
return dhcpMac;
}
protected void setDhcpMac(String dhcpMac) {
this.dhcpMac = dhcpMac;
}
public String getDhcpIp() {
return dhcpIp;
}
protected void setDhcpIp(String dhcpIp) {
this.dhcpIp = dhcpIp;
}
public Type getType() {
return type;
}
public String getDhcpName() {
return dhcpName;
}
public void setDhcpName(String dhcpName) {
this.dhcpName = dhcpName;
}
public String getNetworkTag() {
return networkTag;
}
}

View File

@ -134,6 +134,7 @@ public class EventTypes {
public static final String EVENT_REMOVE_FROM_GLOBAL_LOAD_BALANCER_RULE = "GLOBAL.LB.REMOVE";
public static final String EVENT_GLOBAL_LOAD_BALANCER_CREATE = "GLOBAL.LB.CREATE";
public static final String EVENT_GLOBAL_LOAD_BALANCER_DELETE = "GLOBAL.LB.DELETE";
public static final String EVENT_GLOBAL_LOAD_BALANCER_UPDATE = "GLOBAL.LB.UPDATE";
// Account events
public static final String EVENT_ACCOUNT_ENABLE = "ACCOUNT.ENABLE";

View File

@ -147,6 +147,7 @@ public enum Status {
s_fsm.addTransition(Status.Down, Event.Remove, Status.Removed);
s_fsm.addTransition(Status.Down, Event.ManagementServerDown, Status.Down);
s_fsm.addTransition(Status.Down, Event.AgentDisconnected, Status.Down);
s_fsm.addTransition(Status.Down, Event.PingTimeout, Status.Down);
s_fsm.addTransition(Status.Alert, Event.AgentConnected, Status.Connecting);
s_fsm.addTransition(Status.Alert, Event.Ping, Status.Up);
s_fsm.addTransition(Status.Alert, Event.Remove, Status.Removed);

View File

@ -63,6 +63,7 @@ public class Networks {
Storage("storage", Integer.class),
Lswitch("lswitch", String.class),
Mido("mido", String.class),
Pvlan("pvlan", String.class),
UnDecided(null, null);
private String scheme;

View File

@ -230,6 +230,7 @@ public class ApiConstants {
public static final String VLAN_RANGE = "vlanrange";
public static final String REMOVE_VLAN="removevlan";
public static final String VLAN_ID = "vlanid";
public static final String ISOLATED_PVLAN = "isolatedpvlan";
public static final String VM_AVAILABLE = "vmavailable";
public static final String VM_LIMIT = "vmlimit";
public static final String VM_TOTAL = "vmtotal";

View File

@ -80,6 +80,9 @@ public class CreateNetworkCmd extends BaseCmd {
@Parameter(name=ApiConstants.VLAN, type=CommandType.STRING, description="the ID or VID of the network")
private String vlan;
@Parameter(name=ApiConstants.ISOLATED_PVLAN, type=CommandType.STRING, description="the isolated private vlan for this network")
private String isolatedPvlan;
@Parameter(name=ApiConstants.NETWORK_DOMAIN, type=CommandType.STRING, description="network domain")
private String networkDomain;
@ -141,6 +144,10 @@ public class CreateNetworkCmd extends BaseCmd {
return vlan;
}
public String getIsolatedPvlan() {
return isolatedPvlan;
}
public String getAccountName() {
return accountName;
}

View File

@ -95,7 +95,7 @@ public class AssignToGlobalLoadBalancerRuleCmd extends BaseAsyncCmd {
@Override
public String getEventDescription() {
return "applying load balancer rules " + StringUtils.join(getLoadBalancerRulesIds(), ",") +
return "assign load balancer rules " + StringUtils.join(getLoadBalancerRulesIds(), ",") +
" to global load balancer rule " + getGlobalLoadBalancerRuleId();
}

View File

@ -85,7 +85,11 @@ public class CreateGlobalLoadBalancerRuleCmd extends BaseAsyncCreateCmd {
}
public String getAlgorithm() {
return algorithm;
if (algorithm != null) {
return algorithm;
} else {
return GlobalLoadBalancerRule.Algorithm.RoundRobin.name();
}
}
public String getGslbMethod() {
@ -158,7 +162,7 @@ public class CreateGlobalLoadBalancerRuleCmd extends BaseAsyncCreateCmd {
@Override
public String getEventDescription() {
return "creating a global load balancer: " + getName() + " for account: " + getAccountName();
return "creating a global load balancer rule Id: " + getEntityId();
}

View File

@ -77,12 +77,12 @@ public class DeleteGlobalLoadBalancerRuleCmd extends BaseAsyncCmd {
@Override
public String getEventType() {
return EventTypes.EVENT_LOAD_BALANCER_DELETE;
return EventTypes.EVENT_GLOBAL_LOAD_BALANCER_DELETE;
}
@Override
public String getEventDescription() {
return "deleting global load balancer: " + getGlobalLoadBalancerId();
return "deleting global load balancer rule: " + getGlobalLoadBalancerId();
}
@Override

View File

@ -17,11 +17,11 @@
package org.apache.cloudstack.api.command.user.region.ha.gslb;
import com.cloud.event.EventTypes;
import com.cloud.region.ha.GlobalLoadBalancerRule;
import com.cloud.region.ha.GlobalLoadBalancingRulesService;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.BaseListTaggedResourcesCmd;
import org.apache.cloudstack.api.Parameter;
import com.cloud.user.Account;
import org.apache.cloudstack.api.*;
import org.apache.cloudstack.api.response.GlobalLoadBalancerResponse;
import org.apache.cloudstack.api.response.LoadBalancerResponse;
import org.apache.log4j.Logger;
@ -29,7 +29,7 @@ import org.apache.log4j.Logger;
import javax.inject.Inject;
@APICommand(name = "updateGlobalLoadBalancerRule", description = "update global load balancer rules.", responseObject = LoadBalancerResponse.class)
public class UpdateGlobalLoadBalancerRuleCmd extends BaseListTaggedResourcesCmd {
public class UpdateGlobalLoadBalancerRuleCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(GlobalLoadBalancerResponse.class.getName());
private static final String s_name = "updategloballoadbalancerruleresponse";
@ -88,9 +88,27 @@ public class UpdateGlobalLoadBalancerRuleCmd extends BaseListTaggedResourcesCmd
return s_name;
}
@Override
public long getEntityOwnerId() {
GlobalLoadBalancerRule lb = _entityMgr.findById(GlobalLoadBalancerRule.class, getId());
if (lb != null) {
return lb.getAccountId();
}
return Account.ACCOUNT_ID_SYSTEM;
}
@Override
public void execute() {
_gslbService.updateGlobalLoadBalancerRule(this);
}
@Override
public String getEventType() {
return EventTypes.EVENT_GLOBAL_LOAD_BALANCER_UPDATE;
}
@Override
public String getEventDescription() {
return null;
}
}

View File

@ -41,9 +41,9 @@ under the License.
<para>You probably want to ensure that your environment variables will survive a logout/reboot.
Be sure to update <filename>~/.bashrc</filename> with the PATH and JAVA_HOME variables.</para>
<para>Building RPMs for $PRODUCT; is fairly simple. Assuming you already have the source downloaded and have uncompressed the tarball into a local directory, you're going to be able to generate packages in just a few minutes.</para>
<para>Building RPMs for &PRODUCT; is fairly simple. Assuming you already have the source downloaded and have uncompressed the tarball into a local directory, you're going to be able to generate packages in just a few minutes.</para>
<note><title>Packaging has Changed</title>
<para>If you've created packages for $PRODUCT; previously, you should be aware that the process has changed considerably since the project has moved to using Apache Maven. Please be sure to follow the steps in this section closely.</para>
<para>If you've created packages for &PRODUCT; previously, you should be aware that the process has changed considerably since the project has moved to using Apache Maven. Please be sure to follow the steps in this section closely.</para>
</note>
<section id="generating-rpms">
<title>Generating RPMS</title>
@ -69,7 +69,7 @@ under the License.
<title>Configuring your systems to use your new yum repository</title>
<para>
Now that your yum repository is populated with RPMs and metadata
we need to configure the machines that need to install $PRODUCT;.
we need to configure the machines that need to install &PRODUCT;.
Create a file named <filename>/etc/yum.repos.d/cloudstack.repo</filename> with this information:
<programlisting>
[apache-cloudstack]
@ -79,7 +79,7 @@ under the License.
gpgcheck=0
</programlisting>
</para>
<para> Completing this step will allow you to easily install $PRODUCT; on a number of machines across the network.
<para> Completing this step will allow you to easily install &PRODUCT; on a number of machines across the network.
</para>
</section>
</section>

View File

@ -49,7 +49,7 @@
multi-node Management Server installation and up to tens of thousands of
hosts using any of several advanced networking setups. For
information about deployment options, see the "Choosing a Deployment Architecture"
section of the $PRODUCT; Installation Guide.
section of the &PRODUCT; Installation Guide.
</para>
<xi:include href="management-server-overview.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
<xi:include href="cloud-infrastructure-overview.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />

View File

@ -24,7 +24,7 @@
<para>Event notification framework provides a means for the Management Server components to
publish and subscribe to &PRODUCT; events. Event notification is achieved by implementing the
concept of event bus abstraction in the Management Server. An event bus is introduced in the
Management Server that allows the &PRODUCT;components and extension plug-ins to subscribe to the
Management Server that allows the &PRODUCT; components and extension plug-ins to subscribe to the
events by using the Advanced Message Queuing Protocol (AMQP) client. In &PRODUCT;, a default
implementation of event bus is provided as a plug-in that uses the RabbitMQ AMQP client. The
AMQP client pushes the published events to a compatible AMQP server. Therefore all the &PRODUCT;

View File

@ -45,7 +45,7 @@
<para>A typical GSLB environment is comprised of the following components:</para>
<itemizedlist>
<listitem>
<para><emphasis role="bold">GSLB Site</emphasis>: In &PRODUCT;terminology, GSLB sites are
<para><emphasis role="bold">GSLB Site</emphasis>: In &PRODUCT; terminology, GSLB sites are
represented by zones that are mapped to data centers, each of which has various network
appliances. Each GSLB site is managed by a NetScaler appliance that is local to that
site. Each of these appliances treats its own site as the local site and all other

View File

@ -21,7 +21,7 @@
-->
<section id="ipv6-support">
<title>IPv6 Support in &PRODUCT;</title>
<para>&PRODUCT;supports Internet Protocol version 6 (IPv6), the recent version of the Internet
<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,

View File

@ -21,7 +21,7 @@
-->
<section id="vmware-cluster-config-dvswitch">
<title>Configuring a vSphere Cluster with VMware Distributed Virtual Switch</title>
<para>&PRODUCT;supports VMware vNetwork Distributed Switch (VDS) for virtual network configuration
<para>&PRODUCT; supports VMware vNetwork Distributed Switch (VDS) for virtual network configuration
in a VMware vSphere environment. This section helps you configure VMware VDS in a &PRODUCT;
deployment. Each vCenter server instance can support up to 128 VDS instances and each VDS
instance can manage up to 500 VMware hosts.</para>

View File

@ -16,6 +16,8 @@
// under the License.
package org.apache.cloudstack.engine.datacenter.entity.api.db.dao;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -30,18 +32,19 @@ import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
import com.cloud.utils.db.Transaction;
import com.cloud.utils.exception.CloudRuntimeException;
@Component(value="EngineHostDetailsDao")
@Local(value=HostDetailsDao.class)
public class HostDetailsDaoImpl extends GenericDaoBase<DetailVO, Long> implements HostDetailsDao {
protected final SearchBuilder<DetailVO> HostSearch;
protected final SearchBuilder<DetailVO> DetailSearch;
public HostDetailsDaoImpl() {
HostSearch = createSearchBuilder();
HostSearch.and("hostId", HostSearch.entity().getHostId(), SearchCriteria.Op.EQ);
HostSearch.done();
DetailSearch = createSearchBuilder();
DetailSearch.and("hostId", DetailSearch.entity().getHostId(), SearchCriteria.Op.EQ);
DetailSearch.and("name", DetailSearch.entity().getName(), SearchCriteria.Op.EQ);
@ -53,7 +56,7 @@ public class HostDetailsDaoImpl extends GenericDaoBase<DetailVO, Long> implement
SearchCriteria<DetailVO> sc = DetailSearch.create();
sc.setParameters("hostId", hostId);
sc.setParameters("name", name);
DetailVO detail = findOneIncludingRemovedBy(sc);
if("password".equals(name) && detail != null){
detail.setValue(DBEncryptionUtil.decrypt(detail.getValue()));
@ -65,7 +68,7 @@ public class HostDetailsDaoImpl extends GenericDaoBase<DetailVO, Long> implement
public Map<String, String> findDetails(long hostId) {
SearchCriteria<DetailVO> sc = HostSearch.create();
sc.setParameters("hostId", hostId);
List<DetailVO> results = search(sc, null);
Map<String, String> details = new HashMap<String, String>(results.size());
for (DetailVO result : results) {
@ -77,12 +80,12 @@ public class HostDetailsDaoImpl extends GenericDaoBase<DetailVO, Long> implement
}
return details;
}
@Override
public void deleteDetails(long hostId) {
SearchCriteria sc = HostSearch.create();
sc.setParameters("hostId", hostId);
List<DetailVO> results = search(sc, null);
for (DetailVO result : results) {
remove(result.getId());
@ -91,19 +94,27 @@ public class HostDetailsDaoImpl extends GenericDaoBase<DetailVO, Long> implement
@Override
public void persist(long hostId, Map<String, String> details) {
final String InsertOrUpdateSql = "INSERT INTO `cloud`.`host_details` (host_id, name, value) VALUES (?,?,?) ON DUPLICATE KEY UPDATE value=?";
Transaction txn = Transaction.currentTxn();
txn.start();
SearchCriteria<DetailVO> sc = HostSearch.create();
sc.setParameters("hostId", hostId);
expunge(sc);
for (Map.Entry<String, String> detail : details.entrySet()) {
String value = detail.getValue();
if("password".equals(detail.getKey())){
value = DBEncryptionUtil.encrypt(value);
}
DetailVO vo = new DetailVO(hostId, detail.getKey(), value);
persist(vo);
String value = detail.getValue();
if ("password".equals(detail.getKey())) {
value = DBEncryptionUtil.encrypt(value);
}
try {
PreparedStatement pstmt = txn.prepareAutoCloseStatement(InsertOrUpdateSql);
pstmt.setLong(1, hostId);
pstmt.setString(2, detail.getKey());
pstmt.setString(3, value);
pstmt.setString(4, value);
pstmt.executeUpdate();
} catch (SQLException e) {
throw new CloudRuntimeException("Unable to persist the host_details key: " + detail.getKey()
+ " for host id: " + hostId, e);
}
}
txn.commit();
}

View File

@ -16,6 +16,8 @@
// under the License.
package com.cloud.host.dao;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -30,18 +32,19 @@ import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
import com.cloud.utils.db.Transaction;
import com.cloud.utils.exception.CloudRuntimeException;
@Component
@Local(value=HostDetailsDao.class)
public class HostDetailsDaoImpl extends GenericDaoBase<DetailVO, Long> implements HostDetailsDao {
protected final SearchBuilder<DetailVO> HostSearch;
protected final SearchBuilder<DetailVO> DetailSearch;
public HostDetailsDaoImpl() {
HostSearch = createSearchBuilder();
HostSearch.and("hostId", HostSearch.entity().getHostId(), SearchCriteria.Op.EQ);
HostSearch.done();
DetailSearch = createSearchBuilder();
DetailSearch.and("hostId", DetailSearch.entity().getHostId(), SearchCriteria.Op.EQ);
DetailSearch.and("name", DetailSearch.entity().getName(), SearchCriteria.Op.EQ);
@ -53,7 +56,7 @@ public class HostDetailsDaoImpl extends GenericDaoBase<DetailVO, Long> implement
SearchCriteria<DetailVO> sc = DetailSearch.create();
sc.setParameters("hostId", hostId);
sc.setParameters("name", name);
DetailVO detail = findOneIncludingRemovedBy(sc);
if("password".equals(name) && detail != null){
detail.setValue(DBEncryptionUtil.decrypt(detail.getValue()));
@ -65,7 +68,7 @@ public class HostDetailsDaoImpl extends GenericDaoBase<DetailVO, Long> implement
public Map<String, String> findDetails(long hostId) {
SearchCriteria<DetailVO> sc = HostSearch.create();
sc.setParameters("hostId", hostId);
List<DetailVO> results = search(sc, null);
Map<String, String> details = new HashMap<String, String>(results.size());
for (DetailVO result : results) {
@ -77,12 +80,12 @@ public class HostDetailsDaoImpl extends GenericDaoBase<DetailVO, Long> implement
}
return details;
}
@Override
public void deleteDetails(long hostId) {
SearchCriteria sc = HostSearch.create();
sc.setParameters("hostId", hostId);
List<DetailVO> results = search(sc, null);
for (DetailVO result : results) {
remove(result.getId());
@ -91,19 +94,27 @@ public class HostDetailsDaoImpl extends GenericDaoBase<DetailVO, Long> implement
@Override
public void persist(long hostId, Map<String, String> details) {
final String InsertOrUpdateSql = "INSERT INTO `cloud`.`host_details` (host_id, name, value) VALUES (?,?,?) ON DUPLICATE KEY UPDATE value=?";
Transaction txn = Transaction.currentTxn();
txn.start();
SearchCriteria<DetailVO> sc = HostSearch.create();
sc.setParameters("hostId", hostId);
expunge(sc);
for (Map.Entry<String, String> detail : details.entrySet()) {
String value = detail.getValue();
if("password".equals(detail.getKey())){
value = DBEncryptionUtil.encrypt(value);
}
DetailVO vo = new DetailVO(hostId, detail.getKey(), value);
persist(vo);
String value = detail.getValue();
if ("password".equals(detail.getKey())) {
value = DBEncryptionUtil.encrypt(value);
}
try {
PreparedStatement pstmt = txn.prepareAutoCloseStatement(InsertOrUpdateSql);
pstmt.setLong(1, hostId);
pstmt.setString(2, detail.getKey());
pstmt.setString(3, value);
pstmt.setString(4, value);
pstmt.executeUpdate();
} catch (SQLException e) {
throw new CloudRuntimeException("Unable to persist the host_details key: " + detail.getKey()
+ " for host id: " + hostId, e);
}
}
txn.commit();
}

View File

@ -113,4 +113,6 @@ public interface NetworkDao extends GenericDao<NetworkVO, Long> , StateDao<State
List<NetworkVO> listRedundantNetworks();
List<NetworkVO> listByAclId(long aclId);
int getNonSystemNetworkCountByVpcId(long vpcId);
}

View File

@ -162,6 +162,9 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
CountBy.and("offeringId", CountBy.entity().getNetworkOfferingId(), Op.EQ);
CountBy.and("vpcId", CountBy.entity().getVpcId(), Op.EQ);
CountBy.and("removed", CountBy.entity().getRemoved(), Op.NULL);
SearchBuilder<NetworkOfferingVO> ntwkOffJoin = _ntwkOffDao.createSearchBuilder();
ntwkOffJoin.and("isSystem", ntwkOffJoin.entity().isSystemOnly(), Op.EQ);
CountBy.join("offerings", ntwkOffJoin, CountBy.entity().getNetworkOfferingId(), ntwkOffJoin.entity().getId(), JoinBuilder.JoinType.INNER);
CountBy.done();
PhysicalNetworkSearch = createSearchBuilder();
@ -627,4 +630,14 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N
return listBy(sc, null);
}
@Override
public int getNonSystemNetworkCountByVpcId(long vpcId) {
SearchCriteria<Integer> sc = CountBy.create();
sc.setParameters("vpcId", vpcId);
sc.setJoinParameters("offerings", "isSystem", false);
List<Integer> results = customSearch(sc, null);
return results.get(0);
}
}

View File

@ -73,9 +73,11 @@ public class Upgrade410to420 implements DbUpgrade {
upgradeDefaultVpcOffering(conn);
upgradePhysicalNtwksWithInternalLbProvider(conn);
updateNetworkACLs(conn);
addHostDetailsIndex(conn);
updateNetworksForPrivateGateways(conn);
}
private void updateSystemVmTemplates(Connection conn) {
private void updateSystemVmTemplates(Connection conn) {
PreparedStatement sql = null;
try {
sql = conn.prepareStatement("update vm_template set image_data_store_id = 1 where type = 'SYSTEM' or type = 'BUILTIN'");
@ -91,7 +93,7 @@ public class Upgrade410to420 implements DbUpgrade {
}
}
}
private void updatePrimaryStore(Connection conn) {
PreparedStatement sql = null;
PreparedStatement sql2 = null;
@ -100,7 +102,7 @@ public class Upgrade410to420 implements DbUpgrade {
sql.setString(1, "ancient primary data store provider");
sql.setString(2, "HOST");
sql.executeUpdate();
sql2 = conn.prepareStatement("update storage_pool set storage_provider_name = ? , scope = ? where pool_type != 'Filesystem' and pool_type != 'LVM'");
sql2.setString(1, "ancient primary data store provider");
sql2.setString(2, "CLUSTER");
@ -114,7 +116,7 @@ public class Upgrade410to420 implements DbUpgrade {
} catch (SQLException e) {
}
}
if (sql2 != null) {
try {
sql2.close();
@ -242,7 +244,7 @@ public class Upgrade410to420 implements DbUpgrade {
}
}
}
private void createPlaceHolderNics(Connection conn) {
PreparedStatement pstmt = null;
ResultSet rs = null;
@ -263,7 +265,7 @@ public class Upgrade410to420 implements DbUpgrade {
pstmt.setLong(4, networkId);
pstmt.executeUpdate();
s_logger.debug("Created placeholder nic for the ipAddress " + ip);
}
} catch (SQLException e) {
throw new CloudRuntimeException("Unable to create placeholder nics", e);
@ -279,8 +281,8 @@ public class Upgrade410to420 implements DbUpgrade {
}
}
}
private void updateRemoteAccessVpn(Connection conn) {
PreparedStatement pstmt = null;
ResultSet rs = null;
@ -560,10 +562,9 @@ public class Upgrade410to420 implements DbUpgrade {
}
}
}
private void upgradeDefaultVpcOffering(Connection conn) {
private void upgradeDefaultVpcOffering(Connection conn) {
PreparedStatement pstmt = null;
ResultSet rs = null;
@ -579,7 +580,7 @@ public class Upgrade410to420 implements DbUpgrade {
pstmt.setString(3, "InternalLbVm");
pstmt.executeUpdate();
}
} catch (SQLException e) {
throw new CloudRuntimeException("Unable update the default VPC offering with the internal lb service", e);
} finally {
@ -594,9 +595,9 @@ public class Upgrade410to420 implements DbUpgrade {
}
}
}
private void upgradePhysicalNtwksWithInternalLbProvider(Connection conn) {
PreparedStatement pstmt = null;
@ -615,7 +616,7 @@ public class Upgrade410to420 implements DbUpgrade {
pstmt.setString(1, uuid);
pstmt.setLong(2, pNtwkId);
pstmt.executeUpdate();
//Add internal lb vm to the list of physical network elements
PreparedStatement pstmt1 = conn.prepareStatement("SELECT id FROM `cloud`.`physical_network_service_providers`" +
" WHERE physical_network_id=? AND provider_name='InternalLbVm'");
@ -629,7 +630,7 @@ public class Upgrade410to420 implements DbUpgrade {
pstmt1.executeUpdate();
}
}
} catch (SQLException e) {
throw new CloudRuntimeException("Unable existing physical networks with internal lb provider", e);
} finally {
@ -643,6 +644,63 @@ public class Upgrade410to420 implements DbUpgrade {
} catch (SQLException e) {
}
}
}
private void addHostDetailsIndex(Connection conn) {
s_logger.debug("Checking if host_details index exists, if not we will add it");
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = conn.prepareStatement("SHOW INDEX FROM `cloud`.`host_details` where KEY_NAME = 'fk_host_details__host_id'");
rs = pstmt.executeQuery();
if (rs.next()) {
s_logger.debug("Index already exists on host_details - not adding new one");
} else {
// add the index
PreparedStatement pstmtUpdate = conn.prepareStatement("ALTER IGNORE TABLE `cloud`.`host_details` ADD INDEX `fk_host_details__host_id` (`host_id`)");
pstmtUpdate.executeUpdate();
s_logger.debug("Index did not exist on host_details - added new one");
pstmtUpdate.close();
}
} catch (SQLException e) {
throw new CloudRuntimeException("Failed to check/update the host_details index ", e);
} finally {
try {
if (rs != null) {
rs.close();
}
if (pstmt != null) {
pstmt.close();
}
} catch (SQLException e) {
}
}
}
private void updateNetworksForPrivateGateways(Connection conn) {
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
//1) get all non removed gateways
pstmt = conn.prepareStatement("SELECT network_id, vpc_id FROM `cloud`.`vpc_gateways` WHERE type='Private' AND removed IS null");
rs = pstmt.executeQuery();
while (rs.next()) {
Long networkId = rs.getLong(1);
Long vpcId = rs.getLong(2);
//2) Update networks with vpc_id if its set to NULL
pstmt = conn.prepareStatement("UPDATE `cloud`.`networks` set vpc_id=? where id=? and vpc_id is NULL and removed is NULL");
pstmt.setLong(1, vpcId);
pstmt.setLong(2, networkId);
pstmt.executeUpdate();
}
} catch (SQLException e) {
throw new CloudRuntimeException("Failed to update private networks with VPC id.", e);
}
}
}

View File

@ -118,18 +118,18 @@ public class UsageNetworkOfferingDaoImpl extends GenericDaoBase<UsageNetworkOffe
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
//zoneId, account_id, domain_id, vm_instance_id, network_offering_id, is_default, created, deleted
//zoneId, account_id, domain_id, vm_instance_id, network_offering_id, nic_id, is_default, created, deleted
Long zoneId = Long.valueOf(rs.getLong(1));
Long acctId = Long.valueOf(rs.getLong(2));
Long dId = Long.valueOf(rs.getLong(3));
long vmId = Long.valueOf(rs.getLong(4));
long noId = Long.valueOf(rs.getLong(5));
long nicId = Long.valueOf(rs.getLong(6));
boolean isDefault = Boolean.valueOf(rs.getBoolean(6));
boolean isDefault = Boolean.valueOf(rs.getBoolean(7));
Date createdDate = null;
Date deletedDate = null;
String createdTS = rs.getString(7);
String deletedTS = rs.getString(8);
String createdTS = rs.getString(8);
String deletedTS = rs.getString(9);
if (createdTS != null) {

View File

@ -434,6 +434,12 @@ setup_common() {
ping -n -c 3 $MGMT_GW &
sleep 3
pkill ping
fi
local hyp=$(hypervisor)
if [ "$hyp" == "vmware" ]; then
ntpq -p &> /dev/null || vmware-toolbox-cmd timesync enable
fi
}

View File

@ -125,6 +125,7 @@ import com.cloud.agent.api.PlugNicAnswer;
import com.cloud.agent.api.PlugNicCommand;
import com.cloud.agent.api.PrepareForMigrationAnswer;
import com.cloud.agent.api.PrepareForMigrationCommand;
import com.cloud.agent.api.PvlanSetupCommand;
import com.cloud.agent.api.ReadyAnswer;
import com.cloud.agent.api.ReadyCommand;
import com.cloud.agent.api.RebootAnswer;
@ -267,6 +268,8 @@ ServerResource {
private String _createTmplPath;
private String _heartBeatPath;
private String _securityGroupPath;
private String _ovsPvlanDhcpHostPath;
private String _ovsPvlanVmPath;
private String _routerProxyPath;
private String _host;
private String _dcId;
@ -587,6 +590,18 @@ ServerResource {
"Unable to find the router_proxy.sh");
}
_ovsPvlanDhcpHostPath = Script.findScript(networkScriptsDir, "ovs-pvlan-dhcp-host.sh");
if ( _ovsPvlanDhcpHostPath == null) {
throw new ConfigurationException(
"Unable to find the ovs-pvlan-dhcp-host.sh");
}
_ovsPvlanVmPath = Script.findScript(networkScriptsDir, "ovs-pvlan-vm.sh");
if ( _ovsPvlanVmPath == null) {
throw new ConfigurationException(
"Unable to find the ovs-pvlan-vm.sh");
}
String value = (String) params.get("developer");
boolean isDeveloper = Boolean.parseBoolean(value);
@ -1202,6 +1217,8 @@ ServerResource {
return execute((CheckNetworkCommand) cmd);
} else if (cmd instanceof NetworkRulesVmSecondaryIpCommand) {
return execute((NetworkRulesVmSecondaryIpCommand) cmd);
} else if (cmd instanceof PvlanSetupCommand) {
return execute((PvlanSetupCommand) cmd);
} else {
s_logger.warn("Unsupported command ");
return Answer.createUnsupportedCommandAnswer(cmd);
@ -1517,6 +1534,65 @@ ServerResource {
}
}
private Answer execute(PvlanSetupCommand cmd) {
String primaryPvlan = cmd.getPrimary();
String isolatedPvlan = cmd.getIsolated();
String op = cmd.getOp();
String dhcpName = cmd.getDhcpName();
String dhcpMac = cmd.getDhcpMac();
String dhcpIp = cmd.getDhcpIp();
String vmMac = cmd.getVmMac();
boolean add = true;
String opr = "-A";
if (op.equals("delete")) {
opr = "-D";
add = false;
}
String result = null;
Connect conn;
try {
if (cmd.getType() == PvlanSetupCommand.Type.DHCP) {
Script script = new Script(_ovsPvlanDhcpHostPath, _timeout, s_logger);
if (add) {
conn = LibvirtConnection.getConnectionByVmName(dhcpName);
List<InterfaceDef> ifaces = getInterfaces(conn, dhcpName);
InterfaceDef guestNic = ifaces.get(0);
script.add(opr, "-b", _guestBridgeName,
"-p", primaryPvlan, "-i", isolatedPvlan, "-n", dhcpName,
"-d", dhcpIp, "-m", dhcpMac, "-I", guestNic.getDevName());
} else {
script.add(opr, "-b", _guestBridgeName,
"-p", primaryPvlan, "-i", isolatedPvlan, "-n", dhcpName,
"-d", dhcpIp, "-m", dhcpMac);
}
result = script.execute();
if (result != null) {
s_logger.warn("Failed to program pvlan for dhcp server with mac " + dhcpMac);
return new Answer(cmd, false, result);
} else {
s_logger.info("Programmed pvlan for dhcp server with mac " + dhcpMac);
}
} else if (cmd.getType() == PvlanSetupCommand.Type.VM) {
Script script = new Script(_ovsPvlanVmPath, _timeout, s_logger);
script.add(opr, "-b", _guestBridgeName,
"-p", primaryPvlan, "-i", isolatedPvlan, "-v", vmMac);
result = script.execute();
if (result != null) {
s_logger.warn("Failed to program pvlan for vm with mac " + vmMac);
return new Answer(cmd, false, result);
} else {
s_logger.info("Programmed pvlan for vm with mac " + vmMac);
}
}
} catch (LibvirtException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return new Answer(cmd, true, result);
}
private void VifHotPlug(Connect conn, String vmName, String vlanId,
String macAddr) throws InternalErrorException, LibvirtException {
NicTO nicTO = new NicTO();

View File

@ -76,10 +76,12 @@ public class OvsVifDriver extends VifDriverBase {
}
else if (nic.getBroadcastType() == Networks.BroadcastDomainType.Lswitch) {
logicalSwitchUuid = nic.getBroadcastUri().getSchemeSpecificPart();
} else if (nic.getBroadcastType() == Networks.BroadcastDomainType.Pvlan) {
vlanId = NetUtils.getPrimaryPvlanFromUri(nic.getBroadcastUri());
}
String trafficLabel = nic.getName();
if (nic.getType() == Networks.TrafficType.Guest) {
if (nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan
if ((nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan || nic.getBroadcastType() == Networks.BroadcastDomainType.Pvlan)
&& !vlanId.equalsIgnoreCase("untagged")) {
if(trafficLabel != null && !trafficLabel.isEmpty()) {
s_logger.debug("creating a vlan dev and bridge for guest traffic per traffic label " + trafficLabel);

View File

@ -83,6 +83,7 @@ import com.cloud.agent.api.PlugNicCommand;
import com.cloud.agent.api.PoolEjectCommand;
import com.cloud.agent.api.PrepareForMigrationAnswer;
import com.cloud.agent.api.PrepareForMigrationCommand;
import com.cloud.agent.api.PvlanSetupCommand;
import com.cloud.agent.api.ReadyAnswer;
import com.cloud.agent.api.ReadyCommand;
import com.cloud.agent.api.RebootAnswer;
@ -614,6 +615,8 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
return execute((NetworkRulesVmSecondaryIpCommand)cmd);
} else if (clazz == ScaleVmCommand.class) {
return execute((ScaleVmCommand) cmd);
} else if (clazz == PvlanSetupCommand.class) {
return execute((PvlanSetupCommand) cmd);
} else {
return Answer.createUnsupportedCommandAnswer(cmd);
}
@ -1030,6 +1033,11 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
} else if (nic.getBroadcastType() == BroadcastDomainType.Lswitch) {
// Nicira Logical Switch
return network.getNetwork();
} else if (nic.getBroadcastType() == BroadcastDomainType.Pvlan) {
URI broadcastUri = nic.getBroadcastUri();
assert broadcastUri.getScheme().equals(BroadcastDomainType.Pvlan.scheme());
long vlan = Long.parseLong(NetUtils.getPrimaryPvlanFromUri(broadcastUri));
return enableVlanNetwork(conn, vlan, network);
}
throw new CloudRuntimeException("Unable to support this type of network broadcast domain: " + nic.getBroadcastUri());
@ -1065,7 +1073,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
vifr = vif.getRecord(conn);
s_logger.debug("Created a vif " + vifr.uuid + " on " + nic.getDeviceId());
}
return vif;
}
@ -1476,6 +1484,55 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
}
}
}
private Answer execute(PvlanSetupCommand cmd) {
Connection conn = getConnection();
String primaryPvlan = cmd.getPrimary();
String isolatedPvlan = cmd.getIsolated();
String op = cmd.getOp();
String dhcpName = cmd.getDhcpName();
String dhcpMac = cmd.getDhcpMac();
String dhcpIp = cmd.getDhcpIp();
String vmMac = cmd.getVmMac();
String networkTag = cmd.getNetworkTag();
XsLocalNetwork nw = null;
String nwNameLabel = null;
try {
nw = getNativeNetworkForTraffic(conn, TrafficType.Guest, networkTag);
nwNameLabel = nw.getNetwork().getNameLabel(conn);
} catch (XenAPIException e) {
s_logger.warn("Fail to get network", e);
return new Answer(cmd, false, e.toString());
} catch (XmlRpcException e) {
s_logger.warn("Fail to get network", e);
return new Answer(cmd, false, e.toString());
}
String result = null;
if (cmd.getType() == PvlanSetupCommand.Type.DHCP) {
result = callHostPlugin(conn, "ovs-pvlan", "setup-pvlan-dhcp", "op", op, "nw-label", nwNameLabel,
"primary-pvlan", primaryPvlan, "isolated-pvlan", isolatedPvlan, "dhcp-name", dhcpName,
"dhcp-ip", dhcpIp, "dhcp-mac", dhcpMac);
if (result == null || result.isEmpty() || !Boolean.parseBoolean(result)) {
s_logger.warn("Failed to program pvlan for dhcp server with mac " + dhcpMac);
return new Answer(cmd, false, result);
} else {
s_logger.info("Programmed pvlan for dhcp server with mac " + dhcpMac);
}
} else if (cmd.getType() == PvlanSetupCommand.Type.VM) {
result = callHostPlugin(conn, "ovs-pvlan", "setup-pvlan-vm", "op", op, "nw-label", nwNameLabel,
"primary-pvlan", primaryPvlan, "isolated-pvlan", isolatedPvlan, "vm-mac", vmMac);
if (result == null || result.isEmpty() || !Boolean.parseBoolean(result)) {
s_logger.warn("Failed to program pvlan for vm with mac " + vmMac);
return new Answer(cmd, false, result);
} else {
s_logger.info("Programmed pvlan for vm with mac " + vmMac);
}
}
return new Answer(cmd, true, result);
}
@Override
public StartAnswer execute(StartCommand cmd) {

View File

@ -80,7 +80,7 @@ under the License.
</pair>
<pair key="%aclruledn%/rule-cond-3/nw-expr2/nw-attr-qual">
<policyNwAttrQualifier
attrEp="destination"
attrEp="source"
dn="%aclruledn%/rule-cond-3/nw-expr2/nw-attr-qual"
status="created"/>
</pair>
@ -93,7 +93,7 @@ under the License.
name=""
placement="begin"
status="created"
value="%deststartip%"/>
value="%sourcestartip%"/>
</pair>
<pair key="%aclruledn%/rule-cond-3/nw-expr2/nw-ip-3">
<policyIPAddress
@ -104,7 +104,7 @@ under the License.
name=""
placement="end"
status="created"
value="%destendip%"/>
value="%sourceendip%"/>
</pair>
<pair key="%aclruledn%/rule-cond-4">
@ -161,8 +161,8 @@ under the License.
descr=value
actiontype="drop" or "permit"
protocolvalue = "TCP" or "UDP"
deststartip="destination start ip"
destendip="destination end ip"
sourcestartip="source start ip"
sourceendip="source end ip"
deststartport="start port at destination"
destendport="end port at destination"
--!>

View File

@ -54,7 +54,7 @@ under the License.
</pair>
<pair key="%aclruledn%/rule-cond-2/nw-expr2/nw-attr-qual">
<policyNwAttrQualifier
attrEp="destination"
attrEp="source"
dn="%aclruledn%/rule-cond-2/nw-expr2/nw-attr-qual"
status="created"/>
</pair>
@ -67,7 +67,7 @@ under the License.
name=""
placement="begin"
status="created"
value="%deststartip%"/>
value="%sourcestartip%"/>
</pair>
<pair key="%aclruledn%/rule-cond-2/nw-expr2/nw-ip-3">
<policyIPAddress
@ -78,7 +78,7 @@ under the License.
name=""
placement="end"
status="created"
value="%destendip%"/>
value="%sourceendip%"/>
</pair>
</inConfigs>
@ -89,6 +89,6 @@ under the License.
aclrulename="dummy"
descr=value
actiontype="drop" or "permit"
deststartip="destination start ip"
destendip="destination end ip"
sourcestartip="source start ip"
sourceendip="source end ip"
--!>

View File

@ -80,7 +80,7 @@ under the License.
</pair>
<pair key="%aclruledn%/rule-cond-3/nw-expr2/nw-attr-qual">
<policyNwAttrQualifier
attrEp="destination"
attrEp="source"
dn="%aclruledn%/rule-cond-3/nw-expr2/nw-attr-qual"
status="created"/>
</pair>
@ -93,7 +93,7 @@ under the License.
name=""
placement="begin"
status="created"
value="%deststartip%"/>
value="%sourcestartip%"/>
</pair>
<pair key="%aclruledn%/rule-cond-3/nw-expr2/nw-ip-3">
<policyIPAddress
@ -104,7 +104,7 @@ under the License.
name=""
placement="end"
status="created"
value="%destendip%"/>
value="%sourceendip%"/>
</pair>
</inConfigs>
@ -116,6 +116,6 @@ under the License.
descr=value
actiontype="drop" or "permit"
protocolvalue = "TCP" or "UDP" or "ICMP"
deststartip="destination start ip"
destendip="destination end ip"
sourcestartip="source start ip"
sourceendip="source end ip"
--!>

View File

@ -150,13 +150,13 @@ public interface CiscoVnmcConnection {
public boolean createTenantVDCEgressAclRule(String tenantName,
String identifier, String policyIdentifier,
String protocol, String destStartIp, String destEndIp,
String protocol, String sourceStartIp, String sourceEndIp,
String destStartPort, String destEndPort)
throws ExecutionException;
public boolean createTenantVDCEgressAclRule(String tenantName,
String identifier, String policyIdentifier,
String protocol, String destStartIp, String destEndIp)
String protocol, String sourceStartIp, String sourceEndIp)
throws ExecutionException;
public boolean deleteTenantVDCAclRule(String tenantName,

View File

@ -729,7 +729,7 @@ public class CiscoVnmcConnectionImpl implements CiscoVnmcConnection {
@Override
public boolean createTenantVDCEgressAclRule(String tenantName,
String identifier, String policyIdentifier,
String protocol, String destStartIp, String destEndIp,
String protocol, String sourceStartIp, String sourceEndIp,
String destStartPort, String destEndPort) throws ExecutionException {
String xml = VnmcXml.CREATE_EGRESS_ACL_RULE.getXml();
String service = VnmcXml.CREATE_EGRESS_ACL_RULE.getService();
@ -740,8 +740,8 @@ public class CiscoVnmcConnectionImpl implements CiscoVnmcConnection {
xml = replaceXmlValue(xml, "descr", "Egress ACL rule for Tenant VDC " + tenantName);
xml = replaceXmlValue(xml, "actiontype", "permit");
xml = replaceXmlValue(xml, "protocolvalue", protocol);
xml = replaceXmlValue(xml, "deststartip", destStartIp);
xml = replaceXmlValue(xml, "destendip", destEndIp);
xml = replaceXmlValue(xml, "sourcestartip", sourceStartIp);
xml = replaceXmlValue(xml, "sourceendip", sourceEndIp);
xml = replaceXmlValue(xml, "deststartport", destStartPort);
xml = replaceXmlValue(xml, "destendport", destEndPort);
@ -759,7 +759,7 @@ public class CiscoVnmcConnectionImpl implements CiscoVnmcConnection {
@Override
public boolean createTenantVDCEgressAclRule(String tenantName,
String identifier, String policyIdentifier,
String protocol, String destStartIp, String destEndIp) throws ExecutionException {
String protocol, String sourceStartIp, String sourceEndIp) throws ExecutionException {
String xml = VnmcXml.CREATE_GENERIC_EGRESS_ACL_RULE.getXml();
String service = VnmcXml.CREATE_GENERIC_EGRESS_ACL_RULE.getService();
if (protocol.equalsIgnoreCase("all")) { // any protocol
@ -773,8 +773,8 @@ public class CiscoVnmcConnectionImpl implements CiscoVnmcConnection {
xml = replaceXmlValue(xml, "aclrulename", getNameForAclRule(tenantName, identifier));
xml = replaceXmlValue(xml, "descr", "Egress ACL rule for Tenant VDC " + tenantName);
xml = replaceXmlValue(xml, "actiontype", "permit");
xml = replaceXmlValue(xml, "deststartip", destStartIp);
xml = replaceXmlValue(xml, "destendip", destEndIp);
xml = replaceXmlValue(xml, "sourcestartip", sourceStartIp);
xml = replaceXmlValue(xml, "sourceendip", sourceEndIp);
List<String> rules = listChildren(getDnForAclPolicy(tenantName, policyIdentifier));
int order = 100;

View File

@ -60,6 +60,7 @@ import com.cloud.utils.Pair;
import com.cloud.utils.cisco.n1kv.vsm.NetconfHelper;
import com.cloud.utils.cisco.n1kv.vsm.VsmCommand.OperationType;
import com.cloud.utils.cisco.n1kv.vsm.VsmCommand.SwitchPortMode;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.exception.ExecutionException;
import com.cloud.utils.net.NetUtils;
@ -280,30 +281,30 @@ public class CiscoVnmcResource implements ServerResource {
String policyIdentifier = cmd.getIpAddress().getPublicIp().replace('.', '-');
try {
if (!_connection.createTenantVDCNatPolicySet(tenant)) {
throw new Exception("Failed to create NAT policy set in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to create NAT policy set in VNMC for guest network with vlan " + vlanId);
}
if (!_connection.createTenantVDCSourceNatPolicy(tenant, policyIdentifier)) {
throw new Exception("Failed to create source NAT policy in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to create source NAT policy in VNMC for guest network with vlan " + vlanId);
}
if (!_connection.createTenantVDCSourceNatPolicyRef(tenant, policyIdentifier)) {
throw new Exception("Failed to associate source NAT policy with NAT policy set in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to associate source NAT policy with NAT policy set in VNMC for guest network with vlan " + vlanId);
}
if (!_connection.createTenantVDCSourceNatIpPool(tenant, policyIdentifier, cmd.getIpAddress().getPublicIp())) {
throw new Exception("Failed to create source NAT ip pool in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to create source NAT ip pool in VNMC for guest network with vlan " + vlanId);
}
String[] ipRange = getIpRangeFromCidr(cmd.getContextParam(NetworkElementCommand.GUEST_NETWORK_CIDR));
if (!_connection.createTenantVDCSourceNatRule(tenant, policyIdentifier, ipRange[0], ipRange[1])) {
throw new Exception("Failed to create source NAT rule in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to create source NAT rule in VNMC for guest network with vlan " + vlanId);
}
if (!_connection.associateNatPolicySet(tenant)) {
throw new Exception("Failed to associate source NAT policy set with edge security profile in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to associate source NAT policy set with edge security profile in VNMC for guest network with vlan " + vlanId);
}
} catch (Throwable e) {
} catch (ExecutionException e) {
String msg = "SetSourceNatCommand failed due to " + e.getMessage();
s_logger.error(msg, e);
return new Answer(cmd, false, msg);
@ -337,29 +338,29 @@ public class CiscoVnmcResource implements ServerResource {
try {
if (!_connection.createTenantVDCAclPolicySet(tenant, true)) {
throw new Exception("Failed to create ACL ingress policy set in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to create ACL ingress policy set in VNMC for guest network with vlan " + vlanId);
}
if (!_connection.createTenantVDCAclPolicySet(tenant, false)) {
throw new Exception("Failed to create ACL egress policy set in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to create ACL egress policy set in VNMC for guest network with vlan " + vlanId);
}
for (String publicIp : publicIpRulesMap.keySet()) {
String policyIdentifier = publicIp.replace('.', '-');
if (!_connection.createTenantVDCAclPolicy(tenant, policyIdentifier)) {
throw new Exception("Failed to create ACL policy in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to create ACL policy in VNMC for guest network with vlan " + vlanId);
}
if (!_connection.createTenantVDCAclPolicyRef(tenant, policyIdentifier, true)) {
throw new Exception("Failed to associate ACL policy with ACL ingress policy set in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to associate ACL policy with ACL ingress policy set in VNMC for guest network with vlan " + vlanId);
}
if (!_connection.createTenantVDCAclPolicyRef(tenant, policyIdentifier, false)) {
throw new Exception("Failed to associate ACL policy with ACL egress policy set in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to associate ACL policy with ACL egress policy set in VNMC for guest network with vlan " + vlanId);
}
for (FirewallRuleTO rule : publicIpRulesMap.get(publicIp)) {
if (rule.revoked()) {
if (!_connection.deleteTenantVDCAclRule(tenant, Long.toString(rule.getId()), policyIdentifier)) {
throw new Exception("Failed to delete ACL rule in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to delete ACL rule in VNMC for guest network with vlan " + vlanId);
}
} else {
String[] externalIpRange = getIpRangeFromCidr(rule.getSourceCidrList().get(0));
@ -370,13 +371,13 @@ public class CiscoVnmcResource implements ServerResource {
Long.toString(rule.getId()), policyIdentifier,
rule.getProtocol().toUpperCase(), externalIpRange[0], externalIpRange[1],
Integer.toString(rule.getSrcPortRange()[0]), Integer.toString(rule.getSrcPortRange()[1]))) {
throw new Exception("Failed to create ACL ingress rule in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to create ACL ingress rule in VNMC for guest network with vlan " + vlanId);
}
} else {
if (!_connection.createTenantVDCIngressAclRule(tenant,
Long.toString(rule.getId()), policyIdentifier,
rule.getProtocol().toUpperCase(), externalIpRange[0], externalIpRange[1])) {
throw new Exception("Failed to create ACL ingress rule in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to create ACL ingress rule in VNMC for guest network with vlan " + vlanId);
}
}
} else {
@ -387,13 +388,13 @@ public class CiscoVnmcResource implements ServerResource {
rule.getProtocol().toUpperCase(),
externalIpRange[0], externalIpRange[1],
Integer.toString(rule.getSrcPortRange()[0]), Integer.toString(rule.getSrcPortRange()[1]))) {
throw new Exception("Failed to create ACL egress rule in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to create ACL egress rule in VNMC for guest network with vlan " + vlanId);
}
} else {
if (!_connection.createTenantVDCEgressAclRule(tenant,
Long.toString(rule.getId()), policyIdentifier,
rule.getProtocol().toUpperCase(), externalIpRange[0], externalIpRange[1])) {
throw new Exception("Failed to create ACL egress rule in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to create ACL egress rule in VNMC for guest network with vlan " + vlanId);
}
}
}
@ -402,9 +403,9 @@ public class CiscoVnmcResource implements ServerResource {
}
if (!_connection.associateAclPolicySet(tenant)) {
throw new Exception("Failed to associate ACL policy set with edge security profile in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to associate ACL policy set with edge security profile in VNMC for guest network with vlan " + vlanId);
}
} catch (Throwable e) {
} catch (ExecutionException e) {
String msg = "SetFirewallRulesCommand failed due to " + e.getMessage();
s_logger.error(msg, e);
return new Answer(cmd, false, msg);
@ -438,69 +439,60 @@ public class CiscoVnmcResource implements ServerResource {
try {
if (!_connection.createTenantVDCNatPolicySet(tenant)) {
throw new Exception("Failed to create NAT policy set in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to create NAT policy set in VNMC for guest network with vlan " + vlanId);
}
if (!_connection.createTenantVDCAclPolicySet(tenant, true)) {
throw new Exception("Failed to create ACL ingress policy set in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to create ACL ingress policy set in VNMC for guest network with vlan " + vlanId);
}
if (!_connection.createTenantVDCAclPolicySet(tenant, false)) {
throw new Exception("Failed to create ACL egress policy set in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to create ACL egress policy set in VNMC for guest network with vlan " + vlanId);
}
for (String publicIp : publicIpRulesMap.keySet()) {
String policyIdentifier = publicIp.replace('.', '-');
if (!_connection.createTenantVDCDNatPolicy(tenant, policyIdentifier)) {
throw new Exception("Failed to create DNAT policy in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to create DNAT policy in VNMC for guest network with vlan " + vlanId);
}
if (!_connection.createTenantVDCDNatPolicyRef(tenant, policyIdentifier)) {
throw new Exception("Failed to associate DNAT policy with NAT policy set in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to associate DNAT policy with NAT policy set in VNMC for guest network with vlan " + vlanId);
}
if (!_connection.createTenantVDCAclPolicy(tenant, policyIdentifier)) {
throw new Exception("Failed to create ACL policy in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to create ACL policy in VNMC for guest network with vlan " + vlanId);
}
if (!_connection.createTenantVDCAclPolicyRef(tenant, policyIdentifier, true)) {
throw new Exception("Failed to associate ACL policy with ACL ingress policy set in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to associate ACL policy with ACL ingress policy set in VNMC for guest network with vlan " + vlanId);
}
if (!_connection.createTenantVDCAclPolicyRef(tenant, policyIdentifier, false)) {
throw new Exception("Failed to associate ACL policy with ACL egress policy set in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to associate ACL policy with ACL egress policy set in VNMC for guest network with vlan " + vlanId);
}
for (StaticNatRuleTO rule : publicIpRulesMap.get(publicIp)) {
if (rule.revoked()) {
if (!_connection.deleteTenantVDCDNatRule(tenant, Long.toString(rule.getId()), policyIdentifier)) {
throw new Exception("Failed to delete DNAT rule in VNMC for guest network with vlan " + vlanId);
}
if (!_connection.deleteTenantVDCAclRule(tenant, Long.toString(rule.getId()), policyIdentifier)) {
throw new Exception("Failed to delete ACL ingress rule for DNAT in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to delete DNAT rule in VNMC for guest network with vlan " + vlanId);
}
} else {
if (!_connection.createTenantVDCDNatIpPool(tenant, Long.toString(rule.getId()), rule.getDstIp())) {
throw new Exception("Failed to create DNAT ip pool in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to create DNAT ip pool in VNMC for guest network with vlan " + vlanId);
}
if (!_connection.createTenantVDCDNatRule(tenant,
Long.toString(rule.getId()), policyIdentifier, rule.getSrcIp())) {
throw new Exception("Failed to create DNAT rule in VNMC for guest network with vlan " + vlanId);
}
if (!_connection.createTenantVDCAclRuleForDNat(tenant,
Long.toString(rule.getId()), policyIdentifier, rule.getDstIp())) {
throw new Exception("Failed to create ACL rule for DNAT in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to create DNAT rule in VNMC for guest network with vlan " + vlanId);
}
}
}
}
if (!_connection.associateAclPolicySet(tenant)) {
throw new Exception("Failed to associate source NAT policy set with edge security profile in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to associate source NAT policy set with edge security profile in VNMC for guest network with vlan " + vlanId);
}
} catch (Throwable e) {
String msg = "SetSourceNatCommand failed due to " + e.getMessage();
} catch (ExecutionException e) {
String msg = "SetStaticNatRulesCommand failed due to " + e.getMessage();
s_logger.error(msg, e);
return new Answer(cmd, false, msg);
}
@ -533,77 +525,66 @@ public class CiscoVnmcResource implements ServerResource {
try {
if (!_connection.createTenantVDCNatPolicySet(tenant)) {
throw new Exception("Failed to create NAT policy set in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to create NAT policy set in VNMC for guest network with vlan " + vlanId);
}
if (!_connection.createTenantVDCAclPolicySet(tenant, true)) {
throw new Exception("Failed to create ACL ingress policy set in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to create ACL ingress policy set in VNMC for guest network with vlan " + vlanId);
}
if (!_connection.createTenantVDCAclPolicySet(tenant, false)) {
throw new Exception("Failed to create ACL egress policy set in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to create ACL egress policy set in VNMC for guest network with vlan " + vlanId);
}
for (String publicIp : publicIpRulesMap.keySet()) {
String policyIdentifier = publicIp.replace('.', '-');
if (!_connection.createTenantVDCPFPolicy(tenant, policyIdentifier)) {
throw new Exception("Failed to create PF policy in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to create PF policy in VNMC for guest network with vlan " + vlanId);
}
if (!_connection.createTenantVDCPFPolicyRef(tenant, policyIdentifier)) {
throw new Exception("Failed to associate PF policy with NAT policy set in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to associate PF policy with NAT policy set in VNMC for guest network with vlan " + vlanId);
}
if (!_connection.createTenantVDCAclPolicy(tenant, policyIdentifier)) {
throw new Exception("Failed to create ACL policy in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to create ACL policy in VNMC for guest network with vlan " + vlanId);
}
if (!_connection.createTenantVDCAclPolicyRef(tenant, policyIdentifier, true)) {
throw new Exception("Failed to associate ACL policy with ACL ingress policy set in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to associate ACL policy with ACL ingress policy set in VNMC for guest network with vlan " + vlanId);
}
if (!_connection.createTenantVDCAclPolicyRef(tenant, policyIdentifier, false)) {
throw new Exception("Failed to associate ACL policy with ACL egress policy set in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to associate ACL policy with ACL egress policy set in VNMC for guest network with vlan " + vlanId);
}
for (PortForwardingRuleTO rule : publicIpRulesMap.get(publicIp)) {
if (rule.revoked()) {
if (!_connection.deleteTenantVDCPFRule(tenant, Long.toString(rule.getId()), policyIdentifier)) {
throw new Exception("Failed to delete PF rule in VNMC for guest network with vlan " + vlanId);
}
if (!_connection.deleteTenantVDCAclRule(tenant, Long.toString(rule.getId()), policyIdentifier)) {
throw new Exception("Failed to delete ACL ingress rule for PF in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to delete PF rule in VNMC for guest network with vlan " + vlanId);
}
} else {
if (!_connection.createTenantVDCPFIpPool(tenant, Long.toString(rule.getId()), rule.getDstIp())) {
throw new Exception("Failed to create PF ip pool in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to create PF ip pool in VNMC for guest network with vlan " + vlanId);
}
if (!_connection.createTenantVDCPFPortPool(tenant, Long.toString(rule.getId()),
Integer.toString(rule.getDstPortRange()[0]), Integer.toString(rule.getDstPortRange()[1]))) {
throw new Exception("Failed to create PF port pool in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to create PF port pool in VNMC for guest network with vlan " + vlanId);
}
if (!_connection.createTenantVDCPFRule(tenant,
Long.toString(rule.getId()), policyIdentifier,
rule.getProtocol().toUpperCase(), rule.getSrcIp(),
Integer.toString(rule.getSrcPortRange()[0]), Integer.toString(rule.getSrcPortRange()[1]))) {
throw new Exception("Failed to create PF rule in VNMC for guest network with vlan " + vlanId);
}
if (!_connection.createTenantVDCAclRuleForPF(tenant,
Long.toString(rule.getId()), policyIdentifier,
rule.getProtocol().toUpperCase(), rule.getDstIp(),
Integer.toString(rule.getDstPortRange()[0]), Integer.toString(rule.getDstPortRange()[1]))) {
throw new Exception("Failed to create ACL rule for PF in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to create PF rule in VNMC for guest network with vlan " + vlanId);
}
}
}
}
if (!_connection.associateAclPolicySet(tenant)) {
throw new Exception("Failed to associate source NAT policy set with edge security profile in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to associate source NAT policy set with edge security profile in VNMC for guest network with vlan " + vlanId);
}
} catch (Throwable e) {
String msg = "SetSourceNatCommand failed due to " + e.getMessage();
} catch (ExecutionException e) {
String msg = "SetPortForwardingRulesCommand failed due to " + e.getMessage();
s_logger.error(msg, e);
return new Answer(cmd, false, msg);
}
@ -619,24 +600,24 @@ public class CiscoVnmcResource implements ServerResource {
return execute(cmd, _numRetries);
}
private void createEdgeDeviceProfile(String tenant, List<String> gateways, Long vlanId) throws Exception {
private void createEdgeDeviceProfile(String tenant, List<String> gateways, Long vlanId) throws ExecutionException {
// create edge device profile
if (!_connection.createTenantVDCEdgeDeviceProfile(tenant))
throw new Exception("Failed to create tenant edge device profile in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to create tenant edge device profile in VNMC for guest network with vlan " + vlanId);
// create edge static route policy
if (!_connection.createTenantVDCEdgeStaticRoutePolicy(tenant))
throw new Exception("Failed to create tenant edge static route policy in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to create tenant edge static route policy in VNMC for guest network with vlan " + vlanId);
// create edge static route for all gateways
for (String gateway : gateways) {
if (!_connection.createTenantVDCEdgeStaticRoute(tenant, gateway, "0.0.0.0", "0.0.0.0"))
throw new Exception("Failed to create tenant edge static route in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to create tenant edge static route in VNMC for guest network with vlan " + vlanId);
}
// associate edge
if (!_connection.associateTenantVDCEdgeStaticRoutePolicy(tenant))
throw new Exception("Failed to associate edge static route policy with edge device profile in VNMC for guest network with vlan " + vlanId);
throw new ExecutionException("Failed to associate edge static route policy with edge device profile in VNMC for guest network with vlan " + vlanId);
}
private Answer execute(CreateLogicalEdgeFirewallCommand cmd, int numRetries) {
@ -644,23 +625,23 @@ public class CiscoVnmcResource implements ServerResource {
try {
// create tenant
if (!_connection.createTenant(tenant))
throw new Exception("Failed to create tenant in VNMC for guest network with vlan " + cmd.getVlanId());
throw new ExecutionException("Failed to create tenant in VNMC for guest network with vlan " + cmd.getVlanId());
// create tenant VDC
if (!_connection.createTenantVDC(tenant))
throw new Exception("Failed to create tenant VDC in VNMC for guest network with vlan " + cmd.getVlanId());
throw new ExecutionException("Failed to create tenant VDC in VNMC for guest network with vlan " + cmd.getVlanId());
// create edge security profile
if (!_connection.createTenantVDCEdgeSecurityProfile(tenant))
throw new Exception("Failed to create tenant edge security profile in VNMC for guest network with vlan " + cmd.getVlanId());
throw new ExecutionException("Failed to create tenant edge security profile in VNMC for guest network with vlan " + cmd.getVlanId());
// create edge device profile and associated route
createEdgeDeviceProfile(tenant, cmd.getPublicGateways(), cmd.getVlanId());
// create logical edge firewall
if (!_connection.createEdgeFirewall(tenant, cmd.getPublicIp(), cmd.getInternalIp(), cmd.getPublicSubnet(), cmd.getInternalSubnet()))
throw new Exception("Failed to create edge firewall in VNMC for guest network with vlan " + cmd.getVlanId());
} catch (Throwable e) {
throw new ExecutionException("Failed to create edge firewall in VNMC for guest network with vlan " + cmd.getVlanId());
} catch (ExecutionException e) {
String msg = "CreateLogicalEdgeFirewallCommand failed due to " + e.getMessage();
s_logger.error(msg, e);
return new Answer(cmd, false, msg);
@ -688,7 +669,7 @@ public class CiscoVnmcResource implements ServerResource {
s_logger.debug("Created vservice node for ASA appliance in Cisco VSM for vlan " + vlanId);
helper.updatePortProfile(cmd.getAsaInPortProfile(), SwitchPortMode.access, params);
s_logger.debug("Updated inside port profile for ASA appliance in Cisco VSM with new vlan " + vlanId);
} catch (Throwable e) {
} catch (CloudRuntimeException e) {
String msg = "ConfigureVSMForASACommand failed due to " + e.getMessage();
s_logger.error(msg, e);
return new Answer(cmd, false, msg);
@ -711,18 +692,18 @@ public class CiscoVnmcResource implements ServerResource {
try {
Map<String, String> availableAsaAppliances = _connection.listUnAssocAsa1000v();
if (availableAsaAppliances.isEmpty()) {
throw new Exception("No ASA 1000v available to associate with logical edge firewall for guest vlan " + cmd.getVlanId());
throw new ExecutionException("No ASA 1000v available to associate with logical edge firewall for guest vlan " + cmd.getVlanId());
}
String asaInstanceDn = availableAsaAppliances.get(cmd.getAsaMgmtIp());
if (asaInstanceDn == null) {
throw new Exception("Requested ASA 1000v (" + cmd.getAsaMgmtIp() + ") is not available");
throw new ExecutionException("Requested ASA 1000v (" + cmd.getAsaMgmtIp() + ") is not available");
}
if (!_connection.assignAsa1000v(tenant, asaInstanceDn)) {
throw new Exception("Failed to associate ASA 1000v (" + cmd.getAsaMgmtIp() + ") with logical edge firewall for guest vlan " + cmd.getVlanId());
throw new ExecutionException("Failed to associate ASA 1000v (" + cmd.getAsaMgmtIp() + ") with logical edge firewall for guest vlan " + cmd.getVlanId());
}
} catch (Throwable e) {
} catch (ExecutionException e) {
String msg = "AssociateAsaWithLogicalEdgeFirewallCommand failed due to " + e.getMessage();
s_logger.error(msg, e);
return new Answer(cmd, false, msg);
@ -743,7 +724,7 @@ public class CiscoVnmcResource implements ServerResource {
String tenant = "vlan-" + cmd.getVlanId();
try {
_connection.deleteTenant(tenant);
} catch (Throwable e) {
} catch (ExecutionException e) {
String msg = "CleanupLogicalEdgeFirewallCommand failed due to " + e.getMessage();
s_logger.error(msg, e);
return new Answer(cmd, false, msg);

View File

@ -240,7 +240,7 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl impl
return false;
}
if (canHandleLbRules(rules)) {
if (!canHandleLbRules(rules)) {
return false;
}
@ -923,13 +923,13 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl impl
}
@Override
public boolean applyGlobalLoadBalancerRule(long zoneId, GlobalLoadBalancerConfigCommand gslbConfigCmd)
public boolean applyGlobalLoadBalancerRule(long zoneId, long physicalNetworkId, GlobalLoadBalancerConfigCommand gslbConfigCmd)
throws ResourceUnavailableException {
long zoneGslbProviderHosId = 0;
// find the NetScaler device configured as gslb service provider in the zone
ExternalLoadBalancerDeviceVO nsGslbProvider = findGslbProvider(zoneId);
ExternalLoadBalancerDeviceVO nsGslbProvider = findGslbProvider(zoneId, physicalNetworkId);
if (nsGslbProvider == null) {
String msg = "Unable to find a NetScaler configured as gslb service provider in zone " + zoneId;
s_logger.debug(msg);
@ -950,28 +950,37 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl impl
return true;
}
private ExternalLoadBalancerDeviceVO findGslbProvider(long zoneId) {
private ExternalLoadBalancerDeviceVO findGslbProvider(long zoneId, long physicalNetworkId) {
List<PhysicalNetworkVO> pNtwks = _physicalNetworkDao.listByZoneAndTrafficType(zoneId, TrafficType.Guest);
if (pNtwks.isEmpty() || pNtwks.size() > 1) {
throw new InvalidParameterValueException("Unable to get physical network in zone id = " + zoneId);
if (pNtwks == null || pNtwks.isEmpty()) {
throw new InvalidParameterValueException("Unable to get physical network: " + physicalNetworkId +
" in zone id = " + zoneId);
} else {
for (PhysicalNetwork physicalNetwork : pNtwks) {
if (physicalNetwork.getId() == physicalNetworkId) {
PhysicalNetworkVO physNetwork = pNtwks.get(0);
ExternalLoadBalancerDeviceVO nsGslbProvider = _externalLoadBalancerDeviceDao.findGslbServiceProvider(
physNetwork.getId(), Provider.Netscaler.getName());
return nsGslbProvider;
}
}
}
PhysicalNetworkVO physNetwork = pNtwks.get(0);
ExternalLoadBalancerDeviceVO nsGslbProvider = _externalLoadBalancerDeviceDao.findGslbServiceProvider(
physNetwork.getId(), Provider.Netscaler.getName());
return nsGslbProvider;
return null;
}
@Override
public boolean isServiceEnabledInZone(long zoneId) {
public boolean isServiceEnabledInZone(long zoneId, long physicalNetworkId) {
ExternalLoadBalancerDeviceVO nsGslbProvider = findGslbProvider(zoneId);
ExternalLoadBalancerDeviceVO nsGslbProvider = findGslbProvider(zoneId, physicalNetworkId);
//return true if a NetScaler device is configured in the zone
return (nsGslbProvider != null);
}
@Override
public String getZoneGslbProviderPublicIp(long zoneId) {
ExternalLoadBalancerDeviceVO nsGslbProvider = findGslbProvider(zoneId);
public String getZoneGslbProviderPublicIp(long zoneId, long physicalNetworkId) {
ExternalLoadBalancerDeviceVO nsGslbProvider = findGslbProvider(zoneId, physicalNetworkId);
if (nsGslbProvider != null) {
return nsGslbProvider.getGslbSitePublicIP();
}
@ -979,8 +988,8 @@ public class NetscalerElement extends ExternalLoadBalancerDeviceManagerImpl impl
}
@Override
public String getZoneGslbProviderPrivateIp(long zoneId) {
ExternalLoadBalancerDeviceVO nsGslbProvider = findGslbProvider(zoneId);
public String getZoneGslbProviderPrivateIp(long zoneId, long physicalNetworkId) {
ExternalLoadBalancerDeviceVO nsGslbProvider = findGslbProvider(zoneId, physicalNetworkId);
if (nsGslbProvider != null) {
return nsGslbProvider.getGslbSitePrivateIP();
}

View File

@ -1095,7 +1095,15 @@ public class NetscalerResource implements ServerResource {
}
vserver.set_name(vserverName);
vserver.set_lbmethod(lbMethod);
if ("RoundRobin".equalsIgnoreCase(lbMethod)) {
vserver.set_lbmethod("ROUNDROBIN");
} else if ("LeastConn".equalsIgnoreCase(lbMethod)) {
vserver.set_lbmethod("LEASTCONNECTION");
} else if ("Proximity".equalsIgnoreCase(lbMethod)) {
vserver.set_lbmethod("RTT");
} else {
throw new ExecutionException("Unsupported LB method");
}
vserver.set_persistencetype(persistenceType);
if ("SOURCEIP".equalsIgnoreCase(persistenceType)) {
vserver.set_persistenceid(persistenceId);

View File

@ -0,0 +1,27 @@
#!/bin/bash
# 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.
nw_label=$1
br=`xe network-list name-label="$nw_label" params=bridge |cut -d ':' -f 2 |tr -d ' ' `
pbr=`ovs-vsctl br-to-parent $br`
while [ "$br" != "$pbr" ]
do
br=$pbr
pbr=`ovs-vsctl br-to-parent $br`
done
echo $pbr

View File

@ -0,0 +1,25 @@
#!/bin/bash
# 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.
#!/bin/bash
bridge=$1
dhcp_name=$2
dom_id=`xe vm-list is-control-domain=false power-state=running params=dom-id name-label=$dhcp_name|cut -d ':' -f 2 |tr -d ' ' `
iface="vif${dom_id}.0"
echo $iface

View File

@ -0,0 +1,145 @@
#!/usr/bin/python
# 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.
import cloudstack_pluginlib as lib
import logging
import os
import sys
import subprocess
import time
import XenAPIPlugin
sys.path.append("/opt/xensource/sm/")
import util
from time import localtime as _localtime, asctime as _asctime
xePath = "/opt/xensource/bin/xe"
lib.setup_logging("/var/log/ovs-pvlan.log")
dhcpSetupPath = "/opt/xensource/bin/ovs-pvlan-dhcp-host.sh"
vmSetupPath = "/opt/xensource/bin/ovs-pvlan-vm.sh"
getDhcpIfacePath = "/opt/xensource/bin/ovs-get-dhcp-iface.sh"
pvlanCleanupPath = "/opt/xensource/bin/ovs-pvlan-cleanup.sh"
getBridgePath = "/opt/xensource/bin/ovs-get-bridge.sh"
def echo(fn):
def wrapped(*v, **k):
name = fn.__name__
util.SMlog("#### VMOPS enter %s ####" % name)
res = fn(*v, **k)
util.SMlog("#### VMOPS exit %s ####" % name)
return res
return wrapped
@echo
def setup_pvlan_dhcp(session, args):
op = args.pop("op")
nw_label = args.pop("nw-label")
primary = args.pop("primary-pvlan")
isolated = args.pop("isolated-pvlan")
dhcp_name = args.pop("dhcp-name")
dhcp_ip = args.pop("dhcp-ip")
dhcp_mac = args.pop("dhcp-mac")
res = lib.check_switch()
if res != "SUCCESS":
return "FAILURE:%s" % res
logging.debug("Network is:%s" % (nw_label))
bridge = lib.do_cmd([getBridgePath, nw_label])
logging.debug("Determine bridge/switch is :%s" % (bridge))
if op == "add":
logging.debug("Try to get dhcp vm %s port on the switch:%s" % (dhcp_name, bridge))
dhcp_iface = lib.do_cmd([getDhcpIfacePath, bridge, dhcp_name])
logging.debug("About to setup dhcp vm on the switch:%s" % bridge)
res = lib.do_cmd([dhcpSetupPath, "-A", "-b", bridge, "-p", primary,
"-i", isolated, "-n", dhcp_name, "-d", dhcp_ip, "-m", dhcp_mac,
"-I", dhcp_iface])
if res:
result = "FAILURE:%s" % res
return result;
logging.debug("Setup dhcp vm on switch program done")
elif op == "delete":
logging.debug("About to remove dhcp the switch:%s" % bridge)
res = lib.do_cmd([dhcpSetupPath, "-D", "-b", bridge, "-p", primary,
"-i", isolated, "-n", dhcp_name, "-d", dhcp_ip, "-m", dhcp_mac])
if res:
result = "FAILURE:%s" % res
return result;
logging.debug("Remove DHCP on switch program done")
result = "true"
logging.debug("Setup_pvlan_dhcp completed with result:%s" % result)
return result
@echo
def setup_pvlan_vm(session, args):
op = args.pop("op")
nw_label = args.pop("nw-label")
primary = args.pop("primary-pvlan")
isolated = args.pop("isolated-pvlan")
vm_mac = args.pop("vm-mac")
trunk_port = 1
res = lib.check_switch()
if res != "SUCCESS":
return "FAILURE:%s" % res
bridge = lib.do_cmd([getBridgePath, nw_label])
logging.debug("Determine bridge/switch is :%s" % (bridge))
if op == "add":
logging.debug("About to setup vm on the switch:%s" % bridge)
res = lib.do_cmd([vmSetupPath, "-A", "-b", bridge, "-p", primary, "-i", isolated, "-v", vm_mac])
if res:
result = "FAILURE:%s" % res
return result;
logging.debug("Setup vm on switch program done")
elif op == "delete":
logging.debug("About to remove vm on the switch:%s" % bridge)
res = lib.do_cmd([vmSetupPath, "-D", "-b", bridge, "-p", primary, "-i", isolated, "-v", vm_mac])
if res:
result = "FAILURE:%s" % res
return result;
logging.debug("Remove vm on switch program done")
result = "true"
logging.debug("Setup_pvlan_vm_alone completed with result:%s" % result)
return result
@echo
def cleanup(session, args):
res = lib.check_switch()
if res != "SUCCESS":
return "FAILURE:%s" % res
res = lib.do_cmd([pvlanCleanUpPath])
if res:
result = "FAILURE:%s" % res
return result;
result = "true"
logging.debug("Setup_pvlan_vm_dhcp completed with result:%s" % result)
return result
if __name__ == "__main__":
XenAPIPlugin.dispatch({"setup-pvlan-dhcp": setup_pvlan_dhcp,
"setup-pvlan-vm": setup_pvlan_vm,
"cleanup":cleanup})

View File

@ -70,4 +70,9 @@ swift=..,0755,/opt/xensource/bin
swiftxen=..,0755,/etc/xapi.d/plugins
s3xen=..,0755,/etc/xapi.d/plugins
add_to_vcpus_params_live.sh=..,0755,/opt/xensource/bin
ovs-pvlan=..,0755,/etc/xapi.d/plugins
ovs-pvlan-dhcp-host.sh=../../../network,0755,/opt/xensource/bin
ovs-pvlan-vm.sh=../../../network,0755,/opt/xensource/bin
ovs-pvlan-cleanup.sh=../../../network,0755,/opt/xensource/bin
ovs-get-dhcp-iface.sh=..,0755,/opt/xensource/bin
ovs-get-bridge.sh=..,0755,/opt/xensource/bin

View File

@ -0,0 +1,23 @@
#!/bin/bash
# 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.
#!/bin/bash
ovs-ofctl del-flows xenbr0
ovs-ofctl add-flow xenbr0 priority=0,actions=NORMAL

View File

@ -0,0 +1,123 @@
#!/bin/bash
# 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.
#!/bin/bash
usage() {
printf "Usage: %s: (-A|-D) -b <bridge/switch> -p <primary vlan> -i <secondary isolated vlan> -n <DHCP server name> -d <DHCP server IP> -m <DHCP server MAC> -I <interface> -v <VM MAC> -h \n" $(basename $0) >&2
exit 2
}
br=
pri_vlan=
sec_iso_vlan=
dhcp_name=
dhcp_ip=
dhcp_mac=
vm_mac=
iface=
op=
while getopts 'ADb:p:i:d:m:v:n:I:h' OPTION
do
case $OPTION in
A) op="add"
;;
D) op="del"
;;
b) br="$OPTARG"
;;
p) pri_vlan="$OPTARG"
;;
i) sec_iso_vlan="$OPTARG"
;;
n) dhcp_name="$OPTARG"
;;
d) dhcp_ip="$OPTARG"
;;
m) dhcp_mac="$OPTARG"
;;
I) iface="$OPTARG"
;;
v) vm_mac="$OPTARG"
;;
h) usage
exit 1
;;
esac
done
if [ -z "$op" ]
then
echo Missing operation pararmeter!
exit 1
fi
if [ -z "$br" ]
then
echo Missing parameter bridge!
exit 1
fi
if [ -z "$pri_vlan" ]
then
echo Missing parameter primary vlan!
exit 1
fi
if [ -z "$sec_iso_vlan" ]
then
echo Missing parameter secondary isolate vlan!
exit 1
fi
if [ -z "$dhcp_name" ]
then
echo Missing parameter DHCP NAME!
exit 1
fi
if [ -z "$dhcp_ip" ]
then
echo Missing parameter DHCP IP!
exit 1
fi
if [ -z "$dhcp_mac" ]
then
echo Missing parameter DHCP MAC!
exit 1
fi
if [ "$op" == "add" -a -z "$iface" ]
then
echo Missing parameter DHCP VM interface!
exit 1
fi
if [ "$op" == "add" ]
then
dhcp_port=`ovs-ofctl show $br | grep $iface | cut -d '(' -f 1|tr -d ' '`
ovs-ofctl add-flow $br priority=200,arp,dl_vlan=$sec_iso_vlan,nw_dst=$dhcp_ip,actions=strip_vlan,output:$dhcp_port
ovs-ofctl add-flow $br priority=150,dl_vlan=$sec_iso_vlan,dl_dst=$dhcp_mac,actions=strip_vlan,output:$dhcp_port
ovs-ofctl add-flow $br priority=100,udp,dl_vlan=$sec_iso_vlan,nw_dst=255.255.255.255,tp_dst=67,actions=strip_vlan,output:$dhcp_port
else
ovs-ofctl del-flows --strict $br priority=200,arp,dl_vlan=$sec_iso_vlan,nw_dst=$dhcp_ip
ovs-ofctl del-flows --strict $br priority=150,dl_vlan=$sec_iso_vlan,dl_dst=$dhcp_mac
ovs-ofctl del-flows --strict $br priority=100,udp,dl_vlan=$sec_iso_vlan,nw_dst=255.255.255.255,tp_dst=67
fi

View File

@ -0,0 +1,99 @@
#!/bin/bash
# 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.
#!/bin/bash
usage() {
printf "Usage: %s: (-A|-D) -b <bridge/switch> -p <primary vlan> -i <secondary isolated vlan> -d <DHCP server IP> -m <DHCP server MAC> -v <VM MAC> -h \n" $(basename $0) >&2
exit 2
}
br=
pri_vlan=
sec_iso_vlan=
dhcp_ip=
dhcp_mac=
vm_mac=
op=
while getopts 'ADb:p:i:d:m:v:h' OPTION
do
case $OPTION in
A) op="add"
;;
D) op="del"
;;
b) br="$OPTARG"
;;
p) pri_vlan="$OPTARG"
;;
i) sec_iso_vlan="$OPTARG"
;;
d) dhcp_ip="$OPTARG"
;;
m) dhcp_mac="$OPTARG"
;;
v) vm_mac="$OPTARG"
;;
h) usage
exit 1
;;
esac
done
if [ -z "$op" ]
then
echo Missing operation pararmeter!
exit 1
fi
if [ -z "$br" ]
then
echo Missing parameter bridge!
exit 1
fi
if [ -z "$vm_mac" ]
then
echo Missing parameter VM MAC!
exit 1
fi
if [ -z "$pri_vlan" ]
then
echo Missing parameter secondary isolate vlan!
exit 1
fi
if [ -z "$sec_iso_vlan" ]
then
echo Missing parameter secondary isolate vlan!
exit 1
fi
trunk_port=1
if [ "$op" == "add" ]
then
ovs-ofctl add-flow $br priority=50,dl_vlan=0xffff,dl_src=$vm_mac,actions=mod_vlan_vid:$sec_iso_vlan,resubmit:$trunk_port
ovs-ofctl add-flow $br priority=60,dl_vlan=$sec_iso_vlan,dl_src=$vm_mac,actions=output:$trunk_port
else
ovs-ofctl del-flows --strict $br priority=50,dl_vlan=0xffff,dl_src=$vm_mac
ovs-ofctl del-flows --strict $br priority=60,dl_vlan=$sec_iso_vlan,dl_src=$vm_mac
fi

View File

@ -1668,4 +1668,9 @@ public class ApiDBUtils {
public static List<? extends LoadBalancer> listSiteLoadBalancers(long gslbRuleId) {
return _gslbService.listSiteLoadBalancers(gslbRuleId);
}
public static String getDnsNameConfiguredForGslb() {
String providerDnsName = _configDao.getValue(Config.CloudDnsName.key());
return providerDnsName;
}
}

View File

@ -168,7 +168,7 @@ public class ApiDispatcher {
pageSize = Long.valueOf((String) pageSizeObj);
}
if ((unpackedParams.get(ApiConstants.PAGE) == null) && (pageSize != null && pageSize != BaseListCmd.PAGESIZE_UNLIMITED)) {
if ((unpackedParams.get(ApiConstants.PAGE) == null) && (pageSize != null && !pageSize.equals(BaseListCmd.PAGESIZE_UNLIMITED))) {
ServerApiException ex = new ServerApiException(ApiErrorCode.PARAM_ERROR, "\"page\" parameter is required when \"pagesize\" is specified");
ex.setCSErrorCode(CSExceptionErrorCode.getCSErrCode(ex.getClass().getName()));
throw ex;

View File

@ -787,7 +787,8 @@ public class ApiResponseHelper implements ResponseGenerator {
response.setAlgorithm(globalLoadBalancerRule.getAlgorithm());
response.setStickyMethod(globalLoadBalancerRule.getPersistence());
response.setServiceType(globalLoadBalancerRule.getServiceType());
response.setServiceDomainName(globalLoadBalancerRule.getGslbDomain());
response.setServiceDomainName(globalLoadBalancerRule.getGslbDomain() + "."
+ ApiDBUtils.getDnsNameConfiguredForGslb());
response.setName(globalLoadBalancerRule.getName());
response.setDescription(globalLoadBalancerRule.getDescription());
response.setRegionIdId(globalLoadBalancerRule.getRegion());

View File

@ -2346,7 +2346,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService {
// offerings
private boolean isPermissible(Long accountDomainId, Long offeringDomainId) {
if (accountDomainId == offeringDomainId) {
if (accountDomainId.equals(offeringDomainId)) {
return true; // account and service offering in same domain
}

View File

@ -681,7 +681,7 @@ public class CapacityManagerImpl extends ManagerBase implements CapacityManager,
if ((newState == State.Starting || newState == State.Migrating || event == Event.AgentReportMigrated) && vm.getHostId() != null) {
boolean fromLastHost = false;
if (vm.getLastHostId() == vm.getHostId()) {
if (vm.getHostId().equals(vm.getLastHostId())) {
s_logger.debug("VM starting again on the last host it was stopped on");
fromLastHost = true;
}

View File

@ -2491,7 +2491,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
if ( vlans != null && vlans.size() > 0 ) {
if ( vlanId == null ) {
vlanId = vlan.getVlanTag();
} else if ( vlan.getVlanTag() != vlanId ) {
} else if (!vlan.getVlanTag().equals(vlanId)) {
throw new InvalidParameterValueException("there is already one vlan " + vlan.getVlanTag() + " on network :" +
+ network.getId() + ", only one vlan is allowed on guest network");
}
@ -2657,6 +2657,8 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
if (uri != null) {
String[] vlan = uri.toString().split("vlan:\\/\\/");
networkVlanId = vlan[1];
//For pvlan
networkVlanId = networkVlanId.split("-")[0];
}
if (vlanId != null) {

View File

@ -57,7 +57,7 @@ AgentBasedConsoleProxyManager {
if (allocatedHost == null) {
/*Is there a consoleproxy agent running in the same pod?*/
for (HostVO hv : hosts) {
if (hv.getType() == Host.Type.ConsoleProxy && hv.getPodId() == host.getPodId()) {
if (hv.getType() == Host.Type.ConsoleProxy && hv.getPodId().equals(host.getPodId())) {
allocatedHost = hv;
break;
}

View File

@ -130,7 +130,8 @@ public interface NetworkManager {
Network createGuestNetwork(long networkOfferingId, String name, String displayText, String gateway, String cidr,
String vlanId, String networkDomain, Account owner, Long domainId, PhysicalNetwork physicalNetwork,
long zoneId, ACLType aclType, Boolean subdomainAccess, Long vpcId, String ip6Gateway, String ip6Cidr, Boolean displayNetworkEnabled)
long zoneId, ACLType aclType, Boolean subdomainAccess, Long vpcId, String ip6Gateway, String ip6Cidr,
Boolean displayNetworkEnabled, String isolatedPvlan)
throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException;
/**

View File

@ -1900,7 +1900,8 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
@DB
public Network createGuestNetwork(long networkOfferingId, String name, String displayText, String gateway,
String cidr, String vlanId, String networkDomain, Account owner, Long domainId,
PhysicalNetwork pNtwk, long zoneId, ACLType aclType, Boolean subdomainAccess, Long vpcId, String ip6Gateway, String ip6Cidr, Boolean isDisplayNetworkEnabled)
PhysicalNetwork pNtwk, long zoneId, ACLType aclType, Boolean subdomainAccess, Long vpcId, String ip6Gateway, String ip6Cidr,
Boolean isDisplayNetworkEnabled, String isolatedPvlan)
throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException {
NetworkOfferingVO ntwkOff = _networkOfferingDao.findById(networkOfferingId);
@ -1990,6 +1991,9 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
if (ipv6) {
throw new InvalidParameterValueException("IPv6 is not supported with security group!");
}
if (isolatedPvlan != null) {
throw new InvalidParameterValueException("Isolated Private VLAN is not supported with security group!");
}
// Only Account specific Isolated network with sourceNat service disabled are allowed in security group
// enabled zone
if ( ntwkOff.getGuestType() != GuestType.Shared ){
@ -2149,13 +2153,20 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
}
if (vlanId != null) {
userNetwork.setBroadcastUri(URI.create("vlan://" + vlanId));
userNetwork.setBroadcastDomainType(BroadcastDomainType.Vlan);
if (!vlanId.equalsIgnoreCase(Vlan.UNTAGGED)) {
userNetwork.setBroadcastDomainType(BroadcastDomainType.Vlan);
} else {
userNetwork.setBroadcastDomainType(BroadcastDomainType.Native);
}
if (isolatedPvlan == null) {
userNetwork.setBroadcastUri(URI.create("vlan://" + vlanId));
if (!vlanId.equalsIgnoreCase(Vlan.UNTAGGED)) {
userNetwork.setBroadcastDomainType(BroadcastDomainType.Vlan);
} else {
userNetwork.setBroadcastDomainType(BroadcastDomainType.Native);
}
} else {
if (vlanId.equalsIgnoreCase(Vlan.UNTAGGED)) {
throw new InvalidParameterValueException("Cannot support pvlan with untagged primary vlan!");
}
userNetwork.setBroadcastUri(NetUtils.generateUriForPvlan(vlanId, isolatedPvlan));
userNetwork.setBroadcastDomainType(BroadcastDomainType.Pvlan);
}
}
List<NetworkVO> networks = setupNetwork(owner, ntwkOff, userNetwork, plan, name, displayText, true, domainId,
@ -2758,7 +2769,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
guestNetwork = createGuestNetwork(requiredOfferings.get(0).getId(), owner.getAccountName() + "-network"
, owner.getAccountName() + "-network", null, null, null, null, owner, null, physicalNetwork,
zoneId, ACLType.Account,
null, null, null, null, true);
null, null, null, null, true, null);
if (guestNetwork == null) {
s_logger.warn("Failed to create default Virtual network for the account " + accountId + "in zone " + zoneId);
throw new CloudRuntimeException("Failed to create a Guest Isolated Networks with SourceNAT " +
@ -3634,8 +3645,10 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
nic.setGateway(ip.getGateway());
nic.setNetmask(ip.getNetmask());
nic.setIsolationUri(IsolationType.Vlan.toUri(ip.getVlanTag()));
nic.setBroadcastType(BroadcastDomainType.Vlan);
nic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(ip.getVlanTag()));
//nic.setBroadcastType(BroadcastDomainType.Vlan);
//nic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(ip.getVlanTag()));
nic.setBroadcastType(network.getBroadcastDomainType());
nic.setBroadcastUri(network.getBroadcastUri());
nic.setFormat(AddressFormat.Ip4);
nic.setReservationId(String.valueOf(ip.getVlanTag()));
nic.setMacAddress(ip.getMacAddress());

View File

@ -952,6 +952,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
String ip6Cidr = cmd.getIp6Cidr();
Boolean displayNetwork = cmd.getDisplayNetwork();
Long aclId = cmd.getAclId();
String isolatedPvlan = cmd.getIsolatedPvlan();
// Validate network offering
NetworkOfferingVO ntwkOff = _networkOfferingDao.findById(networkOfferingId);
@ -1143,6 +1144,14 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
}
}
if (isolatedPvlan != null && (zone.getNetworkType() != NetworkType.Advanced || ntwkOff.getGuestType() != Network.GuestType.Shared)) {
throw new InvalidParameterValueException("Can only support create Private VLAN network with advance shared network!");
}
if (isolatedPvlan != null && ipv6) {
throw new InvalidParameterValueException("Can only support create Private VLAN network with IPv4!");
}
// Regular user can create Guest Isolated Source Nat enabled network only
if (caller.getType() == Account.ACCOUNT_TYPE_NORMAL
&& (ntwkOff.getTrafficType() != TrafficType.Guest || ntwkOff.getGuestType() != Network.GuestType.Isolated
@ -1175,6 +1184,10 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
throw new InvalidParameterValueException("Cannot support IPv6 on network offering with external devices!");
}
if (isolatedPvlan != null && providersConfiguredForExternalNetworking(ntwkProviders)) {
throw new InvalidParameterValueException("Cannot support private vlan on network offering with external devices!");
}
if (cidr != null && providersConfiguredForExternalNetworking(ntwkProviders)) {
if (ntwkOff.getGuestType() == GuestType.Shared && (zone.getNetworkType() == NetworkType.Advanced) &&
isSharedNetworkOfferingWithServices(networkOfferingId)) {
@ -1251,7 +1264,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
throw new InvalidParameterValueException("Unable to find specified NetworkACL");
}
if(vpcId != acl.getVpcId()){
if(!vpcId.equals(acl.getVpcId())){
throw new InvalidParameterValueException("ACL: "+aclId+" do not belong to the VPC");
}
}
@ -1265,8 +1278,9 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
throw new InvalidParameterValueException("Internal Lb can be enabled on vpc networks only");
}
network = _networkMgr.createGuestNetwork(networkOfferingId, name, displayText, gateway, cidr, vlanId,
networkDomain, owner, sharedDomainId, pNtwk, zoneId, aclType, subdomainAccess, vpcId, ip6Gateway, ip6Cidr, displayNetwork);
network = _networkMgr.createGuestNetwork(networkOfferingId, name, displayText, gateway, cidr, vlanId,
networkDomain, owner, sharedDomainId, pNtwk, zoneId, aclType, subdomainAccess, vpcId,
ip6Gateway, ip6Cidr, displayNetwork, isolatedPvlan);
}
if (caller.getType() == Account.ACCOUNT_TYPE_ADMIN && createVlan) {
@ -3813,8 +3827,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService {
if (privateNetwork == null) {
//create Guest network
privateNetwork = _networkMgr.createGuestNetwork(ntwkOff.getId(), networkName, displayText, gateway, cidr, vlan,
null, owner, null, pNtwk, pNtwk.getDataCenterId(), ACLType.Account, null, null, null, null, true);
null, owner, null, pNtwk, pNtwk.getDataCenterId(), ACLType.Account, null, vpcId, null, null, true, null);
s_logger.debug("Created private network " + privateNetwork);
} else {
s_logger.debug("Private network already exists: " + privateNetwork);

View File

@ -30,6 +30,7 @@ import org.apache.cloudstack.api.command.admin.router.CreateVirtualRouterElement
import org.apache.cloudstack.api.command.admin.router.ListVirtualRouterElementsCmd;
import org.apache.log4j.Logger;
import com.cloud.agent.api.PvlanSetupCommand;
import com.cloud.agent.api.to.LoadBalancerTO;
import com.cloud.configuration.ConfigurationManager;
import com.cloud.configuration.dao.ConfigurationDao;
@ -47,6 +48,7 @@ import com.cloud.network.Network.Capability;
import com.cloud.network.Network.Provider;
import com.cloud.network.Network.Service;
import com.cloud.network.NetworkModel;
import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.Networks.TrafficType;
import com.cloud.network.PhysicalNetworkServiceProvider;
import com.cloud.network.PublicIpAddress;
@ -228,7 +230,6 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
throw new ResourceUnavailableException("Can't find at least one running router!",
DataCenter.class, network.getDataCenterId());
}
return true;
}

View File

@ -83,7 +83,7 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
if (networkType == NetworkType.Advanced
&& isMyTrafficType(offering.getTrafficType())
&& offering.getGuestType() == Network.GuestType.Isolated
&& isMyIsolationMethod(physicalNetwork)) {
&& isMyIsolationMethod(physicalNetwork) && !offering.isSystemOnly()) {
return true;
} else {
s_logger.trace("We only take care of Guest networks of type "

View File

@ -33,6 +33,7 @@ import com.cloud.user.User;
import com.cloud.uservm.UserVm;
import com.cloud.utils.component.Manager;
import com.cloud.vm.DomainRouterVO;
import com.cloud.vm.Nic;
import com.cloud.vm.NicProfile;
import com.cloud.vm.VirtualMachineProfile;
@ -112,4 +113,4 @@ public interface VirtualNetworkApplianceManager extends Manager, VirtualNetworkA
boolean removeDhcpSupportForSubnet(Network network, List<DomainRouterVO> routers) throws ResourceUnavailableException;
}
}

View File

@ -34,6 +34,7 @@ import com.cloud.agent.api.GetDomRVersionCmd;
import com.cloud.agent.api.ModifySshKeysCommand;
import com.cloud.agent.api.NetworkUsageAnswer;
import com.cloud.agent.api.NetworkUsageCommand;
import com.cloud.agent.api.PvlanSetupCommand;
import com.cloud.agent.api.StartupCommand;
import com.cloud.agent.api.StopAnswer;
import com.cloud.agent.api.check.CheckSshAnswer;
@ -2222,6 +2223,28 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
return dhcpRange;
}
private boolean setupDhcpForPvlan(boolean add, DomainRouterVO router, Nic nic) {
if (!nic.getBroadcastUri().getScheme().equals("pvlan")) {
return false;
}
String op = "add";
if (!add) {
op = "delete";
}
Network network = _networkDao.findById(nic.getNetworkId());
String networkTag = _networkModel.getNetworkTag(router.getHypervisorType(), network);
PvlanSetupCommand cmd = PvlanSetupCommand.createDhcpSetup(op, nic.getBroadcastUri(), networkTag, router.getInstanceName(), nic.getMacAddress(), nic.getIp4Address());
Commands cmds = new Commands(cmd);
// In fact we send command to the host of router, we're not programming router but the host
try {
sendCommandsToRouter(router, cmds);
} catch (AgentUnavailableException e) {
s_logger.warn("Agent Unavailable ", e);
return false;
}
return true;
}
@Override
public boolean finalizeDeployment(Commands cmds, VirtualMachineProfile<DomainRouterVO> profile,
DeployDestination dest, ReservationContext context) throws ResourceUnavailableException {
@ -2535,13 +2558,20 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
List<Network> guestNetworks = new ArrayList<Network>();
List<? extends Nic> routerNics = _nicDao.listByVmId(profile.getId());
for (Nic routerNic : routerNics) {
Network network = _networkModel.getNetwork(routerNic.getNetworkId());
for (Nic nic : routerNics) {
Network network = _networkModel.getNetwork(nic.getNetworkId());
if (network.getTrafficType() == TrafficType.Guest) {
guestNetworks.add(network);
if (nic.getBroadcastUri().getScheme().equals("pvlan")) {
result = setupDhcpForPvlan(true, router, nic);
}
}
}
if (!result) {
return result;
}
answer = cmds.getAnswer("getDomRVersion");
if (answer != null && answer instanceof GetDomRVersionAnswer) {
GetDomRVersionAnswer versionAnswer = (GetDomRVersionAnswer)answer;
@ -2567,6 +2597,14 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
VMInstanceVO vm = profile.getVirtualMachine();
DomainRouterVO domR = _routerDao.findById(vm.getId());
processStopOrRebootAnswer(domR, answer);
List<? extends Nic> routerNics = _nicDao.listByVmId(profile.getId());
for (Nic nic : routerNics) {
Network network = _networkModel.getNetwork(nic.getNetworkId());
if (network.getTrafficType() == TrafficType.Guest && nic.getBroadcastUri().getScheme().equals("pvlan")) {
setupDhcpForPvlan(false, domR, nic);
}
}
}
}

View File

@ -1236,12 +1236,14 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
//1) allocate nic for control and source nat public ip
networks = super.createRouterNetworks(owner, isRedundant, plan, null, sourceNatIp);
//2) allocate nic for private gateway if needed
PrivateGateway privateGateway = _vpcMgr.getVpcPrivateGateway(vpcId);
if (privateGateway != null) {
NicProfile privateNic = createPrivateNicProfileForGateway(privateGateway);
Network privateNetwork = _networkModel.getNetwork(privateGateway.getNetworkId());
networks.add(new Pair<NetworkVO, NicProfile>((NetworkVO) privateNetwork, privateNic));
//2) allocate nic for private gateways if needed
List<PrivateGateway> privateGateways = _vpcMgr.getVpcPrivateGateways(vpcId);
if (privateGateways != null && !privateGateways.isEmpty()) {
for (PrivateGateway privateGateway : privateGateways) {
NicProfile privateNic = createPrivateNicProfileForGateway(privateGateway);
Network privateNetwork = _networkModel.getNetwork(privateGateway.getNetworkId());
networks.add(new Pair<NetworkVO, NicProfile>((NetworkVO) privateNetwork, privateNic));
}
}
//3) allocate nic for guest gateway if needed

View File

@ -182,7 +182,7 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ
throw new InvalidParameterValueException("Unable to find Vpc associated with the NetworkACL");
}
_accountMgr.checkAccess(caller, null, true, vpc);
if(gateway.getVpcId() != acl.getVpcId()){
if(!gateway.getVpcId().equals(acl.getVpcId())){
throw new InvalidParameterValueException("private gateway: "+privateGatewayId+" and ACL: "+aclId+" do not belong to the same VPC");
}
}
@ -225,7 +225,7 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ
}
_accountMgr.checkAccess(caller, null, true, vpc);
if(network.getVpcId() != acl.getVpcId()){
if(!network.getVpcId().equals(acl.getVpcId())){
throw new InvalidParameterValueException("Network: "+networkId+" and ACL: "+aclId+" do not belong to the same VPC");
}
}

View File

@ -166,5 +166,5 @@ public interface VpcManager extends VpcService{
*/
void validateNtwkOffForNtwkInVpc(Long networkId, long newNtwkOffId, String newCidr, String newNetworkDomain, Vpc vpc, String gateway, Account networkOwner);
List<PrivateGateway> getVpcPrivateGateways(long id);
List<PrivateGateway> getVpcPrivateGateways(long vpcId);
}

View File

@ -711,8 +711,9 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
public boolean destroyVpc(Vpc vpc, Account caller, Long callerUserId) throws ConcurrentOperationException, ResourceUnavailableException {
s_logger.debug("Destroying vpc " + vpc);
//don't allow to delete vpc if it's in use by existing networks
int networksCount = _ntwkDao.getNetworkCountByVpcId(vpc.getId());
//don't allow to delete vpc if it's in use by existing non system networks (system networks are networks of a private gateway of the VPC,
//and they will get removed as a part of VPC cleanup
int networksCount = _ntwkDao.getNonSystemNetworkCountByVpcId(vpc.getId());
if (networksCount > 0) {
throw new InvalidParameterValueException("Can't delete VPC " + vpc + " as its used by " + networksCount + " networks");
}
@ -1235,7 +1236,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
return false;
}
//4) Delete private gateway
//4) Delete private gateways
List<PrivateGateway> gateways = getVpcPrivateGateways(vpcId);
if (gateways != null) {
for (PrivateGateway gateway: gateways) {
@ -1299,8 +1300,8 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
@Override
public List<PrivateGateway> getVpcPrivateGateways(long id) {
List<VpcGatewayVO> gateways = _vpcGatewayDao.listByVpcIdAndType(id, VpcGateway.Type.Private);
public List<PrivateGateway> getVpcPrivateGateways(long vpcId) {
List<VpcGatewayVO> gateways = _vpcGatewayDao.listByVpcIdAndType(vpcId, VpcGateway.Type.Private);
if (gateways != null) {
List<PrivateGateway> pvtGateway = new ArrayList();
@ -2024,8 +2025,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
//2) Create network
Network guestNetwork = _ntwkMgr.createGuestNetwork(ntwkOffId, name, displayText, gateway, cidr, vlanId,
networkDomain, owner, domainId, pNtwk, zoneId, aclType, subdomainAccess, vpcId, null, null, isDisplayNetworkEnabled);
networkDomain, owner, domainId, pNtwk, zoneId, aclType, subdomainAccess, vpcId, null, null, isDisplayNetworkEnabled, null);
if(guestNetwork != null){
guestNetwork.setNetworkACLId(aclId);

View File

@ -1152,7 +1152,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
if (volumePools.isEmpty()) {
allHosts.remove(host);
} else {
if (host.getClusterId() != srcHost.getClusterId() || usesLocal) {
if (!host.getClusterId().equals(srcHost.getClusterId()) || usesLocal) {
requiresStorageMotion.put(host, true);
}
}
@ -1887,7 +1887,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
}
// Don't allow to modify system template
if (id == Long.valueOf(1)) {
if (id.equals(Long.valueOf(1))) {
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to update template/iso of specified id");
ex.addProxyObject(template, id, "templateId");
throw ex;
@ -2414,7 +2414,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
public int compare(SummedCapacity arg0, SummedCapacity arg1) {
if (arg0.getPercentUsed() < arg1.getPercentUsed()) {
return 1;
} else if (arg0.getPercentUsed() == arg1.getPercentUsed()) {
} else if (arg0.getPercentUsed().equals(arg1.getPercentUsed())) {
return 0;
}
return -1;

View File

@ -423,6 +423,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
SearchCriteria.Op.EQ);
volumeSB.and("removed", volumeSB.entity().getRemoved(),
SearchCriteria.Op.NULL);
volumeSB.and("state", volumeSB.entity().getState(), SearchCriteria.Op.NIN);
SearchBuilder<VMInstanceVO> activeVmSB = _vmInstanceDao
.createSearchBuilder();
@ -434,6 +435,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
SearchCriteria<VolumeVO> volumeSC = volumeSB.create();
volumeSC.setParameters("poolId", PrimaryDataStoreVO.getId());
volumeSC.setParameters("state", Volume.State.Expunging, Volume.State.Destroy);
volumeSC.setJoinParameters("activeVmSB", "state",
State.Starting, State.Running, State.Stopping,
State.Migrating);
@ -456,13 +458,13 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
VirtualMachineProfile<VMInstanceVO> profile = new VirtualMachineProfileImpl<VMInstanceVO>(
vm);
for (StoragePoolAllocator allocator : _storagePoolAllocators) {
ExcludeList avoidList = new ExcludeList();
for(StoragePool pool : avoid){
avoidList.addPool(pool.getId());
}
DataCenterDeployment plan = new DataCenterDeployment(dc.getId(), pod.getId(), clusterId, hostId, null, null);
final List<StoragePool> poolList = allocator.allocateToPool(dskCh, profile, plan, avoidList, 1);
if (poolList != null && !poolList.isEmpty()) {
return (StoragePool)this.dataStoreMgr.getDataStore(poolList.get(0).getId(), DataStoreRole.Primary);
@ -629,6 +631,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
SearchCriteria.Op.EQ);
volumeSearch.and("poolId", volumeSearch.entity().getPoolId(),
SearchCriteria.Op.EQ);
volumeSearch.and("state", volumeSearch.entity().getState(), SearchCriteria.Op.EQ);
StoragePoolSearch.join("vmVolume", volumeSearch, volumeSearch.entity()
.getInstanceId(), StoragePoolSearch.entity().getId(),
JoinBuilder.JoinType.INNER);
@ -651,7 +654,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
return true;
}
@Override
public String getStoragePoolTags(long poolId) {
return _configMgr.listToCsvTags(_storagePoolDao
@ -680,7 +683,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
return true;
}
@DB
@Override
public DataStore createLocalStorage(Host host, StoragePoolInfo pInfo) throws ConnectionException {
@ -694,7 +697,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
StoragePoolVO pool = _storagePoolDao.findPoolByHostPath(host.getDataCenterId(), host.getPodId(), pInfo.getHost(), pInfo.getHostPath(), pInfo.getUuid());
if(pool == null && host.getHypervisorType() == HypervisorType.VMware) {
// perform run-time upgrade. In versions prior to 2.2.12, there is a bug that we don't save local datastore info (host path is empty), this will cause us
// not able to distinguish multiple local datastores that may be available on the host, to support smooth migration, we
// not able to distinguish multiple local datastores that may be available on the host, to support smooth migration, we
// need to perform runtime upgrade here
if(pInfo.getHostPath().length() > 0) {
pool = _storagePoolDao.findPoolByHostPath(host.getDataCenterId(), host.getPodId(), pInfo.getHost(), "", pInfo.getUuid());
@ -714,13 +717,13 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
params.put("details", pInfo.getDetails());
params.put("uuid", pInfo.getUuid());
params.put("providerName", provider.getName());
store = lifeCycle.initialize(params);
} else {
store = (DataStore) dataStoreMgr.getDataStore(pool.getId(),
DataStoreRole.Primary);
}
HostScope scope = new HostScope(host.getId());
lifeCycle.attachHost(store, scope, pInfo);
} catch (Exception e) {
@ -990,7 +993,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
}
CapacityState capacityState = (allocationState == AllocationState.Disabled) ?
CapacityState.Disabled : CapacityState.Enabled;
capacity.setCapacityState(capacityState);
_capacityDao.persist(capacity);
} else {
@ -1130,7 +1133,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
}finally {
scanLock.unlock();
}
}
}
}finally {
scanLock.releaseRef();
}
@ -1462,7 +1465,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
DataStore store = dataStoreMgr.getDataStore(
primaryStorage.getId(), DataStoreRole.Primary);
lifeCycle.cancelMaintain(store);
return (PrimaryDataStoreInfo) dataStoreMgr.getDataStore(
primaryStorage.getId(), DataStoreRole.Primary);
}
@ -1610,7 +1613,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
DataStoreRole.Primary);
}
@Override
@DB
@ -1618,6 +1621,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
SearchCriteria<VMInstanceVO> sc = StoragePoolSearch.create();
sc.setJoinParameters("vmVolume", "volumeType", Volume.Type.ROOT);
sc.setJoinParameters("vmVolume", "poolId", storagePoolId);
sc.setJoinParameters("vmVolume", "state", Volume.State.Ready);
return _vmInstanceDao.search(sc, null);
}
@ -1691,7 +1695,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
return secHost;
}
@Override
public HypervisorType getHypervisorTypeFromFormat(ImageFormat format) {

View File

@ -993,7 +993,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
}
//Verify parameters
if (sourceZoneId == destZoneId) {
if (sourceZoneId.equals(destZoneId)) {
throw new InvalidParameterValueException("Please specify different source and destination zones.");
}
@ -1522,7 +1522,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
Account caller = UserContext.current().getCaller();
Long id = cmd.getId();
if (id == Long.valueOf(1)) {
if (id.equals(Long.valueOf(1))) {
throw new PermissionDeniedException("unable to list permissions for " + cmd.getMediaType() + " with id " + id);
}
@ -1614,7 +1614,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
throw new InvalidParameterValueException("unable to update permissions for " + mediaType + " with id " + id + " as it is removed ");
}
if (id == Long.valueOf(1)) {
if (id.equals(Long.valueOf(1))) {
throw new InvalidParameterValueException("unable to update permissions for " + mediaType + " with id " + id);
}

View File

@ -792,14 +792,14 @@ public class DatabaseConfig {
}
// If a netmask was provided, check that the startIP, endIP, and gateway all belong to the same subnet
if (netmask != null && netmask != "") {
if (netmask != null && !netmask.equals("")) {
if (endIP != null) {
if (!IPRangeConfig.sameSubnet(startIP, endIP, netmask)) {
printError("Start and end IPs for the public IP range must be in the same subnet, as per the provided netmask.");
}
}
if (gateway != null && gateway != "") {
if (gateway != null && !gateway.equals("")) {
if (!IPRangeConfig.sameSubnet(startIP, gateway, netmask)) {
printError("The start IP for the public IP range must be in the same subnet as the gateway, as per the provided netmask.");
}

View File

@ -69,6 +69,7 @@ import com.cloud.agent.api.GetVmStatsAnswer;
import com.cloud.agent.api.GetVmStatsCommand;
import com.cloud.agent.api.PlugNicAnswer;
import com.cloud.agent.api.PlugNicCommand;
import com.cloud.agent.api.PvlanSetupCommand;
import com.cloud.agent.api.StartAnswer;
import com.cloud.agent.api.StopAnswer;
import com.cloud.agent.api.UnPlugNicAnswer;
@ -1023,6 +1024,13 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
throw new CloudRuntimeException("Failed to find a nic profile for the existing default network. This is bad and probably means some sort of configuration corruption");
}
Network oldDefaultNetwork = null;
oldDefaultNetwork = _networkModel.getDefaultNetworkForVm(vmId);
long oldNetworkOfferingId = -1L;
if(oldDefaultNetwork!=null) {
oldNetworkOfferingId = oldDefaultNetwork.getNetworkOfferingId();
}
NicVO existingVO = _nicDao.findById(existing.id);
Integer chosenID = nic.getDeviceId();
Integer existingID = existing.getDeviceId();
@ -1054,6 +1062,16 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
throw new CloudRuntimeException("Failed to change default nic to " + nic + " and now we have no default");
} else if (newdefault.getId() == nic.getNetworkId()) {
s_logger.debug("successfully set default network to " + network + " for " + vmInstance);
String nicIdString = Long.toString(nic.getId());
long newNetworkOfferingId = network.getNetworkOfferingId();
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_NETWORK_OFFERING_REMOVE, vmInstance.getAccountId(), vmInstance.getDataCenterId(),
vmInstance.getId(), nicIdString, oldNetworkOfferingId, null, 1L, VirtualMachine.class.getName(), vmInstance.getUuid());
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_NETWORK_OFFERING_ASSIGN, vmInstance.getAccountId(), vmInstance.getDataCenterId(),
vmInstance.getId(), nicIdString, newNetworkOfferingId, null, 1L, VirtualMachine.class.getName(), vmInstance.getUuid());
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_NETWORK_OFFERING_REMOVE, vmInstance.getAccountId(), vmInstance.getDataCenterId(),
vmInstance.getId(), nicIdString, newNetworkOfferingId, null, 0L, VirtualMachine.class.getName(), vmInstance.getUuid());
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_NETWORK_OFFERING_ASSIGN, vmInstance.getAccountId(), vmInstance.getDataCenterId(),
vmInstance.getId(), nicIdString, oldNetworkOfferingId, null, 0L, VirtualMachine.class.getName(), vmInstance.getUuid());
return _vmDao.findById(vmInstance.getId());
}
@ -1655,7 +1673,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
String description = "";
if (displayName != vmInstance.getDisplayName()) {
if (!displayName.equals(vmInstance.getDisplayName())) {
description += "New display name: " + displayName + ". ";
}
@ -2191,7 +2209,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
s_logger.debug("Creating network for account " + owner + " from the network offering id=" +requiredOfferings.get(0).getId() + " as a part of deployVM process");
Network newNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(),
owner.getAccountName() + "-network", owner.getAccountName() + "-network", null, null,
null, null, owner, null, physicalNetwork, zone.getId(), ACLType.Account, null, null, null, null, true);
null, null, owner, null, physicalNetwork, zone.getId(), ACLType.Account, null, null, null, null, true, null);
defaultNetwork = _networkDao.findById(newNetwork.getId());
} else if (virtualNetworks.size() > 1) {
throw new InvalidParameterValueException(
@ -2788,6 +2806,37 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
return true;
}
private boolean setupVmForPvlan(boolean add, Long hostId, NicVO nic) {
if (!nic.getBroadcastUri().getScheme().equals("pvlan")) {
return false;
}
String op = "add";
if (!add) {
// "delete" would remove all the rules(if using ovs) related to this vm
op = "delete";
}
Network network = _networkDao.findById(nic.getNetworkId());
Host host = _hostDao.findById(hostId);
String networkTag = _networkModel.getNetworkTag(host.getHypervisorType(), network);
PvlanSetupCommand cmd = PvlanSetupCommand.createVmSetup(op, nic.getBroadcastUri(), networkTag, nic.getMacAddress());
Answer answer = null;
try {
answer = _agentMgr.send(hostId, cmd);
} catch (OperationTimedoutException e) {
s_logger.warn("Timed Out", e);
return false;
} catch (AgentUnavailableException e) {
s_logger.warn("Agent Unavailable ", e);
return false;
}
boolean result = true;
if (answer == null || !answer.getResult()) {
result = false;
}
return result;
}
@Override
public boolean finalizeDeployment(Commands cmds,
VirtualMachineProfile<UserVmVO> profile, DeployDestination dest,
@ -2849,6 +2898,11 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
originalIp = nic.getIp4Address();
guestNic = nic;
guestNetwork = network;
if (nic.getBroadcastUri().getScheme().equals("pvlan")) {
if (!setupVmForPvlan(true, hostId, nic)) {
return false;
}
}
}
}
boolean ipChanged = false;
@ -2979,6 +3033,17 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
+ " stop due to exception ", ex);
}
}
VMInstanceVO vm = profile.getVirtualMachine();
List<NicVO> nics = _nicDao.listByVmId(vm.getId());
for (NicVO nic : nics) {
NetworkVO network = _networkDao.findById(nic.getNetworkId());
if (network.getTrafficType() == TrafficType.Guest) {
if (nic.getBroadcastUri().getScheme().equals("pvlan")) {
setupVmForPvlan(false, vm.getHostId(), nic);
}
}
}
}
public String generateRandomPassword() {
@ -3643,7 +3708,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
List<VolumeVO> vmVolumes = _volsDao.findUsableVolumesForInstance(vm.getId());
Map<VolumeVO, StoragePoolVO> volToPoolObjectMap = new HashMap<VolumeVO, StoragePoolVO>();
if (!isVMUsingLocalStorage(vm) && destinationHost.getClusterId() == srcHost.getClusterId()) {
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
// then fail the call. migrateVirtualMachine api should have been used.
@ -4038,7 +4103,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
requiredOfferings.get(0).getId() + " as a part of deployVM process");
Network newNetwork = _networkMgr.createGuestNetwork(requiredOfferings.get(0).getId(),
newAccount.getAccountName() + "-network", newAccount.getAccountName() + "-network", null, null,
null, null, newAccount, null, physicalNetwork, zone.getId(), ACLType.Account, null, null, null, null, true);
null, null, newAccount, null, physicalNetwork, zone.getId(), ACLType.Account, null, null, null, null, true, null);
// if the network offering has persistent set to true, implement the network
if (requiredOfferings.get(0).getIsPersistent()) {
DeployDestination dest = new DeployDestination(zone, null, null, null);

View File

@ -1322,7 +1322,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
if (migrationResult) {
//if the vm is migrated to different pod in basic mode, need to reallocate ip
if (vm.getPodIdToDeployIn() != destPool.getPodId()) {
if (!vm.getPodIdToDeployIn().equals(destPool.getPodId())) {
DataCenterDeployment plan = new DataCenterDeployment(vm.getDataCenterId(), destPool.getPodId(), null, null, null, null);
VirtualMachineProfileImpl<T> vmProfile = new VirtualMachineProfileImpl<T>(vm, null, null, null, null);
_networkMgr.reallocate(vmProfile, plan);

View File

@ -35,6 +35,7 @@ import com.cloud.region.ha.GlobalLoadBalancingRulesService;
import com.cloud.user.Account;
import com.cloud.user.AccountManager;
import com.cloud.user.UserContext;
import com.cloud.utils.Pair;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.Transaction;
import com.cloud.utils.exception.CloudRuntimeException;
@ -173,6 +174,7 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
List<Long> oldLbRuleIds = new ArrayList<Long>();
List<Long> oldZones = new ArrayList<Long>();
List<Long> newZones = new ArrayList<Long>(oldZones);
List<Pair<Long, Long>> physcialNetworks = new ArrayList<Pair<Long, Long>>();
// get the list of load balancer rules id's that are assigned currently to GSLB rule and corresponding zone id's
List<GlobalLoadBalancerLbRuleMapVO> gslbLbMapVos = _gslbLbMapDao.listByGslbRuleId(gslbRuleId);
@ -217,12 +219,14 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
}
newZones.add(network.getDataCenterId());
physcialNetworks.add(new Pair<Long, Long>(network.getDataCenterId(), network.getPhysicalNetworkId()));
}
// check each of the zone has a GSLB service provider configured
for (Long zoneId: newZones) {
if (!checkGslbServiceEnabledInZone(zoneId)) {
throw new InvalidParameterValueException("GSLB service is not enabled in the Zone");
// for each of the physical network check if GSLB service provider configured
for (Pair<Long, Long> physicalNetwork: physcialNetworks) {
if (!checkGslbServiceEnabledInZone(physicalNetwork.first(), physicalNetwork.second())) {
throw new InvalidParameterValueException("GSLB service is not enabled in the Zone:" +
physicalNetwork.first() + " and physical network " + physicalNetwork.second());
}
}
@ -543,8 +547,8 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
GlobalLoadBalancerConfigCommand gslbConfigCmd = new GlobalLoadBalancerConfigCommand(gslbFqdn,
lbMethod, persistenceMethod, serviceType, gslbRuleId, revoke);
// list of the zones participating in global load balancing
List<Long> gslbSiteIds = new ArrayList<Long>();
// list of the physical network participating in global load balancing
List<Pair<Long, Long>> gslbSiteIds = new ArrayList<Pair<Long, Long>>();
// map of the zone and info corresponding to the load balancer configured in the zone
Map<Long, SiteLoadBalancerConfig> zoneSiteLoadbalancerMap = new HashMap<Long, SiteLoadBalancerConfig>();
@ -559,37 +563,38 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
LoadBalancerVO loadBalancer = _lbDao.findById(gslbLbMapVo.getLoadBalancerId());
Network network = _networkDao.findById(loadBalancer.getNetworkId());
long dataCenterId = network.getDataCenterId();
long physicalNetworkId = network.getPhysicalNetworkId();
gslbSiteIds.add(dataCenterId);
gslbSiteIds.add(new Pair<Long, Long>(dataCenterId, physicalNetworkId));
IPAddressVO ip = _ipAddressDao.findById(loadBalancer.getSourceIpAddressId());
SiteLoadBalancerConfig siteLb = new SiteLoadBalancerConfig(gslbLbMapVo.isRevoke(), serviceType,
ip.getAddress().addr(), Integer.toString(loadBalancer.getDefaultPortStart()),
dataCenterId);
siteLb.setGslbProviderPublicIp(_gslbProvider.getZoneGslbProviderPublicIp(dataCenterId));
siteLb.setGslbProviderPrivateIp(_gslbProvider.getZoneGslbProviderPrivateIp(dataCenterId));
siteLb.setGslbProviderPublicIp(_gslbProvider.getZoneGslbProviderPublicIp(dataCenterId, physicalNetworkId));
siteLb.setGslbProviderPrivateIp(_gslbProvider.getZoneGslbProviderPrivateIp(dataCenterId, physicalNetworkId));
zoneSiteLoadbalancerMap.put(network.getDataCenterId(), siteLb);
}
// loop through all the zones, participating in GSLB, and send GSLB config command
// to the corresponding GSLB service provider in that zone
for (long zoneId: gslbSiteIds) {
for (Pair<Long,Long> zoneId: gslbSiteIds) {
List<SiteLoadBalancerConfig> slbs = new ArrayList<SiteLoadBalancerConfig>();
// set site as 'local' for the site in that zone
for (long innerLoopZoneId: gslbSiteIds) {
SiteLoadBalancerConfig siteLb = zoneSiteLoadbalancerMap.get(innerLoopZoneId);
siteLb.setLocal(zoneId == innerLoopZoneId);
for (Pair<Long,Long> innerLoopZoneId: gslbSiteIds) {
SiteLoadBalancerConfig siteLb = zoneSiteLoadbalancerMap.get(innerLoopZoneId.first());
siteLb.setLocal(zoneId.first() == innerLoopZoneId.first());
slbs.add(siteLb);
}
gslbConfigCmd.setSiteLoadBalancers(slbs);
try {
_gslbProvider.applyGlobalLoadBalancerRule(zoneId, gslbConfigCmd);
_gslbProvider.applyGlobalLoadBalancerRule(zoneId.first(), zoneId.second(), gslbConfigCmd);
} catch (ResourceUnavailableException e) {
s_logger.warn("Failed to configure GSLB rul in the zone " + zoneId + " due to " + e.getMessage());
throw new CloudRuntimeException("Failed to configure GSLB rul in the zone");
@ -599,13 +604,13 @@ public class GlobalLoadBalancingRulesServiceImpl implements GlobalLoadBalancingR
return true;
}
private boolean checkGslbServiceEnabledInZone(long zoneId) {
private boolean checkGslbServiceEnabledInZone(long zoneId, long physicalNetworkId) {
if (_gslbProvider == null) {
throw new CloudRuntimeException("No GSLB provider is available");
}
return _gslbProvider.isServiceEnabledInZone(zoneId);
return _gslbProvider.isServiceEnabledInZone(zoneId, physicalNetworkId);
}
@Override

View File

@ -24,13 +24,13 @@ import org.apache.cloudstack.region.RegionServiceProvider;
public interface GslbServiceProvider extends RegionServiceProvider {
public boolean isServiceEnabledInZone(long zoneId);
public boolean isServiceEnabledInZone(long zoneId, long physicalNetworkId);
public String getZoneGslbProviderPublicIp(long zoneId);
public String getZoneGslbProviderPublicIp(long zoneId, long physicalNetworkId);
public String getZoneGslbProviderPrivateIp(long zoneId);
public String getZoneGslbProviderPrivateIp(long zoneId, long physicalNetworkId);
public boolean applyGlobalLoadBalancerRule(long zoneId, GlobalLoadBalancerConfigCommand gslbConfigCmd)
public boolean applyGlobalLoadBalancerRule(long zoneId, long physicalNetworkId, GlobalLoadBalancerConfigCommand gslbConfigCmd)
throws ResourceUnavailableException;
}

View File

@ -272,7 +272,7 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkManage
@Override
public Network createGuestNetwork(long networkOfferingId, String name, String displayText, String gateway, String cidr, String vlanId, String networkDomain, Account owner, Long domainId,
PhysicalNetwork physicalNetwork, long zoneId, ACLType aclType, Boolean subdomainAccess, Long vpcId, String gatewayv6, String cidrv6, Boolean displayNetworkEnabled) throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException {
PhysicalNetwork physicalNetwork, long zoneId, ACLType aclType, Boolean subdomainAccess, Long vpcId, String gatewayv6, String cidrv6, Boolean displayNetworkEnabled, String isolatedPvlan) throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException {
// TODO Auto-generated method stub
return null;
}

View File

@ -868,7 +868,8 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkManage
@Override
public Network createGuestNetwork(long networkOfferingId, String name, String displayText, String gateway,
String cidr, String vlanId, String networkDomain, Account owner, Long domainId,
PhysicalNetwork physicalNetwork, long zoneId, ACLType aclType, Boolean subdomainAccess, Long vpcId, String gatewayv6, String cidrv6, Boolean displayNetworkEnabled)
PhysicalNetwork physicalNetwork, long zoneId, ACLType aclType, Boolean subdomainAccess, Long vpcId, String gatewayv6, String cidrv6,
Boolean displayNetworkEnabled, String isolatedPvlan)
throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException {
// TODO Auto-generated method stub
return null;

View File

@ -379,7 +379,7 @@ public class MockVpcManagerImpl extends ManagerBase implements VpcManager {
}
@Override
public List<PrivateGateway> getVpcPrivateGateways(long id) {
public List<PrivateGateway> getVpcPrivateGateways(long vpcId) {
return null;
}

View File

@ -367,4 +367,9 @@ public class MockNetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implemen
return null;
}
@Override
public int getNonSystemNetworkCountByVpcId(long vpcId) {
return 0;
}
}

View File

@ -730,6 +730,9 @@ public class GlobalLoadBalancingRulesServiceImplTest extends TestCase {
Field dcID = NetworkVO.class.getDeclaredField("dataCenterId");
dcID.setAccessible(true);
dcID.set(networkVo, new Long(1));
Field phyNetworkId = NetworkVO.class.getDeclaredField("physicalNetworkId");
phyNetworkId.setAccessible(true);
phyNetworkId.set(networkVo, new Long(200));
when(gslbServiceImpl._networkDao.findById(new Long(1))).thenReturn(networkVo);
GlobalLoadBalancerLbRuleMapVO gslbLbMap = new GlobalLoadBalancerLbRuleMapVO(1, 1);

View File

@ -78,7 +78,6 @@ class Services:
"template": {
"displaytext": "Public Template",
"name": "Public template",
"ostypeid": 'bc66ada0-99e7-483b-befc-8fb0c2129b70',
"url": "http://download.cloud.com/releases/2.0.0/UbuntuServer-10-04-64bit.vhd.bz2",
"hypervisor": 'XenServer',
"format": 'VHD',
@ -243,7 +242,7 @@ class TestRemoveUserFromAccount(cloudstackTestCase):
cls.template = get_template(
cls.api_client,
cls.zone.id,
cls.services["ostypeid"]
cls.services["ostype"]
)
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls.services["virtual_machine"]["template"] = cls.template.id
@ -568,7 +567,7 @@ class TestNonRootAdminsPrivileges(cloudstackTestCase):
self.apiclient,
self.services["account"]
)
self.debug("Created account: %s" % account_2.account.name)
self.debug("Created account: %s" % account_2.name)
self.cleanup.append(account_2)
accounts_response = list_accounts(
@ -886,7 +885,7 @@ class TesttemplateHierarchy(cloudstackTestCase):
cls.template = Template.register(
cls.api_client,
cls.services["template"],
account=cls.account_1.account.name,
account=cls.account_1.name,
domainid=cls.domain_1.id
)
cls._cleanup = [
@ -935,7 +934,7 @@ class TesttemplateHierarchy(cloudstackTestCase):
templates = list_templates(
self.apiclient,
templatefilter='self',
account=self.account_1.account.name,
account=self.account_1.name,
domainid=self.domain_1.id
)
self.assertEqual(
@ -960,7 +959,7 @@ class TesttemplateHierarchy(cloudstackTestCase):
templates = list_templates(
self.apiclient,
templatefilter='self',
account=self.account_2.account.name,
account=self.account_2.name,
domainid=self.domain_2.id
)
self.assertEqual(
@ -1033,15 +1032,15 @@ class TestAddVmToSubDomain(cloudstackTestCase):
cls.template = get_template(
cls.api_client,
cls.zone.id,
cls.services["ostypeid"]
cls.services["ostype"]
)
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls.vm_1 = VirtualMachine.create(
cls.api_client,
cls.services["virtual_machine"],
templateid=cls.template.id,
accountid=cls.account_1.account.name,
domainid=cls.account_1.account.domainid,
accountid=cls.account_1.name,
domainid=cls.account_1.domainid,
serviceofferingid=cls.service_offering.id
)
@ -1049,8 +1048,8 @@ class TestAddVmToSubDomain(cloudstackTestCase):
cls.api_client,
cls.services["virtual_machine"],
templateid=cls.template.id,
accountid=cls.account_2.account.name,
domainid=cls.account_2.account.domainid,
accountid=cls.account_2.name,
domainid=cls.account_2.domainid,
serviceofferingid=cls.service_offering.id
)
cls._cleanup = [
@ -1625,7 +1624,7 @@ class TestDomainForceRemove(cloudstackTestCase):
cls.template = get_template(
cls.api_client,
cls.zone.id,
cls.services["ostypeid"]
cls.services["ostype"]
)
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
@ -1719,31 +1718,31 @@ class TestDomainForceRemove(cloudstackTestCase):
)
self.debug("Deploying virtual machine in account 1: %s" %
self.account_1.account.name)
self.account_1.name)
vm_1 = VirtualMachine.create(
self.apiclient,
self.services["virtual_machine"],
templateid=self.template.id,
accountid=self.account_1.account.name,
domainid=self.account_1.account.domainid,
accountid=self.account_1.name,
domainid=self.account_1.domainid,
serviceofferingid=self.service_offering.id
)
self.debug("Deploying virtual machine in account 2: %s" %
self.account_2.account.name)
self.account_2.name)
vm_2 = VirtualMachine.create(
self.apiclient,
self.services["virtual_machine"],
templateid=self.template.id,
accountid=self.account_2.account.name,
domainid=self.account_2.account.domainid,
accountid=self.account_2.name,
domainid=self.account_2.domainid,
serviceofferingid=self.service_offering.id
)
networks = Network.list(
self.apiclient,
account=self.account_1.account.name,
domainid=self.account_1.account.domainid,
account=self.account_1.name,
domainid=self.account_1.domainid,
listall=True
)
self.assertEqual(
@ -1753,13 +1752,13 @@ class TestDomainForceRemove(cloudstackTestCase):
)
network_1 = networks[0]
self.debug("Default network in account 1: %s is %s" % (
self.account_1.account.name,
self.account_1.name,
network_1.name))
src_nat_list = PublicIPAddress.list(
self.apiclient,
associatednetworkid=network_1.id,
account=self.account_1.account.name,
domainid=self.account_1.account.domainid,
account=self.account_1.name,
domainid=self.account_1.domainid,
listall=True,
issourcenat=True,
)
@ -1823,8 +1822,8 @@ class TestDomainForceRemove(cloudstackTestCase):
self.debug("Checking if the resources in domain are deleted or not..")
accounts = Account.list(
self.apiclient,
name=self.account_1.account.name,
domainid=self.account_1.account.domainid,
name=self.account_1.name,
domainid=self.account_1.domainid,
listall=True
)
@ -1894,31 +1893,31 @@ class TestDomainForceRemove(cloudstackTestCase):
self.cleanup.append(self.service_offering)
self.debug("Deploying virtual machine in account 1: %s" %
self.account_1.account.name)
self.account_1.name)
vm_1 = VirtualMachine.create(
self.apiclient,
self.services["virtual_machine"],
templateid=self.template.id,
accountid=self.account_1.account.name,
domainid=self.account_1.account.domainid,
accountid=self.account_1.name,
domainid=self.account_1.domainid,
serviceofferingid=self.service_offering.id
)
self.debug("Deploying virtual machine in account 2: %s" %
self.account_2.account.name)
self.account_2.name)
vm_2 = VirtualMachine.create(
self.apiclient,
self.services["virtual_machine"],
templateid=self.template.id,
accountid=self.account_2.account.name,
domainid=self.account_2.account.domainid,
accountid=self.account_2.name,
domainid=self.account_2.domainid,
serviceofferingid=self.service_offering.id
)
networks = Network.list(
self.apiclient,
account=self.account_1.account.name,
domainid=self.account_1.account.domainid,
account=self.account_1.name,
domainid=self.account_1.domainid,
listall=True
)
self.assertEqual(
@ -1928,13 +1927,13 @@ class TestDomainForceRemove(cloudstackTestCase):
)
network_1 = networks[0]
self.debug("Default network in account 1: %s is %s" % (
self.account_1.account.name,
self.account_1.name,
network_1.name))
src_nat_list = PublicIPAddress.list(
self.apiclient,
associatednetworkid=network_1.id,
account=self.account_1.account.name,
domainid=self.account_1.account.domainid,
account=self.account_1.name,
domainid=self.account_1.domainid,
listall=True,
issourcenat=True,
)

View File

@ -191,25 +191,25 @@ class TestResourceLimitsAccount(cloudstackTestCase):
self.debug(
"Updating instance resource limit for account: %s" %
self.account_1.account.name)
self.account_1.name)
# Set usage_vm=1 for Account 1
update_resource_limit(
self.apiclient,
0, # Instance
account=self.account_1.account.name,
domainid=self.account_1.account.domainid,
account=self.account_1.name,
domainid=self.account_1.domainid,
max=1
)
self.debug(
"Deploying VM instance in account: %s" %
self.account_1.account.name)
self.account_1.name)
virtual_machine = VirtualMachine.create(
self.apiclient,
self.services["server"],
templateid=self.template.id,
accountid=self.account_1.account.name,
domainid=self.account_1.account.domainid,
accountid=self.account_1.name,
domainid=self.account_1.domainid,
serviceofferingid=self.service_offering.id
)
self.cleanup.append(virtual_machine)
@ -227,20 +227,20 @@ class TestResourceLimitsAccount(cloudstackTestCase):
self.apiclient,
self.services["server"],
templateid=self.template.id,
accountid=self.account_1.account.name,
domainid=self.account_1.account.domainid,
accountid=self.account_1.name,
domainid=self.account_1.domainid,
serviceofferingid=self.service_offering.id
)
self.debug(
"Deploying VM instance in account: %s" %
self.account_2.account.name)
self.account_2.name)
# Start 2 instances for account_2
virtual_machine_1 = VirtualMachine.create(
self.apiclient,
self.services["server"],
templateid=self.template.id,
accountid=self.account_2.account.name,
domainid=self.account_2.account.domainid,
accountid=self.account_2.name,
domainid=self.account_2.domainid,
serviceofferingid=self.service_offering.id
)
self.cleanup.append(virtual_machine_1)
@ -253,13 +253,13 @@ class TestResourceLimitsAccount(cloudstackTestCase):
self.debug(
"Deploying VM instance in account: %s" %
self.account_2.account.name)
self.account_2.name)
virtual_machine_2 = VirtualMachine.create(
self.apiclient,
self.services["server"],
templateid=self.template.id,
accountid=self.account_2.account.name,
domainid=self.account_2.account.domainid,
accountid=self.account_2.name,
domainid=self.account_2.domainid,
serviceofferingid=self.service_offering.id
)
self.cleanup.append(virtual_machine_2)
@ -287,25 +287,25 @@ class TestResourceLimitsAccount(cloudstackTestCase):
self.debug(
"Updating public IP resource limit for account: %s" %
self.account_1.account.name)
self.account_1.name)
# Set usage_vm=1 for Account 1
update_resource_limit(
self.apiclient,
1, # Public Ip
account=self.account_1.account.name,
domainid=self.account_1.account.domainid,
account=self.account_1.name,
domainid=self.account_1.domainid,
max=2
)
self.debug(
"Deploying VM instance in account: %s" %
self.account_1.account.name)
self.account_1.name)
virtual_machine_1 = VirtualMachine.create(
self.apiclient,
self.services["server"],
templateid=self.template.id,
accountid=self.account_1.account.name,
domainid=self.account_1.account.domainid,
accountid=self.account_1.name,
domainid=self.account_1.domainid,
serviceofferingid=self.service_offering.id
)
self.cleanup.append(virtual_machine_1)
@ -318,14 +318,14 @@ class TestResourceLimitsAccount(cloudstackTestCase):
self.debug(
"Deploying VM instance in account: %s" %
self.account_2.account.name)
self.account_2.name)
# Create VM for second account
virtual_machine_2 = VirtualMachine.create(
self.apiclient,
self.services["server"],
templateid=self.template.id,
accountid=self.account_2.account.name,
domainid=self.account_2.account.domainid,
accountid=self.account_2.name,
domainid=self.account_2.domainid,
serviceofferingid=self.service_offering.id
)
self.cleanup.append(virtual_machine_2)
@ -431,25 +431,25 @@ class TestResourceLimitsAccount(cloudstackTestCase):
self.debug(
"Updating public IP resource limit for account: %s" %
self.account_1.account.name)
self.account_1.name)
# Set usage_vm=1 for Account 1
update_resource_limit(
self.apiclient,
3, # Snapshot
account=self.account_1.account.name,
domainid=self.account_1.account.domainid,
account=self.account_1.name,
domainid=self.account_1.domainid,
max=1
)
self.debug(
"Deploying VM instance in account: %s" %
self.account_1.account.name)
self.account_1.name)
virtual_machine_1 = VirtualMachine.create(
self.apiclient,
self.services["server"],
templateid=self.template.id,
accountid=self.account_1.account.name,
domainid=self.account_1.account.domainid,
accountid=self.account_1.name,
domainid=self.account_1.domainid,
serviceofferingid=self.service_offering.id
)
self.cleanup.append(virtual_machine_1)
@ -462,14 +462,14 @@ class TestResourceLimitsAccount(cloudstackTestCase):
self.debug(
"Deploying VM instance in account: %s" %
self.account_1.account.name)
self.account_1.name)
# Create VM for second account
virtual_machine_2 = VirtualMachine.create(
self.apiclient,
self.services["server"],
templateid=self.template.id,
accountid=self.account_2.account.name,
domainid=self.account_2.account.domainid,
accountid=self.account_2.name,
domainid=self.account_2.domainid,
serviceofferingid=self.service_offering.id
)
self.cleanup.append(virtual_machine_2)
@ -498,8 +498,8 @@ class TestResourceLimitsAccount(cloudstackTestCase):
# Create a snapshot from the ROOTDISK (Account 1)
snapshot_1 = Snapshot.create(self.apiclient,
volumes[0].id,
account=self.account_1.account.name,
domainid=self.account_1.account.domainid,
account=self.account_1.name,
domainid=self.account_1.domainid,
)
self.cleanup.append(snapshot_1)
# Verify Snapshot state
@ -516,8 +516,8 @@ class TestResourceLimitsAccount(cloudstackTestCase):
with self.assertRaises(Exception):
Snapshot.create(self.apiclient,
volumes[0].id,
account=self.account_1.account.name,
domainid=self.account_1.account.domainid,
account=self.account_1.name,
domainid=self.account_1.domainid,
)
# Get the Root disk of VM
@ -538,8 +538,8 @@ class TestResourceLimitsAccount(cloudstackTestCase):
# Create a snapshot from the ROOTDISK (Account 2)
snapshot_2 = Snapshot.create(self.apiclient,
volumes[0].id,
account=self.account_2.account.name,
domainid=self.account_2.account.domainid,
account=self.account_2.name,
domainid=self.account_2.domainid,
)
self.cleanup.append(snapshot_2)
# Verify Snapshot state
@ -556,8 +556,8 @@ class TestResourceLimitsAccount(cloudstackTestCase):
# Create a second snapshot from the ROOTDISK (Account 2)
snapshot_3 = Snapshot.create(self.apiclient,
volumes[0].id,
account=self.account_2.account.name,
domainid=self.account_2.account.domainid,
account=self.account_2.name,
domainid=self.account_2.domainid,
)
self.cleanup.append(snapshot_3)
# Verify Snapshot state
@ -587,25 +587,25 @@ class TestResourceLimitsAccount(cloudstackTestCase):
self.debug(
"Updating volume resource limit for account: %s" %
self.account_1.account.name)
self.account_1.name)
# Set usage_vm=1 for Account 1
update_resource_limit(
self.apiclient,
2, # Volume
account=self.account_1.account.name,
domainid=self.account_1.account.domainid,
account=self.account_1.name,
domainid=self.account_1.domainid,
max=2
)
self.debug(
"Deploying VM for account: %s" % self.account_1.account.name)
"Deploying VM for account: %s" % self.account_1.name)
virtual_machine_1 = VirtualMachine.create(
self.apiclient,
self.services["server"],
templateid=self.template.id,
accountid=self.account_1.account.name,
domainid=self.account_1.account.domainid,
accountid=self.account_1.name,
domainid=self.account_1.domainid,
serviceofferingid=self.service_offering.id
)
self.cleanup.append(virtual_machine_1)
@ -617,15 +617,15 @@ class TestResourceLimitsAccount(cloudstackTestCase):
)
self.debug(
"Deploying VM for account: %s" % self.account_2.account.name)
"Deploying VM for account: %s" % self.account_2.name)
# Create VM for second account
virtual_machine_2 = VirtualMachine.create(
self.apiclient,
self.services["server"],
templateid=self.template.id,
accountid=self.account_2.account.name,
domainid=self.account_2.account.domainid,
accountid=self.account_2.name,
domainid=self.account_2.domainid,
serviceofferingid=self.service_offering.id
)
self.cleanup.append(virtual_machine_2)
@ -637,13 +637,13 @@ class TestResourceLimitsAccount(cloudstackTestCase):
)
self.debug(
"Create a data volume for account: %s" % self.account_1.account.name)
"Create a data volume for account: %s" % self.account_1.name)
volume_1 = Volume.create(
self.apiclient,
self.services["volume"],
zoneid=self.zone.id,
account=self.account_1.account.name,
domainid=self.account_1.account.domainid,
account=self.account_1.name,
domainid=self.account_1.domainid,
diskofferingid=self.disk_offering.id
)
self.cleanup.append(volume_1)
@ -663,20 +663,20 @@ class TestResourceLimitsAccount(cloudstackTestCase):
self.apiclient,
self.services["volume"],
zoneid=self.zone.id,
account=self.account_1.account.name,
domainid=self.account_1.account.domainid,
account=self.account_1.name,
domainid=self.account_1.domainid,
diskofferingid=self.disk_offering.id
)
self.debug(
"Create a data volume for account: %s" % self.account_2.account.name)
"Create a data volume for account: %s" % self.account_2.name)
# Create volume for Account 2
volume_2 = Volume.create(
self.apiclient,
self.services["volume"],
zoneid=self.zone.id,
account=self.account_2.account.name,
domainid=self.account_2.account.domainid,
account=self.account_2.name,
domainid=self.account_2.domainid,
diskofferingid=self.disk_offering.id
)
self.cleanup.append(volume_2)
@ -691,14 +691,14 @@ class TestResourceLimitsAccount(cloudstackTestCase):
)
self.debug(
"Create a data volume for account: %s" % self.account_2.account.name)
"Create a data volume for account: %s" % self.account_2.name)
# Create a second volume from the ROOTDISK (Account 2)
volume_3 = Volume.create(
self.apiclient,
self.services["volume"],
zoneid=self.zone.id,
account=self.account_2.account.name,
domainid=self.account_2.account.domainid,
account=self.account_2.name,
domainid=self.account_2.domainid,
diskofferingid=self.disk_offering.id
)
self.cleanup.append(volume_3)
@ -727,25 +727,25 @@ class TestResourceLimitsAccount(cloudstackTestCase):
self.debug(
"Updating template resource limit for account: %s" %
self.account_1.account.name)
self.account_1.name)
# Set usage_vm=1 for Account 1
update_resource_limit(
self.apiclient,
4, # Template
account=self.account_1.account.name,
domainid=self.account_1.account.domainid,
account=self.account_1.name,
domainid=self.account_1.domainid,
max=1
)
self.debug(
"Updating volume resource limit for account: %s" %
self.account_1.account.name)
self.account_1.name)
virtual_machine_1 = VirtualMachine.create(
self.apiclient,
self.services["server"],
templateid=self.template.id,
accountid=self.account_1.account.name,
domainid=self.account_1.account.domainid,
accountid=self.account_1.name,
domainid=self.account_1.domainid,
serviceofferingid=self.service_offering.id
)
self.cleanup.append(virtual_machine_1)
@ -758,14 +758,14 @@ class TestResourceLimitsAccount(cloudstackTestCase):
self.debug(
"Deploying virtual machine for account: %s" %
self.account_2.account.name)
self.account_2.name)
# Create VM for second account
virtual_machine_2 = VirtualMachine.create(
self.apiclient,
self.services["server"],
templateid=self.template.id,
accountid=self.account_2.account.name,
domainid=self.account_2.account.domainid,
accountid=self.account_2.name,
domainid=self.account_2.domainid,
serviceofferingid=self.service_offering.id
)
self.cleanup.append(virtual_machine_2)
@ -798,8 +798,8 @@ class TestResourceLimitsAccount(cloudstackTestCase):
self.apiclient,
self.services["template"],
volumeid=volume.id,
account=self.account_1.account.name,
domainid=self.account_1.account.domainid,
account=self.account_1.name,
domainid=self.account_1.domainid,
)
self.cleanup.append(template_1)
@ -816,8 +816,8 @@ class TestResourceLimitsAccount(cloudstackTestCase):
self.apiclient,
self.services["template"],
volumeid=volume.id,
account=self.account_1.account.name,
domainid=self.account_1.account.domainid,
account=self.account_1.name,
domainid=self.account_1.domainid,
)
virtual_machine_2.stop(self.apiclient)
# Get the Root disk of VM
@ -841,8 +841,8 @@ class TestResourceLimitsAccount(cloudstackTestCase):
self.apiclient,
self.services["template"],
volumeid=volume.id,
account=self.account_2.account.name,
domainid=self.account_2.account.domainid,
account=self.account_2.name,
domainid=self.account_2.domainid,
)
self.cleanup.append(template_2)
@ -859,8 +859,8 @@ class TestResourceLimitsAccount(cloudstackTestCase):
self.apiclient,
self.services["template"],
volumeid=volume.id,
account=self.account_2.account.name,
domainid=self.account_2.account.domainid,
account=self.account_2.name,
domainid=self.account_2.domainid,
)
self.cleanup.append(template_3)

View File

@ -178,6 +178,12 @@ class TestStorageMotion(cloudstackTestCase):
# Migrate to a host that requires storage motion
hosts[:] = [host for host in hosts if host.requiresStorageMotion]
self.assert_(hosts is not None, msg="No valid hosts for storage motion")
self.assert_(len(hosts)>0, msg="No valid hosts for storage motion. Skipping")
if hosts is None or len(hosts) == 0:
self.skipTest("No valid hosts for storage motion. Skipping")
host = hosts[0]
self.debug("Migrating VM-ID: %s to Host: %s" % (
self.virtual_machine.id,

View File

@ -83,7 +83,7 @@ class TestVMPasswordEnabled(cloudstackTestCase):
# Get Zone, Domain and templates
domain = get_domain(cls.api_client, cls.services)
zone = get_zone(cls.api_client, cls.services)
cls.services['mode'] = cls.zone.networktype
cls.services['mode'] = zone.networktype
template = get_template(
cls.api_client,
zone.id,

View File

@ -0,0 +1,86 @@
# 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.
""" test for private vlan isolation
"""
#Import Local Modules
import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin import remoteSSHClient
from marvin.integration.lib.utils import *
from marvin.integration.lib.base import *
from marvin.integration.lib.common import *
from nose.plugins.attrib import attr
import telnetlib
#Import System modules
import time
_multiprocess_shared_ = True
class TestPVLAN(cloudstackTestCase):
zoneId = 1
networkOfferingId = 7
vlan = 1234
isolatedpvlan = 567
def setUp(self):
self.apiClient = self.testClient.getApiClient()
def test_create_pvlan_network(self):
self.debug("Test create pvlan network")
createNetworkCmd = createNetwork.createNetworkCmd()
createNetworkCmd.name = "pvlan network"
createNetworkCmd.displaytext = "pvlan network"
createNetworkCmd.netmask = "255.255.255.0"
createNetworkCmd.gateway = "10.10.10.1"
createNetworkCmd.startip = "10.10.10.10"
createNetworkCmd.gateway = "10.10.10.20"
createNetworkCmd.vlan = "1234"
createNetworkCmd.isolatedpvlan = "567"
createNetworkCmd.zoneid = self.zoneId
createNetworkCmd.networkofferingid = self.networkOfferingId
createNetworkResponse = self.apiClient.createNetwork(createNetworkCmd)
self.networkId = createNetworkResponse.id
self.broadcasttype = createNetworkResponse.broadcastdomaintype
self.broadcasturi = createNetworkResponse.broadcasturi
self.assertIsNotNone(createNetworkResponse.id, "Network failed to create")
self.assertTrue(createNetworkResponse.broadcastdomaintype, "Pvlan")
self.assertTrue(createNetworkResponse.broadcasturi, "pvlan://1234-i567")
self.debug("Clean up test pvlan network")
deleteNetworkCmd = deleteNetwork.deleteNetworkCmd()
deleteNetworkCmd.id = self.networkId;
self.apiClient.deleteNetwork(deleteNetworkCmd)
#Test invalid parameter
# CLOUDSTACK-2392: Should not allow create pvlan with ipv6
createNetworkCmd.ip6gateway="fc00:1234::1"
createNetworkCmd.ip6cidr="fc00:1234::/64"
createNetworkCmd.startipv6="fc00:1234::10"
createNetworkCmd.endipv6="fc00:1234::20"
err = 0;
try:
createNetworkResponse = self.apiClient.createNetwork(createNetworkCmd)
except Exception as e:
err = 1;
self.debug("Try alloc with ipv6, got:%s" % e)
self.assertEqual(err, 1, "Shouldn't allow create PVLAN network with IPv6");

View File

@ -34,7 +34,7 @@ bundle
# Clean and start building the appliance
veewee vbox destroy $appliance
veewee vbox build $appliance --nogui
veewee vbox build $appliance --nogui --auto
veewee vbox halt $appliance
while [[ `vboxmanage list runningvms | grep $appliance | wc -l` -ne 0 ]];

View File

@ -1300,6 +1300,7 @@
name: { label: 'label.name' },
type: { label: 'label.type' },
vlan: { label: 'label.vlan.id' },
broadcasturi: { label: 'broadcast URI' },
cidr: { label: 'IPv4 CIDR' },
ip6cidr: { label: 'IPv6 CIDR'}
//scope: { label: 'label.scope' }
@ -1335,7 +1336,10 @@
label: 'label.vlan.id',
docID: 'helpGuestNetworkZoneVLANID'
},
isolatedpvlanId: {
label: 'Private VLAN ID'
},
scope: {
label: 'label.scope',
docID: 'helpGuestNetworkZoneScope',
@ -1549,11 +1553,15 @@
if(this.id == selectedNetworkOfferingId) {
if(this.specifyvlan == false) {
$form.find('.form-item[rel=vlanId]').hide();
cloudStack.dialog.createFormField.validation.required.remove($form.find('.form-item[rel=vlanId]')); //make vlanId optional
cloudStack.dialog.createFormField.validation.required.remove($form.find('.form-item[rel=vlanId]')); //make vlanId optional
$form.find('.form-item[rel=isolatedpvlanId]').hide();
}
else {
$form.find('.form-item[rel=vlanId]').css('display', 'inline-block');
cloudStack.dialog.createFormField.validation.required.add($form.find('.form-item[rel=vlanId]')); //make vlanId required
cloudStack.dialog.createFormField.validation.required.add($form.find('.form-item[rel=vlanId]')); //make vlanId required
$form.find('.form-item[rel=isolatedpvlanId]').css('display', 'inline-block');
}
return false; //break each loop
}
@ -1639,7 +1647,10 @@
if(($form.find('.form-item[rel=vlanId]').css("display") != "none") && (args.data.vlanId != null && args.data.vlanId.length > 0))
array1.push("&vlan=" + todb(args.data.vlanId));
if(($form.find('.form-item[rel=isolatedpvlanId]').css("display") != "none") && (args.data.isolatedpvlanId != null && args.data.isolatedpvlanId.length > 0))
array1.push("&isolatedpvlan=" + todb(args.data.isolatedpvlanId));
if($form.find('.form-item[rel=domainId]').css("display") != "none") {
array1.push("&domainId=" + args.data.domainId);
@ -2007,6 +2018,7 @@
}
},
vlan: { label: 'label.vlan.id' },
broadcasturi: { label: 'broadcast URI' },
scope: { label: 'label.scope' },
networkofferingdisplaytext: { label: 'label.network.offering' },
networkofferingid: {

View File

@ -24,6 +24,7 @@ import java.net.InetAddress;
import java.net.InterfaceAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.URI;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Formatter;
@ -1294,4 +1295,29 @@ public class NetUtils {
}
return resultIp;
}
public static URI generateUriForPvlan(String primaryVlan, String isolatedPvlan) {
return URI.create("pvlan://" + primaryVlan + "-i" + isolatedPvlan);
}
public static String getPrimaryPvlanFromUri(URI uri) {
String[] vlans = uri.getHost().split("-");
if (vlans.length < 1) {
return null;
}
return vlans[0];
}
public static String getIsolatedPvlanFromUri(URI uri) {
String[] vlans = uri.getHost().split("-");
if (vlans.length < 2) {
return null;
}
for (String vlan : vlans) {
if (vlan.startsWith("i")) {
return vlan.replace("i", " ").trim();
}
}
return null;
}
}

View File

@ -17,6 +17,7 @@
package com.cloud.utils.net;
import java.math.BigInteger;
import java.net.URI;
import java.util.SortedSet;
import java.util.TreeSet;
@ -128,4 +129,11 @@ public class NetUtilsTest extends TestCase {
assertFalse(NetUtils.isIp6InRange("1234:5678:abcd::1", null));
assertTrue(NetUtils.isIp6InRange("1234:5678:abcd::1", "1234:5678::1-1234:5679::1"));
}
public void testPvlan() {
URI uri = NetUtils.generateUriForPvlan("123", "456");
assertTrue(uri.toString().equals("pvlan://123-i456"));
assertTrue(NetUtils.getPrimaryPvlanFromUri(uri).equals("123"));
assertTrue(NetUtils.getIsolatedPvlanFromUri(uri).equals("456"));
}
}