Revision c41eea6e lib/hypervisor/hv_xen.py
b/lib/hypervisor/hv_xen.py | ||
---|---|---|
61 | 61 |
def _GetXMList(include_node): |
62 | 62 |
"""Return the list of running instances. |
63 | 63 |
|
64 |
If the `include_node` argument is True, then we return information
|
|
64 |
If the include_node argument is True, then we return information
|
|
65 | 65 |
for dom0 also, otherwise we filter that from the return value. |
66 | 66 |
|
67 |
The return value is a list of (name, id, memory, vcpus, state, time spent)
|
|
67 |
@return: list of (name, id, memory, vcpus, state, time spent)
|
|
68 | 68 |
|
69 | 69 |
""" |
70 | 70 |
for dummy in range(5): |
... | ... | |
117 | 117 |
def GetInstanceInfo(self, instance_name): |
118 | 118 |
"""Get instance properties. |
119 | 119 |
|
120 |
Args: |
|
121 |
instance_name: the instance name |
|
120 |
@param instance_name: the instance name |
|
121 |
|
|
122 |
@return: tuple (name, id, memory, vcpus, stat, times) |
|
122 | 123 |
|
123 |
Returns: |
|
124 |
(name, id, memory, vcpus, stat, times) |
|
125 | 124 |
""" |
126 | 125 |
xm_list = self._GetXMList(instance_name=="Domain-0") |
127 | 126 |
result = None |
... | ... | |
134 | 133 |
def GetAllInstancesInfo(self): |
135 | 134 |
"""Get properties of all instances. |
136 | 135 |
|
137 |
Returns:
|
|
138 |
[(name, id, memory, vcpus, stat, times),...] |
|
136 |
@return: list of tuples (name, id, memory, vcpus, stat, times)
|
|
137 |
|
|
139 | 138 |
""" |
140 | 139 |
xm_list = self._GetXMList(False) |
141 | 140 |
return xm_list |
142 | 141 |
|
143 | 142 |
def StartInstance(self, instance, block_devices, extra_args): |
144 |
"""Start an instance.""" |
|
143 |
"""Start an instance. |
|
144 |
|
|
145 |
""" |
|
145 | 146 |
self._WriteConfigFile(instance, block_devices, extra_args) |
146 | 147 |
result = utils.RunCmd(["xm", "create", instance.name]) |
147 | 148 |
|
... | ... | |
151 | 152 |
result.output)) |
152 | 153 |
|
153 | 154 |
def StopInstance(self, instance, force=False): |
154 |
"""Stop an instance.""" |
|
155 |
"""Stop an instance. |
|
156 |
|
|
157 |
""" |
|
155 | 158 |
self._RemoveConfigFile(instance) |
156 | 159 |
if force: |
157 | 160 |
command = ["xm", "destroy", instance.name] |
... | ... | |
164 | 167 |
(instance.name, result.fail_reason)) |
165 | 168 |
|
166 | 169 |
def RebootInstance(self, instance): |
167 |
"""Reboot an instance.""" |
|
170 |
"""Reboot an instance. |
|
171 |
|
|
172 |
""" |
|
168 | 173 |
result = utils.RunCmd(["xm", "reboot", instance.name]) |
169 | 174 |
|
170 | 175 |
if result.failed: |
... | ... | |
174 | 179 |
def GetNodeInfo(self): |
175 | 180 |
"""Return information about the node. |
176 | 181 |
|
177 |
The return value is a dict, which has to have the following items: |
|
178 |
(all values in MiB) |
|
179 |
- memory_total: the total memory size on the node |
|
180 |
- memory_free: the available memory on the node for instances |
|
181 |
- memory_dom0: the memory used by the node itself, if available |
|
182 |
@return: a dict with the following keys (values in MiB): |
|
183 |
- memory_total: the total memory size on the node |
|
184 |
- memory_free: the available memory on the node for instances |
|
185 |
- memory_dom0: the memory used by the node itself, if available |
|
182 | 186 |
|
183 | 187 |
""" |
184 | 188 |
# note: in xen 3, memory has changed to total_memory |
... | ... | |
233 | 237 |
This method builds the xen config disk directive according to the |
234 | 238 |
given disk_template and block_devices. |
235 | 239 |
|
236 |
Args: |
|
237 |
disk_template: String containing instance disk template |
|
238 |
block_devices: List[tuple1,tuple2,...] |
|
239 |
tuple: (cfdev, rldev) |
|
240 |
cfdev: dict containing ganeti config disk part |
|
241 |
rldev: ganeti.bdev.BlockDev object |
|
240 |
@param disk_template: string containing instance disk template |
|
241 |
@param block_devices: list of tuples (cfdev, rldev): |
|
242 |
- cfdev: dict containing ganeti config disk part |
|
243 |
- rldev: ganeti.bdev.BlockDev object |
|
242 | 244 |
|
243 |
Returns: |
|
244 |
String containing disk directive for xen instance config file |
|
245 |
@return: string containing disk directive for xen instance config file |
|
245 | 246 |
|
246 | 247 |
""" |
247 | 248 |
FILE_DRIVER_MAP = { |
Also available in: Unified diff