---
name: openstack-manager
description: Manages OpenStack virtual machines, networks, and infrastructure through the OpenStack API. Use when creating VMs, managing instances, configuring networks, or handling OpenStack infrastructure.
argument-hint: "[action] [--name=vm-name]"
allowed-tools: [Read, Write, Bash, mcp__myaidev_openstack__*]
---

# OpenStack Manager Skill

Manage OpenStack virtual machines, networks, and infrastructure through the OpenStack API with full MCP integration.

## Capabilities

- Create and manage virtual machines
- Configure networks and security groups
- Manage floating IPs
- Handle volumes and storage
- Monitor instance status
- Cloud-init configuration

## Prerequisites

Configure OpenStack credentials using the configure skill:

```
/myaidev-method:configure openstack
```

Or set environment variables manually:
```
OS_AUTH_URL=https://your-openstack.com:5000/v3
OS_USERNAME=your_username
OS_PASSWORD=your_password
OS_PROJECT_NAME=your_project
OS_REGION_NAME=your_region
OS_USER_DOMAIN_NAME=Default
OS_PROJECT_DOMAIN_NAME=Default
```

## MCP Tools Available

| Tool | Description |
|------|-------------|
| `os_session_create` | Create authenticated session |
| `os_health_check` | Verify connection |
| `os_server_list` | List instances |
| `os_server_create` | Create new instance |
| `os_server_delete` | Delete instance |
| `os_server_start` | Start instance |
| `os_server_stop` | Stop instance |
| `os_server_reboot` | Reboot instance |
| `os_server_console` | Get console output |
| `os_floating_ip_create` | Create floating IP |
| `os_server_add_floating_ip` | Assign floating IP |
| `os_image_list` | List available images |
| `os_flavor_list` | List instance sizes |
| `os_network_list` | List networks |
| `os_security_group_list` | List security groups |
| `os_keypair_list` | List SSH keypairs |
| `os_keypair_create` | Create keypair |
| `os_volume_list` | List volumes |
| `os_volume_create` | Create volume |
| `os_server_add_volume` | Attach volume |
| `os_cloud_init_info` | Get cloud-init templates |
| `os_operation_history` | View operation history |

## Actions

| Action | Description |
|--------|-------------|
| `list` | List all instances |
| `create` | Create new instance |
| `delete` | Delete instance |
| `start` | Start stopped instance |
| `stop` | Stop running instance |
| `reboot` | Reboot instance |
| `console` | Get console output |
| `ssh` | Connect via SSH |

## Parameters

| Parameter | Description | Default |
|-----------|-------------|---------|
| `action` | Action to perform | list |
| `--name` | Instance name | Required for create |
| `--image` | OS image to use | Ubuntu 22.04 |
| `--flavor` | Instance size | m1.small |
| `--network` | Network to attach | default |
| `--key` | SSH keypair name | default |
| `--security-group` | Security group | default |
| `--floating-ip` | Assign floating IP | false |
| `--cloud-init` | Cloud-init script | none |

## Example Usage

```bash
# List all instances
/myaidev-method:openstack list

# Create new instance
/myaidev-method:openstack create --name=webserver --image="Ubuntu 22.04" --flavor=m1.medium

# Create with floating IP
/myaidev-method:openstack create --name=api-server --floating-ip

# Start/stop instance
/myaidev-method:openstack start --name=webserver
/myaidev-method:openstack stop --name=webserver

# Get console output
/myaidev-method:openstack console --name=webserver

# Delete instance
/myaidev-method:openstack delete --name=webserver
```

## Cloud-Init Configuration

Create instances with custom initialization:

```yaml
# cloud-init.yaml
#cloud-config
package_update: true
packages:
  - nginx
  - docker.io

runcmd:
  - systemctl start nginx
  - systemctl enable docker

users:
  - name: deploy
    sudo: ALL=(ALL) NOPASSWD:ALL
    ssh_authorized_keys:
      - ssh-rsa AAAA...
```

```bash
/myaidev-method:openstack create --name=webserver --cloud-init=./cloud-init.yaml
```

## Instance Output

```markdown
# Instance Details

## webserver
- **ID**: abc-123-def
- **Status**: ACTIVE
- **IP (Private)**: 192.168.1.100
- **IP (Floating)**: 203.0.113.50
- **Image**: Ubuntu 22.04
- **Flavor**: m1.medium (2 vCPU, 4GB RAM)
- **Created**: 2025-01-15 10:30:00
- **Key**: my-keypair
- **Security Groups**: default, web

## Connection
```bash
ssh ubuntu@203.0.113.50
```
```

## Common Workflows

### Web Server Setup
```bash
# Create instance with nginx
/myaidev-method:openstack create \
  --name=webserver \
  --flavor=m1.medium \
  --floating-ip \
  --security-group=web \
  --cloud-init=./nginx-setup.yaml
```

### Database Server
```bash
# Create with extra volume
/myaidev-method:openstack create \
  --name=db-server \
  --flavor=m1.large \
  --cloud-init=./postgresql-setup.yaml

# Add data volume
/myaidev-method:openstack volume create --name=db-data --size=100
/myaidev-method:openstack volume attach --server=db-server --volume=db-data
```

## Integration

- Works with deployment workflows
- Supports infrastructure-as-code patterns
- Integrates with monitoring systems

## Troubleshooting

| Issue | Solution |
|-------|----------|
| Auth failed | Check credentials and endpoint URL |
| Quota exceeded | Request quota increase |
| Network unavailable | Check network configuration |
| Image not found | Use `os_image_list` to find available |
| Flavor not found | Use `os_flavor_list` to find available |
