NETAJI SUBHASH UNIVERSITY OF
TECHNOLOGY
CLOUD COMPUTING PRACTICAL FILE
SEMESTER - VI
EIOT(2024-2025)
SECTION-I
NAME- GAURAV KUMAR
ROLL NO. – 2022UEI2832
Cloud Computing Lab – Index
1. Set up Virtual Machines with Diverse OS Flavors on Windows
2. File Transfer Between Virtual Machines
3. Install C Compiler and Execute Programs Inside Virtual Machine
4. Install Google App Engine and Create Web Applications (Python and Java)
5. Launch Web Applications with Google App Engine Launcher
6. Cloud Scenario with CloudSim
7. Docker Lab Task: Containerize and Deploy a Simple Web Application
8. Launch Virtual Machine using TryStack (Online OpenStack Demo)Simulate
9. Cloud Server Task Processing Simulation Using AnyLogic
EXPERIMENT 1
Aim:
To set up virtual machines with diverse operating system flavors on a Windows host using
VirtualBox or VMware Workstation.
Procedure:
1. Download and install either VirtualBox or VMware Workstation on your Windows
machine.
○ For VirtualBox: https://www.virtualbox.org/
○ For VMware Workstation Player: https://www.vmware.com/products/workstation-
player.html
2. Download the ISO files for the operating systems you want to install. Recommended
distributions:
○ Ubuntu: https://ubuntu.com/download/desktop
○ Fedora: https://getfedora.org/
○ CentOS (Stream): https://www.centos.org/centos-stream/
○ Windows ISOs: https://www.microsoft.com/en-us/software-download/
3. Follow this tutorial to create your first virtual machine:
Ubuntu on VirtualBox Tutorial
4. For each new virtual machine:
○ Open VirtualBox or VMware.
○ Click New.
○ Name the VM and select the OS type and version.
○ Allocate RAM and hard disk space.
○ Mount the respective ISO file as the startup disk.
○ Start the VM and go through the OS installation steps.
5. Repeat the steps for each OS flavor:
○ Create a VM for Ubuntu.
○ Create a VM for Fedora.
○ Create a VM for CentOS.
○ (Optional) Create VMs for different versions of Windows (e.g., Windows 10,
Windows 11).
6. Once installed, boot into each VM and verify that the OS is functioning correctly.
EXPERIMENT 2
Aim:
To explore and implement methods for transferring files between virtual machines using shared
folders and network-based file transfer protocols.
Procedure:
1. Set Up Virtual Machines:
○ Ensure you have two or more virtual machines (VMs) running—either on
VirtualBox, VMware, or a cloud platform.
○ Confirm that the VMs are connected to the same virtual network or can access
the internet.
2. Method 1: Shared Folders (for VirtualBox or VMware)
○ On VirtualBox:
■ Go to VM Settings > Shared Folders.
■ Click Add, then choose a folder path from your host and assign a name.
■ Enable Auto-mount and Make Permanent.
■ Start the VM and access the shared folder, usually mounted at
/media/sf_<foldername> on Linux.
○ On VMware:
■ Enable Shared Folders in the VM settings.
■ Access the shared folder in the VM’s filesystem (e.g., /mnt/hgfs/ in
Linux).
3. Method 2: File Transfer via Google Drive or Dropbox
○ Install a web browser in each VM or use a command-line tool like rclone.
○ Upload the file to Google Drive or Dropbox from VM1.
○ On VM2, log in to the same account and download the file.
○ Alternative: Use shared links to avoid logging in again.
4. Method 3: SCP (Secure Copy) – Works between networked VMs
○ On Linux VMs, enable SSH on both systems.
From VM1, use the following command to copy a file to VM2:
scp /path/to/file username@VM2_IP:/destination/path
○
○ You’ll be prompted to enter the password or use SSH keys for secure,
passwordless transfer.
5. Method 4: Python HTTP File Server (Quick and Simple)
On VM1, navigate to the file directory and run:
python3 -m http.server 8000
○
○ On VM2, open a browser and visit http://<VM1_IP>:8000 to download the
file.
6. Verify the File Transfer:
○ Check that the file is present and accessible on the destination VM.
○ Open or execute the file to confirm its integrity.
EXPERIMENT 3
Aim:
To install a C compiler inside a VirtualBox virtual machine and verify its functionality by writing,
compiling, and executing simple C programs.
Procedure:
1. Start the Virtual Machine:
○ Boot into the virtual machine (VM) created earlier using VirtualBox.
○ Ensure the VM is running a Linux-based OS like Ubuntu.
2. Install the GCC Compiler:
○ Open the terminal in the VM.
Update package lists:
sudo apt update
Install GCC and essential build tools:
sudo apt install build-essential
Verify installation:
gcc --version
○
○ This should display the version of GCC installed, confirming a successful setup.
3. Write a Simple C Program:
Create a new file named hello.c:
nano hello.c
Paste the following code:
#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
}
○
○ Save and exit (Ctrl+O, Enter, then Ctrl+X in nano).
4. Compile the C Program:
Run the compilation command:
gcc hello.c -o hello
○
○ This creates an executable file named hello.
5. Execute the Compiled Program:
Run the executable:
./hello
○
○ You should see the output: Hello, World!
6. Write and Compile a Second Program (e.g., Arithmetic):
Create another file:
nano calc.c
○
Add the following code:
#include <stdio.h>
int main() {
int a = 10, b = 5;
printf("Sum = %d\n", a + b);
printf("Product = %d\n", a * b);
return 0;
}
Compile and run:
gcc calc.c -o calc
./calc
○
EXPERIMENT 4
Aim:
To set up the Google App Engine development environment on a host machine and create a
"Hello World" web application using both Python and Java.
Procedure:
1. Install Google Cloud SDK (Includes GAE Tools):
○ Download and install the Google Cloud SDK from:
https://cloud.google.com/sdk/docs/install
After installation, initialize it using:
gcloud init
○
○ Log in with your Google account and select or create a Google Cloud project.
2. Install GAE Components for Python and Java:
For Python:
gcloud components install app-engine-python
For Java:
gcloud components install app-engine-java
○
3. Set Up Python "Hello World" Web App:
○ Create a new folder, e.g., gae-python-app.
Inside, create the following files:
main.py
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
return 'Hello, World from Python on GAE!'
if __name__ == '__main__':
app.run()
app.yaml
runtime: python39
entrypoint: gunicorn -b :$PORT main:app
handlers:
- url: /.*
script: auto
requirements.txt
Flask==2.0.3
gunicorn==20.1.0
Install dependencies:
pip install -r requirements.txt
Deploy the app:
gcloud app deploy
View the app:
gcloud app browse
○
4. Set Up Java "Hello World" Web App:
○ Use Maven or Gradle to scaffold a simple GAE app.
5. Using Maven:
Generate a new project with the App Engine standard archetype:
mvn archetype:generate \
-DgroupId=com.example \
-DartifactId=gae-java-app \
-Dversion=1.0 \
-DarchetypeGroupId=com.google.appengine.archetypes \
-DarchetypeArtifactId=appengine-standard-archetype \
-DarchetypeVersion=1.9.88
Navigate into the project folder and run:
mvn package
gcloud app deploy target/*.war
Once deployed, open the app:
gcloud app browse
○
6. Verify Web Applications:
○ Access both applications in your browser.
○ Confirm that "Hello, World!" messages are displayed from both the Python and
Java versions.
EXPERIMENT 5
Aim:
To deploy and launch web applications using Google App Engine Launcher on Google Cloud’s
infrastructure.
Procedure:
1. Set up Google Cloud SDK:
○ Download and install the Google Cloud SDK from https://cloud.google.com/sdk.
○ During installation, select the option to install Google App Engine components
for your preferred language (e.g., Python).
○ After installation, open a terminal or command prompt and run:
gcloud init
■ Log in with your Google account and select/create a project.
2. Install Google App Engine Launcher (for older Python versions):
○ Note: The launcher is deprecated. If you’re using Python 2.7 and an older setup,
you can still download it from archived sources.
○ For current GCP deployments, use command-line tools with gcloud app deploy.
3. Prepare the “Hello World” application:
Create a new folder (e.g., hello-app) and add these two files:
app.yaml
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: main.app
main.py
import webapp2
class MainHandler(webapp2.RequestHandler):
def get(self):
self.response.write('Hello, World!')
app = webapp2.WSGIApplication([
('/', MainHandler)
], debug=True)
○
4. Deploy the app:
○ Navigate to the project folder in the terminal.
○ Run:
gcloud app deploy
○ Wait for deployment to complete. When done, run:
gcloud app browse
This opens the app in your default browser.
5. Repeat with other simple web applications:
○ Modify the main.py to create variations of web apps.
○ Redeploy using gcloud app deploy.
EXPERIMENT 6
Aim:
To simulate a cloud computing environment using CloudSim, set up a basic cloud scenario,
and implement a custom resource scheduling algorithm.
Procedure:
1. Download and Install CloudSim:
○ Install Java JDK (version 8 or above) on your system:
https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html
○ Download CloudSim from its official repository:
http://www.cloudbus.org/cloudsim/
○ Extract the CloudSim package.
○ Import CloudSim into an IDE like Eclipse or IntelliJ IDEA:
■ Create a new Java project.
■ Add the CloudSim JAR files to your project's build path.
2. Set Up a Basic Cloud Simulation:
○ In your Java project, create a new class (e.g., BasicCloudSimulation).
○ Define a simple scenario with:
■ One or more DataCenters
■ Multiple Hosts and VirtualMachines (VMs)
■ Several Cloudlets (representing tasks)
○ Assign cloudlets to VMs using the default scheduling algorithm.
3. Develop and Implement a Custom Scheduling Algorithm:
○ Create a new VM allocation or cloudlet scheduling policy class by extending
existing CloudSim classes (e.g., VmSchedulerTimeShared or
CloudletScheduler).
○ Define logic for how your scheduler allocates VMs or cloudlets—for example:
■ Priority-based
■ Round-robin
■ Least-loaded VM first
○ Replace the default scheduler in your simulation setup with your custom
scheduler.
4. Run the Simulation:
○ Execute the simulation and observe:
■ VM utilization
■ Cloudlet completion times
■ Resource allocation pattern
5. Analyze the Results:
○ Compare your custom scheduling algorithm's performance with the default.
○ Check logs or add print statements to view how resources were allocated.
EXPERIMENT 7
Aim:
To set up Docker, run a container, create a simple web application, build a Docker image, and
deploy the app using Docker Swarm.
Procedure:
1. Install Docker:
○ Download Docker from https://www.docker.com/get-started.
○ Follow the installation steps for your operating system.
After installation, open a terminal or command prompt and verify the installation by running:
docker --version
○
○ This will display the version of Docker installed.
2. Run Your First Docker Container:
To verify Docker is working, run the following command:
docker run hello-world
○
○ This command downloads the hello-world image from Docker Hub and runs
a container that prints a success message, confirming the Docker setup.
3. Create a Simple Node.js/Python Web App:
○ Create a basic web application in Node.js or Python that serves "Hello World!"
on a port.
Node.js Example (app.js):
const http = require('http');
const server = http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello World!\n');
});
server.listen(8080, () => {
console.log('Server running at http://localhost:8080/');
});
Python Example (app.py):
from http.server import SimpleHTTPRequestHandler
from socketserver import TCPServer
class MyHandler(SimpleHTTPRequestHandler):
def end_headers(self):
self.send_header('Content-Type', 'text/plain')
SimpleHTTPRequestHandler.end_headers(self)
with TCPServer(("", 8080), MyHandler) as httpd:
print("Server running at http://localhost:8080/")
httpd.serve_forever()
4.
5. Build a Docker Image for Your Web App:
○ Create a Dockerfile to define the Docker image.
Node.js Dockerfile:
FROM node:14
WORKDIR /app
COPY . .
RUN npm install
EXPOSE 8080
CMD ["node", "app.js"]
Python Dockerfile:
FROM python:3.8-slim
WORKDIR /app
COPY . .
RUN pip install --no-cache-dir -r requirements.txt
EXPOSE 8080
CMD ["python", "app.py"]
6.
Build the Docker image:
docker build -t my-web-app .
Run the Docker container with port mapping:
docker run -p 8080:8080 my-web-app
○
○ Visit http://localhost:8080 in your browser to see the "Hello World!"
response.
7. Deploy Your App to Docker Swarm:
Initialize Docker Swarm on your machine (if not already done):
docker swarm init
○
○ Create a docker-compose.yml file to define the service.
docker-compose.yml:
version: '3'
services:
web:
image: my-web-app
deploy:
replicas: 1
ports:
- "8080:8080"
8.
Deploy the app to Docker Swarm:
docker stack deploy -c docker-compose.yml my_stack
○
○ To verify if the app is running, visit http://localhost:8080 in your browser.
EXPERIMENT 8
Aim:
To launch a virtual machine using TryStack, the online demo version of OpenStack.
Procedure:
1. Access TryStack:
○ Go to https://trystack.org.
○ Click on the Facebook login button (TryStack requires Facebook
authentication).
○ Once logged in, you'll be redirected to the OpenStack dashboard (Horizon
interface).
2. Select a Region:
○ Choose either the "RACKSPACE" or "OVH" region (if available).
○ The dashboard will load resources available for that specific region.
3. Create a Key Pair:
○ Navigate to Project > Compute > Key Pairs.
○ Click Create Key Pair.
○ Enter a name for the key pair and click Create Key Pair.
○ Save the downloaded .pem file securely—this is needed for SSH access to the
VM.
4. Launch a New Instance:
○ Go to Project > Compute > Instances.
○ Click Launch Instance.
○ In the Details tab:
■ Name your instance (e.g., TestVM).
■ Select an availability zone if required.
○ In the Source tab:
■ Choose Image as the boot source.
■ Select a Linux-based image (e.g., Ubuntu 20.04).
○ In the Flavor tab:
■ Choose a flavor like m1.small (defines RAM, CPU, and disk size).
○ In the Networks tab:
■ Select the default network (usually private or trystack).
○ In the Key Pair tab:
■ Select the key pair you created earlier.
○ Click Launch Instance.
5. Assign a Floating IP (Public IP):
○ After the instance is running, click Associate Floating IP next to it.
○ Allocate a new floating IP and associate it with your instance.
6. Access the Virtual Machine:
Use an SSH client (like PuTTY or terminal) to access the VM:
ssh -i your-key.pem ubuntu@<Floating-IP>
○
○ Replace your-key.pem with the path to your key file and <Floating-IP> with
the public IP assigned to the VM.
EXPERIMENT 9
Aim:
To simulate a basic cloud server using AnyLogic that processes user-generated tasks, queues
incoming requests when busy, and studies the effect of varying task arrival rates on server
performance.
Procedure:
1. Launch AnyLogic and Create a New Model:
○ Open AnyLogic and create a new model.
○ Name your model (e.g., CloudServerSimulation).
○ Choose Agent-Based modeling as the base.
2. Define the Components of the Simulation:
○ Task Generator (Source):
■ Drag a Source block onto the canvas.
■ Set the arrival rate to a customizable parameter (e.g.,
interArrivalTime) to control how frequently tasks are created.
○ Queue:
■ Drag a Queue block next to the Source.
■ This represents the waiting line for tasks when the server is busy.
○ Server (Service):
■ Add a Service block after the Queue.
■ Set service time (e.g., 5 seconds) to simulate processing time per task.
■ Only one task should be processed at a time.
○ Sink:
■ Add a Sink block at the end to represent completion of tasks.
3. Connect the Flow:
○ Link blocks in order:
Source → Queue → Service → Sink
4. Add Parameters to Control Arrival Rate:
○ Create a parameter named interArrivalTime.
○ Assign different values (e.g., 2s, 1s, 0.5s) for testing varying task rates.
5. Add Data Collection (Optional):
○ Use TimePlot to visualize the queue length over time.
○ Add a plot that tracks queue.size().
6. Run Simulation:
○ Click Run and observe:
■ Queue length growth when arrival rate exceeds processing capacity.
■ Steady flow when arrival rate matches service time.
7. Experiment with Different Arrival Rates:
○ Run multiple simulations, changing interArrivalTime (e.g., 2s, 1s, 0.5s).
○ Note the impact on:
■ Queue size
■ Server utilization
■ Task waiting time