Revision 19f31f1f lib/rpc.py
b/lib/rpc.py | ||
---|---|---|
35 | 35 |
import base64 |
36 | 36 |
import pycurl |
37 | 37 |
import threading |
38 |
import copy |
|
38 | 39 |
|
39 | 40 |
from ganeti import utils |
40 | 41 |
from ganeti import objects |
... | ... | |
663 | 664 |
rpc_defs.ED_INST_DICT: self._InstDict, |
664 | 665 |
rpc_defs.ED_INST_DICT_HVP_BEP: self._InstDictHvpBep, |
665 | 666 |
rpc_defs.ED_INST_DICT_OSP_DP: self._InstDictOspDp, |
667 |
rpc_defs.ED_NIC_DICT: self._NicDict, |
|
666 | 668 |
|
667 | 669 |
# Encoders annotating disk parameters |
668 | 670 |
rpc_defs.ED_DISKS_DICT_DP: self._DisksDictDP, |
... | ... | |
688 | 690 |
_generated_rpc.RpcClientDnsOnly.__init__(self) |
689 | 691 |
_generated_rpc.RpcClientDefault.__init__(self) |
690 | 692 |
|
693 |
def _NicDict(self, nic): |
|
694 |
"""Convert the given nic to a dict and encapsulate netinfo |
|
695 |
|
|
696 |
""" |
|
697 |
n = copy.deepcopy(nic) |
|
698 |
if n.network: |
|
699 |
net_uuid = self._cfg.LookupNetwork(n.network) |
|
700 |
if net_uuid: |
|
701 |
nobj = self._cfg.GetNetwork(net_uuid) |
|
702 |
n.netinfo = objects.Network.ToDict(nobj) |
|
703 |
return n.ToDict() |
|
704 |
|
|
691 | 705 |
def _InstDict(self, instance, hvp=None, bep=None, osp=None): |
692 | 706 |
"""Convert the given instance to a dict. |
693 | 707 |
|
... | ... | |
722 | 736 |
nic["nicparams"] = objects.FillDict( |
723 | 737 |
cluster.nicparams[constants.PP_DEFAULT], |
724 | 738 |
nic["nicparams"]) |
739 |
network = nic.get("network", None) |
|
740 |
if network: |
|
741 |
net_uuid = self._cfg.LookupNetwork(network) |
|
742 |
if net_uuid: |
|
743 |
nobj = self._cfg.GetNetwork(net_uuid) |
|
744 |
nic["netinfo"] = objects.Network.ToDict(nobj) |
|
725 | 745 |
return idict |
726 | 746 |
|
727 | 747 |
def _InstDictHvpBep(self, (instance, hvp, bep)): |
Also available in: Unified diff