0% found this document useful (0 votes)
19 views16 pages

3,4,5,6 Clouddcomputing

The document describes steps to simulate a cloud scenario using CloudSim. It involves creating a datacenter, broker, virtual machines, cloudlets and scheduling algorithms. The simulation is started, executed and the results are printed.

Uploaded by

thabeswar2003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views16 pages

3,4,5,6 Clouddcomputing

The document describes steps to simulate a cloud scenario using CloudSim. It involves creating a datacenter, broker, virtual machines, cloudlets and scheduling algorithms. The simulation is started, executed and the results are printed.

Uploaded by

thabeswar2003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Ex.

No:3
Install Google App Engine. Create hello world app and other
Date: simple web applications using python/java

Aim:
To install Google App Engine. Create hello world app and other simple web
applications using python/java.
Procedure:
Steps for installing:
1. Download the Google Cloud SDK installer using the link
https://dl.google.com/dl/cloudsdk/channels/rapid/GoogleCloudSDKInstaller.exe
2. After downloading the Google Cloud SDK installer, Install it normally.

3. After installation has completed, the installer presents several options:


Make sure that the following are selected:
• Start Google Cloud SDKShell
• Run'gcloudinit' to configure the Google Cloud CLI
4. Click on Finish button. The installer then starts a terminal window and runs the
gcloud init command. Type y and press enter.
5. You might need to login to access the Google Cloud CLI. Login with your mail id.

6. After successful login, Give permission by clicking the Allow button.


7. A popup window will open after giving permissions. It will show that “You are
now authenticated with the gcloud CLI!

Steps to run hello world app:


1. Create a python file with the below code, and save it as index.py.
print ("Hello World!!!")
2. Create a YAML file with the below code, and save it as app.yaml.
runtime: python27
api_version: 1
threadsafe: false

