RavenDB - Create File System

Octopus.Script exported 2015-11-15 by timhunt303 belongs to ‘RavenDB’ category.

Used to create a new file system on a server

Parameters

When steps based on the template are included in a project’s deployment process, the parameters below can be set.

URL of RavenDB

ravenFileSystemURL = http://localhost:8080/

URL of the RavenDB, where you would like the file system to be created.

For example http://localhost:8080/

Name of the File System

ravenFileSystemName

Name the new File System will be called. Make sure the name is not being used already within this instance of RavenDB

Active Bundles

ravenActiveBundles

A settings option, Active Bundles refers bundles that RavenDB has (Replication;Versioning; etc)

Name of the Storage Type

ravenStorageTypeName = Esent

What storage type to use

Path for the database directory

ravenDataDir

The path for the database directory on the server

Allow Incremental Backups

allowIncrementalBackups = False

Allow Incremental Backups to be perform on this Database

Path to Temporary Files

voronTempPath

A different path where the temporary files will be stored

Path for the Esent Logs

esentLogsPath

The path for the Esent logs

Path for the Indexes

indexStoragePath

The path for the indexes on a disk, if you want to store the indexes on another HDD for performance reasons

Script body

Steps based on this template will execute the following PowerShell script.

#--------------------------------------------------------------------
#File System Octopus Variables

#URL of RavenFS that is being deleted 
$ravenFileSystemURL = $OctopusParameters["ravenFileSystemURL"]

#name of the RavenFS that is being deleted
$ravenFileSystemName = $OctopusParameters["ravenFileSystemName"]

#--------------------------------------------------------------------
#Settings Octopus Variables

#Name of Active Bundles (Replication; Versioning; etc) (Default is none)
$ravenActiveBundles = $OctopusParameters["ravenActiveBundles"]

#storage Type Name (esent or voron)
$ravenStorageTypeName = $OctopusParameters["ravenStorageTypeName"]

#directory the database will be located on the server
$ravenDataDir = $OctopusParameters["ravenDataDir"]

#allow incremental back ups: boolean
$allowIncrementalBackups = $OctopusParameters["allowIncrementalBackups"]

#temporary files will be created at this location
$voronTempPath = $OctopusParameters["voronTempPath"]

#The path for the esent logs
$esentLogsPath = $OctopusParameters["esentLogsPath"]

#The path for the indexes on a disk
$indexStoragePath = $OctopusParameters["indexStoragePath"]


#--------------------------------------------------------------------

#checks to see if the entered file system exists, return a Boolean value depending on the outcome
function doesRavenFSExist([string] $FSChecking, [string]$URL)
{
    #retrieves the list of File Systems at the specified URL
    $fs_list = Invoke-RestMethod -Uri "$URL/fs" -Method Get
    #checks if the File System is at the specified URL
    if ($fs_list -contains $FSChecking.ToString()) 
    {
        return $TRUE
    }
    else 
    {
        return $FALSE
    }

    
}#ends does File System exist function


Write-Output "`n-------------------------`n"

#--------------------------------------------------------------------
#check to see if File System exists

Write-Output "Checking if $ravenFileSystemName exists"

$fs_exists = doesRavenFSExist -FSChecking $ravenFileSystemName -URL $ravenFileSystemURL

if($fs_exists -eq $TRUE)
{
    Write-Error "$ravenFileSystemName already exists" -ErrorId E4
    Exit 1
}
else
{
    Write-Output "$ravenFileSystemName doesn't exist. Creating $ravenFileSystemName now"
}


Write-Output "`n-------------------------`n"

#--------------------------------------------------------------------
#check setting variables 

if($ravenActiveBundles -eq $null)
{
   $ravenActiveBundles = "" 
}

if($ravenDataDir -eq "")
{
    Write-Warning "A directory for the database has NOT been entered. The default directory ~\Databases\System is being used."
    $ravenDataDir  = "~\Databases\System"
}

