Skip to content

Commit e9629a4

Browse files
authored
Merge pull request #87 from /issues/86-ipmi-lan
IPMI sim Supports Lan Get Commands
2 parents b0afc63 + c1ba5a4 commit e9629a4

5 files changed

Lines changed: 20 additions & 8 deletions

File tree

enginecore/enginecore/cli/model.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,13 @@ def create_command(create_asset_group):
407407
create_server_bmc_action.add_argument(
408408
"--port", type=int, default=9001, help="IPMI interface port"
409409
)
410+
411+
create_server_bmc_action.add_argument(
412+
"--interface",
413+
type=str,
414+
default="",
415+
help="Network interface attached to the server",
416+
)
410417
create_server_bmc_action.add_argument(
411418
"--vmport",
412419
type=int,

enginecore/enginecore/model/system_modeler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ class ServerVariations(Enum):
196196
"user": "ipmiusr",
197197
"password": "test",
198198
"host": "localhost",
199+
"interface": "",
199200
"port": 9001,
200201
"vmport": 9002,
201202
"storcli_port": 50000,

enginecore/enginecore/state/agent/ipmi_agent.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class IPMIAgent(Agent):
2525
"port",
2626
"user",
2727
"password",
28+
"interface",
2829
"vmport",
2930
"num_components",
3031
]
@@ -74,6 +75,9 @@ def _init_sensor_defs(self):
7475
lan_conf_opt = {
7576
"asset_key": self._sensor_repo.server_key,
7677
"extend_lib": self.extend_plugin_path,
78+
"lan_path": os.path.join(
79+
os.environ["SIMENGINE_IPMI_TEMPL"], "ipmi_sim_lancontrol"
80+
),
7781
**self._ipmi_config,
7882
}
7983

enginecore/ipmi_template/ipmi_sim_lancontrol

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ do_get() {
5555
while [ "x$1" != "x" ]; do
5656
case $1 in
5757
ip_addr)
58-
val=`ifconfig $device | grep '^ *inet addr:' | tr ':' ' ' | sed 's/.*inet addr \([0-9.]*\).*$/\1/'`
58+
val=`ifconfig $device | grep 'inet' | awk '{print $2}'`
5959
if [ "x$val" = "x" ]; then
6060
val="0.0.0.0"
6161
fi
@@ -69,29 +69,29 @@ do_get() {
6969
xdhcp)
7070
;;
7171
*)
72-
val="unknown"
72+
val="static"
7373
;;
7474
esac
7575
;;
7676

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

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

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

enginecore/ipmi_template/lan.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ set_working_mc 0x20
3939

4040
# A program to get and set the LAN configuration of the interface.
4141
#lan_config_program "/usr/local/bin/ipmi_sim_lancontrol eth0"
42-
lan_config_program "/usr/local/bin/ipmi_sim_lancontrol bcn1_bridge1"
42+
lan_config_program "$lan_path $interface"
4343
endlan
4444

4545
#chassis_control "./ipmi_sim_chassiscontrol 0x20"

0 commit comments

Comments
 (0)