• R/O
  • SSH
  • HTTPS

eclipse-aws: Commit


Commit MetaInfo

Révision101 (tree)
l'heure2010-09-25 12:44:06
Auteurtanakatmf

Message de Log

Add DetachVolumeAction.
AttachVolumeActionのデバイスも増やした

Change Summary

Modification

--- plugins/trunk/jp.co.intellilink.aws.ui/src/jp/co/intellilink/aws/ui/wizard/AttachVolumeDeviceSettingPage.java (revision 100)
+++ plugins/trunk/jp.co.intellilink.aws.ui/src/jp/co/intellilink/aws/ui/wizard/AttachVolumeDeviceSettingPage.java (revision 101)
@@ -3,6 +3,7 @@
33 */
44 package jp.co.intellilink.aws.ui.wizard;
55
6+import java.util.ArrayList;
67 import java.util.List;
78
89 import org.eclipse.jface.preference.ComboFieldEditor;
@@ -25,6 +26,19 @@
2526
2627 private ComboFieldEditor deviceComboEditor;
2728
29+ private static final List<String> ALL_DEVICE;
30+
31+ static {
32+ final int ALL_DEVICE_SIZE = 'z' - 'b';
33+ char start = 'b';
34+ List<String> allDevice = new ArrayList<String>();
35+ for (int i = 0; i <= ALL_DEVICE_SIZE; i++) {
36+ allDevice.add("/dev/sd" + String.valueOf(start));
37+ start++;
38+ }
39+ ALL_DEVICE = allDevice;
40+ }
41+
2842 protected AttachVolumeDeviceSettingPage(String pageName, final IPreferenceStore store, List<String> usedDevice) {
2943 super(pageName);
3044 this.store = store;
@@ -51,12 +65,18 @@
5165 }
5266
5367 private String[][] createDevices() {
54- // TODO 少なすぎw /dev/sdb - /dev/sdz まで作る(使わないよなぁ).
55- // TODO アタッチ済みのボリュームが使っているdeviceは除くこと. usedDevice
56- for (String device : usedDevice) {
57- device.toString();
68+ List<String> devices = new ArrayList<String>(ALL_DEVICE);
69+ devices.removeAll(usedDevice);
70+ for (String string : devices) {
71+ System.out.println(string);
5872 }
59- String[][] ret = { { "/dev/sdb", "/dev/sdb" }, { "/dev/sdc", "/dev/sdc" }, { "/dev/sdd", "/dev/sdd" } };
73+ String[][] ret = new String[devices.size()][2];
74+ int count = 0;
75+ for (String device : devices) {
76+ ret[count][0] = device;
77+ ret[count][1] = device;
78+ count++;
79+ }
6080 return ret;
6181 }
6282
--- plugins/trunk/jp.co.intellilink.aws.ui/src/jp/co/intellilink/aws/ui/job/DetachVolumeJob.java (nonexistent)
+++ plugins/trunk/jp.co.intellilink.aws.ui/src/jp/co/intellilink/aws/ui/job/DetachVolumeJob.java (revision 101)
@@ -0,0 +1,58 @@
1+/**
2+ *
3+ */
4+package jp.co.intellilink.aws.ui.job;
5+
6+import jp.co.intellilink.aws.api.ElasticComputingCloudInterface;
7+import jp.co.intellilink.aws.api.transport.EC2DetachVolumeRequest;
8+import jp.co.intellilink.aws.core.CoreException;
9+import jp.co.intellilink.aws.core.EC2ServiceProvider;
10+import jp.co.intellilink.aws.ui.Activator;
11+
12+import org.eclipse.core.runtime.IProgressMonitor;
13+import org.eclipse.core.runtime.IStatus;
14+import org.eclipse.core.runtime.Status;
15+import org.eclipse.core.runtime.jobs.Job;
16+
17+/**
18+ * @author tanacasino
19+ *
20+ */
21+public class DetachVolumeJob extends Job {
22+
23+ private String volumeId;
24+
25+ public DetachVolumeJob(String name, String volumeId) {
26+ super(name);
27+ this.volumeId = volumeId;
28+ }
29+
30+ /*
31+ * (non-Javadoc)
32+ *
33+ * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
34+ */
35+ @Override
36+ protected IStatus run(IProgressMonitor monitor) {
37+ monitor.beginTask("AddIpPermission", 0);
38+ monitor.setTaskName("Resolve EC2 Client...");
39+ EC2ServiceProvider provider = Activator.getDefault().getProvider();
40+ monitor.worked(30);
41+ monitor.setTaskName("Add Ip Permission...");
42+ try {
43+ ElasticComputingCloudInterface client = provider.getEC2();
44+ monitor.worked(60);
45+ EC2DetachVolumeRequest request = new EC2DetachVolumeRequest();
46+ request.setVolumeId(volumeId);
47+ client.detachVolume(request);
48+ monitor.worked(90);
49+ } catch (CoreException e) {
50+ // TODO Auto-generated catch block
51+ e.printStackTrace();
52+ return Status.CANCEL_STATUS;
53+ }
54+ monitor.done();
55+ return Status.OK_STATUS;
56+ }
57+
58+}
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
--- plugins/trunk/jp.co.intellilink.aws.ui/src/jp/co/intellilink/aws/ui/view/InstanceView.java (revision 100)
+++ plugins/trunk/jp.co.intellilink.aws.ui/src/jp/co/intellilink/aws/ui/view/InstanceView.java (revision 101)
@@ -15,6 +15,7 @@
1515 import jp.co.intellilink.aws.ui.Activator;
1616 import jp.co.intellilink.aws.ui.action.AttachVolumeAction;
1717 import jp.co.intellilink.aws.ui.action.DescribeInstancesAction;
18+import jp.co.intellilink.aws.ui.action.DetachVolumeAction;
1819 import jp.co.intellilink.aws.ui.action.RebootInstanceAction;
1920 import jp.co.intellilink.aws.ui.action.TerminateInstanceAction;
2021 import jp.co.intellilink.aws.ui.model.InstanceModel;
@@ -202,23 +203,31 @@
202203 System.out.println("canDetach : " + canDetachVolumes);
203204 if (canAttachVolumes.size() >= 1) {
204205 for (EC2Volume vol : canAttachVolumes) {
205- List<String> usedDevice = new ArrayList<String>();
206- for (EC2Attachment attachment : vol.getAttachment()) {
207- usedDevice.add(attachment.getDevice());
208- }
206+ List<String> usedDevice = createUsedDeviceList(instance.getInstanceId(), canDetachVolumes);
209207 attachMenu.add(new AttachVolumeAction(vol.getVolumeId(), instance.getInstanceId(), usedDevice));
210208 System.out.println(vol.getVolumeId());
211209 }
212210 attachMenu.setVisible(true);
213211 }
214- // if (canDetachVolumes.size() >= 1) {
215- // for (EC2Volume vol : canDetachVolumes) {
216- // detachMenu.add(null);
217- // }
218- // detachMenu.setVisible(true);
219- // }
212+ if (canDetachVolumes.size() >= 1) {
213+ for (EC2Volume vol : canDetachVolumes) {
214+ detachMenu.add(new DetachVolumeAction(vol.getVolumeId()));
215+ }
216+ detachMenu.setVisible(true);
217+ }
220218 }
221219
220+ private List<String> createUsedDeviceList(String instanceId, List<EC2Volume> volumes) {
221+ List<String> usedDevice = new ArrayList<String>();
222+ for (EC2Volume volume : volumes) {
223+ List<EC2Attachment> attachments = volume.getAttachment();
224+ for (EC2Attachment attachment : attachments) {
225+ usedDevice.add(attachment.getDevice());
226+ }
227+ }
228+ return usedDevice;
229+ }
230+
222231 private List<EC2Volume> describeVolumes() {
223232 EC2ServiceProvider provider = Activator.getDefault().getProvider();
224233 List<EC2Volume> volumes = null;
--- plugins/trunk/jp.co.intellilink.aws.ui/src/jp/co/intellilink/aws/ui/action/DetachVolumeAction.java (nonexistent)
+++ plugins/trunk/jp.co.intellilink.aws.ui/src/jp/co/intellilink/aws/ui/action/DetachVolumeAction.java (revision 101)
@@ -0,0 +1,30 @@
1+/**
2+ *
3+ */
4+package jp.co.intellilink.aws.ui.action;
5+
6+import jp.co.intellilink.aws.ui.job.DetachVolumeJob;
7+
8+import org.eclipse.jface.action.Action;
9+
10+/**
11+ * @author tanacasino
12+ *
13+ */
14+public class DetachVolumeAction extends Action {
15+
16+ private String volumeId;
17+
18+ public DetachVolumeAction(String volumeId) {
19+ this.volumeId = volumeId;
20+ setText(this.volumeId);
21+ }
22+
23+ @Override
24+ public void run() {
25+ super.run();
26+ DetachVolumeJob job = new DetachVolumeJob("Detach Volume", this.volumeId);
27+ job.schedule();
28+ }
29+
30+}
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Afficher sur ancien navigateur de dépôt.