diff --git a/io_manifests/basic_ros_publisher_subscriber/docker_publisher_subscriber_manifest.json b/io_manifests/basic_ros_publisher_subscriber/docker_publisher_subscriber_manifest.json index 6379e57..25db0e1 100644 --- a/io_manifests/basic_ros_publisher_subscriber/docker_publisher_subscriber_manifest.json +++ b/io_manifests/basic_ros_publisher_subscriber/docker_publisher_subscriber_manifest.json @@ -85,10 +85,8 @@ "includePackages": [], "dependentDeployments": [], "inboundROSInterfaces": { - "topics": [], - "services": [], - "actions": [] - }, + "anyIncomingScopedOrTargetedRosConfig": false + }, "exposedParameters": [] }] } \ No newline at end of file diff --git a/io_manifests/basic_ros_publisher_subscriber/preinstalled_ros_publisher_subsciber_manifest.json b/io_manifests/basic_ros_publisher_subscriber/preinstalled_ros_publisher_subscriber_manifest.json similarity index 96% rename from io_manifests/basic_ros_publisher_subscriber/preinstalled_ros_publisher_subsciber_manifest.json rename to io_manifests/basic_ros_publisher_subscriber/preinstalled_ros_publisher_subscriber_manifest.json index 60d07db..6561f98 100644 --- a/io_manifests/basic_ros_publisher_subscriber/preinstalled_ros_publisher_subsciber_manifest.json +++ b/io_manifests/basic_ros_publisher_subscriber/preinstalled_ros_publisher_subscriber_manifest.json @@ -76,10 +76,8 @@ "includePackages": [], "dependentDeployments": [], "inboundROSInterfaces": { - "topics": [], - "services": [], - "actions": [] - }, + "anyIncomingScopedOrTargetedRosConfig": false + }, "exposedParameters": [] }] } \ No newline at end of file diff --git a/io_manifests/turtlesim/command_center_manifest.json b/io_manifests/turtlesim/command_center_manifest.json index cf63249..d22f0f1 100644 --- a/io_manifests/turtlesim/command_center_manifest.json +++ b/io_manifests/turtlesim/command_center_manifest.json @@ -74,17 +74,7 @@ "includePackages": [], "dependentDeployments": [], "inboundROSInterfaces": { - "topics": [{ - "name": "/pose" - }], - "services": [{ - "name": "/teleport_turtle" - }], - "actions": [{ - "name": "/turtle_1/goto_action" - }, { - "name": "/turtle_0/goto_action" - }] + "anyIncomingScopedOrTargetedRosConfig": true }, "exposedParameters": [] }] diff --git a/io_manifests/turtlesim/simulator_manifest.json b/io_manifests/turtlesim/simulator_manifest.json index 6a648ac..97b4b57 100644 --- a/io_manifests/turtlesim/simulator_manifest.json +++ b/io_manifests/turtlesim/simulator_manifest.json @@ -71,11 +71,7 @@ "includePackages": [], "dependentDeployments": [], "inboundROSInterfaces": { - "topics": [{ - "name": "/sim/cmd_vel" - }], - "services": [], - "actions": [] + "anyIncomingScopedOrTargetedRosConfig": true }, "exposedParameters": [] }] diff --git a/io_manifests/turtlesim/turtle_manifest.json b/io_manifests/turtlesim/turtle_manifest.json index be035c9..d00b781 100644 --- a/io_manifests/turtlesim/turtle_manifest.json +++ b/io_manifests/turtlesim/turtle_manifest.json @@ -69,9 +69,7 @@ "includePackages": [], "dependentDeployments": [], "inboundROSInterfaces": { - "topics": [], - "services": [], - "actions": [] + "anyIncomingScopedOrTargetedRosConfig": true }, "exposedParameters": [] }] diff --git a/io_manifests/turtlesim/user_interface_manifest.json b/io_manifests/turtlesim/user_interface_manifest.json index 9094c52..1272385 100644 --- a/io_manifests/turtlesim/user_interface_manifest.json +++ b/io_manifests/turtlesim/user_interface_manifest.json @@ -46,9 +46,7 @@ "includePackages": [], "dependentDeployments": [], "inboundROSInterfaces": { - "topics": [], - "services": [], - "actions": [] + "anyIncomingScopedOrTargetedRosConfig": true }, "exposedParameters": [] }] diff --git a/sdk_samples/minio_file_server.ipynb b/sdk_samples/minio_file_server.ipynb new file mode 100644 index 0000000..d6346a9 --- /dev/null +++ b/sdk_samples/minio_file_server.ipynb @@ -0,0 +1,230 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### rapyuta.io SDK minio file-server example.\n", + "Deploy minio file server to rapyuta.io\n", + "\n", + "ojb-store-deployment-tutorial: https://userdocs.rapyuta.io/developer-guide/create-software-packages/persistent-storage/obj-store-deployment-tutorial/\n", + "\n", + "SDK doc: https://docs.rapyuta.io/python-sdk/" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 1.Auth, Parameter and File psths.\n", + "you can get auth from rapyuta.io console\n", + "\n", + "SDK auth token:https://userdocs.rapyuta.io/developer-guide/tooling-automation/python-sdk/sdk-tokens-parameters/" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "AUTH_TOKEN = ''\n", + "PROJECT_ID = ''\n", + "\n", + "#params\n", + "retry_count=90\n", + "interval=10\n", + "minio_params = {\n", + " 'MINIO_ACCESS_KEY': 'rapyuta123',\n", + " 'MINIO_SECRET_KEY': 'rapyuta123'\n", + "}\n", + "\n", + "#file paths of package manifests\n", + "base_path = '../io_manifests/'\n", + "minio_manifest = 'minio_file_server_manifest.json'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 2. import module and create Client Instance" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from rapyuta_io import Client, DeploymentPhaseConstants, DiskType\n", + "\n", + "client = Client(AUTH_TOKEN, PROJECT_ID)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 3. Create package" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "import json\n", + "import time\n", + "from pprint import pprint\n", + "\n", + "def create_package(file_path, packages):\n", + " json_data = open(file_path, 'r')\n", + " json_load = json.load(json_data)\n", + " package_id = None\n", + " for package in packages:\n", + " if package['packageName'] == json_load['name'] and \\\n", + " package['packageVersion'] == json_load['packageVersion']:\n", + " package_id = package['packageId']\n", + " break\n", + " if not package_id:\n", + " res = client.create_package(json_load, retry_limit=3)\n", + " print(json_load['name'] + json_load['packageVersion'] + ' was created')\n", + " package_id = res['packageId']\n", + " else :\n", + " print(json_load['name'] + json_load['packageVersion'] + ' exist')\n", + " \n", + " return package_id\n", + "\n", + "def get_plan_id(pakcage_id, index=0):\n", + " pack = client.get_package(pakcage_id)\n", + " return pack['plans'][index]['planId']\n", + "\n", + "def get_ids(base_path, manifest, packages):\n", + " file_path = os.path.join(base_path, manifest)\n", + " package_id = create_package(file_path, packages)\n", + " plan_id = get_plan_id(package_id) \n", + " return {\n", + " 'packageId': package_id,\n", + " 'planId': plan_id \n", + " }\n", + "\n", + "packages = client.get_all_packages()\n", + "# pprint(packages)\n", + "\n", + "minio_ids = get_ids(base_path, minio_manifest ,packages) " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 4.Create persistent volume" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "volume = client.get_persistent_volume()\n", + "volumes = volume.get_all_volume_instances()\n", + "\n", + "persistent_vol_deployment = None\n", + "persistent_vol_name = 'persistent_vol_minio'\n", + "for vol in volumes:\n", + " if vol['name'] == persistent_vol_name and vol['phase'] == 'Succeeded':\n", + " persistent_vol_deployment = volume.get_volume_instance(vol['deploymentId'])\n", + " print('Persistent Vol was found and will be used.')\n", + " break\n", + "\n", + "if not persistent_vol_deployment: \n", + " print ('Creating a new persistent volume deployment... ')\n", + " persistent_vol_deployment = volume.create_volume_instance(persistent_vol_name, 32, DiskType.SSD)\n", + " result = persistent_vol_deployment.poll_deployment_till_ready(retry_count=retry_count, sleep_interval=interval)\n", + " print ('Persistent Vol are created')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 3.Deploy package" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Device Talker code snippet\n", + "package = client.get_package(minio_ids['packageId'])\n", + "configuration = package.get_provision_configuration(minio_ids['planId'])\n", + "for key in minio_params:\n", + " configuration.add_parameter('MinIO_FS', key, minio_params[key])\n", + "configuration.mount_volume(component_name='MinIO_FS',\n", + " volume_instance=persistent_vol_deployment,\n", + " mount_path=\"/data\")\n", + "deployment = package.provision(deployment_name = 'minio-file-server',\n", + "\t\t\t\t\t\tprovision_configuration = configuration)\n", + "result = deployment.poll_deployment_till_ready(retry_count=retry_count, sleep_interval=interval)\n", + "print 'Minio endpoint: ' + result['componentInfo'][0]['networkEndpoints']['FileStorage']" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 4. Deprovison all" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "deployment.deprovision()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.17" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/sdk_samples/publisher_subscriber.ipynb b/sdk_samples/publisher_subscriber.ipynb new file mode 100644 index 0000000..8a26e7f --- /dev/null +++ b/sdk_samples/publisher_subscriber.ipynb @@ -0,0 +1,250 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### rapyuta.io SDK publisher subscriber example.\n", + "ROS topic communication between device and cloud instance with rapyuta.io\n", + "In this example you can use the package created by publisher-subscirber tutorial.\n", + "\n", + "basic-ros-pubsub:\n", + "\n", + "preinstall: https://userdocs.rapyuta.io/build-solutions/sample-walkthroughs/basic-ros-pubsub/preinstalled-runtime/\n", + "\n", + "docker: https://userdocs.rapyuta.io/build-solutions/sample-walkthroughs/basic-ros-pubsub/docker-runtime/\n", + "\n", + "SDK doc: https://docs.rapyuta.io/python-sdk/" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 1.Auth, Parameter and File psths.\n", + "you can get auth from rapyuta.io console\n", + "\n", + "SDK auth token:https://userdocs.rapyuta.io/developer-guide/tooling-automation/python-sdk/sdk-tokens-parameters/\n", + "\n", + "Device onboarding: https://userdocs.rapyuta.io/developer-guide/manage-machines/onboarding/" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "AUTH_TOKEN = ''\n", + "PROJECT_ID = ''\n", + "\n", + "#params\n", + "retry_count=90\n", + "interval=10\n", + "device_id = 'e20b04fb-8b2b-422d-9f74-37cd4db042cf'\n", + "runtime = 'preinstalled'\n", + "# runtime = 'docker'\n", + "\n", + "#file paths of package manifests\n", + "base_path = '../io_manifests/basic_ros_publisher_subscriber'\n", + "if runtime == 'preinstalled':\n", + " pubsub_manifest = 'preinstalled_ros_publisher_subscriber_manifest.json'\n", + "elif runtime == 'docker':\n", + " pubsub_manifest = 'docker_publisher_subscriber_manifest.json'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 2. import module and create Client Instance" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from rapyuta_io import Client, DeploymentPhaseConstants, DiskType\n", + "from rapyuta_io.clients.package import ROSDistro\n", + "\n", + "client = Client(AUTH_TOKEN, PROJECT_ID)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 3. Create routed network" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "networks = client.get_all_routed_networks()\n", + "network = None\n", + "network_name = 'route_network'\n", + "for net in networks:\n", + " if net.name == network_name and net.get_status().status == \"Running\":\n", + " network = net\n", + " print('route_network' + \" was found and will be used\")\n", + " break\n", + " \n", + "if not network:\n", + " network = client.create_cloud_routed_network(network_name, ROSDistro.MELODIC, True)\n", + " network.poll_routed_network_till_ready(retry_count=retry_count, sleep_interval=interval)\n", + " print('route_network' + \"was created successfully\")\n", + "\n", + "routed_networks = [network]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 3. Create package" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "scrolled": true + }, + "outputs": [], + "source": [ + "import os\n", + "import json\n", + "import time\n", + "from pprint import pprint\n", + "\n", + "def create_package(file_path, packages):\n", + " json_data = open(file_path, 'r')\n", + " json_load = json.load(json_data)\n", + " package_id = None\n", + " for package in packages:\n", + " if package['packageName'] == json_load['name'] and \\\n", + " package['packageVersion'] == json_load['packageVersion']:\n", + " package_id = package['packageId']\n", + " break\n", + " if not package_id:\n", + " res = client.create_package(json_load, retry_limit=3)\n", + " print(json_load['name'] + json_load['packageVersion'] + ' was created')\n", + " package_id = res['packageId']\n", + " else :\n", + " print(json_load['name'] + json_load['packageVersion'] + ' exist')\n", + " \n", + " return package_id\n", + "\n", + "def get_plan_id(pakcage_id, index=0):\n", + " pack = client.get_package(pakcage_id)\n", + " return pack['plans'][index]['planId']\n", + "\n", + "def get_ids(base_path, manifest, packages):\n", + " file_path = os.path.join(base_path, manifest)\n", + " package_id = create_package(file_path, packages)\n", + " plan_id = get_plan_id(package_id) \n", + " return {\n", + " 'packageId': package_id,\n", + " 'planId': plan_id \n", + " }\n", + "\n", + "def wait_till_package_ready(package_id, retry_count=15, sleep_interval=6):\n", + " count = 0\n", + " while client.get_package(package_id)['status'] != 'Complete':\n", + " time.sleep(sleep_interval)\n", + " count+=1\n", + " if count > retry_count:\n", + " return False\n", + " return True\n", + "\n", + "\n", + "packages = client.get_all_packages()\n", + "# pprint(packages)\n", + "\n", + "pubsub_ids = get_ids(base_path, pubsub_manifest ,packages) " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 3.Deploy package" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Device Talker code snippet\n", + "if not wait_till_package_ready(pubsub_ids['packageId'], retry_count, interval):\n", + " exit(0)\n", + "package = client.get_package(pubsub_ids['packageId'])\n", + "device = client.get_device(device_id)\n", + "configuration = package.get_provision_configuration(pubsub_ids['planId'])\n", + "configuration.add_device('listener', device)\n", + "configuration.add_routed_networks(routed_networks)\n", + "deployment = package.provision(deployment_name = \"talker-listener\",\n", + "\t\t\t\t\t\tprovision_configuration = configuration)\n", + "res = deployment.poll_deployment_till_ready(retry_count=retry_count, sleep_interval=interval)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 7.Deprovision all" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "deployment.deprovision()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.17" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/sdk_samples/turtlesim.ipynb b/sdk_samples/turtlesim.ipynb new file mode 100644 index 0000000..6a5a57c --- /dev/null +++ b/sdk_samples/turtlesim.ipynb @@ -0,0 +1,328 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### rapyuta.io SDK turtlesim example.\n", + "Deploy turtlesim tutorial from SDK.\n", + "\n", + "turtlesim tutorial: https://userdocs.rapyuta.io/quick-walkthrough/\n", + "\n", + "SDK doc: https://docs.rapyuta.io/python-sdk/" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 1.Auth, Parameter and File psths.\n", + "you can get auth from rapyuta.io console\n", + "\n", + "SDK auth token:https://userdocs.rapyuta.io/developer-guide/tooling-automation/python-sdk/sdk-tokens-parameters/" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "AUTH_TOKEN = ''\n", + "PROJECT_ID = ''\n", + "\n", + "#params\n", + "DEPLOYMENT_PREFIX = 'turtlesim_'\n", + "TURTLE_NUM = 2 #max=2\n", + "retry_count=90\n", + "interval=10\n", + "\n", + "#file paths of package manifests\n", + "base_path = '../io_manifests/turtlesim'\n", + "com_manifest = 'command_center_manifest.json'\n", + "sim_manifest = 'simulator_manifest.json'\n", + "turtle_manifest = 'turtle_manifest.json'\n", + "ui_manifest = 'user_interface_manifest.json'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 2. import module and create Client Instance" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from rapyuta_io import Client, DeploymentPhaseConstants, DiskType\n", + "from rapyuta_io.clients.package import ROSDistro\n", + "\n", + "client = Client(AUTH_TOKEN, PROJECT_ID)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 3. Create routed network" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "networks = client.get_all_routed_networks()\n", + "network = None\n", + "network_name = DEPLOYMENT_PREFIX + 'route_network'\n", + "for net in networks:\n", + " if net.name == network_name and net.get_status().status == \"Running\":\n", + " network = net\n", + " print(DEPLOYMENT_PREFIX + 'route_network' + \" was found and will be used\")\n", + " break\n", + " \n", + "if not network:\n", + " network = client.create_cloud_routed_network(network_name, ROSDistro.MELODIC, True)\n", + " network.poll_routed_network_till_ready(retry_count=retry_count, sleep_interval=interval)\n", + " print(DEPLOYMENT_PREFIX + 'route_network' + \"was created successfully\")\n", + "\n", + "routed_networks = [network]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 4. Create package" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "scrolled": true + }, + "outputs": [], + "source": [ + "import os\n", + "import json\n", + "import time\n", + "from pprint import pprint\n", + "\n", + "def create_package(file_path, packages):\n", + " json_data = open(file_path, 'r')\n", + " json_load = json.load(json_data)\n", + " package_id = None\n", + " for package in packages:\n", + " if package['packageName'] == json_load['name'] and \\\n", + " package['packageVersion'] == json_load['packageVersion']:\n", + " package_id = package['packageId']\n", + " break\n", + " if not package_id:\n", + " res = client.create_package(json_load, retry_limit=3)\n", + " print(json_load['name'] + json_load['packageVersion'] + ' was created')\n", + " package_id = res['packageId']\n", + " else :\n", + " print(json_load['name'] + json_load['packageVersion'] + ' exist')\n", + " \n", + " return package_id\n", + "\n", + "def get_plan_id(pakcage_id, index=0):\n", + " pack = client.get_package(pakcage_id)\n", + " return pack['plans'][index]['planId']\n", + "\n", + "def get_ids(base_path, manifest, packages):\n", + " file_path = os.path.join(base_path, manifest)\n", + " package_id = create_package(file_path, packages)\n", + " plan_id = get_plan_id(package_id) \n", + " return {\n", + " 'packageId': package_id,\n", + " 'planId': plan_id \n", + " }\n", + "\n", + "def wait_till_package_ready(package_id, retry_count=15, sleep_interval=6):\n", + " count = 0\n", + " while client.get_package(package_id)['status'] != 'Complete':\n", + " time.sleep(sleep_interval)\n", + " count+=1\n", + " if count > retry_count:\n", + " return False\n", + " return True\n", + "\n", + "\n", + "packages = client.get_all_packages()\n", + "# pprint(packages)\n", + "\n", + "sim_ids = get_ids(base_path, sim_manifest ,packages) \n", + "com_ids = get_ids(base_path, com_manifest ,packages) \n", + "turtle_ids = get_ids(base_path, turtle_manifest ,packages) \n", + "ui_ids = get_ids(base_path, ui_manifest ,packages) " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 3.Simulator deployment" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "if not wait_till_package_ready(sim_ids['packageId'], retry_count, interval):\n", + " exit(0)\n", + "simulator_package = client.get_package(sim_ids['packageId'])\n", + "simulator_configuration = simulator_package.get_provision_configuration(sim_ids['planId'])\n", + "simulator_configuration.add_routed_networks(routed_networks)\n", + "simulator_deployment = simulator_package.provision(\n", + " deployment_name = DEPLOYMENT_PREFIX + 'simulator',\n", + "\t\t\t\tprovision_configuration = simulator_configuration)\n", + "res = simulator_deployment.poll_deployment_till_ready(retry_count=retry_count, sleep_interval=interval)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 4.Command Center deployment" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "if not wait_till_package_ready(com_ids['packageId'], retry_count, interval):\n", + " exit(0)\n", + "command_center_package = client.get_package(com_ids['packageId'])\n", + "command_center_configuration = command_center_package.get_provision_configuration(com_ids['planId'])\n", + "command_center_configuration.add_routed_networks(routed_networks)\n", + "command_center_deployment = command_center_package.provision(\n", + " deployment_name = DEPLOYMENT_PREFIX + 'command_center',\n", + "\t\t\t\tprovision_configuration = command_center_configuration)\n", + "res = command_center_deployment.poll_deployment_till_ready(retry_count=retry_count, sleep_interval=interval)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 5.UI deployment" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "if not wait_till_package_ready(ui_ids['packageId'], retry_count, interval):\n", + " exit(0)\n", + "ui_package = client.get_package(ui_ids['packageId'])\n", + "ui_configuration = ui_package.get_provision_configuration(ui_ids['planId'])\n", + "ui_configuration.add_dependent_deployment(command_center_deployment)\n", + "ui_deployment = ui_package.provision(\n", + " deployment_name = DEPLOYMENT_PREFIX + 'ui',\n", + "\t\t\t\tprovision_configuration = ui_configuration)\n", + "result = ui_deployment.poll_deployment_till_ready(retry_count=retry_count, sleep_interval=interval)\n", + "print 'UI endpoint: ' + result['componentInfo'][0]['networkEndpoints']['UserInterface']" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 6.Turtle deployments" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "if not wait_till_package_ready(turtle_ids['packageId'], retry_count, interval):\n", + " exit(0)\n", + "turtle_package = client.get_package(turtle_ids['packageId'])\n", + "turtle_deployments = []\n", + "for i in range(TURTLE_NUM):\n", + " turtle_configuration = turtle_package.get_provision_configuration(turtle_ids['planId'])\n", + " turtle_configuration.add_routed_networks(routed_networks)\n", + " turtle_configuration.set_component_alias('turtle', 'turtle'+str(i))\n", + " turtle_deployment = turtle_package.provision(\n", + " deployment_name = DEPLOYMENT_PREFIX + 'turtle' + str(i),\n", + " provision_configuration = turtle_configuration)\n", + " turtle_deployments.append(turtle_deployment)\n", + "\n", + "for i in range(TURTLE_NUM):\n", + " turtle_deployments[i].poll_deployment_till_ready(retry_count=retry_count, sleep_interval=interval)\n", + " print('Turtle' + str(i) + ' started')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### 7.Deprovision all" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "retry_limit = 3\n", + "simulator_deployment.deprovision(retry_limit)\n", + "command_center_deployment.deprovision(retry_limit)\n", + "ui_deployment.deprovision(retry_limit)\n", + "for i in range(TURTLE_NUM):\n", + " turtle_deployments[i].deprovision(retry_limit)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.17" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +}