Skip to content

Commit 1035aad

Browse files
author
olevole
committed
fix errcode, add freejname to auto-assign VM name
1 parent 01cec58 commit 1035aad

File tree

8 files changed

+1507
-290
lines changed

8 files changed

+1507
-290
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,9 @@
22
src
33
./cbsd-mq-api
44
cbsd-mq-api
5+
README.IAC.md
6+
cbsd-mq-api-apply
7+
client
8+
common.yaml
9+
hiera.yaml
10+
init.pp

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
BSD 2-Clause License
22

3-
Copyright (c) 2021, CBSD Project
3+
Copyright (c) 2024, CBSD Project
44
All rights reserved.
55

66
Redistribution and use in source and binary forms, with or without

README.md

+39-18
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# CBSD RESTFull API
22

3-
Copyright (c) 2013-2021, The CBSD Development Team
4-
5-
Homepage: https://bsdstore.ru
3+
Copyright (c) 2013-2024, The CBSD Development Team
4+
Homepage: https://github.com/cbsd/cbsd
65

76
#### Table of Contents
87

@@ -30,7 +29,7 @@ ssh-ed25519 AAAA...yyy user2@@example.com
3029

3130
## Installation
3231

33-
Assuming you have a stock vanilla FreeBSD 13.0+ installation.
32+
Assuming you have a stock vanilla FreeBSD 14.0+ installation.
3433
The directives below configure a standalone installation ( single API + hoster env),
3534
however you can use any number of physical nodes for single API.
3635

@@ -41,7 +40,7 @@ pkg install -y cbsd cbsd-mq-router cbsd-mq-api beanstalkd git
4140

4241
2) Configure beanstalkd, the broker service.
4342

44-
Since all services are on the same server, we will specify the address 127.0.0.1
43+
Since all services are on the same server, we will specify the address 127.0.0.1
4544
for incoming connections and start the service:
4645
```
4746
sysrc beanstalkd_flags="-l 127.0.0.1 -p 11300"
@@ -144,18 +143,46 @@ service cbsd-mq-api start
144143

145144
## Usage
146145

147-
Valid endpoints:
146+
### Via curl, valid endpoints:
148147

149148
```
150149
curl -H "cid:<cid>" http://127.0.0.1:65531/api/v1/cluster
150+
curl -X POST -H "Content-Type: application/json" -d @filename.json http://127.0.0.1:65531/api/v1/create/vm1
151151
curl -H "cid:<cid>" http://127.0.0.1:65531/api/v1/status/<env>
152152
curl -H "cid:<cid>" http://127.0.0.1:65531/api/v1/start/<env>
153153
curl -H "cid:<cid>" http://127.0.0.1:65531/api/v1/stop/<env>
154154
curl -H "cid:<cid>" http://127.0.0.1:65531/api/v1/destroy/<env>
155155
```
156156
Where `<cid>` is your token/namespace. For convenience, in a *private cluster*,
157157
we suggest using md5 hash of your public key as <cid>.
158-
To test, lets create simple CBSDfile, where CLOUD_KEY - is your publickey string:
158+
159+
To test with curl, create valid payload file, e.g. `debian12.json`:
160+
```
161+
cat > debian11.json <<EOF
162+
{
163+
"imgsize": "10g",
164+
"ram": "1g",
165+
"cpus": 2,
166+
"image": "debian12",
167+
"pubkey": "ssh-ed25519 AAAA..XXX your@localhost"
168+
}
169+
EOF
170+
```
171+
Then send it to /create endpoint:
172+
```
173+
curl --no-progress-meter -X POST -H "Content-Type: application/json" -d @debian12.json http://127.0.0.1:65531/api/v1/create/vm1
174+
```
175+
176+
to create 'vm1' or:
177+
```
178+
curl --no-progress-meter -X POST -H "Content-Type: application/json" -d @debian12.json http://127.0.0.1:65531/api/v1/create/_
179+
```
180+
181+
to assign a VM name automatically.
182+
183+
### Via CBSDfile:
184+
185+
To test via CBSDfile, lets create simple CBSDfile, where CLOUD_KEY - is your publickey string:
159186
```
160187
CLOUD_URL="http://127.0.0.1:65531"
161188
CLOUD_KEY="ssh-ed25519 AAAA..XXX your@localhost"
@@ -181,17 +208,11 @@ cbsd destroy
181208

