Scenario 3 – create an environment

This scenario will create an environment, then take a snapshot of it to an existing blueprint.

Get a list all blueprints available for an environment

Request

https://use.cloudshare.com/API/v2/Env/CreateEntAppEnvOptions?timestamp=1363331588&token=CBJOXMLZAF&UserApiId=VWRWJ4550LB086FG&HMAC=8340f0b1765de0495575e65463864794be4ca8ee

Response

{
    "data": [
        {
            "Blueprints": [
                {
                    "Name": "CloudShare Documentation linux proto",
                    "Snapshots": [
                        {
                            "Author": "Schachar Levin",
                            "Comment": "",
                            "CreationTime": "11/29/2012 5:54 PM",
                            "IsDefault": true,
                            "IsLatest": true,
                            "Name": "snap1",
                            "snapshotId": "CBEQ10MT1YBB"
                        }
                    ]
                }
            ],
            "EnvironmentPolicyDuration": "PoC (10 days)",
            "EnvironmentPolicyId": "T0JCP2VQ1XHA",
            "Organizations": [
                "CloudShare"
            ],
            "Project": "Documentation Campaign"
        },
        {
            "Blueprints": [
                {
                    "Name": "linux environment",
                    "Snapshots": [
                        {
                            "Author": "john smith",
                            "Comment": null,
                            "CreationTime": "12/2/2012 8:09 AM",
                            "IsDefault": true,
                            "IsLatest": true,
                            "Name": "newsnapshot",
                            "snapshotId": "Q4VCZH0U2SGA"
                        }
                    ]
                }
            ],
            "EnvironmentPolicyDuration": "PoC (10 days)",
            "EnvironmentPolicyId": "GSMKV44JETNA",
            "Organizations": [
                "CloudShare"
            ],
            "Project": "Documentation Campaign"
        },
        {
            "Blueprints": [
                {
                    "Name": "newProto",
                    "Snapshots": [
                        {
                            "Author": "john smith",
                            "Comment": null,
                            "CreationTime": "12/2/2012 11:51 AM",
                            "IsDefault": true,
                            "IsLatest": true,
                            "Name": "snap2",
                            "snapshotId": "4T4UJZBDC1QB"
                        }
                    ]
                }
            ],
            "EnvironmentPolicyDuration": "PoC (10 days)",
            "EnvironmentPolicyId": "SY1FYBBEUMGB",
            "Organizations": [
                "CloudShare"
            ],
            "Project": "Documentation Campaign"
        }
    ],
    "remaining_api_calls": 99994,
    "status_additional_data": null,
    "status_code": "0x20000",
    "status_text": "Success"
}
Create a new environment, with environment name Linux2

Project is “Documentation Project”, from list in previous step.

Request

https://use.cloudshare.com/API/v2/Env/CreateEmptyEntAppEnv?description=A%20new%20linux%20environment&envName=Linux2&projectName=API%20Documentation%20Campaign&timestamp=1363336644&token=N75XA890XN&UserApiId=VWRWJ4550LB086FG&HMAC=b0f8cf4d7cd5b1ef6f90401f3be0d9b3832fd1e8

Response

{
    "data": {
        "successMessage": "Environment Linux2 is being created"
    },
    "remaining_api_calls": 99984,
    "status_additional_data": null,
    "status_code": "0x20000",
    "status_text": "Success"
}
Get list of all environments

Search for the environment with the name Linux2 and get the envId for it (used in the next step).

The envId in this case is HA0VLW3GJ0PA

Request

https://use.cloudshare.com/API/v2/Env/ListEnvironments?timestamp=1363337863&token=YV7F998WU1&UserApiId=VWRWJ4550LB086FG&HMAC=e5ee819d587c563e1958495c8e9b4c0bf83927ea

Response

