Revision ebeb600f lib/rapi/rlib2.py
b/lib/rapi/rlib2.py | ||
---|---|---|
578 | 578 |
default=None), |
579 | 579 |
file_driver=baserlib.CheckParameter(data, "file_driver", |
580 | 580 |
default=constants.FD_LOOP), |
581 |
source_handshake=baserlib.CheckParameter(data, "source_handshake", |
|
582 |
default=None), |
|
583 |
source_x509_ca=baserlib.CheckParameter(data, "source_x509_ca", |
|
584 |
default=None), |
|
585 |
source_instance_name=baserlib.CheckParameter(data, "source_instance_name", |
|
586 |
default=None), |
|
581 | 587 |
iallocator=baserlib.CheckParameter(data, "iallocator", default=None), |
582 | 588 |
hypervisor=baserlib.CheckParameter(data, "hypervisor", default=None), |
583 | 589 |
hvparams=hvparams, |
... | ... | |
891 | 897 |
return baserlib.SubmitJob([op]) |
892 | 898 |
|
893 | 899 |
|
900 |
class R_2_instances_name_prepare_export(baserlib.R_Generic): |
|
901 |
"""/2/instances/[instance_name]/prepare-export resource. |
|
902 |
|
|
903 |
""" |
|
904 |
def PUT(self): |
|
905 |
"""Prepares an export for an instance. |
|
906 |
|
|
907 |
@return: a job id |
|
908 |
|
|
909 |
""" |
|
910 |
instance_name = self.items[0] |
|
911 |
mode = self._checkStringVariable("mode") |
|
912 |
|
|
913 |
op = opcodes.OpPrepareExport(instance_name=instance_name, |
|
914 |
mode=mode) |
|
915 |
|
|
916 |
return baserlib.SubmitJob([op]) |
|
917 |
|
|
918 |
|
|
919 |
def _ParseExportInstanceRequest(name, data): |
|
920 |
"""Parses a request for an instance export. |
|
921 |
|
|
922 |
@rtype: L{opcodes.OpExportInstance} |
|
923 |
@return: Instance export opcode |
|
924 |
|
|
925 |
""" |
|
926 |
mode = baserlib.CheckParameter(data, "mode", |
|
927 |
default=constants.EXPORT_MODE_LOCAL) |
|
928 |
target_node = baserlib.CheckParameter(data, "destination") |
|
929 |
shutdown = baserlib.CheckParameter(data, "shutdown", exptype=bool) |
|
930 |
remove_instance = baserlib.CheckParameter(data, "remove_instance", |
|
931 |
exptype=bool, default=False) |
|
932 |
x509_key_name = baserlib.CheckParameter(data, "x509_key_name", default=None) |
|
933 |
destination_x509_ca = baserlib.CheckParameter(data, "destination_x509_ca", |
|
934 |
default=None) |
|
935 |
|
|
936 |
return opcodes.OpExportInstance(instance_name=name, |
|
937 |
mode=mode, |
|
938 |
target_node=target_node, |
|
939 |
shutdown=shutdown, |
|
940 |
remove_instance=remove_instance, |
|
941 |
x509_key_name=x509_key_name, |
|
942 |
destination_x509_ca=destination_x509_ca) |
|
943 |
|
|
944 |
|
|
945 |
class R_2_instances_name_export(baserlib.R_Generic): |
|
946 |
"""/2/instances/[instance_name]/export resource. |
|
947 |
|
|
948 |
""" |
|
949 |
def PUT(self): |
|
950 |
"""Exports an instance. |
|
951 |
|
|
952 |
@return: a job id |
|
953 |
|
|
954 |
""" |
|
955 |
if not isinstance(self.request_body, dict): |
|
956 |
raise http.HttpBadRequest("Invalid body contents, not a dictionary") |
|
957 |
|
|
958 |
op = _ParseExportInstanceRequest(self.items[0], self.request_body) |
|
959 |
|
|
960 |
return baserlib.SubmitJob([op]) |
|
961 |
|
|
962 |
|
|
894 | 963 |
class _R_Tags(baserlib.R_Generic): |
895 | 964 |
""" Quasiclass for tagging resources |
896 | 965 |
|
Also available in: Unified diff