Jails

Resources related to FreeBSD Jails.

Configuration

The Configuration resource exposes settings related to jails.

List resource

GET /api/v1.0/jails/configuration/

Returns the configuration dictionary.

Example request:

GET /api/v1.0/jails/configuration/ HTTP/1.1
Content-Type: application/json

Example response:

HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json

  {
    "id": 1,
    "jc_collectionurl": "http://cdn.freenas.org/latest/RELEASE/x64/jails",
    "jc_ipv4_network": "192.168.3.0/24",
    "jc_ipv4_network_end": "192.168.3.254",
    "jc_ipv4_network_start": "192.168.3.34",
    "jc_ipv6_network": "",
    "jc_ipv6_network_end": "",
    "jc_ipv6_network_start": "",
    "jc_path": "/mnt/tank/jails"
  }
Query Parameters:
 
  • offset – offset number. default is 0
  • limit – limit number. default is 20
Response Headers:
 
  • Content-Type – content type of the response
Status Codes:
  • 200 – no error

Update resource

PUT /api/v1.0/jails/configuration/

Update the configuration dictionary.

Example request:

PUT /api/v1.0/jails/configuration/ HTTP/1.1
Content-Type: application/json

  {
    "jc_ipv4_network_start": "192.168.3.50"
  }

Example response:

HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json

  {
    "id": 1,
    "jc_collectionurl": "http://cdn.freenas.org/latest/RELEASE/x64/jails",
    "jc_ipv4_network": "192.168.3.0/24",
    "jc_ipv4_network_end": "192.168.3.254",
    "jc_ipv4_network_start": "192.168.3.50",
    "jc_ipv6_network": "",
    "jc_ipv6_network_end": "",
    "jc_ipv6_network_start": "",
    "jc_path": "/mnt/tank/jails"
  }
JSON Parameters:
 
  • jc_collectionurl (string) – URL for the jail index
  • jc_ipv4_network (string) – IPv4 network range for jails and plugins
  • jc_ipv4_network_start (string) – IPv4 Network Start Address
  • jc_ipv4_network_end (string) – IPv4 Network End Address
  • jc_ipv6_network (string) – IPv6 network range for jails and plugins
  • jc_ipv6_network_start (string) – IPv6 network start address for jails and plugins
  • jc_ipv6_network_end (string) – IPv6 network end address for jails and plugins
  • jc_path (string) – dataset the jails will reside within
Query Parameters:
 
  • offset – offset number. default is 0
  • limit – limit number. default is 20
Response Headers:
 
  • Content-Type – content type of the response
Status Codes:
  • 200 – no error

Jails

The Jails resource represents FreeBSD Jails.

List resource

GET /api/v1.0/jails/jails/

Returns a list of all jails.

Example request:

GET /api/v1.0/jails/jails/ HTTP/1.1
Content-Type: application/json

Example response:

HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json

[
  {
    "id": 1,
    "jail_alias_bridge_ipv4": null,
    "jail_alias_bridge_ipv6": null,
    "jail_alias_ipv4": null,
    "jail_alias_ipv6": null,
    "jail_autostart": True,
    "jail_bridge_ipv4": null,
    "jail_bridge_ipv4_netmask": "",
    "jail_bridge_ipv6": null,
    "jail_bridge_ipv6_prefix": "",
    "jail_defaultrouter_ipv4": null,
    "jail_defaultrouter_ipv6": null,
    "jail_flags": "allow.raw_sockets=true",
    "jail_host": "transmission_1",
    "jail_ipv4": "192.168.3.2",
    "jail_ipv4_netmask": "24",
    "jail_ipv6": null,
    "jail_ipv6_prefix": "",
    "jail_mac": "02:c3:79:00:08:0b",
    "jail_nat": false,
    "jail_status": "Running",
    "jail_type": "pluginjail",
    "jail_vnet": true
  }
]
Query Parameters:
 
  • offset – offset number. default is 0
  • limit – limit number. default is 20
Response Headers:
 
  • Content-Type – content type of the response
Status Codes:
  • 200 – no error

Create resource

POST /api/v1.0/jails/jails/

Creates a new jail and returns the new jail object.

Example request:

POST /api/v1.0/jails/jails/ HTTP/1.1
Content-Type: application/json

  {
    "jail_host": "test"
  }

Example response:

HTTP/1.1 201 Created
Vary: Accept
Content-Type: application/json

  {
    "id": 1,
    "jail_alias_bridge_ipv4": null,
    "jail_alias_bridge_ipv6": null,
    "jail_alias_ipv4": null,
    "jail_alias_ipv6": null,
    "jail_autostart": true,
    "jail_bridge_ipv4": null,
    "jail_bridge_ipv4_netmask": "",
    "jail_bridge_ipv6": null,
    "jail_bridge_ipv6_prefix": "",
    "jail_defaultrouter_ipv4": null,
    "jail_defaultrouter_ipv6": null,
    "jail_flags": "allow.raw_sockets=true",
    "jail_host": "transmission_1",
    "jail_ipv4": "192.168.3.2",
    "jail_ipv4_netmask": "24",
    "jail_ipv6": null,
    "jail_ipv6_prefix": "",
    "jail_mac": "02:c3:79:00:08:0b",
    "jail_nat": false,
    "jail_status": "Running",
    "jail_type": "pluginjail",
    "jail_vnet": true
  }
