2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2024-11-21 09:02:00 +00:00
3 openbmc_support
xuweibj edited this page 2018-05-30 09:55:04 +08:00
This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Mini-design for OpenBMC support

Background

To support OpenBMC management. Interface is openbmc.

Node definition

mgt=openbmc

OpenBMC table

When send request bmc ip, username, password are needed. Create a new table openbmc, “#node,bmc,username,password,comments,disable”.

Plugin file

/opt/xcat/lib/perl/xCAT_plugin/openbmc.pm /opt/xcat/lib/perl/xCAT/OPENBMC.pm

The implementation details(take rpower on as example)

Hash variable

%node_info = (
    $node => {
        bmc        => "x.x.x.x",
        username   => "username",
        password   => "password",
        cur_url    => “”,   
        method     => “”,      
        back_urls  => (),   
        cur_status => "LOGIN_REQUEST",
    },
);

%status_info = {
    LOGIN_REQUEST => {
        method => "POST",
        init_url   => "/login",
    },
    LOGIN_RESPONSE => {
        process => \&login_response,
    },
    RPOWER_ON_REQUEST => {
        method => "POST",
        init_url   => "/power/on”,
    },
    RPOWER_ON_RESPONSE => {
        process => \&rpower_response,
    },
};

%next_status = {
    LOGIN_REQUEST => ”LOGIN_RESPONSE",
    LOGIN_RESPONSE => "RPOWER_ON_REQUEST", 
    RPOWER_ON_REQUEST => “RPOWER_ON_RESPONSE”,
};

The main code logic

Parse argument

  • Check errors.
  • Get parameters and fill into %node_info hash, set cur_status as LOGIN_REQUEST
  • Get subcommands fill into %next_status array.

Login

  • OPENBMC xCAT::OPENBMC->new

    • Generate request use HTTP::Request
    • Create cookies use HTTP::Cookies
    • Send request use add_with_opts (HTTP::Async)
    • Return handle ID
  • openbmc

    • Start Async
    • Start while loop
    • Get handle ID and cookies use xCAT::OPENBMC->new
    • Change cur_status to LOGIN_RESPONSE
  • The code logic for main loop:

      generate and send login request of each node
      while (1)
          if (the node array that stores nodes which hadnt been dealt with is empty) and (pending response counter equal 0)   # It means all nodes have been dealt, and no more response is expected, the loop will end 
              break;
     	    endif
    
          while (wait_for_next_response)
              deal_with_response
          end while (wait_for_next_response)
      end while (1)
    

Wait for response

  • Get response in while loop
  • Compare ID to get node name
  • Deal with response. If status is OK, go to next step, cur_status = RPOWER_ON_REQUEST. Or, return with error message.

Send subcommand request

  • Check cur_status
  • Get cur_url and pop first sub_url, generate url to send. If there is no cur_url, use url in %status_info.
  • Send request use xCAT::OPENBMC->send_request
  • Change cur_status to xxxx_RESPONSE
  • Wait for response

Deal with response

  • Check if there is info want to get
  • If get, go next step. If not, check @sub_url whether empty.
  • If empty, return error. If not, set cur_status as xxx_REQUEST. Send request.