Skip to content

Commit

Permalink
FOPTS-1324 Turbonomic Unattached Volumes (Azure) (#1362)
Browse files Browse the repository at this point in the history
* Add information to azure delet unattached volumes and remove hardcoded host on azure and aws

* Rename azure and aws labels
  • Loading branch information
Rangelmv23 authored Jul 26, 2023
1 parent 27b690d commit b38a0fe
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 35 deletions.
10 changes: 10 additions & 0 deletions cost/turbonomics/delete_unattached_volumes/aws/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## v0.5

- Renamed `Storage Access` incident field to `Provisioned IOPs`.
- Renamed `Storage Amount` incident field to `Size`.
- Renamed `Attachment State` incident field to `State`.
- Renamed `Created Time` incident field to `Action Created Time`.
- Renamed `Last Attached VM` incident field to `Last VM`.
- Renamed `Unused Days` parameter to `Days Unattached`.
- Removed hardcoded host on business units path.

## v0.4

- Added `Storage Access` incident field.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ severity "low"
category "Cost"
default_frequency "daily"
info(
version: "0.4",
version: "0.5",
provider: "AWS",
source: "Turbonomic",
service: "Storage",
Expand Down Expand Up @@ -37,7 +37,7 @@ end

parameter "param_days_unattached" do
type "number"
label "Unused days"
label "Days Unattached"
description "The number of days a volume has been unused. The days should be greater than zero"
default 30
min_value 1
Expand Down Expand Up @@ -99,7 +99,7 @@ datasource "ds_get_turbonomics_recommendations" do
field "actionState", jmes_path(col_item, "actionState")
field "disruptiveness", jmes_path(col_item, "executionCharacteristics.disruptiveness")
field "reversibility", jmes_path(col_item, "executionCharacteristics.reversibility")
field "lastAttachedVm", jmes_path(col_item, "target.aspects.virtualDisksAspect.virtualDisks[0].lastAttachedVm")
field "lastVm", jmes_path(col_item, "target.aspects.virtualDisksAspect.virtualDisks[0].lastAttachedVm")
field "uuid", jmes_path(col_item, "uuid")
end
end
Expand All @@ -108,7 +108,7 @@ end
##this will potentially be a lot of calls. how to make this more performant
datasource "ds_get_business_units" do
request do
run_script $js_get_business_units, $auth_cookie, $param_provider
run_script $js_get_business_units, $auth_cookie, $param_provider, $param_turbonomic_host
end
result do
encoding "json"
Expand Down Expand Up @@ -161,7 +161,7 @@ end
## verified that discovered is the only one we need
script "js_get_business_units", type: "javascript" do
result "request"
parameters "auth_cookie", "param_provider"
parameters "auth_cookie", "param_provider", "param_turbonomic_host"
code <<-EOS
//replace cookie every day this is run
var providers = {
Expand All @@ -171,7 +171,7 @@ script "js_get_business_units", type: "javascript" do
}
var request = {
verb: "GET",
host: "sales1.demo.turbonomic.com",
host: param_turbonomic_host,
path: "/api/v3/businessunits",
query_params: {
"cloud_type": providers[param_provider],
Expand Down Expand Up @@ -232,10 +232,10 @@ script "js_filtered_turbonomics_recommendations", type: "javascript" do
}
_.each(volume.stats, function(stat){
if (stat.name === "StorageAmount") {
volume.size = stat.capacity.total + " " + stat.units
volume.size = stat.capacity.total
}
if(stat.name === "StorageAccess") {
volume.iops = stat.capacity.total + " " + stat.units
volume.iops = stat.capacity.total
}
})
tags = []
Expand Down Expand Up @@ -326,29 +326,29 @@ EOS
field "tags" do
label "Tags"
end
field "createdTime" do
label "Created Time"
field "actionCreatedTime" do
label "Action Created Time"
path "createdTime"
end
field "state" do
label "Attachment State"
label "State"
path "attachmentState"
end
field "lookbackPeriod" do
field "daysUnattached" do
label "Days Unattached"
path "daysUnattached"
end
field "id" do
label "Resource ID"
path "resourceID"
end
field "iops" do
label "Storage Access"
label "Provisioned IOPs"
end
field "size" do
label "Storage Amount"
label "Size (GB)"
end
field "lastAttachedVm" do
label "Last Attached VM"
field "lastVm" do
label "Last VM"
end
field "actionState" do
label "Action State"
Expand Down
14 changes: 14 additions & 0 deletions cost/turbonomics/delete_unattached_volumes/azure/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## v0.4

- Added `Provisioned IOPs` incident field.
- Added `Last VM` incident field.
- Added `Action State` incident field.
- Added `Disruptiveness` incident field.
- Added `Reversibility` incident field.
- Added `System Details URL` incident field.
- Renamed `Attachment State` incident field to `State`.
- Renamed `Created Time` incident field to `Action Created Time`.
- Renamed `Unused Days` parameter to `Days Unattached`.
- Changed internal names of several incident fields to ensure that they are properly scraped for dashboards.
- Removed hardcoded host on business units path.

## v0.3

- Fixed readme Link in the policy.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ severity "low"
category "Cost"
default_frequency "daily"
info(
version: "0.3",
version: "0.4",
provider: "Azure",
source: "Turbonomic",
service: "Storage",
Expand Down Expand Up @@ -38,7 +38,7 @@ end

parameter "param_days_unattached" do
type "number"
label "Unused days"
label "Days Unattached"
description "The number of days a volume has been unused. The days should be greater than zero"
default 30
min_value 1
Expand Down Expand Up @@ -94,17 +94,22 @@ datasource "ds_get_turbonomics_recommendations" do
field "createdTime", jmes_path(col_item, "createTime")
field "attachmentState", jmes_path(col_item, "target.aspects.virtualDisksAspect.virtualDisks[0].attachmentState")
field "daysUnattached", jmes_path(col_item, "target.aspects.virtualDisksAspect.virtualDisks[0].numDaysUnattached")
field "size", jmes_path(col_item, "target.aspects.virtualDisksAspect.virtualDisks[0].stats")
field "stats", jmes_path(col_item, "target.aspects.virtualDisksAspect.virtualDisks[0].stats")
field "savings", jmes_path(col_item, "stats[0].value")
field "savingsCurrency", jmes_path(col_item, "stats[0].units")
field "actionState", jmes_path(col_item, "actionState")
field "disruptiveness", jmes_path(col_item, "executionCharacteristics.disruptiveness")
field "reversibility", jmes_path(col_item, "executionCharacteristics.reversibility")
field "lastVm", jmes_path(col_item, "target.aspects.virtualDisksAspect.virtualDisks[0].lastAttachedVm")
field "uuid", jmes_path(col_item, "uuid")
end
end
end

##this will potentially be a lot of calls. how to make this more performant
datasource "ds_get_business_units" do
request do
run_script $js_get_business_units, $auth_cookie, $param_provider
run_script $js_get_business_units, $auth_cookie, $param_provider, $param_turbonomic_host
end
result do
encoding "json"
Expand All @@ -117,7 +122,7 @@ datasource "ds_get_business_units" do
end

datasource "ds_filtered_turbonomics_recommendations" do
run_script $js_filtered_turbonomics_recommendations, $ds_get_turbonomics_recommendations, $param_days_unattached, $ds_get_business_units, $param_provider
run_script $js_filtered_turbonomics_recommendations, $ds_get_turbonomics_recommendations, $param_days_unattached, $ds_get_business_units, $param_provider, $param_turbonomic_host
end

###############################################################################
Expand Down Expand Up @@ -156,7 +161,7 @@ end
## verified that discovered is the only one we need
script "js_get_business_units", type: "javascript" do
result "request"
parameters "auth_cookie", "param_provider"
parameters "auth_cookie", "param_provider", "param_turbonomic_host"
code <<-EOS
//replace cookie every day this is run
var providers = {
Expand All @@ -166,7 +171,7 @@ script "js_get_business_units", type: "javascript" do
}
var request = {
verb: "GET",
host: "sales1.demo.turbonomic.com",
host: param_turbonomic_host,
path: "/api/v3/businessunits",
query_params: {
"cloud_type": providers[param_provider],
Expand All @@ -182,7 +187,7 @@ end

script "js_filtered_turbonomics_recommendations", type: "javascript" do
result "result"
parameters "ds_get_turbonomics_recommendations", "param_days_unattached", "ds_get_business_units", "param_provider"
parameters "ds_get_turbonomics_recommendations", "param_days_unattached", "ds_get_business_units", "param_provider", "param_turbonomic_host"
code <<-EOS
instances = []
monthlySavings = 0.0
Expand Down Expand Up @@ -225,10 +230,12 @@ script "js_filtered_turbonomics_recommendations", type: "javascript" do
} else {
volume.savingsCurrency = "$"
}
_.each(volume.size, function(stat){
_.each(volume.stats, function(stat){
if (stat.name === "StorageAmount") {
volume.size = stat.capacity.total + " " + stat.units
return
volume.size = stat.capacity.total
}
if(stat.name === "StorageAccess") {
volume.iops = stat.capacity.total
}
})
tags = []
Expand All @@ -251,6 +258,7 @@ script "js_filtered_turbonomics_recommendations", type: "javascript" do
}
volume.savings = (Math.round(volume.savings * 730 * 1000) / 1000)
monthlySavings = monthlySavings + volume.savings
volume.url = param_turbonomic_host + "/app/index.html#/view/main/action/" + volume.uuid
instances.push(volume)
}
})
Expand Down Expand Up @@ -318,23 +326,44 @@ EOS
field "tags" do
label "Tags"
end
field "createdTime" do
label "Created Time"
field "actionCreatedTime" do
label "Action Created Time"
path "createdTime"
end
field "attachmentState" do
label "Attachment State"
field "state" do
label "State"
path "attachmentState"
end
field "daysUnattached" do
label "Days Unattached"
end
field "size" do
label "Size"
end
field "id" do
label "Resource ID"
path "resourceID"
end
field "iops" do
label "Provisioned IOPs"
end
field "size" do
label "Size (GB)"
end
field "lastVm" do
label "Last VM"
end
field "actionState" do
label "Action State"
end
field "disruptiveness" do
label "Disruptiveness"
end
field "reversibility" do
label "Reversibility"
end
field "url" do
label "System Details URL"
end
end

escalate $esc_email
end
end
Expand Down

0 comments on commit b38a0fe

Please sign in to comment.