Fabric1 env.hosts和env.hosts_name的fabric2替代方法是什么

时间:2018-05-24 10:20:29

标签: python ssh fabric statsd collectd

在我的代码中,我希望有一个主机列表,并向每个主机发送不同的参数。

目前我在数组中找到索引并使用它来确定输入

index = env.hosts.index(env.host_name)

在面料3中不再使用主机和host_name。

The primary API is now properly OOP: instantiate Connection objects and call their methods. These objects encapsulate all connection state (user, host, gateway, etc) and have their own SSH client instances.

1 个答案:

答案 0 :(得分:1)

在Fabric 2中,通过实例化SELECT z.* FROM ( SELECT *, ROW_NUMBER() OVER (PARTITION BY [id] ORDER BY [action_timestamp] DESC) AS rowNum, [new_state] AS [Last_State], DATEADD(MONTH, 0, @date) AS [date] FROM [dbo].[CR_hist_Data] WHERE [action_timestamp_formatted] < DATEADD(MONTH, -1, @date) ) z WHERE z.rowNum = 1 UNION SELECT z.* FROM ( SELECT *, ROW_NUMBER() OVER (PARTITION BY [id] ORDER BY [action_timestamp] DESC) AS rowNum, [new_state] AS [Last_State], DATEADD(MONTH, -1, @date) AS [date] FROM [dbo].[CR_hist_Data] WHERE [action_timestamp_formatted] < DATEADD(MONTH, -2, @date) ) z WHERE z.rowNum = 1 UNION SELECT z.* FROM ( SELECT *, ROW_NUMBER() OVER (PARTITION BY [id] ORDER BY [action_timestamp] DESC) AS rowNum, [new_state] AS [Last_State], DATEADD(MONTH, -2, @date) AS [date] FROM [dbo].[CR_hist_Data] WHERE [action_timestamp_formatted] < DATEADD(MONTH, -3, @date) ) z WHERE z.rowNum = 1; etc....for 12 times 对象连接到主机。您可以通过调用Connection属性访问其主机:

host

如果您需要连接到多个服务器,则需要实例化由多个连接组成的conn = Connection('192.168.11.12') print(conn.host)

SerialGroup

您可以查看(已更新!)文档here和(已更新!)git repo here