コード例 #1
0
def reboot(wait=60):
    log_cmd = 'reboot> wait={0}'.format(wait)
    api.env.cmd_history.append(log_cmd)
    log.info(log_cmd)
    print_for_test(log_cmd)

    if api.env.is_test:
        result = test_cmd('uptime')
    else:
        api.reboot(wait=wait)
        result = api.run('uptime')

    result_msg = 'return> {0}  out>\n{1}'.format(result.return_code, result)
    log.info(result_msg)
コード例 #2
0
ファイル: base.py プロジェクト: fabrickit/fabkit
def reboot(wait=60):
    log_cmd = 'reboot> wait={0}'.format(wait)
    api.env.cmd_history.append(log_cmd)
    log.info(log_cmd)
    print_for_test(log_cmd)

    if api.env.is_test:
        result = test_cmd('uptime')
    else:
        api.reboot(wait=wait)
        result = api.run('uptime')

    result_msg = 'return> {0}  out>\n{1}'.format(result.return_code, result)
    log.info(result_msg)
コード例 #3
0
ファイル: neutron.py プロジェクト: fabrickit-fablib/openstack
    def setup_network_bridge(self):
        data = self.init()

        if 'linuxbridge' in data['ml2']['mechanism_drivers']:
            sudo('modprobe bridge')

        elif 'openvswitch' in data['ml2']['mechanism_drivers']:
            sudo('modprobe -r bridge')
            Service('openvswitch').start().enable()

            sudo('ovs-vsctl br-exists {0} || ovs-vsctl add-br {0}'.format(
                data['ovs']['integration_bridge']))

            filer.template(
                '/etc/sysconfig/network-scripts/ifcfg-{0}'.format(
                    data['ovs']['integration_bridge']),
                src='network/ovs-ifcfg-br.j2',
                data=data)

            for mapping in data['ovs']['bridge_mappings']:
                pair = mapping.split(':')
                ovs_interface = pair[1]
                sudo('ovs-vsctl br-exists {0} || ovs-vsctl add-br {0}'.format(ovs_interface))

            for mapping in data['ovs']['physical_interface_mappings']:
                pair = mapping.split(':')
                ovs_interface = pair[0]
                physical_interface = pair[1]

                backup_default_dev_file = '/etc/sysconfig/network-scripts/bk-ifcfg-defualt'
                if filer.exists(backup_default_dev_file):
                    default = run('cat {0}'.format(backup_default_dev_file))
                    dev, ip, subnet, gateway = default.split(':')
                    data['default_dev'] = {
                        'dev': dev,
                        'ip': ip,
                        'subnet': subnet,
                        'gateway': gateway,
                    }
                else:
                    sudo("echo '{0[dev]}:{0[ip]}:{0[subnet]}:{1}' > {2}".format(
                        env.node['ip']['default_dev'],
                        env.node['ip']['default']['ip'],
                        backup_default_dev_file))
                    data['default_dev'] = env.node['ip']['default_dev']
                    data['default_dev']['gateway'] = env.node['ip']['default']['ip']

                data['default_dev']['netmask'] = self.cidr(
                    data['default_dev']['subnet'].split('/')[1])

                if physical_interface == data['default_dev']['dev']:
                    # create backup for default interface

                    data['ovs_interface'] = ovs_interface

                    filer.template(
                        '/etc/sysconfig/network-scripts/ifcfg-{0}'.format(physical_interface),
                        src='network/ovs-ifcfg-flat.j2',
                        data=data)

                    filer.template(
                        '/etc/sysconfig/network-scripts/ifcfg-{0}'.format(ovs_interface),
                        src='network/ovs-ifcfg-br-flat.j2',
                        data=data)

                    result = sudo('ovs-vsctl list-ports {0}'.format(ovs_interface))
                    if result.find(data['default_dev']['dev']) == -1:
                        with api.warn_only():
                            api.reboot(180)