-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Travis CI User
committed
Jun 20, 2023
1 parent
3d626d3
commit a173ba8
Showing
37 changed files
with
751 additions
and
525 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
fsf-fra0451b-byok-fz.adn.networklayer.com:/949845d1_2fec_41dc_acca_9deb0f5f7a5a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
########### | ||
|
||
echo 'Login to ibmcloud' | ||
ibmcloud config --check-version=false -q --http-timeout 240 --color enable | ||
ibmcloud login -r $region -g $resource_group_id --apikey $api_key | ||
export oauth_token=$(ibmcloud iam oauth-tokens | awk '{print $4}') | ||
|
||
share_id=$(cat modules/file-shares/cleaning-up/share_id_$share_name.tmpl) | ||
|
||
curl -X DELETE "$vpc_api_endpoint/v1/shares/$share_id?version=2023-05-30&generation=2&maturity=beta" -H "Authorization: Bearer ${oauth_token}" |
11 changes: 11 additions & 0 deletions
11
cli/modules/file-shares/cleaning-up/delete_file_shares_mounts.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
########### | ||
|
||
echo 'Login to ibmcloud' | ||
ibmcloud config --check-version=false -q --http-timeout 240 --color enable | ||
ibmcloud login -r $region -g $resource_group_id --apikey $api_key | ||
export oauth_token=$(ibmcloud iam oauth-tokens | awk '{print $4}') | ||
|
||
share_id=$(cat modules/file-shares/cleaning-up/share_id_$share_name.tmpl) | ||
mount_id=$(cat modules/file-shares/cleaning-up/mount_id_$share_name.tmpl) | ||
curl -X DELETE "$vpc_api_endpoint/v1/shares/$share_id/mount_targets/$mount_id?version=2023-05-30&generation=2&maturity=beta" -H "Authorization: Bearer ${oauth_token}" |
88 changes: 88 additions & 0 deletions
88
cli/modules/file-shares/cleaning-up/fs_clean_up_operations.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
########################### File Share Creation | ||
################################################## | ||
|
||
resource "null_resource" "get_fs_ids" { | ||
depends_on = [ null_resource.delete_file_shares_mounts ] | ||
triggers = { | ||
vpc_api_endpoint = local.vpc_api_endpoint | ||
api_key = var.api_key | ||
share_name = lower ("${var.prefix}-${var.sap_sid}") | ||
region = var.region | ||
share_size = var.share_size | ||
share_profile = var.share_profile | ||
var_timeout = var.var_timeout | ||
zone = var.zone | ||
resource_group_id = var.resource_group_id | ||
} | ||
|
||
provisioner "local-exec" { | ||
when = destroy | ||
|
||
command = "sleep ${self.triggers.var_timeout};export resource_group_id=${self.triggers.resource_group_id};export share_profile=${self.triggers.share_profile};export share_size=${self.triggers.share_size};export zone=${self.triggers.zone};export vpc_api_endpoint=${self.triggers.vpc_api_endpoint};export api_key=${self.triggers.api_key};export share_name=${self.triggers.share_name}; export region=${self.triggers.region}; chmod +x ${path.module}/get_fs_ids.sh;${path.module}/get_fs_ids.sh > ${path.module}/get_ids.log" | ||
interpreter = ["/bin/bash", "-c"] | ||
on_failure = continue | ||
} | ||
|
||
} | ||
|
||
resource "null_resource" "delete_file_shares_mounts" { | ||
depends_on = [ null_resource.delete_file_share ] | ||
#count = 1 | ||
triggers = { | ||
vpc_api_endpoint = local.vpc_api_endpoint | ||
api_key = var.api_key | ||
share_name = lower ("${var.prefix}-${var.sap_sid}") | ||
region = var.region | ||
zone = var.zone | ||
share_size = var.share_size | ||
share_profile = var.share_profile | ||
resource_group_id = var.resource_group_id | ||
} | ||
|
||
provisioner "local-exec" { | ||
when = destroy | ||
|
||
command = "export resource_group_id=${self.triggers.resource_group_id};export share_profile=${self.triggers.share_profile};export share_size=${self.triggers.share_size};export zone=${self.triggers.zone};export vpc_api_endpoint=${self.triggers.vpc_api_endpoint};export api_key=${self.triggers.api_key};export share_name=${self.triggers.share_name}; export region=${self.triggers.region};chmod +x ${path.module}/get_fs_ids.sh;${path.module}/get_fs_ids.sh ;chmod +x ${path.module}/delete_file_shares_mounts.sh; ${path.module}/delete_file_shares_mounts.sh > ${path.module}/dmfs.log" | ||
interpreter = ["/bin/bash", "-c"] | ||
} | ||
} | ||
|
||
resource "null_resource" "delete_file_share" { | ||
depends_on = [ null_resource.troubleshoot_fs_ids ] | ||
#count = 1 | ||
triggers = { | ||
vpc_api_endpoint = local.vpc_api_endpoint | ||
api_key = var.api_key | ||
share_name = lower ("${var.prefix}-${var.sap_sid}") | ||
region = var.region | ||
resource_group_id = var.resource_group_id | ||
} | ||
|
||
provisioner "local-exec" { | ||
when = destroy | ||
|
||
command = "export resource_group_id=${self.triggers.resource_group_id};export vpc_api_endpoint=${self.triggers.vpc_api_endpoint};export api_key=${self.triggers.api_key};export share_name=${self.triggers.share_name}; export region=${self.triggers.region};chmod +x ${path.module}/delete_file_share.sh; ${path.module}/delete_file_share.sh > ${path.module}/dfs.log" | ||
interpreter = ["/bin/bash", "-c"] | ||
} | ||
} | ||
|
||
resource "null_resource" "troubleshoot_fs_ids" { | ||
triggers = { | ||
vpc_api_endpoint = local.vpc_api_endpoint | ||
api_key = var.api_key | ||
share_name = lower ("${var.prefix}-${var.sap_sid}") | ||
region = var.region | ||
share_size = var.share_size | ||
share_profile = var.share_profile | ||
var_timeout = var.var_timeout | ||
zone = var.zone | ||
} | ||
|
||
provisioner "local-exec" { | ||
when = destroy | ||
|
||
command = "cat ${path.module}/*.log" | ||
interpreter = ["/bin/bash", "-c"] | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
########### | ||
|
||
echo 'Login to ibmcloud' | ||
ibmcloud config --check-version=false -q --http-timeout 240 --color enable | ||
ibmcloud login -r $region -g $resource_group_id --apikey $api_key | ||
export oauth_token=$(ibmcloud iam oauth-tokens | awk '{print $4}') | ||
|
||
export share_id=$(ibmcloud is share "$share_name" | awk '/ID/ {print $2}' | head -n 1) | ||
|
||
echo $share_id > modules/file-shares/cleaning-up/share_id_$share_name.tmpl | ||
|
||
|
||
curl -X GET "$vpc_api_endpoint/v1/shares/$share_id/mount_targets?version=2023-05-30&generation=2&maturity=beta" \ | ||
-H "Authorization: Bearer ${oauth_token}" \ | ||
-H 'Content-Type: application/json' \ | ||
-d '{ | ||
"name": "'"$share_name"'", | ||
"vpc": { | ||
"id": "'"$vpc_id"'" | ||
} | ||
}' -o modules/file-shares/cleaning-up/output_fs_mt_$share_name.json | ||
|
||
export mount_id=$(grep -m 1 -o '"id":"[^"]*"' modules/file-shares/cleaning-up/output_fs_mt_$share_name.json | sed -n '1s/"id":"\(.*\)"/\1/p;q') | ||
echo $mount_id > modules/file-shares/cleaning-up/mount_id_$share_name.tmpl |
Oops, something went wrong.