示例#1
0
def main(reactor):
    print("Logging to example-eliot.log...")
    logWriter = ThreadedWriter(
        FileDestination(file=open("example-eliot.log", "ab")), reactor)

    # Manually start the service, which will add it as a
    # destination. Normally we'd register ThreadedWriter with the usual
    # Twisted Service/Application infrastructure.
    logWriter.startService()

    # Log a message:
    Message.log(value="hello", another=1)

    # Manually stop the service.
    done = logWriter.stopService()
    return done
    def main(reactor):
        logWriter = ThreadedWriter(
            FileDestination(file=open("emc_midrange_driver.log", "ab")),
            reactor)

        # Manually start the service, which will add it as a
        # destination. Normally we'd register ThreadedWriter with the usual
        # Twisted Service/Application infrastructure.
        logWriter.startService()

        parameter = {
            'cluster_id': uuid.uuid4(),
            'ip': '192.168.1.58',
            'user': '******',
            'password': '******',
            'storage_pools': 'Manila_Pool',
            'multipath': True,
            'proto': 'iSCSI',
            'host_ip': '192.168.21.237',
        }

        api = EMCVNXBlockAPI(**parameter)

        print api.list_volumes()

        volume = api.create_volume(uuid.uuid4(), 80530636800)

        print api.list_volumes()

        volume = api.attach_volume(volume.blockdevice_id, api.hostname)
        print api.list_volumes()

        device_path = api.get_device_path(volume.blockdevice_id)
        print device_path

        api.detach_volume(volume.blockdevice_id)

        api.destroy_volume(volume.blockdevice_id)

        # Manually stop the service.
        done = logWriter.stopService()
        return done