Skip to content

Commit

Permalink
Sprint 1 (#139)
Browse files Browse the repository at this point in the history
Contains all features implemented during Sprint 1:
- Vm/Server Overview + Details Page
-
  • Loading branch information
marcfreiheit authored and MkuuWaUjinga committed Dec 7, 2018
1 parent 3c2f340 commit 9cdf077
Show file tree
Hide file tree
Showing 88 changed files with 2,356 additions and 99 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/user-story.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ about: This template should be used for all user stories

**Akzeptanzkriterien**

**Priorität:**
**Priorität**

**Aufwandsschätzung**
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

# Ignore bundler config.
/.bundle
.vagrant/

# Ignore the default SQLite database.
/db/*.sqlite3
Expand Down Expand Up @@ -35,3 +36,5 @@

# Ignore coverage directory
coverage

.DS_Store
11 changes: 11 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
inherit_from: .rubocop_todo.yml
require: rubocop-rspec

Metrics/BlockLength:
Exclude:
- 'Rakefile'
- '**/*.rake'
- 'spec/**/*.rb'

Documentation:
Enabled: false

EnforcedStyle: expanded
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ before_script:
# https://docs.travis-ci.com/user/job-lifecycle#customizing-the-build-phase
script:
- bundle exec rspec spec/
after_success:
# https://docs.travis-ci.com/user/environment-variables/#default-environment-variables
- curl --data "commit=$TRAVIS_COMMIT" --data "branch=$TRAVIS_BRANCH" --data "eventtype=$TRAVIS_EVENT_TYPE" http://hart-deploy.epic-hpi.de/
12 changes: 8 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
gem 'mini_racer', platforms: :ruby
# See https://github.com/bokmann/font-awesome-rails for details
gem 'font-awesome-rails'

# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
Expand Down Expand Up @@ -50,19 +52,19 @@ gem 'jquery-rails'
# https://github.com/vmware/rbvmomi
gem 'rbvmomi'

# Mina for deployment
# Mina for deployment
# Have a look in the tutorial:
# https://github.com/lnikell/wiki/wiki/Deploy-rails-application-with-Mina,-Nginx-and-Puma
gem 'mina', require: false
gem 'mina-puma', require: false, github: 'untitledkingdom/mina-puma'
gem 'mina-puma', require: false, github: 'untitledkingdom/mina-puma'
# Adds support for multiple stages, https://github.com/endoze/mina-multistage
gem 'mina-multistage', require: false
# Tail production logs, https://github.com/windy/mina-logs
# $ mina logs # tail -f log/production.log
gem 'mina-logs', require: false
# Announce Mina deploys to Slack channels, https://github.com/krichly/mina-slack
gem 'mina-slack', require: false, github: 'krichly/mina-slack'
gem 'execjs', require: false
gem 'mina-slack', require: false, github: 'krichly/mina-slack'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.1.0', require: false
Expand Down Expand Up @@ -93,6 +95,8 @@ group :development do
# Much nicer error pages https://github.com/BetterErrors/better_errors
gem 'better_errors'
gem 'binding_of_caller'
# Continous execution of unit tests
gem 'guard'
end

group :test do
Expand All @@ -110,7 +114,7 @@ group :test do
end

group :production do
gem 'pg' # production database runs on postgres
gem 'pg' # production database runs on postgres
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
Expand Down
23 changes: 23 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,20 @@ GEM
factory_bot (~> 4.11.1)
railties (>= 3.0.0)
ffi (1.9.25)
font-awesome-rails (4.7.0.4)
railties (>= 3.2, < 6.0)
formatador (0.2.5)
globalid (0.4.1)
activesupport (>= 4.2.0)
guard (2.15.0)
formatador (>= 0.2.4)
listen (>= 2.7, < 4.0)
lumberjack (>= 1.0.12, < 2.0)
nenv (~> 0.1)
notiffany (~> 0.0)
pry (>= 0.9.12)
shellany (~> 0.0)
thor (>= 0.18.1)
http-cookie (1.0.3)
domain_name (~> 0.5)
i18n (1.1.1)
Expand All @@ -167,6 +179,7 @@ GEM
loofah (2.2.3)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
lumberjack (1.0.13)
mail (2.7.1)
mini_mime (>= 0.1.1)
marcel (0.3.3)
Expand All @@ -190,11 +203,15 @@ GEM
minitest (5.11.3)
msgpack (1.2.4)
multi_json (1.13.1)
nenv (0.3.0)
net-ssh (5.0.2)
netrc (0.11.0)
nio4r (2.3.1)
nokogiri (1.8.5)
mini_portile2 (~> 2.3.0)
notiffany (0.1.1)
nenv (~> 0.1)
shellany (~> 0.0)
open4 (1.3.4)
optimist (3.0.0)
orm_adapter (0.5.0)
Expand All @@ -204,6 +221,9 @@ GEM
pg (1.1.3)
popper_js (1.14.3)
powerpack (0.1.2)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
public_suffix (3.0.3)
puma (3.12.0)
pundit (2.0.0)
Expand Down Expand Up @@ -301,6 +321,7 @@ GEM
selenium-webdriver (3.141.0)
childprocess (~> 0.5)
rubyzip (~> 1.2, >= 1.2.2)
shellany (0.0.1)
shoulda-matchers (4.0.0.rc1)
activesupport (>= 4.2.0)
simplecov (0.16.1)
Expand Down Expand Up @@ -370,6 +391,8 @@ DEPENDENCIES
execjs
factory_bot_rails
faker!
font-awesome-rails
guard
jbuilder (~> 2.5)
jquery-rails
listen (>= 3.0.5, < 3.2)
Expand Down
18 changes: 18 additions & 0 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

# A sample Guardfile
# More info at https://github.com/guard/guard#readme

## Uncomment and set this to only include directories you want to watch
# directories %w(app lib config test spec features) \
# .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}

## Note: if you are using the `directories` clause above and you are not
## watching the project directory ('.'), then you will want to move
## the Guardfile to a watched dir and symlink it back, e.g.
#
# $ mkdir config
# $ mv Guardfile config/
# $ ln -s config/Guardfile .
#
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
20 changes: 11 additions & 9 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
# frozen_string_literal: true

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
Vagrant.configure('2') do |config|
# VM with Ruby 2.5.0 based on Ubuntu 14.04.5 LTS (Trusty Tahr)
config.vm.box = "swt2/trusty-ruby25"
config.vm.box_url = "https://github.com/hpi-swt2/swt2-vagrant/releases/download/v0.4/swt2-ruby25.box"
config.vm.box = 'swt2/trusty-ruby25'
config.vm.box_url = 'https://github.com/hpi-swt2/swt2-vagrant/releases/download/v0.4/swt2-ruby25.box'

# Try the following optimizations for performance.
# Disable if problems occur or fall back to the 32bit VM
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "2048"]
vb.customize ["modifyvm", :id, "--cpus", 2]
vb.customize ["modifyvm", :id, "--ioapic", "on"]
vb.customize ["modifyvm", :id, "--hwvirtex", "on"]
vb.customize ['modifyvm', :id, '--memory', '2048']
vb.customize ['modifyvm', :id, '--cpus', 2]
vb.customize ['modifyvm', :id, '--ioapic', 'on']
vb.customize ['modifyvm', :id, '--hwvirtex', 'on']
end

