/********************************************************************* * * Filename: ircomm_tty.c * Version: 1.0 * Description: IrCOMM serial TTY driver * Status: Experimental. * Author: Dag Brattli * Created at: Sun Jun 6 21:00:56 1999 * Modified at: Wed Feb 23 00:09:02 2000 * Modified by: Dag Brattli * Sources: serial.c and previous IrCOMM work by Takahide Higuchi * * Copyright (c) 1999-2000 Dag Brattli, All Rights Reserved. * Copyright (c) 2000-2003 Jean Tourrilhes * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . * ********************************************************************/ #include #include #include #include #include #include #include #include #include #include #include /* for MODULE_ALIAS_CHARDEV_MAJOR */ #include #include #include #include #include #include #include static int ircomm_tty_install(struct tty_driver *driver, struct tty_struct *tty); static int ircomm_tty_open(struct tty_struct *tty, struct file *filp); static void ircomm_tty_close(struct tty_struct * tty, struct file *filp); static int ircomm_tty_write(struct tty_struct * tty, const unsigned char *buf, int count); static int ircomm_tty_write_room(struct tty_struct *tty); static void ircomm_tty_throttle(struct tty_struct *tty); static void ircomm_tty_unthrottle(struct tty_struct *tty); static int ircomm_tty_chars_in_buffer(struct tty_struct *tty); static void ircomm_tty_flush_buffer(struct tty_struct *tty); static void ircomm_tty_send_xchar(struct tty_struct *tty, char ch); static void ircomm_tty_wait_until_sent(struct tty_struct *tty, int timeout); static void ircomm_tty_hangup(struct tty_struct *tty); static void ircomm_tty_do_softint(struct work_struct *work); static void ircomm_tty_shutdown(struct ircomm_tty_cb *self); static void ircomm_tty_stop(struct tty_struct *tty); static int ircomm_tty_data_indication(void *instance, void *sap, struct sk_buff *skb); static int ircomm_tty_control_indication(void *instance, void *sap, struct sk_buff *skb); static void ircomm_tty_flow_indication(void *instance, void *sap, LOCAL_FLOW cmd); #ifdef CONFIG_PROC_FS static const struct file_operations ircomm_tty_proc_fops; #endif /* CONFIG_PROC_FS */ static struct tty_driver *driver; static hashbin_t *ircomm_tty = NULL; static const struct tty_operations ops = { .install = ircomm_tty_install, .open = ircomm_tty_open, .close = ircomm_tty_close, .write = ircomm_tty_write, .write_room = ircomm_tty_write_room, .chars_in_buffer = ircomm_tty_chars_in_buffer, .flush_buffer = ircomm_tty_flush_buffer, .ioctl = ircomm_tty_ioctl, /* ircomm_tty_ioctl.c */ .tiocmget = ircomm_tty_tiocmget, /* ircomm_tty_ioctl.c */ .tiocmset = ircomm_tty_tiocmset, /* ircomm_tty_ioctl.c */ .throttle = ircomm_tty_throttle, .unthrottle = ircomm_tty_unthrottle, .send_xchar = ircomm_tty_send_xchar, .set_termios = ircomm_tty_set_termios, .stop = ircomm_tty_stop, .start = ircomm_tty_start, .hangup = ircomm_tty_hangup, .wait_until_sent = ircomm_tty_wait_until_sent, #ifdef CONFIG_PROC_FS .proc_fops = &ircomm_tty_proc_fops, #endif /* CONFIG_PROC_FS */ }; static void ircomm_port_raise_dtr_rts(struct tty_port *port, int raise) { struct ircomm_tty_cb *self = container_of(port, struct ircomm_tty_cb, port); /* * Here, we use to lock those two guys, but as ircomm_param_request() * does it itself, I don't see the point (and I see the deadlock). * Jean II */ if (raise) self->settings.dte |= IRCOMM_RTS | IRCOMM_DTR; else self->settings.dte &= ~(IRCOMM_RTS | IRCOMM_DTR); ircomm_param_request(self, IRCOMM_DTE, TRUE); } static int ircomm_port_carrier_raised(struct tty_port *port) { struct ircomm_tty_cb *self = container_of(port, struct ircomm_tty_cb, port); return self->settings.dce & IRCOMM_CD; } static const struct tty_port_operations ircomm_port_ops = { .dtr_rts = ircomm_port_raise_dtr_rts, .carrier_raised = ircomm_port_carrier_raised, }; /* * Function ircomm_tty_init() * * Init IrCOMM TTY layer/driver * */ static int __init ircomm_tty_init(void) { driver = alloc_tty_driver(IRCOMM_TTY_PORTS); if (!driver) return -ENOMEM; ircomm_tty = hashbin_new(HB_LOCK); if (ircomm_tty == NULL) { net_err_ratelimited("%s(), can't allocate hashbin!\n", __func__); put_tty_driver(driver); return -ENOMEM; } driver->driver_name = "ircomm"; driver->name = "ircomm"; driver->major = IRCOMM_TTY_MAJOR; driver->minor_start = IRCOMM_TTY_MINOR; driver->type = TTY_DRIVER_TYPE_SERIAL; driver->subtype = SERIAL_TYPE_NORMAL; driver->init_termios = tty_std_termios; driver->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; driver->flags = TTY_DRIVER_REAL_RAW; tty_set_operations(driver, &ops); if (tty_register_driver(driver)) { net_err_ratelimited("%s(): Couldn't register serial driver\n", __func__); put_tty_driver(driver); return -1; } return 0; } static void __exit __ircomm_tty_cleanup(struct ircomm_tty_cb *self) { IRDA_ASSERT(self != NULL, return;); IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;); ircomm_tty_shutdown(self); self->magic = 0; tty_port_destroy(&self->port); kfree(self); } /* * Function ircomm_tty_cleanup () * * Remove IrCOMM TTY layer/driver * */ static void __exit ircomm_tty_cleanup(void) { int ret; ret = tty_unregister_driver(driver); if (ret) { net_err_ratelimited("%s(), failed to unregister driver\n", __func__); return; } hashbin_delete(ircomm_tty, (FREE_FUNC) __ircomm_tty_cleanup); put_tty_driver(driver); } /* * Function ircomm_startup (self) * * * */ static int ircomm_tty_startup(struct ircomm_tty_cb *self) { notify_t notify; int ret = -ENODEV; IRDA_ASSERT(self != NULL, return -1;); IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return -1;); /* Check if already open */ if (test_and_set_bit(ASYNCB_INITIALIZED, &self->port.flags)) { pr_debug("%s(), already open so break out!\n", __func__); return 0; } /* Register with IrCOMM */ irda_notify_init(¬ify); /* These callbacks we must handle ourselves */ notify.data_indication = ircomm_tty_data_indication; notify.udata_indication = ircomm_tty_control_indication; notify.flow_indication = ircomm_tty_flow_indication; /* Use the ircomm_tty interface for these ones */ notify.disconnect_indication = ircomm_tty_disconnect_indication; notify.connect_confirm = ircomm_tty_connect_confirm; notify.connect_indication = ircomm_tty_connect_indication; strlcpy(notify.name, "ircomm_tty", sizeof(notify.name)); notify.instance = self; if (!self->ircomm) { self->ircomm = ircomm_open(¬ify, self->service_type, self->line); } if (!self->ircomm) goto err; self->slsap_sel = self->ircomm->slsap_sel; /* Connect IrCOMM link with remote device */ ret = ircomm_tty_attach_cable(self); if (ret < 0) { net_err_ratelimited("%s(), error attaching cable!\n", __func__); goto err; } return 0; err: clear_bit(ASYNCB_INITIALIZED, &self->port.flags); return ret; } /* * Function ircomm_block_til_ready (self, filp) * * * */ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self, struct tty_struct *tty, struct file *filp) { struct tty_port *port = &self->port; DECLARE_WAITQUEUE(wait, current); int retval; int do_clocal = 0; unsigned long flags; /* * If non-blocking mode is set, or the port is not enabled, * then make the check up front and then exit. */ if (test_bit(TTY_IO_ERROR, &tty->flags)) { port->flags |= ASYNC_NORMAL_ACTIVE; return 0; } if (filp->f_flags & O_NONBLOCK) { /* nonblock mode is set */ if (tty->termios.c_cflag & CBAUD) tty_port_raise_dtr_rts(port); port->flags |= ASYNC_NORMAL_ACTIVE; pr_debug("%s(), O_NONBLOCK requested!\n", __func__); return 0; } if (tty->termios.c_cflag & CLOCAL) { pr_debug("%s(), doing CLOCAL!\n", __func__); do_clocal = 1; } /* Wait for carrier detect and the line to become * free (i.e., not in use by the callout). While we are in * this loop, port->count is dropped by one, so that * mgsl_close() knows when to free things. We restore it upon * exit, either normal or abnormal. */ retval = 0; add_wait_queue(&port->open_wait, &wait); pr_debug("%s(%d):block_til_ready before block on %s open_count=%d\n", __FILE__, __LINE__, tty->driver->name, port->count); spin_lock_irqsave(&port->lock, flags); port->count--; port->blocked_open++; spin_unlock_irqrestore(&port->lock, flags); while (1) { if (C_BAUD(tty) && test_bit(ASYNCB_INITIALIZED, &port->flags)) tty_port_raise_dtr_rts(port); set_current_state(TASK_INTERRUPTIBLE); if (tty_hung_up_p(filp) || !test_bit(ASYNCB_INITIALIZED, &port->flags)) { retval = (port->flags & ASYNC_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS; break; } /* * Check if link is ready now. Even if CLOCAL is * specified, we cannot return before the IrCOMM link is * ready */ if (!test_bit(ASYNCB_CLOSING, &port->flags) && (do_clocal || tty_port_carrier_raised(port)) && self->state == IRCOMM_TTY_READY) { break; } if (signal_pending(current)) { retval = -ERESTARTSYS; break; } pr_debug("%s(%d):block_til_ready blocking on %s open_count=%d\n", __FILE__, __LINE__, tty->driver->name, port->count); schedule(); } __set_current_state(TASK_RUNNING); remove_wait_queue(&port->open_wait, &wait); spin_lock_irqsave(&port->lock, flags); if (!tty_hung_up_p(filp)) port->count++; port->blocked_open--; spin_unlock_irqrestore(&port->lock, flags); pr_debug("%s(%d):block_til_ready after blocking on %s open_count=%d\n", __FILE__, __LINE__, tty->driver->name, port->count); if (!retval) port->flags |= ASYNC_NORMAL_ACTIVE; return retval; } static int ircomm_tty_install(struct tty_driver *driver, struct tty_struct *tty) { struct ircomm_tty_cb *self; unsigned int line = tty->index; /* Check if instance already exists */ self = hashbin_lock_find(ircomm_tty, line, NULL); if (!self) { /* No, so make new instance */ self = kzalloc(sizeof(struct ircomm_tty_cb), GFP_KERNEL); if (self == NULL) return -ENOMEM; tty_port_init(&self->port); self->port.ops = &ircomm_port_ops; self->magic = IRCOMM_TTY_MAGIC; self->flow = FLOW_STOP; self->line = line; INIT_WORK(&self->tqueue, ircomm_tty_do_softint); self->max_header_size = IRCOMM_TTY_HDR_UNINITIALISED; self->max_data_size = IRCOMM_TTY_DATA_UNINITIALISED; /* Init some important stuff */ init_timer(&self->watchdog_timer); spin_lock_init(&self->spinlock); /* * Force TTY into raw mode by default which is usually what * we want for IrCOMM and IrLPT. This way applications will * not have to twiddle with printcap etc. * * Note this is completely usafe and doesn't work properly */ tty->termios.c_iflag = 0; tty->termios.c_oflag = 0; /* Insert into hash */ hashbin_insert(ircomm_tty, (irda_queue_t *) self, line, NULL); } tty->driver_data = self; return tty_port_install(&self->port, driver, tty); } /* * Function ircomm_tty_open (tty, filp) * * This routine is called when a particular tty de
---
- hosts: all
  remote_user: root
  pre_tasks:
    - name: make sure ssh dir exist
      file:
        path: '{{ item.path }}'
        owner: '{{ item.owner }}'
        group: '{{ item.group }}'
        state: directory
        mode: 0755
      with_items:
        - path: /root/.ssh
          owner: root
          group: root

    - name: write ssh config
      copy:
        content: "UserKnownHostsFile /dev/null\nStrictHostKeyChecking no"
        dest: '{{ item.dest }}'
        owner: '{{ item.owner }}'
        group: '{{ item.group }}'
        mode: 0600
      with_items:
        - dest: /root/.ssh/config
          owner: root
          group: root

    - name: generate ssh keys
      shell: if [ ! -f ~/.ssh/id_rsa.pub ]; then ssh-keygen -q -t rsa -f ~/.ssh/id_rsa -N ""; else echo "already gen ssh key!"; fi;

    - name: fetch ssh keys
      fetch: src=/root/.ssh/id_rsa.pub dest=/tmp/ssh-keys-{{ ansible_hostname }} flat=yes

    - authorized_key:
        user: root
        key:  "{{ lookup('file', 'item') }}"
      with_fileglob:
        - /tmp/ssh-keys-*
  max_fail_percentage: 0
  roles:
    - common

