Using API Interface

Prerequisites

- BVCP Installed and running on the machine
- API Interface requires a security key called as `API KEY`. You can always validate your current API key from the config file: `/var/lib/nPulse/BVCP/bvcp.conf`
Please bear in mind, the API key will not changed automatically, disclose the API key gives anyone the privilege to make modifications or even destroy the virtual machines!

                      security
                      {
                              api_key = 208C694F9CBD2BFA47F8E4EC7C0D2A5FB3B29984802E3E049A73A2011CB93BDC
                              secret = 59DFDCCC370406476578BDB1A42F2E0A05113D161F3F6A931E78564A7D034EC2
                      }
                      


PHP API Interface

Under /var/lib/nPulse/BVCP/API there is a `cli.php` example PHP program to use the API. To achieve a successfull connection you must edit the header of the file.

                    $API_KEY = "208C694F9CBD2BFA47F8E4EC7C0D2A5FB3B29984802E3E049A73A2011CB93BDC"; // CHANGE THIS !!
                    $API_HOST = "localhost";
                    $API_PORT = "8628";
                  


Built-In API Interface

To invoke built-in API feature just run: `/var/lib/nPulse/BVCP/Backend/vmm cli`


API Reference / Top Level


  ██████╗ ██╗   ██╗ ██████╗██████╗
  ██╔══██╗██║   ██║██╔════╝██╔══██╗
  ██████╔╝██║   ██║██║     ██████╔╝
  ██╔══██╗╚██╗ ██╔╝██║     ██╔═══╝
  ██████╔╝ ╚████╔╝ ╚██████╗██║
  ╚═════╝   ╚═══╝   ╚═════╝╚═╝

Bhyve Virtual-Machine Control Panel under FreeBSD

[N] 2021-06-28 03:04:17 | application/vmserver/main.c | Initialising bhyve VM Server Application
Error: / ERR / invalid_parameter
Available Commands:
+ vm      | Virtual Machine Management
+ storage | Storage Management
+ switch  | Virtual Switch Management
+ user    | Built-in User Management
+ vminfo  | SysInfo
+ config  | Internal Storage

more details:  vm
cmd example:  vm list ALL
Note: type exit to Quit

_>



API Reference / VM Submenu

  _> vm
  * [vm] Available Commands:
    [Start/Stop Commands]
    + start [prefix]                                                          | Start virtual machine
    + check [prefix]                                                          | Check virtual machine
    + shutdown [prefix]                                                       | ACPI Shutdown
    + user [user]                                                             | Add user to the VM
    + log [prefix] [max_entries]                                              | Fetch VM Journal
    + kill [prefix]                                                           | Kill virtual machine
    + stop [prefix]                                                           | Stop virtual machine
    + list {prefix}                                                           | List virtual machine
    + destroy {prefix}                                                        | Destroy virtual machine
    + restart [prefix]                                                        | Restart virtual machine
 
    [Management Commands]
    + create [prefix] [description]                                           | New virtual machine
    + desc [prefix] [new_description]                                         | Modify virtual machine
    + note [prefix] {new_note}                                                | Add/Get note
    + clear [prefix]                                                          | Clear config (debug purpose)
    + set [prefix] [key] [value]                                              | Set core variables
      - keys: cpu.socket, cpu.core, memory, sys[linux,win,bsd] arch[intel,amd]
      - keys: auto.boot, vnc.wait
    - destroy [prefix]                                                        | Destroy virtual machine
    + list                                                                    | List virtual machine
 
    [Disk Management Commands]
    + disk create [prefix] [storage] [name] [size]                            | Create new disk
    + disk attach [prefix] [file] [desc] [slot] [ahci/virtio]                 | Attach Disk into VM
    + disk detach [prefix] [file]                                             | Detach Disk from VM
    + disk destroy [prefix] [ID/file]                                         | Delete Disk
    + disk resize [prefix] [file] [new_size]                                  | Resize Disk
    + disk list [prefix]                                                      | List Disks
 
    [CDROM Commands]
    + cdrom attach [prefix] [iso_file]                                        | Attach ISO file as CD-ROM
    + cdrom detach [prefix] [iso_file]                                        | Detach ISO
    + cdrom list [prefix]                                                     | List ISO Images
 
    [Network Commands]
    + nic add_virtio [prefix] [switch] {mac_addr}                             | Add VirtIO/NIC bound to switch
    + nic add_legacy [prefix] [switch] {mac_addr}                             | Add Intel/NIC bound to switch
    + nic change [prefix] [NIC] [switch]                                      | Change Switch
    + nic enable [prefix] [NIC]                                               | Enable NIC
    + nic disable [prefix] [NIC]                                              | Disable NIC
    + nic remove [prefix] [NIC]                                               | Remove NIC
    + nic list [prefix]                                                       | List Interfaces
 



API Reference / Storage Submenu

  _> storage
  * [storage] Available Commands:
  [Basic Commands]
  + list {active}                               | List Storages
  + create [mountpoint] [description]           | Enable new storage
  + modify [mountpoint] [desc] {enable/disable} | Modify existing storage
  + destroy [mountpoint]                        | Destroy Storage



API Reference / Switch Submenu

  _> switch
  * [switch] Available Commands:
  [Basic Commands]
  + create [prefix] [description]                                                       | Create new vSwitch
  + destroy [prefix]                                                                    | Destroy vSwitch
  + desc [prefix] [description]                                                         | Rename vSwitch
  + reload                                                                              | Reload Configuration
  + cleanup                                                                             | Clear OS configuration
  + bound [prefix] [iface]                                                              | Bound to network interface
  + unbound [prefix]                                                                    | UnBound from network interface
  + list                                                                                | List vSwitch
  + listDevs                                                                            | List Network Cards
  



API Reference / User Submenu

  _> user
  * [user] Available Commands:
  + ipinfo [ip_addr]                                                  | Show IP Geo Info
  + fetch [userID/mail/ALL]                                           | Get list of user(s)
  + logauth [mail] [TYPE] [IP] [CUID] [EXT]                           | Log Authentication
  + authlog [mail/ALL]                                                | Retrieve Authentication Logs
  + change [mail/ID] [new_name] [new_mail] [new_password (optional)]  | Modify User Settings
  + role [mail/ID] [USER/ADMIN]                                       | Modify User Role
  + create [name] [mail] [passwd]                                     | Create new user account
  + delete [mail/userID]                                              | Delete user account
  



API Reference / Config Submenu

    _> config
    * [config] Available Commands:
    [Basic Commands]
    + set [key] [value]   | Set config variable
    + get [key]           | Get config variable
    + del [key]           | Delete config variable