Skip to content

Commit

Permalink
added tutorital for managing datasource configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
ffeldhaus committed Feb 29, 2016
1 parent 1fb4b0a commit e731e39
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
34 changes: 34 additions & 0 deletions OnCommand-Insight-Tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,40 @@ foreach ($Device in $DuplicateDevices) {
"$Device," + (($Datasources | ? { $_.Devices.name -match $Device } | select -ExpandProperty Name) -join ',')
}

### Manage Datasource Configuration

Get all datasources including its configuration
```powershell
Get-OciDatasources -config
```

Get a single datasource including its configuration
```powershell
Get-OciDatasource -id 1 -config
```

The configuration contains packages (e.g. foundation, performance, cloud) and each package has several attributes which can be modified.

Here's an example to change the password of a NetApp 7-Mode datasource:
```powershell
$Datasource = Get-OciDatasource -id 1 -config
# list packages
$Datasource.config.packages
# select foundation package and list it's attributes
$Datasource.config.packages | ? { $_.id -eq "foundation" } | Select -ExpandProperty Attributes
# modify password attribute
($Datasource.config.packages | ? { $_.id -eq "foundation" } | Select -ExpandProperty Attributes | ? { $_.Name -eq "password" }).Value = "test"
# update datasource
$Datasource | Update-OciDatasource
```

To simplify changing attributes, if possible, attributes have aliases in the config section (attributes with same name in several packages will not work and attributes with some reserved names will also not work). This is to simplify usage. For robust scripts, use the methods above!
```powershell
$Datasource = Get-OciDatasource -id 1 -config
$Datasource.config.password = "test"
$Datasource | Update-OciDatasource
```

## Troubleshooting

If you encounter issues with timeouts, this may be due to slow OCI Servers or very large environments. Try increasing the Timout from the default of 600 seconds (10 minutes) when connecting to the OCI Server
Expand Down
4 changes: 2 additions & 2 deletions src/OnCommand-Insight.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1373,7 +1373,7 @@ function Global:Get-OciDatasource {
foreach (`$Attribute in `$Package.attributes) {
`$PackageIndex = `$Result.config.packages.IndexOf(`$Package)
`$AttributeIndex = `$Package.attributes.IndexOf(`$Attribute)
Invoke-Command -ScriptBlock ([ScriptBlock]::Create("```$Result.config | Add-Member -MemberType ScriptProperty -Name `$(`$Attribute.name) -Value { ```$this.packages[`$PackageIndex].attributes[`$AttributeIndex].Value } -SecondValue { ```$this.packages[`$PackageIndex].attributes[`$AttributeIndex].Value = ```$args[0] } -Force"))
Invoke-Command -ScriptBlock ([ScriptBlock]::Create("```$Result.config | Add-Member -MemberType ScriptProperty -Name `$(`$Attribute.name) -Value { ```$this.packages[`$PackageIndex].attributes[`$AttributeIndex].Value } -SecondValue { ```$this.packages[`$PackageIndex].attributes[`$AttributeIndex].Value = ```$args[0] } -ErrorAction SilentlyContinue"))
}
}
}
Expand Down Expand Up @@ -1494,7 +1494,7 @@ function Global:Get-OciDatasources {
foreach (`$Attribute in `$Package.attributes) {
`$PackageIndex = `$Datasource.config.packages.IndexOf(`$Package)
`$AttributeIndex = `$Package.attributes.IndexOf(`$Attribute)
Invoke-Command -ScriptBlock ([ScriptBlock]::Create("```$Datasource.config | Add-Member -MemberType ScriptProperty -Name `$(`$Attribute.name) -Value { ```$this.packages[`$PackageIndex].attributes[`$AttributeIndex].Value } -SecondValue { ```$this.packages[`$PackageIndex].attributes[`$AttributeIndex].Value = ```$args[0] } -Force"))
Invoke-Command -ScriptBlock ([ScriptBlock]::Create("```$Datasource.config | Add-Member -MemberType ScriptProperty -Name `$(`$Attribute.name) -Value { ```$this.packages[`$PackageIndex].attributes[`$AttributeIndex].Value } -SecondValue { ```$this.packages[`$PackageIndex].attributes[`$AttributeIndex].Value = ```$args[0] } -ErrorAction SilentlyContinue"))
}
}
}
Expand Down

0 comments on commit e731e39

Please sign in to comment.