{
    "data": [
        {
            "blueprint": "CloudShare Documentation linux proto",
            "description": " CloudShare Pro environment",
            "envId": "M1KPOT1Z5V1A",
            "envToken": "x8tVu_-txyY6IhB7dxDxhA2",
            "environmentPolicy": "CloudShare/PoC (10 days)",
            "expirationTime": "Sat, 16 Mar 2013 09:20:37 GMT",
            "invitationAllowed": true,
            "licenseValid": "Not relevant",
            "name": "A linux environment",
            "organization": "CloudShare",
            "owner": "jsmith@company.com",
            "project": "Documentation Campaign",
            "snapshot": "snap1",
            "status_code": 2,
            "status_text": "Not ready",
            "view_url": "https://use.cloudshare.com/Ent/Environment.mvc/View/x8tVu_-txyY6IhB7dxDxhA2"
        },
        {
            "blueprint": "A linux environment",
            "description": " CloudShare Pro environment",
            "envId": "V0MDPUQHHN1A",
            "envToken": "VQbE1o1IBQK6B633_UFGog2",
            "environmentPolicy": null,
            "expirationTime": "Wed, 18 Dec 2013 22:00:00 GMT",
            "invitationAllowed": true,
            "licenseValid": "Valid",
            "name": "A linux environment",
            "organization": null,
            "owner": "jsmith@company.com",
            "project": null,
            "snapshot": "snap1",
            "status_code": 2,
            "status_text": "Not ready",
            "view_url": "https://use.cloudshare.com/Pro/Environment.mvc/View/VQbE1o1IBQK6B633_UFGog2"
        },
        {
            "blueprint": "Linux2",
            "description": "A new linux environment",
            "envId": "HA0VLW3GJ0PA",
            "envToken": "Gh5wSR5wN2nm7I6orvTcDg2",
            "environmentPolicy": "CloudShare/PoC (10 days)",
            "expirationTime": "Thu, 04 Apr 2013 08:37:32 GMT",
            "invitationAllowed": false,
            "licenseValid": "Not relevant",
            "name": "Linux2",
            "organization": "CloudShare",
            "owner": "jsmith@company.com",
            "project": "Documentation Campaign",
            "snapshot": null,
            "status_code": 0,
            "status_text": "Ready",
            "view_url": "https://use.cloudshare.com/Ent/Environment.mvc/View/Gh5wSR5wN2nm7I6orvTcDg2"
        }
    ],
    "remaining_api_calls": 99983,
    "status_additional_data": null,
    "status_code": "0x20000",
    "status_text": "Success"
}
Wait until environment is ready

Check the response for status_text. When the environment is ready the state will be Ready.

Request

https://use.cloudshare.com/API/v2/Env/GetEnvironmentState?envId=HA0VLW3GJ0PA&timestamp=1363338132&token=BJTQKHL8DO&UserApiId=VWRWJ4550LB086FG&HMAC=59640d07e3859daf8ba2205bd0f206576460aa6d

Response

{
    "data": {
        "available_actions": {
            "add_vms": true,
            "delete_vm": false,
            "reboot_vm": true,
            "resume_environment": false,
            "revert_environment": false,
            "revert_vm": false,
            "take_snapshot": true
        },
        "blueprint": "Linux2",
        "description": "A new linux environment",
        "envId": "HA0VLW3GJ0PA",
        "envToken": "Gh5wSR5wN2nm7I6orvTcDg2",
        "environmentPolicy": "CloudShare/PoC (10 days)",
        "expirationTime": "Thu, 04 Apr 2013 08:37:32 GMT",
        "invitationAllowed": false,
        "licenseValid": "Not relevant",
        "name": "Linux2",
        "organization": "CloudShare",
        "owner": "jsmith@company.com",
        "project": "Documentation Campaign",
        "resources": {
            "cpu_in_use": 0,
            "cpu_qouta": 10,
            "disk_size_in_use_mb": 0,
            "disk_size_qouta_mb": 204800,
            "total_memory_in_use_mb": 0,
            "total_memory_qouta_mb": 10240
        },
        "snapshot": null,
        "status_code": 0,
        "status_text": "Ready",
        "view_url": "https://use.cloudshare.com/Ent/Environment.mvc/View/Gh5wSR5wN2nm7I6orvTcDg2",
        "vms": []
    },
    "remaining_api_calls": 99982,
    "status_additional_data": null,
    "status_code": "0x20000",
    "status_text": "Success"
}
Get a list of all blueprints for publishing available for the environment.

