Cloud
https://www.vagrantup.com/docs/cli/cloud.html
命令: vagrant cloud
这是用来管理与vagrant相关的任何东西的命令。
该命令的主要功能是通过子命令公开的:
1)Cloud Auth
cloud auth命令用于处理与vagrant云授权相关的所有事情。
1》Cloud Auth Login
格式:
vagrant cloud auth login [options]
登录命令用于对HashiCorp的vagrant云服务器进行身份验证。只有在访问受保护的boxes时才需要登录。
使用Vagrant不需要登录。绝大多数vagrant使用者不需要登录。只有在使用某些特性,如使用受保护的boxes时需要登录。
userdeMBP:~ user$ vagrant cloud auth login -h
Usage: vagrant cloud auth login [options] Options: -c, --check Checks if currently logged in 查看目前是否已经登录
-d, --description DESCRIPTION Set description for the Vagrant Cloud token 设置vagrant云令牌的描述,将会改变用户此时的token值
-k, --logout Logout from Vagrant Cloud 从vagrant云退出
-t, --token TOKEN Set the Vagrant Cloud token 设置vagrant云令牌,将其存储在本地磁盘上
-u, --username USERNAME_OR_EMAIL Vagrant Cloud username or email address vagrant云用户名或邮箱地址
-h, --help Print this help 打印帮助信息
例子:
1>使用用户名和密码安全认证到vagrant云:
userdeMBP:~ user$ vagrant cloud auth login
In a moment we will ask for your username and password to HashiCorp's Vagrant Cloud. After authenticating, we will store an access token locally on disk. Your login details will be transmitted over a secure connection, and
are never stored on disk locally. If you do not have an Vagrant Cloud account, sign up at
https://www.vagrantcloud.com Vagrant Cloud username or email:
因为我还没有注册,所以应该先到https://www.vagrantcloud.com 进行注册
成功创建了一个账户后再使用login:
userdeMBP:~ user$ vagrant cloud auth login
In a moment we will ask for your username and password to HashiCorp's
Vagrant Cloud. After authenticating, we will store an access token locally on
disk. Your login details will be transmitted over a secure connection, and
are never stored on disk locally. If you do not have an Vagrant Cloud account, sign up at
https://www.vagrantcloud.com Vagrant Cloud username or email: Garcia-user
Password (will be hidden):
Token description (Defaults to "Vagrant login from userdeMacBook-Pro.local"):
You are now logged in.
2>检查当前用户是否经过身份验证
userdeMBP:~ user$ vagrant cloud auth login -c
You are already logged in.
3>使用令牌对vagrant云进行安全身份验证:
因为在上面的login过程中,在Token description 中没有输入内容,所以其默认为Vagrant login from userdeMacBook-Pro.local
userdeMBP:~ user$ vagrant cloud auth login -t Vagrant login from userdeMacBook-Pro.local
The token was successfully saved.
Invalid token. Please try again.
然后我又重新login了一遍,将Token description 值内容设置为firsttime-login
1.下面使用的-t标签的作用是将firsttime-login token值存储在你本地的磁盘中
userdeMBP:~ user$ vagrant cloud auth login -t firsttime-login
The token was successfully saved.
Invalid token. Please try again.
2.使用-d标签,通过token的描述来生成一个token,其实过程和login是一样的:
userdeMBP:~ user$ vagrant cloud auth login -d firsttime-login
In a moment we will ask for your username and password to HashiCorp's Vagrant Cloud. After authenticating, we will store an access token locally on disk. Your login details will be transmitted over a secure connection, and
are never stored on disk locally. If you do not have an Vagrant Cloud account, sign up at
https://www.vagrantcloud.com Vagrant Cloud username or email: Garcia-user
Password (will be hidden):
Token description: firsttime-login
You are now logged in.
然后我们在网站上可以看见:
有三个token信息,是上面的两个login和一个-d生成的
如果这个时候我运行:
userdeMBP:~ user$ vagrant cloud auth login -t secondtime-login
The token was successfully saved.
Invalid token. Please try again.
发现上面图示的页面不会有什么变化,所以-t标签是不会对用户token造成影响的,仅仅只是存储到了本地磁盘
2》Cloud Auth Logout
格式:
vagrant cloud auth logout [options]
当你已经登录时用来退出。如果你已经退出了,这个命令将不会做什么。如果你已经退出,运行这个命令是不会出现什么错误的
userdeMBP:~ user$ vagrant cloud auth logout -h
Usage: vagrant cloud auth logout [options] Log out of Vagrant Cloud Options: -u, --username USERNAME_OR_EMAIL Vagrant Cloud username or email address Vagrant云的用户名或邮箱地址
-h, --help Print this help 打印帮助信息
例子:
userdeMBP:~ user$ vagrant cloud auth logout
In a moment we will ask for your username and password to HashiCorp's
Vagrant Cloud. After authenticating, we will store an access token locally on
disk. Your login details will be transmitted over a secure connection, and
are never stored on disk locally. If you do not have an Vagrant Cloud account, sign up at
https://www.vagrantcloud.com Vagrant Cloud username or email: Garcia-user
Password (will be hidden):
Token description (Defaults to "Vagrant login from userdeMacBook-Pro.local"): firsttime-logout
You are now logged in.
You are logged out.
查看login状态:
userdeMBP:~ user$ vagrant cloud auth login -c
You are not currently logged in. Please run `vagrant login` and provide your login information to authenticate.
果然成功退出了
3》Cloud Auth Whoami
格式:
vagrant cloud auth whoami [options] [token]
这个命令将验证你的vagrant云令牌,并打印它所属的用户。如果传入一个令牌值,它将尝试验证它,而不是将其存储在磁盘上。
userdeMBP:~ user$ vagrant cloud auth whoami -h
Usage: vagrant cloud auth whoami [options] [token] Display currently logged in user Options: -u, --username USERNAME_OR_EMAIL Vagrant Cloud username or email address Vagrant云的用户名或邮箱地址
-h, --help Print this help 打印帮助信息
例子:
userdeMBP:~ user$ vagrant cloud auth logout
You are logged out.
userdeMBP:~ user$ vagrant cloud auth whoami //因为之前退出过,所以调用whoami前要先登录才行
In a moment we will ask for your username and password to HashiCorp's
Vagrant Cloud. After authenticating, we will store an access token locally on
disk. Your login details will be transmitted over a secure connection, and
are never stored on disk locally. If you do not have an Vagrant Cloud account, sign up at
https://www.vagrantcloud.com Vagrant Cloud username or email: Garcia-user
Password (will be hidden):
Token description (Defaults to "Vagrant login from userdeMBP.lan"): secondtime-login //重新设置这次新登录的新token描述
You are now logged in.
Currently logged in as Garcia-user userdeMBP:~ user$ vagrant cloud auth whoami //但是直接调用whoami就能够得到你登录的信息
Currently logged in as Garcia-user
但是如果想要将token添加进去验证时,就会报错:?????????
没能解决,有解决该问题的小伙伴请告知,谢谢
userdeMBP:~ user$ vagrant cloud auth whoami secondtime-login
Failed to read organization
Unauthorized - {"message"=>"Bad credentials"} userdeMBP:~ user$ vagrant cloud auth whoami -u Garcia-user //如果仅仅指明用户名,又不会出错
Currently logged in as Garcia-user userdeMBP:~ user$ vagrant cloud auth whoami -u Garcia-user secondtime-login
Failed to read organization
Unauthorized - {"message"=>"Bad credentials"}
2)Cloud Box
命令: vagrant cloud box
1》Cloud Box Create
格式:
vagrant cloud box create [options] organization/box-name
box create命令用于在Vagrant云上创建一个新的box条目
userdeMacBook-Pro:~ user$ vagrant cloud box create -h
Usage: vagrant cloud box create [options] organization/box-name Creates an empty box entry on Vagrant Cloud Options: -d, --description DESCRIPTION Full description of the box 该box的详细描述信息
-u, --username USERNAME_OR_EMAIL Vagrant Cloud username or email address vagrant云的用户名或邮箱地址
-s DESCRIPTION, Short description of the box 该box的简短描述信息
--short-description
-p, --private Makes box private 私有化box,仅自己可见
-h, --help Print this help 打印帮助信息
2》Cloud Box Delete
格式:
vagrant cloud box delete [options] organization/box-name
删除vagrant云上的某box条目
userdeMacBook-Pro:~ user$ vagrant cloud box delete -h
Usage: vagrant cloud box delete [options] organization/box-name Deletes box entry on Vagrant Cloud 删除vagrant云上的某box条目 Options: -u, --username USERNAME_OR_EMAIL Vagrant Cloud username or email addressvagrant云的用户名或邮箱地址
-h, --help Print this help 打印帮助信息
3》Cloud Box Show
格式:
vagrant cloud box show [options] organization/box-name
显示vagrant云上某box的属性
userdeMacBook-Pro:~ user$ vagrant cloud box show -h
Usage: vagrant cloud box show [options] organization/box-name Displays a boxes attributes on Vagrant Cloud 显示vagrant云上某box的属性 Options: -u, --username USERNAME_OR_EMAIL Vagrant Cloud username or email address vagrant云的用户名或邮箱地址
--versions VERSION Display box information for a specific version 显示指定版本的box的信息
-h, --help Print this help 打印帮助信息
4》Cloud Box Update
格式:
vagrant cloud box update [options] organization/box-name
更新vagrant云上的box条目
userdeMacBook-Pro:~ user$ vagrant cloud box update -h
Usage: vagrant cloud box update [options] organization/box-name Updates a box entry on Vagrant Cloud 更新vagrant云上的box条目 Options: -d, --description DESCRIPTION Full description of the box 该box的详细描述信息
-u, --username The username of the organization that will own the box 拥有该box的组织的用户名
-s DESCRIPTION, Short description of the box 该box的简短描述信息
--short-description
-p, --private Makes box private 私有化box,仅自己可见
-h, --help Print this help 打印帮助信息
3)Cloud Provider
命令: vagrant cloud provider
云provider
命令用于管理vagrant云上所有provider
实体的生命周期操作。
1》Cloud Provider Create
格式:
vagrant cloud provider create [options] organization/box-name provider-name version [url]
在vagrant云上创建一个provider条目
userdeMacBook-Pro:~ user$ vagrant cloud provider create -h
Usage: vagrant cloud provider create [options] organization/box-name provider-name version [url] Creates a provider entry on Vagrant Cloud 在vagrant云上创建一个provider条目 Options: -u, --username USERNAME_OR_EMAIL Vagrant Cloud username or email address vagrant云的用户名或邮箱地址
-h, --help Print this help 打印帮助信息
[url]参数应该是一个远程url,vagrant云可以使用它来下载provider。如果没有指定url,以后可以使用url更新提供provider条目,或者使用upload命令上传vagrant box文件。
2》Cloud Provider Delete
格式:
vagrant cloud provider delete [options] organization/box-name provider-name version
删除vagrant云上的某provider条目
userdeMacBook-Pro:~ user$ vagrant cloud provider delete -h
Usage: vagrant cloud provider delete [options] organization/box-name provider-name version Deletes a provider entry on Vagrant Cloud 删除vagrant云上的某provider条目 Options: -u, --username USERNAME_OR_EMAIL Vagrant Cloud username or email address vagrant云的用户名或邮箱地址
-h, --help Print this help 打印帮助信息
3》Cloud Provider Update
格式:
vagrant cloud provider update [options] organization/box-name provider-name version url
更新vagrant云上的某个provider条目
userdeMacBook-Pro:~ user$ vagrant cloud provider update -h
Usage: vagrant cloud provider update [options] organization/box-name provider-name version url Updates a provider entry on Vagrant Cloud 更新vagrant云上的某个provider条目 Options: -u, --username USERNAME_OR_EMAIL Vagrant Cloud username or email address vagrant云的用户名或邮箱地址
-h, --help Print this help 打印帮助信息
4》Cloud Provider Upload
格式:
vagrant cloud provider upload [options] organization/box-name provider-name version box-file
上传指定provider的box文件到vagrant云中
userdeMacBook-Pro:~ user$ vagrant cloud provider upload -h
Usage: vagrant cloud provider upload [options] organization/box-name provider-name version box-file Uploads a box file to Vagrant Cloud for a specific provider 上传指定provider的box文件到vagrant云中 Options: -u, --username USERNAME_OR_EMAIL Vagrant Cloud username or email address vagrant云的用户名或邮箱地址
-h, --help Print this help 打印帮助信息
provider上传命令将向vagrant云上传指定版本和provider的vagrant box文件
4)Cloud Publish
格式:
vagrant cloud publish ORGANIZATION/BOX-NAME VERSION PROVIDER-NAME [PROVIDER-FILE]
在vagrant云上创建和公布一个新的vagrant box
userdeMacBook-Pro:~ user$ vagrant cloud publish -h
Usage: vagrant cloud publish [options] organization/box-name version provider-name [provider-file] Create and release a new Vagrant Box on Vagrant Cloud 在vagrant云上创建和公布一个新的vagrant box Options: --box-version VERSION Version of box to create 创建的box的版本
--url URL Remote URL to download this provider 下载这个provider的远程URL
-d, --description DESCRIPTION Full description of box 该box的详细描述信息
--version-description DESCRIPTION Description of the version to create 该创建版本的描述
-f, --force Disables confirmation to create or update box 取消创建和更新box时的确认,即强制执行
-p, --private Makes box private 私有化box,仅自己可见
-r, --release Releases box 公布box
-s DESCRIPTION, Short description of the box 该box的简短描述信息
--short-description
-u, --username USERNAME_OR_EMAIL Vagrant Cloud username or email address vagrant云的用户名或邮箱地址
-h, --help Print this help 打印帮助信息
5)Cloud Search
格式:
vagrant cloud search [options] query
通过指定的user/organization名字来在vagrant云上搜索boxes
userdeMacBook-Pro:~ user$ vagrant cloud search -h
Usage: vagrant cloud search [options] query Search for boxes managed by a specific user/organization on Vagrant Cloud。通过指定的user/organization名字来在vagrant云上搜索boxes Options: -j, --json Formats results in JSON 将结果格式化成JSON格式
--page PAGE The page to display Default: 默认显示一页的内容
-s, --short Shows a simple list of box names 只显示box名字的简单列表
-o, --order ORDER Order to display results ('desc' or 'asc') Default: 'desc' 显示结果的顺序(逆向或正向),默认为逆向
-l, --limit LIMIT Max number of search results Default: 搜索结果的最大数量,默认为25
-p, --provider PROVIDER Filter search results to a single provider. Defaults to all. 使用provider来过滤搜索结果。默认是得到所有provider类型
--sort-by SORT Field to sort results on (created, downloads, updated) Default: downloads
指定用于对结果进行排序的字断(created, downloads, updated),默认使用的是downloads(即下载数量)
-u, --username USERNAME_OR_EMAIL Vagrant Cloud username or email address vagrant云的用户名或邮箱地址
-h, --help Print this help 打印帮助信息
例子:
6)Cloud Version
命令: vagrant cloud version
云version
命令用于管理vagrant云上的一个box中的所有版本实体的生命周期操作。
1》Cloud Version Create
格式:
vagrant cloud version create [options] organization/box-name version
在vagrant云上创建版本条目
userdeMacBook-Pro:~ user$ vagrant cloud version create -h
Usage: vagrant cloud version create [options] organization/box-name version Creates a version entry on Vagrant Cloud 在vagrant云上创建版本条目 Options: -d, --description DESCRIPTION A description for this version 对该版本的详细描述
-u, --username USERNAME_OR_EMAIL Vagrant Cloud username or email address vagrant云的用户名或邮箱地址
-h, --help Print this help 打印帮助信息
2》Cloud Version Delete
格式:
vagrant cloud version delete [options] organization/box-name version
从vagrant云中删除一个版本条目
userdeMacBook-Pro:~ user$ vagrant cloud version delete -h
Usage: vagrant cloud version delete [options] organization/box-name version Deletes a version entry on Vagrant Cloud 从vagrant云中删除一个版本条目 Options: -u, --username USERNAME_OR_EMAIL Vagrant Cloud username or email address vagrant云的用户名或邮箱地址
-h, --help Print this help 打印帮助信息
3》Cloud Version Release
格式:
vagrant cloud version release [options] organization/box-name version
在vagrant云上发布版本条目
userdeMacBook-Pro:~ user$ vagrant cloud version release -h
Usage: vagrant cloud version release [options] organization/box-name version Releases a version entry on Vagrant Cloud 在vagrant云上发布版本条目 Options: -u, --username USERNAME_OR_EMAIL Vagrant Cloud username or email address vagrant云的用户名或邮箱地址
-h, --help Print this help 打印帮助信息
4》Cloud Version Revoke
格式:
vagrant cloud version revoke [options] organization/box-name version
从vagrant云上撤销一个版本条目
userdeMacBook-Pro:~ user$ vagrant cloud version revoke -h
Usage: vagrant cloud version revoke [options] organization/box-name version Revokes a version entry on Vagrant Cloud 从vagrant云上撤销一个版本条目 Options: -u, --username USERNAME_OR_EMAIL Vagrant Cloud username or email address vagrant云的用户名或邮箱地址
-h, --help Print this help 打印帮助信息
5》Cloud Version Update
格式:
vagrant cloud version update [options] organization/box-name version
更新在vagrant云上的版本条目
userdeMacBook-Pro:~ user$ vagrant cloud version update -h
Usage: vagrant cloud version update [options] organization/box-name version Updates a version entry on Vagrant Cloud 更新在vagrant云上的版本条目 Options: -d, --description DESCRIPTION A description for this version 对该版本的详细描述
-u, --username USERNAME_OR_EMAIL Vagrant Cloud username or email address vagrant云的用户名或邮箱地址
-h, --help Print this help 打印帮助信息