在OpenStack Havana中,当您通过Web界面启动新实例时,它可让您选择要连接到实例的虚拟网络。 (这是在Launch Instance-> Networking下。)用户选择一个或多个网络与实例关联。
当我尝试通过EC2Connection.run_instances()启动实例时,实例始终连接到所有可用网络,Instance数据结构随机选择其中一个作为主要接口。如果选择了错误的界面,那么我的程序就会失败。
我尝试通过创建网络接口规范并使其成为传递给run_instances()的唯一网络接口来强制执行,但我仍然遇到同样的问题。
interface = ec2.networkinterface.NetworkInterfaceSpecification(subnet_id=subnet_id,device_index=0,
groups=['default'],
associate_public_ip_address=False)
interfaces = ec2.networkinterface.NetworkInterfaceCollection(interface)
reservation = self.ec2_connection.run_instances(image_id=image.id,min_count=number_nodes, max_count=number_nodes, key_name=self.instance_key, user_data=None, instance_type=instance_type,network_interfaces=interfaces)
有什么想法吗?