From the response list, use the blueprint linux environment with id LWD0GW52CEJA

Request

https://use.cloudshare.com/API/v2/Env/GetBlueprintsForPublish?envId=HA0VLW3GJ0PA&timestamp=1363339007&token=SSNG6JL1W4&UserApiId=VWRWJ4550LB086FG&HMAC=77ed25c87ac6cc3c882ec1c441985fa5db8567a8

Response

{
    "data": [
        {
            "ApiId": "TXRICZURB1TA",
            "Name": "CloudShare Documentation linux proto"
        },
        {
            "ApiId": "LWD0GW52CEJA",
            "Name": "linux environment"
        },
        {
            "ApiId": "RG1DSAXBFEJB",
            "Name": "newProto"
        }
    ],
    "remaining_api_calls": 99981,
    "status_additional_data": null,
    "status_code": "0x20000",
    "status_text": "Success"
}
Take a snapshot of the environment to a blueprint.

Use the blueprint linux environment from the previous step, with id LWD0GW52CEJA

Request

https://use.cloudshare.com/API/v2/Env/EntAppTakeSnapshotToExistingBlueprint?envId=HA0VLW3GJ0PA&otherBlueprintId=LWD0GW52CEJA&setAsDefault=true&snapshotName=Initial%20State%20Snapshot&timestamp=1363339960&token=6N2NKCHRYR&UserApiId=VWRWJ4550LB086FG&HMAC=1f22d78cea0a22da2052c451c71062a11ad3e8eb

Response

{
    "data": {
        "envId": "HA0VLW3GJ0PA"
    },
    "remaining_api_calls": 99979,
    "status_additional_data": null,
    "status_code": "0x20000",
    "status_text": "Success"
}
Get list of all blueprints available for the environment

The response should include details for the new snapshot taken for the blueprint linux environment.

Request

https://use.cloudshare.com/API/v2/Env/CreateEntAppEnvOptions?timestamp=1363340355&token=1W5Z10DQC1&UserApiId=VWRWJ4550LB086FG&HMAC=2424b9e46c7d428e0b066ec2c13f9979aa442166

Response

{
    "data": [
        {
            "Blueprints": [
                {
                    "Name": "CloudShare Documentation linux proto",
                    "Snapshots": [
                        {
                            "Author": "Schachar Levin",
                            "Comment": "",
                            "CreationTime": "11/29/2012 5:54 PM",
                            "IsDefault": true,
                            "IsLatest": true,
                            "Name": "snap1",
                            "snapshotId": "CBEQ10MT1YBB"
                        }
                    ]
                }
            ],
            "EnvironmentPolicyDuration": "PoC (10 days)",
            "EnvironmentPolicyId": "T0JCP2VQ1XHA",
            "Organizations": [
                "CloudShare"
            ],
            "Project": "Documentation Campaign"
        },
        {
            "Blueprints": [
                {
                    "Name": "linux environment",
                    "Snapshots": [
                        {
                            "Author": "john smith",
                            "Comment": null,
                            "CreationTime": "12/2/2012 8:09 AM",
                            "IsDefault": false,
                            "IsLatest": false,
                            "Name": "newsnapshot",
                            "snapshotId": "Q4VCZH0U2SGA"
                        },
                        {
                            "Author": "john smith",
                            "Comment": null,
                            "CreationTime": "3/15/2013 9:32 AM",
                            "IsDefault": true,
                            "IsLatest": true,
                            "Name": "Initial State Snapshot",
                            "snapshotId": "25AK430NVL0A"
                        }
                    ]
                }
            ],
            "EnvironmentPolicyDuration": "PoC (10 days)",
            "EnvironmentPolicyId": "GSMKV44JETNA",
            "Organizations": [
                "CloudShare"
            ],
            "Project": "Documentation Campaign"
        },
        {
            "Blueprints": [
                {
                    "Name": "newProto",
                    "Snapshots": [
                        {
                            "Author": "john smith",
                            "Comment": null,
                            "CreationTime": "12/2/2012 11:51 AM",
                            "IsDefault": true,
                            "IsLatest": true,
                            "Name": "snap2",
                            "snapshotId": "4T4UJZBDC1QB"
                        }
                    ]
                }
            ],
            "EnvironmentPolicyDuration": "PoC (10 days)",
            "EnvironmentPolicyId": "SY1FYBBEUMGB",
            "Organizations": [
                "CloudShare"
            ],
            "Project": "Documentation Campaign"
        }
    ],
    "remaining_api_calls": 99978,
    "status_additional_data": null,
    "status_code": "0x20000",
    "status_text": "Success"
}
Create a new environment from the snapshot taken in the previous step

