def __init__(self): self.cache = zvmutils.CacheData() self.cache_expiration = timeutils.utcnow_ts() self.instances = {} self.zhcp_info = { "nodename": CONF.zvm.xcat_zhcp_nodename, "hostname": zvmutils.get_node_hostname(CONF.zvm.xcat_zhcp_nodename), "userid": zvmutils.get_userid(CONF.zvm.xcat_zhcp_nodename), }
def __init__(self): self.cache = zvmutils.CacheData() self.cache_expiration = timeutils.utcnow_ts() self.instances = {} self.zhcp_info = { 'nodename': CONF.zvm.xcat_zhcp_nodename, 'hostname': zvmutils.get_node_hostname(CONF.zvm.xcat_zhcp_nodename), 'userid': zvmutils.get_userid(CONF.zvm.xcat_zhcp_nodename) }
def _get_inst_stat(self, meter, instance): inst_name = zvmutils.get_inst_name(instance) # zvm inspector can not get instance info in shutdown stat if zvmutils.get_inst_power_state(instance) == 0x04: msg = _("Can not get vm info in shutdown state " "for %s") % inst_name raise virt_inspector.InstanceShutOffException(msg) self._check_expiration_and_update_cache(meter) inst_stat = self.cache.get(meter, inst_name) if inst_stat is None: userid = self.instances.get(inst_name) or zvmutils.get_userid(inst_name) self._update_cache(meter, {inst_name: userid}) inst_stat = self.cache.get(meter, inst_name) if inst_stat is None: msg = _("Can not get vm info for %s") % inst_name raise virt_inspector.InstanceNotFoundException(msg) else: return inst_stat
def _get_inst_stat(self, meter, instance): inst_name = zvmutils.get_inst_name(instance) # zvm inspector can not get instance info in shutdown stat if zvmutils.get_inst_power_state(instance) == 0x04: msg = _("Can not get vm info in shutdown state " "for %s") % inst_name raise virt_inspector.InstanceShutOffException(msg) self._check_expiration_and_update_cache(meter) inst_stat = self.cache.get(meter, inst_name) if inst_stat is None: userid = (self.instances.get(inst_name) or zvmutils.get_userid(inst_name)) self._update_cache(meter, {inst_name: userid}) inst_stat = self.cache.get(meter, inst_name) if inst_stat is None: msg = _("Can not get vm info for %s") % inst_name raise virt_inspector.InstanceNotFoundException(msg) else: return inst_stat
def test_get_userid(self, xcat_req): xcat_req.return_value = {'info': [['userid=fakeuser']]} self.assertEqual('fakeuser', zvmutils.get_userid('fakenode'))