python Fabric API:找不到主机

时间:2017-02-01 02:53:59

标签: python amazon-web-services fabric

我正在运行以下fabric命令:

  1. fab -f fabfile_awsgpu.py -R mygpu ssh
  2. fab -f fabfile_awsgpu.py -R mygpu cuda_setup8 anaconda_setup tf_setup keras_setup torch_preroll torch_setup_solo
  3. 第一个命令打印正确的env.host_string,而第二个命令打印env.host_stringNone,并显示以下消息:

    No hosts found. Please specify (single) host string for connection:
    

    这是否会发生? fabfile_awsgpu如下:

    env.roledefs.update(get_target_instance())
    #env.hosts = ['ec2-35-167-153-191.us-west-2.compute.amazonaws.com']
    #env.disable_known_hosts = True
    
    @task
    def launch():
    
        ec2 = boto3.resource('ec2', region_name=AWS_REGION)
    
        BlockDeviceMappings=[
            {
                'DeviceName': '/dev/xvda',
                'Ebs': {
                    'VolumeSize': 600,
                    'DeleteOnTermination': True,
                    'VolumeType': 'standard',
                    'SnapshotId' : 'snap-c87f35ec'
                },
            },
        ]
    
        instances = ec2.create_instances(ImageId=tgt_ami, MinCount=1, MaxCount=1,
                                         KeyName=my_aws_key, InstanceType=INSTANCE_TYPE,
                                         BlockDeviceMappings = BlockDeviceMappings,
                                         EbsOptimized=True
        )
    
        inst = instances[0]
        print inst
    
        inst.wait_until_running()
        inst.reload()
        inst.create_tags(
            Resources=[
                inst.instance_id
            ],
            Tags=[
                {
                    'Key': 'Name',
                    'Value': instance_name
                },
            ]
        )
        @task
        def ssh():
            print env.host_string
            local("ssh -A " + env.host_string)
    
    
        @task
        def tensorboard():
            local("open http://"+env.host_string+":6006")
    
        @task
        def copy_model():
            local("scp " + env.host_string+":/tmp/model.ckpt /tmp/")
    
        @task
        def basic_setup():
            print env.host_string
            print env.hosts
            run("sudo yum update -q -y")
            run("sudo yum groupinstall 'Development Tools' -q -y")
            run("sudo yum install -q -y emacs tmux  gcc g++ dstat htop")
            run("sudo yum install -y kernel-devel-`uname -r`")
    

0 个答案:

没有答案