Exemplo n.º 1
0
import vmware.common.global_config as global_config
import vmware.interfaces.switch_interface as switch_interface
import vmware.linux.ovs.cli.default_crud_impl as default_crud_impl

pylogger = global_config.configure_logger()
DefaultCRUDImpl = default_crud_impl.DefaultCRUDImpl


class Ubuntu1204SwitchImpl(switch_interface.SwitchInterface):
    """Switch management class for Ubuntu."""
    BIND_CMD = "vtep-ctl "

    @classmethod
    def bind_pnic(cls, client_object, name=None, switch_name=None):

        if name is None:
            raise ValueError('Adapter name cannot be None')

        if switch_name is None:
            raise ValueError('Switch name cannot be None')

        ip = None
        parsed_data = DefaultCRUDImpl.get_adapter_info(client_object)
        for record in parsed_data['table']:
            if record['dev'] == name:
                ip = record['ip']

        if ip is None:
            raise ValueError('Adapter has no IP')

        bind_cmd = cls.BIND_CMD + " set Physical_Switch "
import vmware.common.global_config as global_config
import vmware.interfaces.switch_interface as switch_interface
import vmware.linux.ovs.cli.default_crud_impl as default_crud_impl

pylogger = global_config.configure_logger()
DefaultCRUDImpl = default_crud_impl.DefaultCRUDImpl


class Ubuntu1204SwitchImpl(switch_interface.SwitchInterface):
    """Switch management class for Ubuntu."""
    BIND_CMD = "vtep-ctl "

    @classmethod
    def bind_pnic(cls, client_object, name=None, switch_name=None):

        if name is None:
            raise ValueError('Adapter name cannot be None')

        if switch_name is None:
            raise ValueError('Switch name cannot be None')

        ip = None
        parsed_data = DefaultCRUDImpl.get_adapter_info(
            client_object)
        for record in parsed_data['table']:
            if record['dev'] == name:
                ip = record['ip']

        if ip is None:
            raise ValueError('Adapter has no IP')
Exemplo n.º 3
0
import vmware.common.compute_utilities as compute_utilities
import vmware.common.connection as connection
import vmware.common.constants as constants
import vmware.common.global_config as global_config
import vmware.common.result as result
import vmware.common.utilities as utilities

CONNECTION_TIMEOUT = constants.Timeout.SSH_CONNECT
COMMAND_EXEC_TIMEOUT = global_config.COMMAND_EXEC_TIMEOUT

pylogger = global_config.pylogger

if pylogger is None:
    pylogger = global_config.configure_logger(
        log_prefix="SSHConnection", stdout=True, log_level=logging.INFO,
        logfile_level=logging.DEBUG)


class SSHConnection(connection.Connection):

    def __init__(self, ip="", username="", password="",
                 connection_object=None):
        super(SSHConnection, self).__init__(ip, username, password,
                                            connection_object)

    def create_connection(self):
        conn = paramiko.SSHClient()
        conn.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        host_keys_file = global_config.get_host_keys_file()
        pylogger.debug("Loading ssh known_hosts key from %r" % host_keys_file)