cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bfede...@apache.org
Subject [45/47] git commit: updated refs/heads/ui-vpc-redesign to 1c2ee35
Date Tue, 14 May 2013 20:56:26 GMT
InternalLB: allow domain admin to stop/start internal lb vms


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/eff7587d
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/eff7587d
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/eff7587d

Branch: refs/heads/ui-vpc-redesign
Commit: eff7587d5120ab8eeccbf8a0b488768c7185907d
Parents: 10380ce
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Mon May 13 17:16:30 2013 -0700
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Tue May 14 10:38:17 2013 -0700

----------------------------------------------------------------------
 client/tomcatconf/commands.properties.in           |    6 +-
 .../lb/InternalLoadBalancerVMManagerImpl.java      |    9 +++-
 .../internallbvmmgr/InternalLBVMServiceTest.java   |   35 +++++----------
 .../internallbvmmgr/LbChildTestConfiguration.java  |    8 +++
 4 files changed, 30 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/eff7587d/client/tomcatconf/commands.properties.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in
index 89bc875..f57cc3c 100644
--- a/client/tomcatconf/commands.properties.in
+++ b/client/tomcatconf/commands.properties.in
@@ -603,9 +603,9 @@ listLoadBalancers=15
 deleteLoadBalancer=15
 
 #Internal Load Balancer Element commands
-configureInternalLoadBalancerElement=1
-createInternalLoadBalancerElement=1
-listInternalLoadBalancerElements=1
+configureInternalLoadBalancerElement=7
+createInternalLoadBalancerElement=7
+listInternalLoadBalancerElements=7
 
 
 #### Affinity group commands

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/eff7587d/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java
b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java
index fe32a7b..d0a9771 100644
--- a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java
+++ b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/lb/InternalLoadBalancerVMManagerImpl.java
@@ -117,6 +117,7 @@ import com.cloud.vm.VirtualMachineProfile.Param;
 import com.cloud.vm.dao.DomainRouterDao;
 import com.cloud.vm.dao.NicDao;
 
+
 @Component
 @Local(value = { InternalLoadBalancerVMManager.class, InternalLoadBalancerVMService.class})
 public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
@@ -543,12 +544,15 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
     
     @Override
     public VirtualRouter stopInternalLbVm(long vmId, boolean forced, Account caller, long
callerUserId) throws ConcurrentOperationException,
-    ResourceUnavailableException {
+                                        ResourceUnavailableException {
         DomainRouterVO internalLbVm = _internalLbVmDao.findById(vmId);
         if (internalLbVm == null || internalLbVm.getRole() != Role.INTERNAL_LB_VM) {
             throw new InvalidParameterValueException("Can't find internal lb vm by id specified");
         }
         
+        //check permissions
+        _accountMgr.checkAccess(caller, null, true, internalLbVm);
+        
         return stopInternalLbVm(internalLbVm, forced, caller, callerUserId);
     }
 
@@ -946,6 +950,9 @@ public class InternalLoadBalancerVMManagerImpl extends ManagerBase implements
             throw new InvalidParameterValueException("Can't find internal lb vm by id specified");
         }
         
+        //check permissions
+        _accountMgr.checkAccess(caller, null, true, internalLbVm);
+        
         return startInternalLbVm(internalLbVm, caller, callerUserId, null);
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/eff7587d/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/InternalLBVMServiceTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/InternalLBVMServiceTest.java
b/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/InternalLBVMServiceTest.java
index 75f54fa..5a1d56f 100644
--- a/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/InternalLBVMServiceTest.java
+++ b/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/InternalLBVMServiceTest.java
@@ -47,11 +47,15 @@ import com.cloud.user.Account;
 import com.cloud.user.AccountManager;
 import com.cloud.user.AccountVO;
 import com.cloud.user.User;
+import com.cloud.user.UserVO;
 import com.cloud.utils.component.ComponentContext;
 import com.cloud.vm.DomainRouterVO;
 import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachineManager;
 import com.cloud.vm.dao.DomainRouterDao;
