Skip to content

Commit

Permalink
Merge pull request #87 from /issues/86-ipmi-lan
Browse files Browse the repository at this point in the history
IPMI sim Supports Lan Get Commands
  • Loading branch information
belavina authored Jul 9, 2019
2 parents b0afc63 + c1ba5a4 commit e9629a4
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
7 changes: 7 additions & 0 deletions enginecore/enginecore/cli/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,13 @@ def create_command(create_asset_group):
create_server_bmc_action.add_argument(
"--port", type=int, default=9001, help="IPMI interface port"
)

create_server_bmc_action.add_argument(
"--interface",
type=str,
default="",
help="Network interface attached to the server",
)
create_server_bmc_action.add_argument(
"--vmport",
type=int,
Expand Down
1 change: 1 addition & 0 deletions enginecore/enginecore/model/system_modeler.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ class ServerVariations(Enum):
"user": "ipmiusr",
"password": "test",
"host": "localhost",
"interface": "",
"port": 9001,
"vmport": 9002,
"storcli_port": 50000,
Expand Down
4 changes: 4 additions & 0 deletions enginecore/enginecore/state/agent/ipmi_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class IPMIAgent(Agent):
"port",
"user",
"password",
"interface",
"vmport",
"num_components",
]
Expand Down Expand Up @@ -74,6 +75,9 @@ def _init_sensor_defs(self):
lan_conf_opt = {
"asset_key": self._sensor_repo.server_key,
"extend_lib": self.extend_plugin_path,
"lan_path": os.path.join(
os.environ["SIMENGINE_IPMI_TEMPL"], "ipmi_sim_lancontrol"
),
**self._ipmi_config,
}

Expand Down
14 changes: 7 additions & 7 deletions enginecore/ipmi_template/ipmi_sim_lancontrol
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ do_get() {
while [ "x$1" != "x" ]; do
case $1 in
ip_addr)
val=`ifconfig $device | grep '^ *inet addr:' | tr ':' ' ' | sed 's/.*inet addr \([0-9.]*\).*$/\1/'`
val=`ifconfig $device | grep 'inet' | awk '{print $2}'`
if [ "x$val" = "x" ]; then
val="0.0.0.0"
fi
Expand All @@ -69,29 +69,29 @@ do_get() {
xdhcp)
;;
*)
val="unknown"
val="static"
;;
esac
;;

mac_addr)
val=`ifconfig $device | grep 'HWaddr' | sed 's/.*HWaddr \([0-9a-f:]*\).*$/\1/'`
val=`ifconfig $device | grep -o -E '([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}'`
if [ "x$val" = "x" ]; then
val="00:00:00:00:00:00"
fi
;;

subnet_mask)
val=`ifconfig $device | grep '^ *inet addr:' | tr ':' ' ' | sed 's/.*Mask \([0-9.]*\).*$/\1/'`
val=`/sbin/ifconfig $device | awk '/netmask /{ print $4;} '`
if [ "x$val" = "x" ]; then
val="0.0.0.0"
val="255.255.0.0"
fi
;;

default_gw_ip_addr)
val=`route -n | grep '^0\.0\.0\.0' | grep 'eth1$' | tr ' ' '\t' | tr -s '\t' '\t' | cut -f 2`
val=`route -n | grep '^0\.0\.0\.0' | grep "$device" | tr ' ' '\t' | tr -s '\t' '\t' | cut -f 2`
if [ "x$val" = "x" ]; then
val="0.0.0.0"
val="10.20.255.254"
fi
;;

Expand Down
2 changes: 1 addition & 1 deletion enginecore/ipmi_template/lan.conf
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ set_working_mc 0x20

# A program to get and set the LAN configuration of the interface.
#lan_config_program "/usr/local/bin/ipmi_sim_lancontrol eth0"
lan_config_program "/usr/local/bin/ipmi_sim_lancontrol bcn1_bridge1"
lan_config_program "$lan_path $interface"
endlan

#chassis_control "./ipmi_sim_chassiscontrol 0x20"
Expand Down

0 comments on commit e9629a4

Please sign in to comment.