Openstack Usage - hqzhang/cloudtestbed GitHub Wiki

Openstack Introduction

Openstack can offer cloud-computing services running on standard hardware.
1. Compute (Nova)      
It is designed to manage and automate pools of computer resources and can work with widely available virtualization technologies, as well as bare metal and high-performance computing (HPC) configurations. 

2. Networking (Neutron) .                VPC(aws) ELB (Elastic Load Balancing) Route53(DNS)
OpenStack Networking (Neutron) is a system for managing networks and IP addresses. 

3. Block/Object storage (Cinder/Swift)   EBS(Elastic Block Storage)S3(aws)
OpenStack Block Storage (Cinder) provides persistent block-level storage devices for use with OpenStack compute instances.  Snapshots can be restored or used to create a new block storage volume. Object can provide redundancy storage. 

4. Identity (Keystone) .                  IAM(aws)
OpenStack Identity (Keystone) provides a central directory of users mapped to the OpenStack services they can access. It acts as a common authentication system across the cloud operating system and can integrate with existing backend directory services like LDAP. It supports multiple forms of authentication.

5. Image (Glance) .                        AMI(aws)
OpenStack Image (Glance) provides discovery, registration, and delivery services for disk and server images. Stored images can be used as a template. It can also be used to store and catalog an unlimited number of backups. The Image Service can store disk and server images in a variety of back-ends, including Swift. The Image Service API provides a standard REST interface for querying information about disk images and lets clients stream the images to new servers.

Glance adds many enhancements to existing legacy infrastructures. For example, if integrated with VMware, Glance introduces advanced features to the vSphere family such as vMotion, high availability and dynamic resource scheduling (DRS). vMotion is the live migration of a running VM, from one physical server to another, without service interruption. Thus, it enables a dynamic and automated self-optimizing datacenter, allowing hardware maintenance for the underperforming servers without downtimes.[58][59]

Other OpenStack modules that need to interact with Images, for example Heat, must communicate with the images metadata through Glance. Also, Nova can present information about the images, and configure a variation on an image to produce an instance. However, Glance is the only module that can add, delete, share, or duplicate images.[60]

6. Dashboard (Horizon)             Console(aws)

7. Orchestration (Heat)            CloudFormation(aws)

8. Workflow (Mistral)

9. Telemetry (Ceilometer)             Cloudwatch(aws)

10. Database (Trove)                 RDS(aws)
                              Relational Database Service (RDS) with MySQL, Oracle, SQL Server, and PostgreSQL

11.Elastic map reduce (Sahara) .     EMR(aws)

12.Bare metal (Ironic)

13. Amazon CloudHSM Hardware Security Module for data security and for meeting regulatory compliance requirements
14.AWS Key Management Service (KMS) for creating and managing encryption keys

Messaging (Zaqar)
Shared file system (Manila)
DNS (Designate)
Search (Searchlight)
Key manager (Barbican)
Container orchestration (Magnum)
Root Cause Analysis (Vitrage)
Rule-based alarm actions (Aodh)

Networking Graph

+-----------------------+
|  network4             |
|  (external=True)      |
+------------------+----+
                   |router gateway port
                   |(its primary address is gw-ip)
         +---------+--------------------------------------------+
         |      floating-ip-A                                   |
         |    router                                            |
         |    (enable_snat=True)                                |
         |                                        floating-ip-B |
         +----+-----------------+--------------------+----------+
              |router           |router              |router
              |interface        |interface           |interface
  +-----------+-----+    +------+----------+    +----+------------+
  | network1        |    | network2        |    | network3        |
  | (external=False)|    | (external=False)|    | (external=True) |
  +-----+-----------+    +--------+--------+    +------+----------+
        |                         |                    |
    +---+-------+             +---+-------+        +---+-------+
    |fixed-ip-X |             |fixed-ip-Y |        |fixed-ip-Z |
    +-----------+             +-----------+        +-----------+
       VM-X                      VM-Y                 VM-Z