The snapshot id is 25AK430NVL0A. Include the description another linux environment

Request

https://use.cloudshare.com/API/v2/Env/CreateEntAppEnv?blueprintFilter=linux%20environment&description=another%20linux%20environment&environmentPolicyId=GSMKV44JETNA&snapshotId=25AK430NVL0A&timestamp=1363341940&token=VJ27FYB1B9&UserApiId=VWRWJ4550LB086FG&HMAC=cbdae227fad85850f5720183d5ea9b25f74348b6

Response

{
    "data": {
        "environmentPolicyId": "GSMKV44JETNA"
    },
    "remaining_api_calls": 99977,
    "status_additional_data": null,
    "status_code": "0x20000",
    "status_text": "Success"
}
Get list of all environments

Search for the environment with the name linux environment and get the envId for it (used in the next step).

The envId in this case is VJ1DWJYN5GXB

Request

https://use.cloudshare.com/API/v2/Env/ListEnvironments?timestamp=1363341564&token=LA86ATI6TA&UserApiId=VWRWJ4550LB086FG&HMAC=123e4cfe138abc5843b0af5eeebbcfdabed6b449

Response

{
    "data": [
        {
            "blueprint": "CloudShare Documentation linux proto",
            "description": " CloudShare Pro environment",
            "envId": "M1KPOT1Z5V1A",
            "envToken": "x8tVu_-txyY6IhB7dxDxhA2",
            "environmentPolicy": "CloudShare/PoC (10 days)",
            "expirationTime": "Sat, 16 Mar 2013 09:20:37 GMT",
            "invitationAllowed": true,
            "licenseValid": "Not relevant",
            "name": "A linux environment",
            "organization": "CloudShare",
            "owner": "jsmith@company.com",
            "project": "Documentation Campaign",
            "snapshot": "snap1",
            "status_code": 2,
            "status_text": "Not ready",
            "view_url": "https://use.cloudshare.com/Ent/Environment.mvc/View/x8tVu_-txyY6IhB7dxDxhA2"
        },
        {
            "blueprint": "A linux environment",
            "description": " CloudShare Pro environment",
            "envId": "V0MDPUQHHN1A",
            "envToken": "VQbE1o1IBQK6B633_UFGog2",
            "environmentPolicy": null,
            "expirationTime": "Wed, 18 Dec 2013 22:00:00 GMT",
            "invitationAllowed": true,
            "licenseValid": "Valid",
            "name": "A linux environment",
            "organization": null,
            "owner": "jsmith@company.com",
            "project": null,
            "snapshot": "snap1",
            "status_code": 2,
            "status_text": "Not ready",
            "view_url": "https://use.cloudshare.com/Pro/Environment.mvc/View/VQbE1o1IBQK6B633_UFGog2"
        },
        {
            "blueprint": "linux environment",
            "description": "another linux environment",
            "envId": "VJ1DWJYN5GXB",
            "envToken": "9wtGldOX2PVXHaUlrTRG2g2",
            "environmentPolicy": "CloudShare/PoC (10 days)",
            "expirationTime": "Thu, 04 Apr 2013 09:55:44 GMT",
            "invitationAllowed": true,
            "licenseValid": "Not relevant",
            "name": "Linux2",
            "organization": "CloudShare",
            "owner": "jsmith@company.com",
            "project": "Documentation Campaign",
            "snapshot": "Initial State Snapshot",
            "status_code": 0,
            "status_text": "Ready",
            "view_url": "https://use.cloudshare.com/Ent/Environment.mvc/View/9wtGldOX2PVXHaUlrTRG2g2"
        },
        {
            "blueprint": "Linux2",
            "description": "A new linux environment",
            "envId": "HA0VLW3GJ0PA",
            "envToken": "Gh5wSR5wN2nm7I6orvTcDg2",
            "environmentPolicy": "CloudShare/PoC (10 days)",
            "expirationTime": "Thu, 04 Apr 2013 08:37:32 GMT",
            "invitationAllowed": false,
            "licenseValid": "Not relevant",
            "name": "Linux2",
            "organization": "CloudShare",
            "owner": "jsmith@company.com",
            "project": "Documentation Campaign",
            "snapshot": null,
            "status_code": 2,
            "status_text": "Not ready",
            "view_url": "https://use.cloudshare.com/Ent/Environment.mvc/View/Gh5wSR5wN2nm7I6orvTcDg2"
        }
    ],
    "remaining_api_calls": 99976,
    "status_additional_data": null,
    "status_code": "0x20000",
    "status_text": "Success"
}
Wait until environment is ready

