diff --git a/agent/src/com/cloud/agent/resource/computing/LibvirtComputingResource.java b/agent/src/com/cloud/agent/resource/computing/LibvirtComputingResource.java index 575b0e9f6fb..8dbb12fe12f 100644 --- a/agent/src/com/cloud/agent/resource/computing/LibvirtComputingResource.java +++ b/agent/src/com/cloud/agent/resource/computing/LibvirtComputingResource.java @@ -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; diff --git a/api/src/com/cloud/agent/api/to/NetworkTO.java b/api/src/com/cloud/agent/api/to/NetworkTO.java index 009fc1df7b6..d2d699b49d2 100644 --- a/api/src/com/cloud/agent/api/to/NetworkTO.java +++ b/api/src/com/cloud/agent/api/to/NetworkTO.java @@ -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. diff --git a/api/src/com/cloud/network/Network.java b/api/src/com/cloud/network/Network.java index 22e822097fe..2a250609247 100644 --- a/api/src/com/cloud/network/Network.java +++ b/api/src/com/cloud/network/Network.java @@ -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 . * */ 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 { + 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 getStateMachine() { + return s_fsm; + } + + @Override + public State getNextState(Event event) { + return s_fsm.getNextState(this, event); + } + + @Override + public List getFromStates(Event event) { + return s_fsm.getFromStates(this, event); + } + + @Override + public Set 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 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 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 s_fsm = new StateMachine(); + 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(); } diff --git a/api/src/com/cloud/network/NetworkConfiguration.java b/api/src/com/cloud/network/NetworkConfiguration.java deleted file mode 100644 index 51907693330..00000000000 --- a/api/src/com/cloud/network/NetworkConfiguration.java +++ /dev/null @@ -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 { - 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 getStateMachine() { - return s_fsm; - } - - @Override - public State getNextState(Event event) { - return s_fsm.getNextState(this, event); - } - - @Override - public List getFromStates(Event event) { - return s_fsm.getFromStates(this, event); - } - - @Override - public Set getPossibleEvents() { - return s_fsm.getPossibleEvents(this); - } - - String _description; - - @Override - public String getDescription() { - return _description; - } - - private State(String description) { - _description = description; - } - - private static StateMachine s_fsm = new StateMachine(); - 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(); -} diff --git a/api/src/com/cloud/network/Networks.java b/api/src/com/cloud/network/Networks.java new file mode 100644 index 00000000000..b5a20a94330 --- /dev/null +++ b/api/src/com/cloud/network/Networks.java @@ -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 . + * + */ +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 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 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; + } + } +} diff --git a/api/src/com/cloud/network/configuration/NetworkGuru.java b/api/src/com/cloud/network/configuration/NetworkGuru.java index ac2c19b8c7a..5db35d4fdea 100644 --- a/api/src/com/cloud/network/configuration/NetworkGuru.java +++ b/api/src/com/cloud/network/configuration/NetworkGuru.java @@ -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 vm) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException; + NicProfile allocate(Network config, NicProfile nic, VirtualMachineProfile 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 vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException; + void reserve(NicProfile nic, Network config, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException; boolean release(NicProfile nic, VirtualMachineProfile vm, String reservationId); - void deallocate(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm); + void deallocate(Network config, NicProfile nic, VirtualMachineProfile 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); } diff --git a/api/src/com/cloud/network/element/NetworkElement.java b/api/src/com/cloud/network/element/NetworkElement.java index 66b2e474bd7..4439861792b 100644 --- a/api/src/com/cloud/network/element/NetworkElement.java +++ b/api/src/com/cloud/network/element/NetworkElement.java @@ -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 vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientNetworkCapacityException; + boolean prepare(Network config, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientNetworkCapacityException; - boolean release(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException; + boolean release(Network config, NicProfile nic, VirtualMachineProfile 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(); diff --git a/api/src/com/cloud/offering/NetworkOffering.java b/api/src/com/cloud/offering/NetworkOffering.java index 5441625f9b9..0b4f9e84b91 100644 --- a/api/src/com/cloud/offering/NetworkOffering.java +++ b/api/src/com/cloud/offering/NetworkOffering.java @@ -17,7 +17,7 @@ */ package com.cloud.offering; -import com.cloud.network.Network.TrafficType; +import com.cloud.network.Networks.TrafficType; /** * Describes network offering diff --git a/api/src/com/cloud/vm/Nic.java b/api/src/com/cloud/vm/Nic.java index 8e7fdfed336..321a72a06ca 100644 --- a/api/src/com/cloud/vm/Nic.java +++ b/api/src/com/cloud/vm/Nic.java @@ -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. diff --git a/api/src/com/cloud/vm/NicProfile.java b/api/src/com/cloud/vm/NicProfile.java index 74edf3d7a91..95eb958fae1 100644 --- a/api/src/com/cloud/vm/NicProfile.java +++ b/api/src/com/cloud/vm/NicProfile.java @@ -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(); diff --git a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index 970dbdcf668..6c53fbc3a74 100644 --- a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -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; diff --git a/core/src/com/cloud/network/FirewallRuleVO.java b/core/src/com/cloud/network/FirewallRuleVO.java index e3badaf1068..ccf07b28776 100644 --- a/core/src/com/cloud/network/FirewallRuleVO.java +++ b/core/src/com/cloud/network/FirewallRuleVO.java @@ -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; } diff --git a/core/src/com/cloud/network/LoadBalancerVO.java b/core/src/com/cloud/network/LoadBalancerVO.java index 11b1fc7aa72..d5a2500ae44 100644 --- a/core/src/com/cloud/network/LoadBalancerVO.java +++ b/core/src/com/cloud/network/LoadBalancerVO.java @@ -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; } diff --git a/core/src/com/cloud/offerings/NetworkOfferingVO.java b/core/src/com/cloud/offerings/NetworkOfferingVO.java index adef5307aee..b7fa1c8002a 100644 --- a/core/src/com/cloud/offerings/NetworkOfferingVO.java +++ b/core/src/com/cloud/offerings/NetworkOfferingVO.java @@ -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; diff --git a/core/src/com/cloud/vm/DomainRouterVO.java b/core/src/com/cloud/vm/DomainRouterVO.java index 34e173dbdab..d1b05e11473 100755 --- a/core/src/com/cloud/vm/DomainRouterVO.java +++ b/core/src/com/cloud/vm/DomainRouterVO.java @@ -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 diff --git a/core/src/com/cloud/vm/VirtualNetwork.java b/core/src/com/cloud/vm/VirtualNetwork.java index 44651f65b3b..a58c894dd51 100644 --- a/core/src/com/cloud/vm/VirtualNetwork.java +++ b/core/src/com/cloud/vm/VirtualNetwork.java @@ -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 diff --git a/core/src/com/cloud/vm/dao/DomainRouterDaoImpl.java b/core/src/com/cloud/vm/dao/DomainRouterDaoImpl.java index 218dcdd515a..bf307cac57c 100755 --- a/core/src/com/cloud/vm/dao/DomainRouterDaoImpl.java +++ b/core/src/com/cloud/vm/dao/DomainRouterDaoImpl.java @@ -117,7 +117,7 @@ public class DomainRouterDaoImpl extends GenericDaoBase 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"; diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java index 7f99cf268b6..db07ed7ce6e 100644 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -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 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 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 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()); diff --git a/server/src/com/cloud/configuration/DefaultComponentLibrary.java b/server/src/com/cloud/configuration/DefaultComponentLibrary.java index 43816af5af6..930ffffa3b4 100644 --- a/server/src/com/cloud/configuration/DefaultComponentLibrary.java +++ b/server/src/com/cloud/configuration/DefaultComponentLibrary.java @@ -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); diff --git a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java index b6c5e0f947f..11d867aeabf 100644 --- a/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java +++ b/server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java @@ -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 defaultOffering = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemVmPublicNetwork); List offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemVmControlNetwork, NetworkOfferingVO.SystemVmManagementNetwork); - List> networks = new ArrayList>(offerings.size() + 1); + List> networks = new ArrayList>(offerings.size() + 1); NicProfile defaultNic = new NicProfile(); defaultNic.setDefaultNic(true); defaultNic.setDeviceId(2); - networks.add(new Pair(_networkMgr.setupNetworkConfiguration(systemAcct, defaultOffering.get(0), plan).get(0), defaultNic)); + networks.add(new Pair(_networkMgr.setupNetworkConfiguration(systemAcct, defaultOffering.get(0), plan).get(0), defaultNic)); for (NetworkOfferingVO offering : offerings) { - networks.add(new Pair(_networkMgr.setupNetworkConfiguration(systemAcct, offering, plan).get(0), null)); + networks.add(new Pair(_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 { diff --git a/server/src/com/cloud/network/NetworkAccountVO.java b/server/src/com/cloud/network/NetworkAccountVO.java index 4c900567603..b6c368a8ecc 100644 --- a/server/src/com/cloud/network/NetworkAccountVO.java +++ b/server/src/com/cloud/network/NetworkAccountVO.java @@ -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() { diff --git a/server/src/com/cloud/network/NetworkManager.java b/server/src/com/cloud/network/NetworkManager.java index f8e9e55092b..d2f74443e17 100644 --- a/server/src/com/cloud/network/NetworkManager.java +++ b/server/src/com/cloud/network/NetworkManager.java @@ -278,12 +278,12 @@ public interface NetworkManager { public boolean disassociateIpAddress(DisassociateIPAddrCmd cmd); - List setupNetworkConfiguration(Account owner, NetworkOfferingVO offering, DeploymentPlan plan); - List setupNetworkConfiguration(Account owner, NetworkOfferingVO offering, NetworkConfiguration predefined, DeploymentPlan plan); + List setupNetworkConfiguration(Account owner, NetworkOfferingVO offering, DeploymentPlan plan); + List setupNetworkConfiguration(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan plan); List getSystemAccountNetworkOfferings(String... offeringNames); - void allocate(VirtualMachineProfile vm, List> networks) throws InsufficientCapacityException; + void allocate(VirtualMachineProfile vm, List> networks) throws InsufficientCapacityException; void prepare(VirtualMachineProfile profile, DeployDestination dest, ReservationContext context) throws InsufficientNetworkCapacityException, ConcurrentOperationException, ResourceUnavailableException; void release(VirtualMachineProfile vmProfile); @@ -293,9 +293,9 @@ public interface NetworkManager { List getAccountsUsingNetworkConfiguration(long configurationId); AccountVO getNetworkConfigurationOwner(long configurationId); - List getNetworkConfigurationsforOffering(long offeringId, long dataCenterId, long accountId); + List getNetworkConfigurationsforOffering(long offeringId, long dataCenterId, long accountId); - List setupNetworkConfiguration(Account owner, ServiceOfferingVO offering, DeploymentPlan plan); + List 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; diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index 76179f3f064..8a077dc02d9 100755 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -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 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 setupNetworkConfiguration(Account owner, NetworkOfferingVO offering, DeploymentPlan plan) { + public List setupNetworkConfiguration(Account owner, NetworkOfferingVO offering, DeploymentPlan plan) { return setupNetworkConfiguration(owner, offering, null, plan); } @Override - public List setupNetworkConfiguration(Account owner, NetworkOfferingVO offering, NetworkConfiguration predefined, DeploymentPlan plan) { - List configs = _networkConfigDao.listBy(owner.getId(), offering.getId(), plan.getDataCenterId()); + public List setupNetworkConfiguration(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan plan) { + List 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(); + configs = new ArrayList(); 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 vm, List> networks) throws InsufficientCapacityException { + public void allocate(VirtualMachineProfile vm, List> networks) throws InsufficientCapacityException { Transaction txn = Transaction.currentTxn(); txn.start(); @@ -1871,8 +1869,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag List nics = new ArrayList(networks.size()); NicVO defaultNic = null; - for (Pair network : networks) { - NetworkConfigurationVO config = network.first(); + for (Pair 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 implementNetworkConfiguration(long configId, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientAddressCapacityException { + protected Pair implementNetworkConfiguration(long configId, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientAddressCapacityException { Transaction.currentTxn(); - Pair implemented = new Pair(null, null); + Pair implemented = new Pair(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 vmProfile, DeployDestination dest, ReservationContext context) throws InsufficientNetworkCapacityException, ConcurrentOperationException, ResourceUnavailableException { List nics = _nicDao.listBy(vmProfile.getId()); for (NicVO nic : nics) { - Pair implemented = implementNetworkConfiguration(nic.getNetworkConfigurationId(), dest, context); + Pair 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 vmProfile) { List 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 getNetworkConfigurationsforOffering(long offeringId, long dataCenterId, long accountId) { + public List getNetworkConfigurationsforOffering(long offeringId, long dataCenterId, long accountId) { return _networkConfigDao.getNetworkConfigurationsForOffering(offeringId, dataCenterId, accountId); } @Override - public List setupNetworkConfiguration(Account owner, ServiceOfferingVO offering, DeploymentPlan plan) { + public List 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); } diff --git a/server/src/com/cloud/network/NetworkConfigurationVO.java b/server/src/com/cloud/network/NetworkVO.java similarity index 85% rename from server/src/com/cloud/network/NetworkConfigurationVO.java rename to server/src/com/cloud/network/NetworkVO.java index 3db02d8e16a..8f5f838eee6 100644 --- a/server/src/com/cloud/network/NetworkConfigurationVO.java +++ b/server/src/com/cloud/network/NetworkVO.java @@ -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; } diff --git a/server/src/com/cloud/network/configuration/ControlNetworkGuru.java b/server/src/com/cloud/network/configuration/ControlNetworkGuru.java index ffda1027d96..9e526c0b73c 100644 --- a/server/src/com/cloud/network/configuration/ControlNetworkGuru.java +++ b/server/src/com/cloud/network/configuration/ControlNetworkGuru.java @@ -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 vm) throws InsufficientVirtualNetworkCapcityException, + public NicProfile allocate(Network config, NicProfile nic, VirtualMachineProfile 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 vm) { + public void deallocate(Network config, NicProfile nic, VirtualMachineProfile vm) { } @Override - public void reserve(NicProfile nic, NetworkConfiguration config, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapcityException, + public void reserve(NicProfile nic, Network config, VirtualMachineProfile 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; } diff --git a/server/src/com/cloud/network/configuration/GuestNetworkGuru.java b/server/src/com/cloud/network/configuration/GuestNetworkGuru.java index 1e6814e9d76..96311314f45 100644 --- a/server/src/com/cloud/network/configuration/GuestNetworkGuru.java +++ b/server/src/com/cloud/network/configuration/GuestNetworkGuru.java @@ -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 vm) { + public void deallocate(Network config, NicProfile nic, VirtualMachineProfile 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 vm) + public NicProfile allocate(Network config, NicProfile nic, VirtualMachineProfile 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 ips = _nicDao.listIpAddressInNetworkConfiguration(config.getId()); String[] cidr = config.getCidr().split("/"); Set 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 vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapcityException, + public void reserve(NicProfile nic, Network config, VirtualMachineProfile 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; } diff --git a/server/src/com/cloud/network/configuration/PodBasedNetworkGuru.java b/server/src/com/cloud/network/configuration/PodBasedNetworkGuru.java index eddc5698434..45b2e837241 100644 --- a/server/src/com/cloud/network/configuration/PodBasedNetworkGuru.java +++ b/server/src/com/cloud/network/configuration/PodBasedNetworkGuru.java @@ -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 vm) { + public void deallocate(Network config, NicProfile nic, VirtualMachineProfile vm) { } @Override - public NicProfile allocate(NetworkConfiguration config, NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapcityException, + public NicProfile allocate(Network config, NicProfile nic, VirtualMachineProfile 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 vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapcityException, + public void reserve(NicProfile nic, Network config, VirtualMachineProfile 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; } } diff --git a/server/src/com/cloud/network/configuration/PublicNetworkGuru.java b/server/src/com/cloud/network/configuration/PublicNetworkGuru.java index 7dcc049567f..45cae3ec1f2 100644 --- a/server/src/com/cloud/network/configuration/PublicNetworkGuru.java +++ b/server/src/com/cloud/network/configuration/PublicNetworkGuru.java @@ -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 vm) throws InsufficientVirtualNetworkCapcityException, + public NicProfile allocate(Network config, NicProfile nic, VirtualMachineProfile 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 vm, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException { + public void reserve(NicProfile nic, Network configuration, VirtualMachineProfile 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 vm) { + public void deallocate(Network config, NicProfile nic, VirtualMachineProfile 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; } } diff --git a/server/src/com/cloud/network/dao/NetworkConfigurationDao.java b/server/src/com/cloud/network/dao/NetworkDao.java similarity index 71% rename from server/src/com/cloud/network/dao/NetworkConfigurationDao.java rename to server/src/com/cloud/network/dao/NetworkDao.java index 74571cecc0f..a6f92858ed3 100644 --- a/server/src/com/cloud/network/dao/NetworkConfigurationDao.java +++ b/server/src/com/cloud/network/dao/NetworkDao.java @@ -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 { - List listBy(long accountId); - List listBy(long accountId, long offeringId, long dataCenterId); +public interface NetworkDao extends GenericDao { + List listBy(long accountId); + List listBy(long accountId, long offeringId, long dataCenterId); @Override - NetworkConfigurationVO persist(NetworkConfigurationVO config); + NetworkVO persist(NetworkVO config); void addAccountToNetworkConfiguration(long configId, long accountId); SearchBuilder createSearchBuilderForAccount(); - List getNetworkConfigurationsForOffering(long offeringId, long dataCenterId, long accountId); - List getRelatedNetworkConfigurations(long related); + List getNetworkConfigurationsForOffering(long offeringId, long dataCenterId, long accountId); + List getRelatedNetworkConfigurations(long related); /** * Retrieves the next available mac address in this network configuration. diff --git a/server/src/com/cloud/network/dao/NetworkConfigurationDaoImpl.java b/server/src/com/cloud/network/dao/NetworkDaoImpl.java similarity index 76% rename from server/src/com/cloud/network/dao/NetworkConfigurationDaoImpl.java rename to server/src/com/cloud/network/dao/NetworkDaoImpl.java index 3e77b050b65..1373629b5e4 100644 --- a/server/src/com/cloud/network/dao/NetworkConfigurationDaoImpl.java +++ b/server/src/com/cloud/network/dao/NetworkDaoImpl.java @@ -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 implements NetworkConfigurationDao { - final SearchBuilder ProfileSearch; - final SearchBuilder AccountSearch; - final SearchBuilder OfferingSearch; - final SearchBuilder RelatedConfigSearch; - final SearchBuilder RelatedConfigsSearch; +@Local(value=NetworkDao.class) @DB(txn=false) +public class NetworkDaoImpl extends GenericDaoBase implements NetworkDao { + final SearchBuilder ProfileSearch; + final SearchBuilder AccountSearch; + final SearchBuilder OfferingSearch; + final SearchBuilder RelatedConfigSearch; + final SearchBuilder 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 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 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 findBy(TrafficType trafficType, Mode mode, BroadcastDomainType broadcastType, long networkOfferingId, long dataCenterId) { - SearchCriteria sc = ProfileSearch.create(); + public List findBy(TrafficType trafficType, Mode mode, BroadcastDomainType broadcastType, long networkOfferingId, long dataCenterId) { + SearchCriteria sc = ProfileSearch.create(); sc.setParameters("trafficType", trafficType); sc.setParameters("broadcastType", broadcastType); sc.setParameters("offering", networkOfferingId); @@ -104,8 +104,8 @@ public class NetworkConfigurationDaoImpl extends GenericDaoBase listBy(long accountId) { - SearchCriteria sc = AccountSearch.create(); + public List listBy(long accountId) { + SearchCriteria sc = AccountSearch.create(); sc.setParameters("account", accountId); sc.setJoinParameters("accounts", "account", accountId); @@ -113,8 +113,8 @@ public class NetworkConfigurationDaoImpl extends GenericDaoBase listBy(long accountId, long offeringId, long dataCenterId) { - SearchCriteria sc = AccountSearch.create(); + public List listBy(long accountId, long offeringId, long dataCenterId) { + SearchCriteria 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 getNetworkConfigurationsForOffering(long offeringId, long dataCenterId, long accountId) { - SearchCriteria sc = RelatedConfigSearch.create(); + public List getNetworkConfigurationsForOffering(long offeringId, long dataCenterId, long accountId) { + SearchCriteria 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 getRelatedNetworkConfigurations(long related) { - SearchCriteria sc = RelatedConfigsSearch.create(); + public List getRelatedNetworkConfigurations(long related) { + SearchCriteria sc = RelatedConfigsSearch.create(); sc.setParameters("related", related); return search(sc, null); } diff --git a/server/src/com/cloud/network/element/DomainRouterElement.java b/server/src/com/cloud/network/element/DomainRouterElement.java index 86d34ff11d3..9acd82e6b09 100644 --- a/server/src/com/cloud/network/element/DomainRouterElement.java +++ b/server/src/com/cloud/network/element/DomainRouterElement.java @@ -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 vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientNetworkCapacityException, ResourceUnavailableException { + public boolean prepare(Network config, NicProfile nic, VirtualMachineProfile 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 vm, ReservationContext context) { + public boolean release(Network config, NicProfile nic, VirtualMachineProfile 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; diff --git a/server/src/com/cloud/network/router/DomainRouterManager.java b/server/src/com/cloud/network/router/DomainRouterManager.java index 9c6397ac4c0..074753d6b7c 100644 --- a/server/src/com/cloud/network/router/DomainRouterManager.java +++ b/server/src/com/cloud/network/router/DomainRouterManager.java @@ -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 vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientNetworkCapacityException, ResourceUnavailableException; + DomainRouterVO addVirtualMachineIntoNetwork(Network config, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientNetworkCapacityException, ResourceUnavailableException; } diff --git a/server/src/com/cloud/network/router/DomainRouterManagerImpl.java b/server/src/com/cloud/network/router/DomainRouterManagerImpl.java index 542b6266fc9..7c337b3454d 100644 --- a/server/src/com/cloud/network/router/DomainRouterManagerImpl.java +++ b/server/src/com/cloud/network/router/DomainRouterManagerImpl.java @@ -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 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> networks = new ArrayList>(3); + List> networks = new ArrayList>(3); NetworkOfferingVO publicOffering = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemVmPublicNetwork).get(0); - List publicConfigs = _networkMgr.setupNetworkConfiguration(_systemAcct, publicOffering, plan); + List publicConfigs = _networkMgr.setupNetworkConfiguration(_systemAcct, publicOffering, plan); NicProfile defaultNic = new NicProfile(); defaultNic.setDefaultNic(true); //defaultNic.setIp4Address(sourceNatIp); defaultNic.setDeviceId(2); - networks.add(new Pair(publicConfigs.get(0), defaultNic)); + networks.add(new Pair(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)guestConfig, gatewayNic)); - networks.add(new Pair(controlConfig, null)); + networks.add(new Pair((NetworkVO)guestConfig, gatewayNic)); + networks.add(new Pair(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 profile, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, InsufficientNetworkCapacityException, ResourceUnavailableException { + public DomainRouterVO addVirtualMachineIntoNetwork(Network config, NicProfile nic, VirtualMachineProfile 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 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 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) { diff --git a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java index f4133d1f986..9631bbd6d0a 100644 --- a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java +++ b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java @@ -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 defaultOffering = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemVmPublicNetwork); List offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemVmControlNetwork, NetworkOfferingVO.SystemVmManagementNetwork); - List> networks = new ArrayList>(offerings.size() + 1); + List> networks = new ArrayList>(offerings.size() + 1); NicProfile defaultNic = new NicProfile(); defaultNic.setDefaultNic(true); defaultNic.setDeviceId(2); - networks.add(new Pair(_networkMgr.setupNetworkConfiguration(systemAcct, defaultOffering.get(0), plan).get(0), defaultNic)); + networks.add(new Pair(_networkMgr.setupNetworkConfiguration(systemAcct, defaultOffering.get(0), plan).get(0), defaultNic)); for (NetworkOfferingVO offering : offerings) { - networks.add(new Pair(_networkMgr.setupNetworkConfiguration(systemAcct, offering, plan).get(0), null)); + networks.add(new Pair(_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()); diff --git a/server/src/com/cloud/vm/MauriceMoss.java b/server/src/com/cloud/vm/MauriceMoss.java index 38c8503f868..a435d05e83d 100644 --- a/server/src/com/cloud/vm/MauriceMoss.java +++ b/server/src/com/cloud/vm/MauriceMoss.java @@ -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 rootDiskOffering, List> dataDiskOfferings, - List> networks, + List> networks, Map params, DeploymentPlan plan, Account owner) throws InsufficientCapacityException { @@ -185,7 +185,7 @@ public class MauriceMoss implements VmManager, ClusterManagerListener { ServiceOfferingVO serviceOffering, Long rootSize, Pair dataDiskOffering, - List> networks, + List> networks, DeploymentPlan plan, Account owner) throws InsufficientCapacityException { List> diskOfferings = new ArrayList>(1); @@ -199,7 +199,7 @@ public class MauriceMoss implements VmManager, ClusterManagerListener { public T allocate(T vm, VMTemplateVO template, ServiceOfferingVO serviceOffering, - List> networks, + List> networks, DeploymentPlan plan, Account owner) throws InsufficientCapacityException { return allocate(vm, template, serviceOffering, new Pair(serviceOffering, null), null, networks, null, plan, owner); diff --git a/server/src/com/cloud/vm/NicVO.java b/server/src/com/cloud/vm/NicVO.java index 239bfba49f9..3e0e1481fff 100644 --- a/server/src/com/cloud/vm/NicVO.java +++ b/server/src/com/cloud/vm/NicVO.java @@ -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 diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 9b3289cc256..56c295a9b5e 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -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 configs = _networkMgr.setupNetworkConfiguration(owner, offering, plan); - List> networks = new ArrayList>(); - for (NetworkConfigurationVO config : configs) { - networks.add(new Pair(config, null)); + List configs = _networkMgr.setupNetworkConfiguration(owner, offering, plan); + List> networks = new ArrayList>(); + for (NetworkVO config : configs) { + networks.add(new Pair(config, null)); } diff --git a/server/src/com/cloud/vm/VmManager.java b/server/src/com/cloud/vm/VmManager.java index 46a2bdebd9d..63ea51d7474 100644 --- a/server/src/com/cloud/vm/VmManager.java +++ b/server/src/com/cloud/vm/VmManager.java @@ -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 rootDiskOffering, List> dataDiskOfferings, - List> networks, + List> networks, Map params, DeploymentPlan plan, Account owner) throws InsufficientCapacityException, StorageUnavailableException; @@ -56,14 +56,14 @@ public interface VmManager extends Manager { ServiceOfferingVO serviceOffering, Long rootSize, Pair dataDiskOffering, - List> networks, + List> networks, DeploymentPlan plan, Account owner) throws InsufficientCapacityException, StorageUnavailableException; T allocate(T vm, VMTemplateVO template, ServiceOfferingVO serviceOffering, - List> networkProfiles, + List> networkProfiles, DeploymentPlan plan, Account owner) throws InsufficientCapacityException, StorageUnavailableException; diff --git a/server/src/com/cloud/vm/dao/NicDaoImpl.java b/server/src/com/cloud/vm/dao/NicDaoImpl.java index ba209d5e8bf..3e43214e99f 100644 --- a/server/src/com/cloud/vm/dao/NicDaoImpl.java +++ b/server/src/com/cloud/vm/dao/NicDaoImpl.java @@ -28,7 +28,7 @@ public class NicDaoImpl extends GenericDaoBase 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(); } diff --git a/setup/db/create-index-fk.sql b/setup/db/create-index-fk.sql index 812160bffea..1dd3b1bc61a 100755 --- a/setup/db/create-index-fk.sql +++ b/setup/db/create-index-fk.sql @@ -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`); diff --git a/setup/db/create-schema.sql b/setup/db/create-schema.sql index 424a970a61c..0aa7000398c 100755 --- a/setup/db/create-schema.sql +++ b/setup/db/create-schema.sql @@ -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'; diff --git a/utils/src/com/cloud/utils/component/ComponentLocator.java b/utils/src/com/cloud/utils/component/ComponentLocator.java index 7efa68b6916..39a13894611 100755 --- a/utils/src/com/cloud/utils/component/ComponentLocator.java +++ b/utils/src/com/cloud/utils/component/ComponentLocator.java @@ -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);