# Guest Agent Implementation - Completion Checklist

## ✅ Code Implementation (COMPLETED)

### 1. VM Creation Code
- [x] **New VM creation** - `agent=1` added to VM config (line 318)
- [x] **VM cloning** - `agent=1` added to cloned VM config (line 242)
- [x] **VM updates** - `agent=1` enforced in UpdateVM function (line 560)

**Status:** ✅ All code changes are in place and verified

### 2. Automation Scripts
- [x] **Enable script** - `scripts/enable-guest-agent-existing-vms.sh` created and executable
  - [x] Dynamic node discovery
  - [x] Dynamic VM discovery
  - [x] Status checking before enabling
  - [x] Comprehensive summaries
- [x] **Verification script** - `scripts/verify-guest-agent.sh` created and executable
  - [x] Lists all VMs with status
  - [x] Per-node summaries
  - [x] Color-coded output

**Status:** ✅ All scripts created and ready to use

### 3. Documentation
- [x] Updated `docs/enable-guest-agent-manual.md`
- [x] Updated `scripts/README.md`
- [x] Created `docs/GUEST_AGENT_ENABLED.md`
- [x] Created this checklist

**Status:** ✅ All documentation updated

---

## ⏳ Operational Tasks (TO BE COMPLETED)

### 1. Enable Guest Agent on Existing VMs
**Status:** ⏳ **NOT YET EXECUTED**

**Action Required:**
```bash
./scripts/enable-guest-agent-existing-vms.sh
```

**What this does:**
- Discovers all nodes on both Proxmox sites
- Discovers all VMs on each node
- Enables guest agent (`agent=1`) in Proxmox config for VMs that need it
- Provides summary of actions taken

**Expected Output:**
- List of all nodes discovered
- List of all VMs processed
- Count of VMs enabled
- Count of VMs already enabled
- Count of failures (if any)

---

### 2. Verify Guest Agent Status
**Status:** ⏳ **NOT YET EXECUTED**

**Action Required:**
```bash
./scripts/verify-guest-agent.sh
```

**What this does:**
- Lists all VMs with their current guest agent status
- Shows which VMs have guest agent enabled/disabled
- Provides per-node and per-site summaries

**Expected Output:**
- Table showing VMID, Name, and Status (ENABLED/DISABLED)
- Summary statistics per node
- Overall summary across all sites

---

### 3. Install Guest Agent Package in OS (for existing VMs)
**Status:** ⏳ **TO BE VERIFIED**

**Action Required (if not already installed):**

For each existing VM, SSH in and verify/install:

```bash
# SSH into VM
ssh admin@<vm-ip>

# Check if package is installed
dpkg -l | grep qemu-guest-agent

# If not installed, install it:
sudo apt-get update
sudo apt-get install -y qemu-guest-agent
sudo systemctl enable qemu-guest-agent
sudo systemctl start qemu-guest-agent

# Verify it's running
sudo systemctl status qemu-guest-agent
```

**Note:** VMs created with updated manifests already include guest agent installation in cloud-init userData, so they should have the package automatically.

**Check if userData includes guest agent:**
```bash
grep -r "qemu-guest-agent" examples/ gitops/ all-vm-userdata.txt
```

---

## 📊 Current Status Summary

| Task | Status | Notes |
|------|--------|-------|
| Code Implementation | ✅ Complete | All code changes verified in place |
| Enable Script | ✅ Ready | Script exists and is executable |
| Verification Script | ✅ Ready | Script exists and is executable |
| Documentation | ✅ Complete | All docs updated |
| **Run Enable Script** | ⏳ **Pending** | Needs to be executed |
| **Run Verify Script** | ⏳ **Pending** | Needs to be executed |
| **OS Package Installation** | ⏳ **Unknown** | Needs verification per VM |

---

## 🎯 Next Actions

1. **Run the enablement script:**
   ```bash
   cd /home/intlc/projects/Sankofa
   ./scripts/enable-guest-agent-existing-vms.sh
   ```

2. **Run the verification script:**
   ```bash
   ./scripts/verify-guest-agent.sh
   ```

3. **Review the output** to see:
   - How many VMs had guest agent enabled
   - Which VMs already had it enabled
   - Any failures that need attention

4. **For VMs that need OS package installation:**
   - Check if cloud-init userData already includes it
   - If not, SSH into each VM and install manually
   - Or update the VM manifests to include it in userData

---

## 🔍 Verification Commands

### Check if code changes are in place:
```bash
grep -n "agent.*1" crossplane-provider-proxmox/pkg/proxmox/client.go
```

### Check if scripts exist:
```bash
ls -lh scripts/*guest*agent*.sh
```

### Check if scripts are executable:
```bash
test -x scripts/enable-guest-agent-existing-vms.sh && echo "Executable" || echo "Not executable"
test -x scripts/verify-guest-agent.sh && echo "Executable" || echo "Not executable"
```

---

## 📝 Notes

- **New VMs:** Will automatically have guest agent enabled (code is in place)
- **Existing VMs:** Need to run the enablement script
- **OS Package:** May need manual installation for existing VMs, but check userData first
- **Future VMs:** Will have both Proxmox config and OS package automatically configured

