Class: Admiral::Core
- Inherits:
-
Thor
- Object
- Thor
- Admiral::Core
- Defined in:
- lib/admiral/core.rb
Instance Method Summary collapse
- #apply_layer(platform_name, layer_uid) ⇒ Object
- #config_help ⇒ Object
- #create(platform_name) ⇒ Object
- #destroy(platform_name) ⇒ Object
-
#initialize(*args) ⇒ Core
constructor
A new instance of Core.
- #layer_info(layer_uid) ⇒ Object
- #list ⇒ Object
- #login(platform_name) ⇒ Object
- #test(platform_name) ⇒ Object
Constructor Details
Instance Method Details
#apply_layer(platform_name, layer_uid) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/admiral/core.rb', line 34 def apply_layer(platform_name, layer_uid) Admiral::Docker::verify((@config[platform_name])) if @config.platform?(platform_name) container_id = Admiral::Docker::get_container_id(platform_name) docker = @config[platform_name]['docker'] if container_id ip_address = Admiral::Docker::get_ip_address(docker, container_id) if ip_address success = Admiral::Docker::apply_layer(@config[platform_name], layer_uid, ip_address) if not success STDERR.puts "failed to run the layer" exit! end else STDERR.puts "Failed to get IP address" exit! end else STDERR.puts "Failed to get container ID" exit! end else STDERR.puts "Platform #{platform_name} don't exist" exit! end end |
#config_help ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/admiral/core.rb', line 116 def config_help() puts <<-EOF The configuration is located in .admiral.yml files. The global configuration is in ~/ and the local configuration is in any other directory. common: # Configuration for all plaforms, in global or local configuration docker: unix:///var/run/docker.sock # Docker socket registry: 127.0.0.1:5000 # Docker registry username: admiral # Username for Admiral user in the container password: admiral # Password for Admiral keyfile: docker_id_rsa # Private Key for Admiral connection in the container pubkeyfile: docker_id_rsa.pub # Associated public Key volumes: # Optional, list of volumes to export in the container - guest: /path/in/the/guest # Path of the volume in the container host: /path/in/the/host # Optional, path of the real directory layers: # Layers for the configuration - admiral.svn.puppet.manifest - admiral.svn.puppet.cookbook - admiral.puppet.apply tests: # Layers for the tests - admiral.test.chef.install - admiral.test.serverspec.install - admiral.test.serverspec.upload - admiral.test.serverspec.run platforms: # List of platforms' configuration, only in local configuration - name: my-server image: ubuntu16 # Docker image hostname: web.domain.lan lsp: false # A layer parameter ... EOF end |
#create(platform_name) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/admiral/core.rb', line 22 def create(platform_name) if @config.platform?(platform_name) Admiral::Docker::verify((@config[platform_name])) Admiral::Docker::create(@config[platform_name]) else STDERR.puts "Platform #{platform_name} don't exist" exit! end end |
#destroy(platform_name) ⇒ Object
86 87 88 89 90 91 92 93 |
# File 'lib/admiral/core.rb', line 86 def destroy(platform_name) if @config.platform?(platform_name) Admiral::Docker::destroy(@config[platform_name]) else STDERR.puts "Platform #{platform_name} don't exist" exit! end end |
#layer_info(layer_uid) ⇒ Object
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/admiral/core.rb', line 96 def layer_info(layer_uid) begin require "admiral/layers/#{layer_uid}.rb" rescue LoadError STDERR.puts "Layer #{layer_uid} not found" return false end begin kclass = ::Admiral::Layers.const_get(Admiral::Layer.uid_to_name(layer_uid)) rescue NameError STDERR.puts "Layer #{layer_uid} has a mistake" return false end layer = kclass.new(nil, nil) layer.show_information end |
#list ⇒ Object
14 15 16 17 18 19 |
# File 'lib/admiral/core.rb', line 14 def list() platforms = @config.platforms platforms.keys.each do | platform | puts "#{platform}" end end |
#login(platform_name) ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/admiral/core.rb', line 63 def login(platform_name) Admiral::Docker::create(@config[platform_name]) if @config.platform?(platform_name) Admiral::Docker::login(@config[platform_name]) else STDERR.puts "Platform #{platform_name} don't exist" exit! end end |
#test(platform_name) ⇒ Object
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/admiral/core.rb', line 74 def test(platform_name) if @config.platform?(platform_name) Admiral::Docker::create(@config[platform_name]) Admiral::Docker::test(@config[platform_name]) Admiral::Docker::destroy(@config[platform_name]) else STDERR.puts "Platform #{platform_name} don't exist" exit! end end |