Merge pull request #1578 from nlivens/nuage_vsp_internal_dns

CLOUDSTACK-9401 : Support for Internal DNS in Nuage VSP pluginSupporting Internal Dns by using Dns service provider as Virtual Router but Dhcp provider will be NuageVsp. The idea is here is to keep using Internal Dns service of cloudstack when network provider is some other vendor.

A sample network offering will be like below one:-
Service Provider
DHCP NuageVsp
DNS VirtualRouter/VpcVirtualRouter
UserData VirtualRouter/VpcVirtualRouter
Virtual Networking NuageVsp
SourceNat NuageVsp
StaticNat NuageVsp
NetworkAcl/Firewall NuageVsp

* pr/1578:
  CLOUDSTACK-9401 : Marvin tests for Internal DNS verification with NuageVsp
  CLOUDSTACK-9401 : Support for Internal DNS in Nuage VSP plugin

Signed-off-by: Rajani Karuturi <rajani.karuturi@accelerite.com>
This commit is contained in:
Rajani Karuturi 2016-11-16 11:04:02 +05:30
commit 363896571b
42 changed files with 3412 additions and 1694 deletions

View File

@ -0,0 +1,36 @@
// 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.network.element;
import com.cloud.deploy.DeployDestination;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.Network;
import com.cloud.vm.NicProfile;
import com.cloud.vm.ReservationContext;
import com.cloud.vm.VirtualMachineProfile;
public interface DnsServiceProvider extends NetworkElement {
boolean addDnsEntry(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context)
throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException;
boolean configDnsSupportForSubnet(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context)
throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException;
boolean removeDnsSupportForSubnet(Network network) throws ResourceUnavailableException;
}

View File

@ -23,7 +23,6 @@ import java.util.Map;
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
import org.apache.cloudstack.framework.config.ConfigKey;
import org.apache.cloudstack.framework.config.ConfigKey.Scope;
import com.cloud.deploy.DataCenterDeployment;
import com.cloud.deploy.DeployDestination;
import com.cloud.deploy.DeploymentPlan;
@ -39,6 +38,7 @@ import com.cloud.network.Network.Service;
import com.cloud.network.NetworkProfile;
import com.cloud.network.PhysicalNetwork;
import com.cloud.network.element.DhcpServiceProvider;
import com.cloud.network.element.DnsServiceProvider;
import com.cloud.network.element.LoadBalancingServiceProvider;
import com.cloud.network.element.StaticNatServiceProvider;
import com.cloud.network.element.UserDataServiceProvider;
@ -219,6 +219,8 @@ public interface NetworkOrchestrationService {
DhcpServiceProvider getDhcpServiceProvider(Network network);
DnsServiceProvider getDnsServiceProvider(Network network);
void removeDhcpServiceInSubnet(Nic nic);
boolean resourceCountNeedsUpdate(NetworkOffering ntwkOff, ACLType aclType);

View File

@ -32,12 +32,9 @@ import java.util.UUID;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
import com.cloud.network.Networks;
import com.cloud.network.dao.NetworkDetailsDao;
import com.cloud.network.dao.RemoteAccessVpnDao;
import com.cloud.network.dao.RemoteAccessVpnVO;
@ -59,7 +56,6 @@ import org.apache.cloudstack.framework.messagebus.MessageBus;
import org.apache.cloudstack.framework.messagebus.PublishScope;
import org.apache.cloudstack.managed.context.ManagedContextRunnable;
import org.apache.cloudstack.region.PortableIpDao;
import com.cloud.agent.AgentManager;
import com.cloud.agent.Listener;
import com.cloud.agent.api.AgentControlAnswer;
@ -115,6 +111,7 @@ import com.cloud.network.NetworkMigrationResponder;
import com.cloud.network.NetworkModel;
import com.cloud.network.NetworkProfile;
import com.cloud.network.NetworkStateListener;
import com.cloud.network.Networks;
import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.Networks.TrafficType;
import com.cloud.network.PhysicalNetwork;
@ -141,6 +138,7 @@ import com.cloud.network.dao.PhysicalNetworkTrafficTypeVO;
import com.cloud.network.dao.PhysicalNetworkVO;
import com.cloud.network.element.AggregatedCommandExecutor;
import com.cloud.network.element.DhcpServiceProvider;
import com.cloud.network.element.DnsServiceProvider;
import com.cloud.network.element.IpDeployer;
import com.cloud.network.element.LoadBalancingServiceProvider;
import com.cloud.network.element.NetworkElement;
@ -1276,6 +1274,18 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
return false;
}
}
if (_networkModel.areServicesSupportedInNetwork(network.getId(), Service.Dns)
&& _networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.Dns, element.getProvider()) && element instanceof DnsServiceProvider) {
final DnsServiceProvider sp = (DnsServiceProvider)element;
if (profile.getIPv6Address() == null) {
if (!sp.configDnsSupportForSubnet(network, profile, vmProfile, dest, context)) {
return false;
}
}
if(!sp.addDnsEntry(network, profile, vmProfile, dest, context)) {
return false;
}
}
if (_networkModel.areServicesSupportedInNetwork(network.getId(), Service.UserData)
&& _networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.UserData, element.getProvider()) && element instanceof UserDataServiceProvider) {
final UserDataServiceProvider sp = (UserDataServiceProvider)element;
@ -1885,15 +1895,29 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
}
if (vm.getType() == Type.User
&& _networkModel.areServicesSupportedInNetwork(network.getId(), Service.Dhcp)
&& network.getTrafficType() == TrafficType.Guest
&& network.getGuestType() == GuestType.Shared
&& isLastNicInSubnet(nic)) {
// remove the dhcpservice ip if this is the last nic in subnet.
final DhcpServiceProvider dhcpServiceProvider = getDhcpServiceProvider(network);
if (dhcpServiceProvider != null
&& isDhcpAccrossMultipleSubnetsSupported(dhcpServiceProvider)) {
removeDhcpServiceInSubnet(nic);
if (_networkModel.areServicesSupportedInNetwork(network.getId(), Service.Dhcp)) {
// remove the dhcpservice ip if this is the last nic in subnet.
final DhcpServiceProvider dhcpServiceProvider = getDhcpServiceProvider(network);
if (dhcpServiceProvider != null
&& isDhcpAccrossMultipleSubnetsSupported(dhcpServiceProvider)) {
removeDhcpServiceInSubnet(nic);
}
}
if (_networkModel.areServicesSupportedInNetwork(network.getId(), Service.Dns)){
final DnsServiceProvider dnsServiceProvider = getDnsServiceProvider(network);
if (dnsServiceProvider != null) {
try {
if(!dnsServiceProvider.removeDnsSupportForSubnet(network)) {
s_logger.warn("Failed to remove the ip alias on the dns server");
}
} catch (final ResourceUnavailableException e) {
//failed to remove the dnsconfig.
s_logger.info("Unable to delete the ip alias due to unable to contact the dns server.");
}
}
}
}
@ -2807,6 +2831,18 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
}
}
@Override
public DnsServiceProvider getDnsServiceProvider(final Network network) {
final String dnsProvider = _ntwkSrvcDao.getProviderForServiceInNetwork(network.getId(), Service.Dns);
if (dnsProvider == null) {
s_logger.debug("Network " + network + " doesn't support service " + Service.Dhcp.getName());
return null;
}
return (DnsServiceProvider) _networkModel.getElementImplementingProvider(dnsProvider);
}
protected boolean isSharedNetworkWithServices(final Network network) {
assert network != null;
final DataCenter zone = _entityMgr.findById(DataCenter.class, network.getDataCenterId());

View File

@ -38,7 +38,7 @@
<dependency>
<groupId>net.nuage.vsp</groupId>
<artifactId>nuage-vsp-acs-client</artifactId>
<version>3.2.8.0</version>
<version>3.2.8.1</version>
</dependency>
</dependencies>
<build>

View File

@ -19,6 +19,8 @@
package com.cloud.agent.api;
import org.apache.commons.lang.builder.HashCodeBuilder;
import com.cloud.host.Host;
public class PingNuageVspCommand extends PingCommand {
@ -38,19 +40,18 @@ public class PingNuageVspCommand extends PingCommand {
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof PingNuageVspCommand)) return false;
if (!super.equals(o)) return false;
PingNuageVspCommand that = (PingNuageVspCommand) o;
if (shouldAudit != that.shouldAudit) return false;
return true;
return super.equals(that)
&& shouldAudit == that.shouldAudit;
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (shouldAudit ? 1 : 0);
return result;
return new HashCodeBuilder()
.appendSuper(super.hashCode())
.append(shouldAudit)
.toHashCode();
}
}

View File

@ -19,11 +19,15 @@
package com.cloud.agent.api.element;
import com.cloud.agent.api.Command;
import java.util.List;
import java.util.Objects;
import net.nuage.vsp.acs.client.api.model.VspAclRule;
import net.nuage.vsp.acs.client.api.model.VspNetwork;
import java.util.List;
import org.apache.commons.lang.builder.HashCodeBuilder;
import com.cloud.agent.api.Command;
public class ApplyAclRuleVspCommand extends Command {
@ -63,27 +67,30 @@ public class ApplyAclRuleVspCommand extends Command {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof ApplyAclRuleVspCommand)) return false;
if (!super.equals(o)) return false;
if (this == o) {
return true;
}
if (!(o instanceof ApplyAclRuleVspCommand)) {
return false;
}
ApplyAclRuleVspCommand that = (ApplyAclRuleVspCommand) o;
if (_networkReset != that._networkReset) return false;
if (_aclRules != null ? !_aclRules.equals(that._aclRules) : that._aclRules != null) return false;
if (_aclType != that._aclType) return false;
if (_network != null ? !_network.equals(that._network) : that._network != null) return false;
return true;
return super.equals(that)
&& _networkReset == that._networkReset
&& Objects.equals(_aclType, that._aclType)
&& Objects.equals(_network, that._network)
&& Objects.equals(_aclRules, that._aclRules);
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (_aclType != null ? _aclType.hashCode() : 0);
result = 31 * result + (_network != null ? _network.hashCode() : 0);
result = 31 * result + (_aclRules != null ? _aclRules.hashCode() : 0);
result = 31 * result + (_networkReset ? 1 : 0);
return result;
return new HashCodeBuilder()
.appendSuper(super.hashCode())
.append(_aclType)
.append(_network)
.append(_networkReset)
.toHashCode();
}
}

View File

@ -19,11 +19,15 @@
package com.cloud.agent.api.element;
import com.cloud.agent.api.Command;
import java.util.List;
import java.util.Objects;
import net.nuage.vsp.acs.client.api.model.VspNetwork;
import net.nuage.vsp.acs.client.api.model.VspStaticNat;
import java.util.List;
import org.apache.commons.lang.builder.HashCodeBuilder;
import com.cloud.agent.api.Command;
public class ApplyStaticNatVspCommand extends Command {
@ -51,24 +55,26 @@ public class ApplyStaticNatVspCommand extends Command {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof ApplyStaticNatVspCommand)) return false;
if (!super.equals(o)) return false;
if (this == o) {
return true;
}
if (!(o instanceof ApplyStaticNatVspCommand)) {
return false;
}
ApplyStaticNatVspCommand that = (ApplyStaticNatVspCommand) o;
if (_network != null ? !_network.equals(that._network) : that._network != null) return false;
if (_staticNatDetails != null ? !_staticNatDetails.equals(that._staticNatDetails) : that._staticNatDetails != null)
return false;
return true;
return super.equals(that)
&& Objects.equals(_network, that._network)
&& Objects.equals(_staticNatDetails, that._staticNatDetails);
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (_network != null ? _network.hashCode() : 0);
result = 31 * result + (_staticNatDetails != null ? _staticNatDetails.hashCode() : 0);
return result;
return new HashCodeBuilder()
.appendSuper(super.hashCode())
.append(_network)
.toHashCode();
}
}

View File

@ -19,38 +19,39 @@
package com.cloud.agent.api.element;
import com.cloud.agent.api.Command;
import java.util.List;
import java.util.Objects;
import net.nuage.vsp.acs.client.api.model.VspAclRule;
import net.nuage.vsp.acs.client.api.model.VspDhcpDomainOption;
import net.nuage.vsp.acs.client.api.model.VspNetwork;
import java.util.List;
import org.apache.commons.lang.builder.HashCodeBuilder;
import com.cloud.agent.api.Command;
public class ImplementVspCommand extends Command {
private final VspNetwork _network;
private final List<String> _dnsServers;
private final List<VspAclRule> _ingressFirewallRules;
private final List<VspAclRule> _egressFirewallRules;
private final List<String> _floatingIpUuids;
private final VspDhcpDomainOption _dhcpOption;
public ImplementVspCommand(VspNetwork network, List<String> dnsServers, List<VspAclRule> ingressFirewallRules,
List<VspAclRule> egressFirewallRules, List<String> floatingIpUuids) {
public ImplementVspCommand(VspNetwork network, List<VspAclRule> ingressFirewallRules,
List<VspAclRule> egressFirewallRules, List<String> floatingIpUuids, VspDhcpDomainOption dhcpOption) {
super();
this._network = network;
this._dnsServers = dnsServers;
this._ingressFirewallRules = ingressFirewallRules;
this._egressFirewallRules = egressFirewallRules;
this._floatingIpUuids = floatingIpUuids;
this._dhcpOption = dhcpOption;
}
public VspNetwork getNetwork() {
return _network;
}
public List<String> getDnsServers() {
return _dnsServers;
}
public List<VspAclRule> getIngressFirewallRules() {
return _ingressFirewallRules;
}
@ -63,6 +64,10 @@ public class ImplementVspCommand extends Command {
return _floatingIpUuids;
}
public VspDhcpDomainOption getDhcpOption() {
return _dhcpOption;
}
@Override
public boolean executeInSequence() {
return false;
@ -70,32 +75,30 @@ public class ImplementVspCommand extends Command {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof ImplementVspCommand)) return false;
if (!super.equals(o)) return false;
if (this == o) {
return true;
}
if (!(o instanceof ImplementVspCommand)) {
return false;
}
ImplementVspCommand that = (ImplementVspCommand) o;
if (_dnsServers != null ? !_dnsServers.equals(that._dnsServers) : that._dnsServers != null) return false;
if (_egressFirewallRules != null ? !_egressFirewallRules.equals(that._egressFirewallRules) : that._egressFirewallRules != null)
return false;
if (_floatingIpUuids != null ? !_floatingIpUuids.equals(that._floatingIpUuids) : that._floatingIpUuids != null)
return false;
if (_ingressFirewallRules != null ? !_ingressFirewallRules.equals(that._ingressFirewallRules) : that._ingressFirewallRules != null)
return false;
if (_network != null ? !_network.equals(that._network) : that._network != null) return false;
return true;
return super.equals(that)
&& Objects.equals(_network, that._network)
&& Objects.equals(_dhcpOption, that._dhcpOption)
&& Objects.equals(_floatingIpUuids, that._floatingIpUuids)
&& Objects.equals(_ingressFirewallRules, that._ingressFirewallRules)
&& Objects.equals(_egressFirewallRules, that._egressFirewallRules);
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (_network != null ? _network.hashCode() : 0);
result = 31 * result + (_dnsServers != null ? _dnsServers.hashCode() : 0);
result = 31 * result + (_ingressFirewallRules != null ? _ingressFirewallRules.hashCode() : 0);
result = 31 * result + (_egressFirewallRules != null ? _egressFirewallRules.hashCode() : 0);
result = 31 * result + (_floatingIpUuids != null ? _floatingIpUuids.hashCode() : 0);
return result;
return new HashCodeBuilder()
.appendSuper(super.hashCode())
.append(_network)
.append(_dhcpOption)
.toHashCode();
}
}

View File

@ -19,9 +19,12 @@
package com.cloud.agent.api.element;
import com.cloud.agent.api.Command;
import java.util.List;
import java.util.Objects;
import org.apache.commons.lang.builder.HashCodeBuilder;
import com.cloud.agent.api.Command;
public class ShutDownVpcVspCommand extends Command {
@ -61,29 +64,30 @@ public class ShutDownVpcVspCommand extends Command {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof ShutDownVpcVspCommand)) return false;
if (this == o) {
return true;
}
if (!(o instanceof ShutDownVpcVspCommand)) {
return false;
}
if (!super.equals(o)) return false;
ShutDownVpcVspCommand that = (ShutDownVpcVspCommand) o;
if (_domainRouterUuids != null ? !_domainRouterUuids.equals(that._domainRouterUuids) : that._domainRouterUuids != null)
return false;
if (_domainTemplateName != null ? !_domainTemplateName.equals(that._domainTemplateName) : that._domainTemplateName != null)
return false;
if (_domainUuid != null ? !_domainUuid.equals(that._domainUuid) : that._domainUuid != null) return false;
if (_vpcUuid != null ? !_vpcUuid.equals(that._vpcUuid) : that._vpcUuid != null) return false;
return true;
return super.equals(that)
&& Objects.equals(_domainUuid, that._domainUuid)
&& Objects.equals(_vpcUuid, that._vpcUuid)
&& Objects.equals(_domainTemplateName, that._domainTemplateName)
&& Objects.equals(_domainRouterUuids, that._domainRouterUuids);
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (_domainUuid != null ? _domainUuid.hashCode() : 0);
result = 31 * result + (_vpcUuid != null ? _vpcUuid.hashCode() : 0);
result = 31 * result + (_domainTemplateName != null ? _domainTemplateName.hashCode() : 0);
result = 31 * result + (_domainRouterUuids != null ? _domainRouterUuids.hashCode() : 0);
return result;
return new HashCodeBuilder()
.appendSuper(super.hashCode())
.append(_domainUuid)
.append(_vpcUuid)
.append(_domainTemplateName)
.toHashCode();
}
}

View File

@ -0,0 +1,84 @@
//
// 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.element;
import java.util.Objects;
import net.nuage.vsp.acs.client.api.model.VspDhcpDomainOption;
import net.nuage.vsp.acs.client.api.model.VspNetwork;
import org.apache.commons.lang.builder.ToStringBuilder;
import com.cloud.agent.api.Command;
public class ShutDownVspCommand extends Command {
private final VspNetwork _network;
private final VspDhcpDomainOption _dhcpOptions;
public ShutDownVspCommand(VspNetwork network, VspDhcpDomainOption dhcpOptions) {
super();
this._network = network;
this._dhcpOptions = dhcpOptions;
}
public VspNetwork getNetwork() {
return _network;
}
public VspDhcpDomainOption getDhcpOptions() {
return _dhcpOptions;
}
@Override
public boolean executeInSequence() {
return false;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof ShutDownVspCommand)) {
return false;
}
ShutDownVspCommand that = (ShutDownVspCommand) o;
return super.equals(that)
&& Objects.equals(_dhcpOptions, that._dhcpOptions)
&& Objects.equals(_network, that._network);
}
@Override
public int hashCode() {
return Objects.hash(_network, _dhcpOptions);
}
public String toDetailString() {
return new ToStringBuilder(this)
.append("network", _network)
.append("dhcpOptions", _dhcpOptions)
.toString();
}
}

View File

@ -19,11 +19,16 @@
package com.cloud.agent.api.guru;
import com.cloud.agent.api.Command;
import java.util.Objects;
import net.nuage.vsp.acs.client.api.model.VspNetwork;
import net.nuage.vsp.acs.client.api.model.VspNic;
import net.nuage.vsp.acs.client.api.model.VspVm;
import org.apache.commons.lang.builder.HashCodeBuilder;
import com.cloud.agent.api.Command;
public class DeallocateVmVspCommand extends Command {
private final VspNetwork _network;
@ -56,25 +61,29 @@ public class DeallocateVmVspCommand extends Command {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof DeallocateVmVspCommand)) return false;
if (!super.equals(o)) return false;
if (this == o) {
return true;
}
if (!(o instanceof DeallocateVmVspCommand)) {
return false;
}
DeallocateVmVspCommand that = (DeallocateVmVspCommand) o;
if (_network != null ? !_network.equals(that._network) : that._network != null) return false;
if (_nic != null ? !_nic.equals(that._nic) : that._nic != null) return false;
if (_vm != null ? !_vm.equals(that._vm) : that._vm != null) return false;
return true;
return super.equals(that)
&& Objects.equals(_network, that._network)
&& Objects.equals(_nic, that._nic)
&& Objects.equals(_vm, that._vm);
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (_network != null ? _network.hashCode() : 0);
result = 31 * result + (_vm != null ? _vm.hashCode() : 0);
result = 31 * result + (_nic != null ? _nic.hashCode() : 0);
return result;
return new HashCodeBuilder()
.appendSuper(super.hashCode())
.append(_network)
.append(_vm)
.append(_nic)
.toHashCode();
}
}

