import requests from orm.common.orm_common.utils import utils from orm.common.orm_common.utils.cross_api_utils import (get_regions_of_group, set_utils_conf) from orm.services.customer_manager.cms_rest.data.data_manager import DataManager from orm.services.customer_manager.cms_rest.data.sql_alchemy.models import CustomerMetadata, UserRole from orm.services.customer_manager.cms_rest.logger import get_logger from orm.services.customer_manager.cms_rest.logic.error_base import ( DuplicateEntryError, ErrorStatus, NotFound) from orm.services.customer_manager.cms_rest.model.Models import ( CustomerResultWrapper, CustomerSummary, CustomerSummaryResponse, RegionResultWrapper, UserResultWrapper) from orm.services.customer_manager.cms_rest.rds_proxy import RdsProxy LOG = get_logger(__name__) class CustomerLogic(object): def build_full_customer(self, customer, uuid, datamanager): sql_customer = datamanager.add_customer(customer, uuid) for key, value in customer.metadata.iteritems(): metadata = CustomerMetadata(field_key=key, field_value=value) sql_customer.customer_metadata.append(metadata) datamanager.add_customer_region(sql_customer.id, -1) default_region_users = [] for user in customer.users: sql_user = datamanager.add_user(user)
import os from pecan.commands import CommandRunner from pecan import make_app from orm.common.orm_common.policy import policy from orm.common.orm_common.utils import utils from orm.services.customer_manager.cms_rest.logger import get_logger from orm.services.customer_manager.cms_rest import model from orm.services.customer_manager.cms_rest.utils import authentication logger = get_logger(__name__) def setup_app(config): model.init_model() token_conf = authentication._get_token_conf(config) policy.init(config.authentication.policy_file, token_conf) app_conf = dict(config.app) # setting configurations for utils to be used from now and on utils.set_utils_conf(config) app = make_app(app_conf.pop('root'), logging=getattr(config, 'logging', {}), **app_conf) logger.info('Starting CMS...') return app def main(): dir_name = os.path.dirname(__file__)