# VWP Phone Provisioning - RPS Configuration and Phone Records

## User
- **User:** Mike Swanson (mike)
- **Machine:** Mikes-MacBook-Air
- **Role:** admin

## Session Summary

This session continued the Valley Wide Plastering VoIP provisioning work from the previous day. The primary focus was understanding why phones were not provisioning correctly despite having SIP devices created in PacketDial.

The root cause was identified through reading the RPS documentation: phones in YMCS RPS were registered but had no server assigned (serverId: null). A new RPS server profile "OIT - PacketDial" was created in YMCS with the correct provisioning URL (http://ndp.ucaasnetwork.com/cfg) and credentials (Prov_Admin). All VWP phones were then assigned to this server via PATCH requests to the YMCS RPS API.

A second issue was discovered: the PacketDial "phones" table (MAC-to-SIP mapping) was not being populated correctly via API. Phone records were created with device-models-brand-and-model set to "Yealink SIP-T54W" but the UI showed "Manual or Softphone". Additionally, the provisioning credentials (device-provisioning-username/password) were not being set on API-created phone records. These fields were updated via PUT requests.

A third issue emerged: the SIP device naming convention. The CSV import and API-created devices used the "105a" format (extension + "a" suffix), but when Mike recreated the phone record in the UI, it used "105" without the suffix. This mismatch between phone record SIP URI and device SIP URI prevented registration. Work is ongoing to align the naming convention.

Missing users for extensions 101 (Receptionist), 106 (Tammy), 111 (Kitchen), and 117 (Jesse III) were created along with their SIP devices. Extension 103 (Rose) has a user and device but no phone record yet as her phone (MAC ending 5217) has not connected to YMCS/RPS.

## Key Decisions

- Created a new RPS server profile "OIT - PacketDial" rather than using the existing "WL - ACG" server, ensuring clean configuration with correct credentials
- Set device-level RPS credentials on individual phones rather than relying solely on server-level defaults
- Updated all phone records with device-provisioning-username and device-provisioning-password fields to match the working test phone configuration
- Used PUT to phones collection (not PATCH to individual phone) for updating phone records - the API accepts MAC in body for identification
- Discovered that PacketDial uses separate "devices" (SIP accounts) and "phones" (MAC provisioning records) tables - both must be configured correctly

## Problems Encountered

- **RPS devices had null serverId**: Phones were in YMCS RPS but not assigned to any provisioning server. Fixed by creating OIT server profile and PATCH-assigning each device.
- **Phone records missing provisioning credentials**: API-created phone records had empty device-provisioning-username/password and global-one-time-pass="yes". Fixed by PUT update with Prov_Admin credentials and global-one-time-pass="no".
- **Model field not recognized by UI**: API set "Yealink SIP-T54W" but UI showed "Manual or Softphone". User recreated phone in UI to fix.
- **SIP URI mismatch**: API-created devices used "105a@domain" format, UI-created used "105@domain". Mismatch prevents phone from registering. User deleted duplicate 105a device.
- **DELETE device API failure**: DELETE /users/{user}/devices/{device} returns 404. POST /users/{user}/devices/delete with body also failed (created a device named "delete" instead). User to delete via UI.

## Configuration Changes

### Created
- YMCS RPS Server: "OIT - PacketDial" (ID: 019f4ca999e0740e968c35513dd4ec10)
  - URL: http://ndp.ucaasnetwork.com/cfg
  - Auth: Prov_Admin / YJ5UgRd9pV

### Modified
- 13 phones assigned to OIT RPS server in YMCS (71b1, 7559, 96b8, 7441, 6a36, 73b7, 6509, 958e, 755b, 6d01, 6cf9, a890, 6cf5)
- All phone records in PacketDial updated with provisioning credentials

### PacketDial Users Created
- 101: Customer Service (customerservice@valleywideplastering.com)
- 106: Accounts Payable (acctpay@valleywideplastering.com)
- 111: Kitchen Phone (shared, no voicemail)
- 117: Jesse III (jesse@nescoap.com)

### PacketDial Devices Created
- 101a, 106a, 111a, 117a (and later 105, 106, 111, etc. by user in UI)

### PacketDial Phone Records Created (MAC to SIP mapping)
| MAC | Extension | Model |
|-----|-----------|-------|
| 805e0cdd71b1 | 101a | Yealink SIP-T54W |
| 805e0cdd7559 | 102a | Yealink SIP-T54W |
| 805e0c7896b8 | 104a | Yealink SIP-T54W |
| 805e0cdd7441 | 105a | Yealink SIP-T54W |
| 44dbd26f6a36 | 106a | Yealink SIP-T54W |
| 805e0cdd73b7 | 109a | Yealink SIP-T54W |
| 805e0cdd6509 | 110a | Yealink SIP-T54W |
| 805e0c78958e | 111a | Yealink SIP-T54W |
| 805e0cdd755b | 113a | Yealink SIP-T54W |
| 805e0cdd6d01 | 114a | Yealink SIP-T54W |
| 805e0cdd6cf9 | 115a | Yealink SIP-T54W |
| 805e0c6aa890 | 116a | Yealink SIP-T54W |
| 805e0cdd6cf5 | 117a | Yealink SIP-T54W |

## Credentials & Secrets

### OIT/PacketDial Provisioning (already vaulted)
- Vault: `msp-tools/oitvoip-provisioning.sops.yaml`
- Username: `Prov_Admin`
- Password: `YJ5UgRd9pV`
- Provisioning URL: `http://ndp.ucaasnetwork.com/cfg`

### PacketDial SIP Device Passwords (auto-generated by API)
- 101a: gCPT29Kp31ph6OC6
- 105a: qK5b5WsBW4ErHOyE
- 105 (UI-created): M06vjtV78Ara
- (Others auto-generated, query via `ns.py devices vwp.91912.service <ext>`)

## Infrastructure & Servers

### YMCS RPS Servers
| ID | Name | URL |
|----|------|-----|
| 019c908fe5f47a0da57794899b66b7ab | WL - ACG | http://ndp.ucaasnetwork.com/cfg |
| 019f4ca999e0740e968c35513dd4ec10 | OIT - PacketDial | http://ndp.ucaasnetwork.com/cfg |

### VWP Site in YMCS
- Site ID: 1e7578a6fe0e41cfb5a3e8b40933ffee
- Site Name: VWP

### PacketDial Domain
- Domain: vwp.91912.service
- Reseller: 91912.service
- PBX: pbx.packetdial.com

## Commands & Outputs

### Create OIT RPS Server
```bash
ymcs.py raw POST /v2/rps/servers --body '{"serverName":"OIT - PacketDial","url":"http://ndp.ucaasnetwork.com/cfg","authName":"Prov_Admin","password":"YJ5UgRd9pV"}' --confirm
```

### Assign Phone to RPS Server
```bash
ymcs.py raw PATCH /v2/rps/devices/<device-id> --body '{"serverId":"019f4ca999e0740e968c35513dd4ec10"}' --confirm
```

### Set RPS Device Credentials
```bash
ymcs.py raw PATCH /v2/rps/devices/<device-id> --body '{"authName":"Prov_Admin","password":"YJ5UgRd9pV"}' --confirm
```

### Create Phone Record in PacketDial
```bash
ns.py create-phone vwp.91912.service --body '{
  "device-provisioning-mac-address":"805e0cdd7441",
  "device-models-brand-and-model":"Yealink SIP-T54W",
  "device-provisioning-sip-uri-1":"sip:105a@vwp.91912.service"
}' --confirm
```

### Update Phone with Provisioning Credentials
```bash
ns.py raw PUT domains/vwp.91912.service/phones --body '{
  "device-provisioning-mac-address": "805e0cdd7441",
  "device-provisioning-username": "Prov_Admin",
  "device-provisioning-password": "YJ5UgRd9pV",
  "global-one-time-pass": "no"
}' --confirm
```

### Reboot Phone via YMCS
```bash
ymcs.py reboot --body '{"deviceIds":["<ymcs-device-id>"],"deviceType":1}' --confirm
```

## Pending / Incomplete Tasks

1. **Delete duplicate devices in PacketDial UI**: 105a and accidental "delete" device need removal via UI (API delete not working)
2. **Verify phone 7441 (105) registers**: After UI cleanup, reboot and confirm registration
3. **Create phone record for Rose (103)**: MAC 5217 not yet connected to YMCS - create when available
4. **Test remaining phones**: Reboot and verify registration for all 13 phones once 105 is working
5. **Document correct provisioning workflow**: Update VOIP_ONBOARDING_WORKFLOW.md with:
   - Phone records require model selection (via UI or correct API field)
   - Phone records require provisioning credentials
   - RPS devices need server assignment AND device-level credentials
   - SIP device naming convention (with or without "a" suffix)

## Reference Information

### YMCS Device IDs (for reboots)
| MAC Last 4 | YMCS Device ID |
|------------|----------------|
| 71b1 | 10d6e39239cd411c8e7db51e730a7561 |
| 7559 | 9d5b4e9c2c5949658974fb269e28759a |
| 7441 | 84b6e12b26e24f50a83d0b88596d66bb |

### RPS Device IDs
| MAC Last 4 | RPS Device ID |
|------------|---------------|
| 7441 | 019db6f32a0f73c1a429efeed9b6e054 |
| 7559 | 019db6f7a3507a2ea0f5d44cb91cf4a3 |
| 71b1 | 019db6ba84b27dad9ccbabc1e659c1ed |

### Documentation Files
- Extension mapping: `clients/valleywide/voip/extension-mapping.md`
- Provisioning status: `clients/valleywide/voip/PROVISIONING-STATUS.md`
- Complete setup guide: `clients/valleywide/voip/COMPLETE-CLIENT-SETUP.md`
- RPS provisioning doc: `.claude/skills/yealink-ymcs/docs/rps-provisioning/`
