Command Line Cheat Sheet

shoenisch edited this page Apr 18, 2017 · 7 revisions

This cheat sheet lists common Photon Controller commands. The commands assume that you have installed Photon Controller with authentication turned on.

Viewing help for commands: For information about photon commands, subcommands, and options, see the help for the Photon CLi. Examples:

photon --help
photon tenant quota --help
photon service create -h

Here's the output of photon -h:

photon -h
   photon - Command line interface for Photon Controller
   photon [global options] command [command options] [arguments...]
   Git commit hash: 11f5e4c
     auth              options for auth
     system            options for system operations
     target            options for target
     tenant            options for tenant
     host              options for host
     datastore         options for datastore
     deployment        options for deployment
     image             options for image
     task              options for task
     flavor            options for flavor
     project           options for project
     disk              Options for persistent disks
     vm                options for vm
     service, cluster  Options for services
     router            options for router
     subnet            options for subnet
     zone              options for zone
     help, h           Shows a list of commands or help for one command
   --non-interactive, -n       trigger for non-interactive mode (scripting)
   --log-file value, -l value  write logging information into a logfile at 
                               the specified path
   --output value, -o value    select output format
   --detail, -d                print the current target, user, tenant, project
   --help, -h                  show help
   --version, -v               print the version

Non-interactive mode: The -n option suppresses prompting but assumes that the command contains all the information required to execute successfully.

Replacing variables in commands: Many of the commands in this cheat sheet contain <variables> that you must replace. Commands containing variables are often immediately followed by examples with the variables replaced.

Setting Targets and Logging In

