knife-ionoscloud 5.0.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- 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,50 @@
|
|
1
|
+
require_relative 'ionoscloud_base'
|
2
|
+
|
3
|
+
class Chef
|
4
|
+
class Knife
|
5
|
+
class IonoscloudContractList < Knife
|
6
|
+
include Knife::IonoscloudBase
|
7
|
+
|
8
|
+
banner 'knife ionoscloud contract list'
|
9
|
+
|
10
|
+
attr_reader :description, :required_options
|
11
|
+
|
12
|
+
def initialize(args = [])
|
13
|
+
super(args)
|
14
|
+
@description =
|
15
|
+
'Lists information about available contract resources.'
|
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
|
+
contract = Ionoscloud::ContractApi.new(api_client).contracts_get()
|
24
|
+
|
25
|
+
puts "#{ui.color('Contract Type', :cyan)}: #{contract.type}"
|
26
|
+
puts "#{ui.color('Contract Owner', :cyan)}: #{contract.properties.owner}"
|
27
|
+
puts "#{ui.color('Contract Number', :cyan)}: #{contract.properties.contract_number}"
|
28
|
+
puts "#{ui.color('Registration Domain', :cyan)}: #{contract.properties.reg_domain}"
|
29
|
+
puts "#{ui.color('Status', :cyan)}: #{contract.properties.status}"
|
30
|
+
puts "#{ui.color('Cores per contract', :cyan)}: #{contract.properties.resource_limits.cores_per_contract}"
|
31
|
+
puts "#{ui.color('Cores per server', :cyan)}: #{contract.properties.resource_limits.cores_per_server}"
|
32
|
+
puts "#{ui.color('Cores provisioned', :cyan)}: #{contract.properties.resource_limits.cores_provisioned}"
|
33
|
+
puts "#{ui.color('HDD limit per contract', :cyan)}: #{contract.properties.resource_limits.hdd_limit_per_contract}"
|
34
|
+
puts "#{ui.color('HDD limit per volume', :cyan)}: #{contract.properties.resource_limits.hdd_limit_per_volume}"
|
35
|
+
puts "#{ui.color('HDD volume provisioned', :cyan)}: #{contract.properties.resource_limits.hdd_volume_provisioned}"
|
36
|
+
puts "#{ui.color('RAM per contract', :cyan)}: #{contract.properties.resource_limits.ram_per_contract}"
|
37
|
+
puts "#{ui.color('RAM per server', :cyan)}: #{contract.properties.resource_limits.ram_per_server}"
|
38
|
+
puts "#{ui.color('RAM provisioned', :cyan)}: #{contract.properties.resource_limits.ram_provisioned}"
|
39
|
+
puts "#{ui.color('Reservable IPs', :cyan)}: #{contract.properties.resource_limits.reservable_ips}"
|
40
|
+
puts "#{ui.color('Reservable IPs in use', :cyan)}: #{contract.properties.resource_limits.reserved_ips_in_use}"
|
41
|
+
puts "#{ui.color('Reservable IPs on contract', :cyan)}: #{contract.properties.resource_limits.reserved_ips_on_contract}"
|
42
|
+
puts "#{ui.color('SSD limit per contract', :cyan)}: #{contract.properties.resource_limits.ssd_limit_per_contract}"
|
43
|
+
puts "#{ui.color('SSD limit per volume', :cyan)}: #{contract.properties.resource_limits.ssd_limit_per_volume}"
|
44
|
+
puts "#{ui.color('SSD volume provisioned', :cyan)}: #{contract.properties.resource_limits.ssd_volume_provisioned}"
|
45
|
+
puts "#{ui.color('K8s Cluster Limit Total', :cyan)}: #{contract.properties.resource_limits.k8s_cluster_limit_total}"
|
46
|
+
puts "#{ui.color('K8s Clusters provisioned', :cyan)}: #{contract.properties.resource_limits.k8s_clusters_provisioned}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require_relative 'ionoscloud_base'
|
2
|
+
|
3
|
+
class Chef
|
4
|
+
class Knife
|
5
|
+
class IonoscloudDatacenterCreate < Knife
|
6
|
+
include Knife::IonoscloudBase
|
7
|
+
|
8
|
+
banner 'knife ionoscloud datacenter create (options)'
|
9
|
+
|
10
|
+
option :name,
|
11
|
+
short: '-n NAME',
|
12
|
+
long: '--name NAME',
|
13
|
+
description: 'Name of the data center'
|
14
|
+
|
15
|
+
option :description,
|
16
|
+
short: '-D DESCRIPTION',
|
17
|
+
long: '--description DESCRIPTION',
|
18
|
+
description: 'Description of the data center'
|
19
|
+
|
20
|
+
option :location,
|
21
|
+
short: '-l LOCATION',
|
22
|
+
long: '--location LOCATION',
|
23
|
+
description: 'Location of the data center'
|
24
|
+
|
25
|
+
attr_reader :description, :required_options
|
26
|
+
|
27
|
+
def initialize(args = [])
|
28
|
+
super(args)
|
29
|
+
@description =
|
30
|
+
"Unless you are planning to manage an existing Ionoscloud environment, "\
|
31
|
+
"the first step will typically involve choosing the location for a new virtual data center"\
|
32
|
+
"A list of locations can be obtained with location command.\n\n\t"\
|
33
|
+
"knife ionoscloud location list\n\n"\
|
34
|
+
"Make a note of the desired location ID and now the data center can be created.\n"
|
35
|
+
@required_options = [:location, :ionoscloud_username, :ionoscloud_password]
|
36
|
+
end
|
37
|
+
|
38
|
+
def run
|
39
|
+
$stdout.sync = true
|
40
|
+
validate_required_params(@required_options, config)
|
41
|
+
|
42
|
+
print "#{ui.color('Creating data center...', :magenta)}"
|
43
|
+
|
44
|
+
datacenter_api = Ionoscloud::DataCenterApi.new(api_client)
|
45
|
+
|
46
|
+
datacenter, _, headers = datacenter_api.datacenters_post_with_http_info({
|
47
|
+
properties: {
|
48
|
+
name: config[:name],
|
49
|
+
description: config[:description],
|
50
|
+
location: config[:location],
|
51
|
+
}.compact,
|
52
|
+
})
|
53
|
+
|
54
|
+
dot = ui.color('.', :magenta)
|
55
|
+
api_client.wait_for { print dot; is_done? get_request_id headers }
|
56
|
+
|
57
|
+
puts "\n"
|
58
|
+
puts "#{ui.color('ID', :cyan)}: #{datacenter.id}"
|
59
|
+
puts "#{ui.color('Name', :cyan)}: #{datacenter.properties.name}"
|
60
|
+
puts "#{ui.color('Description', :cyan)}: #{datacenter.properties.description}"
|
61
|
+
puts "#{ui.color('Location', :cyan)}: #{datacenter.properties.location}"
|
62
|
+
puts 'done'
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require_relative 'ionoscloud_base'
|
2
|
+
|
3
|
+
class Chef
|
4
|
+
class Knife
|
5
|
+
class IonoscloudDatacenterDelete < Knife
|
6
|
+
include Knife::IonoscloudBase
|
7
|
+
|
8
|
+
banner 'knife ionoscloud datacenter delete DATACENTER_ID [DATACENTER_ID]'
|
9
|
+
|
10
|
+
attr_reader :description, :required_options
|
11
|
+
|
12
|
+
def initialize(args = [])
|
13
|
+
super(args)
|
14
|
+
@description =
|
15
|
+
'You will want to exercise a bit of caution here. Removing a data center will destroy '\
|
16
|
+
'all objects contained within that data center -- servers, volumes, snapshots, and so on. '\
|
17
|
+
'The objects -- once removed -- will be unrecoverable.'
|
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
|
+
datacenter_api = Ionoscloud::DataCenterApi.new(api_client)
|
26
|
+
|
27
|
+
@name_args.each do |datacenter_id|
|
28
|
+
begin
|
29
|
+
datacenter = datacenter_api.datacenters_find_by_id(datacenter_id)
|
30
|
+
rescue Ionoscloud::ApiError => err
|
31
|
+
raise err unless err.code == 404
|
32
|
+
ui.error("Data center ID #{datacenter_id} not found. Skipping.")
|
33
|
+
next
|
34
|
+
end
|
35
|
+
|
36
|
+
msg_pair('ID', datacenter.id)
|
37
|
+
msg_pair('Name', datacenter.properties.name)
|
38
|
+
msg_pair('Description', datacenter.properties.description)
|
39
|
+
msg_pair('Location', datacenter.properties.location)
|
40
|
+
msg_pair('Version', datacenter.properties.version)
|
41
|
+
|
42
|
+
puts "\n"
|
43
|
+
|
44
|
+
begin
|
45
|
+
confirm('Do you really want to delete this data center')
|
46
|
+
rescue SystemExit => exc
|
47
|
+
next
|
48
|
+
end
|
49
|
+
|
50
|
+
_, _, headers = datacenter_api.datacenters_delete_with_http_info(datacenter_id)
|
51
|
+
ui.warn("Deleted Data center #{datacenter.id}. Request ID: #{get_request_id headers}")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require_relative 'ionoscloud_base'
|
2
|
+
|
3
|
+
class Chef
|
4
|
+
class Knife
|
5
|
+
class IonoscloudDatacenterList < Knife
|
6
|
+
include Knife::IonoscloudBase
|
7
|
+
|
8
|
+
banner 'knife ionoscloud datacenter list'
|
9
|
+
|
10
|
+
attr_reader :description, :required_options
|
11
|
+
|
12
|
+
def initialize(args = [])
|
13
|
+
super(args)
|
14
|
+
@description =
|
15
|
+
'Ionoscloud introduces the concept of virtual data centers. '\
|
16
|
+
'These are logically separated from one another and allow you '\
|
17
|
+
'to have a self-contained environment for all servers, volumes, '\
|
18
|
+
'networking, and other resources. The goal is to give you the same '\
|
19
|
+
'experience as you would have if you were running your own physical '\
|
20
|
+
'data center. A list of available data centers can be obtained with the following command.'
|
21
|
+
@required_options = [:ionoscloud_username, :ionoscloud_password]
|
22
|
+
end
|
23
|
+
|
24
|
+
def run
|
25
|
+
$stdout.sync = true
|
26
|
+
validate_required_params(@required_options, config)
|
27
|
+
|
28
|
+
datacenter_list = [
|
29
|
+
ui.color('ID', :bold),
|
30
|
+
ui.color('Name', :bold),
|
31
|
+
ui.color('Description', :bold),
|
32
|
+
ui.color('Location', :bold),
|
33
|
+
ui.color('Version', :bold),
|
34
|
+
]
|
35
|
+
|
36
|
+
datacenter_api = Ionoscloud::DataCenterApi.new(api_client)
|
37
|
+
|
38
|
+
datacenter_api.datacenters_get({ depth: 1 }).items.each do |datacenter|
|
39
|
+
datacenter_list << datacenter.id
|
40
|
+
datacenter_list << datacenter.properties.name
|
41
|
+
datacenter_list << datacenter.properties.description || ''
|
42
|
+
datacenter_list << datacenter.properties.location
|
43
|
+
datacenter_list << datacenter.properties.version.to_s
|
44
|
+
end
|
45
|
+
|
46
|
+
puts ui.list(datacenter_list, :uneven_columns_across, 5)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,135 @@
|
|
1
|
+
require_relative 'ionoscloud_base'
|
2
|
+
|
3
|
+
class Chef
|
4
|
+
class Knife
|
5
|
+
class IonoscloudFirewallCreate < Knife
|
6
|
+
include Knife::IonoscloudBase
|
7
|
+
|
8
|
+
banner 'knife ionoscloud firewall create (options)'
|
9
|
+
|
10
|
+
option :datacenter_id,
|
11
|
+
short: '-D DATACENTER_ID',
|
12
|
+
long: '--datacenter-id DATACENTER_ID',
|
13
|
+
description: 'ID of the data center'
|
14
|
+
|
15
|
+
option :server_id,
|
16
|
+
short: '-S SERVER_ID',
|
17
|
+
long: '--server-id SERVER_ID',
|
18
|
+
description: 'ID of the server'
|
19
|
+
|
20
|
+
option :nic_id,
|
21
|
+
short: '-N NIC_ID',
|
22
|
+
long: '--nic-id NIC_ID',
|
23
|
+
description: 'ID of the NIC'
|
24
|
+
|
25
|
+
option :name,
|
26
|
+
short: '-n NAME',
|
27
|
+
long: '--name NAME',
|
28
|
+
description: 'Name of the NIC'
|
29
|
+
|
30
|
+
option :protocol,
|
31
|
+
short: '-P PROTOCOL',
|
32
|
+
long: '--protocol PROTOCOL',
|
33
|
+
default: 'TCP',
|
34
|
+
description: 'The protocol of the firewall rule (TCP, UDP, ICMP, ANY)'
|
35
|
+
|
36
|
+
option :source_mac,
|
37
|
+
short: '-m MAC',
|
38
|
+
long: '--source-mac MAC',
|
39
|
+
description: 'Only traffic originating from the respective MAC address is allowed'
|
40
|
+
|
41
|
+
option :source_ip,
|
42
|
+
short: '-I IP',
|
43
|
+
long: '--source-ip IP',
|
44
|
+
description: 'Only traffic originating from the respective IPv4' \
|
45
|
+
' address is allowed; null allows all source IPs'
|
46
|
+
|
47
|
+
option :target_ip,
|
48
|
+
long: '--target-ip IP',
|
49
|
+
description: 'In case the target NIC has multiple IP addresses,' \
|
50
|
+
' only traffic directed to the respective IP' \
|
51
|
+
' address of the NIC is allowed; null value allows' \
|
52
|
+
' all target IPs'
|
53
|
+
|
54
|
+
option :port_range_start,
|
55
|
+
short: '-p PORT',
|
56
|
+
long: '--port-range-start PORT',
|
57
|
+
description: 'Defines the start range of the allowed port(s)'
|
58
|
+
|
59
|
+
option :port_range_end,
|
60
|
+
short: '-t PORT',
|
61
|
+
long: '--port-range-end PORT',
|
62
|
+
description: 'Defines the end range of the allowed port(s)'
|
63
|
+
|
64
|
+
option :icmp_type,
|
65
|
+
long: '--icmp-type INT',
|
66
|
+
description: 'Defines the allowed type (from 0 to 254) if the' \
|
67
|
+
' protocol ICMP is chosen; null allows all types'
|
68
|
+
|
69
|
+
option :icmp_code,
|
70
|
+
long: '--icmp-code INT',
|
71
|
+
description: 'Defines the allowed code (from 0 to 254) if the' \
|
72
|
+
' protocol ICMP is chosen; null allows all codes'
|
73
|
+
|
74
|
+
attr_reader :description, :required_options
|
75
|
+
|
76
|
+
def initialize(args = [])
|
77
|
+
super(args)
|
78
|
+
@description =
|
79
|
+
'Creates a new firewall rule on an existing NIC.'
|
80
|
+
@required_options = [:datacenter_id, :server_id, :nic_id, :ionoscloud_username, :ionoscloud_password]
|
81
|
+
end
|
82
|
+
|
83
|
+
def run
|
84
|
+
$stdout.sync = true
|
85
|
+
validate_required_params(@required_options, config)
|
86
|
+
|
87
|
+
print "#{ui.color('Creating firewall...', :magenta)}"
|
88
|
+
|
89
|
+
params = {
|
90
|
+
name: config[:name],
|
91
|
+
protocol: config[:protocol],
|
92
|
+
source_mac: config[:source_mac],
|
93
|
+
source_ip: config[:source_ip],
|
94
|
+
target_ip: config[:target_ip],
|
95
|
+
port_range_start: config[:port_range_start],
|
96
|
+
port_range_end: config[:port_range_end],
|
97
|
+
icmp_type: config[:icmp_type],
|
98
|
+
icmp_code: config[:icmp_code],
|
99
|
+
}
|
100
|
+
|
101
|
+
nic_api = Ionoscloud::NicApi.new(api_client)
|
102
|
+
|
103
|
+
firewall, _, headers = nic_api.datacenters_servers_nics_firewallrules_post_with_http_info(
|
104
|
+
config[:datacenter_id],
|
105
|
+
config[:server_id],
|
106
|
+
config[:nic_id],
|
107
|
+
Ionoscloud::FirewallRule.new({ properties: Ionoscloud::FirewallruleProperties.new(params.compact) }),
|
108
|
+
)
|
109
|
+
|
110
|
+
dot = ui.color('.', :magenta)
|
111
|
+
api_client.wait_for { print dot; is_done? get_request_id headers }
|
112
|
+
|
113
|
+
firewall = nic_api.datacenters_servers_nics_firewallrules_find_by_id(
|
114
|
+
config[:datacenter_id],
|
115
|
+
config[:server_id],
|
116
|
+
config[:nic_id],
|
117
|
+
firewall.id,
|
118
|
+
)
|
119
|
+
|
120
|
+
puts "\n"
|
121
|
+
puts "#{ui.color('ID', :cyan)}: #{firewall.id}"
|
122
|
+
puts "#{ui.color('Name', :cyan)}: #{firewall.properties.name}"
|
123
|
+
puts "#{ui.color('Protocol', :cyan)}: #{firewall.properties.protocol}"
|
124
|
+
puts "#{ui.color('Source MAC', :cyan)}: #{firewall.properties.source_mac}"
|
125
|
+
puts "#{ui.color('Source IP', :cyan)}: #{firewall.properties.source_ip}"
|
126
|
+
puts "#{ui.color('Target IP', :cyan)}: #{firewall.properties.target_ip}"
|
127
|
+
puts "#{ui.color('Port Range Start', :cyan)}: #{firewall.properties.port_range_start}"
|
128
|
+
puts "#{ui.color('Port Range End', :cyan)}: #{firewall.properties.port_range_end}"
|
129
|
+
puts "#{ui.color('ICMP Type', :cyan)}: #{firewall.properties.icmp_type}"
|
130
|
+
puts "#{ui.color('ICMP Code', :cyan)}: #{firewall.properties.icmp_code}"
|
131
|
+
puts 'done'
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require_relative 'ionoscloud_base'
|
2
|
+
|
3
|
+
class Chef
|
4
|
+
class Knife
|
5
|
+
class IonoscloudFirewallDelete < Knife
|
6
|
+
include Knife::IonoscloudBase
|
7
|
+
|
8
|
+
banner 'knife ionoscloud firewall delete FIREWALL_ID [FIREWALL_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
|
+
option :nic_id,
|
21
|
+
short: '-N NIC_ID',
|
22
|
+
long: '--nic-id NIC_ID',
|
23
|
+
description: 'ID of the NIC'
|
24
|
+
|
25
|
+
attr_reader :description, :required_options
|
26
|
+
|
27
|
+
def initialize(args = [])
|
28
|
+
super(args)
|
29
|
+
@description =
|
30
|
+
'Deletes a firewall rule from an existing NIC.'
|
31
|
+
@required_options = [:datacenter_id, :server_id, :nic_id, :ionoscloud_username, :ionoscloud_password]
|
32
|
+
end
|
33
|
+
|
34
|
+
def run
|
35
|
+
$stdout.sync = true
|
36
|
+
validate_required_params(@required_options, config)
|
37
|
+
|
38
|
+
nic_api = Ionoscloud::NicApi.new(api_client)
|
39
|
+
|
40
|
+
@name_args.each do |firewall_id|
|
41
|
+
begin
|
42
|
+
firewall = nic_api.datacenters_servers_nics_firewallrules_find_by_id(
|
43
|
+
config[:datacenter_id], config[:server_id], config[:nic_id], firewall_id,
|
44
|
+
)
|
45
|
+
rescue Ionoscloud::ApiError => err
|
46
|
+
raise err unless err.code == 404
|
47
|
+
ui.error("Firewall rule ID #{firewall_id} not found. Skipping.")
|
48
|
+
next
|
49
|
+
end
|
50
|
+
|
51
|
+
msg_pair('ID', firewall.id)
|
52
|
+
msg_pair('Name', firewall.properties.name)
|
53
|
+
msg_pair('Protocol', firewall.properties.protocol)
|
54
|
+
msg_pair('Source MAC', firewall.properties.source_mac)
|
55
|
+
msg_pair('Source IP', firewall.properties.source_ip)
|
56
|
+
msg_pair('Target IP', firewall.properties.target_ip)
|
57
|
+
msg_pair('Port Range Start', firewall.properties.port_range_start)
|
58
|
+
msg_pair('Port Range End', firewall.properties.port_range_end)
|
59
|
+
msg_pair('ICMP Type', firewall.properties.icmp_type)
|
60
|
+
msg_pair('ICMP Code', firewall.properties.icmp_code)
|
61
|
+
|
62
|
+
begin
|
63
|
+
confirm('Do you really want to delete this firewall rule')
|
64
|
+
rescue SystemExit => exc
|
65
|
+
next
|
66
|
+
end
|
67
|
+
|
68
|
+
_, _, headers = nic_api.datacenters_servers_nics_firewallrules_delete_with_http_info(
|
69
|
+
config[:datacenter_id], config[:server_id], config[:nic_id], firewall_id,
|
70
|
+
)
|
71
|
+
ui.warn("Deleted Firewall rule #{firewall.id}. Request ID: #{get_request_id headers}")
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require_relative 'ionoscloud_base'
|
2
|
+
|
3
|
+
class Chef
|
4
|
+
class Knife
|
5
|
+
class IonoscloudFirewallList < Knife
|
6
|
+
include Knife::IonoscloudBase
|
7
|
+
|
8
|
+
banner 'knife ionoscloud firewall list (options)'
|
9
|
+
|
10
|
+
option :datacenter_id,
|
11
|
+
short: '-D DATACENTER_ID',
|
12
|
+
long: '--datacenter-id DATACENTER_ID',
|
13
|
+
description: '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
|
+
option :nic_id,
|
21
|
+
short: '-N NIC_ID',
|
22
|
+
long: '--nic-id NIC_ID',
|
23
|
+
description: 'ID of the NIC'
|
24
|
+
|
25
|
+
attr_reader :description, :required_options
|
26
|
+
|
27
|
+
def initialize(args = [])
|
28
|
+
super(args)
|
29
|
+
@description =
|
30
|
+
'Lists all available firewall rules assigned to a NIC.'
|
31
|
+
@required_options = [:datacenter_id, :server_id, :nic_id, :ionoscloud_username, :ionoscloud_password]
|
32
|
+
end
|
33
|
+
|
34
|
+
def run
|
35
|
+
$stdout.sync = true
|
36
|
+
validate_required_params(@required_options, config)
|
37
|
+
|
38
|
+
firewall_list = [
|
39
|
+
ui.color('ID', :bold),
|
40
|
+
ui.color('Name', :bold),
|
41
|
+
ui.color('Protocol', :bold),
|
42
|
+
ui.color('Source MAC', :bold),
|
43
|
+
ui.color('Source IP', :bold),
|
44
|
+
ui.color('Target IP', :bold),
|
45
|
+
ui.color('Port Range Start', :bold),
|
46
|
+
ui.color('Port Range End', :bold),
|
47
|
+
ui.color('ICMP Type', :bold),
|
48
|
+
ui.color('ICMP CODE', :bold),
|
49
|
+
]
|
50
|
+
|
51
|
+
nic_api = Ionoscloud::NicApi.new(api_client)
|
52
|
+
|
53
|
+
nic_api.datacenters_servers_nics_firewallrules_get(
|
54
|
+
config[:datacenter_id], config[:server_id], config[:nic_id], { depth: 1 }
|
55
|
+
).items.each do |firewall|
|
56
|
+
firewall_list << firewall.id
|
57
|
+
firewall_list << firewall.properties.name
|
58
|
+
firewall_list << firewall.properties.protocol.to_s
|
59
|
+
firewall_list << firewall.properties.source_mac.to_s
|
60
|
+
firewall_list << firewall.properties.source_ip.to_s
|
61
|
+
firewall_list << firewall.properties.target_ip.to_s
|
62
|
+
firewall_list << firewall.properties.port_range_start.to_s
|
63
|
+
firewall_list << firewall.properties.port_range_end.to_s
|
64
|
+
firewall_list << firewall.properties.icmp_type.to_s
|
65
|
+
firewall_list << firewall.properties.icmp_code.to_s
|
66
|
+
end
|
67
|
+
|
68
|
+
puts ui.list(firewall_list, :uneven_columns_across, 10)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|