首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >来自Python的集群节点

来自Python的集群节点
EN

Stack Overflow用户
提问于 2017-11-02 20:42:49
回答 2查看 665关注 0票数 0

我有一个集群的DNS名称,它有很少几个运行服务的节点。我首先编写了powershell脚本,这给了我提供服务运行的节点及其状态。脚本使用Get-集群资源命令,然后我编写了python脚本,它正在执行这个powershell。当我运行powershell脚本时,我将得到节点及其状态。但是,当我从python整理powershell脚本时,我得到的错误是:

代码语言:javascript
复制
Get-ClusterResource : The term 'Get-ClusterResource' is not recognized as the 
name of a cmdlet, function, script file, or operable program. Check the 
spelling of the name, or if a path was included, verify that the path is 
correct and try again.

我试着使用import-module failovercluster,但没有成功。

请让我知道我哪里错了,如果不可能的话,我会搜索python来实现同样的目标。

很少了解我对集群的理解:-我们不能对集群进行create PSSession

我以这种方式运行powershell脚本:

代码语言:javascript
复制
subprocess.check_output(["powershell.exe", '-ExecutionPolicy', 'Unrestricted', self.win_cluster_handling() + " -Cluster_Name " + self.cluster_name + " -ClusterNode_Action Stop-Cluster" + " -Service_Name " + self.service_name + " -Username " + self.username + " -Password " + self.password])
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-11-02 20:54:00

您的脚本中也包括了Import-module FailoverClusters吗?

看看这个question

一项建议是更新到PowerShell v3.0或更高版本。

票数 1
EN

Stack Overflow用户

发布于 2017-11-02 21:33:14

重新阅读您的描述,问题发生在您从Python调用的Powershell脚本中。在Powershell脚本中,您可以编写一些行来判断脚本是否与正常运行Powershell时相同的环境变量、路径等一起运行。

例如,如果从Powershell运行:“Get Env:”,它会给出一个环境变量列表。您可以在powershell脚本中包含相同的内容,并检查它们是否相同,或者脚本运行的脚本中缺少了什么。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47084300

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档