Revision cd42d0ad
b/lib/backend.py | ||
---|---|---|
980 | 980 |
@param instance: the instance definition |
981 | 981 |
|
982 | 982 |
""" |
983 |
return (True, '') |
|
983 |
hyper = hypervisor.GetHypervisor(instance.hypervisor) |
|
984 |
try: |
|
985 |
info = hyper.MigrationInfo(instance) |
|
986 |
except errors.HypervisorError, err: |
|
987 |
msg = "Failed to fetch migration information" |
|
988 |
logging.exception(msg) |
|
989 |
return (False, '%s: %s' % (msg, err)) |
|
990 |
return (True, info) |
|
984 | 991 |
|
985 | 992 |
|
986 | 993 |
def AcceptInstance(instance, info, target): |
... | ... | |
994 | 1001 |
@param target: target host (usually ip), on this node |
995 | 1002 |
|
996 | 1003 |
""" |
1004 |
hyper = hypervisor.GetHypervisor(instance.hypervisor) |
|
1005 |
try: |
|
1006 |
hyper.AcceptInstance(instance, info, target) |
|
1007 |
except errors.HypervisorError, err: |
|
1008 |
msg = "Failed to accept instance" |
|
1009 |
logging.exception(msg) |
|
1010 |
return (False, '%s: %s' % (msg, err)) |
|
997 | 1011 |
return (True, "Accept successfull") |
998 | 1012 |
|
999 | 1013 |
|
... | ... | |
1008 | 1022 |
@param success: whether the migration was a success or a failure |
1009 | 1023 |
|
1010 | 1024 |
""" |
1025 |
hyper = hypervisor.GetHypervisor(instance.hypervisor) |
|
1026 |
try: |
|
1027 |
hyper.FinalizeMigration(instance, info, success) |
|
1028 |
except errors.HypervisorError, err: |
|
1029 |
msg = "Failed to finalize migration" |
|
1030 |
logging.exception(msg) |
|
1031 |
return (False, '%s: %s' % (msg, err)) |
|
1011 | 1032 |
return (True, "Migration Finalized") |
1012 | 1033 |
|
1013 | 1034 |
|
b/lib/hypervisor/hv_base.py | ||
---|---|---|
57 | 57 |
def GetInstanceInfo(self, instance_name): |
58 | 58 |
"""Get instance properties. |
59 | 59 |
|
60 |
@type instance_name: string |
|
60 | 61 |
@param instance_name: the instance name |
61 | 62 |
|
62 | 63 |
@return: tuple (name, id, memory, vcpus, state, times) |
... | ... | |
96 | 97 |
""" |
97 | 98 |
raise NotImplementedError |
98 | 99 |
|
100 |
def MigrationInfo(self, instance): |
|
101 |
"""Get instance information to perform a migration. |
|
102 |
|
|
103 |
By default assume no information is needed. |
|
104 |
|
|
105 |
@type instance: L{objects.Instance} |
|
106 |
@param instance: instance to be migrated |
|
107 |
@rtype: string/data (opaque) |
|
108 |
@return: instance migration information - serialized form |
|
109 |
|
|
110 |
""" |
|
111 |
return '' |
|
112 |
|
|
113 |
def AcceptInstance(self, instance, info, target): |
|
114 |
"""Prepare to accept an instance. |
|
115 |
|
|
116 |
By default assume no preparation is needed. |
|
117 |
|
|
118 |
@type instance: L{objects.Instance} |
|
119 |
@param instance: instance to be accepted |
|
120 |
@type info: string/data (opaque) |
|
121 |
@param info: migration information, from the source node |
|
122 |
@type target: string |
|
123 |
@param target: target host (usually ip), on this node |
|
124 |
|
|
125 |
""" |
|
126 |
pass |
|
127 |
|
|
128 |
def FinalizeMigration(self, instance, info, success): |
|
129 |
"""Finalized an instance migration. |
|
130 |
|
|
131 |
Should finalize or revert any preparation done to accept the instance. |
|
132 |
Since by default we do no preparation, we also don't have anything to do |
|
133 |
|
|
134 |
@type instance: L{objects.Instance} |
|
135 |
@param instance: instance whose migration is being aborted |
|
136 |
@type info: string/data (opaque) |
|
137 |
@param info: migration information, from the source node |
|
138 |
@type success: boolean |
|
139 |
@param success: whether the migration was a success or a failure |
|
140 |
|
|
141 |
""" |
|
142 |
pass |
|
143 |
|
|
99 | 144 |
def MigrateInstance(self, name, target, live): |
100 | 145 |
"""Migrate an instance. |
101 | 146 |
|
102 |
Arguments:
|
|
103 |
- name: the name of the instance
|
|
104 |
- target: the target of the migration (usually will be IP and not name)
|
|
105 |
- live: whether to do live migration or not
|
|
106 |
|
|
107 |
Returns: none, errors will be signaled by exception.
|
|
147 |
@type name: string
|
|
148 |
@param name: name of the instance to be migrated
|
|
149 |
@type target: string
|
|
150 |
@param target: hostname (usually ip) of the target node
|
|
151 |
@type live: boolean |
|
152 |
@param live: whether to do a live or non-live migration
|
|
108 | 153 |
|
109 | 154 |
""" |
110 | 155 |
raise NotImplementedError |
111 | 156 |
|
112 |
|
|
113 | 157 |
@classmethod |
114 | 158 |
def CheckParameterSyntax(cls, hvparams): |
115 | 159 |
"""Check the given parameters for validity. |
Also available in: Unified diff