#!/usr/bin/env python
# Usage: devops create [-h] [-r ROLE] {website}
# Summary: Create website
import sys
import os
import subprocess

pylib_dir = os.environ['_DEVOPS_ROOT'] + "/share/devops/"
sys.path.insert(0, pylib_dir)
import devop_config

CONFIG = devop_config.config()

def create_website(role=None):
    devop_config.ssh_cmd('knife openstack server create --node-name {role} --run-list "role[{role}]"'.format(role=role),host='local')

def main():
    switcher = {
        'website': create_website,

    }

    parser = devop_config.devop_args()
    parser.add_argument('command', choices=switcher.keys())
    args = parser.parse_args()

    if args.role is not None:
        role=args.role
    else:
        role=CONFIG.get('defaults','role')

    func = switcher.get(args.command, lambda: "nothing")
    func(role=role)

if __name__ == "__main__":
	main()