View File

@ -19,28 +19,33 @@
package com.cloud.agent.api.guru;
import com.cloud.agent.api.Command;
import java.util.Objects;
import net.nuage.vsp.acs.client.api.model.VspDhcpDomainOption;
import net.nuage.vsp.acs.client.api.model.VspNetwork;
import java.util.List;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import com.cloud.agent.api.Command;
public class ImplementNetworkVspCommand extends Command {
private final VspNetwork _network;
private final List<String> _dnsServers;
private final VspDhcpDomainOption _dhcpOption;
public ImplementNetworkVspCommand(VspNetwork network, List<String> dnsServers) {
public ImplementNetworkVspCommand(VspNetwork network, VspDhcpDomainOption dhcpOption) {
super();
this._network = network;
this._dnsServers = dnsServers;
this._dhcpOption = dhcpOption;
}
public VspNetwork getNetwork() {
return _network;
}
public List<String> getDnsServers() {
return _dnsServers;
public VspDhcpDomainOption getDhcpOption() {
return _dhcpOption;
}
@Override
@ -50,23 +55,34 @@ public class ImplementNetworkVspCommand extends Command {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof ImplementNetworkVspCommand)) return false;
if (!super.equals(o)) return false;
if (this == o) {
return true;
}
if (!(o instanceof ImplementNetworkVspCommand)) {
return false;
}
ImplementNetworkVspCommand that = (ImplementNetworkVspCommand) o;
if (_dnsServers != null ? !_dnsServers.equals(that._dnsServers) : that._dnsServers != null) return false;
if (_network != null ? !_network.equals(that._network) : that._network != null) return false;
return true;
return super.equals(that)
&& Objects.equals(_dhcpOption, that._dhcpOption)
&& Objects.equals(_network, that._network);
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (_network != null ? _network.hashCode() : 0);
result = 31 * result + (_dnsServers != null ? _dnsServers.hashCode() : 0);
return result;
return new HashCodeBuilder()
.appendSuper(super.hashCode())
.append(_network)
.append(_dhcpOption)
.toHashCode();
}
public String toDetailString() {
return new ToStringBuilder(this)
.append("network", _network)
.append("dhcpOption", _dhcpOption)
.toString();
}
}

View File

@ -19,25 +19,33 @@
package com.cloud.agent.api.guru;
import com.cloud.agent.api.Command;
import java.util.Objects;
import net.nuage.vsp.acs.client.api.model.VspDhcpVMOption;
import net.nuage.vsp.acs.client.api.model.VspNetwork;
import net.nuage.vsp.acs.client.api.model.VspNic;
import net.nuage.vsp.acs.client.api.model.VspStaticNat;
import net.nuage.vsp.acs.client.api.model.VspVm;
import org.apache.commons.lang.builder.HashCodeBuilder;
import com.cloud.agent.api.Command;
public class ReserveVmInterfaceVspCommand extends Command {
private final VspNetwork _network;
private final VspVm _vm;
private final VspNic _nic;
private final VspStaticNat _staticNat;
private final VspDhcpVMOption _dhcpOption;
public ReserveVmInterfaceVspCommand(VspNetwork network, VspVm vm, VspNic nic, VspStaticNat staticNat) {
public ReserveVmInterfaceVspCommand(VspNetwork network, VspVm vm, VspNic nic, VspStaticNat staticNat, VspDhcpVMOption dhcpOption) {
super();
this._network = network;
this._vm = vm;
this._nic = nic;
this._staticNat = staticNat;
this._dhcpOption = dhcpOption;
}
public VspNetwork getNetwork() {
@ -56,6 +64,10 @@ public class ReserveVmInterfaceVspCommand extends Command {
return _staticNat;
}
public VspDhcpVMOption getDhcpOption() {
return _dhcpOption;
}
@Override
public boolean executeInSequence() {
return false;
@ -63,27 +75,33 @@ public class ReserveVmInterfaceVspCommand extends Command {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof ReserveVmInterfaceVspCommand)) return false;
if (!super.equals(o)) return false;
if (this == o) {
return true;
}
if (!(o instanceof ReserveVmInterfaceVspCommand)) {
return false;
}
ReserveVmInterfaceVspCommand that = (ReserveVmInterfaceVspCommand) o;
if (_network != null ? !_network.equals(that._network) : that._network != null) return false;
if (_nic != null ? !_nic.equals(that._nic) : that._nic != null) return false;
if (_staticNat != null ? !_staticNat.equals(that._staticNat) : that._staticNat != null) return false;
if (_vm != null ? !_vm.equals(that._vm) : that._vm != null) return false;
return true;
return super.equals(that)
&& Objects.equals(_network, that._network)
&& Objects.equals(_nic, that._nic)
&& Objects.equals(_dhcpOption, that._dhcpOption)
&& Objects.equals(_staticNat, that._staticNat)
&& Objects.equals(_vm, that._vm);
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (_network != null ? _network.hashCode() : 0);
result = 31 * result + (_vm != null ? _vm.hashCode() : 0);
result = 31 * result + (_nic != null ? _nic.hashCode() : 0);
result = 31 * result + (_staticNat != null ? _staticNat.hashCode() : 0);
return result;
return new HashCodeBuilder()
.appendSuper(super.hashCode())
.append(_network)
.append(_vm)
.append(_nic)
.append(_staticNat)
.append(_dhcpOption)
.toHashCode();
}
}

View File

@ -19,9 +19,14 @@
package com.cloud.agent.api.guru;
import com.cloud.agent.api.Command;
import java.util.Objects;
import net.nuage.vsp.acs.client.api.model.VspNetwork;
import org.apache.commons.lang.builder.HashCodeBuilder;
import com.cloud.agent.api.Command;
public class TrashNetworkVspCommand extends Command {
private final VspNetwork _network;
@ -42,21 +47,25 @@ public class TrashNetworkVspCommand extends Command {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof TrashNetworkVspCommand)) return false;
if (!super.equals(o)) return false;
if (this == o) {
return true;
}
if (!(o instanceof TrashNetworkVspCommand)) {
return false;
}
TrashNetworkVspCommand that = (TrashNetworkVspCommand) o;
if (_network != null ? !_network.equals(that._network) : that._network != null) return false;
return true;
return super.equals(that)
&& Objects.equals(_network, that._network);
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (_network != null ? _network.hashCode() : 0);
return result;
return new HashCodeBuilder()
.appendSuper(super.hashCode())
.append(_network)
.toHashCode();
}
}

View File

@ -0,0 +1,87 @@
//
// 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.guru;
import java.util.List;
import java.util.Objects;
import net.nuage.vsp.acs.client.api.model.VspDhcpVMOption;
import net.nuage.vsp.acs.client.api.model.VspNetwork;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import com.cloud.agent.api.Command;
public class UpdateDhcpOptionVspCommand extends Command {
private final List<VspDhcpVMOption> _dhcpOptions;
private final VspNetwork _network;
public UpdateDhcpOptionVspCommand(List<VspDhcpVMOption> dhcpOptions, VspNetwork network) {
this._dhcpOptions = dhcpOptions;
this._network = network;
}
public List<VspDhcpVMOption> getDhcpOptions() {
return _dhcpOptions;
}
public VspNetwork getNetwork() {
return _network;
}
@Override
public boolean executeInSequence() {
return false;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof UpdateDhcpOptionVspCommand)) {
return false;
}
UpdateDhcpOptionVspCommand that = (UpdateDhcpOptionVspCommand) o;
return super.equals(that)
&& Objects.equals(_network, that._network)
&& Objects.equals(_dhcpOptions, that._dhcpOptions);
}
@Override
public int hashCode() {
return new HashCodeBuilder()
.appendSuper(super.hashCode())
.append(_network)
.toHashCode();
}
public String toDetailString() {
return new ToStringBuilder(this)
.append("network", _network)
.append("dhcpOptions", _dhcpOptions)
.toString();
}
}

View File

@ -19,9 +19,14 @@
package com.cloud.agent.api.manager;
import com.cloud.agent.api.Answer;
import java.util.Objects;
import net.nuage.vsp.acs.client.api.model.VspApiDefaults;
import org.apache.commons.lang.builder.HashCodeBuilder;
import com.cloud.agent.api.Answer;
public class GetApiDefaultsAnswer extends Answer {
private VspApiDefaults _apiDefaults;
@ -41,21 +46,25 @@ public class GetApiDefaultsAnswer extends Answer {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof GetApiDefaultsAnswer)) return false;
if (!super.equals(o)) return false;
if (this == o) {
return true;
}
if (!(o instanceof GetApiDefaultsAnswer)) {
return false;
}
GetApiDefaultsAnswer that = (GetApiDefaultsAnswer) o;
if (_apiDefaults != null ? !_apiDefaults.equals(that._apiDefaults) : that._apiDefaults != null) return false;
return true;
return super.equals(that)
&& Objects.equals(_apiDefaults, that._apiDefaults);
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (_apiDefaults != null ? _apiDefaults.hashCode() : 0);
return result;
return new HashCodeBuilder()
.appendSuper(super.hashCode())
.append(_apiDefaults)
.toHashCode();
}
}

View File

@ -19,6 +19,10 @@
package com.cloud.agent.api.manager;
import java.util.Objects;
import org.apache.commons.lang.builder.HashCodeBuilder;
import com.cloud.agent.api.Command;
public class SupportedApiVersionCommand extends Command {
@ -41,21 +45,26 @@ public class SupportedApiVersionCommand extends Command {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof SupportedApiVersionCommand)) return false;
if (!super.equals(o)) return false;
if (this == o) {
return true;
}
if (!(o instanceof SupportedApiVersionCommand)) {
return false;
}
SupportedApiVersionCommand that = (SupportedApiVersionCommand) o;
if (_apiVersion != null ? !_apiVersion.equals(that._apiVersion) : that._apiVersion != null) return false;
return super.equals(that)
&& Objects.equals(_apiVersion, that._apiVersion);
return true;
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (_apiVersion != null ? _apiVersion.hashCode() : 0);
return result;
return new HashCodeBuilder()
.appendSuper(super.hashCode())
.append(_apiVersion)
.toHashCode();
}
}

View File

@ -19,6 +19,8 @@
package com.cloud.agent.api.sync;
import org.apache.commons.lang.builder.HashCodeBuilder;
import com.cloud.agent.api.Answer;
public class SyncDomainAnswer extends Answer {
@ -37,21 +39,26 @@ public class SyncDomainAnswer extends Answer {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof SyncDomainAnswer)) return false;
if (!super.equals(o)) return false;
if (this == o) {
return true;
}
if (!(o instanceof SyncDomainAnswer)) {
return false;
}
SyncDomainAnswer that = (SyncDomainAnswer) o;
if (_success != that._success) return false;
return true;
return super.equals(that)
&& _success == that._success;
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (_success ? 1 : 0);
return result;
return new HashCodeBuilder()
.appendSuper(super.hashCode())
.append(_success)
.toHashCode();
}
}

View File

@ -19,32 +19,40 @@
package com.cloud.agent.api.sync;
import com.cloud.agent.api.Command;
import java.util.Objects;
import net.nuage.vsp.acs.client.api.model.VspDomain;
import org.apache.commons.lang.builder.HashCodeBuilder;
import com.cloud.agent.api.Command;
public class SyncDomainCommand extends Command {
public enum Type { ADD, REMOVE }
private final VspDomain _domain;
private final boolean _toAdd;
private final boolean _toRemove;
private final Type _action;
public SyncDomainCommand(VspDomain domain, boolean toAdd, boolean toRemove) {
public SyncDomainCommand(VspDomain domain, Type action) {
super();
this._domain = domain;
this._toAdd = toAdd;
this._toRemove = toRemove;
this._action = action;
}
public VspDomain getDomain() {
return _domain;
}
public Type getAction() {
return _action;
}
public boolean isToAdd() {
return _toAdd;
return Type.ADD.equals(_action);
}
public boolean isToRemove() {
return _toRemove;
return Type.REMOVE.equals(_action);
}
@Override
@ -60,19 +68,17 @@ public class SyncDomainCommand extends Command {
SyncDomainCommand that = (SyncDomainCommand) o;
if (_toAdd != that._toAdd) return false;
if (_toRemove != that._toRemove) return false;
if (_domain != null ? !_domain.equals(that._domain) : that._domain != null) return false;
return true;
return super.equals(that)
&& Objects.equals(_action, that._action)
&& Objects.equals(_domain, that._domain);
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (_domain != null ? _domain.hashCode() : 0);
result = 31 * result + (_toAdd ? 1 : 0);
result = 31 * result + (_toRemove ? 1 : 0);
return result;
return new HashCodeBuilder()
.appendSuper(super.hashCode())
.append(_domain)
.append(_action)
.toHashCode();
}
}

View File

@ -19,6 +19,10 @@
package com.cloud.agent.api.sync;
import java.util.Objects;
import org.apache.commons.lang.builder.HashCodeBuilder;
import com.cloud.agent.api.Answer;
public class SyncNuageVspCmsIdAnswer extends Answer {
@ -48,26 +52,29 @@ public class SyncNuageVspCmsIdAnswer extends Answer {
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof SyncNuageVspCmsIdAnswer)) return false;
if (!super.equals(o)) return false;
if (this == o) {
return true;
}
if (!(o instanceof SyncNuageVspCmsIdAnswer)) {
return false;
}
SyncNuageVspCmsIdAnswer that = (SyncNuageVspCmsIdAnswer) o;
if (_success != that._success) return false;
if (_nuageVspCmsId != null ? !_nuageVspCmsId.equals(that._nuageVspCmsId) : that._nuageVspCmsId != null)
return false;
if (_syncType != that._syncType) return false;
return true;
return super.equals(that)
&& _success == that._success
&& Objects.equals(_syncType, that._syncType)
&& Objects.equals(_nuageVspCmsId, that._nuageVspCmsId);
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (_success ? 1 : 0);
result = 31 * result + (_nuageVspCmsId != null ? _nuageVspCmsId.hashCode() : 0);
result = 31 * result + (_syncType != null ? _syncType.hashCode() : 0);
return result;
return new HashCodeBuilder()
.appendSuper(super.hashCode())
.append(_syncType)
.append(_nuageVspCmsId)
.append(_success)
.toHashCode();
}
}

View File

@ -19,6 +19,10 @@
package com.cloud.agent.api.sync;
import java.util.Objects;
import org.apache.commons.lang.builder.HashCodeBuilder;
import com.cloud.agent.api.Command;
public class SyncNuageVspCmsIdCommand extends Command {
@ -55,18 +59,17 @@ public class SyncNuageVspCmsIdCommand extends Command {
SyncNuageVspCmsIdCommand that = (SyncNuageVspCmsIdCommand) o;
if (_nuageVspCmsId != null ? !_nuageVspCmsId.equals(that._nuageVspCmsId) : that._nuageVspCmsId != null)
return false;
if (_syncType != that._syncType) return false;
return true;
return super.equals(that)
&& Objects.equals(_syncType, that._syncType)
&& Objects.equals(_nuageVspCmsId, that._nuageVspCmsId);
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (_syncType != null ? _syncType.hashCode() : 0);
result = 31 * result + (_nuageVspCmsId != null ? _nuageVspCmsId.hashCode() : 0);
return result;
return new HashCodeBuilder()
.appendSuper(super.hashCode())
.append(_syncType)
.append(_nuageVspCmsId)
.toHashCode();
}
}

View File