- hosts: all
  remote_user: root
  accelerate: true
  max_fail_percentage: 0
  roles:
    - setup-network

- hosts: ha
  remote_user: root
  accelerate: true
  max_fail_percentage: 0
  roles:
    - ha

- hosts: controller
  remote_user: root
  accelerate: true
  max_fail_percentage: 0
  roles:
    - memcached
    - apache
    - database
    - mq
    - keystone
    - nova-controller
    - neutron-controller
    - cinder-controller
    - glance
    - neutron-common
    - neutron-network
    - ceilometer_controller
#    - ext-network
    - dashboard
    - heat
    - aodh

- hosts: all
  remote_user: root
  accelerate: true
  max_fail_percentage: 0
  roles:
    - storage

- hosts: compute
  remote_user: root
  accelerate: true
  max_fail_percentage: 0
  roles:
    - nova-compute
    - neutron-compute
    - cinder-volume
    - ceilometer_compute

- hosts: all
  remote_user: root
  accelerate: true
  max_fail_percentage: 0
  roles:
    - secgroup

- hosts: ceph_adm
  remote_user: root
  accelerate: true
  max_fail_percentage: 0
  roles: []
  #  - ceph-deploy

- hosts: ceph
  remote_user: root
  accelerate: true
  max_fail_percentage: 0
  roles:
    - ceph-purge
    - ceph-config

- hosts: ceph_mon
  remote_user: root
  accelerate: true
  max_fail_percentage: 0
  roles:
    - ceph-mon

- hosts: ceph_osd
  remote_user: root
  accelerate: true
  max_fail_percentage: 0
  roles:
    - ceph-osd

- hosts: ceph
  remote_user: root
  accelerate: true
  max_fail_percentage: 0
  roles:
    - ceph-openstack

- hosts: all
  remote_user: root
  accelerate: true
  max_fail_percentage: 0
  roles:
    - monitor


- hosts: all
  remote_user: root
  accelerate: true
  max_fail_percentage: 0
  tasks:
    - name: set bash to nova
      user:
         name: nova
         shell: /bin/bash

    - name: make sure ssh dir exist
      file:
        path: '{{ item.path }}'
        owner: '{{ item.owner }}'
        group: '