JSON Parameters:
 
  • jail_alias_bridge_ipv4 (string) – ipv4 bridge address
  • jail_alias_bridge_ipv6 (string) – ipv6 bridge address
  • jail_alias_ipv4 (string) – ipv4 address aliases
  • jail_alias_ipv6 (string) – ipv6 address aliases
  • jail_autostart (boolean) – automatically start jail at boot
  • jail_bridge_ipv4 (string) – ipv4 bridge
  • jail_bridge_ipv4_netmask (string) – ipv4 netmask
  • jail_bridge_ipv6 (string) – ipv6 bridge
  • jail_bridge_ipv6_prefix (string) – ipv6 prefix
  • jail_defaultrouter_ipv4 (string) – ipv4 default route
  • jail_defaultrouter_ipv6 (string) – ipv6 default route
  • jail_flags (string) – sysctl jail flags
  • jail_host (string) – hostname of the jail
  • jail_ipv4 (string) – ipv4 address of the jail
  • jail_ipv4_netmask (string) – ipv4 netmask (8, 16, 24, 32)
  • jail_ipv6 (string) – ipv6 address of the jail
  • jail_ipv6_prefix (string) – ipv6 prefix
  • jail_mac (string) – mac address for the jail interface
  • jail_nat (boolean) – enable NAT for the jail
  • jail_status (string) – current status of the jail
  • jail_type (string) – template name from /api/v1.0/jails/templates/
  • jail_vnet (boolean) – enable VIMAGE for the jail
Request Headers:
 
  • Content-Type – the request content type
Response Headers:
 
  • Content-Type – the response content type
Status Codes:
  • 201 – no error

Start jail

POST /api/v1.0/jails/jails/(int: id)/start/

Starts a jail.

Example request:

POST /api/v1.0/jails/jails/1/start/ HTTP/1.1
Content-Type: application/json

Example response:

HTTP/1.1 202 Accepted
Vary: Accept
Content-Type: application/json

  Jail started.
Request Headers:
 
  • Content-Type – the request content type
Response Headers:
 
  • Content-Type – the response content type
Status Codes:
  • 202 – no error

Stop jail

POST /api/v1.0/jails/jails/(int: id)/stop/

Stops a jail.

Example request:

POST /api/v1.0/jails/jails/1/stop/ HTTP/1.1
Content-Type: application/json

Example response:

HTTP/1.1 202 Accepted
Vary: Accept
Content-Type: application/json

  Jail stopped.
Request Headers:
 
  • Content-Type – the request content type
Response Headers:
 
  • Content-Type – the response content type
Status Codes:
  • 202 – no error

Restart jail

POST /api/v1.0/jails/jails/(int: id)/restart/

Starts a jail.

Example request:

POST /api/v1.0/jails/jails/1/restart/ HTTP/1.1
Content-Type: application/json

Example response:

HTTP/1.1 202 Accepted
Vary: Accept
Content-Type: application/json

  Jail restarted.
Request Headers:
 
  • Content-Type – the request content type
Response Headers:
 
  • Content-Type – the response content type
Status Codes:
  • 202 – no error

Delete resource

DELETE /api/v1.0/jails/jails/(int: id)/

Delete jail id.

Example request:

DELETE /api/v1.0/jails/jails/2/ HTTP/1.1
Content-Type: application/json

Example response:

HTTP/1.1 204 No Response
Vary: Accept
Content-Type: application/json
Status Codes:
  • 204 – no error

MountPoints

The MountPoints resource represents filesystem mounts (nullfs) to jails.

List resource

GET /api/v1.0/jails/mountpoints/

Returns a list of all mountpoints.

Example request:

GET /api/v1.0/jails/mountpoints/ HTTP/1.1
Content-Type: application/json

Example response:

HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json

[
  {
    "id": 1,
    "destination": "/mnt",
    "jail": "transmission_1",
    "mounted": true,
    "readonly": false,
    "source": "/mnt/tank/test"
  }
]
Query Parameters:
 
  • offset – offset number. default is 0
  • limit – limit number. default is 20
Response Headers:
 
  • Content-Type – content type of the response
Status Codes:
  • 200 – no error

Create resource

POST /api/v1.0/jails/mountpoints/

Creates a new mountpoint and returns the object.

Example request:

POST /api/v1.0/jails/mountpoints/ HTTP/1.1
Content-Type: application/json

  {
    "destination": "/mnt",
    "jail": "transmission_1",
    "mounted": true,
    "readonly": false,
    "source": "/mnt/tank/test"
  }

Example response:

HTTP/1.1 201 Created
Vary: Accept
Content-Type: application/json

  {
    "id": 1,
    "destination": "/mnt",
    "jail": "transmission_1",
    "mounted": true,
    "readonly": false,
    "source": "/mnt/tank/test"
  }
