forked from apache/cloudstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVirtualDiskManagerMO.java
More file actions
executable file
·157 lines (120 loc) · 7.36 KB
/
VirtualDiskManagerMO.java
File metadata and controls
executable file
·157 lines (120 loc) · 7.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.hypervisor.vmware.mo;
import org.apache.log4j.Logger;
import com.cloud.hypervisor.vmware.util.VmwareContext;
import com.vmware.vim25.HostDiskDimensionsChs;
import com.vmware.vim25.ManagedObjectReference;
import com.vmware.vim25.VirtualDiskSpec;
public class VirtualDiskManagerMO extends BaseMO {
private static final Logger s_logger = Logger.getLogger(VirtualDiskManagerMO.class);
public VirtualDiskManagerMO(VmwareContext context, ManagedObjectReference morDiskMgr) {
super(context, morDiskMgr);
}
public VirtualDiskManagerMO(VmwareContext context, String morType, String morValue) {
super(context, morType, morValue);
}
public void copyVirtualDisk(String srcName, ManagedObjectReference morSrcDc,
String destName, ManagedObjectReference morDestDc, VirtualDiskSpec diskSpec,
boolean force) throws Exception {
ManagedObjectReference morTask = _context.getService().copyVirtualDisk_Task(_mor, srcName, morSrcDc, destName, morDestDc, diskSpec, force);
String result = _context.getServiceUtil().waitForTask(morTask);
if(!result.equals("sucess"))
throw new Exception("Unable to copy virtual disk " + srcName + " to " + destName
+ " due to " + TaskMO.getTaskFailureInfo(_context, morTask));
_context.waitForTaskProgressDone(morTask);
}
public void createVirtualDisk(String name, ManagedObjectReference morDc, VirtualDiskSpec diskSpec) throws Exception {
ManagedObjectReference morTask = _context.getService().createVirtualDisk_Task(_mor, name, morDc, diskSpec);
String result = _context.getServiceUtil().waitForTask(morTask);
if(!result.equals("sucess"))
throw new Exception("Unable to create virtual disk " + name
+ " due to " + TaskMO.getTaskFailureInfo(_context, morTask));
_context.waitForTaskProgressDone(morTask);
}
public void defragmentVirtualDisk(String name, ManagedObjectReference morDc) throws Exception {
ManagedObjectReference morTask = _context.getService().defragmentVirtualDisk_Task(_mor, name, morDc);
String result = _context.getServiceUtil().waitForTask(morTask);
if(!result.equals("sucess"))
throw new Exception("Unable to defragment virtual disk " + name + " due to " + result);
_context.waitForTaskProgressDone(morTask);
}
public void deleteVirtualDisk(String name, ManagedObjectReference morDc) throws Exception {
ManagedObjectReference morTask = _context.getService().deleteVirtualDisk_Task(_mor, name, morDc);
String result = _context.getServiceUtil().waitForTask(morTask);
if(!result.equals("sucess"))
throw new Exception("Unable to delete virtual disk " + name + " due to " + TaskMO.getTaskFailureInfo(_context, morTask));
_context.waitForTaskProgressDone(morTask);
}
public void eagerZeroVirtualDisk(String name, ManagedObjectReference morDc) throws Exception {
ManagedObjectReference morTask = _context.getService().eagerZeroVirtualDisk_Task(_mor, name, morDc);
String result = _context.getServiceUtil().waitForTask(morTask);
if(!result.equals("sucess"))
throw new Exception("Unable to eager zero virtual disk " + name + " due to " + TaskMO.getTaskFailureInfo(_context, morTask));
_context.waitForTaskProgressDone(morTask);
}
public void extendVirtualDisk(String name, ManagedObjectReference morDc, long newCapacityKb, boolean eagerZero) throws Exception {
ManagedObjectReference morTask = _context.getService().extendVirtualDisk_Task(_mor, name, morDc, newCapacityKb, eagerZero);
String result = _context.getServiceUtil().waitForTask(morTask);
if(!result.equals("sucess"))
throw new Exception("Unable to extend virtual disk " + name + " due to " + TaskMO.getTaskFailureInfo(_context, morTask));
_context.waitForTaskProgressDone(morTask);
}
public void inflateVirtualDisk(String name, ManagedObjectReference morDc) throws Exception {
ManagedObjectReference morTask = _context.getService().inflateVirtualDisk_Task(_mor, name, morDc);
String result = _context.getServiceUtil().waitForTask(morTask);
if(!result.equals("sucess"))
throw new Exception("Unable to inflate virtual disk " + name + " due to " + TaskMO.getTaskFailureInfo(_context, morTask));
_context.waitForTaskProgressDone(morTask);
}
public void shrinkVirtualDisk(String name, ManagedObjectReference morDc, boolean copy) throws Exception {
ManagedObjectReference morTask = _context.getService().shrinkVirtualDisk_Task(_mor, name, morDc, copy);
String result = _context.getServiceUtil().waitForTask(morTask);
if(!result.equals("sucess"))
throw new Exception("Unable to shrink virtual disk " + name + " due to " + TaskMO.getTaskFailureInfo(_context, morTask));
_context.waitForTaskProgressDone(morTask);
}
public void zeroFillVirtualDisk(String name, ManagedObjectReference morDc) throws Exception {
ManagedObjectReference morTask = _context.getService().zeroFillVirtualDisk_Task(_mor, name, morDc);
String result = _context.getServiceUtil().waitForTask(morTask);
if(!result.equals("sucess"))
throw new Exception("Unable to zero fill virtual disk " + name + " due to " + TaskMO.getTaskFailureInfo(_context, morTask));
_context.waitForTaskProgressDone(morTask);
}
public void moveVirtualDisk(String srcName, ManagedObjectReference morSrcDc,
String destName, ManagedObjectReference morDestDc, boolean force) throws Exception {
ManagedObjectReference morTask = _context.getService().moveVirtualDisk_Task(_mor, srcName, morSrcDc,
destName, morDestDc, force);
String result = _context.getServiceUtil().waitForTask(morTask);
if(!result.equals("sucess"))
throw new Exception("Unable to move virtual disk " + srcName + " to " + destName
+ " due to " + TaskMO.getTaskFailureInfo(_context, morTask));
_context.waitForTaskProgressDone(morTask);
}
public int queryVirtualDiskFragmentation(String name, ManagedObjectReference morDc) throws Exception {
return _context.getService().queryVirtualDiskFragmentation(_mor, name, morDc);
}
public HostDiskDimensionsChs queryVirtualDiskGeometry(String name, ManagedObjectReference morDc) throws Exception {
return _context.getService().queryVirtualDiskGeometry(_mor, name, morDc);
}
public String queryVirtualDiskUuid(String name, ManagedObjectReference morDc) throws Exception {
return _context.getService().queryVirtualDiskUuid(_mor, name, morDc);
}
public void setVirtualDiskUuid(String name, ManagedObjectReference morDc, String uuid) throws Exception {
_context.getService().setVirtualDiskUuid(_mor, name, morDc, uuid);
}
}