Permalink
Browse files

merged from eee

  • Loading branch information...
2 parents c257ad5 + a061c80 commit 2f9b310c4d5a2d29262a021b753eed438fc68f6a @dmitrii dmitrii committed Sep 19, 2011
Showing with 633 additions and 489 deletions.
  1. +1 −1 clc/.project
  2. +0 −19 clc/.settings/grze_localhost.launch
  3. +0 −20 clc/.settings/grze_office.launch
  4. +1 −1 clc/eucadmin/.project
  5. +3 −1 clc/modules/authentication/src/main/java/com/eucalyptus/auth/DatabaseUserProxy.java
  6. +9 −9 clc/modules/authentication/src/main/java/com/eucalyptus/auth/ldap/LdapSync.java
  7. +5 −4 clc/modules/authentication/src/main/java/com/eucalyptus/auth/ldap/LicParser.java
  8. +10 −0 clc/modules/cluster-manager/src/main/java/com/eucalyptus/blockstorage/Snapshot.java
  9. +3 −2 clc/modules/cluster-manager/src/main/java/com/eucalyptus/blockstorage/SnapshotManager.java
  10. +3 −16 clc/modules/cluster-manager/src/main/java/com/eucalyptus/blockstorage/Snapshots.java
  11. +5 −24 clc/modules/cluster-manager/src/main/java/com/eucalyptus/blockstorage/StorageUtil.java
  12. +10 −29 clc/modules/cluster-manager/src/main/java/com/eucalyptus/blockstorage/Volume.java
  13. +4 −2 clc/modules/cluster-manager/src/main/java/com/eucalyptus/blockstorage/VolumeManager.java
  14. +3 −2 clc/modules/cluster-manager/src/main/java/com/eucalyptus/blockstorage/Volumes.java
  15. +1 −1 clc/modules/cluster-manager/src/main/java/com/eucalyptus/cloud/UserMetadata.java
  16. +3 −3 clc/modules/cluster-manager/src/main/java/com/eucalyptus/cloud/run/VerifyMetadata.java
  17. +9 −5 clc/modules/cluster-manager/src/main/java/com/eucalyptus/cluster/VmInstance.java
  18. +6 −2 clc/modules/cluster-manager/src/main/java/com/eucalyptus/cluster/VmInstances.java
  19. +7 −9 clc/modules/cluster-manager/src/main/java/com/eucalyptus/cluster/callback/VmStateCallback.java
  20. +3 −0 clc/modules/cluster-manager/src/main/java/com/eucalyptus/images/BootableImageInfo.java
  21. +1 −1 clc/modules/cluster-manager/src/main/java/com/eucalyptus/images/ImageInfo.java
  22. +4 −3 clc/modules/cluster-manager/src/main/java/com/eucalyptus/images/Images.java
  23. +5 −3 clc/modules/cluster-manager/src/main/java/com/eucalyptus/keys/KeyPairManager.java
  24. +3 −4 clc/modules/cluster-manager/src/main/java/com/eucalyptus/keys/KeyPairUtil.java
  25. +30 −3 clc/modules/cluster-manager/src/main/java/com/eucalyptus/keys/KeyPairs.java
  26. +13 −2 clc/modules/cluster-manager/src/main/java/com/eucalyptus/keys/SshKeyPair.java
  27. +4 −11 clc/modules/cluster-manager/src/main/java/com/eucalyptus/network/NetworkGroupManager.java
  28. +0 −149 clc/modules/cluster-manager/src/main/java/com/eucalyptus/network/NetworkGroupUtil.java
  29. +106 −9 clc/modules/cluster-manager/src/main/java/com/eucalyptus/network/NetworkGroups.java
  30. +6 −2 clc/modules/cluster-manager/src/main/java/com/eucalyptus/vm/VmControl.java
  31. +2 −0 clc/modules/configuration/conf/scripts/describe_nodes.groovy
  32. +15 −18 clc/modules/core/conf/upgrade/upgrade_20_30.groovy
  33. +1 −1 clc/modules/euare/src/main/java/com/eucalyptus/auth/euare/EuareService.java
  34. +2 −2 clc/modules/msgs/src/main/java/com/eucalyptus/auth/principal/Principals.java
  35. +1 −1 clc/modules/msgs/src/main/java/com/eucalyptus/auth/principal/User.java
  36. +3 −0 clc/modules/msgs/src/main/java/com/eucalyptus/auth/principal/UserFullName.java
  37. +1 −1 clc/modules/msgs/src/main/java/com/eucalyptus/component/Partitions.java
  38. +59 −26 clc/modules/msgs/src/main/java/com/eucalyptus/configurable/StaticPropertyEntry.java
  39. +2 −2 clc/modules/msgs/src/main/java/com/eucalyptus/context/ServiceContext.java
  40. +9 −0 clc/modules/msgs/src/main/java/com/eucalyptus/scripting/Groovyness.java
  41. +50 −38 clc/modules/walrus/src/main/java/edu/ucsb/eucalyptus/cloud/ws/WalrusManager.java
  42. +9 −0 clc/modules/www/src/main/java/com/eucalyptus/webui/client/activity/AbstractSearchActivity.java
  43. +1 −1 clc/modules/www/src/main/java/com/eucalyptus/webui/client/activity/AccountActivity.java
  44. +26 −6 clc/modules/www/src/main/java/com/eucalyptus/webui/client/activity/ShellActivity.java
  45. +17 −0 clc/modules/www/src/main/java/com/eucalyptus/webui/client/service/EucalyptusService.java
  46. +2 −0 clc/modules/www/src/main/java/com/eucalyptus/webui/client/service/EucalyptusServiceAsync.java
  47. +1 −11 clc/modules/www/src/main/java/com/eucalyptus/webui/client/service/LoginUserProfile.java
  48. +1 −1 clc/modules/www/src/main/java/com/eucalyptus/webui/client/view/AccountView.java
  49. +8 −1 clc/modules/www/src/main/java/com/eucalyptus/webui/client/view/AccountViewImpl.java
  50. +1 −1 clc/modules/www/src/main/java/com/eucalyptus/webui/client/view/CertView.java
  51. +8 −1 clc/modules/www/src/main/java/com/eucalyptus/webui/client/view/CertViewImpl.java
  52. +1 −1 clc/modules/www/src/main/java/com/eucalyptus/webui/client/view/ConfigView.java
  53. +8 −1 clc/modules/www/src/main/java/com/eucalyptus/webui/client/view/ConfigViewImpl.java
  54. +1 −0 clc/modules/www/src/main/java/com/eucalyptus/webui/client/view/DetailView.java
  55. +3 −0 clc/modules/www/src/main/java/com/eucalyptus/webui/client/view/DetailViewImpl.java
  56. +1 −1 clc/modules/www/src/main/java/com/eucalyptus/webui/client/view/GroupView.java
  57. +8 −1 clc/modules/www/src/main/java/com/eucalyptus/webui/client/view/GroupViewImpl.java
  58. +1 −1 clc/modules/www/src/main/java/com/eucalyptus/webui/client/view/ImageView.java
  59. +8 −1 clc/modules/www/src/main/java/com/eucalyptus/webui/client/view/ImageViewImpl.java
  60. +1 −1 clc/modules/www/src/main/java/com/eucalyptus/webui/client/view/KeyView.java
  61. +8 −1 clc/modules/www/src/main/java/com/eucalyptus/webui/client/view/KeyViewImpl.java
  62. +1 −1 clc/modules/www/src/main/java/com/eucalyptus/webui/client/view/PolicyView.java
  63. +8 −1 clc/modules/www/src/main/java/com/eucalyptus/webui/client/view/PolicyViewImpl.java
  64. +5 −0 clc/modules/www/src/main/java/com/eucalyptus/webui/client/view/SelectionController.java
  65. +1 −1 clc/modules/www/src/main/java/com/eucalyptus/webui/client/view/UserView.java
  66. +8 −1 clc/modules/www/src/main/java/com/eucalyptus/webui/client/view/UserViewImpl.java
  67. +1 −1 clc/modules/www/src/main/java/com/eucalyptus/webui/client/view/VmTypeView.java
  68. +8 −1 clc/modules/www/src/main/java/com/eucalyptus/webui/client/view/VmTypeViewImpl.java
  69. +39 −1 clc/modules/www/src/main/java/com/eucalyptus/webui/server/ConfigurationWebBackend.java
  70. +9 −1 clc/modules/www/src/main/java/com/eucalyptus/webui/server/EuarePermission.java
  71. +18 −8 clc/modules/www/src/main/java/com/eucalyptus/webui/server/EuareWebBackend.java
  72. +9 −0 clc/modules/www/src/main/java/com/eucalyptus/webui/server/EucalyptusServiceImpl.java
  73. +0 −13 clc/modules/www/src/main/java/edu/ucsb/eucalyptus/admin/server/EucalyptusManagement.java
  74. +8 −3 clc/modules/www/src/main/java/edu/ucsb/eucalyptus/admin/server/X509Download.java
  75. +1 −1 tools/libvirt.xsl
