Jump to content

Steve G

Hornbill Developer
  • Posts

    748
  • Joined

  • Last visited

  • Days Won

    31

Posts posted by Steve G

  1. Hello everyone,

    We've released v1.16.0 of the Database Asset Import Utility. This release requires Service Manager build 2241 or above.

    Features 

    • Added support for importing Software Asset Management records when creating or updating assets
    • Improved logging, including: grouping log details per-asset; basic log details added to instance log
    • Added version check against Github repo

    Changes

    • Optimised import process, including the local caching of Hornbill asset records for each class & type
    • Refactored code to remove duplicated & unnecessary code
    • Rounded time taken output to the nearest second

    Fixes

    • Removed a number of possible race conditions when using multiple workers

    This can be downloaded from Github, and is documented on the Hornbill Wiki.

  2. Hi @Martyn Houghton,

    This has now been released, and requires the Service Manager update that was released last night:

    It's pretty basic in this release - it only supports deleting Contacts and Organisations whose IDs are provided. Additional filtering options will arrive in due course, but that will require some additional changes to the Core app.

    Cheers,

    Steve

    • Thanks 1
  3. Hello everyone,

    We've just released v.1.16.0 of the Hornbill Cleaner Utility. This release requires Service Manager build 2241 or above.

    Changes

    • Updates to cater for move of Configuration Manager into Service Manager

    Features

    • Added support to filter Requests for deletion by Catalog ID
    • Added support to delete Service Availability records, filtered by Service ID(s)
    • Added support to delete Contact records
    • Added support to delete Organization records
    • Added version check against Github repo
    • Enhanced debug logging, now logs request and response payloads when an API call into Hornbill fails

    This can be downloaded from Github, and is documented on the Hornbill Wiki.

  4. Hi @BillP,

    You can use the activityStreamQuery API to pull paginated lists of posts (and optionally comments) from a requests timeline, using an access token and activity stream ID returned by a call to the getRequestRecord API. The activity stream ID will be returned in the h_activity_stream_id column within the primaryEntityData output parameter of getRequestRecord.

    Let me know if you need any more info.

    Cheers,

    Steve

    • Like 1
  5. Hi @Martyn Houghton,

    The code looks ok, I think the issue may be with the delete - deleting the file from the session before attachFileFromSession can perform its logic. I've looked at the Service Manager code behind attachFileFromSession, and it actually handles the delete from the session for you, so performing the delete in your code is unnecessary.

    I knocked up a very basic example PHP script, using your example from above, and had it attach 1000 images to a request, and all 1000 were successful:

    <?
    
    $image_path = "/Users/steveg/Pictures/me_new.jpg";
    
    for ($x = 0; $x < 1000; $x++) {
        $file_name = "me_new".$x.".jpg";
        $url = "https://hhq-p01-api.hornbill.com/stevegdev/dav/session/" . $file_name;
        uploadFile($url, $image_path);
        attachFileToRequest($file_name);
    }
    
    
    function uploadFile($url, $image_path) {
        $image_handler = fopen($image_path, 'rb');
        
        $ch = curl_init();
        
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
            'Authorization: ESP-APIKEY myapikey'
        ));
        curl_setopt($ch, CURLOPT_UPLOAD, 1);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_INFILE, $image_handler);
        curl_setopt($ch, CURLOPT_INFILESIZE, filesize($image_path));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_TIMEOUT, 15);
        
        curl_exec($ch);
        
        $http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        echo "[UPLOAD] [".$http_status."] [".$url."] [".$image_path."]\n";
        curl_close($ch);
    }
    
    function attachFileToRequest($file_name) {
        
        $ch = curl_init();
    
        $url = "https://hhq-p01-api.hornbill.com/stevegdev/xmlmc/apps/com.hornbill.servicemanager/Requests?method=attachFileFromSession";
        
        $request_id = "IN00013698";
        $file_in_session = "/session/".$file_name;
    
        $data = '<methodCall service="apps/com.hornbill.servicemanager/Requests" method="attachFileFromSession">
                <params>
                    <requestId>'.$request_id.'</requestId>
                    <fileName>'.$file_in_session.'</fileName>
                    <description>some file description</description>
                    <visibility>trustedGuest</visibility>
                </params>
                </methodCall>';
    
        curl_setopt_array($ch, array(
            CURLOPT_URL => $url,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_ENCODING => "",
            CURLOPT_MAXREDIRS => 10,
            CURLOPT_TIMEOUT => 15,
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            CURLOPT_CUSTOMREQUEST => "POST",
            CURLOPT_POSTFIELDS => $data,
            CURLOPT_HTTPHEADER => array(
                'Authorization: ESP-APIKEY myapikey',
                'Content-Type: text/xmlmc',
                'Accept: application/json'
            ),
          ));
        
        $result = curl_exec($ch);
        
        $http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        $json_response = json_decode($result);
        $hornbill_api_status = $json_response->{'@status'} ? 'true' : 'false';
        echo "[ATTACH] [".$http_status."] [". $hornbill_api_status ."] [".$file_name."]\n";
        curl_close($ch);
    }
    
    ?>

    And the 1000 attachments against the request:

    image.png

    Hope this helps, 

    Steve

  6. Hi @vhayer and @MattZ,

    Apologies for the delay in responding, I've been on annual leave. The issue here is that you're providing the entire URL to the web frontend for your instance in the instanceName variable, instead of just the instance name.

    So for example, if your instance was called myinstance, you are currently setting:

    instanceName = "https://live.hornbill.com/myinstance/"

    When this should actually read:

    instanceName = "myinstance"

    Hope this helps,

    Steve

  7. Hi @Martyn Houghton,

    The process would be:

    • HTTP POST the file to the users session folder in dav, providing the API key in the header in the same was as you do for other API calls: https://mdh-p01-api.hornbill.com/yourinstanceid/dav/session/yourfilename.png
    • Make an API call to apps/com.hornbill.servicemanager/Requests::attachFileFromSession as below to attach the file
    • HTTP DELETE the file from the users session folder (same URL as above)
    <methodCall service="apps/com.hornbill.servicemanager/Requests" method="attachFileFromSession">
      <params>
        <requestId>IN00012345</requestId>
        <fileName>/session/yourfilename.png</fileName>
        <description>some file description</description>
        <visibility>trustedGuest</visibility>
      </params>
    </methodCall>

    Hope this helps,

    Steve

    • Like 1
  8. Hi @AndyGilly,

    The preferred method to do what you need is:

    Write-Output "{{SISJobOutputParameterStart:MoverADGroups}}$($output){{SISJobOutputParameterEnd}}"

    Note the use of a subexpression $($output), this will ensure your variable is printed as you would expect, in the event it's not of type string.

    Cheers,

    Steve

  9. Hi @Paul Alexander,

    This would require a small change in Service Manager to be able to add this feature to the cleaner tool - I'll add it to the list, but if you're after a quick fix you could always export a list of references for the requests you wish to delete, and add them to the RequestReferences array in the cleaner config. With this set and CleanRequests set to true, running the tool will delete just those requests (and related records). 

    image.png

    Hope this helps,

    Steve

  10. Hi @BillP,

    There's a good example of how to manage this requirement within the LDAP Import tool, in the userImageUpdate function from the image.go file you have linked above. The process is basically:

    • HTTP PUT the file into the session folder in dav, with the link (replacing yourinstanceid and thefilename as appropriate :)):  https://mdh-p01-api.hornbill.com/yourinstanceid/dav/session/thefilename.jpg
    • Use  activity::profileImageSet to apply the profile image, where sourceImage would be /session/thefilename.jpg
    • HTTP DELETE the file from your session folder in dav, with the link from the PUT. This is to ensure your session folder doesn't end up being full of unnecessary files.

    Note, the HTTP PUT and HTTP DELETE need authenticating, so you'll need to provide the API Key for the user you are using in the Authorization header, in the same manner as you would for making XMLMC API calls into Hornbill.

    With regards to the profileImageGet output, you can get these images via https://mdh-p01-api.hornbill.com/yourinstanceid/dav/_static/img/thevalueofimageReference_theimageresolution.jpg

    So for example, if you had a user profile with an image reference of 50/0000002698, and you wanted the image with a resolution of 512x512, then your url would be:

    https://mdh-p01-api.hornbill.com/yourinstanceid/dav/_static/img/50/0000002698_512x512.jpg

    As always, you will need a valid session, or API key, to get at those images. Supported resolutions are:

    • 16x16
    • 24x24
    • 32x32
    • 54x54
    • 64x64
    • 128x128
    • 200x200
    • 220x264
    • 256x256
    • 512x512

    Note, you don't need to update the image in these resolutions, the userProfileSet API takes care of the resize/cropping for you.

    Hope this helps,

    Steve

     

    • Like 1
  11. Hi @AndyGilly,

    This is posssibly due to the default ErrorAction for the cmdlet in question not being Stop. I've seen examples where the error is output to the CLI and the script continues as normal, even when in a try-catch. If the cmdlet you are using supports it, then set the -ErrorAction Stop argument (either directly in the command line, or by splatting the param(s) in a hash table, example below). This will ensure the error can be caught and handled gracefully.

    try {
        $Params = @{
            Name = $Name
            ErrorAction = "Stop"
            WarningVariable = "warnings"
            WarningAction = "SilentlyContinue"
        }
        Start-VM @Params
    } catch {
        Write-Output "{{SISJobOutputParameterStart:errors}}$($_.Exception.Message){{SISJobOutputParameterEnd}}"
        Write-Output "{{SISJobOutputParameterStart:outcome}}FAIL{{SISJobOutputParameterEnd}}"
        Exit 0
    }

    Cheers,

    Steve

    • Like 1
×
×
  • Create New...