Skip to content

Commit

Permalink
feat: attach volumes to falconstor (#1997)
Browse files Browse the repository at this point in the history
* feat: attach volumes to falconstor

* feat: attach volumes to falconstor

* bump: axios
  • Loading branch information
jvallexm authored and GitHub Enterprise committed Aug 14, 2024
1 parent 11bf972 commit 54ccb1f
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file.
- Power VS Workspace connections are no longer removed from Transit Gateways when updating the Workspace's region
- Users can now create Secrets Groups from the Secrets Manager page
- Users can now add authorizations for Kubernetes and CIS to Secrets Manager from the Secrets Manager Page
- Users can now attach Power VS Volumes to FalconStor VTL instances

### Fixes

Expand Down
3 changes: 2 additions & 1 deletion client/src/lib/docs/release-notes.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"features": [
"Power VS Workspace connections are no longer removed from Transit Gateways when updating the Workspace's region",
"Users can now create Secrets Groups from the Secrets Manager page",
"Users can now add authorizations for Kubernetes and CIS to Secrets Manager from the Secrets Manager Page"
"Users can now add authorizations for Kubernetes and CIS to Secrets Manager from the Secrets Manager Page",
"Users can now attach Power VS Volumes to FalconStor VTL instances"
],
"fixes": [
"Fixed an issue causing generate-env.sh to incorrectly set values for Power VS regions"
Expand Down
19 changes: 14 additions & 5 deletions client/src/lib/json-to-iac/power-vs-volumes.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,15 @@ function formatPowerVsVolumeAttachment(
pi_volume_id: `\${ibm_pi_volume.${snakeCase(
volume.workspace + " volume " + volume.name
)}${count ? "_" + count : ""}.volume_id}`,
pi_instance_id: `\${ibm_pi_instance.${snakeCase(
`${volume.workspace}_workspace_instance_${instance}`
)}.instance_id}`,
pi_instance_id: contains(instance, "VTL")
? `\${ibm_pi_instance.${snakeCase(
volume.workspace +
" falconstor vtl " +
instance.replace(/\s\(VTL\)/, "")
)}.instance_id}`
: `\${ibm_pi_instance.${snakeCase(
`${volume.workspace}_workspace_instance_${instance}`
)}.instance_id}`,
lifecycle: [
{
ignore_changes: ["${pi_cloud_instance_id}", "${pi_volume_id}"],
Expand All @@ -131,7 +137,10 @@ function formatPowerVsVolumeAttachment(
"ibm_pi_volume_attach",
`${volume.workspace} attach ${
volume.name + (count ? "-" + count : "")
} to ${instance} instance`,
} to ${
instance.replace(/\s\(VTL\)/, "") +
(contains(instance, "(") ? "_vtl" : "")
} instance`,
volumeData
);
}
Expand All @@ -158,7 +167,7 @@ function powerVsVolumeTf(config) {
lastAttachmentAddress = `\${ibm_pi_volume_attach.${snakeCase(
`${volume.workspace} attach ${volume.name}${
count ? "_" + (i + 1) : ""
} to ${instance} instance`
} to ${instance.replace(/\s\(VTL\)/, "_vtl")} instance`
)}}`;
}
});
Expand Down
29 changes: 27 additions & 2 deletions client/src/lib/state/power-vs-volumes.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,16 @@ function powerVsVolumesOnStoreUpdate(config) {
let newAttachments = [];
volume.attachments.forEach((attachment) => {
if (
splatContains(config.store.json.power_instances, "name", attachment)
splatContains(
config.store.json.power_instances,
"name",
attachment
) ||
splatContains(
config.store.json.vtl,
"name",
attachment.replace(/\s\(VTL\)/g, "")
)
) {
newAttachments.push(attachment);
}
Expand Down Expand Up @@ -295,7 +304,9 @@ function initPowerVsVolumeStore(store) {
return false;
},
groups: function (stateData, componentProps) {
return (stateData.pi_volume_shareable ? [] : [""]).concat(
let instanceNames = (
stateData.pi_volume_shareable ? [] : [""]
).concat(
splat(
componentProps.craig.store.json.power_instances.filter(
(instance) => {
Expand All @@ -307,6 +318,20 @@ function initPowerVsVolumeStore(store) {
"name"
)
);
let vtlNames = splat(
componentProps.craig.store.json.vtl.filter((instance) => {
if (instance.workspace === stateData.workspace) {
return instance;
}
}),
"name"
);

vtlNames.forEach((name, index) => {
vtlNames[index] = name + " (VTL)";
});

return instanceNames.concat(vtlNames);
},
},
count: {
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
],
"license": "ISC",
"dependencies": {
"axios": "^1.7.3",
"axios": "^1.7.4",
"blob-stream": "^0.1.3",
"body-parser": "^1.20.2",
"dotenv": "^16.3.1",
Expand Down
53 changes: 50 additions & 3 deletions unit-tests/json-to-iac/power-vs-volumes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ resource "ibm_pi_volume_attach" "example_attach_test_volume_2_to_instance_2_inst
pi_affinity_instance: "tier0vm",
pi_replication_enabled: false,
pi_volume_shareable: false,
attachments: ["tier0vm"],
attachments: ["tier0vm", "vtl1 (VTL)"],
pi_affinity_policy: "affinity",
},
{
Expand Down Expand Up @@ -961,7 +961,38 @@ resource "ibm_pi_volume_attach" "example_attach_test_volume_2_to_instance_2_inst
vsi: [],
classic_ssh_keys: [],
classic_vlans: [],
vtl: [],
vtl: [
{
sap: false,
sap_profile: null,
name: "vtl1",
workspace: "smatzek-storage-test",
network: [
{
name: "test-net",
ip_address: "",
},
],
ssh_key: "smatzek",
image: "7300-00-01",
pi_sys_type: "s922",
pi_proc_type: "shared",
pi_processors: ".25",
pi_memory: "4",
pi_storage_pool_affinity: false,
pi_storage_type: "tier0",
storage_option: "None",
pi_storage_pool: null,
affinity_type: null,
pi_affinity_volume: null,
pi_anti_affinity_volume: null,
pi_anti_affinity_instance: null,
pi_affinity_instance: null,
pi_user_data: null,
pi_affinity_policy: null,
zone: "dal10",
},
],
classic_gateways: [],
cis: [],
scc_v2: {
Expand Down Expand Up @@ -1003,6 +1034,22 @@ resource "ibm_pi_volume_attach" "smatzek_storage_test_attach_tier3vol_to_tier0vm
}
}
resource "ibm_pi_volume_attach" "smatzek_storage_test_attach_tier3vol_to_vtl1_vtl_instance" {
provider = ibm.power_vs_dal10
pi_cloud_instance_id = ibm_resource_instance.power_vs_workspace_smatzek_storage_test.guid
pi_volume_id = ibm_pi_volume.smatzek_storage_test_volume_tier3vol.volume_id
pi_instance_id = ibm_pi_instance.smatzek_storage_test_falconstor_vtl_vtl1.instance_id
lifecycle {
ignore_changes = [
pi_cloud_instance_id,
pi_volume_id
]
}
depends_on = [
ibm_pi_volume_attach.smatzek_storage_test_attach_tier3vol_to_tier0vm_instance
]
}
##############################################################################
##############################################################################
Expand Down Expand Up @@ -1033,7 +1080,7 @@ resource "ibm_pi_volume_attach" "smatzek_storage_test_attach_tier1vol_to_tier0vm
]
}
depends_on = [
ibm_pi_volume_attach.smatzek_storage_test_attach_tier3vol_to_tier0vm_instance
ibm_pi_volume_attach.smatzek_storage_test_attach_tier3vol_to_vtl1_vtl_instance
]
}
Expand Down
20 changes: 19 additions & 1 deletion unit-tests/state/power-vs-volumes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,17 +424,35 @@ describe("power_volumes", () => {
);
});
it("should return the correct groups data for attachments when sharable", () => {
craig.store.json._options.power_vs_zones = ["dal10"];
craig.power.create({
name: "example",
imageNames: ["7100-05-09"],
zone: "dal10",
});
craig.vtl.create({
name: "frog",
zone: "dal10",
workspace: "example",
network: [],
});
craig.vtl.create({
name: "toad",
zone: "dal10",
network: [],
});
assert.deepEqual(
craig.power_volumes.attachments.groups(
{
pi_volume_shareable: true,
attachments: "hi",
workspace: "example",
},
{
craig: craig,
}
),
[],
["frog (VTL)"],
"it should return array"
);
});
Expand Down

0 comments on commit 54ccb1f

Please sign in to comment.