Use the environment id for the new environment, VJ1DWJYN5GXB

The status for the environment is Ready

Request

https://use.cloudshare.com/API/v2/Env/GetEnvironmentState?envId=VJ1DWJYN5GXB&timestamp=1363342617&token=XCIIM0SW8M&UserApiId=VWRWJ4550LB086FG&HMAC=9207ec77f15bc29e2fb4c82e6d99a82fa6e3d1eb

Response

{
    "data": {
        "available_actions": {
            "add_vms": true,
            "delete_vm": false,
            "reboot_vm": true,
            "resume_environment": false,
            "revert_environment": true,
            "revert_vm": false,
            "take_snapshot": true
        },
        "blueprint": "linux environment",
        "description": "A new linux environment",
        "envId": "VJ1DWJYN5GXB",
        "envToken": "9wtGldOX2PVXHaUlrTRG2g2",
        "environmentPolicy": "CloudShare/PoC (10 days)",
        "expirationTime": "Thu, 04 Apr 2013 09:55:44 GMT",
        "invitationAllowed": true,
        "licenseValid": "Not relevant",
        "name": "Linux2",
        "organization": "CloudShare",
        "owner": "jsmith@company.com",
        "project": "Documentation Campaign",
        "resources": {
            "cpu_in_use": 0,
            "cpu_qouta": 10,
            "disk_size_in_use_mb": 0,
            "disk_size_qouta_mb": 204800,
            "total_memory_in_use_mb": 0,
            "total_memory_qouta_mb": 10240
        },
        "snapshot": "Initial State Snapshot",
        "status_code": 0,
        "status_text": "Ready",
        "view_url": "https://use.cloudshare.com/Ent/Environment.mvc/View/9wtGldOX2PVXHaUlrTRG2g2",
        "vms": []
    },
    "remaining_api_calls": 99973,
    "status_additional_data": null,
    "status_code": "0x20000",
    "status_text": "Success"
}