# Uses Cases

## Use Cases

* [Neutron](http://superuser.openstack.org/articles/everything-you-need-to-know-to-get-started-with-neutron-f90e2797-26b7-4d1c-84d8-effef03f11d2/)

## Use Cases :: Drones

Images

1. Ardupilot
2. DroneKit Copter
3. DroneKit Python
4. QGroundControl

Distros

1. Lubuntu
2. Ubuntu Server

## Use Cases :: Drones :: Ubuntu Image

1. Change Cloud Image credentials
2. [Generate User Password in Ubuntu Cloud Image](http://www.yamansertdemir.com/?p=55)

```bash
user@workstation:~$ cd Downloads
user@workstation:~/Downloads$ wget http://cloud-images.ubuntu.com/releases/16.04/release/ubuntu-16.04-server-cloudimg-amd64.tar.gz
```

```bash
user@workstation:~/Downloads$ sudo apt-get install libguestfs-tool
user@workstation:~/Downloads$ guestfish --rw -a xenial-server-cloudimg-amd64-disk1.img 

Welcome to guestfish, the guest filesystem shell for
editing virtual machine filesystems and disk images.

Type: 'help' for help on commands
      'man' to read the manual
      'quit' to quit the shell

><fs> run
><fs> list-filesystems
/dev/sda1: ext4
><fs> mount /dev/sda1 /
><fs> vi /etc/cloud/cloud.cfg
><fs> exit

user@workstation:~/Downloads$
```

/etc/cloud/cloud.cfg

```bash
# The top level settings are used as module
# and system configuration.

# A set of users which may be applied and/or used by various modules
# when a 'default' entry is found it will reference the 'default_user'
# from the distro configuration specified below

users:
   - default
   - name: ubuntu
     lock-passwd: false
     plain_text_passwd: 'ubuntu'

# If this is set, 'root' will not be able to ssh in and they
# will get a message to login instead as the default $user
disable_root: true

# This will cause the set+update hostname module to not operate (if true)
preserve_hostname: false

# Example datasource config
# datasource:
#    Ec2:
#      metadata_urls: [ 'blah.com' ]
#      timeout: 5 # (defaults to 50 seconds)
#      max_wait: 10 # (defaults to 120 seconds)

# The modules that run in the 'init' stage
cloud_init_modules:
 - migrator
 - seed_random
 - bootcmd
 - write-files
 - growpart
 - resizefs
 - disk_setup
 - mounts
 - set_hostname
 - update_hostname
 - update_etc_hosts
 - ca-certs
 - rsyslog
 - users-groups
 - ssh

# The modules that run in the 'config' stage
cloud_config_modules:
# Emit the cloud config ready event
# this can be used by upstart jobs for 'start on cloud-config'.
 - emit_upstart
 - snap_config
 - ssh-import-id
 - locale
 - set-passwords
 - grub-dpkg
 - apt-pipelining
 - apt-configure
 - ntp
 - timezone
 - disable-ec2-metadata
 - runcmd
 - byobu

# The modules that run in the 'final' stage
cloud_final_modules:
 - snappy
 - package-update-upgrade-install
 - fan
 - landscape
 - lxd
 - puppet
 - chef
 - salt-minion
 - mcollective
 - rightscale_userdata
 - scripts-vendor
 - scripts-per-once
 - scripts-per-boot
 - scripts-per-instance
 - scripts-user
 - ssh-authkey-fingerprints
 - keys-to-console
 - phone-home
 - final-message
 - power-state-change

# System and/or distro specific settings
# (not accessible to handlers/transforms)
system_info:
   # This will affect which distro class gets used
   distro: ubuntu
   # Default user name + that default users groups (if added/used)
   default_user:
     name: ubuntu
     gecos: Ubuntu
     groups: [adm, audio, cdrom, dialout, dip, floppy, lxd, netdev, plugdev, sudo, video]
     sudo: ["ALL=(ALL) NOPASSWD:ALL"]
     shell: /bin/bash
   # Other config here will be given to the distro class and/or path classes
   paths:
      cloud_dir: /var/lib/cloud/
      templates_dir: /etc/cloud/templates/
      upstart_dir: /etc/init/
   package_mirrors:
     - arches: [i386, amd64]
       failsafe:
         primary: http://archive.ubuntu.com/ubuntu
         security: http://security.ubuntu.com/ubuntu
       search:
         primary:
           - http://%(ec2_region)s.ec2.archive.ubuntu.com/ubuntu/
           - http://%(availability_zone)s.clouds.archive.ubuntu.com/ubuntu/
           - http://%(region)s.clouds.archive.ubuntu.com/ubuntu/
         security: []
     - arches: [armhf, armel, default]
       failsafe:
         primary: http://ports.ubuntu.com/ubuntu-ports
         security: http://ports.ubuntu.com/ubuntu-ports
   ssh_svcname: ssh
```

1. Change Hostname

```bash
ubuntu@ubuntu:~$ hostname
ubuntu
ubuntu@ubuntu:~$ vi /etc/hosts
127.0.0.1 ubuntu
```

1. On Virtual Machine, change nameservers

```bash
ubuntu@ubuntu:~$ vi /etc/resolvconf/resolv.conf.d/base
nameserver 8.8.8.8 8.8.4.4
ubuntu@ubuntu:~$ sudo resolvconf -u
```

1. Create snapshot
2. Download image
3. [Snapshots](https://docs.openstack.org/mitaka/user-guide/cli_use_snapshots_to_migrate_instances.html)
4. Enable SSH Server

```
stack@workstation:~/devstack$ cat userrc_early 
# Use this for debugging issues before files in accrc are created

# Set up password auth credentials now that Keystone is bootstrapped
export OS_IDENTITY_API_VERSION=3
export OS_AUTH_URL=http://192.168.1.83/identity
export OS_USERNAME=admin
export OS_USER_DOMAIN_ID=default
export OS_PASSWORD=admin
export OS_PROJECT_NAME=admin
export OS_PROJECT_DOMAIN_ID=default
export OS_REGION_NAME=RegionOne

stack@workstation:~/devstack$ source userrc_early 
stack@workstation:~/devstack$ glance image-list
+--------------------------------------+---------------------------+
| ID                                   | Name                      |
+--------------------------------------+---------------------------+
| bad12c2e-645d-4453-b7da-f3c78a9d0a5c | cirros-0.3.5-x86_64-disk  |
| e867d2a4-d4d3-446c-84c6-70b0ec4ca9a4 | ubuntu                    |
| 7a652931-1836-4489-805f-09e11a21890f | usecases.drone.ubuntu.one |
+--------------------------------------+---------------------------+
stack@workstation:~/devstack$
```

Not Working!

```bash
stack@workstation:~/devstack$ glance image-download --file usecases.drone.ubuntu.one.img 7a652931-1836-4489-805f-09e11a21890f
```

```bash
stack@workstation:~/devstack$ glance --os-image-api-version 2 image-create --container-format bare --disk-format qcow2 --copy-from usecases.drone.ubuntu.one-img
```

1. Clone Bitol Repository

```bash
ubuntu@ubuntu:~$ git clone https://github.com/TheIoTLearningInitiative/Bitol.git
ubuntu@ubuntu:~$ cd Bitol/SoftwareDevelopmentEnvironment/
ubuntu@ubuntu:~/Bitol/SoftwareDevelopmentEnvironment/$ bash Ardupilot.sh
```

Did not work to change password, do not follow these instructions

```bash
user@workstation:~/Downloads$ sudo apt install bzr
user@workstation:~/Downloads$ bzr branch lp:~smoser/+junk/backdoor-image
You have not informed bzr of your Launchpad ID, and you must do this to
write to Launchpad or access private data.  See "bzr help launchpad-login".
Branched 37 revisions.                                                                                                                       
user@workstation:~/Downloads$
```

```bash
user@workstation:~/Downloads$ sh backdoor-image --user ubuntu --password ubuntu --password-auth xenial-server-cloudimg-amd64-disk1.img 
user@workstation:~/Downloads$
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://theiotlearninginitiative.gitbook.io/edgecomputingsolutions/introduction/stacks/openstack/testing/akraino/uses-cases.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