182209
See documentation for detailed information and additional examples: [https://www.bsdstore.ru/en/cbsd_api_ssi.html](https://www.bsdstore.ru/en/cbsd_api_ssi.html)
183210

184-
## Contributing
211+
## Get Support
185212

186-
* Fork me on GitHub: [https://github.com/cbsd/cbsd-mq-api.git](https://github.com/cbsd/cbsd-mq-api.git)
187-
* Switch to 'develop' branch
188-
* Commit your changes (`git commit -am 'Added some feature'`)
189-
* Push to the branch (`git push`)
190-
* Create new Pull Request
213+
* GitHub: https://github.com/cbsd/cbsd-mq-api/issues
214+
* For CBSD-related support, discussion and talks, please join to Telegram CBSD usergroup channel: @cbsdofficial ( [https://t.me/cbsdofficial](https://t.me/cbsdofficial)
191215

192-
## Support
216+
## Support Us
193217

194-
* For CBSD-related support, discussion and talks, please join to Telegram CBSD usergroup channel: @cbsdofficial
195-
* Web link: https://t.me/cbsdofficial
196-
* Or subscribe to mailing list by sending email to: [email protected]
197-
* Other contact: https://www.bsdstore.ru/en/feedback.html
218+
* https://www.patreon.com/clonos

config.go

+11-9
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@ import (
77
)
88

99
type Config struct {
10-
ServerUrl string `json:"server_url"`
11-
CbsdEnv string `json:"cbsdenv"`
12-
Broker string `json:"broker"`
13-
ImageList string `json:"imagelist"`
14-
Recomendation string `json:"recomendation"`
15-
Freejname string `json:"freejname"`
16-
Cloud_images_list string `json:"cloud_images_list"`
17-
Iso_images_list string `json:"iso_images_list"`
18-
BeanstalkConfig `json:"beanstalkd"`
10+
ServerUrl string `json:"server_url"`
11+
CbsdEnv string `json:"cbsdenv"`
12+
Broker string `json:"broker"`
13+
ImageList string `json:"imagelist"`
14+
Recomendation string `json:"recomendation"`
15+
Freejname string `json:"freejname"`
16+
Freeid string `json:"freeid"`
17+
Cloud_images_list string `json:"cloud_images_list"`
18+
Iso_images_list string `json:"iso_images_list"`
19+
Flavors_list string `json:"flavors_list"`
20+
BeanstalkConfig `json:"beanstalkd"`
1921
}
2022

2123
func LoadConfiguration(file string) (Config, error) {

etc/cbsd-mq-api.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
"logfile": "/dev/stdout",
66
"recomendation": "/usr/local/cbsd/modules/api.d/misc/recomendation.sh",
77
"freejname": "/usr/local/cbsd/modules/api.d/misc/freejname.sh",
8-
"server_url": "https://127.0.0.1",
8+
"freeid": "/usr/local/cbsd/modules/api.d/misc/freeid.sh",
9+
"server_url": "http://127.0.0.1:65531",
910
"cloud_images_list": "/usr/local/etc/cbsd_api_cloud_images.json",
1011
"iso_images_list": "/usr/local/etc/cbsd_api_iso_images.json",
12+
"flavors_list": "/usr/local/etc/cbsd_flavors.json",
1113
"beanstalkd": {
1214
"uri": "127.0.0.1:11300",
13-
"tube": "cbsd_zpool1",
14-
"reply_tube_prefix": "cbsd_zpool1_result_id",
15+
"tube": "cbsd_mother_olevole_ru",
16+
"reply_tube_prefix": "cbsd_mother_olevole_ru_result_id",
1517
"reconnect_timeout": 5,
1618
"reserve_timeout": 5,
1719
"publish_timeout": 5,

etc/cbsd_api_cloud_images.json

+29-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,42 @@
11
{
22
"images": [
3+
"alma9",
4+
"arch22",
35
"centos7",
4-
"centos8",
5-
"debian10",
6+
"centos9",
67
"debian11",
8+
"debian12",
9+
"devuan5",
10+
"dflybsd6",
11+
"euro9",
12+
"fedora39",
13+
"fedora40",
14+
"fedora41",
715
"freebsd13_ufs",
816
"freebsd13_zfs",
917
"freebsd14_ufs",
1018
"freebsd14_zfs",
19+
"freebsd15_ufs",
20+
"freebsd15_zfs",
21+
"freefire14_ufs",
22+
"freepbx",
23+
"ghostbsd24",
24+
"homeass",
25+
"jail",
26+
"kali2024",
27+
"k8s",
1128
"netbsd9",
29+
"netbsd10",
1230
"openbsd7",
13-
"opnsense21",
31+
"opnsense22",
1432
"oracle7",
1533
"oracle8",
16-
"rocky8",
17-
"ubuntu20"
34+
"oracle9",
35+
"rocky9",
36+
"ubuntu22",
37+
"ubuntu22_vdi",
38+
"ubuntu24",
39+
"ubuntu24_vdi",
40+
"xigmanas13"
1841
]
19-
}
42+
}

0 commit comments

Comments
 (0)