GithubHelp home page GithubHelp logo

isabella232 / cloud-manager Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vmware-serengeti/cloud-manager

0.0 0.0 0.0 1.12 MB

VM cluster manger on vSphere provider

License: Apache License 2.0

Ruby 91.04% Perl 8.96%

cloud-manager's Introduction

cloud-manager

cloud-manager is a Ruby cloud manager library, top to bottom:

  • It is a simple Rubust Reliable and Extendable IaaS to manage cluster and VMs in cloud.

  • It manages clusters on vSphere to create/start/stop/delete/resize hadoop clusters, at present.

  • It provide a pluggable framework to use your own placement algorithm

  • It will provide fetching resources/cluster placement/cluster deploy services.

  • It supports vSphere Cloud, now. And it will support EC2 in the future.

Version Description

version = 0.6.0

How hadoop cluster are layout

It uses GROUP to collect same functional VMs to one unit, such as master, worker, client, and etc. Therefore, in one GROUP, each VM has same configuration. So it places massive VMs in a simple way. It also present the concept of virtual group (VG). VG is a set of VMs, which should be placed in one host. All kinds of GROUP, can place their VM in one Virtual Group. VG can handle the relationship between different GROUPs.

Getting Started

Install

Currently, It depend on fog-1.3.1.serengeti.gem, you should install it firstly.
sudo gem install cloud-manager-0.6.0.gem --local --no-ri --no-rdoc

cloud provider definition

It uses json string to describe cloud provider.

