diff --git a/scalpels/cli/actions/load.py b/scalpels/cli/actions/load.py index 6cb2acd..77a3c70 100644 --- a/scalpels/cli/actions/load.py +++ b/scalpels/cli/actions/load.py @@ -2,6 +2,8 @@ #-*- coding:utf-8 -*- # Author: Kun Huang +from novaclient import client +import os def run(config): loads = (k for k in config if config[k]) @@ -13,6 +15,25 @@ def run(config): continue loadcall(config) +def get_creds_from_env(): + user = os.environ.get("OS_USERNAME") + pw = os.environ.get("OS_PASSWORD") + tenant = os.environ.get("OS_TENANT_NAME") + auth_url= os.environ.get("OS_AUTH_URL") + return (user, pw, tenant, auth_url) + +def nova_boot_bulk(): + creds = get_creds_from_env() + if None in creds: + raise ValueError("can't find all necessary creds from env: %s" % creds) + nova = client.Client(2, *creds) + image = nova.images.get("a1e6a7a5-2e77-42a6-8417-1f47ba7ba911") + flavor = nova.flavors.get("3") + nics = [{"net-id":"c5e2d25d-72ef-4ef4-b39e-f10027f9289d"}] + ret = nova.servers.create(name="bulk-foo", image=image, flavor=flavor, min_count=2, max_count=2, nics=nics) + print "we got %s" % ret + return + def load_storm(config): #TODO use novaclient python api to do this - print "now, let's run nova boot api in current." + nova_boot_bulk()