Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration tool fixes and enhancements #48

Merged
merged 12 commits into from
Nov 30, 2023
1 change: 0 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ To remove the tool and its dependencies (if they are not required by other packa
Clean up configuration database: ::

config delete wg-quick@ns8
config delete agent
config delete ns8

Post-migration step back
Expand Down
8 changes: 1 addition & 7 deletions api/connection/read
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,7 @@ def get_config():
output, error = process.communicate()
ns8_config = simplejson.loads(output)

# agent config
bash_command = "/sbin/e-smith/config getjson agent"
process = subprocess.Popen(bash_command.split(), stdout=subprocess.PIPE)
output, error = process.communicate()
agent_config = simplejson.loads(output)

return {"ns8": ns8_config, "agent": agent_config}
return {"ns8": ns8_config}


try:
Expand Down
1 change: 0 additions & 1 deletion createlinks
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ event_templates($event, qw(

event_services($event, qw(
wg-quick@ns8 restart
agent restart
httpd reload
));

Expand Down
2 changes: 0 additions & 2 deletions nethserver-ns8-migration.spec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ Source: %{name}-%{version}.tar.gz
Source1: %{name}-cockpit.tar.gz

%global debug_package %{nil}
Source2: agent

BuildRequires: nethserver-devtools
Requires: wireguard-tools, kmod-wireguard
Expand Down Expand Up @@ -37,7 +36,6 @@ mkdir -p %{buildroot}/usr/libexec/nethserver/api/%{name}/
tar xvf %{SOURCE1} -C %{buildroot}/usr/share/cockpit/%{name}/
cp -a %{name}.json %{buildroot}/usr/share/cockpit/nethserver/applications/
cp -a api/* %{buildroot}/usr/libexec/nethserver/api/%{name}/
install -D -m 0755 %{SOURCE2} %{buildroot}/%{_bindir}/agent

%{genfilelist} %{buildroot} --file /etc/sudoers.d/50_nsapi_nethserver_ns8_migration 'attr(0440,root,root)' > e-smith-%{version}-filelist

Expand Down
25 changes: 0 additions & 25 deletions prep-sources
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,6 @@

set -e

# Download ns8-core
rm -f main.tar.gz
wget https://github.com/NethServer/ns8-core/archive/refs/heads/main.tar.gz
tar xvzf main.tar.gz

# Reuse existing gobuilder-core container, to speed up builds
if ! buildah containers --format "{{.ContainerName}}" | grep -q gobuilder-core; then
echo "Pulling Golang runtime..."
golang_cache_path="${PWD}/.golang-cache"
mkdir -vp "${golang_cache_path}/{mcache,bcache}"
buildah from --name gobuilder-tmp docker.io/library/golang:1.18-alpine
buildah run gobuilder-tmp apk add g++ gcc
buildah config --env GOCACHE=/var/lib/misc/bcache --env GOMODCACHE=/var/lib/misc/mcache gobuilder-tmp
buildah commit --rm gobuilder-tmp gobuilder-image
buildah from --name gobuilder-core \
-v "${golang_cache_path}:/var/lib/misc:z" \
-v "${PWD}/ns8-core-main/core:/usr/src/core:z" \
localhost/gobuilder-image
fi

# Build the agent
buildah run gobuilder-core sh -c "cd /usr/src/core/agent && CGO_ENABLED=0 go build -v ."
# Copy out the binary
buildah run gobuilder-core sh -c "cd /usr/src/core/agent; cat agent" > agent

# Build UI
NODE_OPTIONS="--openssl-legacy-provider"
export NODE_OPTIONS
Expand Down
1 change: 0 additions & 1 deletion root/etc/e-smith/db/configuration/defaults/agent/status

This file was deleted.

1 change: 0 additions & 1 deletion root/etc/e-smith/db/configuration/defaults/agent/type

This file was deleted.

6 changes: 6 additions & 0 deletions root/etc/e-smith/db/configuration/migrate/delete_agent
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
# Disable the agent service
$DB->get_value_and_delete('agent') || return '';
system('systemctl', 'disable', '--now', 'agent');
DavidePrincipi marked this conversation as resolved.
Show resolved Hide resolved
'';
}
17 changes: 0 additions & 17 deletions root/usr/lib/systemd/system/agent.service

This file was deleted.

1 change: 0 additions & 1 deletion root/usr/sbin/ns8-join
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ ret = ret['data']['output']

# Save config inside config db
subprocess.run(["/sbin/e-smith/config", "setprop", "wg-quick@ns8", "Address", ret["ip_address"], "RemoteEndpoint", ret["leader_endpoint"], "RemoteKey", ret["leader_public_key"], "RemoteNetwork", ret['network'], "status", "enabled"], check=True)
subprocess.run(["/sbin/e-smith/config", "setprop", "agent", "status", "enabled"], check=True)
subprocess.run(["/sbin/e-smith/config", "setprop", "ns8", "Host", args.host, "User", args.username, "Password", args.password, "TLSVerify", "enabled" if args.tlsverify else "disabled", "LeaderIpAddress", ret['leader_ip_address']], check=True)

# Save agent environment
Expand Down
1 change: 0 additions & 1 deletion root/usr/sbin/ns8-leave
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ fi

# reset DB props
/sbin/e-smith/config setprop ns8 Host "" User "" Password "" TLSVerify enabled LeaderIpAddress ""
/sbin/e-smith/config setprop agent status disabled
/sbin/e-smith/config setprop wg-quick@ns8 status disabled Address "" RemoteEndpoint "" RemoteKey "" RemoteNetwork ""

# reset nsdc routes
Expand Down
3 changes: 1 addition & 2 deletions ui/src/views/Dashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1179,9 +1179,8 @@ export default {
);
},
connectionReadSuccess(output) {
const agentStatus = output.configuration.agent.props.status;
this.config.isConnected = agentStatus == "enabled";
const ns8Config = output.configuration.ns8.props;
this.config.isConnected = ns8Config.Host != "";
this.config.leaderNode = ns8Config.Host;
this.config.adminUsername = ns8Config.User;
this.config.adminPassword = ns8Config.Password;
Expand Down