当前位置: 首页>>代码示例>>Python>>正文


Python server_mgr_logger.ServerMgrlogger类代码示例

本文整理汇总了Python中server_mgr_logger.ServerMgrlogger的典型用法代码示例。如果您正苦于以下问题:Python ServerMgrlogger类的具体用法?Python ServerMgrlogger怎么用?Python ServerMgrlogger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ServerMgrlogger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, vm_params):
        global _smgr_log
        _smgr_log = ServerMgrlogger()
        _smgr_log.log(_smgr_log.DEBUG, "ContrailVM Init")

        self.vm = vm_params['vm']
        self.vmdk = vm_params['vmdk']
        self.datastore = vm_params['datastore']
        self.eth0_mac = vm_params['eth0_mac']
        self.eth0_ip = vm_params['eth0_ip']
        self.eth0_pg = vm_params['eth0_pg']
        self.eth0_vswitch = vm_params['eth0_vswitch']
        self.eth0_vlan = vm_params['eth0_vlan']
        self.eth1_vswitch = vm_params['eth1_vswitch']
        self.eth1_pg = vm_params['eth1_pg']
        self.eth1_vlan = vm_params['eth1_vlan']
        self.uplink_nic = vm_params['uplink_nic']
        self.uplink_vswitch = vm_params['uplink_vswitch']
        self.server = vm_params['server']
        self.username = vm_params['username']
        self.password = vm_params['password']
        self.thindisk = vm_params['thindisk']
	self.vm_domain = vm_params['domain']
        self.vm_id = 0
	self.smgr_ip = vm_params['smgr_ip']
	self.vm_server = vm_params['vm_server']
	self.vm_password = vm_params['vm_password']
	self.vm_deb = vm_params['vm_deb']
        self._create_networking()
        print self._create_vm()
        print self._install_contrailvm_pkg(self.eth0_ip, "root", self.vm_password, self.vm_domain, self.vm_server,
                                     self.vm_deb, self.smgr_ip)
开发者ID:Akilesh1597,项目名称:contrail-server-manager,代码行数:32,代码来源:esxi_contrailvm.py

示例2: __init__

class PlayLogger:
    """
    Store log output in a single object
    One object per Ansible run
    """
    def __init__(self):
        self.log = ''
        self.runtime = 0
        try:
            self._sm_logger = ServerMgrlogger()
        except:
            f = open("/var/log/contrail-server-manager/debug.log", "a")
            f.write("Ansible Callback Init - ServerMgrlogger init failed\n")
            f.close()


    def append(self, log_line):
        self.log += log_line+"\n"
        self._sm_logger.log(self._sm_logger.INFO, log_line)

    def banner(self, msg):
        width = 78 - len(msg)
        if width < 3:
            width = 3
        filler = "*" * width
        return "\n%s %s " % (msg, filler)
开发者ID:nitishkrishna,项目名称:contrail-server-manager,代码行数:26,代码来源:sm_ansible_callback.py

示例3: Joiner

class Joiner(threading.Thread):
    def __init__(self, q):
        super(Joiner, self).__init__()
        self._smgr_log = ServerMgrlogger()
        self.queue = q

    def run(self):
        while True:
            child = self.queue.get()
            self._smgr_log.log(self._smgr_log.INFO, "Joining a process")
            print "joining a process"
            if child == None:
                return
            child.join()
            self._smgr_log.log(self._smgr_log.INFO, "Process Done")
            print "process done"
开发者ID:Juniper,项目名称:contrail-server-manager,代码行数:16,代码来源:sm_ansible_server.py

