#gpowerd move machine specific configs to the recipe layer
Machine specific configs are required, but the name of the configs, and the information internal could be used to identify aspects of the machine.
#safepower-agent: Add copybara config to the list of tracked files.
This will run the copybara when the copybara file is modified.
Tested: mtest gpowerd_oob
Fustion2: https://fusion2.corp.google.com/9440aee4-f859-4448-b427-de37f0234ae6
PiperOrigin-RevId: 759232327
Change-Id: I9bff4776a704623febf2595aaf9d9507a0fdd8c0
diff --git a/bmc/machine_configs/athena.textproto b/bmc/machine_configs/athena.textproto
deleted file mode 100644
index 69c85cd..0000000
--- a/bmc/machine_configs/athena.textproto
+++ /dev/null
@@ -1,143 +0,0 @@
-# proto-file: safepower_agent_config.proto
-# proto-message: SafePowerAgentConfig
-# LINT.IfChange
-gpowerd_config {
- state_monitor_config [
- {
- state_name: "system_0_PowerState"
- state_gathering_info {
- redfish { uri: "/redfish/v1/Systems/system1" json_key: "PowerState" }
- collection_interval_ms: 1000
- prototype { power_state { state: POWER_STATE_POWERING_ON } }
- }
- system_component { node_entity_tag: " host-compute-node-0" }
- },
- {
- state_name: "system_1_PowerState"
- state_gathering_info {
- redfish { uri: "/redfish/v1/Systems/system2" json_key: "PowerState" }
- collection_interval_ms: 1000
- prototype { power_state { state: POWER_STATE_POWERING_ON } }
- }
- system_component { node_entity_tag: "host-compute-node-1" }
- }
-
- ]
-}
-
-action_configs {
- action_name: "host_0_reboot_force"
- action {
- action_type: ACTION_TYPE_REBOOT
- action_severity: ACTION_SEVERITY_FORCE
- target_component {
- node_entity_tag: "host-compute-node-0"
- }
- }
- redfish {
- uri: "/redfish/v1/Systems/system1/Actions/ComputerSystem.Reset"
- json_body: "{\"ResetType\" : \"ForceRestart\"}"
- ip: "127.0.0.1"
- port: 80
- }
-}
-
-action_configs {
- action_name: "host_1_reboot_force"
- action {
- action_type: ACTION_TYPE_REBOOT
- action_severity: ACTION_SEVERITY_FORCE
- target_component {
- node_entity_tag: "host-compute-node-1"
- }
- }
- redfish {
- uri: "/redfish/v1/Systems/system2/Actions/ComputerSystem.Reset"
- json_body: "{\"ResetType\" : \"ForceRestart\"}"
- ip: "127.0.0.1"
- port: 80
- }
-}
-
-action_configs {
- action_name: "host_0_on_force"
- action {
- action_type: ACTION_TYPE_ON
- action_severity: ACTION_SEVERITY_FORCE
- target_component {
- node_entity_tag: "host-compute-node-0"
- }
- }
- redfish {
- uri: "/redfish/v1/Systems/system1/Actions/ComputerSystem.Reset"
- json_body: "{\"ResetType\" : \"ForceOn\"}"
- ip: "127.0.0.1"
- port: 80
- }
-}
-
-action_configs {
- action_name: "host_1_on_force"
- action {
- action_type: ACTION_TYPE_ON
- action_severity: ACTION_SEVERITY_FORCE
- target_component {
- node_entity_tag: "host-compute-node-1"
- }
- }
- redfish {
- uri: "/redfish/v1/Systems/system2/Actions/ComputerSystem.Reset"
- json_body: "{\"ResetType\" : \"ForceOn\"}"
- ip: "127.0.0.1"
- port: 80
- }
-}
-
-action_configs {
- action_name: "host_0_off_force"
- action {
- action_type: ACTION_TYPE_OFF
- action_severity: ACTION_SEVERITY_FORCE
- target_component {
- node_entity_tag: "host-compute-node-0"
- }
- }
- redfish {
- uri: "/redfish/v1/Systems/system1/Actions/ComputerSystem.Reset"
- json_body: "{\"ResetType\" : \"ForceOff\"}"
- ip: "127.0.0.1"
- port: 80
- }
-}
-
-action_configs {
- action_name: "host_1_off_force"
- action {
- action_type: ACTION_TYPE_OFF
- action_severity: ACTION_SEVERITY_FORCE
- target_component {
- node_entity_tag: "host-compute-node-1"
- }
- }
- redfish {
- uri: "/redfish/v1/Systems/system2/Actions/ComputerSystem.Reset"
- json_body: "{\"ResetType\" : \"ForceOff\"}"
- ip: "127.0.0.1"
- port: 80
- }
-}
-
-action_configs {
- action_name: "tray_power_cycle"
- action {
- action_type: ACTION_TYPE_CYCLE
- action_severity: ACTION_SEVERITY_FORCE
- }
- redfish {
- uri: "/redfish/v1/Chassis/Athena/Actions/Chassis.Reset"
- json_body: "{\"ResetType\" : \"PowerCycle\"}"
- ip: "127.0.0.1"
- port: 80
- }
-}
-# LINT.ThenChange(//depot/bmc/machine_configs/setup_configs_test.cc)
diff --git a/bmc/machine_configs/izumi.textproto b/bmc/machine_configs/izumi.textproto
deleted file mode 100644
index 3748231..0000000
--- a/bmc/machine_configs/izumi.textproto
+++ /dev/null
@@ -1,115 +0,0 @@
-gpowerd_config {
- state_monitor_config [
- {
- state_name: "PowerState"
- state_gathering_info {
- redfish { uri: "/redfish/v1/Systems/system" json_key: "PowerState" }
- collection_interval_ms: 1000
- prototype { power_state { state: POWER_STATE_POWERING_ON } }
- }
- system_component { node_entity_tag: "host-compute-node" }
- }
- ]
-}
-
-action_configs {
- action_name: "host_reboot_force"
- action {
- action_type: ACTION_TYPE_REBOOT
- action_severity: ACTION_SEVERITY_FORCE
- target_component {
- node_entity_tag: "host-compute-node"
- }
- }
- redfish {
- uri: "/redfish/v1/Systems/system/Actions/ComputerSystem.Reset"
- json_body: "{\"ResetType\" : \"ForceRestart\"}"
- ip: "127.0.0.1"
- port: 80
- }
-}
-
-action_configs {
- action_name: "host_reboot_graceful"
- action {
- action_type: ACTION_TYPE_REBOOT
- action_severity: ACTION_SEVERITY_GRACEFUL
- target_component {
- node_entity_tag: "host-compute-node"
- }
- }
- redfish {
- uri: "/redfish/v1/Systems/system/Actions/ComputerSystem.Reset"
- json_body: "{\"ResetType\" : \"GracefulRestart\"}"
- ip: "127.0.0.1"
- port: 80
- }
-}
-
-action_configs {
- action_name: "host_on_force"
- action {
- action_type: ACTION_TYPE_ON
- action_severity: ACTION_SEVERITY_FORCE
- target_component {
- node_entity_tag: "host-compute-node"
- }
- }
- redfish {
- uri: "/redfish/v1/Systems/system/Actions/ComputerSystem.Reset"
- json_body: "{\"ResetType\" : \"ForceOn\"}"
- ip: "127.0.0.1"
- port: 80
- }
-}
-
-action_configs {
- action_name: "host_on_graceful"
- action {
- action_type: ACTION_TYPE_ON
- action_severity: ACTION_SEVERITY_GRACEFUL
- target_component {
- node_entity_tag: "host-compute-node"
- }
- }
- redfish {
- uri: "/redfish/v1/Systems/system/Actions/ComputerSystem.Reset"
- json_body: "{\"ResetType\" : \"On\"}"
- ip: "127.0.0.1"
- port: 80
- }
-}
-
-action_configs {
- action_name: "host_off_force"
- action {
- action_type: ACTION_TYPE_OFF
- action_severity: ACTION_SEVERITY_FORCE
- target_component {
- node_entity_tag: "host-compute-node"
- }
- }
- redfish {
- uri: "/redfish/v1/Systems/system/Actions/ComputerSystem.Reset"
- json_body: "{\"ResetType\" : \"ForceOff\"}"
- ip: "127.0.0.1"
- port: 80
- }
-}
-
-action_configs {
- action_name: "host_off_graceful"
- action {
- action_type: ACTION_TYPE_OFF
- action_severity: ACTION_SEVERITY_GRACEFUL
- target_component {
- node_entity_tag: "host-compute-node"
- }
- }
- redfish {
- uri: "/redfish/v1/Systems/system/Actions/ComputerSystem.Reset"
- json_body: "{\"ResetType\" : \"GracefulShutdown\"}"
- ip: "127.0.0.1"
- port: 80
- }
-}
diff --git a/google3/production/sushid/safepower_agent/copy.bara.sky b/google3/production/sushid/safepower_agent/copy.bara.sky
new file mode 100644
index 0000000..7639aa2
--- /dev/null
+++ b/google3/production/sushid/safepower_agent/copy.bara.sky
@@ -0,0 +1,282 @@
+"""Copybara config to export file from google3 / safepower_agent to gPowerD
+
+Validate the config in terms of syntax:
+copybara validate copy.bara.sky
+
+1. Run the workflow in dry-run mode
+ alias copybara='/google/bin/releases/copybara/public/copybara/copybara'
+ gPowerD: copybara copy.bara.sky gpowerd_presubmit_piper_to_gerrit 12345 --dry-run --ignore-noop
+2. Format patch (get the GIT_DIR from the copybara output)
+ b) gPowerD: GIT_DIR=/usr/local/google/home/$USER/copybara/cache/git_repos/rpc%3A%2F%2Fgbmc%2FgPowerD git format-patch -1 \
+ && cp 0001-DO-NOT-SUBMIT.patch /path/to/gPowerD
+3. Apply the patch and test there.
+
+"""
+
+load("//devtools/copybara/library/scrubbing", "cc_scrub", "message_scrub_google_block", "proto_scrub")
+load("//devtools/copybara/library/workflow", "piper_sot_to_gerrit")
+
+#######################
+# Private definitions
+########################
+_cc_files = ["**.h", "**.cc", "**.in"]
+_proto_files = ["**.proto", "**.textproto"]
+_meson_files = ["**.build", "**meson_options.txt"]
+_copybara_config = [
+ "copy.bara.sky",
+]
+
+_gpowerd_codebase_lib = [
+ # go/keep-sorted start
+ "action_context.cc",
+ "action_context.h",
+ "action_hash.h",
+ "bmc/auth.cc",
+ "bmc/auth.h",
+ "bmc/auth_loas3.h",
+ "bmc/convert_status.h",
+ "bmc/daemon_context_bmc.cc",
+ "bmc/daemon_context_bmc.h",
+ "bmc/daemon_context_bmc_test.cc",
+ "bmc/gmi_reader.cc",
+ "bmc/gmi_reader.h",
+ "bmc/gmi_reader_test.cc",
+ "bmc/gpowerd.cc",
+ "bmc/http_connection.cc",
+ "bmc/http_connection.h",
+ "bmc/http_connection_test.cc",
+ "bmc/machine_configs/embedded_data.h",
+ "bmc/machine_configs/example.textproto",
+ "bmc/machine_configs/meson.build",
+ "bmc/machine_configs/setup_configs.cc",
+ "bmc/machine_configs/setup_configs.h",
+ "bmc/machine_configs/setup_configs_test.cc",
+ "bmc/meson.build",
+ "bmc/mock_server.h",
+ "bmc/persistent_storage_bmc.cc",
+ "bmc/persistent_storage_bmc.h",
+ "bmc/persistent_storage_bmc_test.cc",
+ "bmc/proto_reader.cc",
+ "bmc/proto_reader.h",
+ "bmc/proto_reader_test.cc",
+ "bmc/redfish.cc",
+ "bmc/redfish.h",
+ "bmc/register_actions_bmc.cc",
+ "bmc/register_actions_bmc.h",
+ "bmc/register_actions_bmc_test.cc",
+ "bmc/scheduler_bmc.cc",
+ "bmc/scheduler_bmc.h",
+ "bmc/scheduler_bmc_test.cc",
+ "bmc/state_monitor_bmc.cc",
+ "bmc/state_monitor_bmc.h",
+ "bmc/status_macros.h",
+ "bmc/test_util.h",
+ "condition.cc",
+ "condition.h",
+ "convert_proto.cc",
+ "convert_proto.h",
+ "daemon_context.cc",
+ "daemon_context.h",
+ "disruption_manager.cc",
+ "disruption_manager.h",
+ "gpowerd_build_config.h.in",
+ "meson.build",
+ "meson_options.txt",
+ "parse_text_proto.cc",
+ "parse_text_proto.h",
+ "persistent_storage.h",
+ "proto/meson.build",
+ "proto/safepower_agent.proto",
+ "proto/safepower_agent_config.proto",
+ "proto/state_persistence.proto",
+ "safepower_agent.cc",
+ "safepower_agent.h",
+ "scheduler_interface.h",
+ "state_change_reactor.h",
+ "state_fields.h",
+ "state_merge.cc",
+ "state_merge.h",
+ "state_updater.h",
+ # go/keep-sorted end
+]
+
+_all_gpowerd_google3_files = glob(
+ include =
+ _gpowerd_codebase_lib + _copybara_config,
+)
+
+_all_gob_files = glob(
+ include = ["**"],
+)
+
+allowed_authors = {
+ "jebr": "John Broadbent <jebr@google.com>",
+ "shounak": "Shounak Mitra <shounak@google.com>",
+ "arunsa": "Arun Satyanarayana <arunsa@google.com>",
+ "jainrish": "Rishabh Jain <jainrish@google.com>",
+ "sruthiganti": "Sruthi Ganti <sruthiganti@google.com>",
+}
+
+_transformations = [
+ ###############################
+ # common scrubs
+ ###############################
+ cc_scrub(),
+ proto_scrub(),
+ leakr.check(),
+ ###############################
+ # common headers
+ ###############################
+ core.replace(
+ before = "third_party/absl",
+ after = "absl",
+ paths = glob(_cc_files),
+ ),
+ core.replace(
+ before = "third_party/grpc/google_specific/include/",
+ after = "",
+ paths = glob(_cc_files),
+ ),
+ core.replace(
+ before = "third_party/grpc/include/",
+ after = "",
+ paths = glob(_cc_files),
+ ),
+ core.replace(
+ before = "third_party/protobuf/",
+ after = "google/protobuf/",
+ paths = glob(_cc_files),
+ ),
+ core.replace(
+ before = "third_party/json/include/nlohmann",
+ after = "nlohmann",
+ paths = glob(_cc_files),
+ ),
+ core.replace(
+ before = "",
+ after = "",
+ ),
+ core.replace(
+ before = "${proto_file}.proto.h",
+ after = "${proto_file}.pb.h",
+ regex_groups = {
+ "proto_file": "\\w+",
+ },
+ ),
+ core.replace(
+ before = "google/protobuf/${proto_file}.proto.h",
+ after = "google/protobuf/${proto_file}.pb.h",
+ regex_groups = {
+ "proto_file": "\\w+",
+ },
+ ),
+ core.replace(
+ before = "gmi/machine_identity.pb.h",
+ after = "gmi/machine_identity.pb.h",
+ ),
+ core.replace(
+ before = "",
+ after = "",
+ ),
+ core.replace(
+ before = "",
+ after = "",
+ ),
+ core.replace(
+ before = "",
+ after = "",
+ ),
+ core.replace(
+ before = "bmc/convert_status.h",
+ after = "bmc/convert_status.h",
+ ),
+ core.replace(
+ before = "bmc/status_macros.h",
+ after = "bmc/status_macros.h",
+ ),
+ core.replace(
+ before = "third_party/milotic/internal/cc/authn/generate_self_signed_cert.h",
+ after = "zatar/generate_self_signed_cert.h",
+ paths = glob(_cc_files),
+ ),
+ core.replace(
+ before = "proto2::",
+ after = "google::protobuf::",
+ paths = glob(_cc_files),
+ ),
+ core.replace(
+ before = "testing/base/public/gunit.h",
+ after = "gtest/gtest.h",
+ paths = glob(_cc_files),
+ ),
+ core.replace(
+ before = "testing/base/public/gmock.h",
+ after = "gmock/gmock.h",
+ paths = glob(_cc_files),
+ ),
+ core.replace(
+ before = "absl/types/source_location.h",
+ after = "source_location",
+ paths = glob(_cc_files),
+ ),
+ core.replace(
+ before = "absl::SourceLocation",
+ after = "std::source_location",
+ paths = glob(_cc_files),
+ ),
+ ###############################
+ # move
+ ###############################
+ core.move(
+ before = "",
+ after = "",
+ paths = glob(_cc_files),
+ ),
+ core.move(
+ before = "",
+ after = "",
+ paths = glob(_proto_files),
+ ),
+ core.move(
+ before = "",
+ after = "",
+ paths = glob(_meson_files),
+ ),
+ # , , and are not yet present in the
+ # version of absl gBMC is using. Not all annotations may be present in our code yet, so ignore
+ # noop changes for these replacements.
+ # TODO: b/381875619 - Remove these when absl is bumped to 48f0f91 or newer.
+ core.transform([
+ core.replace(
+ before = "",
+ after = "",
+ ),
+ core.replace(
+ before = "",
+ after = "",
+ ),
+ core.replace(
+ before = "",
+ after = "",
+ ),
+ ], ignore_noop = True),
+]
+
+piper_sot_to_gerrit(
+ name_prefix = "gpowerd",
+ google3_files = _all_gpowerd_google3_files,
+ git_files = _all_gob_files,
+ default_author = "gBMC Team <gbmc-core@google.com>",
+ allowed_authors = allowed_authors,
+ contact_email = "gbmc-core+copybara@google.com",
+ url = "rpc://gbmc/gPowerD",
+ transformations = _transformations,
+ owner_mdb = "gbmc-git-approvers",
+ ci_labels = ["Presubmit"],
+ common_flags = {
+ "--ignore-noop": [],
+ },
+ metadata_scrubber = message_scrub_google_block(),
+ multiple_gerrit_workflows = True,
+ branch = "master",
+)