diff --git a/.gitignore b/.gitignore index c1c306f8f538ca62e47ec2af1ce204a999f6fbe0..542cf0f3757c3750eda7449e6b35187de287e654 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,6 @@ topology/pkg/ topology/build *.yaml !automation.yaml +!ant-agent.yaml # python build cache __pycache__ \ No newline at end of file diff --git a/automation/makefile b/automation/makefile index 46b99a6aeed8f7108bb2529481216f7716cf19af..d25357410b38ed7dcc33d000a818de2a808aba23 100644 --- a/automation/makefile +++ b/automation/makefile @@ -1,4 +1,5 @@ -BINARY_NAME := PilotGo-plugin-automation +SERVER_BINARY_NAME := ismp-automation +AGENT_BINARY_NAME := ant-agent go_build_cflags = -ldflags "-s -w" .PHONY: build-web build-server rpm clean @@ -11,23 +12,42 @@ build-web: build-server: @echo "Building server binary..." - GOSUMDB=off GO111MODULE=on go build $(go_build_cflags) -o $(BINARY_NAME) server/cmd/main.go + GOSUMDB=off CGO_ENABLED=0 GO111MODULE=on go build $(go_build_cflags) -o $(SERVER_BINARY_NAME) server/cmd/main.go + +build-agent: + @echo "Building agent binary..." + GOSUMDB=off CGO_ENABLED=0 GO111MODULE=on go build $(go_build_cflags) -o $(AGENT_BINARY_NAME) agent/cmd/main.go PWD_DIR := $(CURDIR) PARENT_DIR := $(abspath $(PWD_DIR)/..) ARCH := $(shell uname -m) -rpm: +rpm-server: + @echo "Building tar..." + rm -f $(PWD_DIR)/$(SERVER_BINARY_NAME).tar.gz + cd $(PARENT_DIR) && tar -czvf $(SERVER_BINARY_NAME).tar.gz automation + + @echo "Moving tar..." + mv $(PARENT_DIR)/$(SERVER_BINARY_NAME).tar.gz /root/rpmbuild/SOURCES/ + cp $(PWD_DIR)/server/scripts/ismp-automation.spec /root/rpmbuild/SPECS/ + + @echo "Building rpm..." + cd /root/rpmbuild/SPECS && rpmbuild -ba ismp-automation.spec + + @echo "Coping rpm..." + cp /root/rpmbuild/RPMS/$(ARCH)/*.rpm $(PWD_DIR)/ + +rpm-agent: @echo "Building tar..." - rm -f $(PWD_DIR)/$(BINARY_NAME).tar.gz - cd $(PARENT_DIR) && tar -czvf $(BINARY_NAME).tar.gz automation + rm -f $(PWD_DIR)/$(AGENT_BINARY_NAME).tar.gz + cd $(PARENT_DIR) && tar -czvf $(AGENT_BINARY_NAME).tar.gz automation @echo "Moving tar..." - mv $(PARENT_DIR)/$(BINARY_NAME).tar.gz /root/rpmbuild/SOURCES/ - cp $(PWD_DIR)/server/scripts/PilotGo-plugin-automation.spec /root/rpmbuild/SPECS/ + mv $(PARENT_DIR)/$(AGENT_BINARY_NAME).tar.gz /root/rpmbuild/SOURCES/ + cp $(PWD_DIR)/agent/scripts/ant-agent.spec /root/rpmbuild/SPECS/ @echo "Building rpm..." - cd /root/rpmbuild/SPECS && rpmbuild -ba PilotGo-plugin-automation.spec + cd /root/rpmbuild/SPECS && rpmbuild -ba ant-agent.spec @echo "Coping rpm..." cp /root/rpmbuild/RPMS/$(ARCH)/*.rpm $(PWD_DIR)/ @@ -36,4 +56,5 @@ rpm: clean: @echo "Cleaning up..." rm -rf web/dist - rm -rf $(BINARY_NAME) \ No newline at end of file + rm -rf $(SERVER_BINARY_NAME) + rm -rf $(AGENT_BINARY_NAME) \ No newline at end of file diff --git a/automation/server/scripts/PilotGo-plugin-automation.service b/automation/server/scripts/ismp-automation.service similarity index 100% rename from automation/server/scripts/PilotGo-plugin-automation.service rename to automation/server/scripts/ismp-automation.service diff --git a/automation/server/scripts/PilotGo-plugin-automation.spec b/automation/server/scripts/ismp-automation.spec similarity index 52% rename from automation/server/scripts/PilotGo-plugin-automation.spec rename to automation/server/scripts/ismp-automation.spec index ebda918422c01498177d785832103f16b5a98262..54ad392cdace0566701a3039fcc2c050d2d9e2e8 100644 --- a/automation/server/scripts/PilotGo-plugin-automation.spec +++ b/automation/server/scripts/ismp-automation.spec @@ -1,15 +1,15 @@ %define debug_package %{nil} -Name: PilotGo-plugin-automation +Name: ismp-automation Version: 3.0.0 Release: 1 Summary: PilotGo automation plugin provides script execution and orchestration. License: MulanPSL-2.0 URL: https://gitee.com/openeuler/PilotGo-plugins/automation -Source0: PilotGo-plugin-automation.tar.gz +Source0: ismp-automation.tar.gz BuildRequires: systemd -Provides: pilotgo-plugin-automation = %{version}-%{release} +Provides: ismp-automation = %{version}-%{release} %description PilotGo automation plugin provides script execution and orchestration. @@ -19,7 +19,7 @@ PilotGo automation plugin provides script execution and orchestration. %build pushd server -GO111MODULE=on go build -o PilotGo-plugin-automation ./cmd/main.go +CGO_ENABLED=0 GO111MODULE=on go build -o ismp-automation ./cmd/main.go popd pushd web @@ -29,19 +29,19 @@ popd %install mkdir -p %{buildroot}/opt/PilotGo/plugin/automation/{server/log,web/dist} -install -D -m 0755 server/PilotGo-plugin-automation %{buildroot}/opt/PilotGo/plugin/automation/server -install -D -m 0644 server/automation.yml %{buildroot}/opt/PilotGo/plugin/automation/server/automation.yml -install -D -m 0644 server/scripts/PilotGo-plugin-automation.service %{buildroot}%{_unitdir}/PilotGo-plugin-automation.service +install -D -m 0755 server/ismp-automation %{buildroot}/opt/PilotGo/plugin/automation/server +install -D -m 0644 server/automation.yaml %{buildroot}/opt/PilotGo/plugin/automation/server/automation.yaml +install -D -m 0644 server/scripts/ismp-automation.service %{buildroot}%{_unitdir}/ismp-automation.service cp -rf web/dist %{buildroot}/opt/PilotGo/plugin/automation/web %post -%systemd_post PilotGo-plugin-automation.service +%systemd_post ismp-automation.service %preun -%systemd_preun PilotGo-plugin-automation.service +%systemd_preun ismp-automation.service %postun -%systemd_postun PilotGo-plugin-automation.service +%systemd_postun ismp-automation.service %files %dir /opt/PilotGo @@ -49,9 +49,9 @@ cp -rf web/dist %{buildroot}/opt/PilotGo/plugin/automation/web %dir /opt/PilotGo/plugin/automation %dir /opt/PilotGo/plugin/automation/server %dir /opt/PilotGo/plugin/automation/server/log -/opt/PilotGo/plugin/automation/server/PilotGo-plugin-automation -/opt/PilotGo/plugin/automation/server/automation.yml -%{_unitdir}/PilotGo-plugin-automation.service +/opt/PilotGo/plugin/automation/server/ismp-automation +/opt/PilotGo/plugin/automation/server/automation.yaml +%{_unitdir}/ismp-automation.service /opt/PilotGo/plugin/automation/web/dist