+import com.cloud.user.UserContext;
+import com.cloud.user.dao.AccountDao;
+
 
 /**
  * Set of unittests for InternalLoadBalancerVMService
@@ -70,6 +74,7 @@ public class InternalLBVMServiceTest extends TestCase {
     @Inject ServiceOfferingDao _svcOffDao;
     @Inject DomainRouterDao _domainRouterDao;
     @Inject VirtualMachineManager _itMgr;
+    @Inject AccountDao _accountDao;
     
     long validVmId = 1L;
     long nonExistingVmId = 2L;
@@ -86,6 +91,12 @@ public class InternalLBVMServiceTest extends TestCase {
         
         ComponentContext.initComponentsLifeCycle();
         
+        Mockito.when(_accountMgr.getSystemUser()).thenReturn(new UserVO(1));
+        Mockito.when(_accountMgr.getSystemAccount()).thenReturn(new AccountVO(2));
+        Mockito.when(_accountDao.findByIdIncludingRemoved(Mockito.anyLong())).thenReturn(new
AccountVO(2));
+        UserContext.registerContext(_accountMgr.getSystemUser().getId(), _accountMgr.getSystemAccount(),
null, false);
+        
+        
         DomainRouterVO validVm = new DomainRouterVO(validVmId,off.getId(),1,"alena",1,HypervisorType.XenServer,1,1,1,
                 false, 0,false,null,false,false,
                 VirtualMachine.Type.InternalLoadBalancerVm, null);
@@ -145,12 +156,6 @@ public class InternalLBVMServiceTest extends TestCase {
         } catch (ResourceUnavailableException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
-        } catch (InvalidParameterValueException e) {
-            expectedExcText = e.getMessage();
-            throw e;
-        } finally {
-            assertEquals("Test failed. The non-existing internal lb vm was attempted to start"
-        + expectedExcText, expectedExcText, "Can't find internal lb vm by id specified");
         }
     }
     
@@ -171,12 +176,6 @@ public class InternalLBVMServiceTest extends TestCase {
         } catch (ResourceUnavailableException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
-        }catch (InvalidParameterValueException e) {
-            expectedExcText = e.getMessage();
-            throw e;
-        } finally {
-            assertEquals("Test failed. The existing vm of not Internal lb vm type was attempted
to start"
-        + expectedExcText, expectedExcText, "Can't find internal lb vm by id specified");
         }
     }
     
@@ -218,12 +217,6 @@ public class InternalLBVMServiceTest extends TestCase {
         } catch (ResourceUnavailableException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
-        } catch (InvalidParameterValueException e) {
-            expectedExcText = e.getMessage();
-            throw e;
-        } finally {
-            assertEquals("Test failed. The non-existing internal lb vm was attempted to stop"
-        + expectedExcText, expectedExcText, "Can't find internal lb vm by id specified");
         }
     }
     
@@ -242,12 +235,6 @@ public class InternalLBVMServiceTest extends TestCase {
         } catch (ResourceUnavailableException e) {
             // TODO Auto-generated catch block
             e.printStackTrace();
-        }catch (InvalidParameterValueException e) {
-            expectedExcText = e.getMessage();
-            throw e;
-        } finally {
-            assertEquals("Test failed. The existing vm of not Internal lb vm type was attempted
to stop"
-        + expectedExcText, expectedExcText, "Can't find internal lb vm by id specified");
         }
     }
     

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/eff7587d/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/LbChildTestConfiguration.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/LbChildTestConfiguration.java
b/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/LbChildTestConfiguration.java
index 79354ef..74e54b2 100644
--- a/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/LbChildTestConfiguration.java
+++ b/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbvmmgr/LbChildTestConfiguration.java
@@ -50,6 +50,7 @@ import com.cloud.utils.net.NetUtils;
 import com.cloud.vm.VirtualMachineManager;
 import com.cloud.vm.dao.DomainRouterDao;
 import com.cloud.vm.dao.NicDao;
+import com.cloud.user.dao.AccountDao;
 
 
 @Configuration
@@ -161,6 +162,13 @@ import com.cloud.vm.dao.NicDao;
                 return Mockito.mock(ConfigurationServer.class);
             }
             
+            @Bean
+            public AccountDao accountDao() {
+                return Mockito.mock(AccountDao.class);
+            }
+            
+            
+            
             @Override
             public boolean match(MetadataReader mdr, MetadataReaderFactory arg1) throws IOException
{
                 mdr.getClassMetadata().getClassName();


Mime
View raw message