@ -19,6 +19,31 @@
package com.cloud.network.element;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.Nullable;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
import org.apache.commons.collections.CollectionUtils;
import org.apache.log4j.Logger;
import com.google.common.base.Function;
import com.google.common.collect.Lists;
import net.nuage.vsp.acs.client.api.model.VspAclRule;
import net.nuage.vsp.acs.client.api.model.VspDhcpDomainOption;
import net.nuage.vsp.acs.client.api.model.VspNetwork;
import net.nuage.vsp.acs.client.api.model.VspStaticNat;
import org.apache.cloudstack.api.InternalIdentity;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.network.ExternalNetworkDeviceManager;
import org.apache.cloudstack.network.topology.NetworkTopologyContext;
import org.apache.cloudstack.resourcedetail.VpcDetailVO;
import org.apache.cloudstack.resourcedetail.dao.VpcDetailsDao;
import com.cloud.agent.AgentManager;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.StartupCommand;
@ -27,6 +52,7 @@ import com.cloud.agent.api.element.ApplyAclRuleVspCommand;
import com.cloud.agent.api.element.ApplyStaticNatVspCommand;
import com.cloud.agent.api.element.ImplementVspCommand;
import com.cloud.agent.api.element.ShutDownVpcVspCommand;
import com.cloud.agent.api.element.ShutDownVspCommand;
import com.cloud.dc.VlanVO;
import com.cloud.dc.dao.DataCenterDao;
import com.cloud.dc.dao.VlanDao;
@ -60,6 +86,7 @@ import com.cloud.network.dao.PhysicalNetworkDao;
import com.cloud.network.dao.PhysicalNetworkVO;
import com.cloud.network.manager.NuageVspManager;
import com.cloud.network.manager.NuageVspManagerImpl;
import com.cloud.network.router.VpcVirtualNetworkApplianceManager;
import com.cloud.network.rules.FirewallRule;
import com.cloud.network.rules.FirewallRule.FirewallRuleType;
import com.cloud.network.rules.FirewallRuleVO;
@ -74,12 +101,14 @@ import com.cloud.network.vpc.VpcOfferingServiceMapVO;
import com.cloud.network.vpc.dao.VpcDao;
import com.cloud.network.vpc.dao.VpcOfferingServiceMapDao;
import com.cloud.offering.NetworkOffering;
import com.cloud.offerings.NetworkOfferingVO;
import com.cloud.offerings.dao.NetworkOfferingDao;
import com.cloud.offerings.dao.NetworkOfferingServiceMapDao;
import com.cloud.resource.ResourceManager;
import com.cloud.resource.ResourceStateAdapter;
import com.cloud.resource.ServerResource;
import com.cloud.resource.UnableDeleteHostException;
import com.cloud.util.NuageVspEntityBuilder;
import com.cloud.utils.component.AdapterBase;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.vm.DomainRouterVO;
@ -89,28 +118,6 @@ import com.cloud.vm.ReservationContext;
import com.cloud.vm.VirtualMachineProfile;
import com.cloud.vm.dao.DomainRouterDao;
import com.cloud.vm.dao.NicDao;
import com.google.common.base.Function;
import com.google.common.collect.Lists;
import com.cloud.util.NuageVspEntityBuilder;
import net.nuage.vsp.acs.client.api.model.VspAclRule;
import net.nuage.vsp.acs.client.api.model.VspNetwork;
import net.nuage.vsp.acs.client.api.model.VspStaticNat;
import org.apache.cloudstack.api.InternalIdentity;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.network.ExternalNetworkDeviceManager;
import org.apache.cloudstack.resourcedetail.VpcDetailVO;
import org.apache.cloudstack.resourcedetail.dao.VpcDetailsDao;
import org.apache.commons.collections.CollectionUtils;
import org.apache.log4j.Logger;
import javax.annotation.Nullable;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class NuageVspElement extends AdapterBase implements ConnectivityProvider, IpDeployer, SourceNatServiceProvider, StaticNatServiceProvider, FirewallServiceProvider,
DhcpServiceProvider, ResourceStateAdapter, VpcProvider, NetworkACLServiceProvider {
@ -169,8 +176,16 @@ public class NuageVspElement extends AdapterBase implements ConnectivityProvider
NuageVspEntityBuilder _nuageVspEntityBuilder;
@Inject
VpcDetailsDao _vpcDetailsDao;
@Inject
NetworkModel _networkMgr;
@Inject
NetworkTopologyContext networkTopologyContext;
@Inject
DomainRouterDao _routerDao;
@Inject
VpcVirtualNetworkApplianceManager _routerMgr;
@Override
public boolean applyIps(Network network, List<? extends PublicIpAddress> ipAddress, Set<Service> service) throws ResourceUnavailableException {
@ -257,8 +272,7 @@ public class NuageVspElement extends AdapterBase implements ConnectivityProvider
}
VspNetwork vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(network, false);
List<String> dnsServers = _nuageVspManager.getDnsDetails(network);
VspNetwork vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(network, true);
List<VspAclRule> ingressFirewallRules = getFirewallRulesToApply(network, FirewallRule.TrafficType.Ingress);
List<VspAclRule> egressFirewallRules = getFirewallRulesToApply(network, FirewallRule.TrafficType.Egress);
@ -267,9 +281,9 @@ public class NuageVspElement extends AdapterBase implements ConnectivityProvider
for (IPAddressVO ip : ips) {
floatingIpUuids.add(ip.getUuid());
}
VspDhcpDomainOption vspDhcpOptions = _nuageVspEntityBuilder.buildNetworkDhcpOption(network, offering);
HostVO nuageVspHost = getNuageVspHost(network.getPhysicalNetworkId());
ImplementVspCommand cmd = new ImplementVspCommand(vspNetwork, dnsServers, ingressFirewallRules, egressFirewallRules, floatingIpUuids);
ImplementVspCommand cmd = new ImplementVspCommand(vspNetwork, ingressFirewallRules, egressFirewallRules, floatingIpUuids, vspDhcpOptions);
Answer answer = _agentMgr.easySend(nuageVspHost.getId(), cmd);
if (answer == null || !answer.getResult()) {
s_logger.error("ImplementVspCommand for network " + network.getUuid() + " failed on Nuage VSD " + nuageVspHost.getDetail("hostname"));
@ -277,7 +291,6 @@ public class NuageVspElement extends AdapterBase implements ConnectivityProvider
throw new ResourceUnavailableException(answer.getDetails(), Network.class, network.getId());
}
}
return true;
}
@ -335,7 +348,21 @@ public class NuageVspElement extends AdapterBase implements ConnectivityProvider
if (!canHandle(network, Service.Connectivity)) {
return false;
}
if (cleanup && isDnsSupportedByVR(network)) {
// The network is restarted, possibly the domain name is changed, update the dhcpOptions as soon as possible
NetworkOfferingVO networkOfferingVO = _ntwkOfferingDao.findById(network.getNetworkOfferingId());
VspDhcpDomainOption vspDhcpOptions = _nuageVspEntityBuilder.buildNetworkDhcpOption(network, networkOfferingVO);
VspNetwork vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(network, false);
HostVO nuageVspHost = getNuageVspHost(network.getPhysicalNetworkId());
ShutDownVspCommand cmd = new ShutDownVspCommand(vspNetwork, vspDhcpOptions);
Answer answer = _agentMgr.easySend(nuageVspHost.getId(), cmd);
if (answer == null || !answer.getResult()) {
s_logger.error("ShutDownVspCommand for network " + network.getUuid() + " failed on Nuage VSD " + nuageVspHost.getDetail("hostname"));
if ((null != answer) && (null != answer.getDetails())) {
throw new ResourceUnavailableException(answer.getDetails(), Network.class, network.getId());
}
}
}
return true;
}
@ -436,11 +463,18 @@ public class NuageVspElement extends AdapterBase implements ConnectivityProvider
return true;
}
private boolean isDnsSupportedByVR(Network network) {
return (_networkModel.areServicesSupportedInNetwork(network.getId(), Service.Dns) &&
( _networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.Dns, Provider.VirtualRouter) ||
_networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.Dns, Provider.VPCVirtualRouter)));
}
@Override
public boolean removeDhcpSupportForSubnet(Network network) throws ResourceUnavailableException {
return true;
}
@Override
public boolean applyStaticNats(Network config, List<? extends StaticNat> rules) throws ResourceUnavailableException {
List<VspStaticNat> vspStaticNatDetails = new ArrayList<VspStaticNat>();

View File

@ -19,12 +19,33 @@
package com.cloud.network.guru;
import java.util.List;
import java.util.Map;
import javax.inject.Inject;
import net.nuage.vsp.acs.client.api.model.VspDhcpVMOption;
import net.nuage.vsp.acs.client.api.model.VspNetwork;
import net.nuage.vsp.acs.client.api.model.VspNic;
import net.nuage.vsp.acs.client.api.model.VspStaticNat;
import net.nuage.vsp.acs.client.api.model.VspVm;
import org.apache.log4j.Logger;
import com.google.common.base.Strings;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.apache.cloudstack.resourcedetail.VpcDetailVO;
import org.apache.cloudstack.resourcedetail.dao.VpcDetailsDao;
import com.cloud.agent.AgentManager;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.guru.DeallocateVmVspCommand;
import com.cloud.agent.api.guru.ImplementNetworkVspCommand;
import com.cloud.agent.api.guru.ReserveVmInterfaceVspCommand;
import com.cloud.agent.api.guru.TrashNetworkVspCommand;
import com.cloud.agent.api.guru.UpdateDhcpOptionVspCommand;
import com.cloud.configuration.ConfigurationManager;
import com.cloud.dc.DataCenter;
import com.cloud.dc.DataCenter.NetworkType;
@ -59,25 +80,17 @@ import com.cloud.offerings.dao.NetworkOfferingServiceMapDao;
import com.cloud.user.Account;
import com.cloud.user.AccountVO;
import com.cloud.user.dao.AccountDao;
import com.cloud.util.NuageVspEntityBuilder;
import com.cloud.utils.StringUtils;
import com.cloud.utils.db.DB;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.vm.Nic;
import com.cloud.vm.NicProfile;
import com.cloud.vm.NicVO;
import com.cloud.vm.ReservationContext;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachineProfile;
import com.google.common.base.Strings;
import com.cloud.util.NuageVspEntityBuilder;
import net.nuage.vsp.acs.client.api.model.VspNetwork;
import net.nuage.vsp.acs.client.api.model.VspNic;
import net.nuage.vsp.acs.client.api.model.VspStaticNat;
import net.nuage.vsp.acs.client.api.model.VspVm;
import org.apache.cloudstack.resourcedetail.VpcDetailVO;
import org.apache.cloudstack.resourcedetail.dao.VpcDetailsDao;
import org.apache.log4j.Logger;
import javax.inject.Inject;
import java.util.List;
import com.cloud.vm.dao.VMInstanceDao;
public class NuageVspGuestNetworkGuru extends GuestNetworkGuru {
public static final Logger s_logger = Logger.getLogger(NuageVspGuestNetworkGuru.class);
@ -97,6 +110,8 @@ public class NuageVspGuestNetworkGuru extends GuestNetworkGuru {
@Inject
VpcDao _vpcDao;
@Inject
VMInstanceDao _vmInstanceDao;
@Inject
AgentManager _agentMgr;
@Inject
NuageVspManager _nuageVspManager;
@ -184,8 +199,7 @@ public class NuageVspGuestNetworkGuru extends GuestNetworkGuru {
implemented.setBroadcastDomainType(Networks.BroadcastDomainType.Vsp);
HostVO nuageVspHost = getNuageVspHost(physicalNetworkId);
List<String> dnsServers = _nuageVspManager.getDnsDetails(network);
ImplementNetworkVspCommand cmd = new ImplementNetworkVspCommand(vspNetwork, dnsServers);
ImplementNetworkVspCommand cmd = new ImplementNetworkVspCommand(vspNetwork, _nuageVspEntityBuilder.buildNetworkDhcpOption(network, offering));
Answer answer = _agentMgr.easySend(nuageVspHost.getId(), cmd);
if (answer == null || !answer.getResult()) {
@ -242,6 +256,20 @@ public class NuageVspGuestNetworkGuru extends GuestNetworkGuru {
throw new IllegalStateException("The broadcast URI path " + network.getBroadcastUri() + " is empty or in an incorrect format.");
}
HostVO nuageVspHost = getNuageVspHost(network.getPhysicalNetworkId());
VspNetwork vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(network, false);
// Set flags for dhcp options
boolean networkHasDns = networkHasDns(network);
Map<Long, Boolean> networkHasDnsCache = Maps.newHashMap();
networkHasDnsCache.put(network.getId(), networkHasDns);
// Determine if dhcp options of the other nics in the network need to be updated
if (vm.getType() == VirtualMachine.Type.DomainRouter && network.getState() != State.Implementing) {
updateDhcpOptionsForExistingVms(network, nuageVspHost, vspNetwork, networkHasDns, networkHasDnsCache);
}
nic.setBroadcastUri(network.getBroadcastUri());
nic.setIsolationUri(network.getBroadcastUri());
@ -250,7 +278,6 @@ public class NuageVspGuestNetworkGuru extends GuestNetworkGuru {
NicVO nicFromDb = _nicDao.findById(nic.getId());
IPAddressVO staticNatIp = _ipAddressDao.findByVmIdAndNetworkId(network.getId(), vm.getId());
VspNetwork vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(network, false);
VspVm vspVm = _nuageVspEntityBuilder.buildVspVm(vm.getVirtualMachine(), network);
VspNic vspNic = _nuageVspEntityBuilder.buildVspNic(nicFromDb.getUuid(), nic);
VspStaticNat vspStaticNat = null;
@ -259,8 +286,9 @@ public class NuageVspGuestNetworkGuru extends GuestNetworkGuru {
vspStaticNat = _nuageVspEntityBuilder.buildVspStaticNat(null, staticNatIp, staticNatVlan, null);
}
HostVO nuageVspHost = getNuageVspHost(network.getPhysicalNetworkId());
ReserveVmInterfaceVspCommand cmd = new ReserveVmInterfaceVspCommand(vspNetwork, vspVm, vspNic, vspStaticNat);
boolean defaultHasDns = getDefaultHasDns(networkHasDnsCache, nicFromDb);
VspDhcpVMOption dhcpOption = _nuageVspEntityBuilder.buildVmDhcpOption(nicFromDb, defaultHasDns, networkHasDns);
ReserveVmInterfaceVspCommand cmd = new ReserveVmInterfaceVspCommand(vspNetwork, vspVm, vspNic, vspStaticNat, dhcpOption);
Answer answer = _agentMgr.easySend(nuageVspHost.getId(), cmd);
if (answer == null || !answer.getResult()) {
@ -285,6 +313,34 @@ public class NuageVspGuestNetworkGuru extends GuestNetworkGuru {
}
}
private void updateDhcpOptionsForExistingVms(Network network, HostVO nuageVspHost, VspNetwork vspNetwork, boolean networkHasDns, Map<Long, Boolean> networkHasDnsCache)
throws InsufficientVirtualNetworkCapacityException {
// Update dhcp options if a VR is added when we are not initiating the network
if(s_logger.isDebugEnabled()) {
s_logger.debug(String.format("DomainRouter is added to an existing network: %s in state: %s", network.getName(), network.getState()));
}
List<VspDhcpVMOption> dhcpOptions = Lists.newLinkedList();
for (NicVO userNic :_nicDao.listByNetworkId(network.getId())) {
if (userNic.getVmType() != VirtualMachine.Type.DomainRouter) {
boolean defaultHasDns = getDefaultHasDns(networkHasDnsCache, userNic);
dhcpOptions.add(_nuageVspEntityBuilder.buildVmDhcpOption(userNic, defaultHasDns, networkHasDns));
}
}
if (!dhcpOptions.isEmpty()) {
UpdateDhcpOptionVspCommand cmd = new UpdateDhcpOptionVspCommand(dhcpOptions, vspNetwork);
Answer answer = _agentMgr.easySend(nuageVspHost.getId(), cmd);
if (answer == null || !answer.getResult()) {
s_logger.error("UpdateDhcpOptionVspCommand failed at \"reserve\" for network " + vspNetwork.getName());
if ((null != answer) && (null != answer.getDetails())) {
s_logger.error(answer.getDetails());
}
throw new InsufficientVirtualNetworkCapacityException("Failed to reserve VM in Nuage VSP.", Network.class, network.getId());
}
}
}
@Override
protected boolean canHandle(NetworkOffering offering, final NetworkType networkType, final PhysicalNetwork physicalNetwork) {
if (networkType == NetworkType.Advanced && isMyTrafficType(offering.getTrafficType()) && (offering.getGuestType() == Network.GuestType.Isolated || offering.getGuestType() == Network.GuestType.Shared)
@ -403,4 +459,39 @@ public class NuageVspGuestNetworkGuru extends GuestNetworkGuru {
}
return nuageVspHost;
}
private boolean networkHasDns(Network network) {
if (network != null) {
List<String> dnsProviders = _ntwkOfferingSrvcDao.listProvidersForServiceForNetworkOffering(network.getNetworkOfferingId(), Network.Service.Dns);
return dnsProviders.contains(Network.Provider.VirtualRouter.getName())
|| dnsProviders.contains(Network.Provider.VPCVirtualRouter.getName());
}
return false;
}
private boolean getDefaultHasDns(Map<Long, Boolean> cache, Nic nic) {
Long networkId = nic.isDefaultNic()
? Long.valueOf(nic.getNetworkId())
: getDefaultNetwork(nic.getInstanceId());
Boolean hasDns = cache.get(networkId);
if (hasDns == null) {
hasDns = networkHasDns(_networkDao.findById(networkId));
cache.put(networkId, hasDns);
}
return hasDns;
}
private Long getDefaultNetwork(long vmId) {
NicVO defaultNic = _nicDao.findDefaultNicForVM(vmId);
if (defaultNic != null) {
return defaultNic.getNetworkId();
}
return null;
}
}

View File

@ -191,7 +191,7 @@ public class NuageVspManagerImpl extends ManagerBase implements NuageVspManager,
static {
Set<Network.Provider> nuageVspProviders = ImmutableSet.of(Network.Provider.NuageVsp);
Set<Network.Provider> userDataProviders = ImmutableSet.of(Network.Provider.VPCVirtualRouter);
Set<Network.Provider> vrProviders = ImmutableSet.of(Network.Provider.VPCVirtualRouter);
Set<Network.Provider> lbProviders = ImmutableSet.of(Network.Provider.InternalLbVm);
NUAGE_VSP_VPC_SERVICE_MAP = ImmutableMap.<Network.Service, Set<Network.Provider>>builder()
.put(Network.Service.Connectivity, nuageVspProviders)
@ -200,8 +200,9 @@ public class NuageVspManagerImpl extends ManagerBase implements NuageVspManager,
.put(Network.Service.StaticNat, nuageVspProviders)
.put(Network.Service.SourceNat, nuageVspProviders)
.put(Network.Service.NetworkACL, nuageVspProviders)
.put(Network.Service.UserData, userDataProviders)
.put(Network.Service.UserData, vrProviders)
.put(Network.Service.Lb, lbProviders)
.put(Network.Service.Dns, vrProviders)
.build();
}
@ -304,7 +305,7 @@ public class NuageVspManagerImpl extends ManagerBase implements NuageVspManager,
resource.configure(cmd.getHostName(), Maps.<String, Object>newHashMap(resourceConfiguration.build()));
if (matchingNuageVspDevice == null) {
auditDomainsOnVsp((HostVO) host, true, false);
auditDomainsOnVsp((HostVO) host, true);
}
return nuageVspDevice;
@ -486,7 +487,7 @@ public class NuageVspManagerImpl extends ManagerBase implements NuageVspManager,
HostVO host = findNuageVspHost(nuageVspDevice.getHostId());
String nuageVspCmsId = findNuageVspCmsIdForDevice(nuageVspDevice.getId(), cmsIdConfig);
if (matchingNuageVspDevice == null) {
if (!auditDomainsOnVsp(host, false, true)) {
if (!auditDomainsOnVsp(host, false)) {
return false;
}
@ -603,11 +604,11 @@ public class NuageVspManagerImpl extends ManagerBase implements NuageVspManager,
}
if (validateDomains) {
auditDomainsOnVsp(host, true, false);
auditDomainsOnVsp(host, true);
}
}
private boolean auditDomainsOnVsp(HostVO host, boolean add, boolean remove) {
private boolean auditDomainsOnVsp(HostVO host, boolean add) {
List<NuageVspDeviceVO> nuageVspDevices = _nuageVspDao.listByHost(host.getId());
if (CollectionUtils.isEmpty(nuageVspDevices)) {
return true;
@ -617,7 +618,7 @@ public class NuageVspManagerImpl extends ManagerBase implements NuageVspManager,
List<DomainVO> allDomains = _domainDao.listAll();
for (DomainVO domain : allDomains) {
VspDomain vspDomain = _nuageVspEntityBuilder.buildVspDomain(domain);
SyncDomainCommand cmd = new SyncDomainCommand(vspDomain, add, remove);
SyncDomainCommand cmd = new SyncDomainCommand(vspDomain, add ? SyncDomainCommand.Type.ADD : SyncDomainCommand.Type.REMOVE);
SyncDomainAnswer answer = (SyncDomainAnswer) _agentMgr.easySend(host.getId(), cmd);
return answer.getSuccess();
}
@ -714,10 +715,9 @@ public class NuageVspManagerImpl extends ManagerBase implements NuageVspManager,
List<NuageVspDeviceVO> nuageVspDevices = _nuageVspDao.listAll();
for (NuageVspDeviceVO nuageVspDevice : nuageVspDevices) {
HostVO host = findNuageVspHost(nuageVspDevice.getHostId());
VspDomain vspDomain = _nuageVspEntityBuilder.buildVspDomain(domain);
SyncDomainCommand cmd = new SyncDomainCommand(vspDomain, true, false);
_agentMgr.easySend(host.getId(), cmd);
SyncDomainCommand cmd = new SyncDomainCommand(vspDomain, SyncDomainCommand.Type.ADD);
_agentMgr.easySend(nuageVspDevice.getHostId(), cmd);
}
} finally {
_domainDao.releaseFromLockTable(domain.getId());
@ -732,10 +732,9 @@ public class NuageVspManagerImpl extends ManagerBase implements NuageVspManager,
DomainVO domain = (DomainVO) args;
List<NuageVspDeviceVO> nuageVspDevices = _nuageVspDao.listAll();
for (NuageVspDeviceVO nuageVspDevice : nuageVspDevices) {
HostVO host = findNuageVspHost(nuageVspDevice.getHostId());
VspDomain vspDomain = _nuageVspEntityBuilder.buildVspDomain(domain);
SyncDomainCommand cmd = new SyncDomainCommand(vspDomain, false, true);
_agentMgr.easySend(host.getId(), cmd);
SyncDomainCommand cmd = new SyncDomainCommand(vspDomain, SyncDomainCommand.Type.REMOVE);
_agentMgr.easySend(nuageVspDevice.getHostId(), cmd);
}
}
});

View File

@ -19,6 +19,24 @@
package com.cloud.network.resource;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.regex.Pattern;
import javax.naming.ConfigurationException;
import net.nuage.vsp.acs.NuageVspPluginClientLoader;
import net.nuage.vsp.acs.client.api.NuageVspApiClient;
import net.nuage.vsp.acs.client.api.NuageVspElementClient;
import net.nuage.vsp.acs.client.api.NuageVspGuruClient;
import net.nuage.vsp.acs.client.api.NuageVspManagerClient;
import net.nuage.vsp.acs.client.common.model.Pair;
import org.apache.log4j.Logger;
import com.google.common.base.Strings;
import com.cloud.agent.IAgentControl;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.Command;
@ -34,10 +52,12 @@ import com.cloud.agent.api.element.ApplyAclRuleVspCommand;
import com.cloud.agent.api.element.ApplyStaticNatVspCommand;
import com.cloud.agent.api.element.ImplementVspCommand;
import com.cloud.agent.api.element.ShutDownVpcVspCommand;
import com.cloud.agent.api.element.ShutDownVspCommand;
import com.cloud.agent.api.guru.DeallocateVmVspCommand;
import com.cloud.agent.api.guru.ImplementNetworkVspCommand;
import com.cloud.agent.api.guru.ReserveVmInterfaceVspCommand;
import com.cloud.agent.api.guru.TrashNetworkVspCommand;
import com.cloud.agent.api.guru.UpdateDhcpOptionVspCommand;
import com.cloud.agent.api.manager.GetApiDefaultsAnswer;
import com.cloud.agent.api.manager.GetApiDefaultsCommand;
import com.cloud.agent.api.manager.SupportedApiVersionCommand;
@ -51,20 +71,6 @@ import com.cloud.util.NuageVspUtil;
import com.cloud.utils.StringUtils;
import com.cloud.utils.component.ManagerBase;
import com.cloud.utils.exception.CloudRuntimeException;
import com.google.common.base.Strings;
import net.nuage.vsp.acs.NuageVspPluginClientLoader;
import net.nuage.vsp.acs.client.api.NuageVspApiClient;
import net.nuage.vsp.acs.client.api.NuageVspElementClient;
import net.nuage.vsp.acs.client.api.NuageVspGuruClient;
import net.nuage.vsp.acs.client.api.NuageVspManagerClient;
import net.nuage.vsp.acs.client.common.model.Pair;
import org.apache.log4j.Logger;
import javax.naming.ConfigurationException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.regex.Pattern;
import static com.cloud.agent.api.sync.SyncNuageVspCmsIdCommand.SyncType;
@ -291,6 +297,8 @@ public class NuageVspResource extends ManagerBase implements ServerResource {
return executeRequest((DeallocateVmVspCommand)cmd);
} else if (cmd instanceof TrashNetworkVspCommand) {
return executeRequest((TrashNetworkVspCommand)cmd);
} else if (cmd instanceof UpdateDhcpOptionVspCommand) {
return executeRequest((UpdateDhcpOptionVspCommand)cmd);
}
//Element commands
else if (cmd instanceof ImplementVspCommand) {
@ -301,6 +309,8 @@ public class NuageVspResource extends ManagerBase implements ServerResource {
return executeRequest((ApplyStaticNatVspCommand)cmd);
} else if (cmd instanceof ShutDownVpcVspCommand) {
return executeRequest((ShutDownVpcVspCommand)cmd);
} else if (cmd instanceof ShutDownVspCommand) {
return executeRequest((ShutDownVspCommand)cmd);
}
//Sync Commands
else if (cmd instanceof SyncNuageVspCmsIdCommand) {
@ -344,10 +354,10 @@ public class NuageVspResource extends ManagerBase implements ServerResource {
private Answer executeRequest(ImplementNetworkVspCommand cmd) {
try {
isNuageVspGuruLoaded();
_nuageVspGuruClient.implement(cmd.getNetwork(), cmd.getDnsServers());
_nuageVspGuruClient.implement(cmd.getNetwork(), cmd.getDhcpOption());
return new Answer(cmd, true, "Created network mapping to " + cmd.getNetwork().getName() + " on Nuage VSD " + _hostName);
} catch (ExecutionException | ConfigurationException e) {
s_logger.error("Failure during " + cmd + " on Nuage VSD " + _hostName, e);
s_logger.error("Failure during " + cmd.toDetailString() + " on Nuage VSD " + _hostName, e);
return new Answer(cmd, e);
}
}
@ -355,7 +365,7 @@ public class NuageVspResource extends ManagerBase implements ServerResource {
private Answer executeRequest(ReserveVmInterfaceVspCommand cmd) {
try {
isNuageVspGuruLoaded();
_nuageVspGuruClient.reserve(cmd.getNetwork(), cmd.getVm(), cmd.getNic(), cmd.getStaticNat());
_nuageVspGuruClient.reserve(cmd.getNetwork(), cmd.getVm(), cmd.getNic(), cmd.getStaticNat(), cmd.getDhcpOption());
return new Answer(cmd, true, "Created NIC that maps to nicUuid" + cmd.getNic().getUuid() + " on Nuage VSD " + _hostName);
} catch (ExecutionException | ConfigurationException e) {
s_logger.error("Failure during " + cmd + " on Nuage VSD " + _hostName, e);
@ -386,6 +396,17 @@ public class NuageVspResource extends ManagerBase implements ServerResource {
}
}
private Answer executeRequest(UpdateDhcpOptionVspCommand cmd) {
try {
isNuageVspManagerLoaded();
_nuageVspGuruClient.applyDhcpOptions(cmd.getDhcpOptions(), cmd.getNetwork());
return new Answer(cmd, true, "Update DhcpOptions on VM's in network: " + cmd.getNetwork().getName() + " on Nuage VSD " + _hostName);
} catch (ExecutionException | ConfigurationException e) {
s_logger.error("Failure during " + cmd.toDetailString() + " on Nuage VSD " + _hostName, e);
return new Answer(cmd, e);
}
}
private Answer executeRequest(ApplyStaticNatVspCommand cmd) {
try {
isNuageVspElementLoaded();
@ -400,7 +421,7 @@ public class NuageVspResource extends ManagerBase implements ServerResource {
private Answer executeRequest(ImplementVspCommand cmd) {
try {
isNuageVspElementLoaded();
boolean success = _nuageVspElementClient.implement(cmd.getNetwork(), cmd.getDnsServers(), cmd.getIngressFirewallRules(),
boolean success = _nuageVspElementClient.implement(cmd.getNetwork(), cmd.getDhcpOption(), cmd.getIngressFirewallRules(),
cmd.getEgressFirewallRules(), cmd.getFloatingIpUuids());
return new Answer(cmd, success, "Implemented network " + cmd.getNetwork().getUuid() + " on Nuage VSD " + _hostName);
} catch (ExecutionException | ConfigurationException e) {
@ -431,6 +452,17 @@ public class NuageVspResource extends ManagerBase implements ServerResource {
}
}
private Answer executeRequest(ShutDownVspCommand cmd) {
try {
isNuageVspElementLoaded();
_nuageVspElementClient.shutdownNetwork(cmd.getNetwork(), cmd.getDhcpOptions());
return new Answer(cmd, true, "Shutdown VPC " + cmd.getNetwork().getUuid()+ " on Nuage VSD " + _hostName);
} catch (ConfigurationException e) {
s_logger.error("Failure during " + cmd.toDetailString() + " on Nuage VSD " + _hostName, e);
return new Answer(cmd, e);
}
}
private Answer executeRequest(SyncNuageVspCmsIdCommand cmd) {
try {
isNuageVspManagerLoaded();

View File

@ -30,10 +30,12 @@ import com.cloud.network.NetworkModel;
import com.cloud.network.dao.IPAddressDao;
import com.cloud.network.dao.IPAddressVO;
import com.cloud.network.dao.NetworkDetailsDao;
import com.cloud.network.manager.NuageVspManager;
import com.cloud.network.rules.FirewallRule;
import com.cloud.network.vpc.NetworkACLItem;
import com.cloud.network.vpc.VpcVO;
import com.cloud.network.vpc.dao.VpcDao;
import com.cloud.offering.NetworkOffering;
import com.cloud.offerings.NetworkOfferingVO;
import com.cloud.offerings.dao.NetworkOfferingDao;
import com.cloud.offerings.dao.NetworkOfferingServiceMapDao;
@ -43,10 +45,14 @@ import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.net.NetUtils;
import com.cloud.vm.NicProfile;
import com.cloud.vm.NicVO;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.dao.VMInstanceDao;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import net.nuage.vsp.acs.client.api.model.VspAclRule;
import net.nuage.vsp.acs.client.api.model.VspDhcpDomainOption;
import net.nuage.vsp.acs.client.api.model.VspDhcpVMOption;
import net.nuage.vsp.acs.client.api.model.VspDomain;
import net.nuage.vsp.acs.client.api.model.VspNetwork;
import net.nuage.vsp.acs.client.api.model.VspNic;
@ -87,6 +93,13 @@ public class NuageVspEntityBuilder {
IPAddressDao _ipAddressDao;
@Inject
NetworkDetailsDao _networkDetailsDao;
@Inject
VMInstanceDao _vmInstanceDao;
@Inject
NuageVspManager _nuageVspManager;
@Inject
NetworkOfferingServiceMapDao _ntwkOfferingSrvcDao;
public VspDomain buildVspDomain(Domain domain) {
return new VspDomain.Builder()
@ -367,4 +380,32 @@ public class NuageVspEntityBuilder {
return vspAclRuleBuilder.build();
}
/** Build VspDhcpVMOption to put on the VM interface */
public VspDhcpVMOption buildVmDhcpOption (NicVO userNic, boolean defaultHasDns, boolean networkHasDns) {
VMInstanceVO userVm = _vmInstanceDao.findById(userNic.getInstanceId());
VspDhcpVMOption.Builder vspDhcpVMOptionBuilder = new VspDhcpVMOption.Builder()
.nicUuid(userNic.getUuid())
.defaultHasDns(defaultHasDns)
.hostname(userVm.getHostName())
.networkHasDns(networkHasDns)
.isDefaultInterface(userNic.isDefaultNic())
.domainRouter(VirtualMachine.Type.DomainRouter.equals(userNic.getVmType()));
return vspDhcpVMOptionBuilder.build();
}
/** Build VspDhcpVMOption to put on the subnet */
public VspDhcpDomainOption buildNetworkDhcpOption(Network network, NetworkOffering offering) {
List<String> dnsProvider = _ntwkOfferingSrvcDao.listProvidersForServiceForNetworkOffering(offering.getId(), Network.Service.Dns);
boolean isVrDnsProvider = dnsProvider.contains("VirtualRouter") || dnsProvider.contains("VpcVirtualRouter");
VspDhcpDomainOption.Builder vspDhcpDomainBuilder = new VspDhcpDomainOption.Builder()
.dnsServers(_nuageVspManager.getDnsDetails(network))
.vrIsDnsProvider(isVrDnsProvider);
if (isVrDnsProvider) {
vspDhcpDomainBuilder.networkDomain(network.getVpcId() != null ? _vpcDao.findById(network.getVpcId()).getNetworkDomain() : network.getNetworkDomain());
}
return vspDhcpDomainBuilder.build();
}
}

View File

@ -19,6 +19,26 @@
package com.cloud;
import java.util.ArrayList;
import net.nuage.vsp.acs.client.api.model.VspAclRule;
import net.nuage.vsp.acs.client.api.model.VspDhcpDomainOption;
import net.nuage.vsp.acs.client.api.model.VspDhcpVMOption;
import net.nuage.vsp.acs.client.api.model.VspDomain;
import net.nuage.vsp.acs.client.api.model.VspNetwork;
import net.nuage.vsp.acs.client.api.model.VspNic;
import net.nuage.vsp.acs.client.api.model.VspStaticNat;
import net.nuage.vsp.acs.client.api.model.VspVm;
import net.nuage.vsp.acs.client.common.model.Pair;
import org.junit.Before;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import com.google.common.collect.Lists;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import com.cloud.dc.VlanVO;
import com.cloud.domain.Domain;
import com.cloud.network.Network;
@ -30,17 +50,6 @@ import com.cloud.util.NuageVspEntityBuilder;
import com.cloud.vm.NicProfile;
import com.cloud.vm.NicVO;
import com.cloud.vm.VirtualMachine;
import net.nuage.vsp.acs.client.api.model.VspAclRule;
import net.nuage.vsp.acs.client.api.model.VspDomain;
import net.nuage.vsp.acs.client.api.model.VspNetwork;
import net.nuage.vsp.acs.client.api.model.VspNic;
import net.nuage.vsp.acs.client.api.model.VspStaticNat;
import net.nuage.vsp.acs.client.api.model.VspVm;
import net.nuage.vsp.acs.client.common.model.Pair;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.junit.Before;
import java.util.ArrayList;
import static com.cloud.network.manager.NuageVspManager.NuageVspIsolatedNetworkDomainTemplateName;
import static com.cloud.network.manager.NuageVspManager.NuageVspSharedNetworkDomainTemplateName;
@ -48,18 +57,20 @@ import static com.cloud.network.manager.NuageVspManager.NuageVspVpcDomainTemplat
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class NuageTest {
protected static final long NETWORK_ID = 42L;
protected NetworkModel _networkModel = mock(NetworkModel.class);
protected ConfigurationDao _configurationDao = mock(ConfigurationDao.class);
protected NuageVspEntityBuilder _nuageVspEntityBuilder = mock(NuageVspEntityBuilder.class);
@Mock protected NetworkModel _networkModel;
@Mock protected ConfigurationDao _configurationDao;
@Mock protected NuageVspEntityBuilder _nuageVspEntityBuilder;
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
// Standard responses
when(_networkModel.isProviderForNetwork(Network.Provider.NuageVsp, NETWORK_ID)).thenReturn(true);
when(_configurationDao.getValue(NuageVspIsolatedNetworkDomainTemplateName.key())).thenReturn("IsolatedDomainTemplate");
@ -154,4 +165,23 @@ public class NuageTest {
.build();
}
protected VspDhcpDomainOption buildspDhcpDomainOption () {
return new VspDhcpDomainOption.Builder()
.vrIsDnsProvider(true)
.networkDomain("networkDomain")
.dnsServers(Lists.newArrayList("10.10.10.10", "20.20.20.20"))
.build();
}
protected VspDhcpVMOption buildspDhcpVMOption () {
return new VspDhcpVMOption.Builder()
.defaultHasDns(true)
.hostname("VMx")
.networkHasDns(true)
.isDefaultInterface(true)
.domainRouter(false)
.nicUuid("aaaa-bbbbbbbb-ccccccc")
.build();
}
}

View File

@ -19,6 +19,23 @@
package com.cloud.network.element;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import com.google.common.collect.Lists;
import org.apache.cloudstack.resourcedetail.dao.VpcDetailsDao;
import com.cloud.NuageTest;
import com.cloud.agent.AgentManager;
import com.cloud.agent.api.Answer;
@ -63,18 +80,6 @@ import com.cloud.util.NuageVspEntityBuilder;
import com.cloud.vm.DomainRouterVO;
import com.cloud.vm.ReservationContext;
import com.cloud.vm.dao.DomainRouterDao;
import com.google.common.collect.Lists;
import org.apache.cloudstack.resourcedetail.dao.VpcDetailsDao;
import org.junit.Before;
import org.junit.Test;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@ -85,45 +90,29 @@ import static org.mockito.Mockito.when;
public class NuageVspElementTest extends NuageTest {
@InjectMocks
private NuageVspElement _nuageVspElement = new NuageVspElement();
private NetworkServiceMapDao _networkServiceMapDao = mock(NetworkServiceMapDao.class);
private AgentManager _agentManager = mock(AgentManager.class);
private HostDao _hostDao = mock(HostDao.class);
private NuageVspDao _nuageVspDao = mock(NuageVspDao.class);
private DomainDao _domainDao = mock(DomainDao.class);
private NetworkOfferingDao _networkOfferingDao = mock(NetworkOfferingDao.class);
private NetworkOfferingServiceMapDao _networkOfferingServiceMapDao = mock(NetworkOfferingServiceMapDao.class);
private NuageVspManager _nuageVspManager = mock(NuageVspManager.class);
private FirewallRulesDao _firewallRulesDao = mock(FirewallRulesDao.class);
private IPAddressDao _ipAddressDao = mock(IPAddressDao.class);
private PhysicalNetworkDao _physicalNetworkDao = mock(PhysicalNetworkDao.class);
private NuageVspEntityBuilder _nuageVspEntityBuilder = mock(NuageVspEntityBuilder.class);
private VpcDetailsDao _vpcDetailsDao = mock(VpcDetailsDao.class);
private DomainRouterDao _domainRouterDao = mock(DomainRouterDao.class);
@Mock private NetworkServiceMapDao _networkServiceMapDao;
@Mock private AgentManager _agentManager;
@Mock private HostDao _hostDao;
@Mock private NuageVspDao _nuageVspDao;
@Mock private DomainDao _domainDao;
@Mock private NetworkOfferingDao _networkOfferingDao;
@Mock private NetworkOfferingServiceMapDao _networkOfferingServiceMapDao;
@Mock private NuageVspManager _nuageVspManager;
@Mock private FirewallRulesDao _firewallRulesDao;
@Mock private IPAddressDao _ipAddressDao;
@Mock private PhysicalNetworkDao _physicalNetworkDao;
@Mock private NuageVspEntityBuilder _nuageVspEntityBuilder;
@Mock private VpcDetailsDao _vpcDetailsDao;
@Mock private DomainRouterDao _domainRouterDao;
@Mock private ResourceManager _resourceManager;
@Before
public void setUp() throws Exception {
super.setUp();
_nuageVspElement._resourceMgr = mock(ResourceManager.class);
_nuageVspElement._ntwkSrvcDao = _networkServiceMapDao;
_nuageVspElement._networkModel = _networkModel;
_nuageVspElement._agentMgr = _agentManager;
_nuageVspElement._hostDao = _hostDao;
_nuageVspElement._nuageVspDao = _nuageVspDao;
_nuageVspElement._ntwkOfferingSrvcDao = _networkOfferingServiceMapDao;
_nuageVspElement._domainDao = _domainDao;
_nuageVspElement._ntwkOfferingDao = _networkOfferingDao;
_nuageVspElement._configDao = _configurationDao;
_nuageVspElement._nuageVspManager = _nuageVspManager;
_nuageVspElement._firewallRulesDao = _firewallRulesDao;
_nuageVspElement._ipAddressDao = _ipAddressDao;
_nuageVspElement._physicalNetworkDao = _physicalNetworkDao;
_nuageVspElement._nuageVspEntityBuilder = _nuageVspEntityBuilder;
_nuageVspElement._vpcDetailsDao = _vpcDetailsDao;
_nuageVspElement._routerDao = _domainRouterDao;
_nuageVspElement.configure("NuageVspTestElement", Collections.<String, Object>emptyMap());
}

View File

@ -19,6 +19,19 @@
package com.cloud.network.guru;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import com.cloud.NuageTest;
import com.cloud.agent.AgentManager;
import com.cloud.agent.api.Answer;
@ -66,21 +79,15 @@ import com.cloud.vm.ReservationContext;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachineProfile;
import com.cloud.vm.dao.NicDao;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.junit.Before;
import org.junit.Test;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import static com.cloud.network.manager.NuageVspManager.NuageVspIsolatedNetworkDomainTemplateName;
import static com.cloud.network.manager.NuageVspManager.NuageVspSharedNetworkDomainTemplateName;
import static com.cloud.network.manager.NuageVspManager.NuageVspVpcDomainTemplateName;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
@ -89,49 +96,35 @@ import static org.mockito.Mockito.when;
public class NuageVspGuestNetworkGuruTest extends NuageTest {
private static final long NETWORK_ID = 42L;
private PhysicalNetworkDao _physicalNetworkDao = mock(PhysicalNetworkDao.class);
private DataCenterDao _dataCenterDao = mock(DataCenterDao.class);
private NetworkOfferingServiceMapDao _networkOfferingServiceMapDao = mock(NetworkOfferingServiceMapDao.class);
private AgentManager _agentManager = mock(AgentManager.class);
private NetworkModel _networkModel = mock(NetworkModel.class);
private AccountDao _accountDao = mock(AccountDao.class);
private DomainDao _domainDao = mock(DomainDao.class);
private NicDao _nicDao = mock(NicDao.class);
private NetworkOfferingDao _networkOfferingDao = mock(NetworkOfferingDao.class);
private NuageVspDao _nuageVspDao = mock(NuageVspDao.class);
private HostDao _hostDao = mock(HostDao.class);
private NetworkDao _networkDao = mock(NetworkDao.class);
private ConfigurationDao _configurationDao = mock(ConfigurationDao.class);
private IPAddressDao _ipAddressDao = mock(IPAddressDao.class);
private NuageVspManager _nuageVspManager = mock(NuageVspManager.class);
private ConfigurationManager _configurationManager = mock(ConfigurationManager.class);
private NetworkDetailsDao _networkDetailsDao = mock(NetworkDetailsDao.class);
@Mock private PhysicalNetworkDao _physicalNetworkDao;
@Mock private DataCenterDao _dataCenterDao;
@Mock private NetworkOfferingServiceMapDao _networkOfferingServiceMapDao;
@Mock private AgentManager _agentManager;
@Mock private NetworkModel _networkModel;
@Mock private AccountDao _accountDao;
@Mock private DomainDao _domainDao;
@Mock private NicDao _nicDao;
@Mock private NetworkOfferingDao _networkOfferingDao;
@Mock private NuageVspDao _nuageVspDao;
@Mock private HostDao _hostDao;
@Mock private NetworkDao _networkDao;
@Mock private ConfigurationDao _configurationDao;
@Mock private IPAddressDao _ipAddressDao;
@Mock private NuageVspManager _nuageVspManager;
@Mock private ConfigurationManager _configurationManager;
@Mock private NetworkDetailsDao _networkDetailsDao;
@Mock private PhysicalNetworkVO physnet;
@InjectMocks
private NuageVspGuestNetworkGuru _nuageVspGuestNetworkGuru;
@Before
public void setUp() throws Exception {
_nuageVspGuestNetworkGuru = new NuageVspGuestNetworkGuru();
super.setUp();
_nuageVspGuestNetworkGuru = new NuageVspGuestNetworkGuru();
_nuageVspGuestNetworkGuru._physicalNetworkDao = _physicalNetworkDao;
_nuageVspGuestNetworkGuru._physicalNetworkDao = _physicalNetworkDao;
_nuageVspGuestNetworkGuru._nuageVspDao = _nuageVspDao;
_nuageVspGuestNetworkGuru._dcDao = _dataCenterDao;
_nuageVspGuestNetworkGuru._ntwkOfferingSrvcDao = _networkOfferingServiceMapDao;
_nuageVspGuestNetworkGuru._networkModel = _networkModel;
_nuageVspGuestNetworkGuru._hostDao = _hostDao;
_nuageVspGuestNetworkGuru._agentMgr = _agentManager;
_nuageVspGuestNetworkGuru._networkDao = _networkDao;
_nuageVspGuestNetworkGuru._accountDao = _accountDao;
_nuageVspGuestNetworkGuru._domainDao = _domainDao;
_nuageVspGuestNetworkGuru._nicDao = _nicDao;
_nuageVspGuestNetworkGuru._ntwkOfferingDao = _networkOfferingDao;
_nuageVspGuestNetworkGuru._configDao = _configurationDao;
_nuageVspGuestNetworkGuru._ipAddressDao = _ipAddressDao;
_nuageVspGuestNetworkGuru._nuageVspManager = _nuageVspManager;
_nuageVspGuestNetworkGuru._configMgr = _configurationManager;
_nuageVspGuestNetworkGuru._nuageVspEntityBuilder = _nuageVspEntityBuilder;
_nuageVspGuestNetworkGuru._networkDetailsDao = _networkDetailsDao;
final DataCenterVO dc = mock(DataCenterVO.class);
when(dc.getNetworkType()).thenReturn(NetworkType.Advanced);
@ -142,41 +135,51 @@ public class NuageVspGuestNetworkGuruTest extends NuageTest {
when(_configurationDao.getValue(NuageVspIsolatedNetworkDomainTemplateName.key())).thenReturn("IsolatedDomainTemplate");
when(_configurationDao.getValue(NuageVspVpcDomainTemplateName.key())).thenReturn("VpcDomainTemplate");
when(_configurationDao.getValue(NuageVspSharedNetworkDomainTemplateName.key())).thenReturn("SharedDomainTemplate");
when(_physicalNetworkDao.findById(any(Long.class))).thenReturn(physnet);
when(physnet.getIsolationMethods()).thenReturn(Arrays.asList("VSP"));
when(physnet.getId()).thenReturn(NETWORK_ID);
final HostVO host = mock(HostVO.class);
when(_hostDao.findById(NETWORK_ID)).thenReturn(host);
when(host.getId()).thenReturn(NETWORK_ID);
when(_agentManager.easySend(eq(NETWORK_ID), any(Command.class))).thenReturn(new Answer(null));
final NuageVspDeviceVO device = mock(NuageVspDeviceVO.class);
when(_nuageVspDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(device));
when(device.getId()).thenReturn(1L);
when(device.getHostId()).thenReturn(NETWORK_ID);
}
@Test
public void testCanHandle() {
final NetworkOffering offering = mock(NetworkOffering.class);
when(offering.getId()).thenReturn(NETWORK_ID);
when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
when(offering.getGuestType()).thenReturn(GuestType.Isolated);
when(offering.getIsPersistent()).thenReturn(false);
when(_configurationManager.isOfferingForVpc(any(NetworkOffering.class))).thenReturn(false);
final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] {"VSP"}));
when(physnet.getId()).thenReturn(NETWORK_ID);
when(_networkOfferingServiceMapDao.areServicesSupportedByNetworkOffering(NETWORK_ID, Service.Connectivity)).thenReturn(true);
assertTrue(_nuageVspGuestNetworkGuru.canHandle(offering, NetworkType.Advanced, physnet) == true);
when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
when(offering.getGuestType()).thenReturn(GuestType.Isolated);
assertThat(_nuageVspGuestNetworkGuru.canHandle(offering, NetworkType.Advanced, physnet), is(true));
// Not supported TrafficType != Guest
when(offering.getTrafficType()).thenReturn(TrafficType.Management);
assertFalse(_nuageVspGuestNetworkGuru.canHandle(offering, NetworkType.Advanced, physnet) == true);
assertThat(_nuageVspGuestNetworkGuru.canHandle(offering, NetworkType.Advanced, physnet), is(false));
// Supported: GuestType Shared
when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
when(offering.getGuestType()).thenReturn(GuestType.Shared);
assertTrue(_nuageVspGuestNetworkGuru.canHandle(offering, NetworkType.Advanced, physnet) == true);
assertThat(_nuageVspGuestNetworkGuru.canHandle(offering, NetworkType.Advanced, physnet), is(true));
// Not supported: Basic networking
when(offering.getGuestType()).thenReturn(GuestType.Isolated);
assertFalse(_nuageVspGuestNetworkGuru.canHandle(offering, NetworkType.Basic, physnet) == true);
assertThat(_nuageVspGuestNetworkGuru.canHandle(offering, NetworkType.Basic, physnet), is(false));
// Not supported: IsolationMethod != STT
when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] {"VLAN"}));
assertFalse(_nuageVspGuestNetworkGuru.canHandle(offering, NetworkType.Advanced, physnet) == true);
when(physnet.getIsolationMethods()).thenReturn(Arrays.asList("VLAN"));
assertThat(_nuageVspGuestNetworkGuru.canHandle(offering, NetworkType.Basic, physnet), is(false));
// Not supported: Non-persistent VPC tier
when(_configurationManager.isOfferingForVpc(any(NetworkOffering.class))).thenReturn(true);
@ -185,13 +188,8 @@ public class NuageVspGuestNetworkGuruTest extends NuageTest {
@Test
public void testDesign() {
final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
when(_physicalNetworkDao.findById((Long)any())).thenReturn(physnet);
when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] {"VSP"}));
when(physnet.getId()).thenReturn(NETWORK_ID);
final NuageVspDeviceVO device = mock(NuageVspDeviceVO.class);
when(_nuageVspDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NuageVspDeviceVO[]{device}));
when(_nuageVspDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(device));
when(device.getId()).thenReturn(1L);
final NetworkOffering offering = mock(NetworkOffering.class);
@ -208,22 +206,17 @@ public class NuageVspGuestNetworkGuruTest extends NuageTest {
final Account account = mock(Account.class);
final Network designednetwork = _nuageVspGuestNetworkGuru.design(offering, plan, network, account);
assertTrue(designednetwork != null);
assertTrue(designednetwork.getBroadcastDomainType() == BroadcastDomainType.Vsp);
assertThat(designednetwork, notNullValue(Network.class));
assertThat(designednetwork.getBroadcastDomainType(), is(BroadcastDomainType.Vsp));
// Can't design non-persistent VPC tier
when(_configurationManager.isOfferingForVpc(any(NetworkOffering.class))).thenReturn(true);
assertNull(_nuageVspGuestNetworkGuru.design(offering, plan, network, account));
assertThat(_nuageVspGuestNetworkGuru.design(offering, plan, network, account), nullValue(Network.class));
}
@Test
public void testDesignNoElementOnPhysicalNetwork() {
final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
when(_physicalNetworkDao.findById((Long)any())).thenReturn(physnet);
when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] {"STT"}));
when(physnet.getId()).thenReturn(NETWORK_ID);
mock(NuageVspDeviceVO.class);
when(physnet.getIsolationMethods()).thenReturn(Arrays.asList("STT"));
when(_nuageVspDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Collections.<NuageVspDeviceVO>emptyList());
final NetworkOffering offering = mock(NetworkOffering.class);
@ -241,12 +234,7 @@ public class NuageVspGuestNetworkGuruTest extends NuageTest {
@Test
public void testDesignNoIsolationMethodVSP() {
final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
when(_physicalNetworkDao.findById((Long)any())).thenReturn(physnet);
when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] {"VLAN"}));
when(physnet.getId()).thenReturn(NETWORK_ID);
mock(NuageVspDeviceVO.class);
when(physnet.getIsolationMethods()).thenReturn(Arrays.asList("VLAN"));
when(_nuageVspDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Collections.<NuageVspDeviceVO>emptyList());
final NetworkOffering offering = mock(NetworkOffering.class);
@ -289,7 +277,10 @@ public class NuageVspGuestNetworkGuruTest extends NuageTest {
when(nicvo.getId()).thenReturn(NETWORK_ID);
when(nicvo.getMacAddress()).thenReturn("aa-aa-aa-aa-aa-aa");
when(nicvo.getUuid()).thenReturn("aaaa-fffff");
when(nicvo.getNetworkId()).thenReturn(NETWORK_ID);
when(nicvo.getInstanceId()).thenReturn(NETWORK_ID);
when(_nicDao.findById(NETWORK_ID)).thenReturn(nicvo);
when(_nicDao.findDefaultNicForVM(NETWORK_ID)).thenReturn(nicvo);
final VirtualMachine vm = mock(VirtualMachine.class);
when(vm.getId()).thenReturn(NETWORK_ID);
@ -310,21 +301,10 @@ public class NuageVspGuestNetworkGuruTest extends NuageTest {
when(ntwkoffering.getId()).thenReturn(NETWORK_ID);
when(_networkOfferingDao.findById(NETWORK_ID)).thenReturn(ntwkoffering);
final HostVO host = mock(HostVO.class);
when(host.getId()).thenReturn(NETWORK_ID);
final NuageVspDeviceVO nuageVspDevice = mock(NuageVspDeviceVO.class);
when(nuageVspDevice.getHostId()).thenReturn(NETWORK_ID);
when(_nuageVspDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NuageVspDeviceVO[]{nuageVspDevice}));
when(_hostDao.findById(NETWORK_ID)).thenReturn(host);
when(_networkDao.acquireInLockTable(NETWORK_ID, 1200)).thenReturn(network);
when(_ipAddressDao.findByVmIdAndNetworkId(NETWORK_ID, NETWORK_ID)).thenReturn(null);
when(_domainDao.findById(NETWORK_ID)).thenReturn(mock(DomainVO.class));
final Answer answer = mock(Answer.class);
when(answer.getResult()).thenReturn(true);
when(_agentManager.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer);
_nuageVspGuestNetworkGuru.reserve(nicProfile, network, vmProfile, mock(DeployDestination.class), mock(ReservationContext.class));
}
@ -368,20 +348,10 @@ public class NuageVspGuestNetworkGuruTest extends NuageTest {
final AccountVO accountVo = mock(AccountVO.class);
when(_accountDao.findById(NETWORK_ID)).thenReturn(accountVo);
final HostVO host = mock(HostVO.class);
when(host.getId()).thenReturn(NETWORK_ID);
final NuageVspDeviceVO nuageVspDevice = mock(NuageVspDeviceVO.class);
when(nuageVspDevice.getHostId()).thenReturn(NETWORK_ID);
when(_nuageVspDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NuageVspDeviceVO[]{nuageVspDevice}));
when(_hostDao.findById(NETWORK_ID)).thenReturn(host);
when(_networkDao.acquireInLockTable(NETWORK_ID, 1200)).thenReturn(network);
when(_nuageVspManager.getDnsDetails(network)).thenReturn(new ArrayList<String>());
when(_nuageVspManager.getGatewaySystemIds()).thenReturn(new ArrayList<String>());
final Answer answer = mock(Answer.class);
when(answer.getResult()).thenReturn(true);
when(_agentManager.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer);
final DataCenter dc = mock(DataCenter.class);
when(dc.getId()).thenReturn(NETWORK_ID);
final DeployDestination deployDest = mock(DeployDestination.class);
@ -429,17 +399,6 @@ public class NuageVspGuestNetworkGuruTest extends NuageTest {
when(vmProfile.getInstanceName()).thenReturn("Test-VM");
when(vmProfile.getVirtualMachine()).thenReturn(vm);
final HostVO host = mock(HostVO.class);
when(host.getId()).thenReturn(NETWORK_ID);
final NuageVspDeviceVO nuageVspDevice = mock(NuageVspDeviceVO.class);
when(nuageVspDevice.getHostId()).thenReturn(NETWORK_ID);
when(_nuageVspDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NuageVspDeviceVO[]{nuageVspDevice}));
when(_hostDao.findById(NETWORK_ID)).thenReturn(host);
final Answer answer = mock(Answer.class);
when(answer.getResult()).thenReturn(true);
when(_agentManager.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer);
_nuageVspGuestNetworkGuru.deallocate(network, nicProfile, vmProfile);
}
@ -464,19 +423,9 @@ public class NuageVspGuestNetworkGuruTest extends NuageTest {
when(domain.getUuid()).thenReturn("aaaaaa");
when(_domainDao.findById(NETWORK_ID)).thenReturn(domain);
final HostVO host = mock(HostVO.class);
when(host.getId()).thenReturn(NETWORK_ID);
final NuageVspDeviceVO nuageVspDevice = mock(NuageVspDeviceVO.class);
when(nuageVspDevice.getHostId()).thenReturn(NETWORK_ID);
when(_nuageVspDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NuageVspDeviceVO[]{nuageVspDevice}));
when(_hostDao.findById(NETWORK_ID)).thenReturn(host);
when(_nuageVspManager.getDnsDetails(network)).thenReturn(new ArrayList<String>());
when(_nuageVspManager.getGatewaySystemIds()).thenReturn(new ArrayList<String>());
final Answer answer = mock(Answer.class);
when(answer.getResult()).thenReturn(true);
when(_agentManager.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer);
assertTrue(_nuageVspGuestNetworkGuru.trash(network, offering));
}

View File

@ -19,6 +19,30 @@
package com.cloud.network.resource;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import javax.naming.ConfigurationException;
import net.nuage.vsp.acs.client.api.NuageVspApiClient;
import net.nuage.vsp.acs.client.api.NuageVspElementClient;
import net.nuage.vsp.acs.client.api.NuageVspGuruClient;
import net.nuage.vsp.acs.client.api.model.VspAclRule;
import net.nuage.vsp.acs.client.api.model.VspDhcpDomainOption;
import net.nuage.vsp.acs.client.api.model.VspDhcpVMOption;
import net.nuage.vsp.acs.client.api.model.VspNetwork;
import net.nuage.vsp.acs.client.api.model.VspNic;
import net.nuage.vsp.acs.client.api.model.VspStaticNat;
import net.nuage.vsp.acs.client.api.model.VspVm;
import org.junit.Before;
import org.junit.Test;
import org.mockito.invocation.InvocationOnMock;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.cloud.NuageTest;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.PingCommand;
@ -31,25 +55,6 @@ import com.cloud.agent.api.guru.ImplementNetworkVspCommand;
import com.cloud.agent.api.guru.ReserveVmInterfaceVspCommand;
import com.cloud.agent.api.guru.TrashNetworkVspCommand;
import com.cloud.host.Host;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import net.nuage.vsp.acs.client.api.NuageVspApiClient;
import net.nuage.vsp.acs.client.api.NuageVspElementClient;
import net.nuage.vsp.acs.client.api.NuageVspGuruClient;
import net.nuage.vsp.acs.client.api.model.VspAclRule;
import net.nuage.vsp.acs.client.api.model.VspNetwork;
import net.nuage.vsp.acs.client.api.model.VspNic;
import net.nuage.vsp.acs.client.api.model.VspStaticNat;
import net.nuage.vsp.acs.client.api.model.VspVm;
import org.junit.Before;
import org.junit.Test;
import org.mockito.invocation.InvocationOnMock;
import javax.naming.ConfigurationException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.doAnswer;
@ -151,8 +156,9 @@ public class NuageVspResourceTest extends NuageTest {
_resource.configure("NuageVspResource", _hostDetails);
VspNetwork vspNetwork = buildVspNetwork();
ImplementNetworkVspCommand cmd = new ImplementNetworkVspCommand(vspNetwork, new ArrayList<String>());
doAnswer(genericAnswer).when(_mockNuageVspGuruClient).implement(vspNetwork, new ArrayList<String>());
VspDhcpDomainOption vspDhcpOptions = buildspDhcpDomainOption();
ImplementNetworkVspCommand cmd = new ImplementNetworkVspCommand(vspNetwork, vspDhcpOptions);
doAnswer(genericAnswer).when(_mockNuageVspGuruClient).implement(vspNetwork, vspDhcpOptions);
com.cloud.agent.api.Answer implNtwkAns = _resource.executeRequest(cmd);
assertTrue(implNtwkAns.getResult());
}
@ -165,8 +171,9 @@ public class NuageVspResourceTest extends NuageTest {
VspVm vspVm = buildVspVm();
VspNic vspNic = buildVspNic();
VspStaticNat vspStaticNat = buildVspStaticNat();
ReserveVmInterfaceVspCommand cmd = new ReserveVmInterfaceVspCommand(vspNetwork, vspVm, vspNic, vspStaticNat);
doAnswer(genericAnswer).when(_mockNuageVspGuruClient).reserve(vspNetwork, vspVm, vspNic, vspStaticNat);
VspDhcpVMOption vspDhcpOption = buildspDhcpVMOption();
ReserveVmInterfaceVspCommand cmd = new ReserveVmInterfaceVspCommand(vspNetwork, vspVm, vspNic, vspStaticNat, vspDhcpOption);
doAnswer(genericAnswer).when(_mockNuageVspGuruClient).reserve(vspNetwork, vspVm, vspNic, vspStaticNat, vspDhcpOption);
Answer rsrvVmInfAns = _resource.executeRequest(cmd);
assertTrue(rsrvVmInfAns.getResult());
}

View File

@ -24,9 +24,22 @@ import java.util.Set;
import javax.inject.Inject;
import com.cloud.network.dao.NetworkDetailVO;
import com.cloud.network.dao.NetworkDetailsDao;
import com.cloud.utils.exception.CloudRuntimeException;
import org.apache.commons.collections.CollectionUtils;
import org.apache.log4j.Logger;
import org.cloud.network.router.deployment.RouterDeploymentDefinition;
import org.cloud.network.router.deployment.RouterDeploymentDefinitionBuilder;
import com.google.gson.Gson;
import org.apache.cloudstack.api.command.admin.router.ConfigureOvsElementCmd;
import org.apache.cloudstack.api.command.admin.router.ConfigureVirtualRouterElementCmd;
import org.apache.cloudstack.api.command.admin.router.CreateVirtualRouterElementCmd;
import org.apache.cloudstack.api.command.admin.router.ListOvsElementsCmd;
import org.apache.cloudstack.api.command.admin.router.ListVirtualRouterElementsCmd;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.network.topology.NetworkTopology;
import org.apache.cloudstack.network.topology.NetworkTopologyContext;
import com.cloud.agent.api.to.LoadBalancerTO;
import com.cloud.configuration.ConfigurationManager;
import com.cloud.dc.DataCenter;
@ -60,6 +73,8 @@ import com.cloud.network.as.AutoScaleCounter.AutoScaleCounterType;
import com.cloud.network.dao.IPAddressDao;
import com.cloud.network.dao.LoadBalancerDao;
import com.cloud.network.dao.NetworkDao;
import com.cloud.network.dao.NetworkDetailVO;
import com.cloud.network.dao.NetworkDetailsDao;
import com.cloud.network.dao.OvsProviderDao;
import com.cloud.network.dao.VirtualRouterProviderDao;
import com.cloud.network.lb.LoadBalancingRule;
@ -85,6 +100,7 @@ import com.cloud.utils.component.AdapterBase;
import com.cloud.utils.crypt.DBEncryptionUtil;
import com.cloud.utils.db.QueryBuilder;
import com.cloud.utils.db.SearchCriteria.Op;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.net.NetUtils;
import com.cloud.vm.DomainRouterVO;
import com.cloud.vm.NicProfile;
@ -96,23 +112,10 @@ import com.cloud.vm.VirtualMachine.State;
import com.cloud.vm.VirtualMachineProfile;
import com.cloud.vm.dao.DomainRouterDao;
import com.cloud.vm.dao.UserVmDao;
import com.google.gson.Gson;
import org.apache.cloudstack.api.command.admin.router.ConfigureOvsElementCmd;
import org.apache.cloudstack.api.command.admin.router.ConfigureVirtualRouterElementCmd;
import org.apache.cloudstack.api.command.admin.router.CreateVirtualRouterElementCmd;
import org.apache.cloudstack.api.command.admin.router.ListOvsElementsCmd;
import org.apache.cloudstack.api.command.admin.router.ListVirtualRouterElementsCmd;
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
import org.apache.cloudstack.network.topology.NetworkTopology;
import org.apache.cloudstack.network.topology.NetworkTopologyContext;
import org.apache.log4j.Logger;
import org.cloud.network.router.deployment.RouterDeploymentDefinition;
import org.cloud.network.router.deployment.RouterDeploymentDefinitionBuilder;
public class VirtualRouterElement extends AdapterBase implements VirtualRouterElementService, DhcpServiceProvider, UserDataServiceProvider, SourceNatServiceProvider,
StaticNatServiceProvider, FirewallServiceProvider, LoadBalancingServiceProvider, PortForwardingServiceProvider, RemoteAccessVPNServiceProvider, IpDeployer,
NetworkMigrationResponder, AggregatedCommandExecutor, RedundantResource {
NetworkMigrationResponder, AggregatedCommandExecutor, RedundantResource, DnsServiceProvider {
private static final Logger s_logger = Logger.getLogger(VirtualRouterElement.class);
public static final AutoScaleCounterType AutoScaleCounterCpu = new AutoScaleCounterType("cpu");
public static final AutoScaleCounterType AutoScaleCounterMemory = new AutoScaleCounterType("memory");
@ -968,10 +971,24 @@ NetworkMigrationResponder, AggregatedCommandExecutor, RedundantResource {
return true;
}
@Override
public boolean configDhcpSupportForSubnet(final Network network, final NicProfile nic, final VirtualMachineProfile vm, final DeployDestination dest,
final ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
if (canHandle(network, Service.Dhcp)) {
final ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
return configureDhcpSupport(network, nic, vm, dest, Service.Dhcp);
}
@Override
public boolean configDnsSupportForSubnet(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
// Ignore if virtual router is already dhcp provider
if (_networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.Dhcp, getProvider())) {
return true;
}
return configureDhcpSupport(network, nic, vm, dest, Service.Dns);
}
protected boolean configureDhcpSupport(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, Service service) throws ResourceUnavailableException {
if (canHandle(network, service)) {
if (vm.getType() != VirtualMachine.Type.User) {
return false;
}
@ -994,15 +1011,30 @@ NetworkMigrationResponder, AggregatedCommandExecutor, RedundantResource {
@Override
public boolean removeDhcpSupportForSubnet(final Network network) throws ResourceUnavailableException {
if (canHandle(network, Service.Dhcp)) {
return removeDhcpSupportForSubnet(network, Service.Dhcp);
}
@Override
public boolean removeDnsSupportForSubnet(Network network) throws ResourceUnavailableException {
// Ignore if virtual router is already dhcp provider
if (_networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.Dhcp, getProvider())) {
return true;
} else {
return removeDhcpSupportForSubnet(network, Service.Dns);
}
}
protected boolean removeDhcpSupportForSubnet(Network network, Network.Service service) throws ResourceUnavailableException {
if (canHandle(network, service)) {
final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), Role.VIRTUAL_ROUTER);
if (routers == null || routers.size() == 0) {
if (CollectionUtils.isEmpty(routers)) {
throw new ResourceUnavailableException("Can't find at least one router!", DataCenter.class, network.getDataCenterId());
}
try {
return _routerMgr.removeDhcpSupportForSubnet(network, routers);
} catch (final ResourceUnavailableException e) {
s_logger.debug("Router resource unavailable ");
s_logger.info("Router resource unavailable ", e);
}
}
return false;
@ -1011,8 +1043,23 @@ NetworkMigrationResponder, AggregatedCommandExecutor, RedundantResource {
@Override
public boolean addDhcpEntry(final Network network, final NicProfile nic, final VirtualMachineProfile vm, final DeployDestination dest, final ReservationContext context)
throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
return applyDhcpEntries(network, nic, vm, dest, Service.Dhcp);
}
@Override
public boolean addDnsEntry(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
// Ignore if virtual router is already dhcp provider
if (_networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.Dhcp, getProvider())) {
return true;
}
return applyDhcpEntries(network, nic, vm, dest, Service.Dns);
}
protected boolean applyDhcpEntries (final Network network, final NicProfile nic, final VirtualMachineProfile vm, final DeployDestination dest, final Network.Service service) throws ResourceUnavailableException {
boolean result = true;
if (canHandle(network, Service.Dhcp)) {
if (canHandle(network, service)) {
if (vm.getType() != VirtualMachine.Type.User) {
return false;
}

View File

@ -42,6 +42,11 @@ import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
import javax.naming.ConfigurationException;
import org.apache.log4j.Logger;
import org.cloud.network.router.deployment.RouterDeploymentDefinitionBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.apache.cloudstack.alert.AlertService;
import org.apache.cloudstack.alert.AlertService.AlertType;
import org.apache.cloudstack.api.command.admin.router.RebootRouterCmd;
@ -61,10 +66,6 @@ import org.apache.cloudstack.network.topology.NetworkTopology;
import org.apache.cloudstack.network.topology.NetworkTopologyContext;
import org.apache.cloudstack.utils.identity.ManagementServerNode;
import org.apache.cloudstack.utils.usage.UsageUtils;
import org.apache.log4j.Logger;
import org.cloud.network.router.deployment.RouterDeploymentDefinitionBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import com.cloud.agent.AgentManager;
import com.cloud.agent.Listener;
@ -1758,7 +1759,8 @@ Configurable, StateListener<VirtualMachine.State, VirtualMachine.Event, VirtualM
}
protected void finalizeUserDataAndDhcpOnStart(final Commands cmds, final DomainRouterVO router, final Provider provider, final Long guestNetworkId) {
if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.Dhcp, provider)) {
if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.Dhcp, provider)
|| _networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.Dns, provider)) {
// Resend dhcp
s_logger.debug("Reapplying dhcp entries as a part of domR " + router + " start...");
_commandSetupHelper.createDhcpEntryCommandsForVMs(router, cmds, guestNetworkId);

View File

@ -59,6 +59,7 @@ import com.cloud.network.PhysicalNetworkTrafficType;
import com.cloud.network.dao.NetworkServiceMapDao;
import com.cloud.network.dao.NetworkVO;
import com.cloud.network.element.DhcpServiceProvider;
import com.cloud.network.element.DnsServiceProvider;
import com.cloud.network.element.LoadBalancingServiceProvider;
import com.cloud.network.element.NetworkElement;
import com.cloud.network.element.StaticNatServiceProvider;
@ -826,6 +827,11 @@ public class MockNetworkManagerImpl extends ManagerBase implements NetworkOrches
return null; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
public DnsServiceProvider getDnsServiceProvider(Network network) {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
public void removeDhcpServiceInSubnet(Nic nic) {
//To change body of implemented methods use File | Settings | File Templates.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,523 @@
# 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.
""" Component tests for Internal DNS functionality with Nuage VSP SDN plugin
"""
# Import Local Modules
from nuageTestCase import nuageTestCase
from marvin.cloudstackAPI import updateZone
from marvin.lib.base import Account, Network
# Import System Modules
from nose.plugins.attrib import attr
class TestNuageInternalDns(nuageTestCase):
DNS = "06"
HOSTNAME = "0c"
DOMAINNAME = "0f"
@classmethod
def setUpClass(cls):
super(TestNuageInternalDns, cls).setUpClass()
cls.dnsdata = cls.test_data["nuagevsp"]
return
def setUp(self):
self.apiclient = self.testClient.getApiClient()
self.account = Account.create(
self.apiclient,
self.test_data["account"],
admin=True,
domainid=self.domain.id
)
self.test_data["virtual_machine"]["displayname"] = "vm1"
self.test_data["virtual_machine"]["name"] = "vm1"
self.cleanup = [self.account]
return
# Creates and verifies the firewall rule
def create_and_verify_fw(self, vm, public_ip, network):
self.debug("Create and verify firewall rule")
self.create_StaticNatRule_For_VM(vm, public_ip, network)
# VSD verification
self.verify_vsd_floating_ip(network, vm, public_ip.ipaddress)
fw_rule = self.create_FirewallRule(
public_ip, self.test_data["ingress_rule"])
self.verify_vsd_firewall_rule(fw_rule)
def verify_vsd_dhcp_option(self, dhcp_type, value, subnet_or_vm_interface,
is_vm_interface=False):
self.debug("Verifying the creation and value of DHCP option type - %s "
"in VSD" % dhcp_type)
found_dhcp_type = False
if is_vm_interface:
dhcp_options = self.vsd.get_vm_interface_dhcpoptions(
filter=self.get_externalID_filter(subnet_or_vm_interface.id))
else:
dhcp_options = self.vsd.get_subnet_dhcpoptions(
filter=self.get_externalID_filter(subnet_or_vm_interface.id))
for dhcp_option in dhcp_options:
self.debug("dhcptype option is %s:" % dhcp_option.actual_type)
self.debug("dhcptype expected value is option is %s:" % dhcp_type)
if dhcp_option.type == dhcp_type:
found_dhcp_type = True
if isinstance(dhcp_option.actual_values, list):
self.debug("dhcptype actual value is %s:" %
dhcp_option.actual_values)
if value in dhcp_option.actual_values:
self.debug("Excepted DHCP option value found in VSD")
else:
self.fail("Excepted DHCP option value not found in "
"VSD")
else:
self.assertEqual(dhcp_options.actual_values, value,
"Expected DHCP option value is not same "
"in both CloudStack and VSD"
)
if not found_dhcp_type:
self.fail("Expected DHCP option type and value not found in the "
"VSD")
self.debug("Successfully verified the creation and value of DHCP "
"option type - %s in VSD" % dhcp_type)
@attr(tags=["advanced", "nuagevsp"], required_hardware="false")
def test_01_Isolated_Network_with_zone(self):
""" Verify InternalDns on Isolated Network
"""
# Validate the following
# 1. Create an Isolated network - network1 (10.1.1.1/24) by using DNS
# network offering.
# 2. Deploy vm1 in network1.
# 3. Verify dhcp option 06 and 0f for subnet
# 4. Verify dhcp option 06,15 and 0f for vm Interface.
# update Network Domain at zone level
cmd = updateZone.updateZoneCmd()
cmd.id = self.zone.id
cmd.domain = "isolated.com"
self.apiclient.updateZone(cmd)
self.debug("Creating and enabling Nuage Vsp Isolated Network "
"offering...")
network_offering = self.create_NetworkOffering(
self.dnsdata["isolated_network_offering"])
self.validate_NetworkOffering(network_offering, state="Enabled")
network_1 = self.create_Network(network_offering)
vm_1 = self.create_VM(network_1)
# VSD verification
self.verify_vsd_network(self.domain.id, network_1)
self.verify_vsd_vm(vm_1)
# Internal DNS check point on VSD
self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", network_1)
self.verify_vsd_dhcp_option(self.DOMAINNAME, "isolated.com", network_1)
for nic in vm_1.nic:
self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True)
self.verify_vsd_dhcp_option(
self.DOMAINNAME, "isolated.com", nic, True)
self.verify_vsd_dhcp_option(self.HOSTNAME, "vm1", nic, True)
@attr(tags=["advanced", "nuagevsp"], required_hardware="true")
def test_02_Isolated_Network(self):
""" Verify InternalDns on Isolated Network with ping by hostname
"""
# Validate the following
# 1. Create an Isolated network - network1 (10.1.1.1/24) by using DNS
# network offering.
# 2. Deploy vm1 in network1.
# 3. Verify dhcp option 06 and 0f for subnet
# 4. Verify dhcp option 06,15 and 0f for vm Interface.
# 5. Deploy VM2 in network1.
# 6. Verify end to end by pinging with hostname
cmd = updateZone.updateZoneCmd()
cmd.id = self.zone.id
cmd.domain = "isolated.com"
self.apiclient.updateZone(cmd)
self.debug("Creating and enabling Nuage Vsp Isolated Network "
"offering...")
network_offering = self.create_NetworkOffering(
self.dnsdata["isolated_network_offering"])
self.validate_NetworkOffering(network_offering, state="Enabled")
network_1 = self.create_Network(network_offering)
vm_1 = self.create_VM(network_1)
# VSD verification
self.verify_vsd_network(self.domain.id, network_1)
self.verify_vsd_vm(vm_1)
# Internal DNS check point on VSD
self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", network_1)
self.verify_vsd_dhcp_option(self.DOMAINNAME, "isolated.com", network_1)
for nic in vm_1.nic:
self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True)
self.verify_vsd_dhcp_option(
self.DOMAINNAME, "isolated.com", nic, True)
self.verify_vsd_dhcp_option(self.HOSTNAME, "vm1", nic, True)
self.test_data["virtual_machine"]["displayname"] = "vm2"
self.test_data["virtual_machine"]["name"] = "vm2"
vm_2 = self.create_VM(network_1)
self.test_data["virtual_machine"]["displayname"] = "vm1"
self.test_data["virtual_machine"]["name"] = "vm1"
self.verify_vsd_vm(vm_2)
for nic in vm_2.nic:
self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True)
self.verify_vsd_dhcp_option(
self.DOMAINNAME, "isolated.com", nic, True)
self.verify_vsd_dhcp_option(self.HOSTNAME, "vm2", nic, True)
public_ip_1 = self.acquire_PublicIPAddress(network_1)
self.create_and_verify_fw(vm_1, public_ip_1, network_1)
vm_public_ip = public_ip_1.ipaddress.ipaddress
try:
vm_1.ssh_ip = vm_public_ip
vm_1.ssh_port = self.test_data["virtual_machine"]["ssh_port"]
vm_1.username = self.test_data["virtual_machine"]["username"]
vm_1.password = self.test_data["virtual_machine"]["password"]
self.debug("SSHing into VM: %s with %s" %
(vm_1.ssh_ip, vm_1.password))
ssh = vm_1.get_ssh_client(ipaddress=vm_public_ip)
except Exception as e:
self.fail("SSH into VM failed with exception %s" % e)
cmd = 'ping -c 2 vm2'
self.debug("ping vm2 by hostname with command: " + cmd)
outputlist = ssh.execute(cmd)
self.debug("command is executed properly " + cmd)
completeoutput = str(outputlist).strip('[]')
self.debug("complete output is " + completeoutput)
expectedlist = ['2 received', 'vm2.isolated.com', vm_2.ipaddress]
for item in expectedlist:
if item in completeoutput:
self.debug("excepted value found in vm: " + item)
else:
self.fail("excepted value not found in vm: " + item)
@attr(tags=["advanced", "nuagevsp"], required_hardware="false")
def test_03_Update_Network_with_Domain(self):
""" Verify update NetworkDomain for InternalDns on Isolated Network
"""
# Validate the following
# 1. Create an Isolated network - network1 (10.1.1.1/24) by using DNS
# network offering.
# 2. Deploy vm1 in network1.
# 3. Verify dhcp option 06 and 0f for subnet
# 4. Verify dhcp option 06,15 and 0f for vm Interface.
# 5. Update Network domain and verify it is properly updated
# update Network Domain at zone level
cmd = updateZone.updateZoneCmd()
cmd.id = self.zone.id
cmd.domain = "isolated.com"
self.apiclient.updateZone(cmd)
self.debug("Creating and enabling Nuage Vsp Isolated Network "
"offering...")
network_offering = self.create_NetworkOffering(
self.dnsdata["isolated_network_offering"])
self.validate_NetworkOffering(network_offering, state="Enabled")
network_1 = self.create_Network(network_offering)
vm_1 = self.create_VM(network_1)
# VSD verification
self.verify_vsd_network(self.domain.id, network_1)
self.verify_vsd_vm(vm_1)
# Internal DNS check point on VSD
self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", network_1)
self.verify_vsd_dhcp_option(self.DOMAINNAME, "isolated.com", network_1)
for nic in vm_1.nic:
self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True)
self.verify_vsd_dhcp_option(
self.DOMAINNAME, "isolated.com", nic, True)
self.verify_vsd_dhcp_option(self.HOSTNAME, "vm1", nic, True)
update_response = Network.update(
network_1, self.apiclient, id=network_1.id,
networkdomain="update.com", changecidr=False)
completeoutput = str(update_response).strip('[]')
self.debug("network update response is " + completeoutput)
self.assertEqual("update.com", update_response.networkdomain,
"Network Domain is not updated as expected"
)
self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", network_1)
self.verify_vsd_dhcp_option(self.DOMAINNAME, "update.com", network_1)
for nic in vm_1.nic:
self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True)
self.verify_vsd_dhcp_option(
self.DOMAINNAME, "update.com", nic, True)
self.verify_vsd_dhcp_option(self.HOSTNAME, "vm1", nic, True)
@attr(tags=["advanced", "nuagevsp"], required_hardware="true")
def test_04_Update_Network_with_Domain(self):
""" Verify update NetworkDomain for InternalDns on Isolated Network
with ping VM
"""
# Validate the following
# 1. Create an Isolated network - network1 (10.1.1.1/24) by using DNS
# network offering.
# 2. Deploy vm1 in network1.
# 3. Verify dhcp option 06 and 0f for subnet
# 4. Verify dhcp option 06,15 and 0f for vm Interface.
# 5. Update Network domain and verify it is properly updated
# update Network Domain at zone level
cmd = updateZone.updateZoneCmd()
cmd.id = self.zone.id
cmd.domain = "isolated.com"
self.apiclient.updateZone(cmd)
self.debug("Creating and enabling Nuage Vsp Isolated Network "
"offering...")
network_offering = self.create_NetworkOffering(
self.dnsdata["isolated_network_offering"])
self.validate_NetworkOffering(network_offering, state="Enabled")
network_1 = self.create_Network(network_offering)
vm_1 = self.create_VM(network_1)
# VSD verification
self.verify_vsd_network(self.domain.id, network_1)
self.verify_vsd_vm(vm_1)
# Internal DNS check point on VSD
self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", network_1)
self.verify_vsd_dhcp_option(
self.DOMAINNAME, "isolated.com", network_1)
for nic in vm_1.nic:
self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True)
self.verify_vsd_dhcp_option(
self.DOMAINNAME, "isolated.com", nic, True)
self.verify_vsd_dhcp_option(self.HOSTNAME, "vm1", nic, True)
update_response = Network.update(
network_1, self.apiclient, id=network_1.id,
networkdomain="update.com", changecidr=False)
completeoutput = str(update_response).strip('[]')
self.debug("network update response is " + completeoutput)
self.assertEqual("update.com", update_response.networkdomain,
"Network Domain is not updated as expected"
)
self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", network_1)
self.verify_vsd_dhcp_option(self.DOMAINNAME, "update.com", network_1)
for nic in vm_1.nic:
self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True)
self.verify_vsd_dhcp_option(
self.DOMAINNAME, "update.com", nic, True)
self.verify_vsd_dhcp_option(self.HOSTNAME, "vm1", nic, True)
# stop and start VM to get new DHCP option
try:
vm_1.stop(self.apiclient)
except Exception as e:
self.fail("Failed to stop the virtual instances, %s" % e)
try:
vm_1.start(self.apiclient)
except Exception as e:
self.fail("Failed to start the virtual instances, %s" % e)
self.test_data["virtual_machine"]["displayname"] = "vm2"
self.test_data["virtual_machine"]["name"] = "vm2"
vm_2 = self.create_VM(network_1)
self.test_data["virtual_machine"]["displayname"] = "vm1"
self.test_data["virtual_machine"]["name"] = "vm1"
self.verify_vsd_vm(vm_2)
for nic in vm_2.nic:
self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True)
self.verify_vsd_dhcp_option(
self.DOMAINNAME, "update.com", nic, True)
self.verify_vsd_dhcp_option(self.HOSTNAME, "vm2", nic, True)
public_ip_1 = self.acquire_PublicIPAddress(network_1)
self.create_and_verify_fw(vm_1, public_ip_1, network_1)
vm_public_ip = public_ip_1.ipaddress.ipaddress
try:
vm_1.ssh_ip = vm_public_ip
vm_1.ssh_port = self.test_data["virtual_machine"]["ssh_port"]
vm_1.username = self.test_data["virtual_machine"]["username"]
vm_1.password = self.test_data["virtual_machine"]["password"]
self.debug("SSHing into VM: %s with %s" %
(vm_1.ssh_ip, vm_1.password))
ssh = vm_1.get_ssh_client(ipaddress=vm_public_ip)
except Exception as e:
self.fail("SSH into VM failed with exception: %s " % e)
cmd = 'ping -c 2 vm2'
self.debug("ping vm2 by hostname with command: " + cmd)
outputlist = ssh.execute(cmd)
self.debug("command is executed properly " + cmd)
completeoutput = str(outputlist).strip('[]')
self.debug("complete output is " + completeoutput)
expectedlist = ['2 received', 'vm2.update.com', vm_2.ipaddress]
for item in expectedlist:
if item in completeoutput:
self.debug("excepted value found in vm: " + item)
else:
self.fail("excepted value not found in vm: " + item)
@attr(tags=["advanced", "nuagevsp"], required_hardware="false")
def test_05_VPC_Network_With_InternalDns(self):
""" Verify InternalDns on VPC Network
"""
# Validate the following
# 1. Create a VPC and tier network by using DNS network offering.
# 2. Deploy vm1 in tier network.
# 3. Verify dhcp option 06 and 0f for subnet
# 4. Verify dhcp option 06,15 and 0f for vm Interface.
cmd = updateZone.updateZoneCmd()
cmd.id = self.zone.id
cmd.domain = "vpc.com"
self.apiclient.updateZone(cmd)
vpc_off = self.create_VpcOffering(self.dnsdata["vpc_offering"])
self.validate_VpcOffering(vpc_off, state="Enabled")
vpc = self.create_Vpc(vpc_off, cidr='10.1.0.0/16', cleanup=False)
self.debug("Creating Nuage Vsp VPC Network offering...")
network_offering = self.create_NetworkOffering(
self.dnsdata["vpc_network_offering"])
self.validate_NetworkOffering(network_offering, state="Enabled")
network_1 = self.create_Network(
network_offering, gateway='10.1.1.1', vpc=vpc)
vm_1 = self.create_VM(network_1)
# VSD verification
self.verify_vsd_network(self.domain.id, network_1, vpc)
self.verify_vsd_vm(vm_1)
# Internal DNS check point on VSD
self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", network_1)
self.verify_vsd_dhcp_option(self.DOMAINNAME, "vpc.com", network_1)
for nic in vm_1.nic:
self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True)
self.verify_vsd_dhcp_option(self.DOMAINNAME, "vpc.com", nic, True)
self.verify_vsd_dhcp_option(self.HOSTNAME, "vm1", nic, True)
@attr(tags=["advanced", "nuagevsp"], required_hardware="true")
def test_06_VPC_Network_With_InternalDns(self):
""" Verify InternalDns on VPC Network by ping with hostname
"""
# Validate the following
# 1. Create a VPC and Tier network by using DNS network offering.
# 2. Deploy vm1 in Tier network network1.
# 3. Verify dhcp option 06 and 0f for subnet
# 4. Verify dhcp option 06,15 and 0f for vm Interface.
# 5. Deploy Vm2.
# 6. Verify end to end by pinging with hostname
cmd = updateZone.updateZoneCmd()
cmd.id = self.zone.id
cmd.domain = "vpc.com"
self.apiclient.updateZone(cmd)
vpc_off = self.create_VpcOffering(self.dnsdata["vpc_offering"])
self.validate_VpcOffering(vpc_off, state="Enabled")
vpc = self.create_Vpc(vpc_off, cidr='10.1.0.0/16', cleanup=False)
self.debug("Creating Nuage Vsp VPC Network offering...")
network_offering = self.create_NetworkOffering(
self.dnsdata["vpc_network_offering"])
self.validate_NetworkOffering(network_offering, state="Enabled")
network_1 = self.create_Network(
network_offering, gateway='10.1.1.1', vpc=vpc)
vm_1 = self.create_VM(network_1)
# VSD verification
self.verify_vsd_network(self.domain.id, network_1, vpc)
self.verify_vsd_vm(vm_1)
# Internal DNS check point on VSD
self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", network_1)
self.verify_vsd_dhcp_option(self.DOMAINNAME, "vpc.com", network_1)
for nic in vm_1.nic:
self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True)
self.verify_vsd_dhcp_option(self.DOMAINNAME, "vpc.com", nic, True)
self.verify_vsd_dhcp_option(self.HOSTNAME, "vm1", nic, True)
self.test_data["virtual_machine"]["displayname"] = "vm2"
self.test_data["virtual_machine"]["name"] = "vm2"
vm_2 = self.create_VM(network_1)
self.test_data["virtual_machine"]["displayname"] = "vm1"
self.test_data["virtual_machine"]["name"] = "vm1"
self.verify_vsd_vm(vm_2)
for nic in vm_2.nic:
self.verify_vsd_dhcp_option(self.DNS, "10.1.1.2", nic, True)
self.verify_vsd_dhcp_option(self.DOMAINNAME, "vpc.com", nic, True)
self.verify_vsd_dhcp_option(self.HOSTNAME, "vm2", nic, True)
public_ip_1 = self.acquire_PublicIPAddress(network_1, vpc)
self.create_StaticNatRule_For_VM(vm_1, public_ip_1, network_1)
# Adding Network ACL rule in the Public tier
self.debug("Adding Network ACL rule to make the created NAT rule "
"(SSH) accessible...")
public_ssh_rule = self.create_NetworkAclRule(
self.test_data["ingress_rule"], network=network_1)
# VSD verification
self.verify_vsd_firewall_rule(public_ssh_rule)
vm_public_ip = public_ip_1.ipaddress.ipaddress
try:
vm_1.ssh_ip = vm_public_ip
vm_1.ssh_port = self.test_data["virtual_machine"]["ssh_port"]
vm_1.username = self.test_data["virtual_machine"]["username"]
vm_1.password = self.test_data["virtual_machine"]["password"]
self.debug("SSHing into VM: %s with %s" %
(vm_1.ssh_ip, vm_1.password))
ssh = vm_1.get_ssh_client(ipaddress=vm_public_ip)
except Exception as e:
self.fail("SSH into VM failed with exception %s" % e)
cmd = 'ping -c 2 vm2'
self.debug("ping vm2 by hostname with command: " + cmd)
outputlist = ssh.execute(cmd)
self.debug("command is executed properly " + cmd)
completeoutput = str(outputlist).strip('[]')
self.debug("complete output is " + completeoutput)
expectedlist = ['2 received', 'vm2.vpc.com', vm_2.ipaddress]
for item in expectedlist:
if item in completeoutput:
self.debug("excepted value found in vm: " + item)
else:
self.fail("excepted value not found in vm: " + item)

View File

@ -15,7 +15,8 @@
# specific language governing permissions and limitations
# under the License.
""" Component tests for user data and password reset functionality with Nuage VSP SDN plugin
""" Component tests for user data and password reset functionality with
Nuage VSP SDN plugin
"""
# Import Local Modules
from nuageTestCase import nuageTestCase
@ -31,7 +32,8 @@ import base64
class TestNuagePasswordReset(nuageTestCase):
"""Test user data and password reset functionality with Nuage VSP SDN plugin
"""Test user data and password reset functionality with
Nuage VSP SDN plugin
"""
@classmethod
@ -60,22 +62,26 @@ class TestNuagePasswordReset(nuageTestCase):
if isinstance(list_volume, list):
self.volume = list_volume[0]
else:
raise Exception("Exception: Unable to find root volume for VM with ID - %s" % vm.id)
self.pw_enabled_template = Template.create(self.api_client,
self.test_data["template"],
self.volume.id,
account=self.account.name,
domainid=self.account.domainid
)
raise Exception("Exception: Unable to find root volume for VM "
"with ID - %s" % vm.id)
self.pw_enabled_template = Template.create(
self.api_client,
self.test_data["template"],
self.volume.id,
account=self.account.name,
domainid=self.account.domainid
)
self.assertEqual(self.pw_enabled_template.passwordenabled, True,
"template is not passwordenabled"
"Template is not password enabled"
)
self.cleanup.append(self.pw_enabled_template)
self.debug("Created guest VM template")
# updateTemplate - Updates value of the guest VM template's password enabled setting
# updateTemplate - Updates value of the guest VM template's password
# enabled setting
def updateTemplate(self, value):
self.debug("Updating value of guest VM template's password enabled setting")
self.debug("Updating value of guest VM template's password enabled "
"setting")
cmd = updateTemplate.updateTemplateCmd()
cmd.id = self.template.id
cmd.passwordenabled = value
@ -96,7 +102,8 @@ class TestNuagePasswordReset(nuageTestCase):
user_data_url = 'curl "http://' + gateway + ':80/latest/user-data"'
return user_data_url
# create_and_verify_fw - Creates and verifies (Ingress) firewall rule with a Static NAT rule enabled public IP
# create_and_verify_fw - Creates and verifies (Ingress) firewall rule with
# a Static NAT rule enabled public IP
def create_and_verify_fw(self, vm, public_ip, network):
self.debug("Creating and verifying firewall rule")
self.create_StaticNatRule_For_VM(vm, public_ip, network)
@ -104,7 +111,8 @@ class TestNuagePasswordReset(nuageTestCase):
# VSD verification
self.verify_vsd_floating_ip(network, vm, public_ip.ipaddress)
fw_rule = self.create_FirewallRule(public_ip, self.test_data["ingress_rule"])
fw_rule = self.create_FirewallRule(
public_ip, self.test_data["ingress_rule"])
# VSD verification
self.verify_vsd_firewall_rule(fw_rule)
@ -122,14 +130,17 @@ class TestNuagePasswordReset(nuageTestCase):
if vm.state != 'Stopped':
raise Exception("Failed to stop VM (ID: %s) " % self.vm.id)
else:
raise Exception("Invalid response from list_virtual_machines VM (ID: %s) " % self.vm.id)
raise Exception("Invalid response from list_virtual_machines VM "
"(ID: %s) " % self.vm.id)
self.debug("Stopped VM")
# install_cloud_set_guest_password_script - Installs the cloud-set-guest-password script from people.apache.org in
# the given VM (SSH client)
# install_cloud_set_guest_password_script - Installs the
# cloud-set-guest-password script from people.apache.org in the given VM
# (SSH client)
def install_cloud_set_guest_password_script(self, ssh_client):
self.debug("Installing cloud-set-guest-password script")
cmd = "cd /etc/init.d;wget http://people.apache.org/~tsp/cloud-set-guest-password"
cmd = "cd /etc/init.d;wget http://people.apache.org/~tsp/" \
"cloud-set-guest-password"
result = self.execute_cmd(ssh_client, cmd)
self.debug("wget file cloud-set-guest-password: " + result)
if "200 OK" not in result:
@ -145,53 +156,71 @@ class TestNuagePasswordReset(nuageTestCase):
@attr(tags=["advanced", "nuagevsp"], required_hardware="true")
def test_nuage_UserDataPasswordReset(self):
"""Test user data and password reset functionality with Nuage VSP SDN plugin
"""Test user data and password reset functionality with
Nuage VSP SDN plugin
"""
# 1. Create an Isolated Network with Nuage VSP Isolated Network offering, check if it is successfully created
# and is in the "Allocated" state.
# 1. Create an Isolated Network with Nuage VSP Isolated Network
# offering, check if it is successfully created and is in the
# "Allocated" state.
# 2. Set password enabled to false in the guest VM template.
# 3. Deploy a VM in the created Isolated network with user data, check if the Isolated network state is changed
# to "Implemented", and both the VM & VR are successfully deployed and are in the "Running" state.
# 4. Verify that the guest VM template is not password enabled by checking the deployed VM's password
# (password == "password").
# 5. SSH into the deployed VM and verify its user data (expected user data == actual user data).
# 6. Check for cloud-set-guest-password script in the deployed VM for testing password reset functionality.
# 7. if cloud-set-guest-password script does not exist in the deployed VM:
# 7.1 Install the cloud-set-guest-password script from people.apache.org in the deployed VM.
# 7.2 Stop the deployed VM, and create a new password enabled guest VM template with it.
# 7.3 Deploy a new VM in the created Isolated network with the newly created guest VM template,
# check if the VM is successfully deployed and is in the "Running" state.
# 7.4 Verify that the new guest VM template is password enabled by checking the newly deployed VM's
# password (password != "password").
# 3. Deploy a VM in the created Isolated network with user data, check
# if the Isolated network state is changed to "Implemented", and
# both the VM & VR are successfully deployed and are in the
# "Running" state.
# 4. Verify that the guest VM template is not password enabled by
# checking the deployed VM's password (password == "password").
# 5. SSH into the deployed VM and verify its user data
# (expected user data == actual user data).
# 6. Check for cloud-set-guest-password script in the deployed VM for
# testing password reset functionality.
# 7. if cloud-set-guest-password script does not exist in the deployed
# VM:
# 7.1 Install the cloud-set-guest-password script from
# people.apache.org in the deployed VM.
# 7.2 Stop the deployed VM, and create a new password enabled
# guest VM template with it.
# 7.3 Deploy a new VM in the created Isolated network with the
# newly created guest VM template, check if the VM is
# successfully deployed and is in the "Running" state.
# 7.4 Verify that the new guest VM template is password enabled
# by checking the newly deployed VM's password
# (password != "password").
# 7.5 SSH into the newly deployed VM for verifying its password.
# 8. else cloud-set-guest-password script exists in the deployed VM:
# 8.1 Change password enabled to true in the guest VM template.
# 8.2 Verify that the guest VM template is password enabled.
# 9. Reset VM password, and start the VM.
# 10. Verify that the new guest VM template is password enabled by checking the VM's password
# (password != "password").
# 11. SSH into the VM for verifying its new password after its password reset.
# 12. Set password enabled to the default value in the guest VM template.
# 10. Verify that the new guest VM template is password enabled by
# checking the VM's password (password != "password").
# 11. SSH into the VM for verifying its new password after its password
# reset.
# 12. Set password enabled to the default value in the guest VM
# template.
# 13. Delete all the created objects (cleanup).
self.debug("Testing user data & password reset functionality in an Isolated network...")
self.debug("Testing user data & password reset functionality in an "
"Isolated network...")
self.debug("Creating an Isolated network...")
net_off = self.create_NetworkOffering(self.test_data["nuagevsp"]["isolated_network_offering"])
net_off = self.create_NetworkOffering(
self.test_data["nuagevsp"]["isolated_network_offering"])
self.network = self.create_Network(net_off)
self.validate_Network(self.network, state="Allocated")
self.debug("Setting password enabled to false in the guest VM template...")
self.debug("Setting password enabled to false in the guest VM "
"template...")
self.defaultTemplateVal = self.template.passwordenabled
if self.template.passwordenabled:
self.updateTemplate(False)
self.debug("Deploying a VM in the created Isolated network with user data...")
self.debug("Deploying a VM in the created Isolated network with user "
"data...")
expected_user_data = "hello world vm1"
user_data = base64.b64encode(expected_user_data)
self.test_data["virtual_machine_userdata"]["userdata"] = user_data
self.vm_1 = self.create_VM(self.network, testdata=self.test_data["virtual_machine_userdata"])
self.vm_1 = self.create_VM(
self.network, testdata=self.test_data["virtual_machine_userdata"])
self.validate_Network(self.network, state="Implemented")
vr = self.get_Router(self.network)
self.check_Router_state(vr, state="Running")
@ -202,11 +231,15 @@ class TestNuagePasswordReset(nuageTestCase):
self.verify_vsd_router(vr)
self.verify_vsd_vm(self.vm_1)
self.debug("verifying that the guest VM template is not password enabled...")
self.debug("VM - %s password - %s !" % (self.vm_1.name, self.vm_1.password))
self.assertEqual(self.vm_1.password, self.test_data["virtual_machine_userdata"]["password"],
"Password is enabled for the VM (vm_1)"
)
self.debug("verifying that the guest VM template is not password "
"enabled...")
self.debug("VM - %s password - %s !" %
(self.vm_1.name, self.vm_1.password))
self.assertEqual(
self.vm_1.password,
self.test_data["virtual_machine_userdata"]["password"],
"Password is enabled for the VM (vm_1)"
)
self.debug("SSHing into the VM for verifying its user data...")
public_ip_1 = self.acquire_PublicIPAddress(self.network)
@ -214,27 +247,35 @@ class TestNuagePasswordReset(nuageTestCase):
ssh = self.ssh_into_VM(self.vm_1, public_ip_1)
user_data_cmd = self.get_userdata_url(self.vm_1)
self.debug("Getting user data with command: " + user_data_cmd)
actual_user_data = base64.b64decode(self.execute_cmd(ssh, user_data_cmd))
self.debug("Actual user data - " + actual_user_data + ", Expected user data - " + expected_user_data)
actual_user_data = base64.b64decode(self.execute_cmd
(ssh, user_data_cmd))
self.debug("Actual user data - " + actual_user_data +
", Expected user data - " + expected_user_data)
self.assertEqual(actual_user_data, expected_user_data,
"Un-expected VM (VM_1) user data"
)
self.debug("Checking for cloud-set-guest-password script in the VM for testing password reset functionality...")
self.debug("Checking for cloud-set-guest-password script in the VM "
"for testing password reset functionality...")
ls_cmd = "ls /etc/init.d/cloud-set-guest-password"
ls_result = self.execute_cmd(ssh, ls_cmd)
ls_result = ls_result.lower()
self.debug("Response from ls_cmd: " + ls_result)
if "no such file" in ls_result:
self.debug("No cloud-set-guest-password script in the VM")
self.debug("Installing the cloud-set-guest-password script from people.apache.org in the VM...")
self.debug("Installing the cloud-set-guest-password script from "
"people.apache.org in the VM...")
self.install_cloud_set_guest_password_script(ssh)
self.debug("Stopping the VM, and creating a new password enabled guest VM template with it...")
self.debug("Stopping the VM, and creating a new password enabled "
"guest VM template with it...")
self.stop_vm(self.vm_1)
self.create_template(self.vm_1)
self.debug("Deploying a new VM in the created Isolated network with the newly created guest VM template...")
self.vm_2 = self.create_VM(self.network, testdata=self.test_data["virtual_machine_userdata"])
self.debug("Deploying a new VM in the created Isolated network "
"with the newly created guest VM template...")
self.vm_2 = self.create_VM(
self.network,
testdata=self.test_data["virtual_machine_userdata"])
self.debug("Starting the VM...")
vm_2a = self.vm_2.start(self.api_client)
self.vm_2.password = vm_2a.password.strip()
@ -243,11 +284,15 @@ class TestNuagePasswordReset(nuageTestCase):
# VSD verification
self.verify_vsd_vm(self.vm_2)
self.debug("verifying that the guest VM template is password enabled...")
self.debug("VM - %s password - %s !" % (self.vm_2.name, self.vm_2.password))
self.assertNotEqual(self.vm_2.password, self.test_data["virtual_machine_userdata"]["password"],
"Password is not enabled for the VM"
)
self.debug("verifying that the guest VM template is password "
"enabled...")
self.debug("VM - %s password - %s !" %
(self.vm_2.name, self.vm_2.password))
self.assertNotEqual(
self.vm_2.password,
self.test_data["virtual_machine_userdata"]["password"],
"Password is not enabled for the VM"
)
self.debug("SSHing into the VM for verifying its password...")
public_ip_2 = self.acquire_PublicIPAddress(self.network)
@ -272,14 +317,20 @@ class TestNuagePasswordReset(nuageTestCase):
self.debug("Starting the VM")
vm_test.start(self.api_client)
self.debug("verifying that the guest VM template is password enabled...")
self.debug("VM - %s password - %s !" % (vm_test.name, vm_test.password))
self.assertNotEqual(vm_test.password, self.test_data["virtual_machine_userdata"]["password"],
"Password is not enabled for the VM"
)
self.debug("verifying that the guest VM template is password "
"enabled...")
self.debug("VM - %s password - %s !" %
(vm_test.name, vm_test.password))
self.assertNotEqual(
vm_test.password,
self.test_data["virtual_machine_userdata"]["password"],
"Password is not enabled for the VM"
)
self.debug("SSHing into the VM for verifying its new password after its password reset...")
self.debug("SSHing into the VM for verifying its new password after "
"its password reset...")
self.ssh_into_VM(vm_test, vm_test_public_ip)
self.debug("Setting password enabled to the default value in the guest VM template...")
self.debug("Setting password enabled to the default value in the "
"guest VM template...")
self.updateTemplate(self.defaultTemplateVal)

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,8 @@
# specific language governing permissions and limitations
# under the License.
""" Component tests for basic VPC Network functionality with Nuage VSP SDN plugin
""" Component tests for basic VPC Network functionality with
Nuage VSP SDN plugin
"""
# Import Local Modules
from nuageTestCase import nuageTestCase
@ -30,7 +31,7 @@ class TestNuageVpcNetwork(nuageTestCase):
@classmethod
def setUpClass(cls, zone=None):
super(TestNuageVpcNetwork, cls).setUpClass(zone=zone)
super(TestNuageVpcNetwork, cls).setUpClass()
return
def setUp(self):
@ -48,20 +49,26 @@ class TestNuageVpcNetwork(nuageTestCase):
""" Test basic VPC Network functionality with Nuage VSP SDN plugin
"""
# 1. Create Nuage VSP VPC offering, check if it is successfully created and enabled.
# 2. Create a VPC with Nuage VSP VPC offering, check if it is successfully created and enabled.
# 3. Create Nuage VSP VPC Network offering, check if it is successfully created and enabled.
# 1. Create Nuage VSP VPC offering, check if it is successfully
# created and enabled.
# 2. Create a VPC with Nuage VSP VPC offering, check if it is
# successfully created and enabled.
# 3. Create Nuage VSP VPC Network offering, check if it is successfully
# created and enabled.
# 4. Create an ACL list in the created VPC, and add an ACL item to it.
# 5. Create a VPC Network with Nuage VSP VPC Network offering and the created ACL list, check if it is
# successfully created, is in the "Implemented" state, and is added to the VPC VR.
# 6. Deploy a VM in the created VPC network, check if the VM is successfully deployed and is in the "Running"
# state.
# 7. Verify that the created ACL item is successfully implemented in Nuage VSP.
# 5. Create a VPC Network with Nuage VSP VPC Network offering and the
# created ACL list, check if it is successfully created, is in the
# "Implemented" state, and is added to the VPC VR.
# 6. Deploy a VM in the created VPC network, check if the VM is
# successfully deployed and is in the "Running" state.
# 7. Verify that the created ACL item is successfully implemented in
# Nuage VSP.
# 8. Delete all the created objects (cleanup).
# Creating a VPC offering
self.debug("Creating Nuage VSP VPC offering...")
vpc_offering = self.create_VpcOffering(self.test_data["nuagevsp"]["vpc_offering"])
vpc_offering = self.create_VpcOffering(
self.test_data["nuagevsp"]["vpc_offering"])
self.validate_VpcOffering(vpc_offering, state="Enabled")
# Creating a VPC
@ -71,18 +78,23 @@ class TestNuageVpcNetwork(nuageTestCase):
# Creating a network offering
self.debug("Creating Nuage VSP VPC Network offering...")
network_offering = self.create_NetworkOffering(self.test_data["nuagevsp"]["vpc_network_offering"])
network_offering = self.create_NetworkOffering(
self.test_data["nuagevsp"]["vpc_network_offering"])
self.validate_NetworkOffering(network_offering, state="Enabled")
# Creating an ACL list
acl_list = self.create_NetworkAclList(name="acl", description="acl", vpc=vpc)
acl_list = self.create_NetworkAclList(
name="acl", description="acl", vpc=vpc)
# Creating an ACL item
acl_item = self.create_NetworkAclRule(self.test_data["ingress_rule"], acl_list=acl_list)
acl_item = self.create_NetworkAclRule(
self.test_data["ingress_rule"], acl_list=acl_list)
# Creating a VPC network in the VPC
self.debug("Creating a VPC network with Nuage VSP VPC Network offering...")
vpc_network = self.create_Network(network_offering, vpc=vpc, acl_list=acl_list)
self.debug("Creating a VPC network with Nuage VSP VPC Network "
"offering...")
vpc_network = self.create_Network(
network_offering, vpc=vpc, acl_list=acl_list)
self.validate_Network(vpc_network, state="Implemented")
vr = self.get_Router(vpc_network)
self.check_Router_state(vr, state="Running")
@ -99,18 +111,25 @@ class TestNuageVpcNetwork(nuageTestCase):
# VSD verification for ACL item
self.verify_vsd_firewall_rule(acl_item)
@attr(tags=["advanced", "nuagevsp", "multizone"], required_hardware="false")
@attr(
tags=["advanced", "nuagevsp", "multizone"], required_hardware="false")
def test_nuage_vpc_network_multizone(self):
""" Test basic VPC Network functionality with Nuage VSP SDN plugin on multiple zones
""" Test basic VPC Network functionality with Nuage VSP SDN plugin on
multiple zones
"""
# Repeat the tests in the above testcase "test_nuage_vpc_network" on multiple zones
# Repeat the tests in the above testcase "test_nuage_vpc_network" on
# multiple zones
self.debug("Testing basic VPC Network functionality with Nuage VSP SDN plugin on multiple zones...")
self.debug("Testing basic VPC Network functionality with Nuage VSP "
"SDN plugin on multiple zones...")
zones = Zone.list(self.api_client)
if len(zones) == 1:
self.skipTest("There is only one Zone configured: skipping test")
for zone in zones:
self.debug("Zone - %s" % zone.name)
self.setUpClass(zone=zone)
# Get Zone details
self.getZoneDetails()
# Configure VSD sessions
self.configureVSDSessions()
self.test_nuage_vpc_network()

View File

@ -45,89 +45,110 @@ class TestNuageVsp(nuageTestCase):
self.cleanup = [self.account]
return
# validate_NuageVspDevice - Validates the addition of Nuage VSP device in the Nuage VSP Physical Network
# validate_NuageVspDevice - Validates the addition of Nuage VSP device in
# the Nuage VSP Physical Network
def validate_NuageVspDevice(self):
"""Validates the addition of Nuage VSP device in the Nuage VSP Physical Network"""
self.debug("Validating the addition of Nuage VSP device in the Nuage VSP Physical Network - %s" %
self.vsp_physical_network.id)
nuage_vsp_device = Nuage.list(self.api_client,
physicalnetworkid=self.vsp_physical_network.id
)
"""Validates the addition of Nuage VSP device in the
Nuage VSP Physical Network"""
self.debug("Validating the addition of Nuage VSP device in the Nuage "
"VSP Physical Network - %s" % self.vsp_physical_network.id)
nuage_vsp_device = Nuage.list(
self.api_client,
physicalnetworkid=self.vsp_physical_network.id
)
self.assertEqual(isinstance(nuage_vsp_device, list), True,
"List Nuage VSP device should return a valid list"
)
self.debug("Successfully validated the addition of Nuage VSP device in the Nuage VSP Physical Network - %s" %
self.debug("Successfully validated the addition of Nuage VSP device "
"in the Nuage VSP Physical Network - %s" %
self.vsp_physical_network.id)
# delete_NuageVspDevice - Deletes the Nuage VSP device in the Nuage VSP Physical Network
# delete_NuageVspDevice - Deletes the Nuage VSP device in the Nuage VSP
# Physical Network
def delete_NuageVspDevice(self):
"""Deletes the Nuage VSP device in the Nuage VSP Physical Network"""
self.debug("Deleting the Nuage VSP device in the Nuage VSP Physical Network - %s" %
self.vsp_physical_network.id)
nuage_vsp_device = Nuage.list(self.api_client,
physicalnetworkid=self.vsp_physical_network.id
)[0]
self.debug("Deleting the Nuage VSP device in the Nuage VSP Physical "
"Network - %s" % self.vsp_physical_network.id)
nuage_vsp_device = Nuage.list(
self.api_client,
physicalnetworkid=self.vsp_physical_network.id)[0]
cmd = deleteNuageVspDevice.deleteNuageVspDeviceCmd()
cmd.vspdeviceid = nuage_vsp_device.vspdeviceid
self.api_client.deleteNuageVspDevice(cmd)
self.debug("Successfully deleted the Nuage VSP device in the Nuage VSP Physical Network - %s" %
self.vsp_physical_network.id)
self.debug("Successfully deleted the Nuage VSP device in the Nuage "
"VSP Physical Network - %s" % self.vsp_physical_network.id)
@attr(tags=["advanced", "nuagevsp"], required_hardware="false")
def test_nuage_vsp_device(self):
""" Test Nuage VSP device in the Nuage VSP Physical Network
"""
# 1. Verify that the Nuage VSP network service provider is successfully created and enabled in the Nuage VSP
# Physical Network.
# 2. Verify that the Nuage VSP device is successfully created in the Nuage VSP Physical Network.
# 3. Delete the Nuage VSP device in the Nuage VSP Physical Network, verify that the Nuage VSP device is
# successfully deleted in the Nuage VSP Physical Network.
# 4. Add the Nuage VSP device in the Nuage VSP Physical Network with invalid VSD credentials, verify that the
# Nuage VSP device failed to add in the Nuage VSP Physical Network.
# 5. Add the Nuage VSP device in the Nuage VSP Physical Network with valid VSD credentials, verify that the
# Nuage VSP device is successfully added in the Nuage VSP Physical Network.
# 1. Verify that the Nuage VSP network service provider is successfully
# created and enabled in the Nuage VSP Physical Network.
# 2. Verify that the Nuage VSP device is successfully created in the
# Nuage VSP Physical Network.
# 3. Delete the Nuage VSP device in the Nuage VSP Physical Network,
# verify that the Nuage VSP device is successfully deleted in the
# Nuage VSP Physical Network.
# 4. Add the Nuage VSP device in the Nuage VSP Physical Network with
# invalid VSD credentials, verify that the Nuage VSP device failed
# to add in the Nuage VSP Physical Network.
# 5. Add the Nuage VSP device in the Nuage VSP Physical Network with
# valid VSD credentials, verify that the Nuage VSP device is
# successfully added in the Nuage VSP Physical Network.
# Nuage VSP network service provider validation
self.debug("Validating the Nuage VSP network service provider in the Nuage VSP Physical Network...")
self.debug("Validating the Nuage VSP network service provider in the "
"Nuage VSP Physical Network...")
self.validate_NetworkServiceProvider("NuageVsp", state="Enabled")
# Nuage VSP device validation
self.debug("Validating the Nuage VSP device in the Nuage VSP Physical Network...")
self.debug("Validating the Nuage VSP device in the Nuage VSP Physical "
"Network...")
self.validate_NuageVspDevice()
# Nuage VSP device deletion
self.debug("Deleting the Nuage VSP device in the Nuage VSP Physical Network...")
self.debug("Deleting the Nuage VSP device in the Nuage VSP Physical "
"Network...")
self.delete_NuageVspDevice()
# Nuage VSP device validation
self.debug("Validating the Nuage VSP device in the Nuage VSP Physical Network...")
self.debug("Validating the Nuage VSP device in the Nuage VSP Physical "
"Network...")
with self.assertRaises(Exception):
self.validate_NuageVspDevice()
self.debug("Successfully deleted the Nuage VSP device in the Nuage VSP Physical Network")
self.debug("Successfully deleted the Nuage VSP device in the Nuage "
"VSP Physical Network")
# Adding the Nuage VSP device with invalid VSD credentials
self.debug("Adding the Nuage VSP device in the Nuage VSP Physical Network with invalid VSD credentials...")
self.debug("Adding the Nuage VSP device in the Nuage VSP Physical "
"Network with invalid VSD credentials...")
vsd_info = self.nuage_vsp_device.__dict__
invalid_vsd_info = copy.deepcopy(vsd_info)
invalid_vsd_info["password"] = ""
with self.assertRaises(Exception):
Nuage.add(self.api_client, invalid_vsd_info, self.vsp_physical_network.id)
self.debug("Failed to add the Nuage VSP device in the Nuage VSP Physical Network due to invalid VSD "
"credentials")
Nuage.add(
self.api_client, invalid_vsd_info,
self.vsp_physical_network.id)
self.debug("Failed to add the Nuage VSP device in the Nuage VSP "
"Physical Network due to invalid VSD credentials")
# Nuage VSP device validation
self.debug("Validating the Nuage VSP device in the Nuage VSP Physical Network...")
self.debug("Validating the Nuage VSP device in the Nuage VSP "
"Physical Network...")
with self.assertRaises(Exception):
self.validate_NuageVspDevice()
self.debug("The Nuage VSP device is not added in the Nuage VSP Physical Network")
self.debug("The Nuage VSP device is not added in the Nuage VSP "
"Physical Network")
# Adding the Nuage VSP device with valid VSD credentials
self.debug("Adding the Nuage VSP device in the Nuage VSP Physical Network with valid VSD credentials...")
self.debug("Adding the Nuage VSP device in the Nuage VSP Physical "
"Network with valid VSD credentials...")
Nuage.add(self.api_client, vsd_info, self.vsp_physical_network.id)
# Nuage VSP device validation
self.debug("Validating the Nuage VSP device in the Nuage VSP Physical Network...")
self.debug("Validating the Nuage VSP device in the Nuage VSP Physical "
"Network...")
self.validate_NuageVspDevice()
@attr(tags=["advanced", "nuagevsp"], required_hardware="false")
@ -135,26 +156,32 @@ class TestNuageVsp(nuageTestCase):
""" Test Nuage VSP SDN plugin with basic Isolated Network functionality
"""
# 1. Verify that the Nuage VSP network service provider is successfully created and enabled.
# 2. Create and enable Nuage VSP Isolated Network offering, check if it is successfully created and enabled.
# 3. Create an Isolated Network with Nuage VSP Isolated Network offering, check if it is successfully created
# and is in the "Allocated" state.
# 4. Deploy a VM in the created Isolated network, check if the Isolated network state is changed to
# "Implemented", and both the VM & VR are successfully deployed and are in the "Running" state.
# 5. Deploy one more VM in the created Isolated network, check if the VM is successfully deployed and is in the
# "Running" state.
# 6. Delete the created Isolated Network after destroying its VMs, check if the Isolated network is successfully
# deleted.
# 1. Verify that the Nuage VSP network service provider is successfully
# created and enabled.
# 2. Create and enable Nuage VSP Isolated Network offering, check if it
# is successfully created and enabled.
# 3. Create an Isolated Network with Nuage VSP Isolated Network
# offering, check if it is successfully created and is in the
# "Allocated" state.
# 4. Deploy a VM in the created Isolated network, check if the Isolated
# network state is changed to "Implemented", and both the VM & VR
# are successfully deployed and are in the "Running" state.
# 5. Deploy one more VM in the created Isolated network, check if the
# VM is successfully deployed and is in the "Running" state.
# 6. Delete the created Isolated Network after destroying its VMs,
# check if the Isolated network is successfully deleted.
# 7. Delete all the created objects (cleanup).
# Creating a network offering
self.debug("Creating and enabling Nuage VSP Isolated Network offering...")
self.debug("Creating and enabling Nuage VSP Isolated Network "
"offering...")
network_offering = self.create_NetworkOffering(
self.test_data["nuagevsp"]["isolated_network_offering"])
self.validate_NetworkOffering(network_offering, state="Enabled")
# Creating a network
self.debug("Creating an Isolated Network with Nuage VSP Isolated Network offering...")
self.debug("Creating an Isolated Network with Nuage VSP Isolated "
"Network offering...")
network = self.create_Network(network_offering)
self.validate_Network(network, state="Allocated")
@ -178,7 +205,8 @@ class TestNuageVsp(nuageTestCase):
self.verify_vsd_vm(vm_2)
# Deleting the network
self.debug("Deleting the Isolated Network with Nuage VSP Isolated Network offering...")
self.debug("Deleting the Isolated Network with Nuage VSP Isolated "
"Network offering...")
self.delete_VM(vm_1)
self.delete_VM(vm_2)
self.delete_Network(network)

View File

@ -37,7 +37,7 @@ def user(Name, DomainName, AcctType):
class cloudstackTestCase(unittest.case.TestCase):
clstestclient = None
def assertElementInList(inp, toverify, responsevar=None, pos=0,
def assertElementInList(self, inp, toverify, responsevar=None, pos=0,
assertmsg="TC Failed for reason"):
'''
@Name: assertElementInList

View File

@ -1731,7 +1731,7 @@ test_data = {
"name": 'nuage_marvin',
"displaytext": 'nuage_marvin',
"guestiptype": 'Isolated',
"supportedservices": 'Dhcp,SourceNat,Connectivity,StaticNat,UserData,Firewall',
"supportedservices": 'Dhcp,SourceNat,Connectivity,StaticNat,UserData,Firewall,Dns',
"traffictype": 'GUEST',
"availability": 'Optional',
"serviceProviderList": {
@ -1740,7 +1740,8 @@ test_data = {
"SourceNat": 'NuageVsp',
"Firewall": 'NuageVsp',
"Connectivity": 'NuageVsp',
"UserData": 'VirtualRouter'
"UserData": 'VirtualRouter',
"Dns": 'VirtualRouter'
},
"serviceCapabilityList": {
"SourceNat": {"SupportedSourceNatTypes": "perzone"}
@ -1751,7 +1752,7 @@ test_data = {
"name": 'nuage_vpc_marvin',
"displaytext": 'nuage_vpc_marvin',
"guestiptype": 'Isolated',
"supportedservices": 'Dhcp,StaticNat,SourceNat,NetworkACL,Connectivity,UserData',
"supportedservices": 'Dhcp,StaticNat,SourceNat,NetworkACL,Connectivity,UserData,Dns',
"traffictype": 'GUEST',
"availability": 'Optional',
"useVpc": 'on',
@ -1762,7 +1763,8 @@ test_data = {
"SourceNat": "NuageVsp",
"NetworkACL": "NuageVsp",
"Connectivity": "NuageVsp",
"UserData": "VpcVirtualRouter"
"UserData": "VpcVirtualRouter",
"Dns": "VpcVirtualRouter"
},
"serviceCapabilityList": {
"SourceNat": {"SupportedSourceNatTypes": "perzone"}
@ -1772,7 +1774,7 @@ test_data = {
"name": "nuage_vpc_marvin_internal_lb",
"displaytext": "nuage_vpc_marvin_internal_lb",
"guestiptype": 'Isolated',
"supportedservices": 'Dhcp,Lb,StaticNat,SourceNat,NetworkACL,Connectivity,UserData',
"supportedservices": 'Dhcp,Lb,StaticNat,SourceNat,NetworkACL,Connectivity,UserData,Dns',
"traffictype": 'GUEST',
"availability": 'Optional',
"useVpc": 'on',
@ -1784,7 +1786,8 @@ test_data = {
"SourceNat": "NuageVsp",
"NetworkACL": "NuageVsp",
"Connectivity": "NuageVsp",
"UserData": "VpcVirtualRouter"
"UserData": "VpcVirtualRouter",
"Dns": "VpcVirtualRouter"
},
"serviceCapabilityList": {
"SourceNat": {"SupportedSourceNatTypes": "perzone"},
@ -1795,20 +1798,21 @@ test_data = {
"vpc_offering": {
"name": 'Nuage VSP VPC offering',
"displaytext": 'Nuage VSP VPC offering',
"supportedservices": 'Dhcp,StaticNat,SourceNat,NetworkACL,Connectivity,UserData',
"supportedservices": 'Dhcp,StaticNat,SourceNat,NetworkACL,Connectivity,UserData,Dns',
"serviceProviderList": {
"Dhcp": "NuageVsp",
"StaticNat": "NuageVsp",
"SourceNat": "NuageVsp",
"NetworkACL": "NuageVsp",
"Connectivity": "NuageVsp",
"UserData": "VpcVirtualRouter"
"UserData": "VpcVirtualRouter",
"Dns": "VpcVirtualRouter"
}
},
"vpc_offering_lb": {
"name": 'Nuage VSP VPC offering with Lb',
"displaytext": 'Nuage VSP VPC offering with Lb',
"supportedservices": 'Dhcp,Lb,StaticNat,SourceNat,NetworkACL,Connectivity,UserData',
"supportedservices": 'Dhcp,Lb,StaticNat,SourceNat,NetworkACL,Connectivity,UserData,Dns',
"serviceProviderList": {
"Dhcp": "NuageVsp",
"Lb": "InternalLbVm",
@ -1816,7 +1820,8 @@ test_data = {
"SourceNat": "NuageVsp",
"NetworkACL": "NuageVsp",
"Connectivity": "NuageVsp",
"UserData": "VpcVirtualRouter"
"UserData": "VpcVirtualRouter",
"Dns": "VpcVirtualRouter"
}
}
}

View File

@ -56,6 +56,9 @@ setup(name="Marvin",
"dnspython",
"ipmisim >= 0.7"
],
extras_require={
"nuagevsp": ["libVSD", "PyYAML", "futures", "netaddr", "retries"]
},
py_modules=['marvin.marvinPlugin'],
zip_safe=False,
entry_points={