JSON Parameters:
 
  • jail (string) – name of the jail
  • source (string) – path source in the host
  • destination (string) – path destination within the jail root
  • mounted (string) – where the path is/should be mounted
  • readonly (string) – mount as read-only
Request Headers:
 
  • Content-Type – the request content type
Response Headers:
 
  • Content-Type – the response content type
Status Codes:
  • 201 – no error

Update resource

PUT /api/v1.0/jails/mountpoints/(int: id)/

Updates a mountpoint object.

Example request:

PUT /api/v1.0/jails/mountpoints/1/ HTTP/1.1
Content-Type: application/json

  {
    "source": "/mnt/tank/test2"
  }

Example response:

HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json

  {
    "id": 1,
    "destination": "/mnt",
    "jail": "transmission_1",
    "mounted": true,
    "readonly": false,
    "source": "/mnt/tank/test2"
  }
JSON Parameters:
 
  • jail (string) – name of the jail
  • source (string) – path source in the host
  • destination (string) – path destination within the jail root
  • mounted (string) – where the path is/should be mounted
  • readonly (string) – mount as read-only
Request Headers:
 
  • Content-Type – the request content type
Response Headers:
 
  • Content-Type – the response content type
Status Codes:
  • 200 – no error

Delete resource

DELETE /api/v1.0/jails/mountpoints/(int: id)/

Delete mountpoint id.

Example request:

DELETE /api/v1.0/jails/mountpoints/1/ HTTP/1.1
Content-Type: application/json

Example response:

HTTP/1.1 204 No Response
Vary: Accept
Content-Type: application/json
Status Codes:
  • 204 – no error

Templates

The Templates resource represents templates to be used for FreeBSD Jails.

List resource

GET /api/v1.0/jails/templates/

Returns a list of all templates.

Example request:

GET /api/v1.0/jails/templates/ HTTP/1.1
Content-Type: application/json

Example response:

HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json

[
  {
    "id": 1,
    "jt_arch": "x64",
    "jt_instances": 0,
    "jt_name": "VirtualBox-4.3.12",
    "jt_os": "FreeBSD",
    "jt_url": "http://download.freenas.org/jails/9.2/x64/freenas-virtualbox-4.3.12.tgz"
  }
]
Query Parameters:
 
  • offset – offset number. default is 0
  • limit – limit number. default is 20
Response Headers:
 
  • Content-Type – content type of the response
Status Codes:
  • 200 – no error

Create resource

POST /api/v1.0/jails/templates/

Creates a new template and returns the new object.

Example request:

POST /api/v1.0/jails/templates/ HTTP/1.1
Content-Type: application/json

  {
    "jt_name": "My Template",
    "jt_os": "FreeBSD",
    "jt_arch": "x64",
    "jt_url": "http://example.com/jails/mytemplate_x64.tgz"
  }

Example response:

HTTP/1.1 201 Created
Vary: Accept
Content-Type: application/json

  {
    "id": 14,
    "jt_name": "My Template",
    "jt_os": "FreeBSD",
    "jt_arch": "x64",
    "jt_instances": 0,
    "jt_url": "http://example.com/jails/mytemplate_x64.tgz"
  }
JSON Parameters:
 
  • jt_name (string) – name of the template
  • jt_os (string) – type of the OS (FreeBSD/Linux)
  • jt_arch (string) – jail architecture (x64/x86)
  • jt_url (string) – url of the template
  • jt_instances (string) – read-only, number of instances using this template
Request Headers:
 
  • Content-Type – the request content type
Response Headers:
 
  • Content-Type – the response content type
Status Codes:
  • 201 – no error

Update resource

PUT /api/v1.0/jails/templates/(int: id)/

Updates a template object.

Example request:

PUT /api/v1.0/jails/templates/14/ HTTP/1.1
Content-Type: application/json

  {
    "jt_url": "http://example.com/jails/mytemplate_2_x64.tgz"
  }

Example response:

HTTP/1.1 200 OK
Vary: Accept
Content-Type: application/json

  {
    "id": 14,
    "jt_name": "My Template",
    "jt_os": "FreeBSD",
    "jt_arch": "x64",
    "jt_instances": 0,
    "jt_url": "http://example.com/jails/mytemplate_2_x64.tgz"
  }
JSON Parameters:
 
  • jt_name (string) – name of the template
  • jt_os (string) – type of the OS (FreeBSD/Linux)
  • jt_arch (string) – jail architecture (x64/x86)
  • jt_url (string) – url of the template
  • jt_instances (string) – read-only, number of instances using this template
Request Headers:
 
  • Content-Type – the request content type
Response Headers:
 
  • Content-Type – the response content type
Status Codes:
  • 200 – no error

Delete resource

DELETE /api/v1.0/jails/templates/(int: id)/

Delete template id.

Example request:

DELETE /api/v1.0/jails/templates/14/ HTTP/1.1
Content-Type: application/json

Example response:

HTTP/1.1 204 No Response
Vary: Accept
Content-Type: application/json
Status Codes:
  • 204 – no error