# port forward
config.vm.network :forwarded_port, host: 3000, guest: 3000
config.vm.synced_folder ".", "/home/vagrant/hpi-swt2"
end
config.vm.synced_folder '.', '/home/vagrant/hpi-swt2'
end
57 changes: 52 additions & 5 deletions app/api/vmapi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,53 @@ def all_vms
end
end

def all_clusters
connect
@clusters.map do |cluster|
{ name: cluster.name, stats: cluster.stats, cores: cluster.summary[:numCpuCores], threads: cluster.summary[:numCpuThreads] }
end
end

def all_hosts
connect
@hosts = Array.new([])
@clusters.map do |cluster|
cluster.host.map do |host|
vm_names = Array.new([])
host.vm.map do |vm|
vm_names << vm.name
end
@hosts << { name: host.name,
vm_names: vm_names,
model: host.hardware.systemInfo.model,
vendor: host.hardware.systemInfo.vendor,
bootTime: host.runtime.bootTime,
connectionState: host.runtime.connectionState,
summary: host.summary }
end
end
@hosts
end

def get_vm(name)
connect
if (vm = find_vm(name))
{ name: vm.name,
boot_time: vm.runtime.bootTime,
host: vm.summary.runtime.host.name,
guestHeartbeatStatus: vm.guestHeartbeatStatus,
summary: vm.summary }
end
end

def get_host(name)
all_hosts
@hosts.each do |host|
return host if host[:name] == name
end
nil
end

def delete_vm(name)
connect
vm = find_vm(name)
Expand Down Expand Up @@ -103,17 +150,17 @@ def connect
@vim = RbVmomi::VIM.connect(host: API_SERVER_IP, user: API_SERVER_USER, password: API_SERVER_PASSWORD, insecure: true)
@dc = @vim.serviceInstance.find_datacenter('Datacenter') || raise('datacenter not found')
@vm_folder = @dc.vmFolder
@host_folder = @dc.hostFolder
@hosts = extract_hosts(@host_folder).flatten
@cluster_folder = @dc.hostFolder
@clusters = extract_clusters(@cluster_folder).flatten
@vms = @vm_folder.children
@resource_pool = @hosts.first.resourcePool
@resource_pool = @clusters.first.resourcePool
end

def extract_hosts(element)
def extract_clusters(element)
if element.class == RbVmomi::VIM::Folder
a = []
element.children.each do |child|
a << extract_hosts(child)
a << extract_clusters(child)
end
a
else
Expand Down
3 changes: 3 additions & 0 deletions app/assets/javascripts/landing.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
3 changes: 3 additions & 0 deletions app/assets/javascripts/requests.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
7 changes: 5 additions & 2 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
* files in this directory. Styles in this file should be added after the last require_* statement.
* It is generally better to create a new file per style scope.
*/
@import "bootstrap";
*= require font-awesome
*= require_self
*= require_tree .
*/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/landing.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the Landing controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
21 changes: 21 additions & 0 deletions app/assets/stylesheets/layout.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@import "bootstrap";

html, body {
height: 100%;
}

body {
display: flex;
flex-direction: column;
}

#content {
flex: 1 0 auto;
}

#footer {
flex-shrink: 0;
padding: 10px 0;
background-color: #343a40;
color: #ffffff;
}
3 changes: 3 additions & 0 deletions app/assets/stylesheets/requests.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the Requests controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
Loading

0 comments on commit 9cdf077

Please sign in to comment.