Changed networkconfigurations to network as per Sheng's suggestion

This commit is contained in:
Alex Huang 2010-11-19 15:43:48 -08:00
parent a495f34d4f
commit 5b4a6f27db
42 changed files with 551 additions and 540 deletions

View File

@ -175,8 +175,8 @@ import com.cloud.agent.resource.virtualnetwork.VirtualRoutingResource;
import com.cloud.exception.InternalErrorException;
import com.cloud.host.Host.Type;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.network.Network.BroadcastDomainType;
import com.cloud.network.Network.TrafficType;
import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.Networks.TrafficType;
import com.cloud.network.NetworkEnums.RouterPrivateIpStrategy;
import com.cloud.resource.ServerResource;
import com.cloud.resource.ServerResourceBase;

View File

@ -19,8 +19,8 @@ package com.cloud.agent.api.to;
import java.net.URI;
import com.cloud.network.Network.BroadcastDomainType;
import com.cloud.network.Network.TrafficType;
import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.Networks.TrafficType;
/**
* Transfer object to transfer network settings.

View File

@ -1,148 +1,109 @@
/**
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
*
* This software is licensed under the GNU General Public License v3 or later.
*
* It is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.cloud.network;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Set;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.acl.ControlledEntity;
import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.Networks.Mode;
import com.cloud.network.Networks.TrafficType;
import com.cloud.offering.NetworkOffering.GuestIpType;
import com.cloud.utils.fsm.FiniteState;
import com.cloud.utils.fsm.StateMachine;
/**
* Network includes all of the enums used within networking.
*
* A NetworkProfile defines the specifics of a network
* owned by an account.
*/
public class Network {
/**
* Different ways to assign ip address to this network.
*/
public enum Mode {
None,
Static,
Dhcp,
ExternalDhcp;
};
public enum AddressFormat {
Ip4,
Ip6,
Mixed
public interface Network extends ControlledEntity {
enum Event {
ImplementNetwork,
DestroyNetwork,
OperationSucceeded,
OperationFailed;
}
enum State implements FiniteState<State, Event> {
Allocated("Indicates the network configuration is in allocated but not setup"),
Setup("Indicates the network configuration is setup"),
Implementing("Indicates the network configuration is being implemented"),
Implemented("Indicates the network configuration is in use"),
Destroying("Indicates the network configuration is being destroyed");
/**
* Different types of broadcast domains.
*/
public enum BroadcastDomainType {
Native(null, null),
Vlan("vlan", Integer.class),
Vswitch("vs", String.class),
LinkLocal(null, null),
Vnet("vnet", Long.class),
UnDecided(null, null);
private String scheme;
private Class<?> type;
private BroadcastDomainType(String scheme, Class<?> type) {
this.scheme = scheme;
this.type = type;
@Override
public StateMachine<State, Event> getStateMachine() {
return s_fsm;
}
@Override
public State getNextState(Event event) {
return s_fsm.getNextState(this, event);
}
@Override
public List<State> getFromStates(Event event) {
return s_fsm.getFromStates(this, event);
}
@Override
public Set<Event> getPossibleEvents() {
return s_fsm.getPossibleEvents(this);
}
/**
* @return scheme to be used in broadcast uri. Null indicates that this type does not have broadcast tags.
*/
public String scheme() {
return scheme;
}
/**
* @return type of the value in the broadcast uri. Null indicates that this type does not have broadcast tags.
*/
public Class<?> type() {
return type;
}
public <T> URI toUri(T value) {
try {
return new URI(scheme + "://" + value);
} catch (URISyntaxException e) {
throw new CloudRuntimeException("Unable to convert to broadcast URI: " + value);
}
}
};
/**
* Different types of network traffic in the data center.
*/
public enum TrafficType {
Public,
Guest,
Storage,
Management,
Control,
Vpn
};
public enum IsolationType {
None(null, null),
Ec2("ec2", String.class),
Vlan("vlan", Integer.class),
Vswitch("vs", String.class),
Undecided(null, null),
Vnet("vnet", Long.class);
private final String scheme;
private final Class<?> type;
private IsolationType(String scheme, Class<?> type) {
this.scheme = scheme;
this.type = type;
}
public String scheme() {
return scheme;
}
public Class<?> type() {
return type;
}
public <T> URI toUri(T value) {
try {
return new URI(scheme + "://" + value.toString());
} catch (URISyntaxException e) {
throw new CloudRuntimeException("Unable to convert to isolation type URI: " + value);
}
}
}
public enum BroadcastScheme {
Vlan("vlan"),
VSwitch("vswitch");
private String scheme;
private BroadcastScheme(String scheme) {
this.scheme = scheme;
}
String _description;
@Override
public String toString() {
return scheme;
public String getDescription() {
return _description;
}
private State(String description) {
_description = description;
}
private static StateMachine<State, Event> s_fsm = new StateMachine<State, Event>();
static {
s_fsm.addTransition(State.Allocated, Event.ImplementNetwork, State.Implementing);
s_fsm.addTransition(State.Implementing, Event.OperationSucceeded, State.Implemented);
s_fsm.addTransition(State.Implementing, Event.OperationFailed, State.Destroying);
s_fsm.addTransition(State.Implemented, Event.DestroyNetwork, State.Destroying);
s_fsm.addTransition(State.Destroying, Event.OperationSucceeded, State.Allocated);
s_fsm.addTransition(State.Destroying, Event.OperationFailed, State.Implemented);
}
}
/**
* @return id of the network profile. Null means the network profile is not from the database.
*/
long getId();
Mode getMode();
BroadcastDomainType getBroadcastDomainType();
TrafficType getTrafficType();
String getGateway();
String getCidr();
long getDataCenterId();
long getNetworkOfferingId();
State getState();
long getRelated();
URI getBroadcastUri();
String getDns1();
String getDns2();
GuestIpType getGuestType();
}

View File

@ -1,109 +0,0 @@
/**
*
*/
package com.cloud.network;
import java.net.URI;
import java.util.List;
import java.util.Set;
import com.cloud.acl.ControlledEntity;
import com.cloud.network.Network.BroadcastDomainType;
import com.cloud.network.Network.Mode;
import com.cloud.network.Network.TrafficType;
import com.cloud.offering.NetworkOffering.GuestIpType;
import com.cloud.utils.fsm.FiniteState;
import com.cloud.utils.fsm.StateMachine;
/**
* A NetworkProfile defines the specifics of a network
* owned by an account.
*/
public interface NetworkConfiguration extends ControlledEntity {
enum Event {
ImplementNetwork,
DestroyNetwork,
OperationSucceeded,
OperationFailed;
}
enum State implements FiniteState<State, Event> {
Allocated("Indicates the network configuration is in allocated but not setup"),
Setup("Indicates the network configuration is setup"),
Implementing("Indicates the network configuration is being implemented"),
Implemented("Indicates the network configuration is in use"),
Destroying("Indicates the network configuration is being destroyed");
@Override
public StateMachine<State, Event> getStateMachine() {
return s_fsm;
}
@Override
public State getNextState(Event event) {
return s_fsm.getNextState(this, event);
}
@Override
public List<State> getFromStates(Event event) {
return s_fsm.getFromStates(this, event);
}
@Override
public Set<Event> getPossibleEvents() {
return s_fsm.getPossibleEvents(this);
}
String _description;
@Override
public String getDescription() {
return _description;
}
private State(String description) {
_description = description;
}
private static StateMachine<State, Event> s_fsm = new StateMachine<State, Event>();
static {
s_fsm.addTransition(State.Allocated, Event.ImplementNetwork, State.Implementing);
s_fsm.addTransition(State.Implementing, Event.OperationSucceeded, State.Implemented);
s_fsm.addTransition(State.Implementing, Event.OperationFailed, State.Destroying);
s_fsm.addTransition(State.Implemented, Event.DestroyNetwork, State.Destroying);
s_fsm.addTransition(State.Destroying, Event.OperationSucceeded, State.Allocated);
s_fsm.addTransition(State.Destroying, Event.OperationFailed, State.Implemented);
}
}
/**
* @return id of the network profile. Null means the network profile is not from the database.
*/
long getId();
Mode getMode();
BroadcastDomainType getBroadcastDomainType();
TrafficType getTrafficType();
String getGateway();
String getCidr();
long getDataCenterId();
long getNetworkOfferingId();
State getState();
long getRelated();
URI getBroadcastUri();
String getDns1();
String getDns2();
GuestIpType getGuestType();
}

View File

@ -0,0 +1,148 @@
/**
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
*
* This software is licensed under the GNU General Public License v3 or later.
*
* It is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.cloud.network;
import java.net.URI;
import java.net.URISyntaxException;
import com.cloud.utils.exception.CloudRuntimeException;
/**
* Network includes all of the enums used within networking.
*
*/
public class Networks {
/**
* Different ways to assign ip address to this network.
*/
public enum Mode {
None,
Static,
Dhcp,
ExternalDhcp;
};
public enum AddressFormat {
Ip4,
Ip6,
Mixed
}
/**
* Different types of broadcast domains.
*/
public enum BroadcastDomainType {
Native(null, null),
Vlan("vlan", Integer.class),
Vswitch("vs", String.class),
LinkLocal(null, null),
Vnet("vnet", Long.class),
UnDecided(null, null);
private String scheme;
private Class<?> type;
private BroadcastDomainType(String scheme, Class<?> type) {
this.scheme = scheme;
this.type = type;
}
/**
* @return scheme to be used in broadcast uri. Null indicates that this type does not have broadcast tags.
*/
public String scheme() {
return scheme;
}
/**
* @return type of the value in the broadcast uri. Null indicates that this type does not have broadcast tags.
*/
public Class<?> type() {
return type;
}
public <T> URI toUri(T value) {
try {
return new URI(scheme + "://" + value);
} catch (URISyntaxException e) {
throw new CloudRuntimeException("Unable to convert to broadcast URI: " + value);
}
}
};
/**
* Different types of network traffic in the data center.
*/
public enum TrafficType {
Public,
Guest,
Storage,
Management,
Control,
Vpn
};
public enum IsolationType {
None(null, null),
Ec2("ec2", String.class),
Vlan("vlan", Integer.class),
Vswitch("vs", String.class),
Undecided(null, null),
Vnet("vnet", Long.class);
private final String scheme;
private final Class<?> type;
private IsolationType(String scheme, Class<?> type) {
this.scheme = scheme;
this.type = type;
}
public String scheme() {
return scheme;
}
public Class<?> type() {
return type;
}
public <T> URI toUri(T value) {
try {
return new URI(scheme + "://" + value.toString());
} catch (URISyntaxException e) {
throw new CloudRuntimeException("Unable to convert to isolation type URI: " + value);
}
}
}
public enum BroadcastScheme {
Vlan("vlan"),
VSwitch("vswitch");
private String scheme;
private BroadcastScheme(String scheme) {
this.scheme = scheme;
}
@Override
public String toString() {
return scheme;
}
}
}

View File

@ -7,7 +7,7 @@ import com.cloud.deploy.DeployDestination;
import com.cloud.deploy.DeploymentPlan;
import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
import com.cloud.network.NetworkConfiguration;
import com.cloud.network.Network;
import com.cloud.offering.NetworkOffering;
import com.cloud.user.Account;
import com.cloud.utils.component.Adapter;
@ -31,7 +31,7 @@ public interface NetworkGuru extends Adapter {
* @param owner owner of this network configuration.
* @return NetworkConfiguration
*/
NetworkConfiguration design(NetworkOffering offering, DeploymentPlan plan, NetworkConfiguration userSpecified, Account owner);
Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner);
/**
* allocate a nic in this network. This method implementation cannot take a long time as
@ -43,7 +43,7 @@ public interface NetworkGuru extends Adapter {
* @throws InsufficientVirtualNetworkCapcityException
* @throws InsufficientAddressCapacityException
*/
NicProfile allocate(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException;
NicProfile allocate(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException;
/**
* Fully implement the network configuration as specified.
@ -52,7 +52,7 @@ public interface NetworkGuru extends Adapter {
* @param destination where were deploying to.
* @return a fully implemented NetworkConfiguration.
*/
NetworkConfiguration implement(NetworkConfiguration config, NetworkOffering offering, DeployDestination destination, ReservationContext context);
Network implement(Network config, NetworkOffering offering, DeployDestination destination, ReservationContext context);
/**
* reserve a nic for this VM in this network.
@ -64,13 +64,13 @@ public interface NetworkGuru extends Adapter {
* @throws InsufficientVirtualNetworkCapcityException
* @throws InsufficientAddressCapacityException
*/
void reserve(NicProfile nic, NetworkConfiguration config, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException;
void reserve(NicProfile nic, Network config, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException;
boolean release(NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, String reservationId);
void deallocate(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm);
void deallocate(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm);
void destroy(NetworkConfiguration config, NetworkOffering offering);
void destroy(Network config, NetworkOffering offering);
/**
* Throw away the design.
@ -79,5 +79,5 @@ public interface NetworkGuru extends Adapter {
* @param owner
* @return
*/
boolean trash(NetworkConfiguration config, NetworkOffering offering, Account owner);
boolean trash(Network config, NetworkOffering offering, Account owner);
}

View File

@ -8,7 +8,7 @@ import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InsufficientNetworkCapacityException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.NetworkConfiguration;
import com.cloud.network.Network;
import com.cloud.offering.NetworkOffering;
import com.cloud.utils.component.Adapter;
import com.cloud.vm.NicProfile;
@ -26,13 +26,13 @@ public interface NetworkElement extends Adapter {
* @param offering network offering that originated the network configuration.
* @return true if network configuration is now usable; false if not; null if not handled by this element.
*/
boolean implement(NetworkConfiguration config, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException;
boolean implement(Network config, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException;
boolean prepare(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientNetworkCapacityException;
boolean prepare(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientNetworkCapacityException;
boolean release(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException;
boolean release(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException;
boolean shutdown(NetworkConfiguration config, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException;
boolean shutdown(Network config, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException;
boolean addRule();

View File

@ -17,7 +17,7 @@
*/
package com.cloud.offering;
import com.cloud.network.Network.TrafficType;
import com.cloud.network.Networks.TrafficType;
/**
* Describes network offering

View File

@ -17,7 +17,7 @@
*/
package com.cloud.vm;
import com.cloud.network.Network.Mode;
import com.cloud.network.Networks.Mode;
import com.cloud.resource.Resource;
@ -38,7 +38,7 @@ public interface Nic extends Resource {
/**
* @return network profile id that this
*/
long getNetworkConfigurationId();
long getNetworkId();
/**
* @return the vm instance id that this nic belongs to.

View File

@ -5,11 +5,11 @@ package com.cloud.vm;
import java.net.URI;
import com.cloud.network.Network.AddressFormat;
import com.cloud.network.Network.BroadcastDomainType;
import com.cloud.network.Network.Mode;
import com.cloud.network.Network.TrafficType;
import com.cloud.network.NetworkConfiguration;
import com.cloud.network.Networks.AddressFormat;
import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.Networks.Mode;
import com.cloud.network.Networks.TrafficType;
import com.cloud.network.Network;
import com.cloud.resource.Resource;
import com.cloud.resource.Resource.ReservationStrategy;
@ -182,7 +182,7 @@ public class NicProfile {
this.ip4Address = ip4Address;
}
public NicProfile(Nic nic, NetworkConfiguration network, URI broadcastUri, URI isolationUri) {
public NicProfile(Nic nic, Network network, URI broadcastUri, URI isolationUri) {
this.id = nic.getId();
this.gateway = network.getGateway();
this.mode = network.getMode();

View File

@ -155,8 +155,8 @@ import com.cloud.agent.api.to.VolumeTO;
import com.cloud.exception.InternalErrorException;
import com.cloud.host.Host.Type;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.network.Network.BroadcastDomainType;
import com.cloud.network.Network.TrafficType;
import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.Networks.TrafficType;
import com.cloud.resource.ServerResource;
import com.cloud.storage.Storage;
import com.cloud.storage.Storage.ImageFormat;

View File

@ -18,15 +18,15 @@
package com.cloud.network;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import com.google.gson.Gson;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import com.cloud.network.rules.FirewallRule;
/**
* A bean representing a IP Forwarding
@ -36,11 +36,11 @@ import com.google.gson.Gson;
*/
@Entity
@Table(name=("ip_forwarding"))
public class FirewallRuleVO {
public class FirewallRuleVO implements FirewallRule {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id")
private Long id;
private long id;
@Column(name="group_id")
private Long groupId;
@ -95,8 +95,14 @@ public class FirewallRuleVO {
fwRule.isForwarding(), fwRule.getAlgorithm());
}
public Long getId() {
@Override
public long getId() {
return id;
}
@Override
public String getXid() {
return Long.toHexString(id);
}
public Long getGroupId() {
@ -107,7 +113,8 @@ public class FirewallRuleVO {
this.groupId = groupId;
}
public String getPublicIpAddress() {
@Override
public String getPublicIpAddress() {
return publicIpAddress;
}
@ -115,7 +122,8 @@ public class FirewallRuleVO {
this.publicIpAddress = address;
}
public String getPublicPort() {
@Override
public String getPublicPort() {
return publicPort;
}
@ -123,7 +131,8 @@ public class FirewallRuleVO {
this.publicPort = port;
}
public String getPrivateIpAddress() {
@Override
public String getPrivateIpAddress() {
return privateIpAddress;
}
@ -131,7 +140,8 @@ public class FirewallRuleVO {
this.privateIpAddress = privateIpAddress;
}
public String getPrivatePort() {
@Override
public String getPrivatePort() {
return privatePort;
}

View File

@ -18,14 +18,14 @@
package com.cloud.network;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.SecondaryTable;
import javax.persistence.Table;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.SecondaryTable;
import javax.persistence.Table;
@Entity
@Table(name=("load_balancer"))
@ -35,7 +35,7 @@ public class LoadBalancerVO {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id")
private Long id;
private long id;
@Column(name="name")
private String name;
@ -76,7 +76,7 @@ public class LoadBalancerVO {
this.algorithm = algorithm;
}
public Long getId() {
public long getId() {
return id;
}

View File

@ -28,7 +28,7 @@ import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import com.cloud.network.Network.TrafficType;
import com.cloud.network.Networks.TrafficType;
import com.cloud.offering.NetworkOffering;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.utils.db.GenericDao;

View File

@ -83,8 +83,8 @@ public class DomainRouterVO extends VMInstanceVO implements DomainRouter {
@Column(name="guest_dc_mac_address")
private String guestZoneMacAddress;
@Column(name="network_configuration_id")
long networkConfigurationId;
@Column(name="network_id")
long networkId;
@Column(name="role")
@Enumerated(EnumType.STRING)
@ -149,7 +149,7 @@ public class DomainRouterVO extends VMInstanceVO implements DomainRouter {
long networkConfigurationId,
boolean haEnabled) {
super(id, serviceOfferingId, name, name, Type.DomainRouter, templateId, guestOSId, domainId, accountId, haEnabled);
this.networkConfigurationId = networkConfigurationId;
this.networkId = networkConfigurationId;
}
public void setGateway(String gateway) {
@ -172,8 +172,8 @@ public class DomainRouterVO extends VMInstanceVO implements DomainRouter {
this.guestMacAddress = routerMacAddress;
}
public long getNetworkConfigurationId() {
return networkConfigurationId;
public long getNetworkId() {
return networkId;
}
@Override

View File

@ -17,8 +17,8 @@
*/
package com.cloud.vm;
import com.cloud.network.Network.IsolationType;
import com.cloud.network.Network.Mode;
import com.cloud.network.Networks.IsolationType;
import com.cloud.network.Networks.Mode;
/**
* VirtualNetwork describes from a management level the

View File

@ -117,7 +117,7 @@ public class DomainRouterDaoImpl extends GenericDaoBase<DomainRouterVO, Long> im
StateChangeSearch.done();
NetworkConfigSearch = createSearchBuilder();
NetworkConfigSearch.and("network", NetworkConfigSearch.entity().getNetworkConfigurationId(), SearchCriteria.Op.EQ);
NetworkConfigSearch.and("network", NetworkConfigSearch.entity().getNetworkId(), SearchCriteria.Op.EQ);
_updateTimeAttr = _allAttributes.get("updateTime");
assert _updateTimeAttr != null : "Couldn't get this updateTime attribute";

View File

@ -69,8 +69,8 @@ import com.cloud.host.Status.Event;
import com.cloud.network.FirewallRuleVO;
import com.cloud.network.IPAddressVO;
import com.cloud.network.LoadBalancerVO;
import com.cloud.network.Network.TrafficType;
import com.cloud.network.NetworkConfiguration;
import com.cloud.network.Networks.TrafficType;
import com.cloud.network.Network;
import com.cloud.offering.NetworkOffering.GuestIpType;
import com.cloud.offering.ServiceOffering;
import com.cloud.server.Criteria;
@ -1152,8 +1152,8 @@ public class ApiResponseHelper {
List<? extends Nic> nics = BaseCmd._networkMgr.getNics(userVm);
for (Nic singleNic : nics) {
long configId = singleNic.getNetworkConfigurationId();
NetworkConfiguration networkConf = BaseCmd._networkMgr.getNetworkConfiguration(configId);
long configId = singleNic.getNetworkId();
Network networkConf = BaseCmd._networkMgr.getNetworkConfiguration(configId);
if (networkConf.getTrafficType() == TrafficType.Guest) {
userVmResponse.setIpAddress(singleNic.getIp4Address());
}
@ -1195,8 +1195,8 @@ public class ApiResponseHelper {
List<? extends Nic> nics = BaseCmd._networkMgr.getNics(router);
for (Nic singleNic : nics) {
long configId = singleNic.getNetworkConfigurationId();
NetworkConfiguration networkConf = BaseCmd._networkMgr.getNetworkConfiguration(configId);
long configId = singleNic.getNetworkId();
Network networkConf = BaseCmd._networkMgr.getNetworkConfiguration(configId);
if (networkConf.getTrafficType() == TrafficType.Guest) {
routerResponse.setGuestIpAddress(singleNic.getIp4Address());
@ -1281,8 +1281,8 @@ public class ApiResponseHelper {
List<? extends Nic> nics = BaseCmd._networkMgr.getNics(systemVM);
for (Nic singleNic : nics) {
long configId = singleNic.getNetworkConfigurationId();
NetworkConfiguration networkConf = BaseCmd._networkMgr.getNetworkConfiguration(configId);
long configId = singleNic.getNetworkId();
Network networkConf = BaseCmd._networkMgr.getNetworkConfiguration(configId);
if (networkConf.getTrafficType() == TrafficType.Management) {
vmResponse.setPrivateIp(singleNic.getIp4Address());

View File

@ -63,7 +63,7 @@ import com.cloud.network.dao.FirewallRulesDaoImpl;
import com.cloud.network.dao.IPAddressDaoImpl;
import com.cloud.network.dao.LoadBalancerDaoImpl;
import com.cloud.network.dao.LoadBalancerVMMapDaoImpl;
import com.cloud.network.dao.NetworkConfigurationDaoImpl;
import com.cloud.network.dao.NetworkDaoImpl;
import com.cloud.network.dao.NetworkRuleConfigDaoImpl;
import com.cloud.network.dao.RemoteAccessVpnDaoImpl;
import com.cloud.network.dao.VpnUserDaoImpl;
@ -214,7 +214,7 @@ public class DefaultComponentLibrary implements ComponentLibrary {
addDao("PreallocatedLunDao", PreallocatedLunDaoImpl.class);
addDao("ClusterDao", ClusterDaoImpl.class);
addDao("CertificateDao", CertificateDaoImpl.class);
addDao("NetworkConfigurationDao", NetworkConfigurationDaoImpl.class);
addDao("NetworkConfigurationDao", NetworkDaoImpl.class);
addDao("NetworkOfferingDao", NetworkOfferingDaoImpl.class);
addDao("NicDao", NicDaoImpl.class);
addDao("InstanceGroupDao", InstanceGroupDaoImpl.class);

View File

@ -111,8 +111,8 @@ import com.cloud.info.RunningHostInfoAgregator.ZoneHostInfo;
import com.cloud.maid.StackMaid;
import com.cloud.network.IpAddrAllocator;
import com.cloud.network.IpAddrAllocator.networkInfo;
import com.cloud.network.Network.TrafficType;
import com.cloud.network.NetworkConfigurationVO;
import com.cloud.network.Networks.TrafficType;
import com.cloud.network.NetworkVO;
import com.cloud.network.NetworkManager;
import com.cloud.network.dao.IPAddressDao;
import com.cloud.offering.NetworkOffering;
@ -1067,13 +1067,13 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, VirtualMach
List<NetworkOfferingVO> defaultOffering = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemVmPublicNetwork);
List<NetworkOfferingVO> offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemVmControlNetwork, NetworkOfferingVO.SystemVmManagementNetwork);
List<Pair<NetworkConfigurationVO, NicProfile>> networks = new ArrayList<Pair<NetworkConfigurationVO, NicProfile>>(offerings.size() + 1);
List<Pair<NetworkVO, NicProfile>> networks = new ArrayList<Pair<NetworkVO, NicProfile>>(offerings.size() + 1);
NicProfile defaultNic = new NicProfile();
defaultNic.setDefaultNic(true);
defaultNic.setDeviceId(2);
networks.add(new Pair<NetworkConfigurationVO, NicProfile>(_networkMgr.setupNetworkConfiguration(systemAcct, defaultOffering.get(0), plan).get(0), defaultNic));
networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetworkConfiguration(systemAcct, defaultOffering.get(0), plan).get(0), defaultNic));
for (NetworkOfferingVO offering : offerings) {
networks.add(new Pair<NetworkConfigurationVO, NicProfile>(_networkMgr.setupNetworkConfiguration(systemAcct, offering, plan).get(0), null));
networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetworkConfiguration(systemAcct, offering, plan).get(0), null));
}
ConsoleProxyVO proxy = new ConsoleProxyVO(id, _serviceOffering.getId(), name, _template.getId(), _template.getGuestOSId(), dataCenterId, systemAcct.getDomainId(), systemAcct.getId(), 0);
try {

View File

@ -22,8 +22,8 @@ public class NetworkAccountVO implements OwnedBy {
@Column(name="account_id")
long accountId;
@Column(name="network_configuration_id")
long networkConfigurationId;
@Column(name="network_id")
long networkId;
@Column(name="is_owner")
boolean owner;
@ -31,8 +31,8 @@ public class NetworkAccountVO implements OwnedBy {
protected NetworkAccountVO() {
}
public NetworkAccountVO(long networkConfigurationId, long accountId, boolean owner) {
this.networkConfigurationId = networkConfigurationId;
public NetworkAccountVO(long networkId, long accountId, boolean owner) {
this.networkId = networkId;
this.accountId = accountId;
this.owner = owner;
}
@ -42,8 +42,8 @@ public class NetworkAccountVO implements OwnedBy {
return accountId;
}
public long getNetworkConfigurationId() {
return networkConfigurationId;
public long getNetworkId() {
return networkId;
}
public boolean isOwner() {

View File

@ -278,12 +278,12 @@ public interface NetworkManager {
public boolean disassociateIpAddress(DisassociateIPAddrCmd cmd);
List<NetworkConfigurationVO> setupNetworkConfiguration(Account owner, NetworkOfferingVO offering, DeploymentPlan plan);
List<NetworkConfigurationVO> setupNetworkConfiguration(Account owner, NetworkOfferingVO offering, NetworkConfiguration predefined, DeploymentPlan plan);
List<NetworkVO> setupNetworkConfiguration(Account owner, NetworkOfferingVO offering, DeploymentPlan plan);
List<NetworkVO> setupNetworkConfiguration(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan plan);
List<NetworkOfferingVO> getSystemAccountNetworkOfferings(String... offeringNames);
void allocate(VirtualMachineProfile<? extends VMInstanceVO> vm, List<Pair<NetworkConfigurationVO, NicProfile>> networks) throws InsufficientCapacityException;
void allocate(VirtualMachineProfile<? extends VMInstanceVO> vm, List<Pair<NetworkVO, NicProfile>> networks) throws InsufficientCapacityException;
void prepare(VirtualMachineProfile<? extends VMInstanceVO> profile, DeployDestination dest, ReservationContext context) throws InsufficientNetworkCapacityException, ConcurrentOperationException, ResourceUnavailableException;
void release(VirtualMachineProfile<? extends VMInstanceVO> vmProfile);
@ -293,9 +293,9 @@ public interface NetworkManager {
List<AccountVO> getAccountsUsingNetworkConfiguration(long configurationId);
AccountVO getNetworkConfigurationOwner(long configurationId);
List<NetworkConfigurationVO> getNetworkConfigurationsforOffering(long offeringId, long dataCenterId, long accountId);
List<NetworkVO> getNetworkConfigurationsforOffering(long offeringId, long dataCenterId, long accountId);
List<NetworkConfigurationVO> setupNetworkConfiguration(Account owner, ServiceOfferingVO offering, DeploymentPlan plan);
List<NetworkVO> setupNetworkConfiguration(Account owner, ServiceOfferingVO offering, DeploymentPlan plan);
String assignSourceNatIpAddress(Account account, DataCenter dc) throws InsufficientAddressCapacityException;
/**
@ -329,7 +329,7 @@ public interface NetworkManager {
boolean removeVpnUser(RemoveVpnUserCmd cmd) throws ConcurrentOperationException;
NetworkConfiguration getNetworkConfiguration(long id);
Network getNetworkConfiguration(long id);
String getNextAvailableMacAddressInNetwork(long networkConfigurationId) throws InsufficientAddressCapacityException;
FirewallRuleVO createIpForwardingRuleInDb(String ipAddr, Long virtualMachineId) throws ServerApiException;

View File

@ -97,13 +97,13 @@ import com.cloud.exception.ResourceUnavailableException;
import com.cloud.host.HostVO;
import com.cloud.host.dao.HostDao;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.network.Network.TrafficType;
import com.cloud.network.Networks.TrafficType;
import com.cloud.network.configuration.NetworkGuru;
import com.cloud.network.dao.FirewallRulesDao;
import com.cloud.network.dao.IPAddressDao;
import com.cloud.network.dao.LoadBalancerDao;
import com.cloud.network.dao.LoadBalancerVMMapDao;
import com.cloud.network.dao.NetworkConfigurationDao;
import com.cloud.network.dao.NetworkDao;
import com.cloud.network.dao.NetworkRuleConfigDao;
import com.cloud.network.dao.RemoteAccessVpnDao;
import com.cloud.network.dao.VpnUserDao;
@ -204,7 +204,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
@Inject AccountVlanMapDao _accountVlanMapDao;
@Inject UserStatisticsDao _statsDao = null;
@Inject NetworkOfferingDao _networkOfferingDao = null;
@Inject NetworkConfigurationDao _networkConfigDao = null;
@Inject NetworkDao _networkConfigDao = null;
@Inject NicDao _nicDao;
@Inject GuestOSDao _guestOSDao = null;
@Inject RemoteAccessVpnDao _remoteAccessVpnDao = null;
@ -1264,7 +1264,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
for (FirewallRuleVO fwRule : existingRulesOnPubIp) {
if (!( (fwRule.isForwarding() == false) &&
(fwRule.getGroupId() != null) &&
(fwRule.getGroupId() == loadBalancer.getId().longValue()) )) {
(fwRule.getGroupId() == loadBalancer.getId()) )) {
// if the rule is not for the current load balancer, check to see if the private IP is our target IP,
// in which case we have a conflict
if (fwRule.getPublicPort().equals(loadBalancer.getPublicPort())) {
@ -1348,15 +1348,13 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
*/
for (FirewallRuleVO updatedRule : updatedRules) {
if (updatedRule.getId() == null) {
_rulesDao.persist(updatedRule);
_rulesDao.persist(updatedRule);
description = "created new " + ruleName + " rule [" + updatedRule.getPublicIpAddress() + ":"
+ updatedRule.getPublicPort() + "]->[" + updatedRule.getPrivateIpAddress() + ":"
+ updatedRule.getPrivatePort() + "]" + " " + updatedRule.getProtocol();
description = "created new " + ruleName + " rule [" + updatedRule.getPublicIpAddress() + ":"
+ updatedRule.getPublicPort() + "]->[" + updatedRule.getPrivateIpAddress() + ":"
+ updatedRule.getPrivatePort() + "]" + " " + updatedRule.getProtocol();
EventUtils.saveEvent(UserContext.current().getUserId(), loadBalancer.getAccountId(), level, type, description);
}
EventUtils.saveEvent(UserContext.current().getUserId(), loadBalancer.getAccountId(), level, type, description);
}
return true;
} else {
@ -1563,7 +1561,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
event.setType(EventTypes.EVENT_LOAD_BALANCER_DELETE);
String params = "id="+loadBalancer.getId();
event.setParameters(params);
event.setDescription("Successfully deleted load balancer " + loadBalancer.getId().toString());
event.setDescription("Successfully deleted load balancer " + loadBalancer.getId());
event.setLevel(EventVO.LEVEL_INFO);
_eventDao.persist(event);
}
@ -1722,7 +1720,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
AccountsUsingNetworkConfigurationSearch = _accountDao.createSearchBuilder();
SearchBuilder<NetworkAccountVO> networkAccountSearch = _networkConfigDao.createSearchBuilderForAccount();
AccountsUsingNetworkConfigurationSearch.join("nc", networkAccountSearch, AccountsUsingNetworkConfigurationSearch.entity().getId(), networkAccountSearch.entity().getAccountId(), JoinType.INNER);
networkAccountSearch.and("config", networkAccountSearch.entity().getNetworkConfigurationId(), SearchCriteria.Op.EQ);
networkAccountSearch.and("config", networkAccountSearch.entity().getNetworkId(), SearchCriteria.Op.EQ);
networkAccountSearch.and("owner", networkAccountSearch.entity().isOwner(), SearchCriteria.Op.EQ);
AccountsUsingNetworkConfigurationSearch.done();
@ -1796,13 +1794,13 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
@Override
public List<NetworkConfigurationVO> setupNetworkConfiguration(Account owner, NetworkOfferingVO offering, DeploymentPlan plan) {
public List<NetworkVO> setupNetworkConfiguration(Account owner, NetworkOfferingVO offering, DeploymentPlan plan) {
return setupNetworkConfiguration(owner, offering, null, plan);
}
@Override
public List<NetworkConfigurationVO> setupNetworkConfiguration(Account owner, NetworkOfferingVO offering, NetworkConfiguration predefined, DeploymentPlan plan) {
List<NetworkConfigurationVO> configs = _networkConfigDao.listBy(owner.getId(), offering.getId(), plan.getDataCenterId());
public List<NetworkVO> setupNetworkConfiguration(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan plan) {
List<NetworkVO> configs = _networkConfigDao.listBy(owner.getId(), offering.getId(), plan.getDataCenterId());
if (configs.size() > 0) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Found existing network configuration for offering " + offering + ": " + configs.get(0));
@ -1810,19 +1808,19 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
return configs;
}
configs = new ArrayList<NetworkConfigurationVO>();
configs = new ArrayList<NetworkVO>();
long related = -1;
for (NetworkGuru guru : _networkGurus) {
NetworkConfiguration config = guru.design(offering, plan, predefined, owner);
Network config = guru.design(offering, plan, predefined, owner);
if (config == null) {
continue;
}
if (config.getId() != -1) {
if (config instanceof NetworkConfigurationVO) {
configs.add((NetworkConfigurationVO)config);
if (config instanceof NetworkVO) {
configs.add((NetworkVO)config);
} else {
configs.add(_networkConfigDao.findById(config.getId()));
}
@ -1834,7 +1832,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
related = id;
}
NetworkConfigurationVO vo = new NetworkConfigurationVO(id, config, offering.getId(), plan.getDataCenterId(), guru.getName(), owner.getDomainId(), owner.getId(), related);
NetworkVO vo = new NetworkVO(id, config, offering.getId(), plan.getDataCenterId(), guru.getName(), owner.getDomainId(), owner.getId(), related);
configs.add(_networkConfigDao.persist(vo));
}
@ -1859,7 +1857,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
@Override @DB
public void allocate(VirtualMachineProfile<? extends VMInstanceVO> vm, List<Pair<NetworkConfigurationVO, NicProfile>> networks) throws InsufficientCapacityException {
public void allocate(VirtualMachineProfile<? extends VMInstanceVO> vm, List<Pair<NetworkVO, NicProfile>> networks) throws InsufficientCapacityException {
Transaction txn = Transaction.currentTxn();
txn.start();
@ -1871,8 +1869,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
List<NicVO> nics = new ArrayList<NicVO>(networks.size());
NicVO defaultNic = null;
for (Pair<NetworkConfigurationVO, NicProfile> network : networks) {
NetworkConfigurationVO config = network.first();
for (Pair<NetworkVO, NicProfile> network : networks) {
NetworkVO config = network.first();
NetworkGuru concierge = _networkGurus.get(config.getGuruName());
NicProfile requested = network.second();
NicProfile profile = concierge.allocate(config, requested, vm);
@ -1952,7 +1950,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
return deviceId;
}
protected NicTO toNicTO(NicVO nic, NicProfile profile, NetworkConfigurationVO config) {
protected NicTO toNicTO(NicVO nic, NicProfile profile, NetworkVO config) {
NicTO to = new NicTO();
to.setDeviceId(nic.getDeviceId());
to.setBroadcastType(config.getBroadcastDomainType());
@ -1983,18 +1981,18 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
@DB
protected Pair<NetworkGuru, NetworkConfigurationVO> implementNetworkConfiguration(long configId, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientAddressCapacityException {
protected Pair<NetworkGuru, NetworkVO> implementNetworkConfiguration(long configId, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientAddressCapacityException {
Transaction.currentTxn();
Pair<NetworkGuru, NetworkConfigurationVO> implemented = new Pair<NetworkGuru, NetworkConfigurationVO>(null, null);
Pair<NetworkGuru, NetworkVO> implemented = new Pair<NetworkGuru, NetworkVO>(null, null);
NetworkConfigurationVO config = _networkConfigDao.acquireInLockTable(configId);
NetworkVO config = _networkConfigDao.acquireInLockTable(configId);
if (config == null) {
throw new ConcurrentOperationException("Unable to acquire network configuration: " + configId);
}
try {
NetworkGuru guru = _networkGurus.get(config.getGuruName());
if (config.getState() == NetworkConfiguration.State.Implemented || config.getState() == NetworkConfiguration.State.Setup) {
if (config.getState() == Network.State.Implemented || config.getState() == Network.State.Setup) {
implemented.set(guru, config);
return implemented;
}
@ -2005,14 +2003,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
NetworkOfferingVO offering = _networkOfferingDao.findById(config.getNetworkOfferingId());
NetworkConfiguration result = guru.implement(config, offering, dest, context);
Network result = guru.implement(config, offering, dest, context);
config.setCidr(result.getCidr());
config.setBroadcastUri(result.getBroadcastUri());
config.setGateway(result.getGateway());
config.setDns1(result.getDns1());
config.setDns2(result.getDns2());
config.setMode(result.getMode());
config.setState(NetworkConfiguration.State.Implemented);
config.setState(Network.State.Implemented);
_networkConfigDao.update(configId, config);
for (NetworkElement element : _networkElements) {
@ -2040,9 +2038,9 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
public void prepare(VirtualMachineProfile<? extends VMInstanceVO> vmProfile, DeployDestination dest, ReservationContext context) throws InsufficientNetworkCapacityException, ConcurrentOperationException, ResourceUnavailableException {
List<NicVO> nics = _nicDao.listBy(vmProfile.getId());
for (NicVO nic : nics) {
Pair<NetworkGuru, NetworkConfigurationVO> implemented = implementNetworkConfiguration(nic.getNetworkConfigurationId(), dest, context);
Pair<NetworkGuru, NetworkVO> implemented = implementNetworkConfiguration(nic.getNetworkId(), dest, context);
NetworkGuru concierge = implemented.first();
NetworkConfigurationVO config = implemented.second();
NetworkVO config = implemented.second();
NicProfile profile = null;
if (nic.getReservationStrategy() == ReservationStrategy.Start) {
nic.setState(Resource.State.Reserving);
@ -2083,7 +2081,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
public void release(VirtualMachineProfile<? extends VMInstanceVO> vmProfile) {
List<NicVO> nics = _nicDao.listBy(vmProfile.getId());
for (NicVO nic : nics) {
NetworkConfigurationVO config = _networkConfigDao.findById(nic.getNetworkConfigurationId());
NetworkVO config = _networkConfigDao.findById(nic.getNetworkId());
if (nic.getReservationStrategy() == ReservationStrategy.Start) {
NetworkGuru concierge = _networkGurus.get(config.getGuruName());
nic.setState(Resource.State.Releasing);
@ -2345,7 +2343,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
// make sure the name's not already in use
if (name != null) {
LoadBalancerVO existingLB = _loadBalancerDao.findByAccountAndName(loadBalancer.getAccountId(), name);
if ((existingLB != null) && (existingLB.getId().longValue() != loadBalancer.getId().longValue())) {
if ((existingLB != null) && (existingLB.getId() != loadBalancer.getId())) {
throw new InvalidParameterValueException("Unable to update load balancer " + loadBalancer.getName() + " with new name " + name + ", the name is already in use.");
}
}
@ -2651,12 +2649,12 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
@Override
public List<NetworkConfigurationVO> getNetworkConfigurationsforOffering(long offeringId, long dataCenterId, long accountId) {
public List<NetworkVO> getNetworkConfigurationsforOffering(long offeringId, long dataCenterId, long accountId) {
return _networkConfigDao.getNetworkConfigurationsForOffering(offeringId, dataCenterId, accountId);
}
@Override
public List<NetworkConfigurationVO> setupNetworkConfiguration(Account owner, ServiceOfferingVO offering, DeploymentPlan plan) {
public List<NetworkVO> setupNetworkConfiguration(Account owner, ServiceOfferingVO offering, DeploymentPlan plan) {
NetworkOfferingVO networkOffering = _networkOfferingDao.findByServiceOffering(offering);
return setupNetworkConfiguration(owner, networkOffering, plan);
}
@ -2991,13 +2989,13 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
public String getNextAvailableMacAddressInNetwork(long networkConfigurationId) throws InsufficientAddressCapacityException {
String mac = _networkConfigDao.getNextAvailableMacAddress(networkConfigurationId);
if (mac == null) {
throw new InsufficientAddressCapacityException("Unable to create another mac address", NetworkConfiguration.class, networkConfigurationId);
throw new InsufficientAddressCapacityException("Unable to create another mac address", Network.class, networkConfigurationId);
}
return mac;
}
@Override @DB
public NetworkConfiguration getNetworkConfiguration(long id) {
public Network getNetworkConfiguration(long id) {
return _networkConfigDao.findById(id);
}

View File

@ -28,9 +28,9 @@ import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.persistence.Transient;
import com.cloud.network.Network.BroadcastDomainType;
import com.cloud.network.Network.Mode;
import com.cloud.network.Network.TrafficType;
import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.Networks.Mode;
import com.cloud.network.Networks.TrafficType;
import com.cloud.offering.NetworkOffering.GuestIpType;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.net.NetUtils;
@ -40,10 +40,10 @@ import com.cloud.utils.net.NetUtils;
*
*/
@Entity
@Table(name="network_configurations")
public class NetworkConfigurationVO implements NetworkConfiguration {
@Table(name="networks")
public class NetworkVO implements Network {
@Id
@TableGenerator(name="network_configuration_sq", table="sequence", pkColumnName="name", valueColumnName="value", pkColumnValue="network_configuration_seq", allocationSize=1)
@TableGenerator(name="networks_sq", table="sequence", pkColumnName="name", valueColumnName="value", pkColumnValue="networks_seq", allocationSize=1)
@Column(name="id")
long id;
@ -99,7 +99,7 @@ public class NetworkConfigurationVO implements NetworkConfiguration {
@Column(name="set_fields")
long setFields;
@TableGenerator(name="mac_address_seq", table="op_network_configurations", pkColumnName="id", valueColumnName="mac_address_seq", allocationSize=1)
@TableGenerator(name="mac_address_seq", table="op_networks", pkColumnName="id", valueColumnName="mac_address_seq", allocationSize=1)
@Transient
long macAddress = 1;
@ -109,7 +109,7 @@ public class NetworkConfigurationVO implements NetworkConfiguration {
@Column(name="dns2")
String dns2;
public NetworkConfigurationVO() {
public NetworkVO() {
}
/**
@ -120,7 +120,7 @@ public class NetworkConfigurationVO implements NetworkConfiguration {
* @param networkOfferingId
* @param dataCenterId
*/
public NetworkConfigurationVO(TrafficType trafficType, GuestIpType guestType, Mode mode, BroadcastDomainType broadcastDomainType, long networkOfferingId, long dataCenterId) {
public NetworkVO(TrafficType trafficType, GuestIpType guestType, Mode mode, BroadcastDomainType broadcastDomainType, long networkOfferingId, long dataCenterId) {
this.trafficType = trafficType;
this.mode = mode;
this.broadcastDomainType = broadcastDomainType;
@ -131,7 +131,7 @@ public class NetworkConfigurationVO implements NetworkConfiguration {
this.guestType = guestType;
}
public NetworkConfigurationVO(long id, NetworkConfiguration that, long offeringId, long dataCenterId, String guruName, long domainId, long accountId, long related) {
public NetworkVO(long id, Network that, long offeringId, long dataCenterId, String guruName, long domainId, long accountId, long related) {
this(id, that.getTrafficType(), that.getGuestType(), that.getMode(), that.getBroadcastDomainType(), offeringId, dataCenterId, domainId, accountId, related);
this.gateway = that.getGateway();
this.dns1 = that.getDns1();
@ -154,7 +154,7 @@ public class NetworkConfigurationVO implements NetworkConfiguration {
* @param domainId
* @param accountId
*/
public NetworkConfigurationVO(long id, TrafficType trafficType, GuestIpType guestType, Mode mode, BroadcastDomainType broadcastDomainType, long networkOfferingId, long dataCenterId, long domainId, long accountId, long related) {
public NetworkVO(long id, TrafficType trafficType, GuestIpType guestType, Mode mode, BroadcastDomainType broadcastDomainType, long networkOfferingId, long dataCenterId, long domainId, long accountId, long related) {
this(trafficType, guestType, mode, broadcastDomainType, networkOfferingId, dataCenterId);
this.domainId = domainId;
this.accountId = accountId;
@ -303,10 +303,10 @@ public class NetworkConfigurationVO implements NetworkConfiguration {
@Override
public boolean equals(Object obj) {
if (!(obj instanceof NetworkConfigurationVO)) {
if (!(obj instanceof NetworkVO)) {
return false;
}
NetworkConfigurationVO that = (NetworkConfigurationVO)obj;
NetworkVO that = (NetworkVO)obj;
if (this.trafficType != that.trafficType) {
return false;
}

View File

@ -17,12 +17,12 @@ import com.cloud.deploy.DeployDestination;
import com.cloud.deploy.DeploymentPlan;
import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
import com.cloud.network.Network.AddressFormat;
import com.cloud.network.Network.BroadcastDomainType;
import com.cloud.network.Network.Mode;
import com.cloud.network.Network.TrafficType;
import com.cloud.network.NetworkConfiguration;
import com.cloud.network.NetworkConfigurationVO;
import com.cloud.network.Networks.AddressFormat;
import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.Networks.Mode;
import com.cloud.network.Networks.TrafficType;
import com.cloud.network.Network;
import com.cloud.network.NetworkVO;
import com.cloud.offering.NetworkOffering;
import com.cloud.resource.Resource.ReservationStrategy;
import com.cloud.user.Account;
@ -44,12 +44,12 @@ public class ControlNetworkGuru extends AdapterBase implements NetworkGuru {
String _gateway;
@Override
public NetworkConfiguration design(NetworkOffering offering, DeploymentPlan plan, NetworkConfiguration specifiedConfig, Account owner) {
public Network design(NetworkOffering offering, DeploymentPlan plan, Network specifiedConfig, Account owner) {
if (offering.getTrafficType() != TrafficType.Control) {
return null;
}
NetworkConfigurationVO config = new NetworkConfigurationVO(offering.getTrafficType(), offering.getGuestIpType(), Mode.Static, BroadcastDomainType.LinkLocal, offering.getId(), plan.getDataCenterId());
NetworkVO config = new NetworkVO(offering.getTrafficType(), offering.getGuestIpType(), Mode.Static, BroadcastDomainType.LinkLocal, offering.getId(), plan.getDataCenterId());
config.setCidr(_cidr);
config.setGateway(_gateway);
@ -61,7 +61,7 @@ public class ControlNetworkGuru extends AdapterBase implements NetworkGuru {
}
@Override
public NicProfile allocate(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException,
public NicProfile allocate(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException,
InsufficientAddressCapacityException {
if (config.getTrafficType() != TrafficType.Control) {
return null;
@ -75,11 +75,11 @@ public class ControlNetworkGuru extends AdapterBase implements NetworkGuru {
}
@Override
public void deallocate(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) {
public void deallocate(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) {
}
@Override
public void reserve(NicProfile nic, NetworkConfiguration config, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapcityException,
public void reserve(NicProfile nic, Network config, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapcityException,
InsufficientAddressCapacityException {
assert nic.getTrafficType() == TrafficType.Control;
@ -106,13 +106,13 @@ public class ControlNetworkGuru extends AdapterBase implements NetworkGuru {
}
@Override
public NetworkConfiguration implement(NetworkConfiguration config, NetworkOffering offering, DeployDestination destination, ReservationContext context) {
public Network implement(Network config, NetworkOffering offering, DeployDestination destination, ReservationContext context) {
assert config.getTrafficType() == TrafficType.Control : "Why are you sending this configuration to me " + config;
return config;
}
@Override
public void destroy(NetworkConfiguration config, NetworkOffering offering) {
public void destroy(Network config, NetworkOffering offering) {
assert false : "Destroying a link local...Either you're out of your mind or something has changed.";
}
@ -141,7 +141,7 @@ public class ControlNetworkGuru extends AdapterBase implements NetworkGuru {
}
@Override
public boolean trash(NetworkConfiguration config, NetworkOffering offering, Account owner) {
public boolean trash(Network config, NetworkOffering offering, Account owner) {
return true;
}

View File

@ -32,12 +32,12 @@ import com.cloud.deploy.DeploymentPlan;
import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.network.Network.BroadcastDomainType;
import com.cloud.network.Network.Mode;
import com.cloud.network.Network.TrafficType;
import com.cloud.network.NetworkConfiguration;
import com.cloud.network.NetworkConfiguration.State;
import com.cloud.network.NetworkConfigurationVO;
import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.Networks.Mode;
import com.cloud.network.Networks.TrafficType;
import com.cloud.network.Network;
import com.cloud.network.Network.State;
import com.cloud.network.NetworkVO;
import com.cloud.network.NetworkManager;
import com.cloud.offering.NetworkOffering;
import com.cloud.offering.NetworkOffering.GuestIpType;
@ -69,7 +69,7 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
}
@Override
public NetworkConfiguration design(NetworkOffering offering, DeploymentPlan plan, NetworkConfiguration userSpecified, Account owner) {
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
if (offering.getTrafficType() != TrafficType.Guest) {
return null;
}
@ -86,7 +86,7 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
}
DataCenterVO dc = _dcDao.findById(plan.getDataCenterId());
NetworkConfigurationVO config = new NetworkConfigurationVO(offering.getTrafficType(), offering.getGuestIpType(), mode, broadcastType, offering.getId(), plan.getDataCenterId());
NetworkVO config = new NetworkVO(offering.getTrafficType(), offering.getGuestIpType(), mode, broadcastType, offering.getId(), plan.getDataCenterId());
if (userSpecified != null) {
if ((userSpecified.getCidr() == null && userSpecified.getGateway() != null) ||
(userSpecified.getCidr() != null && userSpecified.getGateway() == null)) {
@ -122,15 +122,15 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
}
@Override
public void deallocate(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) {
public void deallocate(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) {
}
@Override
public NetworkConfiguration implement(NetworkConfiguration config, NetworkOffering offering, DeployDestination dest, ReservationContext context) {
public Network implement(Network config, NetworkOffering offering, DeployDestination dest, ReservationContext context) {
assert (config.getState() == State.Allocated) : "Why implement are we implementing " + config;
long dcId = dest.getDataCenter().getId();
NetworkConfigurationVO implemented = new NetworkConfigurationVO(config.getTrafficType(), config.getGuestType(), config.getMode(), config.getBroadcastDomainType(), config.getNetworkOfferingId(), config.getDataCenterId());
NetworkVO implemented = new NetworkVO(config.getTrafficType(), config.getGuestType(), config.getMode(), config.getBroadcastDomainType(), config.getNetworkOfferingId(), config.getDataCenterId());
if (config.getBroadcastUri() == null) {
String vnet = _dcDao.allocateVnet(dcId, config.getAccountId(), context.getReservationId());
@ -159,7 +159,7 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
}
@Override
public NicProfile allocate(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm)
public NicProfile allocate(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm)
throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
if (config.getTrafficType() != TrafficType.Guest) {
return null;
@ -174,7 +174,7 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
if (nic.getMacAddress() == null) {
nic.setMacAddress(_networkMgr.getNextAvailableMacAddressInNetwork(config.getId()));
if (nic.getMacAddress() == null) {
throw new InsufficientAddressCapacityException("Unable to allocate more mac addresses", NetworkConfiguration.class, config.getId());
throw new InsufficientAddressCapacityException("Unable to allocate more mac addresses", Network.class, config.getId());
}
}
@ -182,7 +182,7 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
}
@DB
protected String acquireGuestIpAddress(NetworkConfiguration config) {
protected String acquireGuestIpAddress(Network config) {
List<String> ips = _nicDao.listIpAddressInNetworkConfiguration(config.getId());
String[] cidr = config.getCidr().split("/");
Set<Long> allPossibleIps = NetUtils.getAllIpsFromCidr(cidr[0], Integer.parseInt(cidr[1]));
@ -201,7 +201,7 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
}
@Override
public void reserve(NicProfile nic, NetworkConfiguration config, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapcityException,
public void reserve(NicProfile nic, Network config, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapcityException,
InsufficientAddressCapacityException {
assert (nic.getReservationStrategy() == ReservationStrategy.Start) : "What can I do for nics that are not allocated at start? ";
@ -222,12 +222,12 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
}
@Override
public void destroy(NetworkConfiguration config, NetworkOffering offering) {
public void destroy(Network config, NetworkOffering offering) {
config.getBroadcastUri();
}
@Override
public boolean trash(NetworkConfiguration config, NetworkOffering offering, Account owner) {
public boolean trash(Network config, NetworkOffering offering, Account owner) {
// TODO Auto-generated method stub
return true;
}

View File

@ -13,12 +13,12 @@ import com.cloud.deploy.DeployDestination;
import com.cloud.deploy.DeploymentPlan;
import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
import com.cloud.network.Network.AddressFormat;
import com.cloud.network.Network.BroadcastDomainType;
import com.cloud.network.Network.Mode;
import com.cloud.network.Network.TrafficType;
import com.cloud.network.NetworkConfiguration;
import com.cloud.network.NetworkConfigurationVO;
import com.cloud.network.Networks.AddressFormat;
import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.Networks.Mode;
import com.cloud.network.Networks.TrafficType;
import com.cloud.network.Network;
import com.cloud.network.NetworkVO;
import com.cloud.network.NetworkManager;
import com.cloud.offering.NetworkOffering;
import com.cloud.resource.Resource.ReservationStrategy;
@ -38,14 +38,14 @@ public class PodBasedNetworkGuru extends AdapterBase implements NetworkGuru {
@Inject NetworkManager _networkMgr;
@Override
public NetworkConfiguration design(NetworkOffering offering, DeploymentPlan plan, NetworkConfiguration userSpecified, Account owner) {
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
TrafficType type = offering.getTrafficType();
if (type != TrafficType.Management && type != TrafficType.Storage) {
return null;
}
NetworkConfigurationVO config = new NetworkConfigurationVO(type, offering.getGuestIpType(), Mode.Static, BroadcastDomainType.Native, offering.getId(), plan.getDataCenterId());
NetworkVO config = new NetworkVO(type, offering.getGuestIpType(), Mode.Static, BroadcastDomainType.Native, offering.getId(), plan.getDataCenterId());
return config;
}
@ -55,11 +55,11 @@ public class PodBasedNetworkGuru extends AdapterBase implements NetworkGuru {
}
@Override
public void deallocate(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) {
public void deallocate(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) {
}
@Override
public NicProfile allocate(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException,
public NicProfile allocate(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException,
InsufficientAddressCapacityException {
TrafficType trafficType = config.getTrafficType();
assert (trafficType == TrafficType.Storage || trafficType == TrafficType.Management) : "Well, I can't take care of this config now can I? " + config;
@ -77,7 +77,7 @@ public class PodBasedNetworkGuru extends AdapterBase implements NetworkGuru {
}
@Override
public void reserve(NicProfile nic, NetworkConfiguration config, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapcityException,
public void reserve(NicProfile nic, Network config, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapcityException,
InsufficientAddressCapacityException {
Pod pod = dest.getPod();
@ -101,16 +101,16 @@ public class PodBasedNetworkGuru extends AdapterBase implements NetworkGuru {
}
@Override
public NetworkConfiguration implement(NetworkConfiguration config, NetworkOffering offering, DeployDestination destination, ReservationContext context) {
public Network implement(Network config, NetworkOffering offering, DeployDestination destination, ReservationContext context) {
return config;
}
@Override
public void destroy(NetworkConfiguration config, NetworkOffering offering) {
public void destroy(Network config, NetworkOffering offering) {
}
@Override
public boolean trash(NetworkConfiguration config, NetworkOffering offering, Account owner) {
public boolean trash(Network config, NetworkOffering offering, Account owner) {
return true;
}
}

View File

@ -16,13 +16,13 @@ import com.cloud.deploy.DeployDestination;
import com.cloud.deploy.DeploymentPlan;
import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
import com.cloud.network.Network.AddressFormat;
import com.cloud.network.Network.BroadcastDomainType;
import com.cloud.network.Network.IsolationType;
import com.cloud.network.Network.Mode;
import com.cloud.network.Network.TrafficType;
import com.cloud.network.NetworkConfiguration;
import com.cloud.network.NetworkConfigurationVO;
import com.cloud.network.Networks.AddressFormat;
import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.Networks.IsolationType;
import com.cloud.network.Networks.Mode;
import com.cloud.network.Networks.TrafficType;
import com.cloud.network.Network;
import com.cloud.network.NetworkVO;
import com.cloud.network.NetworkManager;
import com.cloud.network.dao.IPAddressDao;
import com.cloud.offering.NetworkOffering;
@ -46,12 +46,12 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru {
@Inject IPAddressDao _ipAddressDao;
@Override
public NetworkConfiguration design(NetworkOffering offering, DeploymentPlan plan, NetworkConfiguration config, Account owner) {
public Network design(NetworkOffering offering, DeploymentPlan plan, Network config, Account owner) {
if (offering.getTrafficType() != TrafficType.Public) {
return null;
}
return new NetworkConfigurationVO(offering.getTrafficType(), offering.getGuestIpType(), Mode.Static, BroadcastDomainType.Vlan, offering.getId(), plan.getDataCenterId());
return new NetworkVO(offering.getTrafficType(), offering.getGuestIpType(), Mode.Static, BroadcastDomainType.Vlan, offering.getId(), plan.getDataCenterId());
}
protected PublicNetworkGuru() {
@ -79,7 +79,7 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru {
}
@Override
public NicProfile allocate(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException,
public NicProfile allocate(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException,
InsufficientAddressCapacityException {
if (config.getTrafficType() != TrafficType.Public) {
return null;
@ -101,7 +101,7 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru {
}
@Override
public void reserve(NicProfile nic, NetworkConfiguration configuration, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
public void reserve(NicProfile nic, Network configuration, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
if (nic.getIp4Address() == null) {
getIp(nic, dest.getDataCenter(), vm);
}
@ -114,20 +114,20 @@ public class PublicNetworkGuru extends AdapterBase implements NetworkGuru {
}
@Override
public NetworkConfiguration implement(NetworkConfiguration config, NetworkOffering offering, DeployDestination destination, ReservationContext context) {
public Network implement(Network config, NetworkOffering offering, DeployDestination destination, ReservationContext context) {
return config;
}
@Override
public void deallocate(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) {
public void deallocate(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) {
}
@Override
public void destroy(NetworkConfiguration config, NetworkOffering offering) {
public void destroy(Network config, NetworkOffering offering) {
}
@Override
public boolean trash(NetworkConfiguration config, NetworkOffering offering, Account owner) {
public boolean trash(Network config, NetworkOffering offering, Account owner) {
return true;
}
}

View File

@ -20,19 +20,19 @@ package com.cloud.network.dao;
import java.util.List;
import com.cloud.network.NetworkAccountVO;
import com.cloud.network.NetworkConfigurationVO;
import com.cloud.network.NetworkVO;
import com.cloud.utils.db.GenericDao;
import com.cloud.utils.db.SearchBuilder;
public interface NetworkConfigurationDao extends GenericDao<NetworkConfigurationVO, Long> {
List<NetworkConfigurationVO> listBy(long accountId);
List<NetworkConfigurationVO> listBy(long accountId, long offeringId, long dataCenterId);
public interface NetworkDao extends GenericDao<NetworkVO, Long> {
List<NetworkVO> listBy(long accountId);
List<NetworkVO> listBy(long accountId, long offeringId, long dataCenterId);
@Override
NetworkConfigurationVO persist(NetworkConfigurationVO config);
NetworkVO persist(NetworkVO config);
void addAccountToNetworkConfiguration(long configId, long accountId);
SearchBuilder<NetworkAccountVO> createSearchBuilderForAccount();
List<NetworkConfigurationVO> getNetworkConfigurationsForOffering(long offeringId, long dataCenterId, long accountId);
List<NetworkConfigurationVO> getRelatedNetworkConfigurations(long related);
List<NetworkVO> getNetworkConfigurationsForOffering(long offeringId, long dataCenterId, long accountId);
List<NetworkVO> getRelatedNetworkConfigurations(long related);
/**
* Retrieves the next available mac address in this network configuration.

View File

@ -25,12 +25,12 @@ import java.util.Random;
import javax.ejb.Local;
import javax.persistence.TableGenerator;
import com.cloud.network.Network.BroadcastDomainType;
import com.cloud.network.Network.Mode;
import com.cloud.network.Network.TrafficType;
import com.cloud.network.NetworkAccountDaoImpl;
import com.cloud.network.NetworkAccountVO;
import com.cloud.network.NetworkConfigurationVO;
import com.cloud.network.NetworkVO;
import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.Networks.Mode;
import com.cloud.network.Networks.TrafficType;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.GenericDaoBase;
import com.cloud.utils.db.JoinBuilder;
@ -42,20 +42,20 @@ import com.cloud.utils.db.Transaction;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.net.NetUtils;
@Local(value=NetworkConfigurationDao.class) @DB(txn=false)
public class NetworkConfigurationDaoImpl extends GenericDaoBase<NetworkConfigurationVO, Long> implements NetworkConfigurationDao {
final SearchBuilder<NetworkConfigurationVO> ProfileSearch;
final SearchBuilder<NetworkConfigurationVO> AccountSearch;
final SearchBuilder<NetworkConfigurationVO> OfferingSearch;
final SearchBuilder<NetworkConfigurationVO> RelatedConfigSearch;
final SearchBuilder<NetworkConfigurationVO> RelatedConfigsSearch;
@Local(value=NetworkDao.class) @DB(txn=false)
public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements NetworkDao {
final SearchBuilder<NetworkVO> ProfileSearch;
final SearchBuilder<NetworkVO> AccountSearch;
final SearchBuilder<NetworkVO> OfferingSearch;
final SearchBuilder<NetworkVO> RelatedConfigSearch;
final SearchBuilder<NetworkVO> RelatedConfigsSearch;
NetworkAccountDaoImpl _accountsDao = new NetworkAccountDaoImpl();
final TableGenerator _tgMacAddress;
Random _rand = new Random(System.currentTimeMillis());
long _prefix = 0x2;
protected NetworkConfigurationDaoImpl() {
protected NetworkDaoImpl() {
super();
ProfileSearch = createSearchBuilder();
@ -70,7 +70,7 @@ public class NetworkConfigurationDaoImpl extends GenericDaoBase<NetworkConfigura
AccountSearch.and("offering", AccountSearch.entity().getNetworkOfferingId(), SearchCriteria.Op.EQ);
SearchBuilder<NetworkAccountVO> join = _accountsDao.createSearchBuilder();
join.and("account", join.entity().getAccountId(), SearchCriteria.Op.EQ);
AccountSearch.join("accounts", join, AccountSearch.entity().getId(), join.entity().getNetworkConfigurationId(), JoinBuilder.JoinType.INNER);
AccountSearch.join("accounts", join, AccountSearch.entity().getId(), join.entity().getNetworkId(), JoinBuilder.JoinType.INNER);
AccountSearch.and("datacenter", AccountSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
AccountSearch.done();
@ -83,7 +83,7 @@ public class NetworkConfigurationDaoImpl extends GenericDaoBase<NetworkConfigura
RelatedConfigSearch.and("datacenter", RelatedConfigSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
SearchBuilder<NetworkAccountVO> join2 = _accountsDao.createSearchBuilder();
join2.and("account", join2.entity().getAccountId(), SearchCriteria.Op.EQ);
RelatedConfigSearch.join("account", join2, join2.entity().getNetworkConfigurationId(), RelatedConfigSearch.entity().getId(), JoinType.INNER);
RelatedConfigSearch.join("account", join2, join2.entity().getNetworkId(), RelatedConfigSearch.entity().getId(), JoinType.INNER);
RelatedConfigSearch.done();
RelatedConfigsSearch = createSearchBuilder();
@ -93,8 +93,8 @@ public class NetworkConfigurationDaoImpl extends GenericDaoBase<NetworkConfigura
_tgMacAddress = _tgs.get("macAddress");
}
public List<NetworkConfigurationVO> findBy(TrafficType trafficType, Mode mode, BroadcastDomainType broadcastType, long networkOfferingId, long dataCenterId) {
SearchCriteria<NetworkConfigurationVO> sc = ProfileSearch.create();
public List<NetworkVO> findBy(TrafficType trafficType, Mode mode, BroadcastDomainType broadcastType, long networkOfferingId, long dataCenterId) {
SearchCriteria<NetworkVO> sc = ProfileSearch.create();
sc.setParameters("trafficType", trafficType);
sc.setParameters("broadcastType", broadcastType);
sc.setParameters("offering", networkOfferingId);
@ -104,8 +104,8 @@ public class NetworkConfigurationDaoImpl extends GenericDaoBase<NetworkConfigura
}
@Override
public List<NetworkConfigurationVO> listBy(long accountId) {
SearchCriteria<NetworkConfigurationVO> sc = AccountSearch.create();
public List<NetworkVO> listBy(long accountId) {
SearchCriteria<NetworkVO> sc = AccountSearch.create();
sc.setParameters("account", accountId);
sc.setJoinParameters("accounts", "account", accountId);
@ -113,8 +113,8 @@ public class NetworkConfigurationDaoImpl extends GenericDaoBase<NetworkConfigura
}
@Override
public List<NetworkConfigurationVO> listBy(long accountId, long offeringId, long dataCenterId) {
SearchCriteria<NetworkConfigurationVO> sc = AccountSearch.create();
public List<NetworkVO> listBy(long accountId, long offeringId, long dataCenterId) {
SearchCriteria<NetworkVO> sc = AccountSearch.create();
sc.setParameters("offering", offeringId);
sc.setJoinParameters("accounts", "account", accountId);
sc.setParameters("datacenter", dataCenterId);
@ -123,13 +123,13 @@ public class NetworkConfigurationDaoImpl extends GenericDaoBase<NetworkConfigura
}
@Override @DB
public NetworkConfigurationVO persist(NetworkConfigurationVO config) {
public NetworkVO persist(NetworkVO config) {
Transaction txn = Transaction.currentTxn();
txn.start();
config = super.persist(config);
addAccountToNetworkConfiguration(config.getId(), config.getAccountId(), true);
try {
PreparedStatement pstmt = txn.prepareAutoCloseStatement("INSERT INTO op_network_configurations (id) VALUES(?)");
PreparedStatement pstmt = txn.prepareAutoCloseStatement("INSERT INTO op_networks (id) VALUES(?)");
pstmt.setLong(1, config.getId());
pstmt.executeUpdate();
} catch (SQLException e) {
@ -155,8 +155,8 @@ public class NetworkConfigurationDaoImpl extends GenericDaoBase<NetworkConfigura
}
@Override
public List<NetworkConfigurationVO> getNetworkConfigurationsForOffering(long offeringId, long dataCenterId, long accountId) {
SearchCriteria<NetworkConfigurationVO> sc = RelatedConfigSearch.create();
public List<NetworkVO> getNetworkConfigurationsForOffering(long offeringId, long dataCenterId, long accountId) {
SearchCriteria<NetworkVO> sc = RelatedConfigSearch.create();
sc.setParameters("offering", offeringId);
sc.setParameters("dc", dataCenterId);
sc.setJoinParameters("account", "account", accountId);
@ -164,8 +164,8 @@ public class NetworkConfigurationDaoImpl extends GenericDaoBase<NetworkConfigura
}
@Override
public List<NetworkConfigurationVO> getRelatedNetworkConfigurations(long related) {
SearchCriteria<NetworkConfigurationVO> sc = RelatedConfigsSearch.create();
public List<NetworkVO> getRelatedNetworkConfigurations(long related) {
SearchCriteria<NetworkVO> sc = RelatedConfigsSearch.create();
sc.setParameters("related", related);
return search(sc, null);
}

View File

@ -26,10 +26,10 @@ import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InsufficientNetworkCapacityException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.Network.TrafficType;
import com.cloud.network.NetworkConfiguration;
import com.cloud.network.Networks.TrafficType;
import com.cloud.network.Network;
import com.cloud.network.NetworkManager;
import com.cloud.network.dao.NetworkConfigurationDao;
import com.cloud.network.dao.NetworkDao;
import com.cloud.network.router.DomainRouterManager;
import com.cloud.offering.NetworkOffering;
import com.cloud.offering.NetworkOffering.GuestIpType;
@ -51,7 +51,7 @@ import com.cloud.vm.dao.UserVmDao;
public class DomainRouterElement extends AdapterBase implements NetworkElement {
private static final Logger s_logger = Logger.getLogger(DomainRouterElement.class);
@Inject NetworkConfigurationDao _networkConfigDao;
@Inject NetworkDao _networkConfigDao;
@Inject NetworkManager _networkMgr;
@Inject DomainRouterManager _routerMgr;
@Inject UserVmManager _userVmMgr;
@ -59,7 +59,7 @@ public class DomainRouterElement extends AdapterBase implements NetworkElement {
@Inject DomainRouterDao _routerDao;
@Override
public boolean implement(NetworkConfiguration guestConfig, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException {
public boolean implement(Network guestConfig, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException {
if (offering.getGuestIpType() != GuestIpType.Virtualized) {
s_logger.trace("Not handling guest ip type = " + offering.getGuestIpType());
return false;
@ -74,7 +74,7 @@ public class DomainRouterElement extends AdapterBase implements NetworkElement {
}
@Override
public boolean prepare(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientNetworkCapacityException, ResourceUnavailableException {
public boolean prepare(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientNetworkCapacityException, ResourceUnavailableException {
if (config.getTrafficType() != TrafficType.Guest || vm.getType() != Type.User) {
s_logger.trace("Domain Router only cares about guest network and User VMs");
return false;
@ -91,7 +91,7 @@ public class DomainRouterElement extends AdapterBase implements NetworkElement {
}
@Override
public boolean release(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, ReservationContext context) {
public boolean release(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm, ReservationContext context) {
if (config.getTrafficType() != TrafficType.Guest || vm.getType() != Type.User) {
s_logger.trace("Domain Router only cares about guest network and User VMs");
return false;
@ -102,7 +102,7 @@ public class DomainRouterElement extends AdapterBase implements NetworkElement {
}
@Override
public boolean shutdown(NetworkConfiguration config, ReservationContext context) throws ConcurrentOperationException {
public boolean shutdown(Network config, ReservationContext context) throws ConcurrentOperationException {
if (config.getTrafficType() != TrafficType.Guest) {
s_logger.trace("Domain Router only cares about guet network.");
return false;

View File

@ -31,7 +31,7 @@ import com.cloud.exception.InsufficientNetworkCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.NetworkConfiguration;
import com.cloud.network.Network;
import com.cloud.network.RemoteAccessVpnVO;
import com.cloud.network.VpnUserVO;
import com.cloud.service.ServiceOfferingVO;
@ -148,7 +148,7 @@ public interface DomainRouterManager extends Manager {
DomainRouterVO getRouter(long accountId, long zoneId);
DomainRouterVO getRouter(String publicIpAddress);
DomainRouterVO deploy(NetworkConfiguration guestConfig, DeployDestination dest, Account owner) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException;
DomainRouterVO deploy(Network guestConfig, DeployDestination dest, Account owner) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException;
RemoteAccessVpnVO startRemoteAccessVpn(RemoteAccessVpnVO vpnVO) throws ResourceUnavailableException;
@ -156,5 +156,5 @@ public interface DomainRouterManager extends Manager {
boolean deleteRemoteAccessVpn(RemoteAccessVpnVO vpnVO);
DomainRouterVO addVirtualMachineIntoNetwork(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile<UserVm> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientNetworkCapacityException, ResourceUnavailableException;
DomainRouterVO addVirtualMachineIntoNetwork(Network config, NicProfile nic, VirtualMachineProfile<UserVm> vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientNetworkCapacityException, ResourceUnavailableException;
}

View File

@ -107,9 +107,9 @@ import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.network.DomainRouterService;
import com.cloud.network.FirewallRuleVO;
import com.cloud.network.IPAddressVO;
import com.cloud.network.Network.TrafficType;
import com.cloud.network.NetworkConfiguration;
import com.cloud.network.NetworkConfigurationVO;
import com.cloud.network.Networks.TrafficType;
import com.cloud.network.Network;
import com.cloud.network.NetworkVO;
import com.cloud.network.NetworkManager;
import com.cloud.network.RemoteAccessVpnVO;
import com.cloud.network.SshKeysDistriMonitor;
@ -118,7 +118,7 @@ import com.cloud.network.dao.FirewallRulesDao;
import com.cloud.network.dao.IPAddressDao;
import com.cloud.network.dao.LoadBalancerDao;
import com.cloud.network.dao.LoadBalancerVMMapDao;
import com.cloud.network.dao.NetworkConfigurationDao;
import com.cloud.network.dao.NetworkDao;
import com.cloud.network.dao.NetworkRuleConfigDao;
import com.cloud.network.dao.RemoteAccessVpnDao;
import com.cloud.network.dao.VpnUserDao;
@ -221,7 +221,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
@Inject AccountVlanMapDao _accountVlanMapDao;
@Inject UserStatisticsDao _statsDao = null;
@Inject NetworkOfferingDao _networkOfferingDao = null;
@Inject NetworkConfigurationDao _networkConfigurationDao = null;
@Inject NetworkDao _networkConfigurationDao = null;
@Inject NicDao _nicDao;
@Inject GuestOSDao _guestOSDao = null;
@Inject NetworkManager _networkMgr;
@ -2041,13 +2041,13 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
}
@Override
public DomainRouterVO deploy(NetworkConfiguration guestConfig, DeployDestination dest, Account owner) throws InsufficientCapacityException, StorageUnavailableException, ConcurrentOperationException, ResourceUnavailableException {
public DomainRouterVO deploy(Network guestConfig, DeployDestination dest, Account owner) throws InsufficientCapacityException, StorageUnavailableException, ConcurrentOperationException, ResourceUnavailableException {
long dcId = dest.getDataCenter().getId();
if (s_logger.isDebugEnabled()) {
s_logger.debug("Starting a router for network configurations: virtual=" + guestConfig + " in " + dest);
}
assert guestConfig.getState() == NetworkConfiguration.State.Implemented : "Network is not yet fully implemented: " + guestConfig;
assert guestConfig.getState() == Network.State.Implemented : "Network is not yet fully implemented: " + guestConfig;
assert guestConfig.getTrafficType() == TrafficType.Guest;
DataCenterDeployment plan = new DataCenterDeployment(dcId);
@ -2068,16 +2068,16 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
List<NetworkOfferingVO> offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemVmControlNetwork);
NetworkOfferingVO controlOffering = offerings.get(0);
NetworkConfigurationVO controlConfig = _networkMgr.setupNetworkConfiguration(_systemAcct, controlOffering, plan).get(0);
NetworkVO controlConfig = _networkMgr.setupNetworkConfiguration(_systemAcct, controlOffering, plan).get(0);
List<Pair<NetworkConfigurationVO, NicProfile>> networks = new ArrayList<Pair<NetworkConfigurationVO, NicProfile>>(3);
List<Pair<NetworkVO, NicProfile>> networks = new ArrayList<Pair<NetworkVO, NicProfile>>(3);
NetworkOfferingVO publicOffering = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemVmPublicNetwork).get(0);
List<NetworkConfigurationVO> publicConfigs = _networkMgr.setupNetworkConfiguration(_systemAcct, publicOffering, plan);
List<NetworkVO> publicConfigs = _networkMgr.setupNetworkConfiguration(_systemAcct, publicOffering, plan);
NicProfile defaultNic = new NicProfile();
defaultNic.setDefaultNic(true);
//defaultNic.setIp4Address(sourceNatIp);
defaultNic.setDeviceId(2);
networks.add(new Pair<NetworkConfigurationVO, NicProfile>(publicConfigs.get(0), defaultNic));
networks.add(new Pair<NetworkVO, NicProfile>(publicConfigs.get(0), defaultNic));
NicProfile gatewayNic = new NicProfile();
gatewayNic.setIp4Address(guestConfig.getGateway());
gatewayNic.setBroadcastUri(guestConfig.getBroadcastUri());
@ -2085,8 +2085,8 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
gatewayNic.setIsolationUri(guestConfig.getBroadcastUri());
gatewayNic.setMode(guestConfig.getMode());
gatewayNic.setNetmask(NetUtils.getCidrSubNet(guestConfig.getCidr()));
networks.add(new Pair<NetworkConfigurationVO, NicProfile>((NetworkConfigurationVO)guestConfig, gatewayNic));
networks.add(new Pair<NetworkConfigurationVO, NicProfile>(controlConfig, null));
networks.add(new Pair<NetworkVO, NicProfile>((NetworkVO)guestConfig, gatewayNic));
networks.add(new Pair<NetworkVO, NicProfile>(controlConfig, null));
router = new DomainRouterVO(id, _offering.getId(), VirtualMachineName.getRouterName(id, _instance), _template.getId(), _template.getGuestOSId(), owner.getDomainId(), owner.getId(), guestConfig.getId(), _offering.getOfferHA());
router = _itMgr.allocate(router, _template, _offering, networks, plan, owner);
@ -2231,7 +2231,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
}
@Override
public DomainRouterVO addVirtualMachineIntoNetwork(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile<UserVm> profile, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientNetworkCapacityException, ResourceUnavailableException {
public DomainRouterVO addVirtualMachineIntoNetwork(Network config, NicProfile nic, VirtualMachineProfile<UserVm> profile, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientNetworkCapacityException, ResourceUnavailableException {
DomainRouterVO router = _routerDao.findByNetworkConfiguration(config.getId());
try {
router = this.deploy(config, dest, profile.getOwner());
@ -2254,7 +2254,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
String routerControlIpAddress = null;
List<NicVO> nics = _nicDao.listBy(router.getId());
for (NicVO n : nics) {
NetworkConfigurationVO nc = _networkConfigurationDao.findById(n.getNetworkConfigurationId());
NetworkVO nc = _networkConfigurationDao.findById(n.getNetworkId());
if (n.getIp4Address() != null && nc.getTrafficType() == TrafficType.Public) {
routerPublicIpAddress = nic.getIp4Address();
} else if (nc.getTrafficType() == TrafficType.Control) {
@ -2407,7 +2407,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
return router;
}
private boolean resendRouterState(NetworkConfiguration config, DomainRouterVO router, Commands cmds) {
private boolean resendRouterState(Network config, DomainRouterVO router, Commands cmds) {
if (router.getRole() == Role.DHCP_FIREWALL_LB_PASSWD_USERDATA) {
//source NAT address is stored in /proc/cmdline of the domR and gets
//reassigned upon powerup. Source NAT rule gets configured in StartRouter command
@ -2441,7 +2441,7 @@ public class DomainRouterManagerImpl implements DomainRouterManager, DomainRoute
}
private boolean resendDhcpEntries(NetworkConfiguration config, DomainRouterVO router, Commands cmd){
private boolean resendDhcpEntries(Network config, DomainRouterVO router, Commands cmd){
final List<UserVmVO> vms = _vmDao.listBy(router.getId(), State.Creating, State.Starting, State.Running, State.Stopping, State.Stopped, State.Migrating);
Commands cmds = new Commands(OnError.Continue);
for (UserVmVO vm: vms) {

View File

@ -90,9 +90,9 @@ import com.cloud.info.RunningHostCountInfo;
import com.cloud.info.RunningHostInfoAgregator;
import com.cloud.info.RunningHostInfoAgregator.ZoneHostInfo;
import com.cloud.network.IpAddrAllocator;
import com.cloud.network.NetworkConfigurationVO;
import com.cloud.network.NetworkVO;
import com.cloud.network.IpAddrAllocator.networkInfo;
import com.cloud.network.Network.TrafficType;
import com.cloud.network.Networks.TrafficType;
import com.cloud.network.NetworkManager;
import com.cloud.network.dao.IPAddressDao;
import com.cloud.offering.NetworkOffering;
@ -742,13 +742,13 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
List<NetworkOfferingVO> defaultOffering = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemVmPublicNetwork);
List<NetworkOfferingVO> offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemVmControlNetwork, NetworkOfferingVO.SystemVmManagementNetwork);
List<Pair<NetworkConfigurationVO, NicProfile>> networks = new ArrayList<Pair<NetworkConfigurationVO, NicProfile>>(offerings.size() + 1);
List<Pair<NetworkVO, NicProfile>> networks = new ArrayList<Pair<NetworkVO, NicProfile>>(offerings.size() + 1);
NicProfile defaultNic = new NicProfile();
defaultNic.setDefaultNic(true);
defaultNic.setDeviceId(2);
networks.add(new Pair<NetworkConfigurationVO, NicProfile>(_networkMgr.setupNetworkConfiguration(systemAcct, defaultOffering.get(0), plan).get(0), defaultNic));
networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetworkConfiguration(systemAcct, defaultOffering.get(0), plan).get(0), defaultNic));
for (NetworkOfferingVO offering : offerings) {
networks.add(new Pair<NetworkConfigurationVO, NicProfile>(_networkMgr.setupNetworkConfiguration(systemAcct, offering, plan).get(0), null));
networks.add(new Pair<NetworkVO, NicProfile>(_networkMgr.setupNetworkConfiguration(systemAcct, offering, plan).get(0), null));
}
SecondaryStorageVmVO secStorageVm = new SecondaryStorageVmVO(id, _serviceOffering.getId(), name, _template.getId(),
_template.getGuestOSId(), dataCenterId, systemAcct.getDomainId(), systemAcct.getId());

View File

@ -59,7 +59,7 @@ import com.cloud.exception.ResourceUnavailableException;
import com.cloud.exception.StorageUnavailableException;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.hypervisor.HypervisorGuru;
import com.cloud.network.NetworkConfigurationVO;
import com.cloud.network.NetworkVO;
import com.cloud.network.NetworkManager;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.service.dao.ServiceOfferingDao;
@ -125,7 +125,7 @@ public class MauriceMoss implements VmManager, ClusterManagerListener {
ServiceOfferingVO serviceOffering,
Pair<? extends DiskOfferingVO, Long> rootDiskOffering,
List<Pair<DiskOfferingVO, Long>> dataDiskOfferings,
List<Pair<NetworkConfigurationVO, NicProfile>> networks,
List<Pair<NetworkVO, NicProfile>> networks,
Map<String, Object> params,
DeploymentPlan plan,
Account owner) throws InsufficientCapacityException {
@ -185,7 +185,7 @@ public class MauriceMoss implements VmManager, ClusterManagerListener {
ServiceOfferingVO serviceOffering,
Long rootSize,
Pair<DiskOfferingVO, Long> dataDiskOffering,
List<Pair<NetworkConfigurationVO, NicProfile>> networks,
List<Pair<NetworkVO, NicProfile>> networks,
DeploymentPlan plan,
Account owner) throws InsufficientCapacityException {
List<Pair<DiskOfferingVO, Long>> diskOfferings = new ArrayList<Pair<DiskOfferingVO, Long>>(1);
@ -199,7 +199,7 @@ public class MauriceMoss implements VmManager, ClusterManagerListener {
public <T extends VMInstanceVO> T allocate(T vm,
VMTemplateVO template,
ServiceOfferingVO serviceOffering,
List<Pair<NetworkConfigurationVO, NicProfile>> networks,
List<Pair<NetworkVO, NicProfile>> networks,
DeploymentPlan plan,
Account owner) throws InsufficientCapacityException {
return allocate(vm, template, serviceOffering, new Pair<DiskOfferingVO, Long>(serviceOffering, null), null, networks, null, plan, owner);

View File

@ -29,8 +29,8 @@ import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import com.cloud.network.Network.AddressFormat;
import com.cloud.network.Network.Mode;
import com.cloud.network.Networks.AddressFormat;
import com.cloud.network.Networks.Mode;
@Entity
@Table(name="nics")
@ -74,8 +74,8 @@ public class NicVO implements Nic {
@Enumerated(value=EnumType.STRING)
Mode mode;
@Column(name="network_configuration_id")
long networkConfigurationId;
@Column(name="network_id")
long networkId;
@Column(name="state")
@Enumerated(value=EnumType.STRING)
@ -99,7 +99,7 @@ public class NicVO implements Nic {
public NicVO(String reserver, long instanceId, long configurationId) {
this.reserver = reserver;
this.instanceId = instanceId;
this.networkConfigurationId = configurationId;
this.networkId = configurationId;
this.state = State.Allocated;
}
@ -126,6 +126,7 @@ public class NicVO implements Nic {
return state;
}
@Override
public boolean isDefaultNic() {
return defaultNic;
}
@ -142,10 +143,12 @@ public class NicVO implements Nic {
this.ip6Address = ip6Address;
}
@Override
public String getNetmask() {
return netmask;
}
@Override
public String getGateway() {
return gateway;
}
@ -186,8 +189,8 @@ public class NicVO implements Nic {
this.instanceId = instanceId;
}
public void setNetworkConfigurationId(long networkConfigurationId) {
this.networkConfigurationId = networkConfigurationId;
public void setNetworkId(long networkConfigurationId) {
this.networkId = networkConfigurationId;
}
public void setUpdateTime(Date updateTime) {
@ -209,8 +212,8 @@ public class NicVO implements Nic {
}
@Override
public long getNetworkConfigurationId() {
return networkConfigurationId;
public long getNetworkId() {
return networkId;
}
@Override

View File

@ -132,7 +132,7 @@ import com.cloud.network.FirewallRuleVO;
import com.cloud.network.IPAddressVO;
import com.cloud.network.IpAddrAllocator;
import com.cloud.network.LoadBalancerVMMapVO;
import com.cloud.network.NetworkConfigurationVO;
import com.cloud.network.NetworkVO;
import com.cloud.network.NetworkManager;
import com.cloud.network.dao.FirewallRulesDao;
import com.cloud.network.dao.IPAddressDao;
@ -3600,10 +3600,10 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
s_logger.debug("Allocating in the DB for vm");
List<NetworkConfigurationVO> configs = _networkMgr.setupNetworkConfiguration(owner, offering, plan);
List<Pair<NetworkConfigurationVO, NicProfile>> networks = new ArrayList<Pair<NetworkConfigurationVO, NicProfile>>();
for (NetworkConfigurationVO config : configs) {
networks.add(new Pair<NetworkConfigurationVO, NicProfile>(config, null));
List<NetworkVO> configs = _networkMgr.setupNetworkConfiguration(owner, offering, plan);
List<Pair<NetworkVO, NicProfile>> networks = new ArrayList<Pair<NetworkVO, NicProfile>>();
for (NetworkVO config : configs) {
networks.add(new Pair<NetworkVO, NicProfile>(config, null));
}

View File

@ -27,7 +27,7 @@ import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.OperationTimedoutException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.exception.StorageUnavailableException;
import com.cloud.network.NetworkConfigurationVO;
import com.cloud.network.NetworkVO;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.storage.DiskOfferingVO;
import com.cloud.storage.VMTemplateVO;
@ -46,7 +46,7 @@ public interface VmManager extends Manager {
ServiceOfferingVO serviceOffering,
Pair<? extends DiskOfferingVO, Long> rootDiskOffering,
List<Pair<DiskOfferingVO, Long>> dataDiskOfferings,
List<Pair<NetworkConfigurationVO, NicProfile>> networks,
List<Pair<NetworkVO, NicProfile>> networks,
Map<String, Object> params,
DeploymentPlan plan,
Account owner) throws InsufficientCapacityException, StorageUnavailableException;
@ -56,14 +56,14 @@ public interface VmManager extends Manager {
ServiceOfferingVO serviceOffering,
Long rootSize,
Pair<DiskOfferingVO, Long> dataDiskOffering,
List<Pair<NetworkConfigurationVO, NicProfile>> networks,
List<Pair<NetworkVO, NicProfile>> networks,
DeploymentPlan plan,
Account owner) throws InsufficientCapacityException, StorageUnavailableException;
<T extends VMInstanceVO> T allocate(T vm,
VMTemplateVO template,
ServiceOfferingVO serviceOffering,
List<Pair<NetworkConfigurationVO, NicProfile>> networkProfiles,
List<Pair<NetworkVO, NicProfile>> networkProfiles,
DeploymentPlan plan,
Account owner) throws InsufficientCapacityException, StorageUnavailableException;

View File

@ -28,7 +28,7 @@ public class NicDaoImpl extends GenericDaoBase<NicVO, Long> implements NicDao {
IpSearch = createSearchBuilder(String.class);
IpSearch.select(null, Func.DISTINCT, IpSearch.entity().getIp4Address());
IpSearch.and("nc", IpSearch.entity().getNetworkConfigurationId(), SearchCriteria.Op.EQ);
IpSearch.and("nc", IpSearch.entity().getNetworkId(), SearchCriteria.Op.EQ);
IpSearch.and("address", IpSearch.entity().getIp4Address(), SearchCriteria.Op.NNULL);
IpSearch.done();
}

View File

@ -24,10 +24,10 @@ ALTER TABLE `cloud`.`op_ha_work` ADD INDEX `i_op_ha_work__type`(`type`);
ALTER TABLE `cloud`.`op_ha_work` ADD INDEX `i_op_ha_work__mgmt_server_id`(`mgmt_server_id`);
ALTER TABLE `cloud`.`account_network_ref` ADD CONSTRAINT `fk_account_network_ref__account_id` FOREIGN KEY `fk_account_network_ref__account_id`(`account_id`) REFERENCES `account`(`id`) ON DELETE CASCADE;
ALTER TABLE `cloud`.`account_network_ref` ADD CONSTRAINT `fk_account_network_ref__network_configuration_id` FOREIGN KEY `fk_account_network_ref__network_configuration_id`(`network_configuration_id`) REFERENCES `network_configurations`(`id`) ON DELETE CASCADE;
ALTER TABLE `cloud`.`account_network_ref` ADD CONSTRAINT `fk_account_network_ref__networks_id` FOREIGN KEY `fk_account_network_ref__networks_id`(`network_id`) REFERENCES `networks`(`id`) ON DELETE CASCADE;
ALTER TABLE `cloud`.`nics` ADD CONSTRAINT `fk_nics__instance_id` FOREIGN KEY `fk_nics__instance_id`(`instance_id`) REFERENCES `vm_instance`(`id`) ON DELETE CASCADE;
ALTER TABLE `cloud`.`nics` ADD CONSTRAINT `fk_nics__network_configuration_id` FOREIGN KEY `fk_nics__network_configuration_id`(`network_configuration_id`) REFERENCES `network_configurations`(`id`);
ALTER TABLE `cloud`.`nics` ADD CONSTRAINT `fk_nics__networks_id` FOREIGN KEY `fk_nics__networks_id`(`network_id`) REFERENCES `networks`(`id`);
ALTER TABLE `cloud`.`op_dc_ip_address_alloc` ADD INDEX `i_op_dc_ip_address_alloc__pod_id__data_center_id__taken` (`pod_id`, `data_center_id`, `taken`, `instance_id`);
ALTER TABLE `cloud`.`op_dc_ip_address_alloc` ADD UNIQUE `i_op_dc_ip_address_alloc__ip_address__data_center_id`(`ip_address`, `data_center_id`);
@ -58,7 +58,7 @@ ALTER TABLE `cloud`.`storage_pool` ADD CONSTRAINT `fk_storage_pool__cluster_id`
ALTER TABLE `cloud`.`storage_pool_details` ADD CONSTRAINT `fk_storage_pool_details__pool_id` FOREIGN KEY `fk_storage_pool__pool_id`(`pool_id`) REFERENCES `storage_pool`(`id`) ON DELETE CASCADE;
ALTER TABLE `cloud`.`storage_pool_details` ADD INDEX `i_storage_pool_details__name__value`(`name`(128), `value`(128));
ALTER TABLE `cloud`.`op_network_configurations` ADD CONSTRAINT `fk_op_network_configurations__id` FOREIGN KEY `fk_op_network_configurations__id`(`id`) REFERENCES `network_configurations`(`id`) ON DELETE CASCADE;
ALTER TABLE `cloud`.`op_networks` ADD CONSTRAINT `fk_op_networks__id` FOREIGN KEY `fk_op_networks__id`(`id`) REFERENCES `networks`(`id`) ON DELETE CASCADE;
ALTER TABLE `cloud`.`user` ADD INDEX `i_user__secret_key_removed`(`secret_key`, `removed`);
ALTER TABLE `cloud`.`user` ADD INDEX `i_user__removed`(`removed`);

View File

@ -74,7 +74,8 @@ DROP TABLE IF EXISTS `cloud`.`storage_pool_details`;
DROP TABLE IF EXISTS `cloud`.`ext_lun_details`;
DROP TABLE IF EXISTS `cloud`.`cluster`;
DROP TABLE IF EXISTS `cloud`.`nics`;
DROP TABLE IF EXISTS `cloud`.`network_configurations`;
DROP TABLE IF EXISTS `cloud`.`networks`;
DROP TABLE IF EXISTS `cloud`.`op_networks`;
DROP TABLE IF EXISTS `cloud`.`network_offerings`;
DROP TABLE IF EXISTS `cloud`.`host_master`;
DROP TABLE IF EXISTS `cloud`.`hypervisor_properties`;
@ -102,13 +103,13 @@ CREATE TABLE `cloud`.`hypervsior_properties` (
`max_network_devices` int(10) NOT NULL COMMENT 'maximum number of network devices'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `cloud`.`op_network_configurations`(
CREATE TABLE `cloud`.`op_networks`(
`id` bigint unsigned NOT NULL UNIQUE KEY,
`mac_address_seq` bigint unsigned NOT NULL DEFAULT 1 COMMENT 'mac address',
PRIMARY KEY(`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE `cloud`.`network_configurations` (
CREATE TABLE `cloud`.`networks` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
`name` varchar(255) COMMENT 'name for this network',
`traffic_type` varchar(32) NOT NULL COMMENT 'type of traffic going through this network',
@ -137,7 +138,7 @@ CREATE TABLE `cloud`.`network_configurations` (
CREATE TABLE `cloud`.`account_network_ref` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
`account_id` bigint unsigned NOT NULL COMMENT 'account id',
`network_configuration_id` bigint unsigned NOT NULL COMMENT 'network configuration id',
`network_id` bigint unsigned NOT NULL COMMENT 'network id',
`is_owner` smallint(1) NOT NULL COMMENT 'is the owner of the network',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@ -160,7 +161,7 @@ CREATE TABLE `cloud`.`nics` (
`gateway` varchar(15) COMMENT 'gateway',
`ip_type` varchar(32) COMMENT 'type of ip',
`broadcast_uri` varchar(255) COMMENT 'broadcast uri',
`network_configuration_id` bigint unsigned NOT NULL COMMENT 'network configuration id',
`network_id` bigint unsigned NOT NULL COMMENT 'network configuration id',
`mode` varchar(32) COMMENT 'mode of getting ip address',
`state` varchar(32) NOT NULL COMMENT 'state of the creation',
`reserver_name` varchar(255) COMMENT 'Name of the component that reserved the ip address',
@ -275,7 +276,7 @@ INSERT INTO `cloud`.`sequence` (name, value) VALUES ('public_mac_address_seq', 1
INSERT INTO `cloud`.`sequence` (name, value) VALUES ('private_mac_address_seq', 1);
INSERT INTO `cloud`.`sequence` (name, value) VALUES ('storage_pool_seq', 200);
INSERT INTO `cloud`.`sequence` (name, value) VALUES ('volume_seq', 1);
INSERT INTO `cloud`.`sequence` (name, value) VALUES ('network_configuration_seq', 1);
INSERT INTO `cloud`.`sequence` (name, value) VALUES ('networks_seq', 1);
CREATE TABLE `cloud`.`volumes` (
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'Primary Key',
@ -649,7 +650,7 @@ CREATE TABLE `cloud`.`domain_router` (
`vlan_db_id` bigint unsigned COMMENT 'Foreign key into vlan id table',
`vlan_id` varchar(255) COMMENT 'optional VLAN ID for DomainRouter that can be used in rundomr.sh',
`dhcp_ip_address` bigint unsigned DEFAULT 2 COMMENT 'next ip address for dhcp for this domR',
`network_configuration_id` bigint unsigned NOT NULL DEFAULT 0 COMMENT 'network configuration that this domain router belongs to',
`network_id` bigint unsigned NOT NULL DEFAULT 0 COMMENT 'network configuration that this domain router belongs to',
`role` varchar(64) NOT NULL COMMENT 'type of role played by this router',
PRIMARY KEY (`id`)
) ENGINE = InnoDB DEFAULT CHARSET=utf8 COMMENT = 'information about the domR instance';

View File

@ -842,7 +842,6 @@ public class ComponentLocator implements ComponentLocatorMBean {
parse = true;
parent = getAttribute(atts, "extends");
String implementationClass = getAttribute(atts, "class");
if (implementationClass != null) {
try {
componentClass = Class.forName(implementationClass);