Skip to content

Commit

Permalink
Merge pull request #143 from turtle-fly/bugfix/sync_ipmi_console_inte…
Browse files Browse the repository at this point in the history
…rface

bugfix/sync_ipmi_console_interface
  • Loading branch information
turtle-fly authored Nov 16, 2016
2 parents d9eaa48 + 27bb38c commit 23ccc6b
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 53 deletions.
1 change: 1 addition & 0 deletions etc/infrasim.full.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ bmc:
historyfru: 20
config_file: <path/to/your config file>
emu_file: chassis/node1/quanta_d51.emu
ipmi_over_lan_port: 623

# SSH to this port to visit ipmi-console
ipmi_console_ssh: 9300
Expand Down
2 changes: 1 addition & 1 deletion infrasim/ipmicons/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def init_env(instance):
if ip == "::" or ip == "0.0.0.0":
env.VBMC_IP = "localhost"
else:
env.VBMC_IP = "ip"
env.VBMC_IP = ip
logger.info("VBMC_IP: {}".format(env.VBMC_IP))
env.VBMC_PORT = int(s_vbmc.group("vbmc_port"))
logger.info("VBMC_PORT: {}".format(env.VBMC_PORT))
Expand Down
164 changes: 164 additions & 0 deletions test/unit/test_ipmi_console.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
#!/usr/bin/env python
'''
*********************************************************
Copyright @ 2015 EMC Corporation All Rights Reserved
*********************************************************
'''
# -*- coding: utf-8 -*-

from infrasim.ipmicons import sdr
from infrasim.ipmicons.command import Command_Handler
from infrasim.ipmicons import common
from infrasim.model import CNode
from infrasim import config
from test import fixtures
import unittest
import yaml
import shutil
import time
import os

ch = Command_Handler()


class test_ipmi_console(unittest.TestCase):
@classmethod
def setUpClass(cls):
pass

@classmethod
def tearDownClass(cls):
pass

def test_sensor_value_get_discrete(self):
sensor_d = sdr.build_sensors(name="discrete_sample",
ID=0x10,
mc=32,
value="0xca10",
tp=0x00)
sensor_d.set_event_type(0x6f)

ch.get_sensor_value(["0x10"])
assert "0xca10" in common.msg_queue.get()

def test_sensor_value_get_analog(self):
sensor_a = sdr.build_sensors(name="analog_sample",
ID=0x11,
mc=32,
value=0x63,
tp=0x00)
sensor_a.set_event_type(0x01)
sensor_a.set_m_lb(0x58)
sensor_a.set_m_ub(0x00)
sensor_a.set_b_lb(0x00)
sensor_a.set_b_ub(0x00)
sensor_a.set_exp(0x00)
sensor_a.set_su2(18)

ch.get_sensor_value(["0x11"])
assert "analog_sample : 8712.000 RPM" in common.msg_queue.get()


class test_ipmi_console_default_env(unittest.TestCase):

TMP_CONF_FILE = "/tmp/test.yml"
bmc_conf = ""

@classmethod
def setUpClass(cls):
node_info = {}
fake_config = fixtures.FakeConfig()
node_info = fake_config.get_node_info()
cls.bmc_conf = os.path.join(os.environ["HOME"], ".infrasim",
node_info["name"], "data", "vbmc.conf")

with open(cls.TMP_CONF_FILE, "w") as f:
yaml.dump(node_info, f, default_flow_style=False)

node = CNode(node_info)
node.init()
node.precheck()
node.start()

# Wait ipmi_sim start.
time.sleep(2)

@classmethod
def tearDownClass(cls):

with open(cls.TMP_CONF_FILE, "r") as yml_file:
node_info = yaml.load(yml_file)

node = CNode(node_info)
node.init()
node.precheck()
node.stop()

if os.path.exists(cls.TMP_CONF_FILE):
os.unlink(cls.TMP_CONF_FILE)

workspace = os.path.join(config.infrasim_home, "test")
if os.path.exists(workspace):
shutil.rmtree(workspace)

def test_ipmi_console_env(self):
common.init_env("test")
assert common.env.PORT_SSH_FOR_CLIENT == 9300
assert common.env.PORT_TELNET_TO_VBMC == 9000
assert common.env.VBMC_IP == "localhost"
assert common.env.VBMC_PORT == 623


class test_ipmi_console_customized_env(unittest.TestCase):

TMP_CONF_FILE = "/tmp/test.yml"
bmc_conf = ""

@classmethod
def setUpClass(cls):
node_info = {}
fake_config = fixtures.FakeConfig()
node_info = fake_config.get_node_info()
node_info["bmc"] = {}
node_info["bmc"]["interface"] = "lo"
node_info["bmc"]["ipmi_over_lan_port"] = 625
node_info["ipmi_console_ssh"] = 9401
node_info["ipmi_console_port"] = 9101
cls.bmc_conf = os.path.join(os.environ["HOME"], ".infrasim",
node_info["name"], "data", "vbmc.conf")

with open(cls.TMP_CONF_FILE, "w") as f:
yaml.dump(node_info, f, default_flow_style=False)

node = CNode(node_info)
node.init()
node.precheck()
node.start()

# Wait ipmi_sim start.
time.sleep(2)

@classmethod
def tearDownClass(cls):

with open(cls.TMP_CONF_FILE, "r") as yml_file:
node_info = yaml.load(yml_file)

node = CNode(node_info)
node.init()
node.precheck()
node.stop()

if os.path.exists(cls.TMP_CONF_FILE):
os.unlink(cls.TMP_CONF_FILE)

workspace = os.path.join(config.infrasim_home, "test")
if os.path.exists(workspace):
shutil.rmtree(workspace)

def test_ipmi_console_env(self):
common.init_env("test")
assert common.env.PORT_SSH_FOR_CLIENT == 9401
assert common.env.PORT_TELNET_TO_VBMC == 9101
assert common.env.VBMC_IP == "127.0.0.1"
assert common.env.VBMC_PORT == 625
52 changes: 0 additions & 52 deletions test/unit/test_ipmi_console_command.py

This file was deleted.

0 comments on commit 23ccc6b

Please sign in to comment.