示例4: run

    def run(self):
        #create the logger
        try:
            self._smgr_log = ServerMgrlogger()
        except:
            print "Error Creating logger object"

        # Connect to the cluster-servers database
        try:
            self._status_serverDb = db(
                self._smgr_main._args.server_manager_base_dir+self._smgr_main._args.database_name)
        except:
            self._smgr_log.log(self._smgr_log.DEBUG,
                     "Error Connecting to Server Database %s"
                    % (self._smgr_main._args.server_manager_base_dir+self._smgr_main._args.database_name))
            exit()

        #set the status related handlers
        status_bottle_app = Bottle()
        status_bottle_app.route('/server_status', 'POST', self.put_server_status)
        status_bottle_app.route('/server_status', 'PUT', self.put_server_status)
        self._base_obj = self._status_thread_config['base_obj']

        try:
            bottle.run(status_bottle_app,
                       host=self._status_thread_config['listen_ip'],
                       port=self._status_thread_config['listen_port'])
        except Exception as e:
            # cleanup gracefully
            exit()
开发者ID:biddyweb,项目名称:contrail-server-manager,代码行数:30,代码来源:server_mgr_status.py

示例5: __init__

    def __init__(self, base_dir=_DEF_BASE_DIR,
                 ip_address=_DEF_COBBLER_IP,
                 port=_DEF_COBBLER_PORT,
                 username=_DEF_USERNAME,
                 password=_DEF_PASSWORD):

        self._smgr_log = ServerMgrlogger()
        self._smgr_log.log(self._smgr_log.DEBUG, "ServerMgrCobbler Init")


        # Store the passed in values
        self._cobbler_ip = ip_address
        self._cobbler_port = port
        self._cobbler_username = username
        self._cobbler_password = password
        try:
            if self._cobbler_port:
                self._server = xmlrpclib.Server(
                    "http://" +
                    self._cobbler_ip + ":" +
                    self._cobbler_port + "/cobbler_api")
            else:
                self._server = xmlrpclib.Server(
                    "http://" +
                    self._cobbler_ip + "/cobbler_api")
            self._token = self._server.login(self._cobbler_username,
                                             self._cobbler_password)
        except subprocess.CalledProcessError as e:
            msg = ("Cobbler Init: error %d when executing"
                   "\"%s\"" %(e.returncode, e.cmd))
            self.log_and_raise_exception(msg, ERR_OPR_ERROR)
        except Exception as e:
            raise e
开发者ID:Akilesh1597,项目名称:contrail-server-manager,代码行数:33,代码来源:server_mgr_cobbler.py

示例6: __init__

    def __init__(self, json_entity, args):
        super(ContrailAnsiblePlaybooks, self).__init__()
        try:
            self.logger = ServerMgrlogger()
        except:
            f = open("/var/log/contrail-server-manager/debug.log", "a")
            f.write("Ansible Callback Init - ServerMgrlogger init failed\n")
            f.close()

        #Initialize common stuff
        self.json_entity  = json_entity
        self.args         = args
        self.hosts_in_inv = json_entity[0]["hosts_in_inv"]
        if "kolla_inv" in json_entity[0]["parameters"]:
            self.hosts_in_kolla_inv = \
                    SMAnsibleUtils(self.logger).hosts_in_kolla_inventory(\
                        json_entity[0]['parameters']['kolla_inv'])

        self.tasks        = re.split(r'[,\ ]+', json_entity[0]["tasks"])

        #Initialize vars required for Ansible Playbook APIs
        self.options      = None
        self.extra_vars   = None
        self.pbook_path   = None
        self.var_mgr      = None
        self.inventory    = None
        self.pb_executor  = None
开发者ID:Juniper,项目名称:contrail-server-manager,代码行数:27,代码来源:sm_ansible_playbook.py

示例7: __init__

    def __init__(self, serverdb=None, log_file=None):
        if serverdb:
            self._serverDb = serverdb
        else:
            self._serverDb = db(DEF_SERVER_DB_LOCATION)

        self._smgr_log = ServerMgrlogger()
开发者ID:nitishkrishna,项目名称:contrail-server-manager,代码行数:7,代码来源:server_mgr_ssh_client.py

