86 |
86 |
return ganeti.cli.SubmitOpCode(op)
|
87 |
87 |
|
88 |
88 |
|
89 |
|
class R_2_tags(baserlib.R_Generic):
|
90 |
|
"""/2/tags resource.
|
91 |
|
|
92 |
|
Manages cluster tags.
|
93 |
|
|
94 |
|
"""
|
95 |
|
DOC_URI = "/2/tags"
|
96 |
|
|
97 |
|
def GET(self):
|
98 |
|
"""Returns a list of all cluster tags.
|
99 |
|
|
100 |
|
Example: ["tag1", "tag2", "tag3"]
|
101 |
|
|
102 |
|
"""
|
103 |
|
return baserlib._Tags_GET(constants.TAG_CLUSTER)
|
104 |
|
|
105 |
|
|
106 |
89 |
class R_2_os(baserlib.R_Generic):
|
107 |
90 |
"""/2/os resource.
|
108 |
91 |
|
... | ... | |
455 |
438 |
return job_id
|
456 |
439 |
|
457 |
440 |
|
458 |
|
class R_2_instances_name_tags(baserlib.R_Generic):
|
459 |
|
"""/2/instances/[instance_name]/tags resource.
|
|
441 |
class _R_Tags(baserlib.R_Generic):
|
|
442 |
""" Quasiclass for tagging resources
|
460 |
443 |
|
461 |
|
Manages per-instance tags.
|
|
444 |
Manages tags. Inheriting this class you suppose to define DOC_URI and
|
|
445 |
TAG_LEVEL for it.
|
462 |
446 |
|
463 |
447 |
"""
|
464 |
|
DOC_URI = "/2/instances/[instance_name]/tags"
|
|
448 |
|
|
449 |
def __init__(self, items, queryargs, req):
|
|
450 |
"""A tag resource constructor.
|
|
451 |
|
|
452 |
We have to override the default to sort out cluster naming case.
|
|
453 |
|
|
454 |
"""
|
|
455 |
baserlib.R_Generic.__init__(self, items, queryargs, req)
|
|
456 |
|
|
457 |
if self.TAG_LEVEL != constants.TAG_CLUSTER:
|
|
458 |
self.name = items[0]
|
|
459 |
else:
|
|
460 |
self.name = ""
|
465 |
461 |
|
466 |
462 |
def GET(self):
|
467 |
|
"""Returns a list of instance tags.
|
|
463 |
"""Returns a list of tags.
|
468 |
464 |
|
469 |
465 |
Example: ["tag1", "tag2", "tag3"]
|
470 |
466 |
|
471 |
467 |
"""
|
472 |
|
return baserlib._Tags_GET(constants.TAG_INSTANCE, name=self.items[0])
|
|
468 |
return baserlib._Tags_GET(self.TAG_LEVEL, name=self.name)
|
473 |
469 |
|
474 |
470 |
def PUT(self):
|
475 |
|
"""Add a set of tags to the instance.
|
|
471 |
"""Add a set of tags.
|
476 |
472 |
|
477 |
473 |
The request as a list of strings should be PUT to this URI. And
|
478 |
474 |
you'll have back a job id.
|
479 |
475 |
|
480 |
476 |
"""
|
481 |
|
return baserlib._Tags_PUT(constants.TAG_INSTANCE,
|
482 |
|
self.req.request_post_data, name=self.items[0])
|
|
477 |
return baserlib._Tags_PUT(self.TAG_LEVEL,
|
|
478 |
self.req.request_post_data, name=self.name)
|
483 |
479 |
|
484 |
480 |
def DELETE(self):
|
485 |
481 |
"""Delete a tag.
|
486 |
482 |
|
487 |
|
In order to delete a set of tags from a instance, the DELETE
|
|
483 |
In order to delete a set of tags, the DELETE
|
488 |
484 |
request should be addressed to URI like:
|
489 |
|
/2/instances/[instance_name]/tags?tag=[tag]&tag=[tag]
|
|
485 |
/tags?tag=[tag]&tag=[tag]
|
490 |
486 |
|
491 |
487 |
"""
|
492 |
488 |
if 'tag' not in self.queryargs:
|
493 |
|
# no we not gonna delete all tags from an instance
|
|
489 |
# no we not gonna delete all tags
|
494 |
490 |
raise http.HttpNotImplemented()
|
495 |
|
return baserlib._Tags_DELETE(constants.TAG_INSTANCE,
|
|
491 |
return baserlib._Tags_DELETE(self.TAG_LEVEL,
|
496 |
492 |
self.queryargs['tag'],
|
497 |
|
name=self.items[0])
|
|
493 |
name=self.name)
|
|
494 |
|
|
495 |
|
|
496 |
class R_2_instances_name_tags(_R_Tags):
|
|
497 |
""" /2/instances/[instance_name]/tags resource.
|
|
498 |
|
|
499 |
Manages per-instance tags.
|
|
500 |
|
|
501 |
"""
|
|
502 |
DOC_URI = "/2/instances/[instance_name]/tags"
|
|
503 |
TAG_LEVEL = constants.TAG_INSTANCE
|
|
504 |
|
|
505 |
|
|
506 |
class R_2_nodes_name_tags(_R_Tags):
|
|
507 |
""" /2/nodes/[node_name]/tags resource.
|
|
508 |
|
|
509 |
Manages per-node tags.
|
|
510 |
|
|
511 |
"""
|
|
512 |
DOC_URI = "/2/nodes/[node_name]/tags"
|
|
513 |
TAG_LEVEL = constants.TAG_NODE
|
|
514 |
|
|
515 |
|
|
516 |
class R_2_tags(_R_Tags):
|
|
517 |
""" /2/instances/tags resource.
|
|
518 |
|
|
519 |
Manages cluster tags.
|
|
520 |
|
|
521 |
"""
|
|
522 |
DOC_URI = "/2/tags"
|
|
523 |
TAG_LEVEL = constants.TAG_CLUSTER
|