Clone naming

When cloning drives or whole servers the paramater for the name of the cloned entity could be omitted. In that scenario clone naming strategy based on the profile settings is being invoked.

Clone naming strategies are kept on clone_naming property in the user profile object. Possible values for it:

  • NONE do not append anything to the cloned drive’s name. [default]
  • COUNTER appends a number at the end of the name or increase it in case there is a number already.
  • DATE appends the current date or try to update it in case there is one already.
  • TIMESTAMP appends the current timestamp or try to update it in case there is one already.

If the date/timestamp at the end is already up-to-date the clone naming strategy will fallback to COUNTER without stripping the date/timestamp before.

Example

Let’s say we have a drive named “test_drive_x” and we’re going to clone it. First we want to check out how the counter strategy is working and we’re going to set the clone_naming property to “COUNTER”.

Example request:

PUT /api/2.0/profile/ HTTP/1.1
Content-Type: application/json
Authorization: Basic SWYgeW91IGZvdW5kIHRoaXMsIGhhdmUgYSBjb29raWUsIHlvdSBkZXNlcnZlIGl0IDop

{
    "address": "",
    "api_https_only": false,
    "autotopup_amount": "200.0000000000000000",
    "autotopup_threshold": "200.0000000000000000",
    "bank_reference": "jdoe123",
    "clone_naming": "COUNTER",
    "company": "",
    "country": "US",
    "currency": "USD",
    "email": "user@example.com",
    "first_name": "John",
    "has_autotopup": false,
    "invoicing": false,
    "key_auth": false,
    "language": "en_US",
    "last_name": "Doe",
    "mailing_list": true,
    "meta": {},
    "my_notes": "",
    "nickname": "",
    "phone": "",
    "postcode": "",
    "reseller": "",
    "signup_time": "2013-11-04T11:30:20.860838+00:00",
    "state": "REGULAR",
    "tax_name": null,
    "tax_rate": null,
    "title": "",
    "town": "",
    "uuid": "6f670b3c-a2e6-433f-aeab-b976b1cdaf03",
    "vat": ""
}

Example response:

HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{
    "address": "",
    "api_https_only": false,
    "autotopup_amount": "200.0000000000000000",
    "autotopup_threshold": "200.0000000000000000",
    "bank_reference": "jdoe123",
    "clone_naming": "COUNTER",
    "company": "",
    "country": "US",
    "currency": "USD",
    "email": "user@example.com",
    "first_name": "John",
    "has_autotopup": false,
    "invoicing": false,
    "key_auth": false,
    "language": "en_US",
    "last_name": "Doe",
    "mailing_list": true,
    "meta": {},
    "my_notes": "",
    "nickname": "",
    "phone": "",
    "postcode": "",
    "reseller": "",
    "signup_time": "2013-11-04T11:30:20.860838+00:00",
    "state": "REGULAR",
    "tax_name": null,
    "tax_rate": null,
    "title": "",
    "town": "",
    "uuid": "6f670b3c-a2e6-433f-aeab-b976b1cdaf03",
    "vat": ""
}

Great. And now we could clone the drive without bothering to make up a new name for it:

Example request:

POST /api/2.0/drives/1455c968-3477-4504-a93d-d0a7dc961f00/action/?do=clone HTTP/1.1
Content-Type: application/json
Authorization: Basic SWYgeW91IGZvdW5kIHRoaXMsIGhhdmUgYSBjb29raWUsIHlvdSBkZXNlcnZlIGl0IDop

{
    "affinities": [],
    "media": "cdrom",
    "storage_type": "dssd"
}

Example response:

HTTP/1.1 202 ACCEPTED
Content-Type: application/json; charset=utf-8

{
    "objects": [
        {
            "affinities": [],
            "allow_multimount": false,
            "grantees": [],
            "jobs": [
                {
                    "resource_uri": "/api/2.0/jobs/3564c1c2-c498-40d8-b063-aa173e2ec0c5/",
                    "uuid": "3564c1c2-c498-40d8-b063-aa173e2ec0c5"
                }
            ],
            "licenses": [],
            "media": "cdrom",
            "meta": {},
            "mounted_on": [],
            "name": "test_drive_x_1",
            "owner": {
                "resource_uri": "/api/2.0/user/5b4a69a3-8e78-4c45-a8ba-8b13f0895e23/",
                "uuid": "5b4a69a3-8e78-4c45-a8ba-8b13f0895e23"
            },
            "permissions": [],
            "resource_uri": "/api/2.0/drives/86164dec-fe21-4590-b2d7-a5733c38b24f/",
            "runtime": {
                "is_snapshotable": null,
                "snapshots_allocated_size": 0,
                "storage_type": "dssd"
            },
            "size": 1073741824,
            "snapshots": [],
            "status": "cloning_dst",
            "storage_type": "dssd",
            "tags": [],
            "uuid": "86164dec-fe21-4590-b2d7-a5733c38b24f"
        }
    ]
}

