0

Is there a way to update the contents of an existing iFile? I didn't see any way to update the contents. So, I started looking at deleting and creating a file by uploading a local file to the BigIP using the iControl. I understand there are two objects to use - iFileFile and then iFile in that order.

Can somebody please provide usage for this? Below is what I started with and get the error below. What would be the correct parameters for iFileFile.create() if I have a file named random_key_file1 in the same location as the powershell script? After creating the iFileFile object, how do I use the same in the iFile.create().

Below links have documentation but lack the ussage examples : https://devcentral.f5.com/wiki/iControl.LocalLB__iFile__create.ashx https://devcentral.f5.com/wiki/iControl.LocalLB__iFileFile__create.ashx

Appreciate the help.

Add-PSSnapIn iControlSnapIn

$conn = Initialize-F5.iControl -HostName $hostName -Username $username -Password $password
if($conn) {

    Try
    {
        Write-Output "Connected to load balancer - $hostName"
        $ic = Get-F5.iControl
        $iFileFileObjectNames = @("file1")
        $filePaths = @("random_key_file1")
        $ic.LocalLBiFileFile.create($iFileFileObjectNames,$filePaths)
        Write-Output ("file created")
    }
    Catch
    {
        Write-Output($error[0]|format-list -force)
    }
}   
else
{
    Write-Error "Connection to loadbalancer failed"
}

ERROR

Exception             : System.Management.Automation.MethodInvocationException: Exception calling "create" with "2"
                        argument(s): "Exception caught in LocalLB::urn:iControl:LocalLB/iFileFile::create()
                        Common::InvalidArgument
                        " ---> System.Web.Services.Protocols.SoapHeaderException: Exception caught in
                        LocalLB::urn:iControl:LocalLB/iFileFile::create()
                        Common::InvalidArgument

                           at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage
                        message, WebResponse response, Stream responseStream, Boolean asyncCall)
                           at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[]
                        parameters)
                           at CallSite.Target(Closure , CallSite , Object , Object , Object )
                           --- End of inner exception stack trace ---
                           at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext
                        funcContext, Exception exception)
                           at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame
                        frame)
                           at
                        System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame
                        frame)
                           at
                        System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame
                        frame)
TargetObject          :
CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
FullyQualifiedErrorId : SoapHeaderException
ErrorDetails          :
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at <ScriptBlock>, D:\test.ps1: line 35
                        at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}
PSMessageDetails      :
Answer this Question  0
Ashish Gupta
  • 14,869
  • 20
  • 75
  • 134
  • Your issue is with the Create() method. If you pipe `$ic.LocalLBiFileFile` into `Get-Member` you should be be able to see what arguments the Create() method accepts. – BenH Oct 03 '16 at 19:16
  • @BenH the URL https://devcentral.f5.com/wiki/iControl.LocalLB__iFileFile__create.ashx noted in my question, has the parameters as two arrays. I am not sure what should be the correct values to be passed. files String [] The names of the iFile file objects to create. paths String [] The paths to the files to load into the system. – Ashish Gupta Oct 03 '16 at 19:20
  • Can you give the output for this? `($ic.LocalLBiFileFile | Get-Member | ? {$_.name -eq "Create"}).definition` – BenH Oct 03 '16 at 20:30
  • void create(string[] files, string[] paths) This is also in the link I have above and also in the comments. – Ashish Gupta Oct 03 '16 at 20:53
  • Try dropping the @() around each variable: `$iFileFileObjectNames = "file1"` and `$filePaths = "random_key_file1"` – BenH Oct 03 '16 at 20:54
  • Same error with the below :$ic = Get-F5.iControl $iFileFileObjectNames = "file1" $filePaths = "random_key_file1" $ic.LocalLBiFileFile.create($iFileFileObjectNames,$filePaths) – Ashish Gupta Oct 03 '16 at 20:57
  • The path in the create method has to be to a local system file on the BIG-IP. So the process is: 1) upload the file, 2) create the iFileFile object, 3) create the iFile object. – Jason Rahm Oct 05 '16 at 16:24

0 Answers0