示例8: __init__

    def __init__(self, base_dir=_DEF_BASE_DIR,
                 ip_address=_DEF_COBBLER_IP,
                 port=_DEF_COBBLER_PORT,
                 username=_DEF_USERNAME,
                 password=_DEF_PASSWORD):

        self._smgr_log = ServerMgrlogger()
        self._smgr_log.log(self._smgr_log.DEBUG, "ServerMgrCobbler Init")


        # Store the passed in values
        self._cobbler_ip = ip_address
        self._cobbler_port = port
        self._cobbler_username = username
        self._cobbler_password = password
        try:
            if self._cobbler_port:
                self._server = xmlrpclib.Server(
                    "http://" +
                    self._cobbler_ip + ":" +
                    self._cobbler_port + "/cobbler_api")
            else:
                self._server = xmlrpclib.Server(
                    "http://" +
                    self._cobbler_ip + "/cobbler_api")
            self._token = self._server.login(self._cobbler_username,
                                             self._cobbler_password)

            # Copy contrail centos repo to cobber repos, so that target
            # systems can install and run puppet agent from kickstart.
            repo = self._server.find_repo({"name": _CONTRAIL_CENTOS_REPO})
            if repo:
                rid = self._server.get_repo_handle(
                    _CONTRAIL_CENTOS_REPO, self._token)
            else:
                rid = self._server.new_repo(self._token)
            self._server.modify_repo(rid, "arch", "x86_64", self._token)
            repo_dir = base_dir + "contrail-centos-repo"
            self._server.modify_repo(
                rid, "name", _CONTRAIL_CENTOS_REPO, self._token)
            self._server.modify_repo(rid, "mirror", repo_dir, self._token)
            self._server.modify_repo(rid, "keep_updated", True, self._token)
            self._server.modify_repo(rid, "priority", "99", self._token)
            self._server.modify_repo(rid, "rpm_list", [], self._token)
            self._server.modify_repo(rid, "yumopts", {}, self._token)
            self._server.modify_repo(rid, "mirror_locally", True, self._token)
            self._server.modify_repo(rid, "environment", {}, self._token)
            self._server.modify_repo(rid, "comment", "...", self._token)
            self._server.save_repo(rid, self._token)
            # Issue cobbler reposync for this repo
            cmd = "cobbler reposync --only=" + _CONTRAIL_CENTOS_REPO
            subprocess.check_call(cmd, shell=True)
        except subprocess.CalledProcessError as e:
            msg = ("Cobbler Init: error %d when executing"
                   "\"%s\"" %(e.returncode, e.cmd))
            raise ServerMgrException(msg)
        except Exception as e:
            raise e
开发者ID:jufeng,项目名称:contrail-server-manager,代码行数:58,代码来源:server_mgr_cobbler.py

示例9: __init__

    def __init__(self, db_file_name=def_server_db_file):
        try:
            self._smgr_log = ServerMgrlogger()
            self._con = lite.connect(db_file_name)
            with self._con:
                cursor = self._con.cursor()
                # Create cluster table.
                cursor.execute("CREATE TABLE IF NOT EXISTS " + cluster_table +
                               """ (id TEXT PRIMARY KEY,
                                    parameters TEXT,
                                    email TEXT)""")
                # Create image table
                cursor.execute("CREATE TABLE IF NOT EXISTS " +
                               image_table + """ (id TEXT PRIMARY KEY,
                    version TEXT, type TEXT, path TEXT,
                    parameters TEXT)""")
                # Create status table
                cursor.execute("CREATE TABLE IF NOT EXISTS " +
                               server_status_table + """ (id TEXT PRIMARY KEY,
                            server_status TEXT)""")
                # Create server table
                cursor.execute(
                    "CREATE TABLE IF NOT EXISTS " + server_table +
                    """ (mac_address TEXT PRIMARY KEY NOT NULL,
                         id TEXT, host_name TEXT, static_ip varchar default 'N',
                         ip_address TEXT, subnet_mask TEXT, gateway TEXT, domain TEXT,
                         cluster_id TEXT,  base_image_id TEXT,
                         package_image_id TEXT, password TEXT,
                         last_update TEXT, discovered varchar default 'false',
                         parameters TEXT, roles TEXT, ipmi_username TEXT,
                         ipmi_password TEXT, ipmi_address TEXT,
                         ipmi_type TEXT, intf_control TEXT,
                         intf_data TEXT, intf_bond TEXT,
                         email TEXT, status TEXT,
                         tag1 TEXT, tag2 TEXT, tag3 TEXT,
                         tag4 TEXT, tag5 TEXT, tag6 TAXT, tag7 TEXT,
                         UNIQUE (id))""")
                # Create server tags table
                cursor.execute(
                    "CREATE TABLE IF NOT EXISTS " + server_tags_table +
                    """ (tag_id TEXT PRIMARY KEY NOT NULL,
                         value TEXT,
                         UNIQUE (tag_id),
                         UNIQUE (value))""")
            self._get_table_columns()
            self._smgr_log.log(self._smgr_log.DEBUG, "Created tables")

            # During init, we check if any of the Cluster in DB are missing any Storage Parameters (Generated UUIDs)
            cluster_list = self._get_items(cluster_table, None,
                                       None, True, None)
            for cluster in cluster_list:
                # Check if storage parameters are present in Cluster, else generate them
                if 'storage_fsid' not in set(eval(cluster['parameters'])) or 'storage_virsh_uuid' not in set(eval(
                        cluster['parameters'])):
                    self.update_cluster_uuids(cluster)
        except e:
            raise e
