Skip to content

Instantly share code, notes, and snippets.

@amcrn amcrn/cluster.client.md Secret
Last active May 4, 2019

Embed
What would you like to do?

Problem Statement

how to create a cluster of heterogenous (in terms of flavor, disk, configuration, region, type, etc.) instances via the python-troveclient.

Homogenous Nodes

$ trove help create-cluster
usage: trove create-cluster <name> <cluster_size> <datastore> <datastore_version> <flavor_id> <disk_size>
                            [--configuration <configuration>]

Creates a new cluster.

Positional arguments:
  <name>                Name of the cluster
  <cluster_size>        Size of the cluster (number of instances)
  <datastore>           A datastore name or UUID
  <datastore_version>   A datastore version name or UUID
  <flavor_id>           Flavor of the instance.
  <disk_size>           Size of the instance disk in GB

Optional arguments:
  --configuration <configuration>
                        UUID of the configuration group to attach to the
                        instance.
$ trove create-cluster products 3 mongodb "2.4.10" 12 50 --configuration 1-2-3-4

Heterogenous Nodes

Option #1: Inlining Differing Instances

$ trove create-cluster products 3 mongodb "2.4.10" 12 50 --configuration 1-2-3-4
  --instances '[{"flavorRef": "7",
                 "volume": {"size": 1},
                 "configuration": "b9c8a3f8-7ace-4aea-9908-7b555586d7b6",
                 "type": "arbiter"},
                {"flavorRef": "7",
                 "volume": {"size": 1},
                 "configuration": "b9c8a3f8-7ace-4aea-9908-7b555586d7b6",
                 "type": "arbiter"}
               ]'

The above would create 3 nodes with flavor=12, disk-size=50, config=1-2-3-4, and 2 nodes with flavor=7, disk-size=1, type=arbiter (a cluster of 5)

Option #2: ?

Thoughts

  • Do any of the other python clients support providing a raw json request, and/or is there an example of an openstack project issuing raw json requests? If so, perhaps the official python client can officially support homogenous clusters, but horizon and others provide the raw request to the client (or curl it).
@amcrn

This comment has been minimized.

Copy link
Owner Author

commented May 21, 2014

Heterogenous Options

example: three members in west, 2 secondaries in east, with two arbiters in eu

option #1: non-uniform --instances with json array

trove create-cluster <name> <cluster_size> <datastore> <datastore_version> <flavor> <disk_size> <config> --instances <instances>
$ trove create-cluster products 5 mongodb "2.4.10" 12 100 \
    --configuration e0a6a893-1e41-4a05-8252-3c2cb934dd79 \
    --instances '[{
                   "flavorRef": "7",
                   "volume": {"size": 1},
                   "configuration": "b9c8a3f8-7ace-4aea-9908-7b555586d7b6",
                   "type": "arbiter"
                  },
                  {
                    "flavorRef": "7",
                    "volume": {"size": 1},
                    "configuration": "b9c8a3f8-7ace-4aea-9908-7b555586d7b6",
                    "type": "arbiter"
                  }]'

Notes:

  • The non-uniform instances (i.e. they don't match the other 5 that want flavor=12, disk_size=100) must be provided via the optional --instances flag.

option #2: non-uniform instances, repeatable --instance flag

$ trove create-cluster products 5 mongodb "2.4.10" 12 100 \
    --configuration e0a6a893-1e41-4a05-8252-3c2cb934dd79 \
     --instance '{
                   "flavorRef": "7",
                   "volume": {"size": 1},
                   "configuration": "b9c8a3f8-7ace-4aea-9908-7b555586d7b6",
                   "type": "arbiter"
                 }' \
    --instance '{
                 "flavorRef": "7",
                 "volume": {"size": 1},
                 "configuration": "b9c8a3f8-7ace-4aea-9908-7b555586d7b6",
                 "type": "arbiter"
                }'

option #3: non-uniform instances with block-device-mapping-style colons, repeatable --instance flag

$ trove create-cluster products 5 mongodb "2.4.10" 12 100 \
    --configuration e0a6a893-1e41-4a05-8252-3c2cb934dd79 \
    --instance 7:1:b9c8a3f8-7ace-4aea-9908-7b555586d7b6:arbiter \
    --instance 7:1:b9c8a3f8-7ace-4aea-9908-7b555586d7b6:arbiter

option #4: all instances with block-device-mapping-style colons, repeatable --instance flag

$ trove create-cluster products mongodb "2.4.10"
    --instance 12:100:e0a6a893-1e41-4a05-8252-3c2cb934dd79: \
    --instance 12:100:e0a6a893-1e41-4a05-8252-3c2cb934dd79: \
    --instance 12:100:e0a6a893-1e41-4a05-8252-3c2cb934dd79: \
    --instance 12:100:e0a6a893-1e41-4a05-8252-3c2cb934dd79: \
    --instance 12:100:e0a6a893-1e41-4a05-8252-3c2cb934dd79: \
    --instance 7:1:b9c8a3f8-7ace-4aea-9908-7b555586d7b6:arbiter \
    --instance 7:1:b9c8a3f8-7ace-4aea-9908-7b555586d7b6:arbiter

Notes:

  • Permutations of this include changing ':' to "," or ";"

option 5: all instances with block-device-mapping-style colons, but with labels, repeatable --instance flag

