예제 #1
0
from cloudmesh_base.locations import config_file
from cloudmesh_base.ConfigDict import ConfigDict
from cloudmesh_base.logger import LOGGER

from pymongo import MongoClient
from mongoengine import connect

# Changes of import in existing cloudmesh code:
#
## FROM:
# from cloudmesh.config.cm_config import get_mongo_db, get_mongo_dbname_from_collection, DBConnFactory
## TO:
# from cloudmesh_database.dbconn import get_mongo_db, get_mongo_dbname_from_collection, DBConnFactory
##
log = LOGGER(__file__)

MONGOCLIENT = 0
MONGOENGINE = 1


class DBConnFactory(object):
    connectors = {}
    DBCONFIG = None
    TYPE_MONGOCLIENT = MONGOCLIENT
    TYPE_MONGOENGINE = MONGOENGINE

    @classmethod
    def getconn(cls, dbname, clientType=MONGOCLIENT):

        conn = None
예제 #2
0
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_base.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):
예제 #3
0
from cloudmesh.iaas.ec2.cm_compute import ec2
from cloudmesh.iaas.openstack.cm_idm import keystone
from cloudmesh.iaas.Ec2SecurityGroup import Ec2SecurityGroup
from cloudmesh_base.logger import LOGGER
from cloudmesh.util.stopwatch import StopWatch
from cloudmesh.util.encryptdata import decrypt
from cloudmesh.util.ssh import ssh_execute
import traceback
import time
import sys

# ----------------------------------------------------------------------
# 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("AWS NOT ENABLED")


class cm_MongoBase(object):
    def __init__(self):
        self.cm_type = "overwriteme"
예제 #4
0
import os
from pprint import pprint
import stat
from string import Template
import sys
import traceback

from cloudmesh_base.locations import config_file
from cloudmesh_base.logger import LOGGER
from cloudmesh_base.util import backup_name, path_expand

import simplejson
import yaml


log = LOGGER(__file__)
package_dir = os.path.dirname(os.path.abspath(__file__))
attribute_indent = 4


def check_file_for_tabs(filename, verbose=True):
    """identifies if the file contains tabs and returns True if it
    does. It also prints the location of the lines and columns. If
    verbose is set to False, the location is not printed.

    :param filename: the filename
    :rtype: True if there are tabs in the file
    """
    file_contains_tabs = False
    with file(filename) as f:
        lines = f.read().split("\n")
예제 #5
0
from os import listdir
from os.path import isfile, join
from flask import Blueprint
import flask
from cloudmesh_base.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)))
예제 #6
0
파일: config.py 프로젝트: lee212/cloudmesh
"""Some simple yaml file reader"""
from __future__ import print_function
from pprint import pprint
import os
import sys

from cloudmesh_base.logger import LOGGER
from cloudmesh_common.util import check_file_for_tabs
from cloudmesh_base.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)
예제 #7
0
from __future__ import print_function
from cmd3.shell import command
from pprint import pprint
from cloudmesh.inventory import Inventory
from cloudmesh_base.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")
예제 #8
0
from cloudmesh.iaas.ec2.cm_compute import ec2
from cloudmesh.iaas.openstack.cm_idm import keystone
from cloudmesh.iaas.Ec2SecurityGroup import Ec2SecurityGroup
from cloudmesh_base.logger import LOGGER
from cloudmesh.util.stopwatch import StopWatch
from cloudmesh.util.encryptdata import decrypt
from cloudmesh.util.ssh import ssh_execute
import traceback
import time
import sys

# ----------------------------------------------------------------------
# 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("AWS NOT ENABLED")


class cm_MongoBase(object):
    def __init__(self):
        self.cm_type = "overwriteme"
예제 #9
0
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_base.locations import config_file
from cloudmesh_common.tables import two_column_table, print_format_dict
from cloudmesh_base.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

    @command
예제 #10
0
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_base.locations import config_file
from cloudmesh_common.tables import two_column_table, print_format_dict
from cloudmesh_base.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
예제 #11
0
from __future__ import print_function
from cmd3.shell import command
from pprint import pprint
from cloudmesh.inventory import Inventory
from cloudmesh_base.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):
예제 #12
0
from cloudmesh_base.locations import config_file
from flask import Blueprint, g, render_template, request
from flask.ext.login import login_required
from cloudmesh_base.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_base.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 = {