开发者ID:jufeng,项目名称:contrail-server-manager,代码行数:57,代码来源:server_mgr_db.py

示例10: __init__

    def __init__(self, smgr_base_dir, puppet_dir):
        self._smgr_log = ServerMgrlogger()
        self._smgr_log.log(self._smgr_log.DEBUG, "ServerMgrPuppet Init")


        self.smgr_base_dir = smgr_base_dir
        self.puppet_directory = puppet_dir
        if not os.path.exists(os.path.dirname(puppet_dir)):
            os.makedirs(os.path.dirname(puppet_dir))
开发者ID:Juniper,项目名称:contrail-server-manager,代码行数:9,代码来源:server_mgr_puppet.py

示例11: dict

class PlayLogger:
    default_config = dict()
    """
    Store log output in a single object
    One object per Ansible run
    """
    def __init__(self, cluster_id):
        self.log = ''
        self.runtime = 0
        self.defaults_file = "/etc/contrail/sm-client-config.ini"
        config = ConfigParser.SafeConfigParser()
        config.read([self.defaults_file])
        self.default_config["smgr"] = dict(config.items("SERVER-MANAGER"))
        self.smgr_ip = self.default_config["smgr"]["listen_ip_addr"]
        self._sm_prov_logger = None
        f = open("/var/log/contrail-server-manager/debug.log", "a")
        f.write("Ansible callback init - smgr_ip: %s" % self.smgr_ip)
        try:
            self._sm_logger = ServerMgrlogger()
            if cluster_id:
                self._sm_prov_logger = ServerMgrProvlogger(cluster_id)
            else:
                self._sm_logger.log(self._sm_logger.ERROR,
                   "cluster_id not found in inventory - provision specific "\
                   "logging will not be done")
        except:
            f = open("/var/log/contrail-server-manager/debug.log", "a")
            f.write("Ansible Callback Init - ServerMgrlogger init failed\n")
            f.close()


    def append(self, log_line):
        self.log += log_line+"\n"
        if self._sm_prov_logger:
            self._sm_prov_logger.log("info", log_line)
        self._sm_logger.log(self._sm_logger.INFO, log_line)

    def banner(self, msg):
        width = 78 - len(msg)
        if width < 3:
            width = 3
        filler = "*" * width
        return "\n%s %s " % (msg, filler)
开发者ID:Juniper,项目名称:contrail-server-manager,代码行数:43,代码来源:sm_ansible_callback.py

示例12: __init__

 def __init__(self):
     ''' Constructor '''
     self.MonitoringCfg = {
         'monitoring_frequency': _DEF_MON_FREQ,
         'monitoring_plugin': _DEF_MONITORING_PLUGIN
     }
     self.InventoryCfg = {
         'inventory_plugin': _DEF_INVENTORY_PLUGIN
     }
     self._smgr_log = ServerMgrlogger()
     self.monitoring_args = None
     self.monitoring_config_set = False
     self.inventory_args = None
     self.inventory_config_set = False
     self.server_monitoring_obj = None
     self.server_inventory_obj = None
     self.monitoring_gevent_thread_obj = None
开发者ID:Juniper,项目名称:contrail-server-manager,代码行数:17,代码来源:server_mgr_mon_base_plugin.py

示例13: __init__

    def __init__(self, args_str=None):
        try:
            self._smgr_log = ServerMgrlogger()
        except:
            print "Error Creating logger object"

        self._smgr_log.log(self._smgr_log.INFO, "Starting SM Ansible Server")
        if not args_str:
            args_str = sys.argv[1:]
        self._parse_args(args_str)
        self.joinq  = Queue.Queue()
        self.joiner = Joiner(self.joinq)
        self.joiner.start()
        self._smgr_log.log(self._smgr_log.INFO,  'Initializing Bottle App')
        self.app = bottle.app()
        bottle.route('/run_ansible_playbooks', 'POST',
                self.start_ansible_playbooks)
开发者ID:Juniper,项目名称:contrail-server-manager,代码行数:17,代码来源:sm_ansible_server.py

示例14: __init__

    def __init__(self, package, v1 = 0, v2 = 0, v3 = 0, v4 = 0):
        self.logger = ServerMgrlogger()
        if package == None:
            self.os_sku = 14
            self.major_version = v1
            self.moderate_version = v2
            self.minor_version_1 = v3
            self.minor_version_2 = v4
        elif eval(str(package["parameters"])).get("playbooks_version", False) == False:
            # Could not detect playbooks in image. Set version such
            # that puppet gets triggered
            self.os_sku = 14
            self.major_version = 4
            self.moderate_version = 0
            self.minor_version_1 = 0
            self.minor_version_2 = 0
        else:
            try:
                version_list = re.split(r'[\.\-]',
                        eval(str(package["parameters"]))["playbooks_version"])

                if "sku" in package["parameters"]:
                    # sku is of the following format:
                    # 2:14.0.2-0ubuntu1~cloud0.1contrail
                    # here, 14 represents the openstack sku - newton
                    sku_list = re.split(r'[:.]',
                            eval(str(package["parameters"]))["sku"])
                    self.os_sku = sku_list[1]
                else:
                    self.os_sku = 14
                self.major_version = version_list[0]
                self.moderate_version = version_list[1]
                self.minor_version_1 = version_list[2]
                self.minor_version_2 = version_list[3]
            except Exception as e:
                self.logger.log(self.logger.ERROR, 
                        "ContrailVersion failed: %s. Falling back to 14.4.0.0.0" % e)
                # Could not detect SKU. Fall back to puppet scheme of things
                self.os_sku = 14
                self.major_version = 4
                self.moderate_version = 0
                self.minor_version_1 = 0
                self.minor_version_2 = 0
开发者ID:Juniper,项目名称:contrail-server-manager,代码行数:43,代码来源:server_mgr_utils.py

示例15: __init__

    def __init__(self, args_str=None):
        try:
            self._smgr_log = ServerMgrlogger()
        except:
            print "Error Creating logger object"

        self._smgr_log.log(self._smgr_log.INFO, "Starting SM Ansible Server")
        self.host_run_results = defaultdict(dict)
        if not args_str:
            args_str = sys.argv[1:]
        self._parse_args(args_str)
        self.joinq  = Queue.Queue()
        self.joiner = Joiner(self.joinq)
        self.joiner.start()
        self._smgr_log.log(self._smgr_log.INFO,  'Initializing Bottle App')
        self.app = bottle.app()
        bottle.route('/start_provision', 'POST', self.start_provision)
        bottle.route('/run_playbook', 'POST', self.start_playbook)
        bottle.route('/playbook_status', 'PUT', self.playbook_status)
开发者ID:nitishkrishna,项目名称:contrail-server-manager,代码行数:19,代码来源:sm_ansible_server.py


注:本文中的server_mgr_logger.ServerMgrlogger类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。