if($esentLogsPath -eq "")
{
    Write-Warning "The path for the esent logs has NOT been entered. The default path of ~/Data/Logs will be used"
    $esentLogsPath =  "~/Data/Logs"
}

if($indexStoragePath -eq "")
{
    Write-Warning "The path for the indexes has NOT been entered. The default path of ~/Data/Indexes will be used"
    $indexStoragePath = "~/Data/Indexes"
}


$ravenDataDir = $ravenDataDir.Replace("\", "\\")

$voronTempPath = $voronTempPath.Replace("\", "\\")

$esentLogsPath = $esentLogsPath.Replace("\", "\\")

$indexStoragePath = $indexStoragePath.Replace("\", "\\")

$ravenDataDir = $ravenDataDir.Replace("DB", "FS")

$voronTempPath = $voronTempPath.Replace("DB", "FS")

$esentLogsPath = $esentLogsPath.Replace("DB", "FS")

$indexStoragePath = $indexStoragePath.Replace("DB", "FS")

Write-Output "`n-------------------------`n"

#--------------------------------------------------------------------
#file system settings


$fs_settings = @"
{
   "Settings":
   {
   "Raven/ActiveBundles": "$ravenActiveBundles",
    "Raven/StorageTypeName": "$ravenStorageTypeName",
    "Raven/DataDir": "$ravenDataDir",
    "Raven/Voron/AllowIncrementalBackups": "$allowIncrementalBackups",
    "Raven/Voron/TempPath": "$voronTempPath",
    "Raven/Esent/LogsPath": "$esentLogsPath",
    "Raven/IndexStoragePath": "$indexStoragePath"
   }
}
"@

#--------------------------------------------------------------------
#Create File System

Write-Output "Creating File System: $ravenFileSystemName"

$createURI = "$ravenFileSystemURL/admin/fs/$ravenFileSystemName"

Invoke-RestMethod -Uri $createURI -Body $fs_settings -Method Put

Write-Output "$ravenFileSystemName created."

Provided under the Apache License version 2.0.

Report an issue

To use this template in Octopus Deploy, copy the JSON below and paste it into the Library → Step templates → Import dialog.

{
  "Id": "35e74a1b-3d6a-4d68-be07-51d0dfb56f23",
  "Name": "RavenDB - Create File System",
  "Description": "Used to create a new file system on a server",
  "Version": 3,
  "ExportedAt": "2015-11-15T22:10:59.092+00:00",
  "ActionType": "Octopus.Script",
  "Author": "timhunt303",
  "Parameters": [
    {
      "Name": "ravenFileSystemURL",
      "Label": "URL of RavenDB",
      "HelpText": "URL of the RavenDB, where you would like the file system to be created. \n\nFor example **http://localhost:8080/**",
      "DefaultValue": "http://localhost:8080/",
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "ravenFileSystemName",
      "Label": "Name of the File System",
      "HelpText": "Name the new File System will be called. Make sure the name is not being used already within this instance of RavenDB",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "ravenActiveBundles",
      "Label": "Active Bundles",
      "HelpText": "A settings option, Active Bundles refers bundles that RavenDB has (Replication;Versioning; etc)",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "ravenStorageTypeName",
      "Label": "Name of the Storage Type",
      "HelpText": "What storage type to use",
      "DefaultValue": "Esent",
      "DisplaySettings": {
        "Octopus.ControlType": "Select",
        "Octopus.SelectOptions": "Esent| Esent\nVoron| Voron"
      }
    },
    {
      "Name": "ravenDataDir",
      "Label": "Path for the database directory",
      "HelpText": "The path for the database directory on the server",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "allowIncrementalBackups",
      "Label": "Allow Incremental Backups",
      "HelpText": "Allow Incremental Backups to be perform on this Database",
      "DefaultValue": "False",
      "DisplaySettings": {
        "Octopus.ControlType": "Checkbox"
      }
    },
    {
      "Name": "voronTempPath",
      "Label": "Path to Temporary Files",
      "HelpText": "A different path where the temporary files will be stored",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "esentLogsPath",
      "Label": "Path for the Esent Logs",
      "HelpText": "The path for the Esent logs",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "indexStoragePath",
      "Label": "Path for the Indexes",
      "HelpText": "The path for the indexes on a disk, if you want to store the indexes on another HDD for performance reasons",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    }
  ],
  "Properties": {
    "Octopus.Action.Script.Syntax": "PowerShell",
    "Octopus.Action.Script.ScriptBody": "#--------------------------------------------------------------------\n#File System Octopus Variables\n\n#URL of RavenFS that is being deleted \n$ravenFileSystemURL = $OctopusParameters[\"ravenFileSystemURL\"]\n\n#name of the RavenFS that is being deleted\n$ravenFileSystemName = $OctopusParameters[\"ravenFileSystemName\"]\n\n#--------------------------------------------------------------------\n#Settings Octopus Variables\n\n#Name of Active Bundles (Replication; Versioning; etc) (Default is none)\n$ravenActiveBundles = $OctopusParameters[\"ravenActiveBundles\"]\n\n#storage Type Name (esent or voron)\n$ravenStorageTypeName = $OctopusParameters[\"ravenStorageTypeName\"]\n\n#directory the database will be located on the server\n$ravenDataDir = $OctopusParameters[\"ravenDataDir\"]\n\n#allow incremental back ups: boolean\n$allowIncrementalBackups = $OctopusParameters[\"allowIncrementalBackups\"]\n\n#temporary files will be created at this location\n$voronTempPath = $OctopusParameters[\"voronTempPath\"]\n\n#The path for the esent logs\n$esentLogsPath = $OctopusParameters[\"esentLogsPath\"]\n\n#The path for the indexes on a disk\n$indexStoragePath = $OctopusParameters[\"indexStoragePath\"]\n\n\n#--------------------------------------------------------------------\n\n#checks to see if the entered file system exists, return a Boolean value depending on the outcome\nfunction doesRavenFSExist([string] $FSChecking, [string]$URL)\n{\n    #retrieves the list of File Systems at the specified URL\n    $fs_list = Invoke-RestMethod -Uri \"$URL/fs\" -Method Get\n    #checks if the File System is at the specified URL\n    if ($fs_list -contains $FSChecking.ToString()) \n    {\n        return $TRUE\n    }\n    else \n    {\n        return $FALSE\n    }\n\n    \n}#ends does File System exist function\n\n\nWrite-Output \"`n-------------------------`n\"\n\n#--------------------------------------------------------------------\n#check to see if File System exists\n\nWrite-Output \"Checking if $ravenFileSystemName exists\"\n\n$fs_exists = doesRavenFSExist -FSChecking $ravenFileSystemName -URL $ravenFileSystemURL\n\nif($fs_exists -eq $TRUE)\n{\n    Write-Error \"$ravenFileSystemName already exists\" -ErrorId E4\n    Exit 1\n}\nelse\n{\n    Write-Output \"$ravenFileSystemName doesn't exist. Creating $ravenFileSystemName now\"\n}\n\n\nWrite-Output \"`n-------------------------`n\"\n\n#--------------------------------------------------------------------\n#check setting variables \n\nif($ravenActiveBundles -eq $null)\n{\n   $ravenActiveBundles = \"\" \n}\n\nif($ravenDataDir -eq \"\")\n{\n    Write-Warning \"A directory for the database has NOT been entered. The default directory ~\\Databases\\System is being used.\"\n    $ravenDataDir  = \"~\\Databases\\System\"\n}\n\nif($esentLogsPath -eq \"\")\n{\n    Write-Warning \"The path for the esent logs has NOT been entered. The default path of ~/Data/Logs will be used\"\n    $esentLogsPath =  \"~/Data/Logs\"\n}\n\nif($indexStoragePath -eq \"\")\n{\n    Write-Warning \"The path for the indexes has NOT been entered. The default path of ~/Data/Indexes will be used\"\n    $indexStoragePath = \"~/Data/Indexes\"\n}\n\n\n$ravenDataDir = $ravenDataDir.Replace(\"\\\", \"\\\\\")\n\n$voronTempPath = $voronTempPath.Replace(\"\\\", \"\\\\\")\n\n$esentLogsPath = $esentLogsPath.Replace(\"\\\", \"\\\\\")\n\n$indexStoragePath = $indexStoragePath.Replace(\"\\\", \"\\\\\")\n\n$ravenDataDir = $ravenDataDir.Replace(\"DB\", \"FS\")\n\n$voronTempPath = $voronTempPath.Replace(\"DB\", \"FS\")\n\n$esentLogsPath = $esentLogsPath.Replace(\"DB\", \"FS\")\n\n$indexStoragePath = $indexStoragePath.Replace(\"DB\", \"FS\")\n\nWrite-Output \"`n-------------------------`n\"\n\n#--------------------------------------------------------------------\n#file system settings\n\n\n$fs_settings = @\"\n{\n   \"Settings\":\n   {\n   \"Raven/ActiveBundles\": \"$ravenActiveBundles\",\n    \"Raven/StorageTypeName\": \"$ravenStorageTypeName\",\n    \"Raven/DataDir\": \"$ravenDataDir\",\n    \"Raven/Voron/AllowIncrementalBackups\": \"$allowIncrementalBackups\",\n    \"Raven/Voron/TempPath\": \"$voronTempPath\",\n    \"Raven/Esent/LogsPath\": \"$esentLogsPath\",\n    \"Raven/IndexStoragePath\": \"$indexStoragePath\"\n   }\n}\n\"@\n\n#--------------------------------------------------------------------\n#Create File System\n\nWrite-Output \"Creating File System: $ravenFileSystemName\"\n\n$createURI = \"$ravenFileSystemURL/admin/fs/$ravenFileSystemName\"\n\nInvoke-RestMethod -Uri $createURI -Body $fs_settings -Method Put\n\nWrite-Output \"$ravenFileSystemName created.\"\n"
  },
  "Category": "RavenDB",
  "HistoryUrl": "https://github.com/OctopusDeploy/Library/commits/master/step-templates//opt/buildagent/work/75443764cd38076d/step-templates/ravendb-create-filesystem.json",
  "Website": "/step-templates/35e74a1b-3d6a-4d68-be07-51d0dfb56f23",
  "Logo": "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR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cR4r/Mvmo/ll6FIExrsZp+3QTpuoevlvHIV5AtSSGI7jq91hDmiKTrgjH5WPOdxFaFhG71pjR9QM5A3l96FYL4CzGziESn30O6E5C3FX/J0tsWhA6QQxNJm0+N7jaICBcuwy/SshgRsRuyWOmy4VbSu7uTFSBsrItYSmGwfRD/sX3/PYgKq7ozRMgDkINrW1UhKSC7IEfvCteCtNOjXZDjKw4VIFZqqc3cfD9DvrmLWnfnw1wjrGg4akOc8YrmA+TL1Z+6EbGBsQ35dpmh8qaaKSKyULO6CxKLpHl7GX9iUbEyRMfcevdR98zqVWVImEnipXixbnUT5BEiwtch51Z4a0NaHxG5dhf77Jp7bQj3ETErtX56cbc2xPjcYq+1fn43R20Ii93XFi2PWyCuCRfC5sg9xL8T4ud2+bx1q8jeh+qQ1te6u2APR3WIbJaZVWp/UH0IX2QWc78KYSbrWQV3NlaHuCwgsuAe4Bs2+bvy2+fugbTF0+oeiLtgi+ktkLb0/tK7utYV4bhlZi/brG6DyPK74m+BOHnVO+M/iwECCCCAAAIIIIAAAggggAACCCCAAAIIIIAAAggggAACCCCAAAIIIIAAAggggAACCCCAAAIIIIAAAggggAACSM3xR4ABAI1fHCI0qDDgAAAAAElFTkSuQmCC",
  "$Meta": {
    "Type": "ActionTemplate"
  }
}

History

Page updated on Sunday, November 15, 2015