# Path: opsmgr/inventory/resource_mgr.py
# I_MANAGER_DEVICE_PLUGIN = "opsmgr.inventory.interfaces.IManagerDevicePlugin"
# I_MANAGER_DEVICE_HOOK = "opsmgr.inventory.interfaces.IManagerDeviceHook"
# I_MANAGER_RACK_HOOK = "opsmgr.inventory.interfaces.IManagerRackHook"
# def add_resource(label, device_type, address, userid, password, rackid='', rack_location='',
#                  ssh_key=None, offline=False):
# def change_resource_password(label=None, deviceid=None, old_password=None, new_password=None):
# def change_resource_properties(label=None, deviceid=None, new_label=None,
#                                userid=None, password=None, address=None,
#                                rackid=None, rack_location=None, ssh_key=None):
# def list_resources(labels=None, isbriefly=False, device_types=None, deviceids=None,
#                    list_device_id=False, is_detail=False, racks=None):
# def remove_resource(labels=None, all_devices=False, deviceids=None):
# def list_resource_types():
# def get_labels_message(items):
# def get_resource_id_by_label(resource_label):
# def add_resource_roles(resource_label=None, resource_id=None, roles=None, additional_data=None):
# def validate(address, userid, password, device_type, ssh_key=None):
# def _validate(address, userid, password, device_type, ssh_key=None):
# def _get_devicetag_text_id(tag_name):
# def _change_device_key(device, address, userid, ssh_key_string, password):
# def _change_device_userpass(device, address, userid, password):
# def _load_device_plugins():
# def _load_inventory_device_plugins():
# def _check_device_exist(session, address):
# def _check_device_exist_by_props(session, device_type, mtm, serialnum):
# def validate_address(address):
# def validate_label(label):
# def _check_address(address):
# 
# Path: opsmgr/common/utils.py
# def entry_exit(exclude_index=None, exclude_name=None, log_name=None, level=logging.INFO):
#     """
#     it's a decorator that to add entry and exit log for a function
# 
#     input:
#     excludeIndex -- the index of params that you don't want to be record
#     excludeName -- the name of dictionary params that you don't wnat to be record
#     log_name -- name of the log to write the logging to.
#     level -- the logging level to log the entry/exit with.  default is INFO level
#     """
# 
#     def f(func):
#         @functools.wraps(func)
#         def wrapper(*args, **kwargs):
# 
#             args_for_print = []
#             tmp_index = 0
#             arg_len = len(args)
#             while tmp_index < arg_len:
#                 if tmp_index not in exclude_index:
#                     args_for_print.append(args[tmp_index])
#                 tmp_index += 1
# 
#             kwargs_for_print = {}
#             for a in kwargs:
#                 if a in exclude_name:
#                     continue
#                 else:
#                     kwargs_for_print[a] = kwargs[a]
# 
#             logging.getLogger(log_name).log(level,
#                                             "%s::Entry params %s %s", func.__name__, "{}".format(
#                                                 args_for_print), "{}".format(kwargs_for_print))
#             result = func(*args, **kwargs)
#             logging.getLogger(log_name).log(level,
#                                             "%s::Exit %s ", func.__name__, "{}".format(result))
#             return result
#         return wrapper
#     return f


    from StringIO import StringIO
    from io import StringIO
from opsmgr.inventory.interfaces.IManagerDeviceHook import IManagerDeviceHook
from opsmgr.inventory import resource_mgr, persistent_mgr
from opsmgr.common.utils import entry_exit
import paramiko
# Copyright 2016, IBM US, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

try:
    # python 2.7
except ImportError:
    # python 3.4


class UlyssesDevicePlugin(IManagerDeviceHook):

    ROLE_FILE = "/etc/roles"

    @staticmethod
    def add_device_pre_save(device):

# Path: opsmgr/inventory/resource_mgr.py
# I_MANAGER_DEVICE_PLUGIN = "opsmgr.inventory.interfaces.IManagerDevicePlugin"
# I_MANAGER_DEVICE_HOOK = "opsmgr.inventory.interfaces.IManagerDeviceHook"
# I_MANAGER_RACK_HOOK = "opsmgr.inventory.interfaces.IManagerRackHook"
# def add_resource(label, device_type, address, userid, password, rackid='', rack_location='',
#                  ssh_key=None, offline=False):
# def change_resource_password(label=None, deviceid=None, old_password=None, new_password=None):
# def change_resource_properties(label=None, deviceid=None, new_label=None,
#                                userid=None, password=None, address=None,
#                                rackid=None, rack_location=None, ssh_key=None):
# def list_resources(labels=None, isbriefly=False, device_types=None, deviceids=None,
#                    list_device_id=False, is_detail=False, racks=None):
# def remove_resource(labels=None, all_devices=False, deviceids=None):
# def list_resource_types():
# def get_labels_message(items):
# def get_resource_id_by_label(resource_label):
# def add_resource_roles(resource_label=None, resource_id=None, roles=None, additional_data=None):
# def validate(address, userid, password, device_type, ssh_key=None):
# def _validate(address, userid, password, device_type, ssh_key=None):
# def _get_devicetag_text_id(tag_name):
# def _change_device_key(device, address, userid, ssh_key_string, password):
# def _change_device_userpass(device, address, userid, password):
# def _load_device_plugins():
# def _load_inventory_device_plugins():
# def _check_device_exist(session, address):
# def _check_device_exist_by_props(session, device_type, mtm, serialnum):
# def validate_address(address):
# def validate_label(label):
# def _check_address(address):
# 
# Path: opsmgr/common/utils.py
# def entry_exit(exclude_index=None, exclude_name=None, log_name=None, level=logging.INFO):
#     """
#     it's a decorator that to add entry and exit log for a function
# 
#     input:
#     excludeIndex -- the index of params that you don't want to be record
#     excludeName -- the name of dictionary params that you don't wnat to be record
#     log_name -- name of the log to write the logging to.
#     level -- the logging level to log the entry/exit with.  default is INFO level
#     """
# 
#     def f(func):
#         @functools.wraps(func)
#         def wrapper(*args, **kwargs):
# 
#             args_for_print = []
#             tmp_index = 0
#             arg_len = len(args)
#             while tmp_index < arg_len:
#                 if tmp_index not in exclude_index:
#                     args_for_print.append(args[tmp_index])
#                 tmp_index += 1
# 
#             kwargs_for_print = {}
#             for a in kwargs:
#                 if a in exclude_name:
#                     continue
#                 else:
#                     kwargs_for_print[a] = kwargs[a]
# 
#             logging.getLogger(log_name).log(level,
#                                             "%s::Entry params %s %s", func.__name__, "{}".format(
#                                                 args_for_print), "{}".format(kwargs_for_print))
#             result = func(*args, **kwargs)
#             logging.getLogger(log_name).log(level,
#                                             "%s::Exit %s ", func.__name__, "{}".format(result))
#             return result
#         return wrapper
#     return f


# Path: plugins/hooks/ulysses/opsmgr/plugins/hooks/ulysses/UlyssesDevicePlugin.py
    from StringIO import StringIO
    from io import StringIO
from opsmgr.inventory.interfaces.IManagerDeviceHook import IManagerDeviceHook
from opsmgr.inventory import resource_mgr, persistent_mgr
from opsmgr.common.utils import entry_exit
import paramiko

# Copyright 2016, IBM US, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

try:
    # python 2.7
except ImportError:
    # python 3.4


class UlyssesDevicePlugin(IManagerDeviceHook):

    ROLE_FILE = "/etc/roles"

    @staticmethod
    def add_device_pre_save(device):

        pass