Skip to content

Conversation

@shwstppr
Copy link
Member

Description

Problem: Currently tags cannot be applied to snapshot when it is being created but through separate “create tags” API calls. For snapshot policies tags cannot be set either at creation or through “create tags” API.

Root Cause: The “create snapshots” API does not support adding tags during creation and it can only be done through “create tags” API. Snapshot policy as a resource does not support tags and no tags can be set for them through any API.

Solution: Tag support for snapshot policy has been added. Snapshot policy with tags when executed will produce snapshots containing the same tags from snapshot policy.

Following APIs have been updated:

  • Both “create snapshotpolicy” and “create snapshot” now accepts “tags” as a new parameter. The expected format for “tags” parameter is similar to parameter “tags” in “create tags“ API.
  • Deletion support for tags associated with snapshots policy has been added to “delete snapshotpolicies” API.
  • Tags set for snapshot policies are added to the Response of “list snapshotpolicies“ API.

UI support for setting tags to snapshots and snapshot policy is provided through the corresponding menus with a new section in each form to set tags.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)

Screenshots (if appropriate):

screenshot from 2019-02-08 13-39-23
screenshot from 2019-02-08 13-38-53
screenshot from 2019-02-08 13-25-35

How Has This Been Tested?

UI And Cloudmonkey.

(local) 🐵 > create snapshot volumeid=9d4a3e48-2c27-4822-98c0-a79381cf4113 tags[0].key=keyss tags[0].value=valuess
 
{
  "accountid": "77891a42-1e18-11e9-8d89-34e12d5f623e",
  "cmd": "org.apache.cloudstack.api.command.user.snapshot.CreateSnapshotCmd",
  "created": "2019-02-08T00:01:15+0530",
  "jobid": "f4b82b0d-f256-4c87-a8b4-36bbcb44cdeb",
  "jobinstanceid": "21086b5a-42da-4bd1-aa10-d7e62bed88a9",
  "jobinstancetype": "Snapshot",
  "jobprocstatus": 0,
  "jobresult": {
    "snapshot": {
      "account": "admin",
      "created": "2019-02-08T00:01:15+0530",
      "domain": "ROOT",
      "domainid": "77890928-1e18-11e9-8d89-34e12d5f623e",
      "id": "21086b5a-42da-4bd1-aa10-d7e62bed88a9",
      "intervaltype": "MANUAL",
      "name": "vm1_ROOT-6_20190207183115",
      "osdisplayname": "CentOS 5.5 (64-bit)",
      "ostypeid": "7780d0f5-1e18-11e9-8d89-34e12d5f623e",
      "physicalsize": 1596588032,
      "revertable": true,
      "snapshottype": "MANUAL",
      "state": "BackedUp",
      "tags": [
        {
          "key": "keyss",
          "value": "valuess"
        }
      ],
      "virtualsize": 8589934592,
      "volumeid": "9d4a3e48-2c27-4822-98c0-a79381cf4113",
      "volumename": "ROOT-6",
      "volumetype": "ROOT",
      "zoneid": "df67395c-d21d-4404-adcc-a44c9994763d"
    }
  },
  "jobresultcode": 0,
  "jobresulttype": "object",
  "jobstatus": 1,
  "userid": "77892e56-1e18-11e9-8d89-34e12d5f623e"
}
(local) 🐵 > create snapshotpolicy volumeid=9d4a3e48-2c27-4822-98c0-a79381cf4113 schedule=1 maxsnaps=1 intervaltype=HOURLY timezone="Etc/GMT+12" tags[0].key=hello tags[0].value=world
{
  "snapshotpolicy": {
    "fordisplay": true,
    "id": "c9da9363-cbab-47d8-8d1c-cbc69c140946",
    "intervaltype": 0,
    "maxsnaps": 1,
    "schedule": "1",
    "tags": [
      {
        "account": "system",
        "domain": "ROOT",
        "domainid": "77890928-1e18-11e9-8d89-34e12d5f623e",
        "key": "hello",
        "resourceid": "c9da9363-cbab-47d8-8d1c-cbc69c140946",
        "resourcetype": "SnapshotPolicy",
        "value": "world"
      }
    ],
    "timezone": "Etc/GMT+12",
    "volumeid": "9d4a3e48-2c27-4822-98c0-a79381cf4113"
  }
}
(local) 🐵 > list snapshotpolicies id=c9da9363-cbab-47d8-8d1c-cbc69c140946
{
  "count": 1,
  "snapshotpolicy": [
    {
      "fordisplay": true,
      "id": "c9da9363-cbab-47d8-8d1c-cbc69c140946",
      "intervaltype": 0,
      "maxsnaps": 1,
      "schedule": "1",
      "tags": [
        {
          "account": "system",
          "domain": "ROOT",
          "domainid": "77890928-1e18-11e9-8d89-34e12d5f623e",
          "key": "hello",
          "resourceid": "c9da9363-cbab-47d8-8d1c-cbc69c140946",
          "resourcetype": "SnapshotPolicy",
          "value": "world"
        }
      ],
      "timezone": "Etc/GMT+12",
      "volumeid": "9d4a3e48-2c27-4822-98c0-a79381cf4113"
    }
  ]
}


This change allows adding tags to snapshots and snapshot policy while creating them.
createSnapshot, createSnapshotPolicy APIs have been modified to allow passing key-value based tags.
UI has been modified to show input controls for allowing addition of tags in both create snapshot and snapshot policy form.
Unit test for CreateSnapshotPolicyCmd has been added.

Signed-off-by: Abhishek Kumar <[email protected]>
@shwstppr
Copy link
Member Author

Testing done

@shwstppr shwstppr closed this Mar 14, 2019
rohityadavcloud added a commit that referenced this pull request Jan 20, 2021
This fixes #39

Signed-off-by: Rohit Yadav <[email protected]>
shwstppr added a commit that referenced this pull request Aug 16, 2021
Detaching volume after cross-cluster storage migration of a stopped was resulting in failure.
This PR fixes it by clearing last_host_id value and setting pod_id(podIdToDeployIn) in the database on cluster change when hypervisor migration strategy is used.

Also, backports worker VM hardware version changes during volume migration from community PR, apache#4385

Signed-off-by: Abhishek Kumar <[email protected]>
shwstppr added a commit that referenced this pull request Nov 23, 2021
Detaching volume after cross-cluster storage migration of a stopped was resulting in failure.
This PR fixes it by clearing last_host_id value and setting pod_id(podIdToDeployIn) in the database on cluster change when hypervisor migration strategy is used.

Also, backports worker VM hardware version changes during volume migration from community PR, apache#4385

Signed-off-by: Abhishek Kumar <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants