jamf / JamfMigrator

A tool to migrate data granularly between Jamf Pro servers
MIT License
140 stars 10 forks source link

Conflict when migrating Smart Computer Groups #9

Closed ftiff closed 6 years ago

ftiff commented 6 years ago

Hi Leslie,

Tested on 10.0.0-b.3.t1505777008 with jamf-migrator Version 2.1.0 (1)

I get the following conflict when migrating Smart Computer Groups:

**** CRITICAL NO TextMate - Failed
<?xml version="1.0" encoding="UTF-8"?>
<computer_group>
    <name>CRITICAL NO TextMate</name>
    <is_smart>true</is_smart>
    <site>
        <name>None</name>
    </site>
    <criteria>
        <size>1</size>
        <criterion>
            <name>Application Title</name>
            <priority>0</priority>
            <and_or>and</and_or>
            <search_type>is not</search_type>
            <value>TextMate.app</value>
            <opening_paren>false</opening_paren>
            <closing_paren>false</closing_paren>
        </criterion>
    </criteria>
    <computers>
        <size>1</size>
        <computer>
            <name>Tom’s MacBook Air</name>
            <mac_address>C4:B3:01:93:34:56</mac_address>
            <alt_mac_address>9A:00:0A:27:B3:20</alt_mac_address>
            <serial_number>C02S7130GFWL</serial_number>
        </computer>
    </computers>
</computer_group>
HTTP status code: 409

Error message is:

<html>
<head>
   <title>Status page</title>
</head>
<body style="font-family: sans-serif;">
<p style="font-size: 1.2em;font-weight: bold;margin: 1em 0px;">Conflict</p>
<p>Error: Unable to match computer </p>
<p>You can get technical details <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.10">here</a>.<br>
Please continue your visit at our <a href="/">home page</a>.
</p>
</body>
</html>

This is solved by removing <computers>…</computers> which is not needed in Smart Computer Groups anyway:

<?xml version="1.0" encoding="UTF-8"?>
<computer_group>
    <name>CRITICAL NO TextMate</name>
    <is_smart>true</is_smart>
    <site>
        <name>None</name>
    </site>
    <criteria>
        <size>1</size>
        <criterion>
            <name>Application Title</name>
            <priority>0</priority>
            <and_or>and</and_or>
            <search_type>is not</search_type>
            <value>TextMate.app</value>
            <opening_paren>false</opening_paren>
            <closing_paren>false</closing_paren>
        </criterion>
    </criteria>
</computer_group>

Is this something you're willing to work on?

Thanks, François

BIG-RAT commented 6 years ago

Good day François, Thanks for the note. I’ll have to give things a closer look. I have the following that is, and I thought has, removed computers from smart groups.

if endpoint == "smartcomputergroups" {
    let regexComp = try! NSRegularExpression(pattern: "<computers>(.*?)</computers>", options:.caseInsensitive)
    PostXML = regexComp.stringByReplacingMatches(in: PostXML, options: [], range: NSRange(0..<PostXML.utf16.count), withTemplate: "")
}

Cheers, leslie

On Sep 24, 2017, at 3:40 AM, Francois Levaux-Tiffreau notifications@github.com<mailto:notifications@github.com> wrote:

Hi Leslie,

Tested on 10.0.0-b.3.t1505777008 with jamf-migrator Version 2.1.0 (1)

I get the following conflict when migrating Smart Computer Groups:

**** CRITICAL NO TextMate - Failed <?xml version="1.0" encoding="UTF-8"?>

CRITICAL NO TextMate true None 1 Application Title 0 and is not TextMate.app false false 1 Tom’s MacBook Air C4:B3:01:93:34:56 9A:00:0A:27:B3:20 C02S7130GFWL

HTTP status code: 409

Error message is:

Status page

Conflict

Error: Unable to match computer

You can get technical details here.
Please continue your visit at our home page.

This is solved by removing which is not needed in Smart Computer Groups anyway:

<?xml version="1.0" encoding="UTF-8"?>

CRITICAL NO TextMate true None 1 Application Title 0 and is not TextMate.app false false

Is this something you're willing to work on?

Thanks, François

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/jamfprofessionalservices/JamfMigrator/issues/9, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AVOIF9FHl82IQzcaTMpYEeb4Fya82Wj0ks5slgd3gaJpZM4Phzrp.

BIG-RAT commented 6 years ago

Modified how smart computer groups are identified so that computers are removed regardless if one is doing a bulk or selective migration.

ftiff commented 6 years ago

Well done! It works great. small advice: You can add something like "Fixes #9" in the commit title to link it to this issue. It will appear in line with the comments :) Thank you!