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,69 @@
|
|
1
|
+
require_relative 'ionoscloud_base'
|
2
|
+
|
3
|
+
class Chef
|
4
|
+
class Knife
|
5
|
+
class IonoscloudSnapshotRestore < Knife
|
6
|
+
include Knife::IonoscloudBase
|
7
|
+
|
8
|
+
banner 'knife ionoscloud snapshot restore (options)'
|
9
|
+
|
10
|
+
option :datacenter_id,
|
11
|
+
short: '-D DATACENTER_ID',
|
12
|
+
long: '--datacenter DATACENTER_ID',
|
13
|
+
description: 'ID of the Datacenter'
|
14
|
+
|
15
|
+
option :volume_id,
|
16
|
+
short: '-V VOLUME_ID',
|
17
|
+
long: '--volume VOLUME_ID',
|
18
|
+
description: 'ID of the Volume'
|
19
|
+
|
20
|
+
option :snapshot_id,
|
21
|
+
short: '-S SNAPSHOT_ID',
|
22
|
+
long: '--snapshot SNAPSHOT_ID',
|
23
|
+
description: 'ID of the Snapshot'
|
24
|
+
|
25
|
+
attr_reader :description, :required_options
|
26
|
+
|
27
|
+
def initialize(args = [])
|
28
|
+
super(args)
|
29
|
+
@description =
|
30
|
+
'This will restore a snapshot onto a volume. A snapshot is created as just another image that '\
|
31
|
+
'can be used to create new volumes or to restore an existing volume.'
|
32
|
+
@required_options = [:datacenter_id, :volume_id, :snapshot_id, :ionoscloud_username, :ionoscloud_password]
|
33
|
+
end
|
34
|
+
|
35
|
+
def run
|
36
|
+
$stdout.sync = true
|
37
|
+
validate_required_params(@required_options, config)
|
38
|
+
|
39
|
+
print "#{ui.color('Restoring Snapshot...', :magenta)}"
|
40
|
+
|
41
|
+
volume_api = Ionoscloud::VolumeApi.new(api_client)
|
42
|
+
|
43
|
+
_, _, headers = volume_api.datacenters_volumes_restore_snapshot_post_with_http_info(
|
44
|
+
config[:datacenter_id],
|
45
|
+
config[:volume_id],
|
46
|
+
{ snapshot_id: config[:snapshot_id] },
|
47
|
+
)
|
48
|
+
|
49
|
+
dot = ui.color('.', :magenta)
|
50
|
+
api_client.wait_for { print dot; is_done? get_request_id headers }
|
51
|
+
|
52
|
+
volume_api = Ionoscloud::VolumeApi.new(api_client)
|
53
|
+
|
54
|
+
volume = volume_api.datacenters_volumes_find_by_id(config[:datacenter_id], config[:volume_id])
|
55
|
+
|
56
|
+
puts "\n"
|
57
|
+
puts "#{ui.color('ID', :cyan)}: #{volume.id}"
|
58
|
+
puts "#{ui.color('Name', :cyan)}: #{volume.properties.name}"
|
59
|
+
puts "#{ui.color('Size', :cyan)}: #{volume.properties.size}"
|
60
|
+
puts "#{ui.color('Bus', :cyan)}: #{volume.properties.bus}"
|
61
|
+
puts "#{ui.color('Image', :cyan)}: #{volume.properties.image}"
|
62
|
+
puts "#{ui.color('Type', :cyan)}: #{volume.properties.type}"
|
63
|
+
puts "#{ui.color('Licence Type', :cyan)}: #{volume.properties.licence_type}"
|
64
|
+
puts "#{ui.color('Zone', :cyan)}: #{volume.properties.availability_zone}"
|
65
|
+
puts 'done'
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require_relative 'ionoscloud_base'
|
2
|
+
|
3
|
+
class Chef
|
4
|
+
class Knife
|
5
|
+
class IonoscloudUserCreate < Knife
|
6
|
+
include Knife::IonoscloudBase
|
7
|
+
|
8
|
+
banner 'knife ionoscloud user create (options)'
|
9
|
+
|
10
|
+
option :firstname,
|
11
|
+
short: '-f FIRSTNAME',
|
12
|
+
long: '--firstname FIRSTNAME',
|
13
|
+
description: 'Firstname of the user.'
|
14
|
+
|
15
|
+
option :lastname,
|
16
|
+
short: '-l LASTNAME',
|
17
|
+
long: '--lastname LASTNAME',
|
18
|
+
description: 'Lastname of the user.'
|
19
|
+
|
20
|
+
option :email,
|
21
|
+
short: '-e EMAIL',
|
22
|
+
long: '--email EMAIL',
|
23
|
+
description: 'An e-mail address for the user.'
|
24
|
+
|
25
|
+
option :password,
|
26
|
+
short: '-p PASSWORD',
|
27
|
+
long: '--password PASSWORD',
|
28
|
+
description: 'A password for the user.'
|
29
|
+
|
30
|
+
option :administrator,
|
31
|
+
short: '-a ADMIN',
|
32
|
+
long: '--admin ADMIN',
|
33
|
+
description: 'Assigns the user have administrative rights.'
|
34
|
+
|
35
|
+
option :force_sec_auth,
|
36
|
+
long: '--sec-auth SEC_AUTH',
|
37
|
+
description: 'Indicates if secure (two-factor) authentication should be forced for the user.'
|
38
|
+
|
39
|
+
attr_reader :description, :required_options
|
40
|
+
|
41
|
+
def initialize(args = [])
|
42
|
+
super(args)
|
43
|
+
@description =
|
44
|
+
"Creates a new user under a particular contract.\n**Please Note**: The password set "\
|
45
|
+
"here cannot be updated through the API currently. It is recommended that a new user "\
|
46
|
+
"log into the DCD and change their password."
|
47
|
+
@required_options = [:firstname, :lastname, :email, :password, :ionoscloud_username, :ionoscloud_password]
|
48
|
+
end
|
49
|
+
|
50
|
+
def run
|
51
|
+
$stdout.sync = true
|
52
|
+
validate_required_params(@required_options, config)
|
53
|
+
|
54
|
+
print "#{ui.color('Creating user...', :magenta)}"
|
55
|
+
|
56
|
+
user_management_api = Ionoscloud::UserManagementApi.new(api_client)
|
57
|
+
|
58
|
+
user, _, headers = user_management_api.um_users_post_with_http_info({
|
59
|
+
properties: {
|
60
|
+
firstname: config[:firstname],
|
61
|
+
lastname: config[:lastname],
|
62
|
+
email: config[:email],
|
63
|
+
password: config[:password],
|
64
|
+
administrator: config[:administrator],
|
65
|
+
forceSecAuth: config[:force_sec_auth],
|
66
|
+
}.compact,
|
67
|
+
})
|
68
|
+
|
69
|
+
dot = ui.color('.', :magenta)
|
70
|
+
api_client.wait_for { print dot; is_done? get_request_id headers }
|
71
|
+
|
72
|
+
puts "\n"
|
73
|
+
puts "#{ui.color('ID', :cyan)}: #{user.id}"
|
74
|
+
puts "#{ui.color('Firstname', :cyan)}: #{user.properties.firstname}"
|
75
|
+
puts "#{ui.color('Lastname', :cyan)}: #{user.properties.lastname}"
|
76
|
+
puts "#{ui.color('Email', :cyan)}: #{user.properties.email}"
|
77
|
+
puts "#{ui.color('Administrator', :cyan)}: #{user.properties.administrator.to_s}"
|
78
|
+
puts "#{ui.color('2-Factor Auth', :cyan)}: #{user.properties.force_sec_auth.to_s}"
|
79
|
+
puts 'done'
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require_relative 'ionoscloud_base'
|
2
|
+
|
3
|
+
class Chef
|
4
|
+
class Knife
|
5
|
+
class IonoscloudUserDelete < Knife
|
6
|
+
include Knife::IonoscloudBase
|
7
|
+
|
8
|
+
banner 'knife ionoscloud user delete USER_ID [USER_ID]'
|
9
|
+
|
10
|
+
attr_reader :description, :required_options
|
11
|
+
|
12
|
+
def initialize(args = [])
|
13
|
+
super(args)
|
14
|
+
@description =
|
15
|
+
'Blacklists the user, disabling them. The user is not completely purged, '\
|
16
|
+
'therefore if you anticipate needing to create a user with the same name '\
|
17
|
+
'in the future, we suggest renaming the user before you delete it.'
|
18
|
+
@required_options = [:ionoscloud_username, :ionoscloud_password]
|
19
|
+
end
|
20
|
+
|
21
|
+
def run
|
22
|
+
$stdout.sync = true
|
23
|
+
validate_required_params(@required_options, config)
|
24
|
+
|
25
|
+
user_management_api = Ionoscloud::UserManagementApi.new(api_client)
|
26
|
+
|
27
|
+
@name_args.each do |user_id|
|
28
|
+
begin
|
29
|
+
user = user_management_api.um_users_find_by_id(user_id)
|
30
|
+
rescue Ionoscloud::ApiError => err
|
31
|
+
raise err unless err.code == 404
|
32
|
+
ui.error("User ID #{user_id} not found. Skipping.")
|
33
|
+
next
|
34
|
+
end
|
35
|
+
|
36
|
+
msg_pair('ID', user.id)
|
37
|
+
msg_pair('Firstname', user.properties.firstname)
|
38
|
+
msg_pair('Lastname', user.properties.lastname)
|
39
|
+
msg_pair('Email', user.properties.email)
|
40
|
+
msg_pair('Administrator', user.properties.administrator.to_s)
|
41
|
+
msg_pair('2-Factor Auth', user.properties.force_sec_auth.to_s)
|
42
|
+
puts "\n"
|
43
|
+
|
44
|
+
begin
|
45
|
+
confirm('Do you really want to delete this User')
|
46
|
+
rescue SystemExit => exc
|
47
|
+
next
|
48
|
+
end
|
49
|
+
|
50
|
+
_, _, headers = user_management_api.um_users_delete_with_http_info(user_id)
|
51
|
+
ui.warn("Deleted User #{user.id}. Request ID: #{get_request_id headers}")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require_relative 'ionoscloud_base'
|
2
|
+
|
3
|
+
class Chef
|
4
|
+
class Knife
|
5
|
+
class IonoscloudUserList < Knife
|
6
|
+
include Knife::IonoscloudBase
|
7
|
+
|
8
|
+
banner 'knife ionoscloud user list (options)'
|
9
|
+
|
10
|
+
option :group_id,
|
11
|
+
short: '-g GROUP_ID',
|
12
|
+
long: '--group-id GROUP_ID',
|
13
|
+
description: 'ID of the group.'
|
14
|
+
|
15
|
+
attr_reader :description, :required_options
|
16
|
+
|
17
|
+
def initialize(args = [])
|
18
|
+
super(args)
|
19
|
+
@description =
|
20
|
+
'Retrieve a list of all the users that have been created under a contract. '\
|
21
|
+
'You can retrieve a list of users who are members of the group by passing the '\
|
22
|
+
'*group_id* option.'
|
23
|
+
@required_options = [:ionoscloud_username, :ionoscloud_password]
|
24
|
+
end
|
25
|
+
|
26
|
+
def run
|
27
|
+
$stdout.sync = true
|
28
|
+
validate_required_params(@required_options, config)
|
29
|
+
|
30
|
+
user_list = [
|
31
|
+
ui.color('ID', :bold),
|
32
|
+
ui.color('Firstname', :bold),
|
33
|
+
ui.color('Lastname', :bold),
|
34
|
+
ui.color('Email', :bold),
|
35
|
+
ui.color('Administrator', :bold),
|
36
|
+
ui.color('2-Factor Auth', :bold),
|
37
|
+
]
|
38
|
+
|
39
|
+
user_management_api = Ionoscloud::UserManagementApi.new(api_client)
|
40
|
+
|
41
|
+
if config[:group_id]
|
42
|
+
users = user_management_api.um_groups_users_get(config[:group_id], { depth: 1 }).items
|
43
|
+
else
|
44
|
+
users = user_management_api.um_users_get({ depth: 1 }).items
|
45
|
+
end
|
46
|
+
|
47
|
+
users.each do |user|
|
48
|
+
user_list << user.id
|
49
|
+
user_list << user.properties.firstname
|
50
|
+
user_list << user.properties.lastname
|
51
|
+
user_list << user.properties.email
|
52
|
+
user_list << user.properties.administrator.to_s
|
53
|
+
user_list << user.properties.force_sec_auth.to_s
|
54
|
+
end
|
55
|
+
|
56
|
+
puts ui.list(user_list, :uneven_columns_across, 6)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require_relative 'ionoscloud_base'
|
2
|
+
|
3
|
+
class Chef
|
4
|
+
class Knife
|
5
|
+
class IonoscloudUserSsourl < Knife
|
6
|
+
include Knife::IonoscloudBase
|
7
|
+
|
8
|
+
banner 'knife ionoscloud user ssourl (options)'
|
9
|
+
|
10
|
+
option :user_id,
|
11
|
+
short: '-U USER_ID',
|
12
|
+
long: '--user-id USER_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
|
+
'Retrieve S3 object storage single signon URL for the given user.'
|
21
|
+
@required_options = [:user_id, :ionoscloud_username, :ionoscloud_password]
|
22
|
+
end
|
23
|
+
|
24
|
+
def run
|
25
|
+
$stdout.sync = true
|
26
|
+
validate_required_params(@required_options, config)
|
27
|
+
|
28
|
+
begin
|
29
|
+
puts Ionoscloud::UserManagementApi.new(api_client).um_users_s3ssourl_get(config[:user_id]).sso_url
|
30
|
+
rescue Ionoscloud::ApiError => err
|
31
|
+
raise err unless err.code == 404
|
32
|
+
ui.error("User ID #{config[:user_id]} not found.")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require_relative 'ionoscloud_base'
|
2
|
+
|
3
|
+
class Chef
|
4
|
+
class Knife
|
5
|
+
class IonoscloudVolumeAttach < Knife
|
6
|
+
include Knife::IonoscloudBase
|
7
|
+
|
8
|
+
banner 'knife ionoscloud volume attach VOLUME_ID [VOLUME_ID] (options)'
|
9
|
+
|
10
|
+
option :datacenter_id,
|
11
|
+
short: '-D DATACENTER_ID',
|
12
|
+
long: '--datacenter-id DATACENTER_ID',
|
13
|
+
description: 'The ID of the data center'
|
14
|
+
|
15
|
+
option :server_id,
|
16
|
+
short: '-S SERVER_ID',
|
17
|
+
long: '--server-id SERVER_ID',
|
18
|
+
description: 'The ID of the server'
|
19
|
+
|
20
|
+
attr_reader :description, :required_options
|
21
|
+
|
22
|
+
def initialize(args = [])
|
23
|
+
super(args)
|
24
|
+
@description =
|
25
|
+
'This will attach a pre-existing storage volume to the server.'
|
26
|
+
@required_options = [:datacenter_id, :server_id, :ionoscloud_username, :ionoscloud_password]
|
27
|
+
end
|
28
|
+
|
29
|
+
def run
|
30
|
+
$stdout.sync = true
|
31
|
+
validate_required_params(@required_options, config)
|
32
|
+
|
33
|
+
server_api = Ionoscloud::ServerApi.new(api_client)
|
34
|
+
|
35
|
+
@name_args.each do |volume_id|
|
36
|
+
begin
|
37
|
+
_, _, headers = server_api.datacenters_servers_volumes_post_with_http_info(
|
38
|
+
config[:datacenter_id],
|
39
|
+
config[:server_id],
|
40
|
+
{ id: volume_id },
|
41
|
+
)
|
42
|
+
rescue Ionoscloud::ApiError => err
|
43
|
+
raise err unless err.code == 404
|
44
|
+
ui.error("Volume ID #{volume_id} not found. Skipping.")
|
45
|
+
next
|
46
|
+
end
|
47
|
+
ui.msg("Volume #{volume_id} attached to server. Request ID: #{get_request_id headers}")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,133 @@
|
|
1
|
+
require_relative 'ionoscloud_base'
|
2
|
+
|
3
|
+
class Chef
|
4
|
+
class Knife
|
5
|
+
class IonoscloudVolumeCreate < Knife
|
6
|
+
include Knife::IonoscloudBase
|
7
|
+
|
8
|
+
banner 'knife ionoscloud volume create (options)'
|
9
|
+
|
10
|
+
option :datacenter_id,
|
11
|
+
short: '-D DATACENTER_ID',
|
12
|
+
long: '--datacenter-id DATACENTER_ID',
|
13
|
+
description: 'Name of the data center'
|
14
|
+
|
15
|
+
option :name,
|
16
|
+
short: '-n NAME',
|
17
|
+
long: '--name NAME',
|
18
|
+
description: 'Name of the volume'
|
19
|
+
|
20
|
+
option :size,
|
21
|
+
short: '-S SIZE',
|
22
|
+
long: '--size SIZE',
|
23
|
+
description: 'The size of the volume in GB'
|
24
|
+
|
25
|
+
option :bus,
|
26
|
+
short: '-b BUS',
|
27
|
+
long: '--bus BUS',
|
28
|
+
description: 'The bus type of the volume (VIRTIO or IDE)'
|
29
|
+
|
30
|
+
option :image,
|
31
|
+
short: '-N ID',
|
32
|
+
long: '--image ID',
|
33
|
+
description: 'The image or snapshot ID'
|
34
|
+
|
35
|
+
option :image_alias,
|
36
|
+
long: '--image-alias IMAGE_ALIAS',
|
37
|
+
description: '(required) The image alias'
|
38
|
+
|
39
|
+
option :image_password,
|
40
|
+
short: '-P PASSWORD',
|
41
|
+
long: '--image-password PASSWORD',
|
42
|
+
description: 'The password set on the image for the "root" or "Administrator" user'
|
43
|
+
|
44
|
+
option :type,
|
45
|
+
short: '-t TYPE',
|
46
|
+
long: '--type TYPE',
|
47
|
+
description: 'The disk type (HDD OR SSD)'
|
48
|
+
|
49
|
+
option :licence_type,
|
50
|
+
short: '-l LICENCE',
|
51
|
+
long: '--licence-type LICENCE',
|
52
|
+
description: 'The licence type of the volume (LINUX, WINDOWS, UNKNOWN, OTHER)'
|
53
|
+
|
54
|
+
option :ssh_keys,
|
55
|
+
short: '-K SSHKEY[,SSHKEY,...]',
|
56
|
+
long: '--ssh-keys SSHKEY1,SSHKEY2,...',
|
57
|
+
description: 'A list of public SSH keys to include'
|
58
|
+
|
59
|
+
option :availability_zone,
|
60
|
+
short: '-Z AVAILABILITY_ZONE',
|
61
|
+
long: '--availability-zone AVAILABILITY_ZONE',
|
62
|
+
description: 'The volume availability zone of the server',
|
63
|
+
required: false
|
64
|
+
|
65
|
+
attr_reader :description, :required_options
|
66
|
+
|
67
|
+
def initialize(args = [])
|
68
|
+
super(args)
|
69
|
+
@description =
|
70
|
+
'Creates a volume within the data center. This will NOT attach the volume to a server. '\
|
71
|
+
'Please see the Servers section for details on how to attach storage volumes.'
|
72
|
+
@required_options = [:datacenter_id, :name, :type, :size, :ionoscloud_username, :ionoscloud_password]
|
73
|
+
end
|
74
|
+
|
75
|
+
def run
|
76
|
+
$stdout.sync = true
|
77
|
+
validate_required_params(@required_options, config)
|
78
|
+
|
79
|
+
if !config[:image] && !config[:image_alias]
|
80
|
+
ui.error('Either \'--image\' or \'--image-alias\' parameter must be provided')
|
81
|
+
exit(1)
|
82
|
+
end
|
83
|
+
|
84
|
+
if !config[:ssh_keys] && !config[:image_password]
|
85
|
+
ui.error('Either \'--image-password\' or \'--ssh-keys\' parameter must be provided')
|
86
|
+
exit(1)
|
87
|
+
end
|
88
|
+
|
89
|
+
if config[:ssh_keys]
|
90
|
+
config[:ssh_keys] = config[:ssh_keys].split(',')
|
91
|
+
end
|
92
|
+
|
93
|
+
print "#{ui.color('Creating volume...', :magenta)}"
|
94
|
+
|
95
|
+
volume_api = Ionoscloud::VolumeApi.new(api_client)
|
96
|
+
|
97
|
+
volume, _, headers = volume_api.datacenters_volumes_post_with_http_info(
|
98
|
+
config[:datacenter_id],
|
99
|
+
{
|
100
|
+
properties: {
|
101
|
+
name: config[:name],
|
102
|
+
size: config[:size],
|
103
|
+
bus: config[:bus] || 'VIRTIO',
|
104
|
+
type: config[:type],
|
105
|
+
licenceType: config[:licence_type],
|
106
|
+
image: config[:image],
|
107
|
+
imageAlias: config[:image_alias],
|
108
|
+
sshKeys: config[:sshKeys],
|
109
|
+
imagePassword: config[:image_password],
|
110
|
+
availabilityZone: config[:availability_zone],
|
111
|
+
}.compact
|
112
|
+
},
|
113
|
+
)
|
114
|
+
|
115
|
+
dot = ui.color('.', :magenta)
|
116
|
+
api_client.wait_for(300) { print dot; is_done? get_request_id headers }
|
117
|
+
|
118
|
+
volume = volume_api.datacenters_volumes_find_by_id(config[:datacenter_id], volume.id)
|
119
|
+
|
120
|
+
puts "\n"
|
121
|
+
puts "#{ui.color('ID', :cyan)}: #{volume.id}"
|
122
|
+
puts "#{ui.color('Name', :cyan)}: #{volume.properties.name}"
|
123
|
+
puts "#{ui.color('Size', :cyan)}: #{volume.properties.size}"
|
124
|
+
puts "#{ui.color('Bus', :cyan)}: #{volume.properties.bus}"
|
125
|
+
puts "#{ui.color('Image', :cyan)}: #{volume.properties.image}"
|
126
|
+
puts "#{ui.color('Type', :cyan)}: #{volume.properties.type}"
|
127
|
+
puts "#{ui.color('Licence Type', :cyan)}: #{volume.properties.licence_type}"
|
128
|
+
puts "#{ui.color('Zone', :cyan)}: #{volume.properties.availability_zone}"
|
129
|
+
puts 'done'
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|