Createvm by ShellScript

   #parameters
    netname=public-net1
    routername=TestRouter
    externalnet=public-floating-601
    subcidr=192.168.4.0/24
    flavorname=GP2-Xlarge
    imagename=ubuntu-14.04
    keyname=CloudKey2
    servername=MyVM
    FLOATING_IP_START=
    FLOATING_IP_END=
    EXTERNAL_NETWORK_GATEWAY=
    EXTERNAL_NETWORK_CIDR=

   #1) #create nets
      netid=$(neutron net-list|grep $netname|awk '{print $2}')
      netid=$(neutron net-create $netname|grep id|awk '{print $4}')
      echo $netid
      subid=$(neutron subnet-list|grep $netname|awk '{print $2}')
      subid=$(nt subnet-create $netname  $subcidr --name $netname |grep id|awk '{print $4}')
      echo $subid
      portid=$(neutron port-list|grep $netname|awk '{print $2}')
      #portid=$(nt port-create --fixed-ip subnet_id=$subid,ip_address="192.168.4.20" --name=public-net1|grep id |awk '{print $4}')
      portid=$(neutron port-create $netname --name $netname|grep id |awk '{print $4}')
      echo $portid
   
   #2)#create server
      flavorid=$(nova flavor-list|grep $flavorname|awk '{print $2}')
      keypairid=$(nova keypair-list|grep keyname|awk '{print $4}')
      serverid=$(nova list|grep $imagename|awk '{print $2}')
      imageid=$(nova image-list|grep $imagename|awk '{print $2}')

     serverid=$(nova boot --flavor $flavorname --key-name $keyname --image $imageid --nic port-id=$portid $servername|grep id|awk '{print $4}')
     echo $serverid

   #3) create router
     routerid=$neutron router-list|grep $routername|awk '{print $2}')
     routerid=$(neutron router-create TestRouter|grep id|awk '{print $4}')
     neutron router-gateway-set $routername $externalnet
     neutron router-interface-add $routername $netname

   #4) create floating IP
      neutron floatingip-list   //all ips allocated or used
      flipid=$(neutron floatingip-create $externalnet --port-id $portid|grep id|awk '{print $4}')

   # add extra interface
    5) nova --debug interface-attach  --net-id $netid $serverid

   #create external network (optional)
    6)  neutron net-create $exteranlnet --router:external True \
  --provider:physical_network external --provider:network_type flat

    7) neutron subnet-create $externalnet --name $externalnet \
  --allocation-pool start=$FLOATING_IP_START,end=$FLOATING_IP_END \
  --disable-dhcp --gateway $EXTERNAL_NETWORK_GATEWAY $EXTERNAL_NETWORK_CIDR  

    8) neutron subnet-create $externalnet --name $externalnet \
  --allocation-pool start=203.0.113.101,end=203.0.113.200 \
  --disable-dhcp --gateway 203.0.113.1 203.0.113.0/24

Deletevm ShellScript

   #delete instance
   1) serverid=(nova list $servername|grep id|awk '{print $2}'

   2) serverid=$(nova delete $servername)

   #delete nets
   3) portid=$(neutron port-list|grep $netname|awk '{print $2}'
      neutron port-delete $portid

   4) subid=$(neutron subnet-list|grep $netname|awk '{print $2}' 
      neutron subnet-delete $subid

   5) netid=$(neutron net-list|grep $netname|awk '{print $2}')
      neutron net-delete $netid
  
   # delete floating IP
   6) flipid=$(neutron floatingip-list|grep $portid|awk '{print $2}'   //all ips allocated or used

   7) flipid=$(neutron floatingip-delete $routerid $netname)

   8) neutron router-gateway-clear $routerid 

   9) neutron router-interface-add $routername $netname

   # delete router
   10) routerid=$neutron router-list|grep $routername|awk '{print $2}')

   11) routerid=$(neutron router-delete $routerid|awk '{print $3}')

   #delete external network (optional)
   12) neutron net-delete $exteranlnet 

   13) neutron subnet-delete $externalnet