mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	bug 9651: we're saving the tags twice.
This commit is contained in:
		
							parent
							
								
									404e09f6ee
								
							
						
					
					
						commit
						b1de7ece25
					
				| @ -1599,7 +1599,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag | |||||||
|             domainId = cmd.getDomainId(); |             domainId = cmd.getDomainId(); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         Network network = createNetwork(networkOfferingId, name, displayText, isShared, isDefault, zoneId, gateway, cidr, vlanId, networkDomain, owner, false, domainId, null); |         Network network = createNetwork(networkOfferingId, name, displayText, isShared, isDefault, zoneId, gateway, cidr, vlanId, networkDomain, owner, false, domainId, tags); | ||||||
| 
 | 
 | ||||||
|         // Don't pass owner to create vlan when network offering is of type Direct - done to prevent accountVlanMap entry |         // Don't pass owner to create vlan when network offering is of type Direct - done to prevent accountVlanMap entry | ||||||
|         // creation when vlan is mapped to network |         // creation when vlan is mapped to network | ||||||
| @ -2926,6 +2926,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag | |||||||
|      |      | ||||||
|     Random _rand = new Random(System.currentTimeMillis()); |     Random _rand = new Random(System.currentTimeMillis()); | ||||||
|      |      | ||||||
|  |     @Override | ||||||
|     @DB |     @DB | ||||||
|     public String acquireGuestIpAddress(Network network) { |     public String acquireGuestIpAddress(Network network) { | ||||||
|         List<String> ips = _nicDao.listIpAddressInNetwork(network.getId()); |         List<String> ips = _nicDao.listIpAddressInNetwork(network.getId()); | ||||||
|  | |||||||
| @ -55,7 +55,6 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N | |||||||
|     NetworkAccountDaoImpl _accountsDao = ComponentLocator.inject(NetworkAccountDaoImpl.class); |     NetworkAccountDaoImpl _accountsDao = ComponentLocator.inject(NetworkAccountDaoImpl.class); | ||||||
|     NetworkDomainDaoImpl _domainsDao = ComponentLocator.inject(NetworkDomainDaoImpl.class); |     NetworkDomainDaoImpl _domainsDao = ComponentLocator.inject(NetworkDomainDaoImpl.class); | ||||||
|     NetworkOpDaoImpl _opDao = ComponentLocator.inject(NetworkOpDaoImpl.class); |     NetworkOpDaoImpl _opDao = ComponentLocator.inject(NetworkOpDaoImpl.class); | ||||||
|     NetworkTagDaoImpl _tagDao = ComponentLocator.inject(NetworkTagDaoImpl.class); |  | ||||||
| 
 | 
 | ||||||
|     final TableGenerator _tgMacAddress; |     final TableGenerator _tgMacAddress; | ||||||
|     Random _rand = new Random(System.currentTimeMillis()); |     Random _rand = new Random(System.currentTimeMillis()); | ||||||
| @ -180,9 +179,6 @@ public class NetworkDaoImpl extends GenericDaoBase<NetworkVO, Long> implements N | |||||||
|         addAccountToNetwork(network.getId(), network.getAccountId(), true); |         addAccountToNetwork(network.getId(), network.getAccountId(), true); | ||||||
|         NetworkOpVO op = new NetworkOpVO(network.getId(), gc); |         NetworkOpVO op = new NetworkOpVO(network.getId(), gc); | ||||||
|         _opDao.persist(op); |         _opDao.persist(op); | ||||||
|         for (String tag : network.getTags()) { |  | ||||||
|             _tagDao.persist(new NetworkTagVO(network.getId(), tag)); |  | ||||||
|         } |  | ||||||
|         txn.commit(); |         txn.commit(); | ||||||
|         newNetwork.setTags(network.getTags()); |         newNetwork.setTags(network.getTags()); | ||||||
|         return newNetwork; |         return newNetwork; | ||||||
|  | |||||||
| @ -44,7 +44,6 @@ public class NetworkDaoTest extends TestCase { | |||||||
|         retrievedTags = retrieved.getTags(); |         retrievedTags = retrieved.getTags(); | ||||||
|         assert(retrievedTags.size() == 2 && retrievedTags.contains("e") && retrievedTags.contains("f")); |         assert(retrievedTags.size() == 2 && retrievedTags.contains("e") && retrievedTags.contains("f")); | ||||||
|          |          | ||||||
|          |  | ||||||
|         dao.expunge(1001l); |         dao.expunge(1001l); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|  | |||||||
| @ -1218,6 +1218,8 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene | |||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |              | ||||||
|  |             if (_ecAttributes != null && _ecAttributes.size() > 0) { | ||||||
|                 HashMap<Attribute, Object> ecAttributes = new HashMap<Attribute, Object>(); |                 HashMap<Attribute, Object> ecAttributes = new HashMap<Attribute, Object>(); | ||||||
|                 for (Attribute attr : _ecAttributes) { |                 for (Attribute attr : _ecAttributes) { | ||||||
|                     Object ec = attr.field.get(entity); |                     Object ec = attr.field.get(entity); | ||||||
| @ -1227,6 +1229,7 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene | |||||||
|                 } |                 } | ||||||
|                  |                  | ||||||
|                 insertElementCollection(entity, _idAttributes.get(_table)[0], id, ecAttributes); |                 insertElementCollection(entity, _idAttributes.get(_table)[0], id, ecAttributes); | ||||||
|  |             } | ||||||
|             txn.commit(); |             txn.commit(); | ||||||
|         } catch (final SQLException e) { |         } catch (final SQLException e) { | ||||||
|             if (e.getSQLState().equals("23000") && e.getErrorCode() == 1062) { |             if (e.getSQLState().equals("23000") && e.getErrorCode() == 1062) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user