knife-ionoscloud 5.0.0.beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitbook.yaml +4 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +54 -0
- data/.github/ISSUE_TEMPLATE/config.yml +5 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +51 -0
- data/.github/workflows/ci.yml +38 -0
- data/.github/workflows/publish.yml +58 -0
- data/.gitignore +26 -0
- data/.rubocop.yml +148 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +201 -0
- data/Rakefile +7 -0
- data/docs/README.md +67 -0
- data/docs/changelog.md +1 -0
- data/docs/docs_generator.rb +107 -0
- data/docs/subcommands/backupunit_create.md +38 -0
- data/docs/subcommands/backupunit_delete.md +26 -0
- data/docs/subcommands/backupunit_list.md +26 -0
- data/docs/subcommands/backupunit_ssourl.md +30 -0
- data/docs/subcommands/composite_server_create.md +97 -0
- data/docs/subcommands/contract_list.md +26 -0
- data/docs/subcommands/datacenter_create.md +41 -0
- data/docs/subcommands/datacenter_delete.md +26 -0
- data/docs/subcommands/datacenter_list.md +26 -0
- data/docs/subcommands/firewall_create.md +65 -0
- data/docs/subcommands/firewall_delete.md +38 -0
- data/docs/subcommands/firewall_list.md +38 -0
- data/docs/subcommands/group_create.md +48 -0
- data/docs/subcommands/group_delete.md +26 -0
- data/docs/subcommands/group_get.md +30 -0
- data/docs/subcommands/group_list.md +29 -0
- data/docs/subcommands/group_user_add.md +30 -0
- data/docs/subcommands/group_user_remove.md +30 -0
- data/docs/subcommands/image_list.md +26 -0
- data/docs/subcommands/ipblock_create.md +37 -0
- data/docs/subcommands/ipblock_delete.md +26 -0
- data/docs/subcommands/ipblock_list.md +26 -0
- data/docs/subcommands/ipfailover_add.md +46 -0
- data/docs/subcommands/ipfailover_remove.md +42 -0
- data/docs/subcommands/k8s_create.md +39 -0
- data/docs/subcommands/k8s_delete.md +26 -0
- data/docs/subcommands/k8s_list.md +26 -0
- data/docs/subcommands/kubeconfig_get.md +30 -0
- data/docs/subcommands/label_add.md +45 -0
- data/docs/subcommands/label_list.md +35 -0
- data/docs/subcommands/label_remove.md +37 -0
- data/docs/subcommands/lan_create.md +36 -0
- data/docs/subcommands/lan_delete.md +30 -0
- data/docs/subcommands/lan_list.md +30 -0
- data/docs/subcommands/loadbalancer_create.md +43 -0
- data/docs/subcommands/loadbalancer_delete.md +30 -0
- data/docs/subcommands/loadbalancer_get.md +34 -0
- data/docs/subcommands/loadbalancer_list.md +30 -0
- data/docs/subcommands/loadbalancer_nic_add.md +34 -0
- data/docs/subcommands/loadbalancer_nic_remove.md +34 -0
- data/docs/subcommands/location_list.md +26 -0
- data/docs/subcommands/nic_create.md +51 -0
- data/docs/subcommands/nic_delete.md +34 -0
- data/docs/subcommands/nic_list.md +34 -0
- data/docs/subcommands/node_delete.md +34 -0
- data/docs/subcommands/node_list.md +34 -0
- data/docs/subcommands/node_replace.md +36 -0
- data/docs/subcommands/nodepool_create.md +87 -0
- data/docs/subcommands/nodepool_delete.md +30 -0
- data/docs/subcommands/nodepool_list.md +30 -0
- data/docs/subcommands/pcc_create.md +38 -0
- data/docs/subcommands/pcc_delete.md +26 -0
- data/docs/subcommands/pcc_list.md +26 -0
- data/docs/subcommands/request_list.md +32 -0
- data/docs/subcommands/request_status.md +30 -0
- data/docs/subcommands/request_wait.md +30 -0
- data/docs/subcommands/resource_list.md +34 -0
- data/docs/subcommands/s3key_create.md +30 -0
- data/docs/subcommands/s3key_delete.md +30 -0
- data/docs/subcommands/s3key_list.md +30 -0
- data/docs/subcommands/server_create.md +55 -0
- data/docs/subcommands/server_delete.md +32 -0
- data/docs/subcommands/server_list.md +30 -0
- data/docs/subcommands/server_reboot.md +30 -0
- data/docs/subcommands/server_start.md +30 -0
- data/docs/subcommands/server_stop.md +30 -0
- data/docs/subcommands/share_create.md +40 -0
- data/docs/subcommands/share_delete.md +30 -0
- data/docs/subcommands/share_list.md +30 -0
- data/docs/subcommands/snapshot_create.md +34 -0
- data/docs/subcommands/snapshot_delete.md +26 -0
- data/docs/subcommands/snapshot_list.md +26 -0
- data/docs/subcommands/snapshot_restore.md +38 -0
- data/docs/subcommands/user_create.md +49 -0
- data/docs/subcommands/user_delete.md +26 -0
- data/docs/subcommands/user_list.md +29 -0
- data/docs/subcommands/user_ssourl.md +30 -0
- data/docs/subcommands/volume_attach.md +34 -0
- data/docs/subcommands/volume_create.md +63 -0
- data/docs/subcommands/volume_delete.md +30 -0
- data/docs/subcommands/volume_detach.md +36 -0
- data/docs/subcommands/volume_list.md +33 -0
- data/docs/summary.md +89 -0
- data/docs/templates/subcommand_doc.mustache +26 -0
- data/docs/templates/summary.mustache +10 -0
- data/knife-ionoscloud.gemspec +27 -0
- data/lib/chef/knife/ionoscloud_backupunit_create.rb +63 -0
- data/lib/chef/knife/ionoscloud_backupunit_delete.rb +55 -0
- data/lib/chef/knife/ionoscloud_backupunit_list.rb +41 -0
- data/lib/chef/knife/ionoscloud_backupunit_ssourl.rb +39 -0
- data/lib/chef/knife/ionoscloud_base.rb +76 -0
- data/lib/chef/knife/ionoscloud_composite_server_create.rb +217 -0
- data/lib/chef/knife/ionoscloud_contract_list.rb +50 -0
- data/lib/chef/knife/ionoscloud_datacenter_create.rb +66 -0
- data/lib/chef/knife/ionoscloud_datacenter_delete.rb +56 -0
- data/lib/chef/knife/ionoscloud_datacenter_list.rb +50 -0
- data/lib/chef/knife/ionoscloud_firewall_create.rb +135 -0
- data/lib/chef/knife/ionoscloud_firewall_delete.rb +76 -0
- data/lib/chef/knife/ionoscloud_firewall_list.rb +72 -0
- data/lib/chef/knife/ionoscloud_group_create.rb +89 -0
- data/lib/chef/knife/ionoscloud_group_delete.rb +61 -0
- data/lib/chef/knife/ionoscloud_group_get.rb +46 -0
- data/lib/chef/knife/ionoscloud_group_list.rb +62 -0
- data/lib/chef/knife/ionoscloud_group_user_add.rb +72 -0
- data/lib/chef/knife/ionoscloud_group_user_remove.rb +72 -0
- data/lib/chef/knife/ionoscloud_image_list.rb +47 -0
- data/lib/chef/knife/ionoscloud_ipblock_create.rb +63 -0
- data/lib/chef/knife/ionoscloud_ipblock_delete.rb +50 -0
- data/lib/chef/knife/ionoscloud_ipblock_list.rb +42 -0
- data/lib/chef/knife/ionoscloud_ipfailover_add.rb +76 -0
- data/lib/chef/knife/ionoscloud_ipfailover_remove.rb +76 -0
- data/lib/chef/knife/ionoscloud_k8s_create.rb +79 -0
- data/lib/chef/knife/ionoscloud_k8s_delete.rb +67 -0
- data/lib/chef/knife/ionoscloud_k8s_list.rb +45 -0
- data/lib/chef/knife/ionoscloud_kubeconfig_get.rb +37 -0
- data/lib/chef/knife/ionoscloud_label_add.rb +84 -0
- data/lib/chef/knife/ionoscloud_label_list.rb +83 -0
- data/lib/chef/knife/ionoscloud_label_remove.rb +77 -0
- data/lib/chef/knife/ionoscloud_lan_create.rb +69 -0
- data/lib/chef/knife/ionoscloud_lan_delete.rb +54 -0
- data/lib/chef/knife/ionoscloud_lan_list.rb +46 -0
- data/lib/chef/knife/ionoscloud_loadbalancer_create.rb +87 -0
- data/lib/chef/knife/ionoscloud_loadbalancer_delete.rb +68 -0
- data/lib/chef/knife/ionoscloud_loadbalancer_get.rb +51 -0
- data/lib/chef/knife/ionoscloud_loadbalancer_list.rb +50 -0
- data/lib/chef/knife/ionoscloud_loadbalancer_nic_add.rb +75 -0
- data/lib/chef/knife/ionoscloud_loadbalancer_nic_remove.rb +76 -0
- data/lib/chef/knife/ionoscloud_location_list.rb +38 -0
- data/lib/chef/knife/ionoscloud_nic_create.rb +104 -0
- data/lib/chef/knife/ionoscloud_nic_delete.rb +62 -0
- data/lib/chef/knife/ionoscloud_nic_list.rb +57 -0
- data/lib/chef/knife/ionoscloud_node_delete.rb +65 -0
- data/lib/chef/knife/ionoscloud_node_list.rb +55 -0
- data/lib/chef/knife/ionoscloud_node_replace.rb +54 -0
- data/lib/chef/knife/ionoscloud_nodepool_create.rb +163 -0
- data/lib/chef/knife/ionoscloud_nodepool_delete.rb +60 -0
- data/lib/chef/knife/ionoscloud_nodepool_list.rb +51 -0
- data/lib/chef/knife/ionoscloud_pcc_create.rb +68 -0
- data/lib/chef/knife/ionoscloud_pcc_delete.rb +57 -0
- data/lib/chef/knife/ionoscloud_pcc_list.rb +41 -0
- data/lib/chef/knife/ionoscloud_request_list.rb +94 -0
- data/lib/chef/knife/ionoscloud_request_status.rb +37 -0
- data/lib/chef/knife/ionoscloud_request_wait.rb +41 -0
- data/lib/chef/knife/ionoscloud_resource_list.rb +81 -0
- data/lib/chef/knife/ionoscloud_s3key_create.rb +45 -0
- data/lib/chef/knife/ionoscloud_s3key_delete.rb +57 -0
- data/lib/chef/knife/ionoscloud_s3key_list.rb +46 -0
- data/lib/chef/knife/ionoscloud_server_create.rb +104 -0
- data/lib/chef/knife/ionoscloud_server_delete.rb +62 -0
- data/lib/chef/knife/ionoscloud_server_list.rb +58 -0
- data/lib/chef/knife/ionoscloud_server_reboot.rb +45 -0
- data/lib/chef/knife/ionoscloud_server_start.rb +43 -0
- data/lib/chef/knife/ionoscloud_server_stop.rb +44 -0
- data/lib/chef/knife/ionoscloud_share_create.rb +71 -0
- data/lib/chef/knife/ionoscloud_share_delete.rb +55 -0
- data/lib/chef/knife/ionoscloud_share_list.rb +47 -0
- data/lib/chef/knife/ionoscloud_snapshot_create.rb +58 -0
- data/lib/chef/knife/ionoscloud_snapshot_delete.rb +54 -0
- data/lib/chef/knife/ionoscloud_snapshot_list.rb +45 -0
- data/lib/chef/knife/ionoscloud_snapshot_restore.rb +69 -0
- data/lib/chef/knife/ionoscloud_user_create.rb +83 -0
- data/lib/chef/knife/ionoscloud_user_delete.rb +56 -0
- data/lib/chef/knife/ionoscloud_user_list.rb +60 -0
- data/lib/chef/knife/ionoscloud_user_ssourl.rb +37 -0
- data/lib/chef/knife/ionoscloud_volume_attach.rb +52 -0
- data/lib/chef/knife/ionoscloud_volume_create.rb +133 -0
- data/lib/chef/knife/ionoscloud_volume_delete.rb +67 -0
- data/lib/chef/knife/ionoscloud_volume_detach.rb +77 -0
- data/lib/chef/knife/ionoscloud_volume_list.rb +70 -0
- data/lib/knife-ionoscloud/version.rb +6 -0
- data/spec/chef/knife/ionoscloud_backupunit_create_spec.rb +65 -0
- data/spec/chef/knife/ionoscloud_backupunit_delete_spec.rb +101 -0
- data/spec/chef/knife/ionoscloud_backupunit_list_spec.rb +72 -0
- data/spec/chef/knife/ionoscloud_backupunit_ssourl_spec.rb +93 -0
- data/spec/chef/knife/ionoscloud_base_spec.rb +157 -0
- data/spec/chef/knife/ionoscloud_composite_server_create_spec.rb +111 -0
- data/spec/chef/knife/ionoscloud_contract_list_spec.rb +81 -0
- data/spec/chef/knife/ionoscloud_datacenter_create_spec.rb +72 -0
- data/spec/chef/knife/ionoscloud_datacenter_delete_spec.rb +102 -0
- data/spec/chef/knife/ionoscloud_datacenter_list_spec.rb +76 -0
- data/spec/chef/knife/ionoscloud_firewall_create_spec.rb +90 -0
- data/spec/chef/knife/ionoscloud_firewall_delete_spec.rb +117 -0
- data/spec/chef/knife/ionoscloud_firewall_list_spec.rb +90 -0
- data/spec/chef/knife/ionoscloud_group_create_spec.rb +76 -0
- data/spec/chef/knife/ionoscloud_group_delete_spec.rb +109 -0
- data/spec/chef/knife/ionoscloud_group_get_spec.rb +73 -0
- data/spec/chef/knife/ionoscloud_group_list_spec.rb +115 -0
- data/spec/chef/knife/ionoscloud_group_user_add_spec.rb +134 -0
- data/spec/chef/knife/ionoscloud_group_user_remove_spec.rb +130 -0
- data/spec/chef/knife/ionoscloud_image_list_spec.rb +75 -0
- data/spec/chef/knife/ionoscloud_ipblock_create_spec.rb +72 -0
- data/spec/chef/knife/ionoscloud_ipblock_delete_spec.rb +102 -0
- data/spec/chef/knife/ionoscloud_ipblock_list_spec.rb +74 -0
- data/spec/chef/knife/ionoscloud_ipfailover_add_spec.rb +83 -0
- data/spec/chef/knife/ionoscloud_ipfailover_remove_spec.rb +122 -0
- data/spec/chef/knife/ionoscloud_k8s_create_spec.rb +83 -0
- data/spec/chef/knife/ionoscloud_k8s_delete_spec.rb +172 -0
- data/spec/chef/knife/ionoscloud_k8s_list_spec.rb +73 -0
- data/spec/chef/knife/ionoscloud_kubeconfig_get_spec.rb +91 -0
- data/spec/chef/knife/ionoscloud_label_add_spec.rb +287 -0
- data/spec/chef/knife/ionoscloud_label_list_spec.rb +337 -0
- data/spec/chef/knife/ionoscloud_label_remove_spec.rb +391 -0
- data/spec/chef/knife/ionoscloud_lan_create_spec.rb +77 -0
- data/spec/chef/knife/ionoscloud_lan_delete_spec.rb +103 -0
- data/spec/chef/knife/ionoscloud_lan_list_spec.rb +73 -0
- data/spec/chef/knife/ionoscloud_loadbalancer_create_spec.rb +82 -0
- data/spec/chef/knife/ionoscloud_loadbalancer_delete_spec.rb +107 -0
- data/spec/chef/knife/ionoscloud_loadbalancer_get_spec.rb +68 -0
- data/spec/chef/knife/ionoscloud_loadbalancer_list_spec.rb +74 -0
- data/spec/chef/knife/ionoscloud_loadbalancer_nic_add_spec.rb +128 -0
- data/spec/chef/knife/ionoscloud_loadbalancer_nic_remove_spec.rb +124 -0
- data/spec/chef/knife/ionoscloud_location_list_spec.rb +67 -0
- data/spec/chef/knife/ionoscloud_nic_create_spec.rb +85 -0
- data/spec/chef/knife/ionoscloud_nic_delete_spec.rb +108 -0
- data/spec/chef/knife/ionoscloud_nic_list_spec.rb +83 -0
- data/spec/chef/knife/ionoscloud_node_delete_spec.rb +107 -0
- data/spec/chef/knife/ionoscloud_node_list_spec.rb +75 -0
- data/spec/chef/knife/ionoscloud_node_replace_spec.rb +94 -0
- data/spec/chef/knife/ionoscloud_nodepool_create_spec.rb +99 -0
- data/spec/chef/knife/ionoscloud_nodepool_delete_spec.rb +106 -0
- data/spec/chef/knife/ionoscloud_nodepool_list_spec.rb +76 -0
- data/spec/chef/knife/ionoscloud_pcc_create_spec.rb +70 -0
- data/spec/chef/knife/ionoscloud_pcc_delete_spec.rb +106 -0
- data/spec/chef/knife/ionoscloud_pcc_list_spec.rb +69 -0
- data/spec/chef/knife/ionoscloud_request_list_spec.rb +165 -0
- data/spec/chef/knife/ionoscloud_request_status_spec.rb +92 -0
- data/spec/chef/knife/ionoscloud_request_wait_spec.rb +74 -0
- data/spec/chef/knife/ionoscloud_resource_list_spec.rb +155 -0
- data/spec/chef/knife/ionoscloud_s3key_create_spec.rb +64 -0
- data/spec/chef/knife/ionoscloud_s3key_delete_spec.rb +103 -0
- data/spec/chef/knife/ionoscloud_s3key_list_spec.rb +70 -0
- data/spec/chef/knife/ionoscloud_server_create_spec.rb +84 -0
- data/spec/chef/knife/ionoscloud_server_delete_spec.rb +108 -0
- data/spec/chef/knife/ionoscloud_server_list_spec.rb +85 -0
- data/spec/chef/knife/ionoscloud_server_reboot_spec.rb +95 -0
- data/spec/chef/knife/ionoscloud_server_start_spec.rb +95 -0
- data/spec/chef/knife/ionoscloud_server_stop_spec.rb +95 -0
- data/spec/chef/knife/ionoscloud_share_create_spec.rb +68 -0
- data/spec/chef/knife/ionoscloud_share_delete_spec.rb +103 -0
- data/spec/chef/knife/ionoscloud_share_list_spec.rb +70 -0
- data/spec/chef/knife/ionoscloud_snapshot_create_spec.rb +74 -0
- data/spec/chef/knife/ionoscloud_snapshot_delete_spec.rb +103 -0
- data/spec/chef/knife/ionoscloud_snapshot_list_spec.rb +73 -0
- data/spec/chef/knife/ionoscloud_snapshot_restore_spec.rb +78 -0
- data/spec/chef/knife/ionoscloud_user_create_spec.rb +73 -0
- data/spec/chef/knife/ionoscloud_user_delete_spec.rb +104 -0
- data/spec/chef/knife/ionoscloud_user_list_spec.rb +103 -0
- data/spec/chef/knife/ionoscloud_user_ssourl_spec.rb +93 -0
- data/spec/chef/knife/ionoscloud_volume_attach_spec.rb +99 -0
- data/spec/chef/knife/ionoscloud_volume_create_spec.rb +143 -0
- data/spec/chef/knife/ionoscloud_volume_delete_spec.rb +108 -0
- data/spec/chef/knife/ionoscloud_volume_detach_spec.rb +110 -0
- data/spec/chef/knife/ionoscloud_volume_list_spec.rb +118 -0
- data/spec/spec_helper.rb +702 -0
- data/spec/test.sh +3 -0
- data/summary.md +0 -0
- metadata +460 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
# {{name}}
|
2
|
+
|
3
|
+
{{description}}
|
4
|
+
|
5
|
+
{{banner}}
|
6
|
+
|
7
|
+
|
8
|
+
## Available options:
|
9
|
+
---
|
10
|
+
|
11
|
+
### Required options:
|
12
|
+
{{#required_options}}
|
13
|
+
* {{.}}
|
14
|
+
{{/required_options}}
|
15
|
+
|
16
|
+
```
|
17
|
+
{{#options}}
|
18
|
+
{{name}}: {{long}}{{#short}}, {{short}}{{/short}}
|
19
|
+
{{{description}}}{{#required}} (required){{/required}}
|
20
|
+
|
21
|
+
{{/options}}
|
22
|
+
```
|
23
|
+
|
24
|
+
## Example
|
25
|
+
|
26
|
+
{{example}}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'knife-ionoscloud/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'knife-ionoscloud'
|
9
|
+
spec.version = Knife::Ionoscloud::VERSION
|
10
|
+
spec.authors = ['IONOS Cloud']
|
11
|
+
spec.email = ['sdk@cloud.ionos.com']
|
12
|
+
spec.summary = 'Chef Knife plugin for Ionoscloud platform'
|
13
|
+
spec.description = 'Official Chef Knife plugin for Ionoscloud platform using REST API'
|
14
|
+
spec.homepage = 'https://github.com/ionos-cloud/knife-ionos-cloud'
|
15
|
+
spec.license = 'Apache-2.0'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_runtime_dependency 'chef', '~> 16.10', '>= 16.10.17'
|
23
|
+
spec.add_runtime_dependency 'ionoscloud', '~> 5.0'
|
24
|
+
|
25
|
+
spec.add_development_dependency 'rspec', '~> 3.10'
|
26
|
+
spec.add_development_dependency 'simplecov', '~> 0.21.2'
|
27
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require_relative 'ionoscloud_base'
|
2
|
+
|
3
|
+
class Chef
|
4
|
+
class Knife
|
5
|
+
class IonoscloudBackupunitCreate < Knife
|
6
|
+
include Knife::IonoscloudBase
|
7
|
+
|
8
|
+
banner 'knife ionoscloud backupunit create (options)'
|
9
|
+
|
10
|
+
option :name,
|
11
|
+
short: '-n NAME',
|
12
|
+
long: '--name NAME',
|
13
|
+
description: 'Alphanumeric name you want assigned to the backup unit'
|
14
|
+
|
15
|
+
option :password,
|
16
|
+
short: '-p PASSWORD',
|
17
|
+
long: '--password PASSWORD',
|
18
|
+
description: 'Alphanumeric password you want assigned to the backup unit'
|
19
|
+
|
20
|
+
option :email,
|
21
|
+
short: '-e EMAIL',
|
22
|
+
long: '--email EMAIL',
|
23
|
+
description: 'The e-mail address you want assigned to the backup unit.'
|
24
|
+
|
25
|
+
attr_reader :description, :required_options
|
26
|
+
|
27
|
+
def initialize(args = [])
|
28
|
+
super(args)
|
29
|
+
@description =
|
30
|
+
'Create a new backup unit.'
|
31
|
+
@required_options = [:name, :password, :email, :ionoscloud_username, :ionoscloud_password]
|
32
|
+
end
|
33
|
+
|
34
|
+
def run
|
35
|
+
$stdout.sync = true
|
36
|
+
validate_required_params(@required_options, config)
|
37
|
+
|
38
|
+
print "#{ui.color('Creating Backup unit...', :magenta)}"
|
39
|
+
|
40
|
+
backupunit_api = Ionoscloud::BackupUnitApi.new(api_client)
|
41
|
+
|
42
|
+
backupunit, _, headers = backupunit_api.backupunits_post_with_http_info({
|
43
|
+
properties: {
|
44
|
+
name: config[:name],
|
45
|
+
password: config[:password],
|
46
|
+
email: config[:email],
|
47
|
+
}.compact,
|
48
|
+
})
|
49
|
+
|
50
|
+
dot = ui.color('.', :magenta)
|
51
|
+
api_client.wait_for { print dot; is_done? get_request_id headers }
|
52
|
+
|
53
|
+
puts backupunit
|
54
|
+
|
55
|
+
puts "\n"
|
56
|
+
puts "#{ui.color('ID', :cyan)}: #{backupunit.id}"
|
57
|
+
puts "#{ui.color('Name', :cyan)}: #{backupunit.properties.name}"
|
58
|
+
puts "#{ui.color('Email', :cyan)}: #{backupunit.properties.email}"
|
59
|
+
puts 'done'
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require_relative 'ionoscloud_base'
|
2
|
+
|
3
|
+
class Chef
|
4
|
+
class Knife
|
5
|
+
class IonoscloudBackupunitDelete < Knife
|
6
|
+
include Knife::IonoscloudBase
|
7
|
+
|
8
|
+
banner 'knife ionoscloud backupunit delete BACKUPUNIT_ID [BACKUPUNIT_ID]'
|
9
|
+
|
10
|
+
attr_reader :description, :required_options
|
11
|
+
|
12
|
+
def initialize(args = [])
|
13
|
+
super(args)
|
14
|
+
@description =
|
15
|
+
'A backup unit may be deleted using a DELETE request. Deleting a backup unit '\
|
16
|
+
'is a dangerous operation. A successful DELETE request will remove the backup '\
|
17
|
+
'plans inside a backup unit, ALL backups associated with the backup unit, the '\
|
18
|
+
'backup user and finally the backup unit itself.'
|
19
|
+
@required_options = [:ionoscloud_username, :ionoscloud_password]
|
20
|
+
end
|
21
|
+
|
22
|
+
def run
|
23
|
+
$stdout.sync = true
|
24
|
+
validate_required_params(@required_options, config)
|
25
|
+
|
26
|
+
backupunit_api = Ionoscloud::BackupUnitApi.new(api_client)
|
27
|
+
|
28
|
+
@name_args.each do |backupunit_id|
|
29
|
+
begin
|
30
|
+
backupunit = backupunit_api.backupunits_find_by_id(backupunit_id)
|
31
|
+
rescue Ionoscloud::ApiError => err
|
32
|
+
raise err unless err.code == 404
|
33
|
+
ui.error("Backup unit ID #{backupunit_id} not found. Skipping.")
|
34
|
+
next
|
35
|
+
end
|
36
|
+
|
37
|
+
msg_pair('ID', backupunit.id)
|
38
|
+
msg_pair('Name', backupunit.properties.name)
|
39
|
+
msg_pair('Email', backupunit.properties.email)
|
40
|
+
|
41
|
+
puts "\n"
|
42
|
+
|
43
|
+
begin
|
44
|
+
confirm('Do you really want to delete this Backup unit')
|
45
|
+
rescue SystemExit => exc
|
46
|
+
next
|
47
|
+
end
|
48
|
+
|
49
|
+
_, _, headers = backupunit_api.backupunits_delete_with_http_info(backupunit_id)
|
50
|
+
ui.warn("Deleted Backup unit #{backupunit.id}. Request ID: #{get_request_id headers}")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require_relative 'ionoscloud_base'
|
2
|
+
|
3
|
+
class Chef
|
4
|
+
class Knife
|
5
|
+
class IonoscloudBackupunitList < Knife
|
6
|
+
include Knife::IonoscloudBase
|
7
|
+
|
8
|
+
banner 'knife ionoscloud backupunit list'
|
9
|
+
|
10
|
+
attr_reader :description, :required_options
|
11
|
+
|
12
|
+
def initialize(args = [])
|
13
|
+
super(args)
|
14
|
+
@description =
|
15
|
+
'Retrieve a list of all the backup units the supplied credentials have access to.'
|
16
|
+
@required_options = [:ionoscloud_username, :ionoscloud_password]
|
17
|
+
end
|
18
|
+
|
19
|
+
def run
|
20
|
+
$stdout.sync = true
|
21
|
+
validate_required_params(@required_options, config)
|
22
|
+
|
23
|
+
backupunit_list = [
|
24
|
+
ui.color('ID', :bold),
|
25
|
+
ui.color('Name', :bold),
|
26
|
+
ui.color('Email', :bold),
|
27
|
+
]
|
28
|
+
|
29
|
+
backupunit_api = Ionoscloud::BackupUnitApi.new(api_client)
|
30
|
+
|
31
|
+
backupunit_api.backupunits_get({ depth: 1 }).items.each do |backupunit|
|
32
|
+
backupunit_list << backupunit.id
|
33
|
+
backupunit_list << backupunit.properties.name
|
34
|
+
backupunit_list << backupunit.properties.email
|
35
|
+
end
|
36
|
+
|
37
|
+
puts ui.list(backupunit_list, :uneven_columns_across, 3)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require_relative 'ionoscloud_base'
|
2
|
+
|
3
|
+
class Chef
|
4
|
+
class Knife
|
5
|
+
class IonoscloudBackupunitSsourl < Knife
|
6
|
+
include Knife::IonoscloudBase
|
7
|
+
|
8
|
+
banner 'knife ionoscloud backupunit ssourl (options)'
|
9
|
+
|
10
|
+
option :backupunit_id,
|
11
|
+
short: '-B BACKUPUNIT_ID',
|
12
|
+
long: '--backupunit-id BACKUPUNIT_ID',
|
13
|
+
description: 'The ID of the Backup unit.'
|
14
|
+
|
15
|
+
attr_reader :description, :required_options
|
16
|
+
|
17
|
+
def initialize(args = [])
|
18
|
+
super(args)
|
19
|
+
@description =
|
20
|
+
'The ProfitBricks backup system features a web-based GUI. Once you have created '\
|
21
|
+
'a backup unit, you can access the GUI with a Single Sign On (SSO) URL that can be '\
|
22
|
+
'retrieved from the Cloud API using this request.'
|
23
|
+
@required_options = [:backupunit_id, :ionoscloud_username, :ionoscloud_password]
|
24
|
+
end
|
25
|
+
|
26
|
+
def run
|
27
|
+
$stdout.sync = true
|
28
|
+
validate_required_params(@required_options, config)
|
29
|
+
|
30
|
+
begin
|
31
|
+
puts Ionoscloud::BackupUnitApi.new(api_client).backupunits_ssourl_get(config[:backupunit_id]).sso_url
|
32
|
+
rescue Ionoscloud::ApiError => err
|
33
|
+
raise err unless err.code == 404
|
34
|
+
ui.error("Backup unit ID #{config[:backupunit_id]} not found.")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'chef/knife'
|
2
|
+
|
3
|
+
class Chef
|
4
|
+
class Knife
|
5
|
+
module IonoscloudBase
|
6
|
+
def self.included(includer)
|
7
|
+
includer.class_eval do
|
8
|
+
deps do
|
9
|
+
require 'ionoscloud'
|
10
|
+
end
|
11
|
+
|
12
|
+
option :ionoscloud_username,
|
13
|
+
short: '-u USERNAME',
|
14
|
+
long: '--username USERNAME',
|
15
|
+
description: 'Your Ionoscloud username'
|
16
|
+
|
17
|
+
option :ionoscloud_password,
|
18
|
+
short: '-p PASSWORD',
|
19
|
+
long: '--password PASSWORD',
|
20
|
+
description: 'Your Ionoscloud password'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def msg_pair(label, value, color = :cyan)
|
25
|
+
if !value.nil? && !value.to_s.empty?
|
26
|
+
puts "#{ui.color(label, color)}: #{value}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def validate_required_params(required_params, params)
|
31
|
+
missing_params = required_params.select do |param|
|
32
|
+
params[param].nil?
|
33
|
+
end
|
34
|
+
if missing_params.any?
|
35
|
+
puts "Missing required parameters #{missing_params}"
|
36
|
+
exit(1)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def api_client
|
41
|
+
api_config = Ionoscloud::Configuration.new()
|
42
|
+
|
43
|
+
api_config.username = config[:ionoscloud_username]
|
44
|
+
api_config.password = config[:ionoscloud_password]
|
45
|
+
|
46
|
+
api_config.debugging = config[:ionoscloud_debug] || false
|
47
|
+
|
48
|
+
@api_client ||= Ionoscloud::ApiClient.new(api_config)
|
49
|
+
end
|
50
|
+
|
51
|
+
def get_request_id(headers)
|
52
|
+
begin
|
53
|
+
headers['Location'].scan(%r{/requests/(\b[0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}\b)}).last.first
|
54
|
+
rescue NoMethodError
|
55
|
+
nil
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def is_done?(request_id)
|
60
|
+
response = Ionoscloud::RequestApi.new(api_client).requests_status_get(request_id)
|
61
|
+
if response.metadata.status == 'FAILED'
|
62
|
+
puts "\nRequest #{request_id} failed\n#{response.metadata.message.to_s}"
|
63
|
+
exit(1)
|
64
|
+
end
|
65
|
+
response.metadata.status == 'DONE'
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# compact method will remove nil values from Hash
|
72
|
+
class Hash
|
73
|
+
def compact
|
74
|
+
delete_if { |_k, v| v.nil? }
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,217 @@
|
|
1
|
+
require_relative 'ionoscloud_base'
|
2
|
+
|
3
|
+
class Chef
|
4
|
+
class Knife
|
5
|
+
class IonoscloudCompositeServerCreate < Knife
|
6
|
+
include Knife::IonoscloudBase
|
7
|
+
|
8
|
+
banner 'knife ionoscloud composite server create (options)'
|
9
|
+
|
10
|
+
option :datacenter_id,
|
11
|
+
short: '-D DATACENTER_ID',
|
12
|
+
long: '--datacenter-id DATACENTER_ID',
|
13
|
+
description: 'Name of the virtual datacenter'
|
14
|
+
|
15
|
+
option :name,
|
16
|
+
short: '-n NAME',
|
17
|
+
long: '--name NAME',
|
18
|
+
description: '(required) Name of the server'
|
19
|
+
|
20
|
+
option :cores,
|
21
|
+
short: '-C CORES',
|
22
|
+
long: '--cores CORES',
|
23
|
+
description: '(required) The number of processor cores'
|
24
|
+
|
25
|
+
option :cpu_family,
|
26
|
+
short: '-f CPU_FAMILY',
|
27
|
+
long: '--cpu-family CPU_FAMILY',
|
28
|
+
description: 'The family of processor cores (INTEL_XEON or AMD_OPTERON)',
|
29
|
+
default: 'INTEL_SKYLAKE'
|
30
|
+
|
31
|
+
option :ram,
|
32
|
+
short: '-r RAM',
|
33
|
+
long: '--ram RAM',
|
34
|
+
description: '(required) The amount of RAM in MB'
|
35
|
+
|
36
|
+
option :availability_zone,
|
37
|
+
short: '-a AVAILABILITY_ZONE',
|
38
|
+
long: '--availability-zone AVAILABILITY_ZONE',
|
39
|
+
description: 'The availability zone of the server',
|
40
|
+
default: 'AUTO'
|
41
|
+
|
42
|
+
option :volume_name,
|
43
|
+
long: '--volume-name NAME',
|
44
|
+
description: 'Name of the volume'
|
45
|
+
|
46
|
+
option :size,
|
47
|
+
short: '-S SIZE',
|
48
|
+
long: '--size SIZE',
|
49
|
+
description: '(required) The size of the volume in GB'
|
50
|
+
|
51
|
+
option :bus,
|
52
|
+
short: '-b BUS',
|
53
|
+
long: '--bus BUS',
|
54
|
+
description: 'The bus type of the volume (VIRTIO or IDE)'
|
55
|
+
|
56
|
+
option :image,
|
57
|
+
short: '-N ID',
|
58
|
+
long: '--image ID',
|
59
|
+
description: '(required) The image or snapshot ID'
|
60
|
+
|
61
|
+
option :image_alias,
|
62
|
+
long: '--image-alias IMAGE_ALIAS',
|
63
|
+
description: '(required) The image alias'
|
64
|
+
|
65
|
+
option :type,
|
66
|
+
short: '-t TYPE',
|
67
|
+
long: '--type TYPE',
|
68
|
+
description: '(required) The disk type (HDD or SSD)'
|
69
|
+
|
70
|
+
option :licence_type,
|
71
|
+
short: '-l LICENCE',
|
72
|
+
long: '--licence-type LICENCE',
|
73
|
+
description: 'The licence type of the volume (LINUX, WINDOWS, WINDOWS2016, UNKNOWN, OTHER)'
|
74
|
+
|
75
|
+
option :image_password,
|
76
|
+
short: '-P PASSWORD',
|
77
|
+
long: '--image-password PASSWORD',
|
78
|
+
description: 'The password set on the image for the "root" or "Administrator" user'
|
79
|
+
|
80
|
+
option :volume_availability_zone,
|
81
|
+
short: '-Z AVAILABILITY_ZONE',
|
82
|
+
long: '--volume-availability-zone AVAILABILITY_ZONE',
|
83
|
+
description: 'The volume availability zone of the server'
|
84
|
+
|
85
|
+
option :ssh_keys,
|
86
|
+
short: '-K SSHKEY[,SSHKEY,...]',
|
87
|
+
long: '--ssh-keys SSHKEY1,SSHKEY2,...',
|
88
|
+
description: 'A list of public SSH keys to include'
|
89
|
+
|
90
|
+
option :nic_name,
|
91
|
+
long: '--nic-name NAME',
|
92
|
+
description: 'Name of the NIC'
|
93
|
+
|
94
|
+
option :ips,
|
95
|
+
short: '-i IP[,IP,...]',
|
96
|
+
long: '--ips IP[,IP,...]',
|
97
|
+
description: 'IPs assigned to the NIC'
|
98
|
+
|
99
|
+
option :dhcp,
|
100
|
+
short: '-h',
|
101
|
+
long: '--dhcp',
|
102
|
+
boolean: true | false,
|
103
|
+
default: true,
|
104
|
+
description: 'Set to false if you wish to disable DHCP'
|
105
|
+
|
106
|
+
option :lan,
|
107
|
+
short: '-L ID',
|
108
|
+
long: '--lan ID',
|
109
|
+
description: 'The LAN ID the NIC will reside on; if the LAN ID does not exist it will be created'
|
110
|
+
|
111
|
+
option :nat,
|
112
|
+
long: '--nat',
|
113
|
+
description: 'Set to enable NAT on the NIC'
|
114
|
+
|
115
|
+
attr_reader :description, :required_options
|
116
|
+
|
117
|
+
def initialize(args = [])
|
118
|
+
super(args)
|
119
|
+
@description =
|
120
|
+
'This creates a new composite server with an attached volume and NIC in a specified virtual data center.'
|
121
|
+
@required_options = [
|
122
|
+
:datacenter_id, :name, :cores, :ram, :size, :type, :dhcp, :lan, :ionoscloud_username, :ionoscloud_password,
|
123
|
+
]
|
124
|
+
end
|
125
|
+
|
126
|
+
def run
|
127
|
+
$stdout.sync = true
|
128
|
+
validate_required_params(@required_options, config)
|
129
|
+
|
130
|
+
if !config[:image] && !config[:image_alias]
|
131
|
+
ui.error('Either \'--image\' or \'--image-alias\' parameter must be provided')
|
132
|
+
exit(1)
|
133
|
+
end
|
134
|
+
|
135
|
+
if !config[:ssh_keys] && !config[:image_password]
|
136
|
+
ui.error('Either \'--image-password\' or \'--ssh-keys\' parameter must be provided')
|
137
|
+
exit(1)
|
138
|
+
end
|
139
|
+
|
140
|
+
if config[:ssh_keys]
|
141
|
+
config[:ssh_keys] = config[:ssh_keys].split(',')
|
142
|
+
end
|
143
|
+
|
144
|
+
if config[:ips]
|
145
|
+
config[:ips] = config[:ips].split(',')
|
146
|
+
end
|
147
|
+
|
148
|
+
print ui.color('Creating composite server...', :magenta).to_s
|
149
|
+
|
150
|
+
volume = Ionoscloud::Volume.new(
|
151
|
+
properties: Ionoscloud::VolumeProperties.new({
|
152
|
+
name: config[:volume_name],
|
153
|
+
size: config[:size],
|
154
|
+
bus: config[:bus] || 'VIRTIO',
|
155
|
+
image: config[:image],
|
156
|
+
image_alias: config[:image_alias],
|
157
|
+
ssh_keys: config[:ssh_keys],
|
158
|
+
image_password: config[:image_password],
|
159
|
+
type: config[:type],
|
160
|
+
licence_type: config[:licence_type],
|
161
|
+
availability_zone: config[:volume_availability_zone],
|
162
|
+
}.compact)
|
163
|
+
)
|
164
|
+
|
165
|
+
nic = Ionoscloud::Nic.new(
|
166
|
+
properties: Ionoscloud::NicProperties.new({
|
167
|
+
name: config[:nic_name],
|
168
|
+
ips: config[:ips],
|
169
|
+
dhcp: config[:dhcp],
|
170
|
+
lan: config[:lan],
|
171
|
+
nat: !config[:nat].nil?,
|
172
|
+
}.compact)
|
173
|
+
)
|
174
|
+
|
175
|
+
|
176
|
+
server = Ionoscloud::Server.new(
|
177
|
+
properties: Ionoscloud::ServerProperties.new({
|
178
|
+
name: config[:name],
|
179
|
+
cores: config[:cores],
|
180
|
+
cpu_family: config[:cpu_family],
|
181
|
+
ram: config[:ram],
|
182
|
+
availability_zone: config[:availability_zone],
|
183
|
+
}.compact),
|
184
|
+
entities: Ionoscloud::ServerEntities.new(
|
185
|
+
volumes: {
|
186
|
+
items: [volume],
|
187
|
+
},
|
188
|
+
nics: {
|
189
|
+
items: [nic],
|
190
|
+
},
|
191
|
+
),
|
192
|
+
)
|
193
|
+
|
194
|
+
server_api = Ionoscloud::ServerApi.new(api_client)
|
195
|
+
|
196
|
+
server, _, headers = server_api.datacenters_servers_post_with_http_info(config[:datacenter_id], server)
|
197
|
+
|
198
|
+
dot = ui.color('.', :magenta)
|
199
|
+
api_client.wait_for { print dot; is_done? get_request_id headers }
|
200
|
+
|
201
|
+
server = server_api.datacenters_servers_find_by_id(config[:datacenter_id], server.id)
|
202
|
+
|
203
|
+
puts "\n"
|
204
|
+
puts "#{ui.color('ID', :cyan)}: #{server.id}"
|
205
|
+
puts "#{ui.color('Name', :cyan)}: #{server.properties.name}"
|
206
|
+
puts "#{ui.color('Cores', :cyan)}: #{server.properties.cores}"
|
207
|
+
puts "#{ui.color('CPU Family', :cyan)}: #{server.properties.cpu_family}"
|
208
|
+
puts "#{ui.color('Ram', :cyan)}: #{server.properties.ram}"
|
209
|
+
puts "#{ui.color('Availability Zone', :cyan)}: #{server.properties.availability_zone}"
|
210
|
+
puts "#{ui.color('Boot Volume', :cyan)}: #{server.properties.boot_volume ? server.properties.boot_volume.id : ''}"
|
211
|
+
puts "#{ui.color('Boot CDROM', :cyan)}: #{server.properties.boot_cdrom ? server.properties.boot_cdrom.id : ''}"
|
212
|
+
|
213
|
+
puts 'done'
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|