$ trove create-cluster products mongodb "2.4.10"
    --instance flavor=12:disk=100:config=e0a6a893-1e41-4a05-8252-3c2cb934dd79: \
    --instance flavor=12:disk=100:config=e0a6a893-1e41-4a05-8252-3c2cb934dd79: \
    --instance flavor=12:disk=100:config=e0a6a893-1e41-4a05-8252-3c2cb934dd79: \
    --instance flavor=12:disk=100:config=e0a6a893-1e41-4a05-8252-3c2cb934dd79: \
    --instance flavor=12:disk=100:config=e0a6a893-1e41-4a05-8252-3c2cb934dd79: \
    --instance flavor=7:disk=1:config=b9c8a3f8-7ace-4aea-9908-7b555586d7b6:type=arbiter \
    --instance flavor=7:disk=1:config=b9c8a3f8-7ace-4aea-9908-7b555586d7b6:type=arbiter

Notes:

  • Permutations of this include changing '=' and/or ':'

option #6: all instances with json format, repeatable --instance flag

$ trove create-cluster products mongodb "2.4.10" \
     --instance '{
                   "flavorRef": "12",
                   "volume": {"size": 100},
                   "configuration": "e0a6a893-1e41-4a05-8252-3c2cb934dd79",
                 }' \
     --instance '{
                   "flavorRef": "12",
                   "volume": {"size": 100},
                   "configuration": "e0a6a893-1e41-4a05-8252-3c2cb934dd79",
                 }' \
     --instance '{
                   "flavorRef": "12",
                   "volume": {"size": 100},
                   "configuration": "e0a6a893-1e41-4a05-8252-3c2cb934dd79",
                 }' \
     --instance '{
                   "flavorRef": "12",
                   "volume": {"size": 100},
                   "configuration": "e0a6a893-1e41-4a05-8252-3c2cb934dd79",
                 }' \
     --instance '{
                   "flavorRef": "12",
                   "volume": {"size": 100},
                   "configuration": "e0a6a893-1e41-4a05-8252-3c2cb934dd79",
                 }' \
     --instance '{
                   "flavorRef": "7",
                   "volume": {"size": 1},
                   "configuration": "b9c8a3f8-7ace-4aea-9908-7b555586d7b6",
                   "type": "arbiter"
                 }' \
    --instance  '{
                   "flavorRef": "7",
                   "volume": {"size": 1},
                   "configuration": "b9c8a3f8-7ace-4aea-9908-7b555586d7b6",
                   "type": "arbiter"
                 }'

option #7: comma separated per field

trove create-cluster <name> <datastore> <datastore_version> <flavor,...,flavorN> <disk_size,...,disk_sizeN> <config,...,configN> <type,...,typeN>
$ trove create-cluster products mongodb "2.4.10" \
    "12,12,12,12,12,7,7" \
    "100,100,100,100,100,1,1" \
    "e0a6a893-1e41-4a05-8252-3c2cb934dd79,e0a6a893-1e41-4a05-8252-3c2cb934dd79,e0a6a893-1e41-4a05-8252-3c2cb934dd79,e0a6a893-1e41-4a05-8252-3c2cb934dd79,e0a6a893-1e41-4a05-8252-3c2cb934dd79,b9c8a3f8-7ace-4aea-9908-7b555586d7b6,b9c8a3f8-7ace-4aea-9908-7b555586d7b6" \
    ",,,,,arbiter,arbiter"

option #8: repeatable positional

$ trove create-cluster products mongodb "2.4.10" \
    instance --flavorRef 12 --size 100 --configuration e0a6a893-1e41-4a05-8252-3c2cb934dd79 \
    instance --flavorRef 12 --size 100 --configuration e0a6a893-1e41-4a05-8252-3c2cb934dd79 \
    instance --flavorRef 12 --size 100 --configuration e0a6a893-1e41-4a05-8252-3c2cb934dd79 \
    instance --flavorRef 12 --size 100 --configuration e0a6a893-1e41-4a05-8252-3c2cb934dd79 \
    instance --flavorRef 12 --size 100 --configuration e0a6a893-1e41-4a05-8252-3c2cb934dd79 \
    instance --flavorRef 7 --size 1 --configuration b9c8a3f8-7ace-4aea-9908-7b555586d7b6 \
    instance --flavorRef 7 --size 1 --configuration b9c8a3f8-7ace-4aea-9908-7b555586d7b6

Notes:

  • is misleading because it's marking flavorRef and size as optional to force the printing of "--", despite them being required.
@amcrn

This comment has been minimized.

Copy link
Owner Author

commented May 21, 2014

option #9

$ trove create-cluster products 5 mongodb "2.4.10" 12 100 \
    --configuration e0a6a893-1e41-4a05-8252-3c2cb934dd79 \
    --instance flavor=7:disk=1:config=b9c8a3f8-7ace-4aea-9908-7b555586d7b6:type=arbiter \
    --instance flavor=7:disk=1:config=b9c8a3f8-7ace-4aea-9908-7b555586d7b6:type=arbiter

option 10: multi-non-uniform instances with block-device-mapping-style colons, but with labels, repeatable --instance flag

option #10:

trove create-cluster products mongodb "2.4.10" \
    --instance count=2:flavor=12:disk=100:config=e0a6a893-1e41-4a05-8252-3c2cb934dd79:region=EAST \
    --instance count=3:flavor=12:disk=100:config=e0a6a893-1e41-4a05-8252-3c2cb934dd79:region=WEST \
    --instance flavor=12:disk=100:config=e0a6a893-1e41-4a05-8252-3c2cb934dd79:region=CENTRAL \
    --instance count=2:flavor=7:disk=1:config=b9c8a3f8-7ace-4aea-9908-7b555586d7b6:type=arbiter:region=EAST
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.