コード例 #1
0
 @Override
 public boolean apply(Allocation allocInfo) throws MetadataException {
   Context ctx = allocInfo.getContext();
   User user = ctx.getUser();
   String instanceType = allocInfo.getRequest().getInstanceType();
   VmType vmType = VmTypes.lookup(instanceType);
   if (!ctx.hasAdministrativePrivileges() && !RestrictedTypes.filterPrivileged().apply(vmType)) {
     throw new IllegalMetadataAccessException(
         "Not authorized to allocate vm type " + instanceType + " for " + ctx.getUserFullName());
   }
   allocInfo.setVmType(vmType);
   return true;
 }
コード例 #2
0
 @Override
 public boolean apply(Allocation allocInfo) throws MetadataException {
   String instanceType = allocInfo.getRequest().getInstanceType();
   VmType vmType = VmTypes.lookup(instanceType);
   if (!RestrictedTypes.filterPrivileged().apply(vmType)) {
     throw new IllegalMetadataAccessException(
         "Not authorized to allocate vm type "
             + instanceType
             + " for "
             + allocInfo.getOwnerFullName());
   }
   allocInfo.setVmType(vmType);
   return true;
 }