Revision 363acb1e
b/lib/opcodes.py | ||
---|---|---|
142 | 142 |
raise ValueError("Invalid data to LoadOpcode, missing OP_ID") |
143 | 143 |
op_id = data["OP_ID"] |
144 | 144 |
op_class = None |
145 |
for item in globals().values(): |
|
146 |
if (isinstance(item, type) and |
|
147 |
issubclass(item, cls) and |
|
148 |
hasattr(item, "OP_ID") and |
|
149 |
getattr(item, "OP_ID") == op_id): |
|
150 |
op_class = item |
|
151 |
break |
|
152 |
if op_class is None: |
|
145 |
if op_id in OP_MAPPING: |
|
146 |
op_class = OP_MAPPING[op_id] |
|
147 |
else: |
|
153 | 148 |
raise ValueError("Invalid data to LoadOpCode: OP_ID %s unsupported" % |
154 | 149 |
op_id) |
155 | 150 |
op = op_class() |
... | ... | |
578 | 573 |
"mem_size", "disks", "disk_template", |
579 | 574 |
"os", "tags", "nics", "vcpus", "hypervisor", |
580 | 575 |
] |
576 |
|
|
577 |
OP_MAPPING = dict([(v.OP_ID, v) for v in globals().values() |
|
578 |
if (isinstance(v, type) and issubclass(v, OpCode) and |
|
579 |
hasattr(v, "OP_ID"))]) |
Also available in: Unified diff