mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	Added Availability field for NetworkOffering. Added updateNetworkOffering API command
This commit is contained in:
		
							parent
							
								
									ee6e7b8bf3
								
							
						
					
					
						commit
						d673686f5f
					
				| @ -174,5 +174,6 @@ public class ApiConstants { | ||||
|     public static final String SPECIFY_VLAN = "specifyvlan"; | ||||
|     public static final String IS_DEFAULT = "isdefault"; | ||||
|     public static final String IS_SYSTEM = "issystem"; | ||||
|     public static final String AVAILABILITY = "availability"; | ||||
| } | ||||
|   | ||||
|  | ||||
| @ -26,6 +26,7 @@ import com.cloud.api.Implementation; | ||||
| import com.cloud.api.Parameter; | ||||
| import com.cloud.api.ServerApiException; | ||||
| import com.cloud.api.response.NetworkOfferingResponse; | ||||
| import com.cloud.network.Networks.Availability; | ||||
| import com.cloud.offering.NetworkOffering; | ||||
| 
 | ||||
| @Implementation(description="Creates a network offering.", responseObject=NetworkOfferingResponse.class) | ||||
| @ -57,6 +58,9 @@ public class CreateNetworkOfferingCmd extends BaseCmd { | ||||
|      | ||||
|     @Parameter(name=ApiConstants.SPECIFY_VLAN, type=CommandType.BOOLEAN, description="true is network offering supports vlans") | ||||
|     private Boolean specifyVlan;  | ||||
|      | ||||
|     @Parameter(name=ApiConstants.AVAILABILITY, type=CommandType.STRING, description="the availability of network offering. Default value is Required") | ||||
|     private String availability;  | ||||
| 
 | ||||
|     ///////////////////////////////////////////////////// | ||||
|     /////////////////// Accessors /////////////////////// | ||||
| @ -87,7 +91,12 @@ public class CreateNetworkOfferingCmd extends BaseCmd { | ||||
|     } | ||||
|      | ||||
|     public Boolean getSpecifyVlan() { | ||||
|         return specifyVlan; | ||||
|         return specifyVlan == null ? false : specifyVlan; | ||||
|     } | ||||
| 
 | ||||
|     public String getAvailability() { | ||||
|         //Verify availability | ||||
|         return availability == null ? Availability.Required.toString() : availability; | ||||
|     } | ||||
| 
 | ||||
|     ///////////////////////////////////////////////////// | ||||
|  | ||||
| @ -63,6 +63,9 @@ public class ListNetworkOfferingsCmd extends BaseListCmd { | ||||
|      | ||||
|     @Parameter(name=ApiConstants.IS_SHARED, type=CommandType.BOOLEAN, description="true is network offering supports vlans") | ||||
|     private Boolean isShared;  | ||||
|      | ||||
|     @Parameter(name=ApiConstants.AVAILABILITY, type=CommandType.STRING, description="the availability of network offering. Default value is Required") | ||||
|     private String availability;  | ||||
| 
 | ||||
|     ///////////////////////////////////////////////////// | ||||
|     /////////////////// Accessors /////////////////////// | ||||
| @ -99,6 +102,10 @@ public class ListNetworkOfferingsCmd extends BaseListCmd { | ||||
|     public Boolean getIsShared() { | ||||
|         return isShared; | ||||
|     } | ||||
|      | ||||
|     public String getAvailability() { | ||||
|         return availability; | ||||
|     } | ||||
| 
 | ||||
|     ///////////////////////////////////////////////////// | ||||
|     /////////////// API Implementation/////////////////// | ||||
|  | ||||
							
								
								
									
										92
									
								
								api/src/com/cloud/api/commands/UpdateNetworkOfferingCmd.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										92
									
								
								api/src/com/cloud/api/commands/UpdateNetworkOfferingCmd.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,92 @@ | ||||
| /** | ||||
|  *  Copyright (C) 2010 Cloud.com, Inc.  All rights reserved. | ||||
|  *  | ||||
|  * This software is licensed under the GNU General Public License v3 or later. | ||||
|  *  | ||||
|  * It is free software: you can redistribute it and/or modify | ||||
|  * it under the terms of the GNU General Public License as published by | ||||
|  * the Free Software Foundation, either version 3 of the License, or any later version. | ||||
|  * This program is distributed in the hope that it will be useful, | ||||
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | ||||
|  * GNU General Public License for more details. | ||||
|  *  | ||||
|  * You should have received a copy of the GNU General Public License | ||||
|  * along with this program.  If not, see <http://www.gnu.org/licenses/>. | ||||
|  *  | ||||
|  */ | ||||
| 
 | ||||
| package com.cloud.api.commands; | ||||
| 
 | ||||
| import org.apache.log4j.Logger; | ||||
| 
 | ||||
| import com.cloud.api.ApiConstants; | ||||
| import com.cloud.api.BaseCmd; | ||||
| import com.cloud.api.Implementation; | ||||
| import com.cloud.api.Parameter; | ||||
| import com.cloud.api.ServerApiException; | ||||
| import com.cloud.api.response.NetworkOfferingResponse; | ||||
| import com.cloud.network.Networks.Availability; | ||||
| import com.cloud.offering.NetworkOffering; | ||||
| 
 | ||||
| @Implementation(description="Updates a network offering.", responseObject=NetworkOfferingResponse.class) | ||||
| public class UpdateNetworkOfferingCmd extends BaseCmd { | ||||
|     public static final Logger s_logger = Logger.getLogger(UpdateNetworkOfferingCmd.class.getName()); | ||||
|     private static final String _name = "createnetworkofferingresponse"; | ||||
| 
 | ||||
|     ///////////////////////////////////////////////////// | ||||
|     //////////////// API parameters ///////////////////// | ||||
|     ///////////////////////////////////////////////////// | ||||
|      | ||||
|     @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="the id of the network offering") | ||||
|     private Long id; | ||||
| 
 | ||||
|     @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of the network offering") | ||||
|     private String networkOfferingName; | ||||
|      | ||||
|     @Parameter(name=ApiConstants.DISPLAY_TEXT, type=CommandType.STRING, description="the display text of the network offering") | ||||
|     private String displayText; | ||||
|      | ||||
|     @Parameter(name=ApiConstants.AVAILABILITY, type=CommandType.STRING, description="the availability of network offering. Default value is Required") | ||||
|     private String availability;  | ||||
| 
 | ||||
|     ///////////////////////////////////////////////////// | ||||
|     /////////////////// Accessors /////////////////////// | ||||
|     ///////////////////////////////////////////////////// | ||||
|      | ||||
|     public String getNetworkOfferingName() { | ||||
|         return networkOfferingName; | ||||
|     } | ||||
|      | ||||
|     public String getDisplayText() { | ||||
|         return displayText; | ||||
|     } | ||||
|      | ||||
|     public Long getId() { | ||||
|         return id; | ||||
|     } | ||||
| 
 | ||||
|     public String getAvailability() { | ||||
|         return availability == null ? Availability.Required.toString() : availability; | ||||
|     } | ||||
| 
 | ||||
|     ///////////////////////////////////////////////////// | ||||
|     /////////////// API Implementation/////////////////// | ||||
|     ///////////////////////////////////////////////////// | ||||
|     @Override | ||||
|     public String getCommandName() { | ||||
|         return _name; | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void execute(){ | ||||
|         NetworkOffering result = _configService.updateNetworkOffering(this); | ||||
|         if (result != null) { | ||||
|             NetworkOfferingResponse response = _responseGenerator.createNetworkOfferingResponse(result); | ||||
|             response.setResponseName(getCommandName()); | ||||
|             this.setResponseObject(response); | ||||
|         } else { | ||||
|             throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update network offering"); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @ -35,6 +35,9 @@ public class NetworkOfferingResponse extends BaseResponse{ | ||||
|     | ||||
|     @SerializedName("specifyvlan") @Param(description="true if network offering supports vlans, false otherwise") | ||||
|     private Boolean specifyVlan; | ||||
|      | ||||
|     @SerializedName("availability") @Param(description="availability of the network offering") | ||||
|     private String availability; | ||||
| 
 | ||||
|     public Long getId() { | ||||
|         return id; | ||||
| @ -123,4 +126,12 @@ public class NetworkOfferingResponse extends BaseResponse{ | ||||
|     public void setSpecifyVlan(Boolean specifyVlan) { | ||||
|         this.specifyVlan = specifyVlan; | ||||
|     } | ||||
| 
 | ||||
|     public String getAvailability() { | ||||
|         return availability; | ||||
|     } | ||||
| 
 | ||||
|     public void setAvailability(String availability) { | ||||
|         this.availability = availability; | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -53,6 +53,11 @@ public class NetworkResponse extends BaseResponse{ | ||||
|     @SerializedName("networkofferingdisplaytext") | ||||
|     private String networkOfferingDisplayText; | ||||
|      | ||||
|     //TODO - add description | ||||
|     @SerializedName("networkofferingavailability") | ||||
|     private String networkOfferingAvailability; | ||||
|      | ||||
|      | ||||
|   //TODO - add description | ||||
|     @SerializedName("isshared") | ||||
|     private Boolean isShared; | ||||
| @ -297,6 +302,14 @@ public class NetworkResponse extends BaseResponse{ | ||||
| 	public void setDomain(String domain) { | ||||
| 		this.domain = domain; | ||||
| 	} | ||||
| 
 | ||||
|     public String getNetworkOfferingAvailability() { | ||||
|         return networkOfferingAvailability; | ||||
|     } | ||||
| 
 | ||||
|     public void setNetworkOfferingAvailability(String networkOfferingAvailability) { | ||||
|         this.networkOfferingAvailability = networkOfferingAvailability; | ||||
|     } | ||||
|      | ||||
|      | ||||
| } | ||||
|  | ||||
| @ -18,6 +18,7 @@ import com.cloud.api.commands.DeleteZoneCmd; | ||||
| import com.cloud.api.commands.ListNetworkOfferingsCmd; | ||||
| import com.cloud.api.commands.UpdateCfgCmd; | ||||
| import com.cloud.api.commands.UpdateDiskOfferingCmd; | ||||
| import com.cloud.api.commands.UpdateNetworkOfferingCmd; | ||||
| import com.cloud.api.commands.UpdatePodCmd; | ||||
| import com.cloud.api.commands.UpdateServiceOfferingCmd; | ||||
| import com.cloud.api.commands.UpdateZoneCmd; | ||||
| @ -178,6 +179,8 @@ public interface ConfigurationService { | ||||
|      | ||||
|     NetworkOffering createNetworkOffering(CreateNetworkOfferingCmd cmd); | ||||
|      | ||||
|     NetworkOffering updateNetworkOffering(UpdateNetworkOfferingCmd cmd); | ||||
|      | ||||
|     List<? extends NetworkOffering> searchForNetworkOfferings(ListNetworkOfferingsCmd cmd); | ||||
|      | ||||
|     boolean deleteNetworkOffering(DeleteNetworkOfferingCmd cmd); | ||||
|  | ||||
| @ -36,6 +36,12 @@ public class Networks { | ||||
|         Firewall | ||||
|     } | ||||
|      | ||||
|     public enum Availability { | ||||
|         Required, | ||||
|         Optional, | ||||
|         Unavailable; | ||||
|     } | ||||
|      | ||||
|     /** | ||||
|      * Different ways to assign ip address to this network. | ||||
|      */ | ||||
|  | ||||
| @ -17,6 +17,7 @@ | ||||
|  */ | ||||
| package com.cloud.offering; | ||||
| 
 | ||||
| import com.cloud.network.Networks.Availability; | ||||
| import com.cloud.network.Networks.TrafficType; | ||||
| 
 | ||||
| /** | ||||
| @ -77,4 +78,6 @@ public interface NetworkOffering { | ||||
|     boolean isDefault(); | ||||
|      | ||||
|     boolean isSystemOnly(); | ||||
|      | ||||
|     Availability getAvailability(); | ||||
| } | ||||
|  | ||||
| @ -233,6 +233,7 @@ listVpnUsers=com.cloud.api.commands.ListVpnUsersCmd;15 | ||||
| 
 | ||||
| #### network offering commands | ||||
| createNetworkOffering=com.cloud.api.commands.CreateNetworkOfferingCmd;1 | ||||
| updateNetworkOffering=com.cloud.api.commands.UpdateNetworkOfferingCmd;1 | ||||
| deleteNetworkOffering=com.cloud.api.commands.DeleteNetworkOfferingCmd;1 | ||||
| listNetworkOfferings=com.cloud.api.commands.ListNetworkOfferingsCmd;15 | ||||
| 
 | ||||
|  | ||||
| @ -2109,6 +2109,7 @@ public class ApiResponseHelper implements ResponseGenerator { | ||||
|         response.setMaxconnections(offering.getConcurrentConnections()); | ||||
|         response.setIsDefault(offering.isDefault()); | ||||
|         response.setSpecifyVlan(offering.getSpecifyVlan()); | ||||
|         response.setAvailability(offering.getAvailability().toString()); | ||||
|         response.setObjectName("networkoffering"); | ||||
|         return response; | ||||
|     } | ||||
| @ -2156,6 +2157,7 @@ public class ApiResponseHelper implements ResponseGenerator { | ||||
|             response.setNetworkOfferingName(networkOffering.getName()); | ||||
|             response.setNetworkOfferingDisplayText(networkOffering.getDisplayText()); | ||||
|             response.setIsSystem(networkOffering.isSystemOnly()); | ||||
|             response.setNetworkOfferingAvailability(networkOffering.getAvailability().toString()); | ||||
|         } | ||||
|          | ||||
|         response.setIsShared(network.isShared()); | ||||
|  | ||||
| @ -29,6 +29,7 @@ import com.cloud.exception.InsufficientAddressCapacityException; | ||||
| import com.cloud.exception.InsufficientCapacityException; | ||||
| import com.cloud.exception.InvalidParameterValueException; | ||||
| import com.cloud.exception.PermissionDeniedException; | ||||
| import com.cloud.network.Networks.Availability; | ||||
| import com.cloud.network.Networks.TrafficType; | ||||
| import com.cloud.offering.DiskOffering; | ||||
| import com.cloud.offering.NetworkOffering.GuestIpType; | ||||
| @ -179,7 +180,7 @@ public interface ConfigurationManager extends Manager { | ||||
|      * @param specifyVlan; | ||||
|      * @return network offering object | ||||
|      */ | ||||
|     NetworkOfferingVO createNetworkOffering(long userId, String name, String displayText, GuestIpType type, TrafficType trafficType, String tags, Integer maxConnections, boolean specifyVlan); | ||||
|     NetworkOfferingVO createNetworkOffering(long userId, String name, String displayText, GuestIpType type, TrafficType trafficType, String tags, Integer maxConnections, boolean specifyVlan, Availability availability); | ||||
|      | ||||
|     Vlan createVlanAndPublicIpRange(Long userId, Long zoneId, Long podId, String startIP, String endIP, String vlanGateway, String vlanNetmask, boolean forVirtualNetwork, String vlanId, Account account, Long networkId) throws InsufficientCapacityException, ConcurrentOperationException, InvalidParameterValueException; | ||||
|      | ||||
|  | ||||
| @ -49,6 +49,7 @@ import com.cloud.api.commands.DeleteZoneCmd; | ||||
| import com.cloud.api.commands.ListNetworkOfferingsCmd; | ||||
| import com.cloud.api.commands.UpdateCfgCmd; | ||||
| import com.cloud.api.commands.UpdateDiskOfferingCmd; | ||||
| import com.cloud.api.commands.UpdateNetworkOfferingCmd; | ||||
| import com.cloud.api.commands.UpdatePodCmd; | ||||
| import com.cloud.api.commands.UpdateServiceOfferingCmd; | ||||
| import com.cloud.api.commands.UpdateZoneCmd; | ||||
| @ -87,6 +88,7 @@ import com.cloud.exception.PermissionDeniedException; | ||||
| import com.cloud.hypervisor.Hypervisor.HypervisorType; | ||||
| import com.cloud.network.NetworkManager; | ||||
| import com.cloud.network.NetworkVO; | ||||
| import com.cloud.network.Networks.Availability; | ||||
| import com.cloud.network.Networks.BroadcastDomainType; | ||||
| import com.cloud.network.Networks.TrafficType; | ||||
| import com.cloud.network.dao.IPAddressDao; | ||||
| @ -2548,8 +2550,12 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura | ||||
|         String typeString = cmd.getType(); | ||||
|         String trafficTypeString = cmd.getTraffictype(); | ||||
|         Boolean specifyVlan = cmd.getSpecifyVlan(); | ||||
|         String availabilityStr = cmd.getAvailability(); | ||||
|          | ||||
|         TrafficType trafficType = null; | ||||
|         GuestIpType type = null; | ||||
|         Availability availability = null; | ||||
|         | ||||
|          | ||||
|         //Verify traffic type | ||||
|         for (TrafficType tType : TrafficType.values()) { | ||||
| @ -2571,22 +2577,29 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura | ||||
|             throw new InvalidParameterValueException("Invalid value for type. Supported types: Virtual, Direct"); | ||||
|         } | ||||
|          | ||||
|         if (specifyVlan == null) { | ||||
|             specifyVlan = false; | ||||
|         //Verify availability | ||||
|         for (Availability avlb : Availability.values()) { | ||||
|             if (avlb.name().equalsIgnoreCase(availabilityStr)) { | ||||
|                 availability = avlb; | ||||
|             } | ||||
|         } | ||||
|          | ||||
|         if (availability == null) { | ||||
|             throw new InvalidParameterValueException("Invalid value for Availability. Supported types: " + Availability.Required + ", " + Availability.Optional + ", " + Availability.Unavailable); | ||||
|         } | ||||
| 
 | ||||
|         Integer maxConnections = cmd.getMaxconnections(); | ||||
|         return createNetworkOffering(userId, name, displayText, type, trafficType, tags, maxConnections, specifyVlan); | ||||
|         return createNetworkOffering(userId, name, displayText, type, trafficType, tags, maxConnections, specifyVlan, availability); | ||||
|     } | ||||
|      | ||||
|     @Override | ||||
|     public NetworkOfferingVO createNetworkOffering(long userId, String name, String displayText, GuestIpType type, TrafficType trafficType, String tags, Integer maxConnections, boolean specifyVlan) { | ||||
|     public NetworkOfferingVO createNetworkOffering(long userId, String name, String displayText, GuestIpType type, TrafficType trafficType, String tags, Integer maxConnections, boolean specifyVlan, Availability availability) { | ||||
|         String networkRateStr = _configDao.getValue("network.throttling.rate"); | ||||
|         String multicastRateStr = _configDao.getValue("multicast.throttling.rate"); | ||||
|         int networkRate = ((networkRateStr == null) ? 200 : Integer.parseInt(networkRateStr)); | ||||
|         int multicastRate = ((multicastRateStr == null) ? 10 : Integer.parseInt(multicastRateStr));       | ||||
|         tags = cleanupTags(tags); | ||||
|         NetworkOfferingVO offering = new NetworkOfferingVO(name, displayText, trafficType, type, false, specifyVlan, networkRate, multicastRate, maxConnections, false); | ||||
|         NetworkOfferingVO offering = new NetworkOfferingVO(name, displayText, trafficType, type, false, specifyVlan, networkRate, multicastRate, maxConnections, false, availability); | ||||
|          | ||||
|         if ((offering = _networkOfferingDao.persist(offering)) != null) { | ||||
|             saveConfigurationEvent(userId, null, EventTypes.EVENT_NETWORK_OFFERING_CREATE, "Successfully created new network offering with name: " + name + ".", "noId=" + offering.getId(), "name=" + name, | ||||
| @ -2610,6 +2623,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura | ||||
|         Object isDefault = cmd.getIsDefault(); | ||||
|         Object specifyVlan = cmd.getSpecifyVlan(); | ||||
|         Object isShared = cmd.getIsShared(); | ||||
|         Object availability = cmd.getAvailability(); | ||||
|          | ||||
|         Object keyword = cmd.getKeyword(); | ||||
| 
 | ||||
| @ -2650,6 +2664,10 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura | ||||
|             sc.addAnd("isShared", SearchCriteria.Op.EQ, isShared); | ||||
|         } | ||||
|          | ||||
|         if (availability != null) { | ||||
|             sc.addAnd("availability", SearchCriteria.Op.EQ, availability); | ||||
|         } | ||||
|          | ||||
|         //Don't return system network offerings to the user | ||||
|         sc.addAnd("systemOnly", SearchCriteria.Op.EQ, false); | ||||
|          | ||||
| @ -2682,4 +2700,52 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura | ||||
|             return false; | ||||
|         } | ||||
|     } | ||||
|      | ||||
|      | ||||
|      | ||||
|     @Override | ||||
|     public NetworkOffering updateNetworkOffering(UpdateNetworkOfferingCmd cmd) { | ||||
|         String displayText = cmd.getDisplayText(); | ||||
|         Long id = cmd.getId(); | ||||
|         String name = cmd.getNetworkOfferingName(); | ||||
|         String availabilityStr = cmd.getAvailability(); | ||||
|         Availability availability = null; | ||||
|          | ||||
|         // Verify input parameters | ||||
|         NetworkOfferingVO offeringHandle = _networkOfferingDao.findById(id); | ||||
|         if (offeringHandle == null) { | ||||
|             throw new ServerApiException(BaseCmd.PARAM_ERROR, "unable to find network offering " + id); | ||||
|         } | ||||
| 
 | ||||
|         NetworkOfferingVO offering = _networkOfferingDao.createForUpdate(id); | ||||
| 
 | ||||
|         if (name != null) { | ||||
|             offering.setName(name); | ||||
|         } | ||||
|          | ||||
|         if (displayText != null) { | ||||
|             offering.setDisplayText(displayText); | ||||
|         } | ||||
| 
 | ||||
|         //Verify availability | ||||
|         if (availabilityStr != null) { | ||||
|             for (Availability avlb : Availability.values()) { | ||||
|                 if (avlb.name().equalsIgnoreCase(availabilityStr)) { | ||||
|                     availability = avlb; | ||||
|                 } | ||||
|             } | ||||
|             if (availability == null) { | ||||
|                 throw new InvalidParameterValueException("Invalid value for Availability. Supported types: " + Availability.Required + ", " + Availability.Optional + ", " + Availability.Unavailable); | ||||
|             } else { | ||||
|                 offering.setAvailability(availability); | ||||
|             } | ||||
|         }  | ||||
|          | ||||
|         if (_networkOfferingDao.update(id, offering)) { | ||||
|             offering = _networkOfferingDao.findById(id); | ||||
|             return offering; | ||||
|         } else { | ||||
|             return null; | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -85,6 +85,7 @@ import com.cloud.exception.PermissionDeniedException; | ||||
| import com.cloud.exception.ResourceAllocationException; | ||||
| import com.cloud.exception.ResourceUnavailableException; | ||||
| import com.cloud.network.Networks.AddressFormat; | ||||
| import com.cloud.network.Networks.Availability; | ||||
| import com.cloud.network.Networks.BroadcastDomainType; | ||||
| import com.cloud.network.Networks.TrafficType; | ||||
| import com.cloud.network.addr.PublicIp; | ||||
| @ -764,11 +765,11 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag | ||||
|         storageNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(storageNetworkOffering); | ||||
|         _systemNetworks.put(NetworkOfferingVO.SystemVmStorageNetwork, storageNetworkOffering); | ||||
| 
 | ||||
|         NetworkOfferingVO defaultGuestNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultVirtualizedNetworkOffering, "Virtual Vlan", TrafficType.Guest, GuestIpType.Virtual, false, false, rateMbps, multicastRateMbps, null, true); | ||||
|         NetworkOfferingVO defaultGuestNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultVirtualizedNetworkOffering, "Virtual Vlan", TrafficType.Guest, GuestIpType.Virtual, false, false, rateMbps, multicastRateMbps, null, true, Availability.Required); | ||||
|         defaultGuestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultGuestNetworkOffering); | ||||
|         NetworkOfferingVO defaultGuestDirectNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultDirectNetworkOffering, "Direct", TrafficType.Public, GuestIpType.Direct, false, false, rateMbps, multicastRateMbps, null, true); | ||||
|         NetworkOfferingVO defaultGuestDirectNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultDirectNetworkOffering, "Direct", TrafficType.Public, GuestIpType.Direct, false, false, rateMbps, multicastRateMbps, null, true, Availability.Required); | ||||
|         defaultGuestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultGuestDirectNetworkOffering); | ||||
|         NetworkOfferingVO defaultGuestDirectPodBasedNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultDirectPodBasedNetworkOffering, "DirectPodBased", TrafficType.Public, GuestIpType.DirectPodBased, true, false, rateMbps, multicastRateMbps, null, true); | ||||
|         NetworkOfferingVO defaultGuestDirectPodBasedNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultDirectPodBasedNetworkOffering, "DirectPodBased", TrafficType.Public, GuestIpType.DirectPodBased, true, false, rateMbps, multicastRateMbps, null, true, Availability.Required); | ||||
|         defaultGuestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultGuestDirectPodBasedNetworkOffering); | ||||
|          | ||||
|         AccountsUsingNetworkSearch = _accountDao.createSearchBuilder(); | ||||
|  | ||||
| @ -28,6 +28,7 @@ import javax.persistence.GenerationType; | ||||
| import javax.persistence.Id; | ||||
| import javax.persistence.Table; | ||||
| 
 | ||||
| import com.cloud.network.Networks.Availability; | ||||
| import com.cloud.network.Networks.TrafficType; | ||||
| import com.cloud.offering.NetworkOffering; | ||||
| import com.cloud.service.ServiceOfferingVO; | ||||
| @ -89,6 +90,10 @@ public class NetworkOfferingVO implements NetworkOffering { | ||||
|      | ||||
|     @Column(name=GenericDao.CREATED_COLUMN) | ||||
|     Date created; | ||||
|      | ||||
|     @Column(name="availability") | ||||
|     @Enumerated(value=EnumType.STRING) | ||||
|     Availability availability; | ||||
| 
 | ||||
|     @Override | ||||
|     public String getDisplayText() { | ||||
| @ -212,8 +217,17 @@ public class NetworkOfferingVO implements NetworkOffering { | ||||
|     public void setCreated(Date created) { | ||||
|         this.created = created; | ||||
|     } | ||||
|      | ||||
|     @Override | ||||
|     public Availability getAvailability() { | ||||
|         return availability; | ||||
|     } | ||||
| 
 | ||||
|     public NetworkOfferingVO(String name, String displayText, TrafficType trafficType, GuestIpType type, boolean systemOnly, boolean specifyVlan, Integer rateMbps, Integer multicastRateMbps, Integer concurrentConnections, boolean isDefault) { | ||||
|     public void setAvailability(Availability availability) { | ||||
|         this.availability = availability; | ||||
|     } | ||||
| 
 | ||||
|     public NetworkOfferingVO(String name, String displayText, TrafficType trafficType, GuestIpType type, boolean systemOnly, boolean specifyVlan, Integer rateMbps, Integer multicastRateMbps, Integer concurrentConnections, boolean isDefault, Availability availability) { | ||||
|         this.name = name; | ||||
|         this.displayText = displayText; | ||||
|         this.guestIpType = type; | ||||
| @ -224,10 +238,11 @@ public class NetworkOfferingVO implements NetworkOffering { | ||||
|         this.systemOnly = systemOnly; | ||||
|         this.specifyVlan = specifyVlan; | ||||
|         this.isDefault = isDefault; | ||||
|         this.availability = availability; | ||||
|     } | ||||
|      | ||||
|     public NetworkOfferingVO(ServiceOfferingVO offering) { | ||||
|         this("Network Offering for " + offering.getName(), "Network Offering for " + offering.getDisplayText(), TrafficType.Guest, offering.getGuestIpType(), false, false, offering.getRateMbps(), offering.getMulticastRateMbps(), null, false); | ||||
|         this("Network Offering for " + offering.getName(), "Network Offering for " + offering.getDisplayText(), TrafficType.Guest, offering.getGuestIpType(), false, false, offering.getRateMbps(), offering.getMulticastRateMbps(), null, false, Availability.Required); | ||||
|         this.serviceOfferingId = offering.getId(); | ||||
|     } | ||||
|      | ||||
| @ -239,7 +254,7 @@ public class NetworkOfferingVO implements NetworkOffering { | ||||
|      * @param type | ||||
|      */ | ||||
|     public NetworkOfferingVO(String name, TrafficType trafficType, GuestIpType type) { | ||||
|         this(name, "System Offering for " + name, trafficType, type, true, false, null, null, null, false); | ||||
|         this(name, "System Offering for " + name, trafficType, type, true, false, null, null, null, false, Availability.Required); | ||||
|     } | ||||
|      | ||||
|     @Override | ||||
|  | ||||
| @ -55,6 +55,7 @@ import com.cloud.exception.InternalErrorException; | ||||
| import com.cloud.exception.InvalidParameterValueException; | ||||
| import com.cloud.network.Network.State; | ||||
| import com.cloud.network.NetworkVO; | ||||
| import com.cloud.network.Networks.Availability; | ||||
| import com.cloud.network.Networks.BroadcastDomainType; | ||||
| import com.cloud.network.Networks.Mode; | ||||
| import com.cloud.network.Networks.TrafficType; | ||||
| @ -720,11 +721,11 @@ public class ConfigurationServerImpl implements ConfigurationServer { | ||||
|         controlNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(controlNetworkOffering); | ||||
|         NetworkOfferingVO storageNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemVmStorageNetwork, TrafficType.Storage, null); | ||||
|         storageNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(storageNetworkOffering); | ||||
|         NetworkOfferingVO defaultGuestNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultVirtualizedNetworkOffering, "Virtual Vlan", TrafficType.Guest, GuestIpType.Virtual, false, false, rateMbps, multicastRateMbps, null, true); | ||||
|         NetworkOfferingVO defaultGuestNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultVirtualizedNetworkOffering, "Virtual Vlan", TrafficType.Guest, GuestIpType.Virtual, false, false, rateMbps, multicastRateMbps, null, true, Availability.Required); | ||||
|         defaultGuestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultGuestNetworkOffering); | ||||
|         NetworkOfferingVO defaultGuestDirectNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultDirectNetworkOffering, "Direct", TrafficType.Public, GuestIpType.Direct, false, false, rateMbps, multicastRateMbps, null, true); | ||||
|         NetworkOfferingVO defaultGuestDirectNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultDirectNetworkOffering, "Direct", TrafficType.Public, GuestIpType.Direct, false, false, rateMbps, multicastRateMbps, null, true, Availability.Required); | ||||
|         defaultGuestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultGuestDirectNetworkOffering); | ||||
|         NetworkOfferingVO defaultGuestDirectPodBasedNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultDirectPodBasedNetworkOffering, "DirectPodBased", TrafficType.Public, GuestIpType.DirectPodBased, true, false, rateMbps, multicastRateMbps, null, true); | ||||
|         NetworkOfferingVO defaultGuestDirectPodBasedNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultDirectPodBasedNetworkOffering, "DirectPodBased", TrafficType.Public, GuestIpType.DirectPodBased, true, false, rateMbps, multicastRateMbps, null, true, Availability.Required); | ||||
|         defaultGuestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultGuestDirectPodBasedNetworkOffering); | ||||
|     } | ||||
|      | ||||
|  | ||||
| @ -209,6 +209,7 @@ CREATE TABLE `cloud`.`network_offerings` ( | ||||
|   `created` datetime NOT NULL COMMENT 'time the entry was created', | ||||
|   `removed` datetime DEFAULT NULL COMMENT 'time the entry was removed', | ||||
|   `default` int(1) unsigned NOT NULL DEFAULT 0 COMMENT '1 if network is default', | ||||
|   `availability` varchar(255) NOT NULL COMMENT 'availability of the network', | ||||
|   PRIMARY KEY (`id`) | ||||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8; | ||||
| 
 | ||||
|  | ||||
| @ -24,9 +24,6 @@ import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.Set; | ||||
| 
 | ||||
| import com.cloud.utils.db.DB; | ||||
| import com.cloud.utils.db.Transaction; | ||||
| 
 | ||||
| /** | ||||
|  * StateMachine is a partial implementation of a finite state machine. | ||||
|  * Specifically, it implements the Moore machine. | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user