cloud_provider: {

"name": "vsphere",      # Provider name
"vc_addr": "FQDN/IP",   # vSphere address
"vc_user": "administrator", #vSphere user name
"vc_pwd": "123456",         #vSphere password
"vc_datacenter": "DatacenterName",  #Accessed datacenter name

"vc_clusters": [ #define the cluster:resource pool pair
{ "name": "Cluster1",
  "vc_rps": ["resource_pool1", "resource_pool2", "rp3"] },
{ "name": "Cluster2",
  "vc_rps": ["rp-hadoop"] },
],
"vc_shared_datastore_pattern": ["share", "san*"], #define the datastore_pattern for share storage
"vc_local_datastore_pattern": ["local*", "vmfs*"], #define the datastore_pattern for local storage

cloud-manager configuration

It has a config class to config cloud-manager’s configuration. You could write config field in the file that define cloud_provider info.

config:

client_connection: ['./lib/plugin/client_fog', 'FogAdapter'] #Load FogAdapter as a cloud client.
placement_plugin:  ['plugin/MyPlacement', 'MyPlacement'] #You could select your own placement engine

cluster definition

It uses json string to describe cluster definition

cluster_definition: {

"name": "hadoop_cluster_test",
  "template_id": "vm_template_mob_in_vc", #such like this: 'vm-1234', it is the template vm's mo_id in vSphere
  "deploy_policy":"group_parallel", #default is ‘group_parallel’, can choose 'group_order'
  "vc_clusters":    #Cluster can rewrite the cluster/resource pool requirement
  [  {
    "name": "Cluster1",
    "vc_rps": ["resource_pool1", "resource_pool2"]
    }
  ],

  "networking": [{ #Cluster should define networking configuration
    "port_group": "CFNetwork",
    "type" : "static", # or "dhcp",
    "ip": ["10.1.1.10-10.1.1.11", "10.1.1.17"], # User can input ip ranges
    "netmask": "255.255.255.0",
    "gateway": "10.1.1.254",
    "dns": ["10.1.100.100", "10.1.100.240"]
  }],

  #Cluster can add a filter to select more the datastore pattern like this
  "vc_shared_datastore_pattern": ["share", "san*"],    # Using wildcard to select more 
  "vc_local_datastore_pattern": ["local*", "vmfs?-*"], # datastores, both '*' and '?'

  "groups": [ #Cluster define groups in below:
  {
    "name": "master",   # Group name
    "instance_num": 1,  # Wanted instance number in this group
    "cpu": 2,           # CPU core number
    "memory": 2048,     # Memory size: 2048M
    "storage": {
      "type": 'shared',
      "name_pattern": ["share"], # This pattern will overwrite the cluster's datastore pattern
      "size": 10        # Disk size: 10G
    }
    "ha": 'on'          # ha flag can be set to 'off','on','ft'. Default is 'off'
  },

  { #Another group for 'worker'
    "name": "worker",
    "instance_num": 3,
    "cpu": 1,
    "memory": 1024,

    "vc_clusters": { #group can redefine the cluster:resource pool pair
      "name": "Cluster1",
      "vc_rps": ["resource_pool2"]
    }
    "storage": {
      "type": 'local',
      "name_pattern": ["local", "vmfs*"],
      "size": 50
    }
    "ha": 'off'
  },
]

}

Placement Output

Placement module will output cluster’s VMs placement result in two dimensional Array: placement = [ {‘act’=>‘act function name’, ‘group’ => [[Group1 VM placement], [Group2 VM placement], … [GroupN VM placement]] },

  {'act'=> ... },
]

placement show the number of failed placement show the error messages, during placement. If placement is failed, we could read info from placement tell us it will be rollback to which point. by default is nil

this field to know what has happen.

How to setup UT?

It uses rspec to do UT test. Change path to root of cloud-manager. place configuration file func.vc.yaml and ut.vc.yaml in current dir func.vc.yaml describes vSphere cloud provider definition. ut.vc.yaml describes UT cloud provider definition.

unit test: spec/assets/unit/ut.dc.yaml #define a simulated vSphere datacenter, needed by fog_dummy spec/assets/unit/ut.vc.yaml #define a simle vc configuration for testing spec/assets/unit/ut.cluster_def*.yaml #define UT test cases > spec spec/cloud_unit_test.rb

func test: spec/func/func.vc.yaml #func test vSphere configuration, include user name/password/ip address, etc. spec/func/func.cluster_def.yaml #define func test cases > spec spec/cloud_func_test.rb

note: You had better prepare your cloud provider info firstly. You could place you own func.vc.yaml’s full-path to env variable FUNC_CLOUD_PROVIDER_FILE, and ut.yaml’s full-path to env variable UT_CLOUD_PROVIDER_FILE for example:

export FUNC_CLOUD_PROVIDER_FILE=‘/home/serengeti/cloud-manager/your-func.vc.yaml’

example

Here is an example of wading through server creation/start/stop/delete for vSphere Cloud: require ‘cloud-manager’

# create a cluster

IaasTask task = Serengeti::CloudManager::Manager.create_cluster(parameter, :wait => false)
      # parameter["cluster_definition"] is a Hash object which contains the definition of this cluster
      # parameter["cloud_provider"] is a Hash object, which contains how to login the cloud server and the resource requirement.
      # parameter["targets"] is a target array. It points out which nodes or group should be handled.
      # options[:wait] can make object running in synchronous(wait = true) or asynchronous(wait = false) model

# if caller doesn’t care the progress, call this method to wait until this task is finished.

IaasResult result = task.wait_for_completion()

# if caller cares the progress, call this method

while !task.finished?
  IaasProgress prog = task.get_progress()
  # you could print out progess info here
end

# if caller want to know the result of the task, call:

IaasResult result = task.get_result()
if result.succeed?
  handle result ... ...
  else
    handle failure ... ...
    end

# start the cluster

IaasTask task = Serengeti::CloudManager::Manager.start_cluster(parameter, :options => { :wait => true })

# stop the cluster

IaasTask task = Serengeti::CloudManager::Manager.stop_cluster(parameter, :options => { :wait => true })

# delete the cluster

IaasTask task = Serengeti::CloudManager::Manager.delete_cluster(parameter, :options => { :wait => true })

How to write your own placement algorithm

The placement algorithm can be loaded by placement service. You can add item in your config file 
placement_engine: [{'require' => 'plugin/myplacement', 'obj' => 'MyPlacement'}]
And the placement service will load plugin/myplacement.rb in runtime, and new MyPlacement object as its placement engine
The placement engine should implement those interface

pre_placement_cluster(vm_groups, existed_vms)
get_virtual_groups(vm_groups)
get_virtual_nodes(virtual_group, existed_vms, placed_vms)
select_host(vms, scores)
assign_host(vms, host)

You could read the plugin/placement_rr.rb to see, how to write a simple placement algorithm module
In cloud_manager/placement_imp.rb, you can see a more complicated placement algorithm module.

How to write your own resource plugin

You could write your own resource plugin for your special use,

You could read the plugin/resource_*.rb files to know how to write it. We implement some useful resource plugins, such as
resource pool, compute, networking, HA and FT. Each resource service should be derived from CMService

Contributing to cloud-manager

  • Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet.

  • Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it.

  • Fork the project.

  • Start a feature/bugfix branch.

  • Commit and push until you are happy with your contribution.

  • Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright © 2012 vmware.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

cloud-manager's People

Contributors

haiyuwang avatar jessehu avatar junxiaotime avatar qhli avatar wjun avatar xiaodingbian avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.