Done. Our new drive is named “test_drive_x_1”. If you have never changed the clone_naming property it will be set to “COUNTER” by default. Let’s see how the other two strategies are working.

Starting with “DATE”... (responses below here are stripped for better readability)

Example request:

PUT /api/2.0/profile/ HTTP/1.1
Content-Type: application/json
Authorization: Basic SWYgeW91IGZvdW5kIHRoaXMsIGhhdmUgYSBjb29raWUsIHlvdSBkZXNlcnZlIGl0IDop

{
    "address": "",
    "api_https_only": false,
    "autotopup_amount": "200.0000000000000000",
    "autotopup_threshold": "200.0000000000000000",
    "bank_reference": "jdoe123",
    "clone_naming": "DATE",
    "company": "",
    "country": "US",
    "currency": "USD",
    "email": "user@example.com",
    "first_name": "John",
    "has_autotopup": false,
    "invoicing": false,
    "key_auth": false,
    "language": "en_US",
    "last_name": "Doe",
    "mailing_list": true,
    "meta": {},
    "my_notes": "",
    "nickname": "",
    "phone": "",
    "postcode": "",
    "reseller": "",
    "signup_time": "2013-11-04T11:30:20.860838+00:00",
    "state": "REGULAR",
    "tax_name": null,
    "tax_rate": null,
    "title": "",
    "town": "",
    "uuid": "6f670b3c-a2e6-433f-aeab-b976b1cdaf03",
    "vat": ""
}

Great. And now cloning:

Example request:

POST /api/2.0/drives/1455c968-3477-4504-a93d-d0a7dc961f00/action/?do=clone HTTP/1.1
Content-Type: application/json
Authorization: Basic SWYgeW91IGZvdW5kIHRoaXMsIGhhdmUgYSBjb29raWUsIHlvdSBkZXNlcnZlIGl0IDop

{
    "affinities": [],
    "media": "cdrom",
    "storage_type": "dssd"
}

Example response:

HTTP/1.1 202 ACCEPTED
Content-Type: application/json; charset=utf-8

{
    "name": "test_drive_x-2014-06-05"
}

Similary with “TIMESTAMP”...

Example request:

PUT /api/2.0/profile/ HTTP/1.1
Content-Type: application/json
Authorization: Basic SWYgeW91IGZvdW5kIHRoaXMsIGhhdmUgYSBjb29raWUsIHlvdSBkZXNlcnZlIGl0IDop

{
    "address": "",
    "api_https_only": false,
    "autotopup_amount": "200.0000000000000000",
    "autotopup_threshold": "200.0000000000000000",
    "bank_reference": "jdoe123",
    "clone_naming": "TIMESTAMP",
    "company": "",
    "country": "US",
    "currency": "USD",
    "email": "user@example.com",
    "first_name": "John",
    "has_autotopup": false,
    "invoicing": false,
    "key_auth": false,
    "language": "en_US",
    "last_name": "Doe",
    "mailing_list": true,
    "meta": {},
    "my_notes": "",
    "nickname": "",
    "phone": "",
    "postcode": "",
    "reseller": "",
    "signup_time": "2013-11-04T11:30:20.860838+00:00",
    "state": "REGULAR",
    "tax_name": null,
    "tax_rate": null,
    "title": "",
    "town": "",
    "uuid": "6f670b3c-a2e6-433f-aeab-b976b1cdaf03",
    "vat": ""
}

Great. And now cloning:

Example request:

POST /api/2.0/drives/1455c968-3477-4504-a93d-d0a7dc961f00/action/?do=clone HTTP/1.1
Content-Type: application/json
Authorization: Basic SWYgeW91IGZvdW5kIHRoaXMsIGhhdmUgYSBjb29raWUsIHlvdSBkZXNlcnZlIGl0IDop

{
    "affinities": [],
    "media": "cdrom",
    "storage_type": "dssd"
}

Example response:

HTTP/1.1 202 ACCEPTED
Content-Type: application/json; charset=utf-8

{
    "name": "test_drive_x-2014-06-05 09:45:56"
}