Skip to content

Commit bc3ca92

Browse files
feat: basic vm controls (#1293)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced new GraphQL operations for comprehensive virtual machine control (start, stop, pause, resume, force stop, reboot, reset). - Enhanced API authentication and authorization with standardized roles and permission checks. - Added a configuration template that streamlines server setup and improves remote access and parity management. - New functionality for managing parity checks within the array service, including state validation and conditional command execution. - New types and mutations for array and virtual machine management in the GraphQL schema. - Added a new directive for authorization control within the GraphQL schema. - Introduced a new utility for generating authentication enum type definitions. - Added a new configuration file template for server access and authentication details. - Updated the configuration file version to reflect the latest changes. - **Improvements** - Upgraded core dependencies for better stability and performance. - Refined notification handling and error feedback for a more responsive user experience. - Improved error handling and logging for API key management and validation processes. - Updated configuration versioning for enhanced compatibility. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent c4fdff8 commit bc3ca92

File tree

68 files changed

+4069
-1152
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+4069
-1152
lines changed

.github/workflows/main.yml

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
- name: Cache APT Packages
4848
uses: awalsh128/[email protected]
4949
with:
50-
packages: bash procps python3 libvirt-dev jq zstd git build-essential
50+
packages: bash procps python3 libvirt-dev jq zstd git build-essential libvirt-daemon-system
5151
version: 1.0
5252

5353
- name: Install pnpm
@@ -72,6 +72,45 @@ jobs:
7272
- name: PNPM Install
7373
run: pnpm install --frozen-lockfile
7474

75+
- name: Setup libvirt
76+
run: |
77+
# Create required groups (if they don't already exist)
78+
sudo groupadd -f libvirt
79+
sudo groupadd -f kvm
80+
81+
# Create libvirt user if not present, and add it to the kvm group
82+
sudo useradd -m -s /bin/bash -g libvirt libvirt || true
83+
sudo usermod -aG kvm libvirt || true
84+
85+
# Set up libvirt directories and permissions
86+
sudo mkdir -p /var/run/libvirt /var/log/libvirt /etc/libvirt
87+
sudo chown root:libvirt /var/run/libvirt /var/log/libvirt
88+
sudo chmod g+w /var/run/libvirt /var/log/libvirt
89+
90+
# Configure libvirt by appending required settings
91+
sudo tee -a /etc/libvirt/libvirtd.conf > /dev/null <<EOF
92+
unix_sock_group = "libvirt"
93+
unix_sock_rw_perms = "0770"
94+
auth_unix_rw = "none"
95+
EOF
96+
97+
# Add the current user to libvirt and kvm groups (note: this change won’t apply to the current session)
98+
sudo usermod -aG libvirt,kvm $USER
99+
100+
sudo mkdir -p /var/run/libvirt
101+
sudo chown root:libvirt /var/run/libvirt
102+
sudo chmod 775 /var/run/libvirt
103+
104+
105+
# Start libvirtd in the background
106+
sudo /usr/sbin/libvirtd --daemon
107+
108+
# Wait a bit longer for libvirtd to start
109+
sleep 5
110+
111+
# Verify libvirt is running using sudo to bypass group membership delays
112+
sudo virsh list --all || true
113+
75114
- name: Lint
76115
run: pnpm run lint
77116

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,7 @@ result-*
105105
web/scripts/.sync-webgui-repo-*
106106

107107
# Activation code data
108-
plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/data/activation-data.php
108+
plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix.my.servers/data/activation-data.php
109+
110+
# Config file that changes between versions
111+
api/dev/Unraid.net/myservers.cfg

api/codegen.ts

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { CodegenConfig } from '@graphql-codegen/cli';
22

33

44

5+
import { getAuthEnumTypeDefs } from './src/unraid-api/graph/utils/auth-enum.utils.js';
56

67

78
const config: CodegenConfig = {
@@ -31,28 +32,21 @@ const config: CodegenConfig = {
3132
},
3233
},
3334
generates: {
34-
'src/graphql/generated/client/': {
35-
documents: './src/graphql/mothership/*.ts',
36-
schema: {
37-
[process.env.MOTHERSHIP_GRAPHQL_LINK as string]: {
38-
headers: {
39-
origin: 'https://forums.unraid.net',
40-
},
41-
},
42-
},
43-
preset: 'client',
44-
presetConfig: {
45-
gqlTagName: 'graphql',
46-
},
47-
config: {
48-
useTypeImports: true,
49-
withObjectType: true,
50-
},
51-
plugins: [{ add: { content: '/* eslint-disable */' } }],
35+
'./generated-schema.graphql': {
36+
plugins: ['schema-ast'],
37+
schema: [
38+
'./src/graphql/types.ts',
39+
'./src/graphql/schema/types/**/*.graphql',
40+
getAuthEnumTypeDefs(),
41+
],
5242
},
5343
// Generate Types for the API Server
5444
'src/graphql/generated/api/types.ts': {
55-
schema: ['./src/graphql/types.ts', './src/graphql/schema/types/**/*.graphql'],
45+
schema: [
46+
'./src/graphql/types.ts',
47+
'./src/graphql/schema/types/**/*.graphql',
48+
getAuthEnumTypeDefs(),
49+
],
5650
plugins: [
5751
'typescript',
5852
'typescript-resolvers',
@@ -66,7 +60,11 @@ const config: CodegenConfig = {
6660
// Generate Operations for any built-in API Server Operations (e.g., report.ts)
6761
'src/graphql/generated/api/operations.ts': {
6862
documents: './src/graphql/client/api/*.ts',
69-
schema: ['./src/graphql/types.ts', './src/graphql/schema/types/**/*.graphql'],
63+
schema: [
64+
'./src/graphql/types.ts',
65+
'./src/graphql/schema/types/**/*.graphql',
66+
getAuthEnumTypeDefs(),
67+
],
7068
preset: 'import-types',
7169
presetConfig: {
7270
typesPath: '@app/graphql/generated/api/types.js',
@@ -84,6 +82,26 @@ const config: CodegenConfig = {
8482
withObjectType: true,
8583
},
8684
},
85+
// Generate Types for Mothership GraphQL Client
86+
'src/graphql/generated/client/': {
87+
documents: './src/graphql/mothership/*.ts',
88+
schema: {
89+
[process.env.MOTHERSHIP_GRAPHQL_LINK as string]: {
90+
headers: {
91+
origin: 'https://forums.unraid.net',
92+
},
93+
},
94+
},
95+
preset: 'client',
96+
presetConfig: {
97+
gqlTagName: 'graphql',
98+
},
99+
config: {
100+
useTypeImports: true,
101+
withObjectType: true,
102+
},
103+
plugins: [{ add: { content: '/* eslint-disable */' } }],
104+
},
87105
'src/graphql/generated/client/validators.ts': {
88106
schema: {
89107
[process.env.MOTHERSHIP_GRAPHQL_LINK as string]: {

api/dev/Unraid.net/myservers.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[api]
22
version="4.4.1"
3-
extraOrigins="https://google.com, https://test.com"
3+
extraOrigins="https://google.com,https://test.com"
44
[local]
55
sandbox="yes"
66
[remote]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[api]
2+
version="4.4.1"
3+
extraOrigins="https://google.com,https://test.com"
4+
[local]
5+
sandbox="yes"
6+
[remote]
7+
wanaccess="yes"
8+
wanport="8443"
9+
upnpEnabled="no"
10+
apikey="_______________________BIG_API_KEY_HERE_________________________"
11+
localApiKey="_______________________LOCAL_API_KEY_HERE_________________________"
12+
13+
username="zspearmint"
14+
avatar="https://via.placeholder.com/200"
15+
regWizTime="1611175408732_0951-1653-3509-FBA155FA23C0"
16+
accesstoken=""
17+
idtoken=""
18+
refreshtoken=""
19+
dynamicRemoteAccessType="DISABLED"
20+
ssoSubIds=""

api/dev/keys/b5b4aa3d-8e40-4c92-bc40-d50182071886.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
"name": "Connect",
77
"permissions": [],
88
"roles": [
9-
"connect"
9+
"CONNECT"
1010
]
1111
}

api/dev/states/myservers.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[api]
2-
version="4.4.1"
3-
extraOrigins="https://google.com, https://test.com"
2+
version="4.6.6"
3+
extraOrigins="https://google.com,https://test.com"
44
[local]
55
sandbox="yes"
66
[remote]

0 commit comments

Comments
 (0)