Revision 9ac99fda
b/lib/cmdlib.py | ||
---|---|---|
4436 | 4436 |
def CheckPrereq(self): |
4437 | 4437 |
"""Check prerequisites. |
4438 | 4438 |
|
4439 |
This checks that the instance name is a valid one.
|
|
4439 |
This checks that the instance and node names are valid.
|
|
4440 | 4440 |
|
4441 | 4441 |
""" |
4442 | 4442 |
instance_name = self.cfg.ExpandInstanceName(self.op.instance_name) |
... | ... | |
4523 | 4523 |
" on node %s" % (instance.name, node)) |
4524 | 4524 |
|
4525 | 4525 |
|
4526 |
class LURemoveExport(NoHooksLU): |
|
4527 |
"""Remove exports related to the named instance. |
|
4528 |
|
|
4529 |
""" |
|
4530 |
_OP_REQP = ["instance_name"] |
|
4531 |
|
|
4532 |
def CheckPrereq(self): |
|
4533 |
"""Check prerequisites. |
|
4534 |
""" |
|
4535 |
pass |
|
4536 |
|
|
4537 |
def Exec(self, feedback_fn): |
|
4538 |
"""Remove any export. |
|
4539 |
|
|
4540 |
""" |
|
4541 |
instance_name = self.cfg.ExpandInstanceName(self.op.instance_name) |
|
4542 |
# If the instance was not found we'll try with the name that was passed in. |
|
4543 |
# This will only work if it was an FQDN, though. |
|
4544 |
fqdn_warn = False |
|
4545 |
if not instance_name: |
|
4546 |
fqdn_warn = True |
|
4547 |
instance_name = self.op.instance_name |
|
4548 |
|
|
4549 |
op = opcodes.OpQueryExports(nodes=[]) |
|
4550 |
exportlist = self.proc.ChainOpCode(op) |
|
4551 |
found = False |
|
4552 |
for node in exportlist: |
|
4553 |
if instance_name in exportlist[node]: |
|
4554 |
found = True |
|
4555 |
if not rpc.call_export_remove(node, instance_name): |
|
4556 |
logger.Error("could not remove export for instance %s" |
|
4557 |
" on node %s" % (instance_name, node)) |
|
4558 |
|
|
4559 |
if fqdn_warn and not found: |
|
4560 |
feedback_fn("Export not found. If trying to remove an export belonging" |
|
4561 |
" to a deleted instance please use its Fully Qualified" |
|
4562 |
" Domain Name.") |
|
4563 |
|
|
4564 |
|
|
4526 | 4565 |
class TagsLU(NoHooksLU): |
4527 | 4566 |
"""Generic tags LU. |
4528 | 4567 |
|
b/lib/mcpu.py | ||
---|---|---|
80 | 80 |
# exports lu |
81 | 81 |
opcodes.OpQueryExports: cmdlib.LUQueryExports, |
82 | 82 |
opcodes.OpExportInstance: cmdlib.LUExportInstance, |
83 |
opcodes.OpRemoveExport: cmdlib.LURemoveExport, |
|
83 | 84 |
# tags lu |
84 | 85 |
opcodes.OpGetTags: cmdlib.LUGetTags, |
85 | 86 |
opcodes.OpSearchTags: cmdlib.LUSearchTags, |
b/lib/opcodes.py | ||
---|---|---|
395 | 395 |
OP_ID = "OP_BACKUP_EXPORT" |
396 | 396 |
__slots__ = ["instance_name", "target_node", "shutdown"] |
397 | 397 |
|
398 |
class OpRemoveExport(OpCode): |
|
399 |
"""Remove an instance's export.""" |
|
400 |
OP_ID = "OP_BACKUP_REMOVE" |
|
401 |
__slots__ = ["instance_name"] |
|
398 | 402 |
|
399 | 403 |
# Tags opcodes |
400 | 404 |
class OpGetTags(OpCode): |
b/scripts/gnt-backup | ||
---|---|---|
105 | 105 |
return 0 |
106 | 106 |
|
107 | 107 |
|
108 |
def RemoveExport(opts, args): |
|
109 |
"""Remove an export from the cluster. |
|
110 |
|
|
111 |
Args: |
|
112 |
opts - class with options as members |
|
113 |
args - list with a single element, the exported instance to remove |
|
114 |
Opts used: |
|
115 |
|
|
116 |
Returns: |
|
117 |
1 in case of error, 0 otherwise |
|
118 |
|
|
119 |
""" |
|
120 |
instance = args[0] |
|
121 |
op = opcodes.OpRemoveExport(instance_name=args[0]) |
|
122 |
|
|
123 |
SubmitOpCode(op) |
|
124 |
return 0 |
|
125 |
|
|
126 |
|
|
108 | 127 |
# this is defined separately due to readability only |
109 | 128 |
import_opts = [ |
110 | 129 |
DEBUG_OPT, |
... | ... | |
162 | 181 |
"Exports an instance to an image"), |
163 | 182 |
'import': (ImportInstance, ARGS_ONE, import_opts, "[opts...] <name>", |
164 | 183 |
"Imports an instance from an exported image"), |
184 |
'remove': (RemoveExport, ARGS_ONE, |
|
185 |
[DEBUG_OPT], |
|
186 |
"<name>", |
|
187 |
"Remove exports of named instance from the filesystem."), |
|
165 | 188 |
} |
166 | 189 |
|
167 | 190 |
if __name__ == '__main__': |
Also available in: Unified diff