-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
778 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
active_cluster: default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# ============================================================================= | ||
# Copyright (C) 2019-present Alces Flight Ltd. | ||
# | ||
# This file is part of Flight Inventory. | ||
# | ||
# This program and the accompanying materials are made available under | ||
# the terms of the Eclipse Public License 2.0 which is available at | ||
# <https://www.eclipse.org/legal/epl-2.0>, or alternative license | ||
# terms made available by Alces Flight Ltd - please direct inquiries | ||
# about licensing to [email protected]. | ||
# | ||
# Flight Inventory is distributed in the hope that it will be useful, but | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR | ||
# IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS | ||
# OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A | ||
# PARTICULAR PURPOSE. See the Eclipse Public License 2.0 for more | ||
# details. | ||
# | ||
# You should have received a copy of the Eclipse Public License 2.0 | ||
# along with Flight Inventory. If not, see: | ||
# | ||
# https://opensource.org/licenses/EPL-2.0 | ||
# | ||
# For more information on Flight Inventory, please visit: | ||
# https://github.com/openflighthpc/flight-inventory | ||
# ============================================================================== | ||
|
||
require 'inventoryware/config' | ||
|
||
require 'fileutils' | ||
|
||
module Inventoryware | ||
module Commands | ||
module Cluster | ||
class Delete < Command | ||
def run | ||
cluster = @argv.first | ||
|
||
prompt = TTY::Prompt.new | ||
unless prompt.no?("Are you sure you want to delete '#{cluster}'?") | ||
unless cluster == Config.active_cluster | ||
puts "Cluster '#{cluster}' has been deleted" if delete_cluster(cluster) | ||
else | ||
puts "Can't delete the current cluster, please switch cluster first" | ||
end | ||
end | ||
end | ||
|
||
private | ||
|
||
def delete_cluster(cluster) | ||
cluster_path = File.join(Config.root_dir, 'var/store', cluster) | ||
FileUtils.rm_rf(cluster_path, secure: true) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# ============================================================================= | ||
# Copyright (C) 2019-present Alces Flight Ltd. | ||
# | ||
# This file is part of Flight Inventory. | ||
# | ||
# This program and the accompanying materials are made available under | ||
# the terms of the Eclipse Public License 2.0 which is available at | ||
# <https://www.eclipse.org/legal/epl-2.0>, or alternative license | ||
# terms made available by Alces Flight Ltd - please direct inquiries | ||
# about licensing to [email protected]. | ||
# | ||
# Flight Inventory is distributed in the hope that it will be useful, but | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR | ||
# IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS | ||
# OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A | ||
# PARTICULAR PURPOSE. See the Eclipse Public License 2.0 for more | ||
# details. | ||
# | ||
# You should have received a copy of the Eclipse Public License 2.0 | ||
# along with Flight Inventory. If not, see: | ||
# | ||
# https://opensource.org/licenses/EPL-2.0 | ||
# | ||
# For more information on Flight Inventory, please visit: | ||
# https://github.com/openflighthpc/flight-inventory | ||
# ============================================================================== | ||
|
||
require 'inventoryware/config' | ||
require 'inventoryware/utils' | ||
|
||
require 'fileutils' | ||
|
||
module Inventoryware | ||
module Commands | ||
module Cluster | ||
class Init < Command | ||
def run | ||
cluster_config_path = Config.cluster_config_path | ||
cluster_config = Utils.load_yaml(cluster_config_path) | ||
cluster = @argv.first | ||
|
||
if create_cluster_directory | ||
cluster_config['active_cluster'] = cluster | ||
Utils.save_yaml(cluster_config_path, cluster_config) | ||
|
||
puts "The '#{cluster}' cluster has been successfully initialised and"\ | ||
" is now the active cluster" | ||
end | ||
end | ||
|
||
private | ||
|
||
def create_cluster_directory | ||
FileUtils.mkdir(File.join(Config.root_dir, 'var/store', @argv)) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# ============================================================================= | ||
# Copyright (C) 2019-present Alces Flight Ltd. | ||
# | ||
# This file is part of Flight Inventory. | ||
# | ||
# This program and the accompanying materials are made available under | ||
# the terms of the Eclipse Public License 2.0 which is available at | ||
# <https://www.eclipse.org/legal/epl-2.0>, or alternative license | ||
# terms made available by Alces Flight Ltd - please direct inquiries | ||
# about licensing to [email protected]. | ||
# | ||
# Flight Inventory is distributed in the hope that it will be useful, but | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR | ||
# IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS | ||
# OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A | ||
# PARTICULAR PURPOSE. See the Eclipse Public License 2.0 for more | ||
# details. | ||
# | ||
# You should have received a copy of the Eclipse Public License 2.0 | ||
# along with Flight Inventory. If not, see: | ||
# | ||
# https://opensource.org/licenses/EPL-2.0 | ||
# | ||
# For more information on Flight Inventory, please visit: | ||
# https://github.com/openflighthpc/flight-inventory | ||
# ============================================================================== | ||
|
||
require 'inventoryware/config' | ||
|
||
module Inventoryware | ||
module Commands | ||
module Cluster | ||
class List < Command | ||
def run | ||
clusters = get_list_of_clusters | ||
|
||
clusters.each do |cluster| | ||
if cluster.start_with?('*') | ||
puts cluster | ||
else | ||
puts " #{cluster}" | ||
end | ||
end | ||
end | ||
|
||
private | ||
|
||
def get_list_of_clusters | ||
Dir.glob(File.join(Config.root_dir, 'var/store/*')).select { |e| | ||
File.directory? e | ||
}.map { |dir| | ||
File.basename(dir) | ||
}.map { |cluster| | ||
if cluster == Config.active_cluster | ||
"* #{cluster}" | ||
else | ||
cluster | ||
end | ||
}.sort | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.