@@ -625,59 +625,6 @@ public EC2ImageAttributes describeImageAttribute(EC2DescribeImageAttribute reque
625625 return imageAtts ;
626626 }
627627
628-
629-
630- /**
631- * If given a specific list of snapshots of interest, then only values from those snapshots are returned.
632- *
633- * @param interestedShots - can be null, should be a subset of all snapshots
634- */
635- private EC2DescribeSnapshotsResponse listSnapshots ( String [] interestedShots , List <CloudStackKeyValue > resourceTagSet ) throws Exception {
636- EC2DescribeSnapshotsResponse snapshots = new EC2DescribeSnapshotsResponse ();
637-
638- List <CloudStackSnapshot > cloudSnaps ;
639- if (interestedShots == null || interestedShots .length == 0 ) {
640- cloudSnaps = getApi ().listSnapshots (null , null , null , null , null , null , null , null , null , resourceTagSet );
641- } else {
642- cloudSnaps = new ArrayList <CloudStackSnapshot >();
643-
644- for (String id : interestedShots ) {
645- List <CloudStackSnapshot > tmpList = getApi ().listSnapshots (null , null , id , null , null , null , null ,
646- null , null , resourceTagSet );
647- cloudSnaps .addAll (tmpList );
648- }
649- }
650-
651- if (cloudSnaps == null ) {
652- return null ;
653- }
654-
655- for (CloudStackSnapshot cloudSnapshot : cloudSnaps ) {
656- EC2Snapshot shot = new EC2Snapshot ();
657- shot .setId (cloudSnapshot .getId ());
658- shot .setName (cloudSnapshot .getName ());
659- shot .setVolumeId (cloudSnapshot .getVolumeId ());
660- shot .setType (cloudSnapshot .getSnapshotType ());
661- shot .setState (cloudSnapshot .getState ());
662- shot .setCreated (cloudSnapshot .getCreated ());
663- shot .setAccountName (cloudSnapshot .getAccountName ());
664- shot .setDomainId (cloudSnapshot .getDomainId ());
665-
666- List <CloudStackKeyValue > resourceTags = cloudSnapshot .getTags ();
667- for (CloudStackKeyValue resourceTag : resourceTags ) {
668- EC2TagKeyValue param = new EC2TagKeyValue ();
669- param .setKey (resourceTag .getKey ());
670- if (resourceTag .getValue () != null )
671- param .setValue (resourceTag .getValue ());
672- shot .addResourceTag (param );
673- }
674-
675- snapshots .addSnapshot (shot );
676- }
677- return snapshots ;
678- }
679-
680-
681628 // handlers
682629 /**
683630 * return password data from the instance
@@ -2092,6 +2039,53 @@ private EC2DescribeAddressesResponse listAddresses(String[] addressNames) throws
20922039 }
20932040 }
20942041
2042+ private EC2DescribeSnapshotsResponse listSnapshots ( String [] snapshotIds , List <CloudStackKeyValue > resourceTagSet ) throws Exception {
2043+ try {
2044+ EC2DescribeSnapshotsResponse snapshotSet = new EC2DescribeSnapshotsResponse ();
2045+
2046+ List <CloudStackSnapshot > snapshots = getApi ().listSnapshots (null , null , null , null , null , null , null , null , null , resourceTagSet );
2047+ if ( snapshots != null && snapshots .size () > 0 ) {
2048+ for ( CloudStackSnapshot snapshot : snapshots ) {
2049+ boolean matched = false ;
2050+ if ( snapshotIds .length > 0 ) {
2051+ for ( String snapshotId : snapshotIds ) {
2052+ if (snapshot .getId ().equalsIgnoreCase (snapshotId )) {
2053+ matched = true ;
2054+ break ;
2055+ }
2056+ }
2057+ } else matched = true ;
2058+
2059+ if (!matched ) continue ;
2060+
2061+ EC2Snapshot ec2Snapshot = new EC2Snapshot ();
2062+ ec2Snapshot .setId (snapshot .getId ());
2063+ ec2Snapshot .setName (snapshot .getName ());
2064+ ec2Snapshot .setVolumeId (snapshot .getVolumeId ());
2065+ ec2Snapshot .setType (snapshot .getSnapshotType ());
2066+ ec2Snapshot .setState (snapshot .getState ());
2067+ ec2Snapshot .setCreated (snapshot .getCreated ());
2068+ ec2Snapshot .setAccountName (snapshot .getAccountName ());
2069+ ec2Snapshot .setDomainId (snapshot .getDomainId ());
2070+
2071+ List <CloudStackKeyValue > resourceTags = snapshot .getTags ();
2072+ for ( CloudStackKeyValue resourceTag : resourceTags ) {
2073+ EC2TagKeyValue param = new EC2TagKeyValue ();
2074+ param .setKey (resourceTag .getKey ());
2075+ if ( resourceTag .getValue () != null )
2076+ param .setValue (resourceTag .getValue ());
2077+ ec2Snapshot .addResourceTag (param );
2078+ }
2079+ snapshotSet .addSnapshot (ec2Snapshot );
2080+ }
2081+ }
2082+ return snapshotSet ;
2083+ } catch (Exception e ) {
2084+ logger .error ( "List Snapshots - " , e );
2085+ throw new EC2ServiceException (ServerError .InternalError , e .getMessage ());
2086+ }
2087+ }
2088+
20952089 /**
20962090 * Convert ingress rule to EC2IpPermission records
20972091 *
0 commit comments