首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

WebSphere CloudBurst Appliance 命令行界面简介-3

WebSphere CloudBurst Appliance 命令行界面简介-3

使用交互模式在交互模式中,您将命令输入到命令提示符中,控制台将显示结果。要开始一个交互式会话,必须提供有关 WebSphere CloudBurst Appliance 位置的信息,以及您的登录凭证。
在清单 1 中,一个交互式 CLI 会话将被启动,只要输入 cloudburst 并提供设备的以下信息:
  • 使用参数 -h 提供主机名
  • 通过 -u 选项提供用户名
  • 通过 -p 选项提供密码
在会话期间输入的所有命令都将被发送到位于 mycloudburst.com 中的 WebSphere CloudBurst Appliance 中。
清单 1. 发起 CLI 会话
1
2
C:\cloudburst\cloudburst.cli\bin>cloudburst -h mycloudburst.com -u cloudburstUser
    -p password




WebSphere CloudBurst CLI 还支持通过环境变量传递主机名、用户 id 和密码。为此,在运行 cloudburst 命令前设置 CLOUDBURST_HOSTNAME、CLOUDBURST_USERID 和 CLOUDBURST_PASSWORD 环境变量,然后去掉如上所示的命令行参数。
在运行交互式 CLI 会话期间,普通的命令 shell 提示符将被修改为 >>>。如果命令超出了一个输入行,那么命令提示符变为 ...,表示该行是前一行中的命令的延续。(当解释交互式模式以匹配您从屏幕上看到的内容时,这些提示将在本文的示例中做演示;换而言之,不要输入这些提示字符)。要退出交互模式,输入 exit 并在 >>> 提示符处按下 Enter
清单 2 和 3 展示了命令的使用,将显示 WebSphere CloudBurst 系统上的所有用户。
清单 2. 列出所有用户 - 命令
1
>>> cloudburst.users




清单 3. 列出所有用户 - 输出
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
[
  {
    "currentmessage": "RM02011",
    "currentmessage_text": "Active in the last five minutes",
    "currentstatus": "RM01061",
    "currentstatus_text": "Logged in and active",
    "email": "",
    "fullname": "Administrator",
    "groups": (nested object),
    "id": 1,
    "parts": (nested object),
    "password": (write-only),
    "patterns": (nested object),
    "roles": (nested object),
    "scripts": (nested object),
    "username": "cbadmin",
    "virtualimages": (nested object),
    "virtualsystems": (nested object)
  }
]




除了查看资源和资源集合外,还可以对由 WebSphere CloudBurst 管理的项目执行操作。例如,假设您希望添加一个有权将模式部署到私有云的用户。可以通过几个不同的方式实现这点。
第一种方法是使用交互式向导创建一个新用户,如清单 4 和 5 所示。这里,将提醒您为新用户输入用户名、全名、密码和邮件地址。因此,新用户将被创建,并且用户的细节被显示出来。
清单 4. 使用向导创建一个新用户 - 命令
1
>>> cloudburst.users.create(cloudburst.wizard)




清单 5. 使用向导创建一个新用户 - 输出
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Enter ?? for help using the wizard.

username: newuser
fullname: Pattern Deployer
password: password
email: newuser@mycompany.com
{
  "currentmessage": "RM02013",
  "currentmessage_text": "User has not logged in yet",
  "currentstatus": "RM01062",
  "currentstatus_text": "Inactive",
  "email": "newuser@mycompany.com",
  "fullname": "Pattern Creator",
  "groups": (nested object),
  "id": 2,
  "parts": (nested object),
  "password": (write-only),
  "patterns": (nested object),
  "roles": (nested object),
  "scripts": (nested object),
  "username": "newuser",
  "virtualimages": (nested object),
  "virtualsystems": (nested object)
}




使用内联 Python 对象可以获得相同的结果,如清单 6 和 7 所示。注意,<< 是上面示例中使用的 create() 方法的别名。
清单 6. 使用 JSON 创建一个新用户 - 命令
1
2
>>> cloudburst.users << {"username":"newuser", "fullname":"Pattern Deployer",
... "password":"password", "email":"newuser@mycompany.com"}




清单 7. 使用 JSON 创建一个新用户 - 输出
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{
  "currentmessage": "RM02013",
  "currentmessage_text": "User has not logged in yet",
  "currentstatus": "RM01062",
  "currentstatus_text": "Inactive",
  "email": "newuser@mycompany.com",
  "fullname": "Pattern Deployer",
  "groups": (nested object),
  "id": 3,
  "parts": (nested object),
  "password": (write-only),
  "patterns": (nested object),
  "roles": (nested object),
  "scripts": (nested object),
  "username": "newuser",
  "virtualimages": (nested object),
  "virtualsystems": (nested object)
}




CLI 还提供了一个非常方便的 help 函数,您可以对资源、资源集合和这些项的方法调用该函数:
  • 对于资源和资源集合,help 函数提供了项的简短摘要以及可用的属性和方法。
  • 对于方法,help 提供了方法摘要和方法接受的输入。
清单 8 和 9 展示了如何使用 help 方法找到与某个管理程序资源相关的属性和方法。
清单 8. 使用 help 函数 - 命令
1
>>> help(cloudburst.hypervisors[0])




清单 9. 使用 help 函数 - 输出
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
A Hypervisor object represents a particular hypervisor defined on the
CloudBurst appliance.  Use the Hypervisor object to query and
manipulate the hypervisor definition on the appliance.  Attributes of
the hypervisor and relationships between the hypervisor and other
resources on the CloudBurst appliance are represented as Jython
attributes on the Hypervisor object.  Manipulate these Jython
attributes using standard Jython mechanisms to make changes to the
corresponding data on the CloudBurst appliance.

Additional help is available for the following methods:
   acceptCertificate, __contains__, __delattr__, delete, discover, __eq__,
   __hash__, isMaintenance, isStarted, isStatusTransient, maintenance,
   __nonzero__, refresh, __repr__, start, __str__, __unicode__, waitFor

Additional help is available for the following properties:
   address, certificate, certified, cloud, created, currentmessage,
   currentmessage_text, currentstatus, currentstatus_text, desiredstatus,
   desiredstatus_text, id, name, networks, password, storage, type, updated,
   userid

Remember to append an underscore to the property name when asking for
help using a specific instance of a resource rather than the class.
For example, "help(cloudburst.pattern.name)" or "help(mypattern.name_)"
will work, but "help(mypattern.name)" will resolve the name of the pattern
referenced by mypattern and attempt to provide help for the resulting
string rather than the property itself.

返回列表