from cloudmesh.iaas.openstack.cm_compute import openstack from cloudmesh.iaas.ec2.cm_compute import ec2 from cloudmesh.iaas.openstack.cm_idm import keystone from cloudmesh.iaas.Ec2SecurityGroup import Ec2SecurityGroup from cloudmesh_common.logger import LOGGER from cloudmesh.util.stopwatch import StopWatch # from pprint import pprint import traceback from cloudmesh.util.encryptdata import decrypt import time # ---------------------------------------------------------------------- # SETTING UP A LOGGER # ---------------------------------------------------------------------- log = LOGGER(__file__) try: from cloudmesh.iaas.azure.cm_compute import azure except: log.warning("AZURE NOT ENABLED") try: from cloudmesh.iaas.aws.cm_compute import aws except: log.warning("Amazon NOT ENABLED") class cm_MongoBase(object): def __init__(self): self.cm_type = "overwriteme"
from cloudmesh_common.util import banner from cloudmesh.user.cm_user import cm_user from cloudmesh.config.cm_config import cm_config from cloudmesh.user.cm_template import cm_template from cloudmesh_common.util import yn_choice from cloudmesh.config.ConfigDict import ConfigDict from sh import less import os from pprint import pprint import yaml import json import ast from cloudmesh_common.logger import LOGGER log = LOGGER(__file__) def shell_command_user(arguments): """ Usage: user list user info [ID] Administrative command to lists the users from LDAP Arguments: list list the users ID list the user with the given ID
"""Some simple yaml file reader""" from __future__ import print_function from pprint import pprint import os import sys from cloudmesh_common.logger import LOGGER from cloudmesh_common.util import check_file_for_tabs from cloudmesh_install.util import path_expand as cm_path_expand import yaml from string import Template import traceback from collections import OrderedDict log = LOGGER(__file__) # http://stackoverflow.com/questions/5121931/in-python-how-can-you-load-yaml-mappings-as-ordereddicts def ordered_load(stream, Loader=yaml.Loader, object_pairs_hook=OrderedDict): class OrderedLoader(Loader): pass def construct_mapping(loader, node): loader.flatten_mapping(node) return object_pairs_hook(loader.construct_pairs(node)) OrderedLoader.add_constructor( yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG, construct_mapping) return yaml.load(stream, OrderedLoader)
from __future__ import print_function from cmd3.shell import command from pprint import pprint from cloudmesh.inventory import Inventory from cloudmesh_common.logger import LOGGER log = LOGGER(__file__) class cm_shell_inventory: """opt_example class""" inventory_connection = False inventory_name = None def info_cm_shell_inventory(self): print("%20s =" % "inventory_name", self.inventory_name) print("%20s =" % "inventory_connection", self.inventory_connection) def _connect_to_inventory(self): """connects to the inventory and prints an error if not successfull""" self.inventory_name = "test" try: # TODO: port number is missing # TODO: should be imported from cloudmesh_server.yaml # db = connect(self.inventory_name) self.inventory = Inventory() except: self.Inventory = None raise Exception("ERROR: connection to inventory failed") def activate_cm_shell_inventory(self):
from cloudmesh.iaas.openstack.cm_compute import openstack from cloudmesh.iaas.ec2.cm_compute import ec2 from cloudmesh.iaas.openstack.cm_idm import keystone from cloudmesh.iaas.Ec2SecurityGroup import Ec2SecurityGroup from cloudmesh_common.logger import LOGGER from cloudmesh.util.stopwatch import StopWatch # from pprint import pprint import traceback from cloudmesh.util.encryptdata import decrypt import time # ---------------------------------------------------------------------- # SETTING UP A LOGGER # ---------------------------------------------------------------------- log = LOGGER(__file__) try: from cloudmesh.iaas.azure.cm_compute import azure except: log.warning("AZURE NOT ENABLED") try: from cloudmesh.iaas.aws.cm_compute import aws except: log.warning("Amazon NOT ENABLED") class cm_MongoBase(object): def __init__(self):
from cloudmesh_install import config_file from flask import Blueprint, g, render_template, request from flask.ext.login import login_required from cloudmesh.config.ConfigDict import ConfigDict from cloudmesh.launcher.cm_launcher_db import cm_launcher_db from flask.ext.principal import Permission, RoleNeed from cloudmesh.config.cm_config import cm_config import subprocess from pprint import pprint from cloudmesh_common.logger import LOGGER LOG_MSG = LOGGER(__file__) launch_module = Blueprint('launch _module', __name__) RAIN_PERMISSION = Permission(RoleNeed('rain')) # # ROUTE: launch # # list of recipies which we need to get from cm_launcher.yaml # @RAIN_PERMISSION.require(http_exception=403) # @login_required # @RAIN_PERMISSION.require(http_exception=403) @launch_module.route('/cm/launch/launch_servers/', methods=["POST", "GET"]) def launch_servers(): config = cm_config() data = {
from __future__ import print_function from cmd3.shell import command from cloudmesh.user.cm_user import cm_user from cloudmesh.config.cm_projects import cm_projects from cloudmesh_install import config_file from cloudmesh_common.tables import two_column_table, print_format_dict from cloudmesh_common.logger import LOGGER import json log = LOGGER(__file__) class cm_shell_project: """opt_example class""" def _load_projects(self): if not self.cm_shell_project_loaded: filename = config_file("/cloudmesh.yaml") self.projects = cm_projects(filename) if self.echo: log.info( "Reading project information from -> {0}".format(filename)) self.cm_shell_project_loaded = True def activate_shell_project(self): self.register_command_topic('cloud', 'project') # # BUG this should be done outside of the activate # self.cm_shell_project_loaded = False
from os import listdir from os.path import isfile, join from flask import Blueprint import flask from cloudmesh_common.logger import LOGGER flatpages_module = Blueprint('flatpages_module', __name__) log = LOGGER(__file__) pages_files = [ f.replace(".md", "") for f in listdir("/static/pages") if isfile(join("/static/pages", f)) ] sidebar_flatpages = [] for page in pages_files: sidebar_flatpages.append({ "url": "/static/" + page + "/", "name": page.capitalize() }) flask.Flask.app_ctx_globals_class.sidebar_flatpages = sidebar_flatpages log.info("{0}".format(str( flask.Flask.app_ctx_globals_class.sidebar_flatpages)))
"""Some simple yaml file reader""" import os import sys from cloudmesh_common.logger import LOGGER from cloudmesh_common.util import check_file_for_tabs from cloudmesh_common.util import path_expand as cm_path_expand import yaml from string import Template import traceback log = LOGGER(__file__) def read_yaml_config(filename, check=True, osreplace=True): """ reads in a yaml file from the specified filename. If check is set to true the code will faile if the file does not exist. However if it is set to false and the file does not exist, None is returned. :param filename: the file name :param check: if True fails if the file does not exist, if False and the file does not exist return will be None """ location = filename if location is not None: location = cm_path_expand(location) if not os.path.exists(location) and not check: return None if check and os.path.exists(location):
from os import listdir from os.path import isfile, join from flask import Blueprint import flask from cloudmesh_common.logger import LOGGER flatpages_module = Blueprint('flatpages_module', __name__) log = LOGGER(__file__) pages_files = [f.replace(".md", "") for f in listdir("/static/pages") if isfile(join("/static/pages", f))] sidebar_flatpages = [] for page in pages_files: sidebar_flatpages.append( {"url": "/static/" + page + "/", "name": page.capitalize()}) flask.Flask.app_ctx_globals_class.sidebar_flatpages = sidebar_flatpages log.info( "{0}".format(str(flask.Flask.app_ctx_globals_class.sidebar_flatpages)))
import sys import importlib import simplejson as json import time import cmd from bson.json_util import dumps from cmd3.shell import command from cloudmesh.user.cm_user import cm_user from cloudmesh.cm_mongo import cm_mongo from cloudmesh.config.cm_config import cm_config from pprint import pprint from cloudmesh_common.logger import LOGGER from cloudmesh_common.tables import two_column_table import docopt log = LOGGER(__file__) # BUGS: # TODO: the try methods at the beginning should be called on teh first # call of this method to load the data. otherwise they should not be # called, e.g. dynamic loading # TODO: the defaults should be read at the beginning and when any # command is used that needs them. a logic needs to be defined so that # defaults are included in other methods after their first loading. a # boolean should help prevent constant reloading. # TODO: when printing flavors or images numbers are given instead of # user readable labels. in case of images the uuid is given
from __future__ import print_function from cmd3.shell import command from pprint import pprint from cloudmesh.inventory import Inventory from cloudmesh_common.logger import LOGGER log = LOGGER(__file__) class cm_shell_inventory: """opt_example class""" inventory_connection = False inventory_name = None def info_cm_shell_inventory(self): print("%20s =" % "inventory_name", self.inventory_name) print("%20s =" % "inventory_connection", self.inventory_connection) def _connect_to_inventory(self): """connects to the inventory and prints an error if not successfull""" self.inventory_name = "test" try: # TODO: port number is missing # TODO: should be imported from cloudmesh_server.yaml # db = connect(self.inventory_name) self.inventory = Inventory() except: self.Inventory = None raise Exception("ERROR: connection to inventory failed")
import importlib import simplejson as json import time import cmd from bson.json_util import dumps from cmd3.shell import command from cloudmesh.user.cm_user import cm_user from cloudmesh.cm_mongo import cm_mongo from cloudmesh.config.cm_config import cm_config from pprint import pprint from cloudmesh_common.logger import LOGGER from cloudmesh_common.tables import two_column_table import docopt log = LOGGER(__file__) # BUGS: # TODO: the try methods at the beginning should be called on teh first # call of this method to load the data. otherwise they should not be # called, e.g. dynamic loading # TODO: the defaults should be read at the beginning and when any # command is used that needs them. a logic needs to be defined so that # defaults are included in other methods after their first loading. a # boolean should help prevent constant reloading. # TODO: when printing flavors or images numbers are given instead of # user readable labels. in case of images the uuid is given