View
2 clc/.project
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>net_topo:clc</name>
+ <name>grze_eee_clc_dev:clc</name>
<comment></comment>
<projects>
</projects>
View
19 clc/.settings/grze_localhost.launch
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<launchConfiguration type="org.eclipse.jdt.launching.remoteJavaApplication">
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
-<listEntry value="/grze_eee::clc"/>
-</listAttribute>
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
-<listEntry value="4"/>
-</listAttribute>
-<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
-<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
-</listAttribute>
-<booleanAttribute key="org.eclipse.jdt.launching.ALLOW_TERMINATE" value="false"/>
-<mapAttribute key="org.eclipse.jdt.launching.CONNECT_MAP">
-<mapEntry key="hostname" value="localhost"/>
-<mapEntry key="port" value="5005"/>
-</mapAttribute>
-<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="grze_eee:clc"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_CONNECTOR_ID" value="org.eclipse.jdt.launching.socketAttachConnector"/>
-</launchConfiguration>
View
20 clc/.settings/grze_office.launch
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<launchConfiguration type="org.eclipse.jdt.launching.remoteJavaApplication">
-<stringAttribute key="bad_container_name" value="/bzr:grze_eee:clc/grze.debug"/>
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
-<listEntry value="/grze_eee::clc"/>
-</listAttribute>
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
-<listEntry value="4"/>
-</listAttribute>
-<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
-<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
-</listAttribute>
-<booleanAttribute key="org.eclipse.jdt.launching.ALLOW_TERMINATE" value="false"/>
-<mapAttribute key="org.eclipse.jdt.launching.CONNECT_MAP">
-<mapEntry key="hostname" value="10.1.1.10"/>
-<mapEntry key="port" value="5005"/>
-</mapAttribute>
-<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="grze_eee:clc"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_CONNECTOR_ID" value="org.eclipse.jdt.launching.socketAttachConnector"/>
-</launchConfiguration>
View
2 clc/eucadmin/.project
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
- <name>net_topo:eucadmin</name>
+ <name>grze_eee_clc_dev:eucadmin</name>
<comment></comment>
<projects>
</projects>
View
4 clc/modules/authentication/src/main/java/com/eucalyptus/auth/DatabaseUserProxy.java
@@ -177,8 +177,10 @@ public void fire( UserEntity t ) {
}
@Override
- public void createToken( ) throws AuthException {
+ public String resetToken( ) throws AuthException {
+ String original = this.delegate.getToken( );
this.setToken( Crypto.generateSessionToken( this.delegate.getName( ) ) );
+ return original;
}
@Override
View
18 clc/modules/authentication/src/main/java/com/eucalyptus/auth/ldap/LdapSync.java
@@ -551,9 +551,9 @@ private static String getId( String idAttrName, Attributes attrs ) throws Naming
Attribute membersAttr = attrs.get( memberAttrName );
if ( membersAttr != null ) {
NamingEnumeration<?> names = membersAttr.getAll( );
- while ( names.hasMore( ) ) {
- members.add( parseMemberName( idAttrName, ( String ) names.next( ) ).toLowerCase( ) );
- }
+ while ( names.hasMore( ) ) {
+ members.add( parseMemberName( idAttrName, ( ( String ) names.next( ) ).toLowerCase( ) ).toLowerCase( ) );
+ }
}
return members;
}
@@ -643,7 +643,7 @@ public void processLdapEntry( String dn, Attributes attrs ) throws NamingExcepti
String infoKey = lic.getUserInfoAttributes( ).get( attrName );
String infoVal = getAttrWithNullCheck( attrs, attrName );
if ( infoVal != null ) {
- infoMap.put( infoKey, infoVal );
+ infoMap.put( infoKey, infoVal );
}
}
infoMap.put( User.DN, dn );
@@ -655,11 +655,11 @@ public void processLdapEntry( String dn, Attributes attrs ) throws NamingExcepti
}
private static String getAttrWithNullCheck( Attributes attrs, String attrName ) throws NamingException {
- Attribute attr = attrs.get( attrName );
- if ( attr != null ) {
- return ( String ) attr.get( );
- }
- return null;
+ Attribute attr = attrs.get( attrName );
+ if ( attr != null ) {
+ return ( ( String ) attr.get( ) ).toLowerCase( );
+ }
+ return null;
}
}
View
9 clc/modules/authentication/src/main/java/com/eucalyptus/auth/ldap/LicParser.java
@@ -10,8 +10,8 @@
import com.eucalyptus.auth.LicParseException;
import com.eucalyptus.auth.json.JsonUtils;
import com.eucalyptus.auth.lic.LicSpec;
+import com.google.common.base.Strings;
import com.google.common.collect.Sets;
-import com.google.gwt.thirdparty.guava.common.base.Strings;
/**
* Parser of ldap integration configuration (LIC). LIC is in JSON format.
@@ -75,6 +75,7 @@ public LdapIntegrationConfiguration parse( String licText ) throws LicParseExcep
private void parseLdapService( JSONObject licJson, LdapIntegrationConfiguration lic ) throws JSONException {
JSONObject ldapServiceObj = JsonUtils.getRequiredByType( JSONObject.class, licJson, LicSpec.LDAP_SERVICE );
lic.setServerUrl( validateServerUrl( JsonUtils.getRequiredByType( String.class, ldapServiceObj, LicSpec.SERVER_URL ) ) );
+ // case sensitive
lic.setAuthMethod( validateAuthMethod( JsonUtils.getRequiredByType( String.class, ldapServiceObj, LicSpec.AUTH_METHOD ), false ) );
lic.setAuthPrincipal( validateNonEmpty( JsonUtils.getRequiredByType( String.class, ldapServiceObj, LicSpec.AUTH_PRINCIPAL ) ) );
lic.setAuthCredentials( validateNonEmpty( JsonUtils.getRequiredByType( String.class, ldapServiceObj, LicSpec.AUTH_CREDENTIALS ) ) );
@@ -143,23 +144,23 @@ private void parseAccountingGroups( JSONObject licJson, LdapIntegrationConfigura
JSONObject accountingGroups = JsonUtils.getByType( JSONObject.class, licJson, LicSpec.ACCOUNTING_GROUPS );
lic.setAccountingGroupBaseDn( validateNonEmpty( JsonUtils.getRequiredByType( String.class, accountingGroups, LicSpec.ACCOUNTING_GROUP_BASE_DN ) ) );
lic.setAccountingGroupsSelection( parseSelection( JsonUtils.getByType( JSONObject.class, accountingGroups, LicSpec.SELECTION ) ) );
- lic.setAccountingGroupIdAttribute( JsonUtils.getRequiredByType( String.class, accountingGroups, LicSpec.ID_ATTRIBUTE ) );
+ lic.setAccountingGroupIdAttribute( JsonUtils.getRequiredByType( String.class, accountingGroups, LicSpec.ID_ATTRIBUTE ).toLowerCase( ) );
lic.setGroupsAttribute( JsonUtils.getRequiredByType( String.class, accountingGroups, LicSpec.GROUPS_ATTRIBUTE ) );
}
private void parseGroups( JSONObject licJson, LdapIntegrationConfiguration lic ) throws JSONException {
JSONObject groups = JsonUtils.getRequiredByType( JSONObject.class, licJson, LicSpec.GROUPS );
lic.setGroupBaseDn( validateNonEmpty( JsonUtils.getRequiredByType( String.class, groups, LicSpec.GROUP_BASE_DN ) ) );
lic.setGroupsSelection( parseSelection( JsonUtils.getByType( JSONObject.class, groups, LicSpec.SELECTION ) ) );
- lic.setGroupIdAttribute( JsonUtils.getRequiredByType( String.class, groups, LicSpec.ID_ATTRIBUTE ) );
+ lic.setGroupIdAttribute( JsonUtils.getRequiredByType( String.class, groups, LicSpec.ID_ATTRIBUTE ).toLowerCase( ) );
lic.setUsersAttribute( JsonUtils.getRequiredByType( String.class, groups, LicSpec.USERS_ATTRIBUTE ) );
}
private void parseUsers( JSONObject licJson, LdapIntegrationConfiguration lic ) throws JSONException {
JSONObject users = JsonUtils.getRequiredByType( JSONObject.class, licJson, LicSpec.USERS );
lic.setUserBaseDn( validateNonEmpty( JsonUtils.getRequiredByType( String.class, users, LicSpec.USER_BASE_DN ) ) );
lic.setUsersSelection( parseSelection( JsonUtils.getByType( JSONObject.class, users, LicSpec.SELECTION ) ) );
- lic.setUserIdAttribute( JsonUtils.getRequiredByType( String.class, users, LicSpec.ID_ATTRIBUTE ) );
+ lic.setUserIdAttribute( JsonUtils.getRequiredByType( String.class, users, LicSpec.ID_ATTRIBUTE ).toLowerCase( ) );
parseUserInfoMap( ( JSONObject ) JsonUtils.getByType( JSONObject.class, users, LicSpec.USER_INFO_ATTRIBUTES ), lic );
}
View
10 clc/modules/cluster-manager/src/main/java/com/eucalyptus/blockstorage/Snapshot.java
@@ -108,6 +108,16 @@ private Snapshot( ) {
super.setState( State.NIHIL );
}
+
+ /**
+ * @param accountFullName
+ * @param snapshotId
+ * @return
+ */
+ public static Snapshot named( final OwnerFullName ownerFullName, String snapshotId ) {
+ return new Snapshot( ownerFullName, snapshotId );
+ }
+
public String mapState( ) {
switch ( this.getState( ) ) {
case GENERATING:
View
5 clc/modules/cluster-manager/src/main/java/com/eucalyptus/blockstorage/SnapshotManager.java
@@ -68,6 +68,7 @@
import java.util.NoSuchElementException;
import java.util.concurrent.ExecutionException;
import org.apache.log4j.Logger;
+import com.eucalyptus.auth.principal.AccountFullName;
import com.eucalyptus.cloud.util.DuplicateMetadataException;
import com.eucalyptus.component.NoSuchComponentException;
import com.eucalyptus.component.Partitions;
@@ -154,7 +155,7 @@ public DeleteSnapshotResponseType delete( final DeleteSnapshotType request ) thr
final Context ctx = Contexts.lookup( );
boolean result = false;
try {
- result = Transactions.delete( Snapshots.named( ctx.getUserFullName( ), request.getSnapshotId( ) ), new Predicate<Snapshot>( ) {
+ result = Transactions.delete( Snapshot.named( ctx.getUserFullName( ), request.getSnapshotId( ) ), new Predicate<Snapshot>( ) {
@Override
public boolean apply( Snapshot snap ) {
@@ -200,7 +201,7 @@ public DescribeSnapshotsResponseType describe( DescribeSnapshotsType request ) t
EntityWrapper<Snapshot> db = EntityWrapper.get( Snapshot.class );
try {
- List<Snapshot> snapshots = db.query( Snapshots.named( ctx.getUserFullName( ), null ) );
+ List<Snapshot> snapshots = db.query( Snapshot.named( AccountFullName.getInstance( ctx.getAccount( ) ), null ) );
for ( Snapshot snap : Iterables.filter( snapshots, RestrictedTypes.filterPrivileged( ) ) ) {
DescribeStorageSnapshotsType scRequest = new DescribeStorageSnapshotsType( Lists.newArrayList( snap.getDisplayName( ) ) );
View
19 clc/modules/cluster-manager/src/main/java/com/eucalyptus/blockstorage/Snapshots.java
@@ -99,7 +99,7 @@
@Override
public Long apply( OwnerFullName input ) {
EntityWrapper<Snapshot> db = EntityWrapper.get( Snapshot.class );
- int ret = db.createCriteria( Snapshot.class ).add( Example.create( Snapshots.named( input, null ) ) ).setReadOnly( true ).setCacheable( false ).list( ).size( );
+ int ret = db.createCriteria( Snapshot.class ).add( Example.create( Snapshot.named( input, null ) ) ).setReadOnly( true ).setCacheable( false ).list( ).size( );
db.rollback( );
return new Long( ret );
}
@@ -114,7 +114,7 @@ static Snapshot initializeSnapshot( UserFullName userFullName, Volume vol, Servi
while ( true ) {
newId = Crypto.generateId( userFullName.getUniqueId( ), SnapshotManager.ID_PREFIX );
try {
- db.getUnique( Snapshots.named( newId ) );
+ db.getUnique( Snapshot.named( null, newId ) );
} catch ( EucalyptusCloudException e ) {
snap = new Snapshot( userFullName, newId, vol.getDisplayName( ), sc.getName( ), sc.getPartition( ) );
snap.setVolumeSize( vol.getSize( ) );
@@ -162,24 +162,11 @@ public void fire( Snapshot s ) {
return snap;
}
- /**
- * @param snapshotId
- * @return
- * @throws ExecutionException
- */
- public static Snapshot lookup( String snapshotId ) throws ExecutionException {
- return Transactions.find( Snapshots.named( snapshotId ) );
- }
-
public static Snapshot named( final String snapshotId ) {
return new Snapshot( ( UserFullName ) null, snapshotId );
}
public static Snapshot lookup( OwnerFullName accountFullName, String snapshotId ) throws ExecutionException {
- return Transactions.find( Snapshots.named( accountFullName, snapshotId ) );
- }
-
- public static Snapshot named( final OwnerFullName ownerFullName, String snapshotId ) {
- return new Snapshot( ownerFullName, snapshotId );
+ return Transactions.find( Snapshot.named( accountFullName, snapshotId ) );
}
}
View
29 clc/modules/cluster-manager/src/main/java/com/eucalyptus/blockstorage/StorageUtil.java
@@ -157,6 +157,11 @@ public String apply( Volume arg0 ) {
if ( attachedVolumes.containsKey( v.getDisplayName() ) ) {
aVolume.setStatus( v.mapState( ) );
aVolume.getAttachmentSet().add( attachedVolumes.get( aVolume.getVolumeId() ) );
+
+ for ( AttachedVolume attachedVolume : aVolume.getAttachmentSet( ) ) {
+ attachedVolume.setDevice("/dev/" + attachedVolume.getDevice( ) );
+ }
+
}
if ( "invalid".equals( v.getRemoteDevice( ) ) && !State.FAIL.equals( v.getState( ) ) ) {
aVolume.setStatus( "creating" );
@@ -172,28 +177,4 @@ public String apply( Volume arg0 ) {
return reply;
}
- public static long countVolumeByAccount( String accountId ) throws AuthException {
- EntityWrapper<Volume> db = EntityWrapper.get( Volume.class );
- try {
- List<Volume> vols = db.query( new Volume( accountId, null/* displayName */ ) );
- db.commit( );
- return vols.size( );
- } catch ( Exception e ) {
- db.rollback( );
- throw new AuthException( "Failed to search volume info", e );
- }
- }
-
- public static long countVolumeByUser( String userId ) throws AuthException {
- EntityWrapper<Volume> db = EntityWrapper.get( Volume.class );
- try {
- List<Volume> vols = db.query( new Volume( UserFullName.getInstance( Accounts.lookupUserById( userId ) ), null/* displayName */ ) );
- db.commit( );
- return vols.size( );
- } catch ( Exception e ) {
- db.rollback( );
- throw new AuthException( "Failed to search volume info", e );
- }
- }
-
}
View
39 clc/modules/cluster-manager/src/main/java/com/eucalyptus/blockstorage/Volume.java
@@ -76,8 +76,10 @@
import com.eucalyptus.cloud.CloudMetadata.VolumeMetadata;
import com.eucalyptus.cloud.UserMetadata;
import com.eucalyptus.component.ComponentIds;
+import com.eucalyptus.component.ServiceConfiguration;
import com.eucalyptus.component.id.Eucalyptus;
import com.eucalyptus.util.FullName;
+import com.eucalyptus.util.OwnerFullName;
import com.eucalyptus.util.StorageProperties;
@Entity
@@ -102,12 +104,12 @@
@Transient
private FullName fullName;
- public Volume( ) {
+ private Volume( ) {
super( );
}
- public Volume( final UserFullName userFullName, final String displayName, final Integer size, final String scName, final String partitionName,
- final String parentSnapshot ) {
+ private Volume( final UserFullName userFullName, final String displayName, final Integer size, final String scName, final String partitionName,
+ final String parentSnapshot ) {
super( userFullName, displayName );
this.size = size;
this.scName = scName;
@@ -117,37 +119,16 @@ public Volume( final UserFullName userFullName, final String displayName, final
super.setCreationTimestamp( new Date( ) );
}
- public Volume( final UserFullName userFullName, String displayName ) {
+ private Volume( final OwnerFullName userFullName, String displayName ) {
super( userFullName, displayName );
}
- public Volume( final String accountId, String displayName ) {
- this.setOwnerAccountNumber( accountId );
- this.setDisplayName( displayName );
+ public static Volume create( final ServiceConfiguration sc, final UserFullName owner, final String snapId, final Integer newSize, final String newId ) {
+ return new Volume( owner, newId, newSize, sc.getName( ), sc.getPartition( ), snapId );
}
- public static Volume named( String volumeId ) {
- return named( null, volumeId );
- }
-
- public static Volume named( final FullName fullName, String volumeId ) {
- //Volume v = new Volume( userFullName, volumeId );
- String accountId = null;
- if ( fullName != null ) {
- accountId = fullName.getNamespace( );
- }
- Volume v = new Volume( accountId, volumeId );
- return v;
- }
-
- public static Volume ownedBy( final FullName userFullName ) {
- //Volume v = new Volume( userFullName, null );
- String accountId = null;
- if ( userFullName != null ) {
- accountId = userFullName.getNamespace( );
- }
- Volume v = new Volume( accountId, null );
- return v;
+ public static Volume named( final OwnerFullName fullName, String volumeId ) {
+ return new Volume( fullName, volumeId );
}
public String mapState( ) {
View
6 clc/modules/cluster-manager/src/main/java/com/eucalyptus/blockstorage/VolumeManager.java
@@ -71,6 +71,7 @@
import java.util.concurrent.ExecutionException;
import org.apache.log4j.Logger;
import com.eucalyptus.auth.policy.PolicySpec;
+import com.eucalyptus.auth.principal.AccountFullName;
import com.eucalyptus.auth.principal.UserFullName;
import com.eucalyptus.cluster.Cluster;
import com.eucalyptus.cluster.Clusters;
@@ -84,6 +85,7 @@
import com.eucalyptus.context.Context;
import com.eucalyptus.context.Contexts;
import com.eucalyptus.entities.EntityWrapper;
+import com.eucalyptus.entities.Transactions;
import com.eucalyptus.event.EventFailedException;
import com.eucalyptus.event.ListenerRegistry;
import com.eucalyptus.records.EventClass;
@@ -142,7 +144,7 @@ public CreateVolumeResponseType CreateVolume( final CreateVolumeType request ) t
if ( snapId != null ) {
try {
- Snapshots.lookup( snapId );
+ Transactions.find( Snapshot.named( null, snapId ) );
} catch ( ExecutionException ex ) {
throw new EucalyptusCloudException( "Failed to create volume because the referenced snapshot id is invalid: " + snapId );
}
@@ -239,7 +241,7 @@ public boolean apply( AttachedVolume arg0 ) {
} );
}
- List<Volume> volumes = db.query( Volume.ownedBy( ctx.getUserFullName( ) ) );
+ List<Volume> volumes = db.query( Volume.named( AccountFullName.getInstance( ctx.getAccount( ) ), null ) );
List<Volume> describeVolumes = Lists.newArrayList( );
for ( Volume v : Iterables.filter( volumes, RestrictedTypes.filterPrivileged( ) ) ) {
if ( !State.ANNIHILATED.equals( v.getState( ) ) ) {
View
5 clc/modules/cluster-manager/src/main/java/com/eucalyptus/blockstorage/Volumes.java
@@ -137,7 +137,7 @@ public static Volume checkVolumeReady( final Volume vol ) throws EucalyptusCloud
final ServiceConfiguration sc = Partitions.lookupService( Storage.class, vol.getPartition( ) );
final DescribeStorageVolumesType descVols = new DescribeStorageVolumesType( Lists.newArrayList( vol.getDisplayName( ) ) );
try {
- Transactions.one( Volume.named( vol.getDisplayName( ) ), new Callback<Volume>( ) {
+ Transactions.one( Volume.named( null, vol.getDisplayName( ) ), new Callback<Volume>( ) {
@Override
public void fire( final Volume t ) {
@@ -164,7 +164,7 @@ public void fire( final Volume t ) {
public static Volume createStorageVolume( final ServiceConfiguration sc, final UserFullName owner, final String snapId, final Integer newSize, final BaseMessage request ) throws ExecutionException {
final String newId = Crypto.generateId( owner.getAccountNumber( ), ID_PREFIX );
- final Volume newVol = Transactions.save( new Volume( owner, newId, newSize, sc.getName( ), sc.getPartition( ), snapId ), new Callback<Volume>( ) {
+ final Volume newVol = Transactions.save( Volume.create( sc, owner, snapId, newSize, newId ), new Callback<Volume>( ) {
@Override
public void fire( final Volume t ) {
@@ -184,4 +184,5 @@ public void fire( final Volume t ) {
} );
return newVol;
}
+
}
View
2 clc/modules/cluster-manager/src/main/java/com/eucalyptus/cloud/UserMetadata.java
@@ -110,7 +110,7 @@ protected UserMetadata( final OwnerFullName owner, final String displayName ) {
public void setOwner( final OwnerFullName owner ) {
super.ownerFullNameCached = null;
this.setOwnerUserId( owner != null
- ? owner.getUniqueId( )
+ ? owner.getUserId( )
: null );
this.setOwnerUserName( owner != null
? owner.getUserName( )
View
6 clc/modules/cluster-manager/src/main/java/com/eucalyptus/cloud/run/VerifyMetadata.java
@@ -205,7 +205,7 @@ public boolean apply( Allocation allocInfo ) throws MetadataException {
Context ctx = allocInfo.getContext( );
RunInstancesType request = allocInfo.getRequest( );
String keyName = request.getKeyName( );
- SshKeyPair key = KeyPairs.lookup( ctx.getUserFullName( ), keyName );
+ SshKeyPair key = KeyPairs.lookup( ctx.getUserFullName( ).asAccountFullName( ), keyName );
if ( !ctx.hasAdministrativePrivileges( ) && !RestrictedTypes.filterPrivileged( ).apply( key ) ) {
throw new IllegalMetadataAccessException( "Not authorized to use keypair " + keyName + " by " + ctx.getUser( ).getName( ) );
}
@@ -220,7 +220,7 @@ public boolean apply( Allocation allocInfo ) throws MetadataException {
@Override
public boolean apply( Allocation allocInfo ) throws MetadataException {
Context ctx = allocInfo.getContext( );
- NetworkGroups.lookup( ctx.getUserFullName( ), NetworkGroups.defaultNetworkName( ) );
+ NetworkGroups.lookup( ctx.getUserFullName( ).asAccountFullName( ), NetworkGroups.defaultNetworkName( ) );
Set<String> networkNames = Sets.newHashSet( allocInfo.getRequest( ).getGroupSet( ) );
if ( networkNames.isEmpty( ) ) {
@@ -229,7 +229,7 @@ public boolean apply( Allocation allocInfo ) throws MetadataException {
Map<String, NetworkGroup> networkRuleGroups = Maps.newHashMap( );
for ( String groupName : networkNames ) {
- NetworkGroup group = NetworkGroups.lookup( ctx.getUserFullName( ), groupName );
+ NetworkGroup group = NetworkGroups.lookup( ctx.getUserFullName( ).asAccountFullName( ), groupName );
if ( !ctx.hasAdministrativePrivileges( ) && !RestrictedTypes.filterPrivileged( ).apply( group ) ) {
throw new IllegalMetadataAccessException( "Not authorized to use network group " + groupName + " for " + ctx.getUser( ).getName( ) );
}
View
14 clc/modules/cluster-manager/src/main/java/com/eucalyptus/cluster/VmInstance.java
@@ -117,6 +117,8 @@
import com.eucalyptus.event.EventFailedException;
import com.eucalyptus.event.ListenerRegistry;
import com.eucalyptus.images.Emis;
+import com.eucalyptus.images.MachineImageInfo;
+import com.eucalyptus.images.PutGetImageInfo;
import com.eucalyptus.images.Emis.BootableSet;
import com.eucalyptus.keys.KeyPairs;
import com.eucalyptus.keys.SshKeyPair;
@@ -483,6 +485,7 @@ public VmInstance apply( final VmInstance vm ) {
final EntityTransaction db = Entities.get( VmInstance.class );
try {
vm.cleanUp( );
+ vm.setState( VmState.BURIED );
Entities.delete( vm );
db.commit( );
return vm;
@@ -780,13 +783,14 @@ public String getByKey( final String pathArg ) {
private Map<String, String> getMetadataMap( ) {
final boolean dns = !ComponentIds.lookup( Dns.class ).runLimitedServices( );
final Map<String, String> m = new HashMap<String, String>( );
- //ASAP: FIXME: GRZE:
-// m.put( "ami-id", this.getImageInfo( ).getImageId( ) );
-// m.put( "product-codes", this.getImageInfo( ).getProductCodes( ).toString( ).replaceAll( "[\\Q[]\\E]", "" ).replaceAll( ", ", "\n" ) );
+ m.put( "ami-id", this.getImageId( ) );
+ m.put( "product-codes", this.bootRecord.getMachine( ).getProductCodes( ).toString( ).replaceAll( "[\\Q[]\\E]", "" ).replaceAll( ", ", "\n" ) );
m.put( "ami-launch-index", "" + this.launchRecord.getLaunchIndex( ) );
+//ASAP: FIXME: GRZE:
// m.put( "ancestor-ami-ids", this.getImageInfo( ).getAncestorIds( ).toString( ).replaceAll( "[\\Q[]\\E]", "" ).replaceAll( ", ", "\n" ) );
-
-// m.put( "ami-manifest-path", this.getImageInfo( ).getImageLocation( ) );
+ if( this.bootRecord.getMachine( ) instanceof MachineImageInfo ) {
+ m.put( "ami-manifest-path", ( ( MachineImageInfo ) this.bootRecord.getMachine( ) ).getManifestLocation( ) );
+ }
m.put( "hostname", this.getPublicAddress( ) );
m.put( "instance-id", this.getInstanceId( ) );
m.put( "instance-type", this.getVmType( ).getName( ) );
View
8 clc/modules/cluster-manager/src/main/java/com/eucalyptus/cluster/VmInstances.java
@@ -348,15 +348,19 @@ public static VmInstance register( final VmInstance vm ) {
public static VmInstance delete( final VmInstance vm ) throws TransactionException {
try {
- if ( VmStateSet.DONE.apply( vm ) ) {
+ if ( VmState.BURIED.apply( vm ) ) {
+ terminateCache.remove( vm.getDisplayName( ) );
+ terminateDescribeCache.remove( vm.getDisplayName( ) );
+ } else if ( VmStateSet.DONE.apply( vm ) ) {
RunningInstancesItemType ret = VmInstances.transform( vm );
terminateCache.put( vm.getDisplayName( ), vm );
terminateDescribeCache.put( vm.getDisplayName( ), ret );
+ return VmInstance.Transitions.DELETE.apply( vm );
}
} catch ( Exception ex ) {
LOG.error( ex, ex );
}
- return VmInstance.Transitions.DELETE.apply( vm );
+ return vm;
}
public static VmInstance terminate( final VmInstance vm ) throws TransactionException {
View
16 ...odules/cluster-manager/src/main/java/com/eucalyptus/cluster/callback/VmStateCallback.java
@@ -35,7 +35,7 @@ public VmStateCallback( ) {
@Override
public void fire( VmDescribeResponseType reply ) {
reply.setOriginCluster( this.getSubject( ).getConfiguration( ).getName( ) );
-
+
for ( VmInfo vmInfo : reply.getVms( ) ) {
vmInfo.setPlacement( this.getSubject( ).getConfiguration( ).getName( ) );
VmTypeInfo typeInfo = vmInfo.getInstanceType( );
@@ -49,7 +49,7 @@ public void fire( VmDescribeResponseType reply ) {
}
for ( final VmInfo runVm : reply.getVms( ) ) {
- final VmState state = VmState.Mapper.get( runVm.getStateName( ) );
+ final VmState runVmState = VmState.Mapper.get( runVm.getStateName( ) );
EntityTransaction db = Entities.get( VmInstance.class );
try {
try {
@@ -65,7 +65,7 @@ public void fire( VmDescribeResponseType reply ) {
}
} catch ( Exception ex1 ) {
VmInstance vm = VmInstance.Lookup.INSTANCE.apply( runVm.getInstanceId( ) );
- if ( VmStateSet.RUN.contains( state ) ) {
+ if ( VmStateSet.RUN.contains( runVmState ) ) {
VmInstance.RestoreAllocation.INSTANCE.apply( runVm );
}
}
@@ -75,7 +75,7 @@ public void fire( VmDescribeResponseType reply ) {
db.rollback( );
}
}
-
+
final List<String> unreportedVms = Lists.transform( VmInstances.listValues( ), new Function<VmInstance, String>( ) {
@Override
@@ -97,12 +97,10 @@ public String apply( final VmInfo arg0 ) {
EntityTransaction db1 = Entities.get( VmInstance.class );
try {
VmInstance vm = VmInstances.lookup( vmId );
- if ( VmStateSet.RUN.apply( vm ) ) {
- //noop.
+ if ( VmStateSet.RUN.apply( vm ) && vm.getSplitTime( ) > VmInstances.SHUT_DOWN_TIME ) {
+ VmInstances.terminate( vm );
} else if ( VmState.SHUTTING_DOWN.apply( vm ) ) {
- vm.setState( VmState.TERMINATED, Reason.EXPIRED );
- vm = VmInstances.delete( vm );//TODO:GRZE:OMG:TEMPORARYA!!?@!!@!11
-
+ VmInstances.terminate( vm );
} else if ( VmState.TERMINATED.apply( vm ) && vm.getSplitTime( ) > VmInstances.BURY_TIME ) {
VmInstances.delete( vm );
} else if ( VmState.BURIED.apply( vm ) ) {
View
3 clc/modules/cluster-manager/src/main/java/com/eucalyptus/images/BootableImageInfo.java
@@ -63,6 +63,7 @@
package com.eucalyptus.images;
+import java.util.Set;
import com.eucalyptus.cloud.ImageMetadata;
public interface BootableImageInfo {
@@ -80,5 +81,7 @@
public abstract Long getImageSizeBytes( );
public abstract String getDisplayName( );
+
+ public abstract Set<String> getProductCodes( );
}
View
2 clc/modules/cluster-manager/src/main/java/com/eucalyptus/images/ImageInfo.java
@@ -326,7 +326,7 @@ public void fire( final ImageInfo t ) {
return this;
}
- Set<String> getProductCodes( ) {
+ public Set<String> getProductCodes( ) {
return this.productCodes;
}
View
7 clc/modules/cluster-manager/src/main/java/com/eucalyptus/images/Images.java
@@ -18,6 +18,7 @@
import com.eucalyptus.context.Contexts;
import com.eucalyptus.entities.EntityWrapper;
import com.eucalyptus.entities.TransactionExecutionException;
+import com.eucalyptus.entities.Transactions;
import com.eucalyptus.images.ImageManifests.ImageManifest;
import com.eucalyptus.util.Callback;
import com.eucalyptus.util.EucalyptusCloudException;
@@ -52,7 +53,7 @@ public Long apply( final OwnerFullName input ) {
return ( long ) i;
}
}
-
+
private static String generateImageId( final String imagePrefix, final String imageLocation ) {
Adler32 hash = new Adler32( );
String key = imageLocation + System.currentTimeMillis( );
@@ -226,7 +227,7 @@ public DeviceMapping apply( BlockDeviceMappingItemType input ) {
Snapshot snap;
Integer size;
try {
- snap = Snapshots.lookup( ebsInfo.getSnapshotId( ) );
+ snap = Transactions.find( Snapshot.named( null, ebsInfo.getSnapshotId( ) ) );
size = snap.getVolumeSize( );
if ( ebsInfo.getVolumeSize( ) != null && ebsInfo.getVolumeSize( ) >= snap.getVolumeSize( ) ) {
size = ebsInfo.getVolumeSize( );
@@ -376,7 +377,7 @@ public static ImageInfo createFromDeviceMapping( UserFullName userFullName, Stri
BlockDeviceMappingItemType rootBlockDevice = Iterables.find( blockDeviceMappings, findEbsRoot( rootDeviceName ) );
String snapshotId = rootBlockDevice.getEbs( ).getSnapshotId( );
try {
- Snapshot snap = Snapshots.lookup( userFullName, snapshotId );
+ Snapshot snap = Transactions.find( Snapshot.named( userFullName, snapshotId ) );
if ( !userFullName.getUserId( ).equals( snap.getOwnerUserId( ) ) ) {
throw new EucalyptusCloudException( "Failed to create image from specified block device mapping: " + rootBlockDevice
+ " because of: you must the owner of the source snapshot." );
View
8 clc/modules/cluster-manager/src/main/java/com/eucalyptus/keys/KeyPairManager.java
@@ -34,7 +34,7 @@
public DescribeKeyPairsResponseType describe( DescribeKeyPairsType request ) throws Exception {
DescribeKeyPairsResponseType reply = request.getReply( );
- for ( SshKeyPair kp : Iterables.filter( KeyPairUtil.getUserKeyPairs( Contexts.lookup( ).getUserFullName( ) ), RestrictedTypes.filterPrivileged( ) ) ) {
+ for ( SshKeyPair kp : Iterables.filter( KeyPairs.list( Contexts.lookup( ).getUserFullName( ).asAccountFullName( ) ), RestrictedTypes.filterPrivileged( ) ) ) {
if ( request.getKeySet( ).isEmpty( ) || request.getKeySet( ).contains( kp.getDisplayName( ) ) ) {
reply.getKeySet( ).add( new DescribeKeyPairsResponseItemType( kp.getDisplayName( ), kp.getFingerPrint( ) ) );
}
@@ -46,13 +46,15 @@ public DeleteKeyPairResponseType delete( DeleteKeyPairType request ) throws Euca
DeleteKeyPairResponseType reply = ( DeleteKeyPairResponseType ) request.getReply( );
Context ctx = Contexts.lookup( );
try {
- SshKeyPair key = KeyPairUtil.deleteUserKeyPair( ctx.getUserFullName( ), request.getKeyName( ) );
+ SshKeyPair key = KeyPairs.lookup( ctx.getUserFullName( ).asAccountFullName( ), request.getKeyName( ) );
if ( ! RestrictedTypes.filterPrivileged( ).apply( key ) ) {
throw new EucalyptusCloudException( "Permission denied while trying to delete keypair " + key.getName( ) + " by " + ctx.getUser( ) );
}
+ KeyPairs.delete( ctx.getUserFullName( ).asAccountFullName( ), request.getKeyName( ) );
reply.set_return( true );
} catch ( Exception e1 ) {
- reply.set_return( true );
+ LOG.error( e1 );
+ reply.set_return( false );
}
return reply;
}
View
7 clc/modules/cluster-manager/src/main/java/com/eucalyptus/keys/KeyPairUtil.java
@@ -2,21 +2,20 @@
import java.util.List;
import org.apache.log4j.Logger;
-import com.eucalyptus.auth.principal.AccountFullName;
-import com.eucalyptus.auth.principal.User;
import com.eucalyptus.auth.principal.UserFullName;
import com.eucalyptus.entities.EntityWrapper;
import com.eucalyptus.util.EucalyptusCloudException;
+import com.eucalyptus.util.OwnerFullName;
import com.google.common.collect.Lists;
public class KeyPairUtil {
private static Logger LOG = Logger.getLogger( KeyPairUtil.class );
- public static List<SshKeyPair> getUserKeyPairs( UserFullName userFullName ) {
+ public static List<SshKeyPair> getUserKeyPairs( OwnerFullName ownerFullName ) {
EntityWrapper<SshKeyPair> db = EntityWrapper.get( SshKeyPair.class );;
List<SshKeyPair> keys = Lists.newArrayList( );
try {
- keys = db.query( new SshKeyPair( userFullName ) );
+ keys = db.query( SshKeyPair.named( ownerFullName, null ) );
db.commit( );
} catch ( Exception e ) {
db.rollback( );
View
33 clc/modules/cluster-manager/src/main/java/com/eucalyptus/keys/KeyPairs.java
@@ -67,17 +67,22 @@
import java.security.KeyPair;
import java.security.PrivateKey;
import java.security.interfaces.RSAPublicKey;
+import java.util.List;
+import javax.persistence.EntityTransaction;
import org.apache.log4j.Logger;
import org.bouncycastle.util.encoders.Base64;
import org.hibernate.exception.ConstraintViolationException;
+import com.eucalyptus.auth.principal.AccountFullName;
import com.eucalyptus.auth.principal.UserFullName;
import com.eucalyptus.cloud.util.DuplicateMetadataException;
import com.eucalyptus.cloud.util.MetadataCreationException;
import com.eucalyptus.cloud.util.MetadataException;
import com.eucalyptus.cloud.util.NoSuchMetadataException;
import com.eucalyptus.crypto.Certs;
+import com.eucalyptus.entities.Entities;
import com.eucalyptus.entities.TransactionException;
import com.eucalyptus.entities.Transactions;
+import com.eucalyptus.records.Logs;
import com.eucalyptus.util.OwnerFullName;
public class KeyPairs {
@@ -89,25 +94,46 @@ public static SshKeyPair noKey( ) {
return NO_KEY;
}
+ public static List<SshKeyPair> list( OwnerFullName ownerFullName ) throws NoSuchMetadataException {
+ try {
+ return Transactions.findAll( SshKeyPair.named( ownerFullName, null ) );
+ } catch ( Exception e ) {
+ throw new NoSuchMetadataException( "Failed to find key pairs for " + ownerFullName, e );
+ }
+ }
+
public static SshKeyPair lookup( OwnerFullName ownerFullName, String keyName ) throws NoSuchMetadataException {
try {
return Transactions.find( new SshKeyPair( ownerFullName, keyName ) );
} catch ( Exception e ) {
throw new NoSuchMetadataException( "Failed to find key pair: " + keyName + " for " + ownerFullName, e );
}
}
-
+
+ public static void delete( OwnerFullName ownerFullName, String keyName ) throws NoSuchMetadataException {
+ EntityTransaction db = Entities.get( SshKeyPair.class );
+ try {
+ SshKeyPair entity = Entities.uniqueResult( SshKeyPair.named( ownerFullName, keyName ) );
+ Entities.delete( entity );
+ db.commit( );
+ } catch ( Exception ex ) {
+ Logs.exhaust( ).error( ex, ex );
+ db.rollback( );
+ throw new NoSuchMetadataException( "Failed to find key pair: " + keyName + " for " + ownerFullName, ex );
+ }
+ }
+
public static SshKeyPair fromPublicKey( OwnerFullName ownerFullName, String keyValue ) throws NoSuchMetadataException {
try {
- return Transactions.find( new SshKeyPair( ownerFullName, keyValue ) );
+ return Transactions.find( SshKeyPair.withPublicKey( ownerFullName, keyValue ) );
} catch ( Exception e ) {
throw new NoSuchMetadataException( "Failed to find key pair with public key: " + keyValue + " for " + ownerFullName, e );
}
}
public static PrivateKey create( UserFullName userName, String keyName ) throws MetadataException, TransactionException {
- SshKeyPair newKey = new SshKeyPair( userName, keyName );
+ SshKeyPair newKey = SshKeyPair.create( userName, keyName );
KeyPair newKeys = null;
try {
newKeys = Certs.generateKeyPair( );
@@ -148,4 +174,5 @@ private static String getAuthKeyString( UserFullName userName, KeyPair newKeys )
String authKeyString = String.format( "%s %s %s@eucalyptus", new String( keyType ), new String( Base64.encode( authKeyBlob ) ), userName.toString( ) );
return authKeyString;
}
+
}
View
15 clc/modules/cluster-manager/src/main/java/com/eucalyptus/keys/SshKeyPair.java
@@ -70,14 +70,14 @@
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Entity;
+import com.eucalyptus.auth.principal.AccountFullName;
import com.eucalyptus.auth.principal.Principals;
+import com.eucalyptus.auth.principal.UserFullName;
import com.eucalyptus.cloud.CloudMetadata.KeyPairMetadata;
import com.eucalyptus.cloud.UserMetadata;
import com.eucalyptus.component.ComponentIds;
import com.eucalyptus.component.id.Eucalyptus;
-import com.eucalyptus.network.NetworkGroup;
import com.eucalyptus.util.FullName;
-import com.eucalyptus.util.HasFullName;
import com.eucalyptus.util.OwnerFullName;
@Entity
@@ -149,5 +149,16 @@ public FullName getFullName( ) {
static SshKeyPair noKey( ) {
return new SshKeyPair( Principals.nobodyFullName( ), "nokey", "", "" );
}
+
+ public static SshKeyPair named( OwnerFullName ownerFullName, String keyName ) {
+ return new SshKeyPair( ownerFullName, keyName );
+ }
+ public static SshKeyPair create( UserFullName userFullName, String keyName ) {
+ return new SshKeyPair( userFullName, keyName );
+ }
+
+ public static SshKeyPair withPublicKey( OwnerFullName ownerFullName, String keyValue ) {
+ return new SshKeyPair( ownerFullName, null, keyValue, null );
+ }
}
View
15 clc/modules/cluster-manager/src/main/java/com/eucalyptus/network/NetworkGroupManager.java
@@ -3,14 +3,7 @@
import java.util.List;
import javax.persistence.EntityTransaction;
import org.apache.log4j.Logger;
-import com.eucalyptus.auth.Accounts;
-import com.eucalyptus.auth.AuthException;
-import com.eucalyptus.auth.Permissions;
-import com.eucalyptus.auth.policy.PolicySpec;
-import com.eucalyptus.auth.principal.Account;
import com.eucalyptus.auth.principal.AccountFullName;
-import com.eucalyptus.auth.principal.User;
-import com.eucalyptus.auth.principal.UserFullName;
import com.eucalyptus.cloud.util.MetadataException;
import com.eucalyptus.context.Context;
import com.eucalyptus.context.Contexts;
@@ -66,7 +59,7 @@ public DeleteSecurityGroupResponseType delete( final DeleteSecurityGroupType req
if ( ! RestrictedTypes.filterPrivileged( ).apply( NetworkGroups.lookup( request.getGroupName( ) ) ) ) {
throw new EucalyptusCloudException( "Not authorized to delete network group " + request.getGroupName( ) + " for " + ctx.getUser( ) );
}
- NetworkGroupUtil.deleteUserNetworkRulesGroup( ctx.getUserFullName( ), request.getGroupName( ) );
+ NetworkGroups.delete( ctx.getUserFullName( ), request.getGroupName( ) );
reply.set_return( true );
return reply;
}
@@ -108,14 +101,14 @@ public boolean apply( final NetworkGroup arg0 ) {
public RevokeSecurityGroupIngressResponseType revoke( final RevokeSecurityGroupIngressType request ) throws EucalyptusCloudException, MetadataException {
final Context ctx = Contexts.lookup( );
final RevokeSecurityGroupIngressResponseType reply = ( RevokeSecurityGroupIngressResponseType ) request.getReply( );
- NetworkGroup ruleGroup = NetworkGroupUtil.getUserNetworkRulesGroup( ctx.getUserFullName( ), request.getGroupName( ) );
+ NetworkGroup ruleGroup = NetworkGroups.lookup( ctx.getUserFullName( ), request.getGroupName( ) );
if ( !ctx.hasAdministrativePrivileges( )
&& !RestrictedTypes.filterPrivileged( ).apply( ruleGroup ) ) {
throw new EucalyptusCloudException( "Not authorized to revoke network group " + request.getGroupName( ) + " for " + ctx.getUser( ) );
}
final List<NetworkRule> ruleList = Lists.newArrayList( );
for ( final IpPermissionType ipPerm : request.getIpPermissions( ) ) {
- ruleList.addAll( NetworkGroupUtil.getNetworkRules( ipPerm ) );
+ ruleList.addAll( NetworkGroups.IpPermissionTypeAsNetworkRule.INSTANCE.apply( ipPerm ) );
}
final List<NetworkRule> filtered = Lists.newArrayList( Iterables.filter( ruleGroup.getNetworkRules( ), new Predicate<NetworkRule>( ) {
@Override
@@ -170,7 +163,7 @@ public AuthorizeSecurityGroupIngressResponseType authorize( final AuthorizeSecur
final List<NetworkRule> ruleList = Lists.newArrayList( );
for ( final IpPermissionType ipPerm : request.getIpPermissions( ) ) {
try {
- ruleList.addAll( NetworkGroupUtil.getNetworkRules( ipPerm ) );
+ ruleList.addAll( NetworkGroups.IpPermissionTypeAsNetworkRule.INSTANCE.apply( ipPerm ) );
} catch ( final IllegalArgumentException ex ) {
LOG.error( ex.getMessage( ) );
reply.set_return( false );
View
149 clc/modules/cluster-manager/src/main/java/com/eucalyptus/network/NetworkGroupUtil.java
@@ -1,149 +0,0 @@
-package com.eucalyptus.network;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.List;
-import com.eucalyptus.auth.Accounts;
-import com.eucalyptus.auth.AuthException;
-import com.eucalyptus.auth.Permissions;
-import com.eucalyptus.auth.policy.PolicyResourceType;
-import com.eucalyptus.auth.policy.PolicyVendor;
-import com.eucalyptus.auth.principal.User;
-import com.eucalyptus.auth.principal.UserFullName;
-import com.eucalyptus.cloud.CloudMetadata;
-import com.eucalyptus.cloud.CloudMetadata.AddressMetadata;
-import com.eucalyptus.cloud.util.DuplicateMetadataException;
-import com.eucalyptus.context.Context;
-import com.eucalyptus.context.Contexts;
-import com.eucalyptus.entities.EntityWrapper;
-import com.eucalyptus.system.Ats;
-import com.eucalyptus.util.EucalyptusCloudException;
-import com.eucalyptus.util.OwnerFullName;
-import com.eucalyptus.util.TypeMappers;
-import com.eucalyptus.util.RestrictedTypes;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Lists;
-import edu.ucsb.eucalyptus.msgs.IpPermissionType;
-import edu.ucsb.eucalyptus.msgs.SecurityGroupItemType;
-import edu.ucsb.eucalyptus.msgs.UserIdGroupPairType;
-
-@Deprecated
-public class NetworkGroupUtil {
-
- @Deprecated
- public static List<NetworkGroup> getUserNetworkRulesGroup( OwnerFullName ownerFullName ) {
- EntityWrapper<NetworkGroup> db = EntityWrapper.get( NetworkGroup.class );
- List<NetworkGroup> networkGroups = Lists.newArrayList( );
- try {
- networkGroups = db.query( new NetworkGroup( ownerFullName ) );
- db.commit( );
- } catch ( Exception e ) {
- db.rollback( );
- }
- return networkGroups;
- }
-
- @Deprecated
- public static NetworkGroup getUserNetworkRulesGroup( OwnerFullName ownerFullName, String groupName ) throws EucalyptusCloudException {
- EntityWrapper<NetworkGroup> db = EntityWrapper.get( NetworkGroup.class );
- NetworkGroup group = null;
- try {
- group = db.getUnique( new NetworkGroup( ownerFullName, groupName ) );
- db.commit( );
- } catch ( EucalyptusCloudException e ) {
- db.rollback( );
- throw e;
- }
- return group;
- }
-
- @Deprecated
- public static NetworkGroup deleteUserNetworkRulesGroup( UserFullName ownerFullName, String groupName ) throws EucalyptusCloudException {
- EntityWrapper<NetworkGroup> db = EntityWrapper.get( NetworkGroup.class );
- NetworkGroup group = null;
- try {
- group = db.getUnique( new NetworkGroup( ownerFullName, groupName ) );
- db.delete( group );
- db.commit( );
- } catch ( EucalyptusCloudException e ) {
- db.rollback( );
- throw e;
- } catch ( Exception e ) {
- db.rollback( );
- throw new EucalyptusCloudException( e );
- }
- return group;
- }
-
- @Deprecated
- public static SecurityGroupItemType getAsSecurityGroupItemType( OwnerFullName ownerFullName, NetworkGroup group ) {
- SecurityGroupItemType groupInfo = new SecurityGroupItemType( );
- groupInfo.setGroupName( group.getDisplayName( ) );
- groupInfo.setGroupDescription( group.getDescription( ) );
- groupInfo.setAccountId( ownerFullName.getAccountNumber( ) );
- for ( NetworkRule rule : group.getNetworkRules( ) ) {
- IpPermissionType ipPerm = new IpPermissionType( rule.getProtocol( ), rule.getLowPort( ), rule.getHighPort( ) );
- for ( IpRange ipRange : rule.getIpRanges( ) )
- ipPerm.getIpRanges( ).add( ipRange.getValue( ) );
- if ( !rule.getNetworkPeers( ).isEmpty( ) )
- for ( NetworkPeer peer : rule.getNetworkPeers( ) )
- ipPerm.getGroups( ).add( new UserIdGroupPairType( peer.getUserQueryKey( ), peer.getGroupName( ) ) );
- groupInfo.getIpPermissions( ).add( ipPerm );
- }
- return groupInfo;
- }
-
- @Deprecated
- static List<NetworkRule> getNetworkRules( final IpPermissionType ipPerm ) throws IllegalArgumentException {
- List<NetworkRule> ruleList = new ArrayList<NetworkRule>( );
- if ( !ipPerm.getGroups( ).isEmpty( ) ) {
- if ( ipPerm.getFromPort( ) == 0 && ipPerm.getToPort( ) == 0 ) {
- ipPerm.setToPort( 65535 );
- }
- //:: fixes handling of under-specified named-network rules sent by some clients :://
- if ( ipPerm.getIpProtocol( ) == null ) {
- NetworkRule rule = new NetworkRule( "tcp", ipPerm.getFromPort( ), ipPerm.getToPort( ) );
- rule.getNetworkPeers( ).addAll( getNetworkPeers( ipPerm ) );
- ruleList.add( rule );
- NetworkRule rule1 = new NetworkRule( "udp", ipPerm.getFromPort( ), ipPerm.getToPort( ) );
- rule1.getNetworkPeers( ).addAll( getNetworkPeers( ipPerm ) );
- ruleList.add( rule1 );
- NetworkRule rule2 = new NetworkRule( "icmp", -1, -1 );
- rule2.getNetworkPeers( ).addAll( getNetworkPeers( ipPerm ) );
- ruleList.add( rule2 );
- } else {
- NetworkRule rule = new NetworkRule( ipPerm.getIpProtocol( ), ipPerm.getFromPort( ), ipPerm.getToPort( ) );
- rule.getNetworkPeers( ).addAll( getNetworkPeers( ipPerm ) );
- ruleList.add( rule );
- }
- } else if ( !ipPerm.getIpRanges( ).isEmpty( ) ) {
- List<IpRange> ipRanges = new ArrayList<IpRange>( );
- for ( String range : ipPerm.getIpRanges( ) ) {
- String[] rangeParts = range.split( "/" );
- try {
- if ( Integer.parseInt( rangeParts[1] ) > 32 || Integer.parseInt( rangeParts[1] ) < 0 ) continue;
- if ( rangeParts.length != 2 ) continue;
- if ( InetAddress.getByName( rangeParts[0] ) != null ) {
- ipRanges.add( new IpRange( range ) );
- }
- } catch ( NumberFormatException e ) {} catch ( UnknownHostException e ) {}
- }
- NetworkRule rule = new NetworkRule( ipPerm.getIpProtocol( ), ipPerm.getFromPort( ), ipPerm.getToPort( ), ipRanges );
- ruleList.add( rule );
- } else {
- throw new IllegalArgumentException( "Invalid Ip Permissions: must specify either a source cidr or user" );
- }
- return ruleList;
- }
-
- @Deprecated
- private static List<NetworkPeer> getNetworkPeers( final IpPermissionType ipPerm ) {
- List<NetworkPeer> networkPeers = new ArrayList<NetworkPeer>( );
- for ( UserIdGroupPairType peerInfo : ipPerm.getGroups( ) ) {
- networkPeers.add( new NetworkPeer( peerInfo.getSourceUserId( ), peerInfo.getSourceGroupName( ) ) );
- }
- return networkPeers;
- }
-
-}
View
115 clc/modules/cluster-manager/src/main/java/com/eucalyptus/network/NetworkGroups.java
@@ -63,12 +63,16 @@
package com.eucalyptus.network;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.persistence.EntityTransaction;
import org.apache.log4j.Logger;
import org.hibernate.exception.ConstraintViolationException;
+import com.eucalyptus.auth.principal.AccountFullName;
import com.eucalyptus.cloud.util.DuplicateMetadataException;
import com.eucalyptus.cloud.util.MetadataException;
import com.eucalyptus.cloud.util.NoSuchMetadataException;
@@ -104,9 +108,9 @@
@ConfigurableField( initial = "1", description = "Default min network index." )
public static Long DEFAULT_MIN_NETWORK_INDEX = 2l;
@ConfigurableField( initial = "" + 4096, description = "Default max vlan tag." )
- public static Integer GLOBAL_MAX_NETWORK_TAG = 4096;
+ public static Integer GLOBAL_MAX_NETWORK_TAG = 4096;
@ConfigurableField( initial = "1", description = "Default min vlan tag." )
- public static Integer GLOBAL_MIN_NETWORK_TAG = 1;
+ public static Integer GLOBAL_MIN_NETWORK_TAG = 1;
public static class NetworkRangeConfiguration {
private Boolean useNetworkTags = Boolean.TRUE;
@@ -206,6 +210,23 @@ public static NetworkRangeConfiguration networkingConfiguration( ) {
return netConfig;
}
+ public static NetworkGroup delete( final OwnerFullName ownerFullName, final String groupName ) throws MetadataException {
+ if ( defaultNetworkName( ).equals( groupName ) ) {
+ createDefault( ownerFullName );
+ }
+ final EntityTransaction db = Entities.get( NetworkGroup.class );
+ try {
+ final NetworkGroup ret = Entities.uniqueResult( new NetworkGroup( ownerFullName, groupName ) );
+ Entities.delete( ret );
+ db.commit( );
+ return ret;
+ } catch ( final Exception ex ) {
+ Logs.exhaust( ).error( ex, ex );
+ db.rollback( );
+ throw new NoSuchMetadataException( "Failed to find security group: " + groupName + " for " + ownerFullName, ex );
+ }
+ }
+
public static NetworkGroup lookup( final String groupId ) throws NoSuchMetadataException {
EntityTransaction db = Entities.get( NetworkGroup.class );
try {
@@ -255,14 +276,18 @@ public static NetworkGroup lookup( final OwnerFullName ownerFullName, final Stri
static void createDefault( final OwnerFullName ownerFullName ) throws MetadataException {
try {
try {
- NetworkGroup net = Transactions.find( new NetworkGroup( ownerFullName, NETWORK_DEFAULT_NAME ) );
+ NetworkGroup net = Transactions.find( new NetworkGroup( AccountFullName.getInstance( ownerFullName.getAccountNumber( ) ), NETWORK_DEFAULT_NAME ) );
if ( net == null ) {
create( ownerFullName, NETWORK_DEFAULT_NAME, "default group" );
}
} catch ( NoSuchElementException ex ) {
- create( ownerFullName, NETWORK_DEFAULT_NAME, "default group" );
+ try {
+ create( ownerFullName, NETWORK_DEFAULT_NAME, "default group" );
+ } catch ( ConstraintViolationException ex1 ) {}
} catch ( TransactionException ex ) {
- create( ownerFullName, NETWORK_DEFAULT_NAME, "default group" );
+ try {
+ create( ownerFullName, NETWORK_DEFAULT_NAME, "default group" );
+ } catch ( ConstraintViolationException ex1 ) {}
}
} catch ( DuplicateMetadataException ex ) {}
}
@@ -274,17 +299,27 @@ public static String defaultNetworkName( ) {
public static NetworkGroup create( final OwnerFullName ownerFullName, final String groupName, final String groupDescription ) throws MetadataException {
final EntityTransaction db = Entities.get( NetworkGroup.class );
try {
+ NetworkGroup net = Entities.uniqueResult( new NetworkGroup( AccountFullName.getInstance( ownerFullName.getAccountNumber( ) ), groupName ) );
+ if ( net == null ) {
+ final NetworkGroup entity = Entities.persist( new NetworkGroup( ownerFullName, groupName, groupDescription ) );
+ db.commit( );
+ return entity;
+ } else {
+ db.rollback( );
+ throw new DuplicateMetadataException( "Failed to create group: " + groupName + " for " + ownerFullName.toString( ) );
+ }
+ } catch ( final NoSuchElementException ex ) {
final NetworkGroup entity = Entities.persist( new NetworkGroup( ownerFullName, groupName, groupDescription ) );
db.commit( );
return entity;
} catch ( final ConstraintViolationException ex ) {
Logs.exhaust( ).error( ex );
db.rollback( );
- throw new DuplicateMetadataException( "Failed to create default group: " + ownerFullName.toString( ), ex );
+ throw new DuplicateMetadataException( "Failed to create group: " + groupName + " for " + ownerFullName.toString( ), ex );
} catch ( final Exception ex ) {
Logs.exhaust( ).error( ex, ex );
db.rollback( );
- throw new MetadataException( "Failed to create default group: " + ownerFullName.toString( ), PersistenceExceptions.transform( ex ) );
+ throw new MetadataException( "Failed to create group: " + groupName + " for " + ownerFullName.toString( ), PersistenceExceptions.transform( ex ) );
}
}
@@ -345,7 +380,69 @@ public SecurityGroupItemType apply( final NetworkGroup input ) {
}
- public static List<NetworkGroup> userNetworkGroups( final OwnerFullName owner ) throws MetadataException {
- return lookupAll( owner, null );
+ @TypeMapper
+ public enum IpPermissionTypeExtractNetworkPeers implements Function<IpPermissionType, List<NetworkPeer>> {
+ INSTANCE;
+
+ @Override
+ public List<NetworkPeer> apply( IpPermissionType ipPerm ) {
+ List<NetworkPeer> networkPeers = new ArrayList<NetworkPeer>( );
+ for ( UserIdGroupPairType peerInfo : ipPerm.getGroups( ) ) {
+ networkPeers.add( new NetworkPeer( peerInfo.getSourceUserId( ), peerInfo.getSourceGroupName( ) ) );
+ }
+ return networkPeers;
+ }
+ }
+
+ @TypeMapper
+ public enum IpPermissionTypeAsNetworkRule implements Function<IpPermissionType, List<NetworkRule>> {
+ INSTANCE;
+
+ /**
+ * @see com.google.common.base.Function#apply(java.lang.Object)
+ */
+ @Override
+ public List<NetworkRule> apply( IpPermissionType ipPerm ) {
+ List<NetworkRule> ruleList = new ArrayList<NetworkRule>( );
+ if ( !ipPerm.getGroups( ).isEmpty( ) ) {
+ if ( ipPerm.getFromPort( ) == 0 && ipPerm.getToPort( ) == 0 ) {
+ ipPerm.setToPort( 65535 );
+ }
+ //:: fixes handling of under-specified named-network rules sent by some clients :://
+ if ( ipPerm.getIpProtocol( ) == null ) {
+ NetworkRule rule = new NetworkRule( "tcp", ipPerm.getFromPort( ), ipPerm.getToPort( ) );
+ rule.getNetworkPeers( ).addAll( IpPermissionTypeExtractNetworkPeers.INSTANCE.apply( ipPerm ) );
+ ruleList.add( rule );
+ NetworkRule rule1 = new NetworkRule( "udp", ipPerm.getFromPort( ), ipPerm.getToPort( ) );
+ rule1.getNetworkPeers( ).addAll( IpPermissionTypeExtractNetworkPeers.INSTANCE.apply( ipPerm ) );
+ ruleList.add( rule1 );
+ NetworkRule rule2 = new NetworkRule( "icmp", -1, -1 );
+ rule2.getNetworkPeers( ).addAll( IpPermissionTypeExtractNetworkPeers.INSTANCE.apply( ipPerm ) );
+ ruleList.add( rule2 );
+ } else {
+ NetworkRule rule = new NetworkRule( ipPerm.getIpProtocol( ), ipPerm.getFromPort( ), ipPerm.getToPort( ) );
+ rule.getNetworkPeers( ).addAll( IpPermissionTypeExtractNetworkPeers.INSTANCE.apply( ipPerm ) );
+ ruleList.add( rule );
+ }
+ } else if ( !ipPerm.getIpRanges( ).isEmpty( ) ) {
+ List<IpRange> ipRanges = new ArrayList<IpRange>( );
+ for ( String range : ipPerm.getIpRanges( ) ) {
+ String[] rangeParts = range.split( "/" );
+ try {
+ if ( Integer.parseInt( rangeParts[1] ) > 32 || Integer.parseInt( rangeParts[1] ) < 0 ) continue;
+ if ( rangeParts.length != 2 ) continue;
+ if ( InetAddress.getByName( rangeParts[0] ) != null ) {
+ ipRanges.add( new IpRange( range ) );
+ }
+ } catch ( NumberFormatException e ) {} catch ( UnknownHostException e ) {}
+ }
+ NetworkRule rule = new NetworkRule( ipPerm.getIpProtocol( ), ipPerm.getFromPort( ), ipPerm.getToPort( ), ipRanges );
+ ruleList.add( rule );
+ } else {
+ throw new IllegalArgumentException( "Invalid Ip Permissions: must specify either a source cidr or user" );
+ }
+ return ruleList;
+ }
+
}
}
View
8 clc/modules/cluster-manager/src/main/java/com/eucalyptus/vm/VmControl.java
@@ -187,7 +187,7 @@ public DescribeInstancesResponseType describeInstances( final DescribeInstancesT
if ( !instancesSet.isEmpty( ) && !instancesSet.contains( v.getInstanceId( ) ) ) {
continue;
}
- if ( rsvMap.get( v.getReservationId( ) ) == null ) {
+ if ( !rsvMap.containsKey( v.getReservationId( ) ) ) {
final ReservationInfoType reservation = new ReservationInfoType( v.getReservationId( ), v.getOwner( ).getNamespace( ), v.getNetworkNames( ) );
rsvMap.put( reservation.getReservationId( ), reservation );
}
@@ -197,9 +197,13 @@ public DescribeInstancesResponseType describeInstances( final DescribeInstancesT
Logs.exhaust( ).error( ex, ex );
db.rollback( );
try {
- if ( vm != null ) {
+ if ( vm != null && !VmState.BURIED.apply( vm ) ) {
RunningInstancesItemType ret = VmInstances.transform( vm );
if ( ret != null && vm.getReservationId( ) != null ) {
+ if ( !rsvMap.containsKey( vm.getReservationId( ) ) ) {
+ final ReservationInfoType reservation = new ReservationInfoType( vm.getReservationId( ), vm.getOwner( ).getNamespace( ), vm.getNetworkNames( ) );
+ rsvMap.put( reservation.getReservationId( ), reservation );
+ }
rsvMap.get( vm.getReservationId( ) ).getInstancesSet( ).add( ret );
}
}
View
2 clc/modules/configuration/conf/scripts/describe_nodes.groovy
@@ -7,12 +7,14 @@ import com.google.common.collect.Lists;
import com.eucalyptus.cluster.VmInstance;
import com.eucalyptus.cluster.VmInstances;
import com.eucalyptus.config.NodeComponentInfoType;
+import com.eucalyptus.scripting.Groovyness;
List<NodeComponentInfoType> nodeInfoList = Lists.newArrayList( );
for( Cluster c : Clusters.getInstance( ).listValues( ) ) {
for( String nodeTag : c.getNodeTags( ) ) {
NodeComponentInfoType nodeInfo = new NodeComponentInfoType( new URL(nodeTag).getHost( ), c.getName() );
for( VmInstance vm : VmInstances.listValues( ) ) {
+ vm = Groovyness.expandoMetaClass(vm);
if( nodeTag.equals( vm.getServiceTag() ) ) {
nodeInfo.getInstances().add( vm.getInstanceId() );
}
View
33 clc/modules/core/conf/upgrade/upgrade_20_30.groovy
@@ -56,13 +56,11 @@ import edu.ucsb.eucalyptus.cloud.entities.ZoneInfo;
// Images
import com.eucalyptus.images.ImageInfo;
-import com.eucalyptus.images.LaunchPermission;
-import com.eucalyptus.images.ProductCode;
import com.eucalyptus.images.ImageUtil;
import com.eucalyptus.images.KernelImageInfo;
import com.eucalyptus.images.MachineImageInfo;
import com.eucalyptus.images.RamdiskImageInfo;
-import com.eucalyptus.cloud.Image;
+import com.eucalyptus.cloud.ImageMetadata;
// Storage
import edu.ucsb.eucalyptus.cloud.entities.AOEMetaInfo;
@@ -485,58 +483,57 @@ class upgrade_20_30 extends AbstractUpgradeScript {
def bundleSize = null;
def ckSum = null;
def ckSumType = null;
- def platform = Image.Platform.valueOf("linux");
+ def platform = ImageMetadata.Platform.valueOf("linux");
def cachedImg = connMap['eucalyptus_walrus'].firstRow("""SELECT manifest_name,size sz FROM ImageCache
WHERE bucket_name=? AND manifest_name=?""", path);
if (cachedImg != null)
imgSize = cachedImg.sz.toInteger();
if (img.image_platform != null)
- platform = Image.Platform.valueOf(img.image_platform);
+ platform = ImageMetadata.Platform.valueOf(img.image_platform);
def ii = null;
switch ( img.image_type ) {
case "kernel":
ii = new KernelImageInfo( ufn, img.image_name, img.image_name,
"No Description", imgSize,
- Image.Architecture.valueOf(img.image_arch), platform,
+ ImageMetadata.Architecture.valueOf(img.image_arch), platform,
img.image_path, bundleSize, ckSum, ckSumType );
break;
case "ramdisk":
ii = new RamdiskImageInfo( ufn, img.image_name, img.image_name,
"No Description", imgSize,
- Image.Architecture.valueOf(img.image_arch), platform,
+ ImageMetadata.Architecture.valueOf(img.image_arch), platform,
img.image_path, bundleSize, ckSum, ckSumType );
break;
case "machine":
ii = new MachineImageInfo( ufn, img.image_name, img.image_name,
"No Description", imgSize,
- Image.Architecture.valueOf(img.image_arch), platform,
+ ImageMetadata.Architecture.valueOf(img.image_arch), platform,
img.image_path, bundleSize, ckSum, ckSumType,
img.image_kernel_id, img.image_ramdisk_id );
break;
}
initMetaClass(ii, ii.class);
ii.setImagePublic(img.image_is_public);
- ii.setImageType(Image.Type.valueOf(img.image_type));
+ ii.setImageType(ImageMetadata.Type.valueOf(img.image_type));
ii.setSignature(img.image_signature);
- ii.setState( Image.State.valueOf(img.image_availability));
+ ii.setState( ImageMetadata.State.valueOf(img.image_availability));
dbGen.add(ii);
dbGen.commit();
connMap['eucalyptus_general'].rows("""SELECT image_product_code_value FROM image_product_code
JOIN image_has_product_codes
ON image_product_code.image_product_code_id=image_has_product_codes.image_product_code_id
WHERE image_id=?""", [ img.image_id ]).each { prodCode ->
- EntityWrapper<ProductCode> dbPC = EntityWrapper.get(ProductCode.class);
- dbPC.add(new ProductCode(ii, prodCode.image_product_code_value));
- dbPC.commit();
+ ii.addProductCode(prodCode.image_product_code_value);
}
+
+ List<String> accountIds = new ArrayList<String>();
connMap['eucalyptus_general'].rows("""SELECT * FROM image_authorization
JOIN image_has_user_auth
ON image_authorization.image_auth_id=image_has_user_auth.image_auth_id
WHERE image_id=?""", [ img.image_id ]).each { imgAuth ->
- EntityWrapper<LaunchPermission> dbLP = EntityWrapper.get(LaunchPermission.class);
- dbLP.add(new LaunchPermission(ii, imgAuth.image_auth_name));
- dbLP.commit();
+ accountIds.add(accountIdMap.get(safeUserMap.get(imgAuth.image_auth_name)))
}
+ ii.addPermissions(accountIds);
}
connMap['eucalyptus_images'].rows("SELECT * FROM Volume WHERE username=?", [ it.auth_user_name ]).each { vol ->
@@ -895,7 +892,7 @@ class upgrade_20_30 extends AbstractUpgradeScript {
dbPart.commit();
LOG.debug("Adding Cluster ${ it.config_component_name }");
// First argument is Partition name
- ClusterConfiguration clcfg = new ClusterConfiguration(it.config_component_name, it.config_component_name, it.config_component_hostname, it.config_component_port);
+ ClusterConfiguration clcfg = new ClusterConfiguration(it.config_component_name, it.config_component_name + "_cc", it.config_component_hostname, it.config_component_port);
dbCluster.add(clcfg);
dbCluster.commit();
} finally {
@@ -905,7 +902,7 @@ class upgrade_20_30 extends AbstractUpgradeScript {
connMap['eucalyptus_config'].rows('SELECT * FROM config_sc').each{
EntityWrapper<StorageControllerConfiguration> dbSC = EntityWrapper.get(StorageControllerConfiguration.class);
// First argument is partition name
- StorageControllerConfiguration sc = new StorageControllerConfiguration(it.config_component_name, it.config_component_name, it.config_component_hostname, it.config_component_port);
+ StorageControllerConfiguration sc = new StorageControllerConfiguration(it.config_component_name, it.config_component_name + "_sc", it.config_component_hostname, it.config_component_port);
if (it.config_component_port == -1 || Internets.testLocal(it.config_component_hostname)) {
System.setProperty('euca.storage.name', it.config_component_name);
}
View
2 clc/modules/euare/src/main/java/com/eucalyptus/auth/euare/EuareService.java
@@ -134,7 +134,7 @@ public CreateAccountResponseType createAccount(CreateAccountType request) throws
try {
Account newAccount = Accounts.addAccount( request.getAccountName( ) );
User admin = newAccount.addUser( User.ACCOUNT_ADMIN, "/", true/*skipRegistration*/, true/*enabled*/, null/*info*/ );
- admin.createToken( );
+ admin.resetToken( );
admin.createConfirmationCode( );
//admin.createPassword( );
AccountType account = reply.getCreateAccountResult( ).getAccount( );
View
4 clc/modules/msgs/src/main/java/com/eucalyptus/auth/principal/Principals.java
@@ -413,7 +413,7 @@ public void setEnabled( Boolean enabled ) throws AuthException {}
public void setToken( String token ) throws AuthException {}
@Override
- public void createToken( ) throws AuthException {}
+ public String resetToken( ) throws AuthException { return null; }
@Override
public void setConfirmationCode( String code ) throws AuthException {}
@@ -648,7 +648,7 @@ public void setEnabled( Boolean enabled ) throws AuthException {}
public void setToken( String token ) throws AuthException {}
@Override
- public void createToken( ) throws AuthException {}
+ public String resetToken( ) throws AuthException { return null; }
@Override
public void setConfirmationCode( String code ) throws AuthException {}
View
2 clc/modules/msgs/src/main/java/com/eucalyptus/auth/principal/User.java
@@ -109,7 +109,7 @@
public String getToken( );
public void setToken( String token ) throws AuthException;
- public void createToken( ) throws AuthException;
+ public String resetToken( ) throws AuthException;
public String getConfirmationCode( );
public void setConfirmationCode( String code ) throws AuthException;
View
3 clc/modules/msgs/src/main/java/com/eucalyptus/auth/principal/UserFullName.java
@@ -254,4 +254,7 @@ public boolean isOwner( final OwnerFullName ownerFullName ) {
return this.userId.equals( ownerFullName.getAccountNumber( ) ) || this.accountNumber.equals( ownerFullName.getAccountNumber( ) );
}
+ public AccountFullName asAccountFullName( ) {
+ return AccountFullName.getInstance( this.getAccountNumber( ) );
+ }
}
View
2 clc/modules/msgs/src/main/java/com/eucalyptus/component/Partitions.java
@@ -187,7 +187,7 @@ public static boolean testPartitionCredentialsDirectory( String name ) {
}
@SuppressWarnings("unchecked")
-public static <T extends ServiceConfiguration> T lookupService( Class<? extends ComponentId> compClass, Partition partition ) {
+ public static <T extends ServiceConfiguration> T lookupService( Class<? extends ComponentId> compClass, Partition partition ) {
NavigableSet<ServiceConfiguration> services = Components.lookup( compClass ).enabledPartitionServices( partition );
if ( services.isEmpty( ) ) {
throw new NoSuchElementException( "Failed to find service of type: " + compClass.getSimpleName( ) + " in partition: " + partition );
View
85 clc/modules/msgs/src/main/java/com/eucalyptus/configurable/StaticPropertyEntry.java
@@ -66,9 +66,10 @@
import java.lang.reflect.Modifier;
import java.nio.charset.CoderMalfunctionError;
import javax.activation.UnsupportedDataTypeException;
-import org.apache.commons.lang.ClassUtils;
import org.apache.log4j.Logger;
+import com.eucalyptus.bootstrap.Bootstrap;
import com.eucalyptus.configurable.PropertyDirectory.NoopEventListener;
+import com.eucalyptus.records.Logs;
public class StaticPropertyEntry extends AbstractConfigurableProperty {
static Logger LOG = Logger.getLogger( StaticPropertyEntry.class );
@@ -78,10 +79,14 @@ public StaticPropertyEntry( Class definingClass, String entrySetName, Field fiel
Boolean readOnly, String displayName, ConfigurableFieldType widgetType, String alias, PropertyChangeListener changeListener ) {
super( definingClass, entrySetName, field, defaultValue, description, typeParser, readOnly, displayName, widgetType, alias, changeListener );
this.field = field;
- if ( this.field.getType( ).isPrimitive( ) ) {
- throw new CoderMalfunctionError( new UnsupportedDataTypeException( "Unsupported usage of @Configurable on a primitive field: "
- + field.getDeclaringClass( ) + "." + field.getName( ) ) );
- }
+ }
+
+ private String getFieldCanonicalName( ) {
+ return this.getField( ).getDeclaringClass( ).getCanonicalName( ) + "." + this.getFieldName( );
+// if ( this.field.getType( ).isPrimitive( ) ) {
+// throw new CoderMalfunctionError( new UnsupportedDataTypeException( "Unsupported usage of @Configurable on a primitive field: "
+// + field.getDeclaringClass( ) + "." + field.getName( ) ) );
+// }
}
public Field getField( ) {
@@ -90,10 +95,31 @@ public Field getField( ) {
@Override
public String getValue( ) {
+ if ( Bootstrap.isFinished( ) ) {
+ try {
+ String dbValue = StaticDatabasePropertyEntry.lookup( this.getFieldCanonicalName( ), this.getQualifiedName( ), this.safeGetFieldValue( ) ).getValue( );
+ Object o = super.getTypeParser( ).apply( dbValue );
+ this.field.set( null, o );
+ return dbValue;
+ } catch ( Exception e ) {
+ LOG.warn( "Failed to get property: " + super.getQualifiedName( ) + " because of " + e.getMessage( ) );
+ Logs.extreme( ).debug( e, e );
+ return super.getDefaultValue( );
+ }
+ } else {
+ return super.getDefaultValue( );
+ }
+ }
+
+ private String safeGetFieldValue( ) {
try {
- return "" + this.field.get( null );
- } catch ( Exception e ) {
- LOG.debug( e, e );
+ Object o = this.field.get( null );
+ if ( o == null ) {
+ return super.getDefaultValue( );
+ } else {
+ return o.toString( );
+ }
+ } catch ( Exception ex ) {
return super.getDefaultValue( );
}
}
@@ -102,20 +128,36 @@ public String getValue( ) {
public String setValue( String s ) {
if ( Modifier.isFinal( this.field.getModifiers( ) ) ) {
return "failed to assign final field: " + super.getQualifiedName( );
- } else {
+ } else if ( Bootstrap.isFinished( ) ) {
try {
Object o = super.getTypeParser( ).apply( s );
this.fireChange( s );
+ StaticDatabasePropertyEntry.update( this.getFieldCanonicalName( ), this.getQualifiedName( ), s );
this.field.set( null, o );
LOG.info( "--> Set property value: " + super.getQualifiedName( ) + " to " + s );
- } catch ( Exception t ) {
- LOG.warn( "Failed to set property: " + super.getQualifiedName( ) + " because of " + t.getMessage( ) );
- LOG.debug( t, t );
+ } catch ( Exception e ) {
+ LOG.warn( "Failed to set property: " + super.getQualifiedName( ) + " because of " + e.getMessage( ) );
+ Logs.extreme( ).debug( e, e );
}
return this.getValue( );
+ } else {
+ return super.getDefaultValue( );
}
}
+
+ /**
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ @Override
+ public int compareTo( ConfigurableProperty that ) {
+ return this.getQualifiedName( ) != null
+ ? this.getQualifiedName( ).compareTo( that.getQualifiedName( ) )
+ : ( that.getQualifiedName( ) == null
+ ? 0
+ : -1 );
+ }
+
public static class StaticPropertyBuilder implements ConfigurablePropertyBuilder {
private static String qualifiedName( Class c, Field f ) {
ConfigurableClass annote = ( ConfigurableClass ) c.getAnnotation( ConfigurableClass.class );
@@ -137,9 +179,12 @@ public ConfigurableProperty buildProperty( Class c, Field field ) throws Configu
Class<? extends PropertyChangeListener> changeListenerClass = annote.changeListener( );
PropertyChangeListener changeListener;
if ( !changeListenerClass.equals( NoopEventListener.class ) ) {
+ if ( changeListenerClass.isEnum( ) ) {
+ changeListener = changeListenerClass.getEnumConstants( )[0];
+ }
try {
changeListener = changeListenerClass.newInstance( );
- } catch ( Exception e ) {
+ } catch ( Throwable e ) {
changeListener = NoopEventListener.NOOP;
}
} else {
@@ -149,14 +194,13 @@ public ConfigurableProperty buildProperty( Class c, Field field ) throws Configu
if ( Modifier.isPublic( modifiers ) && Modifier.isStatic( modifiers ) ) {
entry = new StaticPropertyEntry( c, fqPrefix, field, description, defaultValue, p, annote.readonly( ), annote.displayName( ), annote.type( ), alias,
changeListener );
- entry.setValue( defaultValue );
return entry;
}
}
return null;
}
}
-
+
/**
* @see com.eucalyptus.configurable.AbstractConfigurableProperty#getQueryObject()
*/
@@ -165,15 +209,4 @@ protected Object getQueryObject( ) throws Exception {
return null;
}
- /**
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- @Override
- public int compareTo( ConfigurableProperty that ) {
- return this.getQualifiedName( ) != null
- ? this.getQualifiedName( ).compareTo( that.getQualifiedName( ) )
- : ( that.getQualifiedName( ) == null
- ? 0
- : -1 );
- }
}
View
4 clc/modules/msgs/src/main/java/com/eucalyptus/context/ServiceContext.java
@@ -103,7 +103,7 @@ public static void dispatch( String dest, Object msg ) throws ServiceInitializat
LOG.error( ex, ex );
throw new ServiceDispatchException( "Failed to dispatch message to " + dest + " caused by failure to obtain service dispatcher reference: "
+ ex.getMessage( ), ex );
- } finally {
+ } /*finally {
Threads.lookup( Empyrean.class, ServiceContext.class ).submit( new Runnable( ) {
@Override
public void run( ) {
@@ -116,7 +116,7 @@ public void run( ) {
}
}
} );
- }
+ }*/
}
public static <T> T send( String dest, Object msg ) throws ServiceDispatchException {
View
9 clc/modules/msgs/src/main/java/com/eucalyptus/scripting/Groovyness.java
@@ -1,5 +1,6 @@
package com.eucalyptus.scripting;
+import groovy.lang.ExpandoMetaClass;
import groovy.lang.ExpandoMetaClassCreationHandle;
import groovy.lang.GroovyClassLoader;
import groovy.lang.GroovyObject;
@@ -25,7 +26,15 @@
private static Logger LOG = Logger.getLogger( Groovyness.class );
public static ScriptEngine groovyEngine = getGroovyEngine( );
+ public static <T extends GroovyObject> T expandoMetaClass( T obj ) {
+ ExpandoMetaClass emc = new ExpandoMetaClass( obj.getClass( ), false );
+ emc.initialize();
+ obj.setMetaClass( emc );
+ return obj;
+ }
+
private static GroovyClassLoader getGroovyClassLoader( ) {
+ GroovySystem.getMetaClassRegistry( ).setMetaClassCreationHandle( new ExpandoMetaClassCreationHandle( ) );
CompilerConfiguration config = new CompilerConfiguration( );
config.setDebug( true );
config.setVerbose( true );
View
88 clc/modules/walrus/src/main/java/edu/ucsb/eucalyptus/cloud/ws/WalrusManager.java