To manage Photon Controller, you connect to the load balancer from your workstation by using the command-line interface. You can then create tenants, quotas, projects, and Kubernetes clusters. (You can obtain the load balancer's IP address from your YAML deployment file.)

You connect to Port 443 of the IP address of the load balancer by running the following photon target set command with the -c option:

photon target set -c https://<ip-of-load-balancer>:443

After you set the target, you can log in by using the credentials that you set in the lightwave section of the YAML configuration file. Here's an example:

  domain: ""
    username: "administrator"
    password: "Secret1!"

Here's the syntax of the command to log in:

photon target login --username <username>@<lightwave-domain> --password 'Your$ecret1!'

Here is an example. In the sample YAML code block above, the username of the Lightwave credential is set to administrator and the domain is set to The photon target login uses the Lightwave domain and credentials to authenticate the user with the Lightwave security service.

photon target login --username --password 'Secret1!'

Once logged in, you can check the status of Photon Controller:

photon system status
Overall status: READY
Component          Status

You can get more information about the deployment by running the following command:

photon deployment show


Upload an image by using the photon image create command:

photon image create <local-path-to-image> -n <name> -i <replicationType> 
photon image create /tmp/ubuntu14-04.ova -n ubuntu1404 -i ON_DEMAND 

Create an image, list all your images, show information about an image, and then delete it:

photon image create <image_filename> -n <image_name> -i <image_type>
photon image create photon-kubernetes-vm-disk1.vmdk -n photon-kubernetes-vm.vmdk -i EAGER
photon image list
photon image show <image-ID>
photon image show 96cd7af4-f1d0-45ea-8ed1-e18bef6c05ca
photon image delete <image-ID>
photon image delete 96cd7af4-f1d0-45ea-8ed1-e18bef6c05ca

Tenants and Projects

Here are some of the commands for managing tenants and quotas:

photon tenant create <name_of_tenant>
photon tenant list
photon tenant show <tenant-ID>
photon tenant quota show <tenant-id>
photon project quota show <project-id>
photon tenant quota set ...
photon project quota set ...

Here are some examples:

photon tenant create plato
photon tenant quota set plato
         --limits 'vm.count 100 COUNT, vm.memory 1000 GB, vm.cpu 500 COUNT'
photon project create --tenant "plato" --name "plato-prjt"  
--limits "vm.memory 100 GB, vm.cpu 100 COUNT, vm 100 COUNT, 
          persistent-disk 100 COUNT, persistent-disk.capacity 200 GB" 
photon project quota set projectid1 
--limits 'vm.count 100 COUNT, vmMemory 1000 GB, vmCpu 500 COUNT'
photon tenant set "plato"
photon project set "plato-prjt"

Flavors and Disks

Here are examples of how to provision resources for virtual machines or clusters with photon flavor create:

photon -n flavor create --name "vm-basic" --kind "vm" 
                        --cost "vm 1 COUNT, vm.cpu 2 COUNT, vm.memory 2 GB" 
photon -n flavor create --name "disk-eph" --kind "ephemeral-disk" 
                        --cost "ephemeral-disk 1 COUNT"
photon -n flavor create --name "disk-persist" --kind "persistent-disk" 
                        --cost "persistent-disk 1 COUNT"
photon -n flavor create --name "my-vm" --kind "vm" 
                        --cost "vm 1 COUNT, vm.cpu 1 COUNT, vm.memory 2 GB"

Virtual Machines and Disks

Stop a VM by its ID and create a new image from it:

photon vm stop bac117cb-fc32-46e0-abcd-999199c6b6d5
photon vm create-image bac117cb-fc32-46e0-abcd-999199c6b6d5 -n image-1 -r ON_DEMAND

More examples of creating a VM:

photon vm create -n vm-1 -f core-100 -d "disk-1 core-100 boot=true" 
-i 5889ea6b-20ca-4706-99e8-87096d2c274
photon -n vm create --name vm-1 --flavor tiny --disks "disk-1 core-100 boot=true" 
-w “ID of Network”  -i “ID of Image”  --affinities disk:"ID of Persistent disk”

Get a list of all the VMs in your project and show the information about one of them:

photon vm list
photon vm show <ID>
photon vm show bac117cb-fc32-46e0-abcd-999199c6b6d5

Here are examples of how to create a peristent disk:

photon disk create -n disk-2 -f core-100 -g 10
photon  disk create --name persistent-disk-1 --flavor core-100 
--capacityGB 10 --affinities vm:”ID of VM”

Attach or detach a persistent disk to or from a powered-off VM:

photon vm stop <VM-ID>
photon vm attach_disk <VM-ID <disk-ID>
photon vm attach_disk bac117cb-fc32-46e0-abcd-999199c6b6d5 
  -d dab22828-8cfe-441d-b837-b197adbc651e
photon vm detach_disk <VM-ID <disk-ID>
photon vm detach_disk bac117cb-fc32-46e0-abcd-999199c6b6d5 
  -d dab22828-8cfe-441d-b837-b197adbc651e

Delete a disk:

photon disk delete <disk-ID>
photon disk delete dab22828-8cfe-441d-b837-b197adbc651e

Here's how to upload and attach an ISO to a powered-off VM:

photon vm attach_iso <VM-ID> -p path -n name
photon vm attach_iso bac117cb-fc32-46e0-abcd-999199c6b6d5 -p /tmp/db.iso -n test-db

Operate a VM by citing its ID:

photon vm start bac117cb-fc32-46e0-abcd-999199c6b6d5
photon vm stop bac117cb-fc32-46e0-abcd-999199c6b6d5
photon vm suspend bac117cb-fc32-46e0-abcd-999199c6b6d5
photon vm resume bac117cb-fc32-46e0-abcd-999199c6b6d5


Here are examples of how to establish resources for a Kubernetes cluster:

photon image create photon-kubernetes-vm-disk1.vmdk -n photon-kubernetes-vm.vmdk -i EAGER
photon image list
photon deployment list
photon deployment enable-cluster-type <deployment_ID> -k KUBERNETES -i <Kubernetes_image_ID>

Here's how to create a Kubernetes cluster. Replace the example IP addresses with those from your Photon Controller environment. The IP address for the master-ip option should contain the static IP address that you want to assign to the Kubernetes cluster. The etcd option should also contain a static IP address.

photon service create -n kube-socrates -k KUBERNETES --master-ip 
--etcd1 --container-network --dns 
--gateway --netmask

More photon service commands:

photon service list

To get the Kubernetes master node IP address, use show:

photon service show <cluster-id>

See all the VMs in a cluster:

photon service list-vms <cluster-ID>

Delete it:

photon service delete <cluster-ID>

Availability Zones

Create an availability zone, set it as the default, and create a VM in it:

Photon availability_zone create --name “zone-name”
photon host set_availability_zone <hostID> <availabilityZoneID>
photon -n vm create --name vm-2 --flavor core-200 --disks "new-disk core-200 boot=true" 
--affinities "availabilityZone:UUIDofAZ"


View your token:

photon auth show-login-token

Sample output for a domain named photon:

	Login Access Token:
    Subject: faulkner@photon
    Groups: photon\group11, photon\Everyone
    Issued: 2016-11-30 04:02:15.00
    Expires: 2016-11-30 04:07:15.00
    Token: ...
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.