func imageStateTestCmd(cmd *cobra.Command, args []string) { if len(args) < 1 { nmUsage(cmd, nil) } hexBytes, _ := hex.DecodeString(args[0]) req, err := protocol.NewImageStateWriteReq() if err != nil { nmUsage(nil, err) } req.Hash = hexBytes req.Confirm = false nmr, err := req.Encode() if err != nil { nmUsage(nil, err) } runner, err := getTargetCmdRunner() if err != nil { nmUsage(nil, err) } defer runner.Conn.Close() if err := runner.WriteReq(nmr); err != nil { nmUsage(nil, err) } rawRsp, err := runner.ReadResp() if err != nil { nmUsage(nil, err) } rsp, err := protocol.DecodeImageStateResponse(rawRsp.Data) if err != nil { nmUsage(nil, err) } if err := imageStatePrintRsp(rsp); err != nil { nmUsage(nil, err) } }
func imageStateListCmd(cmd *cobra.Command, args []string) { runner, err := getTargetCmdRunner() if err != nil { nmUsage(nil, err) } defer runner.Conn.Close() var nmr *protocol.NmgrReq req, err := protocol.NewImageStateReadReq() if err != nil { nmUsage(nil, err) } nmr, err = req.Encode() if err != nil { nmUsage(nil, err) } if err := runner.WriteReq(nmr); err != nil { nmUsage(nil, err) } rawRsp, err := runner.ReadResp() if err != nil { nmUsage(nil, err) } rsp, err := protocol.DecodeImageStateResponse(rawRsp.Data) if err != nil { nmUsage(nil, err) } if err := imageStatePrintRsp(rsp); err != nil { nmUsage(nil, err) } }