handlers:
- url: /*
script: index.py

3. Search for Google Cloud SDK Shell and run as administrator.


3. Now run the below code in it.
google-cloud-sdk\bin\dev_appserver.py "C:\Users\asus\Desktop\CC_lab\ex3"
Make change the file path, where the files are saved in your PC.

4. A popup window will open, to install needed components. Type y and press
enter.
5. Now, open any browser and enter the url http://localhost:8080/ . Then the hello
world app starts work.
Output:

Result:
Thus the Google App Engine is installed and hello world app is created in python
environment and output is verified.
Ex.No:4
Use GAE launcher to launch the web applications
Date:

Aim:
To launch a web application using Google App Engine(GAE).
Procedure:
1. Create a web application. The web application should contain a python file,
HTML files, CSS files(if needed) and a YAML file.

2. Search for Google Cloud SDK Shell and run as administrator.


3. Now run the below code in it.
google-cloud-sdk\bin\dev_appserver.py "C:\Users\asus\Desktop\CC_lab\ex4"
Make change the file path, where the files are saved in your PC.

4. Now, open any browser and enter the url http://localhost:8080/ . Then the hello
world app starts work.

Output:
Result:
Thus the web application is launched successfully using Google App Engine and
the output is verified.
Ex.No:5
Simulate a cloud scenario using CloudSim and run a scheduling
Date: algorithm that is not present in CloudSim.

Aim:
To Simulate a cloud scenario using CloudSim and run a scheduling algorithm that
is not present in CloudSim

Procedure:

To use CloudSim in Eclipse:

1. Before you start, It is essential that the cloudsim should already


installed/setup on your local computer machine. In case you are yet to install it,
you may follow the process of Cloudsim setup using Eclipse IDE

2. The main() method is the pointer from where the execution of this example
starts

public static void main(String[] args)

3. There are eleven steps that are followed in each example with some
variation in them, specified as follows:

• Step1: Set the Number of users for the current simulation. This user count is
directly proportional to a number of brokers in the current simulation.

int num_user = 1; // number of cloud users


Calendar calendar = Calendar.getInstance();
boolean trace_flag = false;

• Step 2: Initialize the simulation, provided with the current time, number of
users and trace flag.

CloudSim.init(num_user, calendar, trace_flag);

• Step 3: Create a Datacenter.

Datacenter datacenter0 = createDatacenter("Datacenter_0");

where the createDatacenter() method itself initializes the various


datacenter characteristics along with the host list. This is the most important entity
without this there is no way the simulation of hosting the virtual machine is applicable.
private static Datacenter createDatacenter(String name) {
List<Host> hostList = new ArrayList<Host>();
List<Pe> peList = new ArrayList<Pe>();
int mips = 1000;
peList.add(new Pe(0, new PeProvisionerSimple(mips)));
int hostId = 0;
int ram = 2048; // host memory (MB)
long storage = 1000000; // host storage
int bw = 10000;
hostList.add(new Host(
hostId,
new RamProvisionerSimple(ram),
new BwProvisionerSimple(bw),
storage,
peList,
new VmSchedulerTimeShared(peList)
));
String arch = "x86";
String os = "Linux";
String vmm = "Xen";
double time_zone = 10.0;
double cost = 3.0;
double costPerMem = 0.05;
double costPerStorage = 0.001;
double costPerBw = 0.0;
LinkedList<Storage> storageList = new LinkedList<Storage>();
DatacenterCharacteristics characteristics = new
DatacenterCharacteristics(
arch, os, vmm, hostList,
time_zone, cost, costPerMem,
costPerStorage, costPerBw
);
Datacenter datacenter = null;
try {
datacenter = new Datacenter(name, characteristics, new
VmAllocationPolicySimple(hostList),
storageList, 0);
} catch (Exception e) {
e.printStackTrace();
}
return datacenter;
}

• Step 4: Create a Datacenter broker.

DatacenterBroker broker = createBroker();


int brokerId = broker.getId();
Where the createBroker() method initializes the entity object from
DatacenterBroker class

private static DatacenterBroker createBroker() {


DatacenterBroker broker = null;
try {
broker = new DatacenterBroker("Broker");
} catch (Exception e) {
e.printStackTrace();
return null;
}
return broker;
}

• Step 5: Create a Virtual Machine(s).

vmlist = new ArrayList<Vm>();


int vmid = 0;
int mips = 1000;
long size = 10000;
int ram = 512;
long bw = 1000;
int pesNumber = 1;
String vmm = "Xen";
Vm vm = new Vm(vmid, brokerId, mips, pesNumber, ram, bw, size,
vmm, new CloudletSchedulerTimeShared());
vmlist.add(vm);

• Step 6: Submit Virtual Machine to Datacenter broker.

broker.submitVmList(vmlist);

• Step 7: Create Cloudlet(s) by specifying their characteristics.

cloudletList = new ArrayList<Cloudlet>();


int id = 0;
long length = 400000;
long fileSize = 300;

long outputSize = 300;


UtilizationModel utilizationModel = new UtilizationModelFull();
Cloudlet cloudlet = new Cloudlet(id, length, pesNumber, fileSize,
outputSize, utilizationModel, utilizationModel,
utilizationModel);
cloudlet.setUserId(brokerId);
cloudlet.setVmId(vmid);
cloudletList.add(cloudlet);

• Step 8: Submit Cloudlets to Datacenter broker.

broker.submitCloudletList(cloudletList);

• Step 9: Send call to Start Simulation.

CloudSim.startSimulation();

• Step 10: Once no more event to execute, send the call to Stop Simulation.

CloudSim.stopSimulation();

• Step 11 : Finally, print the final status of the Simulation.

List<Cloudlet> newList = broker.getCloudletReceivedList();


printCloudletList(newList)

Where printCloudletList() method formats the output to correctly display it on the


console.

private static void printCloudletList(List<Cloudlet> list) {


int size = list.size();
Cloudlet cloudlet;
String indent = " ";
Log.printLine();
Log.printLine("========== OUTPUT ==========");
Log.printLine("Cloudlet ID" + indent + "STATUS" + indent
+ "Data center ID" + indent + "VM ID" +
indent + "Time" + indent
+ "Start Time" + indent + "Finish Time");
DecimalFormat dft = new DecimalFormat("###.##");
for (int i = 0; i < size; i++) {
cloudlet = list.get(i);
Log.print(indent + cloudlet.getCloudletId() + indent + indent);
if (cloudlet.getCloudletStatus() == Cloudlet.SUCCESS) {
Log.print("SUCCESS");
Log.printLine(indent + indent +
cloudlet.getResourceId()
+ indent + indent + indent +
cloudlet.getVmId()
+ indent + indent +
dft.format(cloudlet.getActualCPUTime())
+ indent + indent +
dft.format(cloudlet.getExecStartTime())
+ indent + indent +
dft.format(cloudlet.getFinishTime()));
}
}
}

Output :

Result :

Thus ,the Simulation of a cloud scenario using CloudSim and run a scheduling
algorithm that is not present in CloudSim is executed successfully.
Ex.No:6
Find a procedure to transfer the files from one virtual machine to
Date: another virtual machine.

Aim:
To Find a procedure to transfer the files from one virtual machine
to another virtual machine.

Procedure:

Step 1: Open Opennebula service from root user and view in localhost:9869
root@linux:$ /etc/init.d/opennebula-sunstone restart

Step 2: Create oneimage, onetemplate and onevm as like earlier


Creating oneimage
oneadmin@linux:~/datastores$ oneimage create --name "Ubuntu" –path
"/home/linux/Downloads/source/tubuntu1404-5.0.1.qcow2c" --driver qcow2 –
datastore default

Creating One Template:


oneadmin@linux:~/datastores$ onetemplate create --name "ubuntu1" --cpu 1 --vcpu
1 -- memory 1024 --arch x86_64 --disk "Ubuntu" --nic "private" --vnc –ssh

Instantiating OneVm (oneemplate)


oneadmin@linux:~/datastores$ onetemplate instantiate "ubuntu1"

Step 3: To perform a migration. We use onevm command with VM id as VID = 0


to host02(HID=1)

oneadmin@linux:~/datastores$ onevm migrate --live 0 1

This will move the VM from host01 to host02.The onevm list shows something like the
following

oneadmin@linux:~/datastores$ onevm list


ID USER GROUP NAME STAT CPU MEM HOSTNAME TIME
0 oneadmin oneadmin one-0 runn 0 0k host02 00:00:48

Result :
Thus the virtual machine transfer the files from one virtual machine to another
virtual machine from one node to the other has executed successfully.

You might also like