kanrisuru 0.14.0 → 0.16.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +27 -0
- data/README.md +5 -5
- data/kanrisuru.gemspec +7 -3
- data/lib/kanrisuru/command.rb +16 -3
- data/lib/kanrisuru/core/apt/parsers/base.rb +1 -1
- data/lib/kanrisuru/core/disk/commands/lsblk.rb +6 -11
- data/lib/kanrisuru/core/disk/constants.rb +9 -0
- data/lib/kanrisuru/core/disk/parser.rb +1 -0
- data/lib/kanrisuru/core/disk/parsers/lsblk_version.rb +21 -0
- data/lib/kanrisuru/core/disk.rb +1 -0
- data/lib/kanrisuru/core/dmi/commands/dmi.rb +1 -1
- data/lib/kanrisuru/core/file/commands/chmod.rb +1 -1
- data/lib/kanrisuru/core/file/commands/copy.rb +1 -3
- data/lib/kanrisuru/core/file/commands/mkdir.rb +11 -6
- data/lib/kanrisuru/core/file/commands/rm.rb +4 -1
- data/lib/kanrisuru/core/file/commands/touch.rb +2 -1
- data/lib/kanrisuru/core/ip/commands/address.rb +64 -47
- data/lib/kanrisuru/core/ip/commands/address_label.rb +32 -16
- data/lib/kanrisuru/core/ip/commands/link.rb +96 -54
- data/lib/kanrisuru/core/ip/commands/link_set_opts.rb +61 -0
- data/lib/kanrisuru/core/ip/commands/link_type_opts.rb +313 -0
- data/lib/kanrisuru/core/ip/commands/maddress.rb +22 -13
- data/lib/kanrisuru/core/ip/commands/neighbour.rb +49 -32
- data/lib/kanrisuru/core/ip/commands/route.rb +130 -93
- data/lib/kanrisuru/core/ip/commands/rule.rb +37 -22
- data/lib/kanrisuru/core/ip/commands.rb +5 -3
- data/lib/kanrisuru/core/ip/constants.rb +12 -0
- data/lib/kanrisuru/core/ip/parser.rb +1 -0
- data/lib/kanrisuru/core/ip/parsers/version.rb +15 -0
- data/lib/kanrisuru/core/ip.rb +10 -7
- data/lib/kanrisuru/core/system/commands/kill.rb +1 -1
- data/lib/kanrisuru/core/user/commands/create_user.rb +9 -17
- data/lib/kanrisuru/core/user/commands/delete_user.rb +1 -1
- data/lib/kanrisuru/core/user/commands/update_user.rb +14 -23
- data/lib/kanrisuru/core/zypper/commands/add_repo.rb +1 -8
- data/lib/kanrisuru/core/zypper/commands/add_service.rb +4 -2
- data/lib/kanrisuru/core/zypper/commands/info.rb +1 -2
- data/lib/kanrisuru/core/zypper/commands/install.rb +2 -3
- data/lib/kanrisuru/core/zypper/commands/modify_repo.rb +1 -7
- data/lib/kanrisuru/core/zypper/commands/modify_service.rb +3 -1
- data/lib/kanrisuru/core/zypper/commands/remove.rb +1 -2
- data/lib/kanrisuru/core/zypper/commands/remove_repo.rb +3 -3
- data/lib/kanrisuru/core/zypper/commands/remove_service.rb +6 -1
- data/lib/kanrisuru/core/zypper/commands/search.rb +1 -3
- data/lib/kanrisuru/core/zypper/commands/source_install.rb +2 -0
- data/lib/kanrisuru/core/zypper/commands.rb +10 -1
- data/lib/kanrisuru/os_package.rb +2 -0
- data/lib/kanrisuru/remote/host.rb +1 -3
- data/lib/kanrisuru/result.rb +15 -0
- data/lib/kanrisuru/version.rb +1 -1
- data/spec/functional/core/archive_spec.rb +1 -1
- data/spec/functional/core/disk_spec.rb +77 -0
- data/spec/functional/core/dmi_spec.rb +78 -0
- data/spec/functional/core/file_spec.rb +284 -0
- data/spec/functional/core/group_spec.rb +62 -0
- data/spec/functional/core/ip_address_label_spec.rb +81 -0
- data/spec/functional/core/ip_address_spec.rb +95 -0
- data/spec/functional/core/ip_link_spec.rb +814 -0
- data/spec/functional/core/ip_maddress_spec.rb +78 -0
- data/spec/functional/core/ip_neighbour_spec.rb +119 -0
- data/spec/functional/core/ip_route_spec.rb +174 -0
- data/spec/functional/core/ip_rule_spec.rb +75 -0
- data/spec/functional/core/ip_spec.rb +27 -0
- data/spec/functional/core/system_spec.rb +135 -0
- data/spec/functional/core/user_spec.rb +97 -0
- data/spec/functional/core/zypper_spec.rb +708 -0
- data/spec/functional/result_spec.rb +91 -44
- data/spec/helper/stub_network.rb +7 -3
- data/spec/support/shared_examples/integration/core/transfer.rb +1 -1
- data/spec/unit/command_spec.rb +2 -0
- data/spec/unit/core/ip_spec.rb +12 -0
- metadata +25 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6038052274021235b996bc9f7ade893cd10d6881c86e563f2b2d382abb16d60
|
4
|
+
data.tar.gz: cdec7058f5ed36cb0e1132be77c01085eed95267249f36458c6a591e02f27fbc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3ef7552d342a0b2fd0cf85fd1bbc03752d24803052feb9639c59d0244f3340edc85f038b2d3d296e0a2d85d468d45bcdde61b79cfd8d9ca8027cc217bf2f615
|
7
|
+
data.tar.gz: a6a4f401e579ff750ca46b5580b259eeb8e25998c76e98612a5123daf4ecef4fbe22fb5bf3f6a19337190afae86a0c87d5319757205e99dfcc8faa2a5de11376
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,30 @@
|
|
1
|
+
## Kanrisuru 0.16.2 (December 19, 2021) ##
|
2
|
+
* Organize functional ip specs
|
3
|
+
* Log in realtime, debug output the stdout from the remote server, as opposed to waiting until after the command is done.
|
4
|
+
* Fix the `opensuse_leap` for the stubnetwork rspec helper.
|
5
|
+
* Refactor and cleanup the `append_array` method for the `Kanrisuru::Command` instance
|
6
|
+
* Move `gpg_opts` for `zypper` command into re-usable method
|
7
|
+
* Add functional test cases for `zypper` command.
|
8
|
+
|
9
|
+
## Kanrisuru 0.16.1 (December 16, 2021) ##
|
10
|
+
* Fix require class for `os_package`.
|
11
|
+
|
12
|
+
## Kanrisuru 0.16.0 (December 14, 2021) ##
|
13
|
+
* Fix `append_array` for the `Kanrisuru::Command` class with negated check on Array type.
|
14
|
+
* Add `to_f` method for `Kanrisuru::Command` and `Kanrisuru::Result` with unit test cases.
|
15
|
+
* Refactor `lsblk_version` into seperate command namespace with it's own parser.
|
16
|
+
* Add functional test cases for several core modules.
|
17
|
+
* Add `return_value` option to `stub_command!` method for non-result return methods. These are few and far between, but need to be tested appropriately.
|
18
|
+
* Refactor several core modules with use of `command` calls for legibility.
|
19
|
+
* Fix several issues with `create_user`, `update_user`, and `delete_user`.
|
20
|
+
|
21
|
+
## Kanrisuru 0.15.0 (December 13, 2021) ##
|
22
|
+
* Add opts for `ip` command.
|
23
|
+
* Refactor `ip` object commands into smaller methods. Refactor `version` for consistent use and stub ability in funcitonal test cases.
|
24
|
+
* Add functional test cases for `ip` command.
|
25
|
+
* Add `append_flag_no` to `Kanrisuru::Command` class. Adds no to value for `falsey` statements. The `no` flag is commonly appended to indicate a deactived state for many arguments passed to programs on the command line.
|
26
|
+
* Fix test case `transfer` by appending the osname to the filename to avoid parallel overwrite.
|
27
|
+
|
1
28
|
## Kanrisuru 0.14.0 (December 08, 2021) ##
|
2
29
|
* Add additional unit test cases for `util` methods.
|
3
30
|
* Refactor the `core` module commands into smaller files, with each command split up. Also refactor parsing code into separate `Parser` class.
|
data/README.md
CHANGED
@@ -7,12 +7,12 @@
|
|
7
7
|
<img src="https://img.shields.io/gem/v/kanrisuru?style=flat-square" alt="Latest version" />
|
8
8
|
</a>
|
9
9
|
<a href="https://github.com/avamia/kanrisuru/blob/main/LICENSE.txt">
|
10
|
-
<img src="https://img.shields.io/github/license/avamia/kanrisuru" alt="Latest version" />
|
10
|
+
<img src="https://img.shields.io/github/license/avamia/kanrisuru?style=flat-square" alt="Latest version" />
|
11
11
|
</a>
|
12
|
-
<img src="https://img.shields.io/github/repo-size/avamia/kanrisuru" alt="GitHub repo size" />
|
13
|
-
<img src="https://img.shields.io/codecov/c/gh/avamia/kanrisuru?token=2Q1BE106B2" alt="Codecov" />
|
14
|
-
<img src="https://img.shields.io/codacy/grade/9e839eb160bc445ea4e81b64cef22b27" alt="Codacy grade" />
|
15
|
-
<img src="https://img.shields.io/codeclimate/maintainability/avamia/kanrisuru" alt="Code Climate maintainability" />
|
12
|
+
<img src="https://img.shields.io/github/repo-size/avamia/kanrisuru?style=flat-square" alt="GitHub repo size" />
|
13
|
+
<img src="https://img.shields.io/codecov/c/gh/avamia/kanrisuru?token=2Q1BE106B2&style=flat-square" alt="Codecov" />
|
14
|
+
<img src="https://img.shields.io/codacy/grade/9e839eb160bc445ea4e81b64cef22b27?style=flat-square" alt="Codacy grade" />
|
15
|
+
<img src="https://img.shields.io/codeclimate/maintainability/avamia/kanrisuru?style=flat-square" alt="Code Climate maintainability" />
|
16
16
|
</p>
|
17
17
|
|
18
18
|
# Kanrisuru
|
data/kanrisuru.gemspec
CHANGED
@@ -8,9 +8,12 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.author = 'Ryan Mammina'
|
9
9
|
gem.email = 'ryan@avamia.com'
|
10
10
|
gem.license = 'MIT'
|
11
|
-
gem.summary = 'Manage remote servers over ssh with ruby.'
|
12
|
-
gem.description = 'Kanrisuru helps manage remote servers with objected oriented ruby. Results come back as structured data, parsed, prepared and ready.'
|
13
11
|
gem.homepage = 'https://github.com/avamia/kanrisuru'
|
12
|
+
gem.summary = 'Manage remote servers over ssh with ruby.'
|
13
|
+
gem.description = <<-EOF
|
14
|
+
Kanrisuru helps manage remote servers with objected oriented ruby.#{' '}
|
15
|
+
Results come back as structured data, parsed, prepared and ready.
|
16
|
+
EOF
|
14
17
|
|
15
18
|
gem.required_ruby_version = '>= 2.5.0'
|
16
19
|
|
@@ -30,6 +33,7 @@ Gem::Specification.new do |gem|
|
|
30
33
|
|
31
34
|
gem.metadata = {
|
32
35
|
'source_code_uri' => 'https://github.com/avamia/kanrisuru/',
|
33
|
-
'changelog_uri' => 'https://github.com/avamia/kanrisuru/blob/main/CHANGELOG.md'
|
36
|
+
'changelog_uri' => 'https://github.com/avamia/kanrisuru/blob/main/CHANGELOG.md',
|
37
|
+
'rubygems_mfa_required' => 'true'
|
34
38
|
}
|
35
39
|
end
|
data/lib/kanrisuru/command.rb
CHANGED
@@ -23,6 +23,10 @@ module Kanrisuru
|
|
23
23
|
to_a.join.to_i
|
24
24
|
end
|
25
25
|
|
26
|
+
def to_f
|
27
|
+
to_a.join.to_f
|
28
|
+
end
|
29
|
+
|
26
30
|
def to_s
|
27
31
|
to_a.join(' ')
|
28
32
|
end
|
@@ -84,11 +88,10 @@ module Kanrisuru
|
|
84
88
|
append_value("| #{value}")
|
85
89
|
end
|
86
90
|
|
87
|
-
def append_array(value)
|
91
|
+
def append_array(value, separator = ' ')
|
88
92
|
return unless Kanrisuru::Util.present?(value)
|
89
93
|
|
90
|
-
value
|
91
|
-
append_value(value.join(' '))
|
94
|
+
append_value(Kanrisuru::Util.array_join_string(value, separator))
|
92
95
|
end
|
93
96
|
|
94
97
|
def append_value(value)
|
@@ -103,6 +106,16 @@ module Kanrisuru
|
|
103
106
|
@raw_command = Kanrisuru::Util.present?(boolean) ? "#{@raw_command} #{arg}" : @raw_command
|
104
107
|
end
|
105
108
|
|
109
|
+
def append_flag_no(arg, boolean = 'true')
|
110
|
+
return if boolean.nil?
|
111
|
+
|
112
|
+
if boolean
|
113
|
+
append_flag(arg, true)
|
114
|
+
else
|
115
|
+
append_flag("no#{arg}", true)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
106
119
|
def append_valid_exit_code(code)
|
107
120
|
@valid_exit_codes << code if code.instance_of?(Integer)
|
108
121
|
@valid_exit_codes.concat(code) if code.instance_of?(Array)
|
@@ -10,12 +10,12 @@ module Kanrisuru
|
|
10
10
|
|
11
11
|
command = Kanrisuru::Command.new('lsblk')
|
12
12
|
|
13
|
-
version = lsblk_version
|
13
|
+
version = lsblk_version.to_f
|
14
14
|
|
15
15
|
## lsblk after version 2.26 handles json parsing.
|
16
16
|
## TODO: parse nested children for earlier version of lsblk
|
17
|
-
if version >=
|
18
|
-
command.append_flag('--json') if version >=
|
17
|
+
if version >= LSBK_VERSION
|
18
|
+
command.append_flag('--json') if version >= LSBK_VERSION
|
19
19
|
else
|
20
20
|
command.append_flag('-i')
|
21
21
|
command.append_flag('-P')
|
@@ -40,14 +40,9 @@ module Kanrisuru
|
|
40
40
|
command = Kanrisuru::Command.new('lsblk --version')
|
41
41
|
execute(command)
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
raise 'lsblk command not found' if command.failure?
|
47
|
-
|
48
|
-
version = command.to_s.scan(regex)[0].to_f unless regex.match(command.to_s).nil?
|
49
|
-
|
50
|
-
version
|
43
|
+
Kanrisuru::Result.new(command) do |cmd|
|
44
|
+
Parser::LsblkVersion.parse(cmd)
|
45
|
+
end
|
51
46
|
end
|
52
47
|
end
|
53
48
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kanrisuru
|
4
|
+
module Core
|
5
|
+
module Disk
|
6
|
+
module Parser
|
7
|
+
class LsblkVersion
|
8
|
+
def self.parse(command)
|
9
|
+
version = 0.00
|
10
|
+
regex = Regexp.new(/\d+(?:[,.]\d+)?/)
|
11
|
+
|
12
|
+
raise 'lsblk command not found' if command.failure?
|
13
|
+
|
14
|
+
version = command.to_s.scan(regex)[0].to_f unless regex.match(command.to_s).nil?
|
15
|
+
version
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/kanrisuru/core/disk.rb
CHANGED
@@ -7,7 +7,7 @@ module Kanrisuru
|
|
7
7
|
recursive = opts[:recursive]
|
8
8
|
|
9
9
|
command =
|
10
|
-
if mode.instance_of?(String) && (mode.include?(',') || /[=+-]/.match(mode))
|
10
|
+
if mode.instance_of?(String) && (mode.include?(',') || /[=+-]/.match(mode)) && mode.length < 10
|
11
11
|
Kanrisuru::Command.new("chmod #{mode} #{path}")
|
12
12
|
elsif mode.instance_of?(Kanrisuru::Mode)
|
13
13
|
Kanrisuru::Command.new("chmod #{mode.numeric} #{path}")
|
@@ -29,9 +29,7 @@ module Kanrisuru
|
|
29
29
|
if opts[:preserve].instance_of?(TrueClass)
|
30
30
|
command.append_flag('-p')
|
31
31
|
elsif Kanrisuru::Util.present?(opts[:preserve])
|
32
|
-
preserve =
|
33
|
-
(opts[:preserve].join(',') if opts[:preserve].instance_of?(Array))
|
34
|
-
|
32
|
+
preserve = Kanrisuru::Util.array_join_string(opts[:preserve], ',')
|
35
33
|
command << "--preserve=#{preserve}"
|
36
34
|
end
|
37
35
|
|
@@ -8,16 +8,21 @@ module Kanrisuru
|
|
8
8
|
group = opts[:group]
|
9
9
|
recursive = opts[:recursive]
|
10
10
|
|
11
|
-
command = Kanrisuru::Command.new(
|
11
|
+
command = Kanrisuru::Command.new('mkdir')
|
12
|
+
|
13
|
+
command.append_array(path)
|
12
14
|
command.append_flag('-p', opts[:silent])
|
13
15
|
|
14
16
|
if Kanrisuru::Util.present?(opts[:mode])
|
15
17
|
mode = opts[:mode]
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
|
19
|
+
mode = if mode.instance_of?(Kanrisuru::Mode)
|
20
|
+
mode.numeric
|
21
|
+
elsif mode.instance_of?(String) && (mode.include?(',') || /[=+-]/.match(mode))
|
22
|
+
mode
|
23
|
+
else
|
24
|
+
Kanrisuru::Mode.new(mode).numeric
|
25
|
+
end
|
21
26
|
|
22
27
|
command.append_arg('-m', mode)
|
23
28
|
end
|
@@ -10,7 +10,10 @@ module Kanrisuru
|
|
10
10
|
raise ArgumentError, "Can't delete root path" if path == '/' || realpath(path).path == '/'
|
11
11
|
end
|
12
12
|
|
13
|
-
command = Kanrisuru::Command.new(
|
13
|
+
command = Kanrisuru::Command.new('rm')
|
14
|
+
command.append_array(paths)
|
15
|
+
|
16
|
+
command.append_flag('--preserve-root')
|
14
17
|
command.append_flag('-f', opts[:force])
|
15
18
|
command.append_flag('-r', opts[:recursive])
|
16
19
|
|
@@ -7,7 +7,8 @@ module Kanrisuru
|
|
7
7
|
date = opts[:date]
|
8
8
|
|
9
9
|
paths = [paths] if paths.instance_of?(String)
|
10
|
-
command = Kanrisuru::Command.new(
|
10
|
+
command = Kanrisuru::Command.new('touch')
|
11
|
+
command.append_array(paths)
|
11
12
|
|
12
13
|
command.append_flag('-a', opts[:atime])
|
13
14
|
command.append_flag('-m', opts[:mtime])
|
@@ -4,58 +4,16 @@ module Kanrisuru
|
|
4
4
|
module Core
|
5
5
|
module IP
|
6
6
|
def ip_address(action, opts)
|
7
|
-
command = nil
|
8
|
-
|
9
7
|
case action
|
10
8
|
when 'show', 'list'
|
11
|
-
version = ip_version
|
12
|
-
|
13
|
-
command = Kanrisuru::Command.new('ip')
|
14
|
-
command.append_flag('-json') if version >= IPROUTE2_JSON_VERSION
|
15
|
-
command.append_flag('-s', opts[:stats])
|
16
|
-
command.append_arg('-family', opts[:family])
|
17
|
-
command << 'address show'
|
18
|
-
|
19
|
-
command.append_arg('dev', opts[:dev])
|
20
|
-
command.append_arg('scope', opts[:scope])
|
21
|
-
command.append_arg('to', opts[:prefix])
|
22
|
-
command.append_arg('label', opts[:label])
|
23
|
-
|
24
|
-
command.append_flag('dynamic', opts[:dynamic])
|
25
|
-
command.append_flag('permanent', opts[:permanent])
|
26
|
-
command.append_flag('tenative', opts[:tenative])
|
27
|
-
command.append_flag('deprecated', opts[:deprecated])
|
28
|
-
command.append_flag('primary', opts[:primary])
|
29
|
-
command.append_flag('secondary', opts[:secondary])
|
30
|
-
command.append_flag('up', opts[:up])
|
9
|
+
version = ip_version.to_i
|
10
|
+
command = ip_address_show(opts, version)
|
31
11
|
when 'add'
|
32
|
-
command =
|
33
|
-
command << opts[:address]
|
34
|
-
|
35
|
-
command.append_arg('dev', opts[:dev])
|
36
|
-
command.append_arg('label', opts[:label])
|
37
|
-
command.append_arg('scope', opts[:scope])
|
12
|
+
command = ip_address_add(opts)
|
38
13
|
when 'del', 'delete'
|
39
|
-
command =
|
40
|
-
command << opts[:address]
|
41
|
-
|
42
|
-
command.append_arg('dev', opts[:dev])
|
43
|
-
command.append_arg('label', opts[:label])
|
44
|
-
command.append_arg('scope', opts[:scope])
|
14
|
+
command = ip_address_delete(opts)
|
45
15
|
when 'flush'
|
46
|
-
command =
|
47
|
-
|
48
|
-
command.append_arg('dev', opts[:dev])
|
49
|
-
command.append_arg('scope', opts[:scope])
|
50
|
-
command.append_arg('to', opts[:prefix])
|
51
|
-
command.append_arg('label', opts[:label])
|
52
|
-
|
53
|
-
command.append_flag('dynamic', opts[:dynamic])
|
54
|
-
command.append_flag('permanent', opts[:permanent])
|
55
|
-
command.append_flag('tenative', opts[:tenative])
|
56
|
-
command.append_flag('deprecated', opts[:deprecated])
|
57
|
-
command.append_flag('primary', opts[:primary])
|
58
|
-
command.append_flag('secondary', opts[:secondary])
|
16
|
+
command = ip_address_flush(opts)
|
59
17
|
end
|
60
18
|
|
61
19
|
execute_shell(command)
|
@@ -64,6 +22,65 @@ module Kanrisuru
|
|
64
22
|
Parser::Address.parse(cmd, action, version)
|
65
23
|
end
|
66
24
|
end
|
25
|
+
|
26
|
+
def ip_address_show(opts, version)
|
27
|
+
command = Kanrisuru::Command.new('ip')
|
28
|
+
command.append_flag('-json') if version >= IPROUTE2_JSON_VERSION
|
29
|
+
command.append_flag('-s', opts[:stats])
|
30
|
+
command.append_arg('-family', opts[:family])
|
31
|
+
command << 'address show'
|
32
|
+
|
33
|
+
command.append_arg('dev', opts[:dev])
|
34
|
+
command.append_arg('scope', opts[:scope])
|
35
|
+
command.append_arg('to', opts[:prefix])
|
36
|
+
command.append_arg('label', opts[:label])
|
37
|
+
|
38
|
+
command.append_flag('dynamic', opts[:dynamic])
|
39
|
+
command.append_flag('permanent', opts[:permanent])
|
40
|
+
command.append_flag('tenative', opts[:tenative])
|
41
|
+
command.append_flag('deprecated', opts[:deprecated])
|
42
|
+
command.append_flag('primary', opts[:primary])
|
43
|
+
command.append_flag('secondary', opts[:secondary])
|
44
|
+
command.append_flag('up', opts[:up])
|
45
|
+
command
|
46
|
+
end
|
47
|
+
|
48
|
+
def ip_address_add(opts)
|
49
|
+
command = Kanrisuru::Command.new('ip address add')
|
50
|
+
command << opts[:address]
|
51
|
+
|
52
|
+
command.append_arg('dev', opts[:dev])
|
53
|
+
command.append_arg('label', opts[:label])
|
54
|
+
command.append_arg('scope', opts[:scope])
|
55
|
+
command
|
56
|
+
end
|
57
|
+
|
58
|
+
def ip_address_delete(opts)
|
59
|
+
command = Kanrisuru::Command.new('ip address del')
|
60
|
+
command << opts[:address]
|
61
|
+
|
62
|
+
command.append_arg('dev', opts[:dev])
|
63
|
+
command.append_arg('label', opts[:label])
|
64
|
+
command.append_arg('scope', opts[:scope])
|
65
|
+
command
|
66
|
+
end
|
67
|
+
|
68
|
+
def ip_address_flush(opts)
|
69
|
+
command = Kanrisuru::Command.new('ip address flush')
|
70
|
+
|
71
|
+
command.append_arg('dev', opts[:dev])
|
72
|
+
command.append_arg('scope', opts[:scope])
|
73
|
+
command.append_arg('to', opts[:prefix])
|
74
|
+
command.append_arg('label', opts[:label])
|
75
|
+
|
76
|
+
command.append_flag('dynamic', opts[:dynamic])
|
77
|
+
command.append_flag('permanent', opts[:permanent])
|
78
|
+
command.append_flag('tenative', opts[:tenative])
|
79
|
+
command.append_flag('deprecated', opts[:deprecated])
|
80
|
+
command.append_flag('primary', opts[:primary])
|
81
|
+
command.append_flag('secondary', opts[:secondary])
|
82
|
+
command
|
83
|
+
end
|
67
84
|
end
|
68
85
|
end
|
69
86
|
end
|
@@ -4,27 +4,16 @@ module Kanrisuru
|
|
4
4
|
module Core
|
5
5
|
module IP
|
6
6
|
def ip_address_label(action, opts)
|
7
|
-
command = nil
|
8
|
-
|
9
7
|
case action
|
10
8
|
when 'show', 'list'
|
11
|
-
version = ip_version
|
12
|
-
|
13
|
-
command = Kanrisuru::Command.new('ip')
|
14
|
-
command.append_flag('-json') if version >= IPROUTE2_JSON_VERSION
|
15
|
-
command << 'addrlabel list'
|
9
|
+
version = ip_version.to_i
|
10
|
+
command = ip_address_label_show(opts, version)
|
16
11
|
when 'flush'
|
17
|
-
command =
|
12
|
+
command = ip_address_label_flush(opts)
|
18
13
|
when 'add'
|
19
|
-
command =
|
20
|
-
command.append_arg('prefix', opts[:prefix])
|
21
|
-
command.append_arg('dev', opts[:dev])
|
22
|
-
command.append_arg('label', opts[:label])
|
14
|
+
command = ip_address_label_add(opts)
|
23
15
|
when 'del'
|
24
|
-
command =
|
25
|
-
command.append_arg('prefix', opts[:prefix])
|
26
|
-
command.append_arg('dev', opts[:dev])
|
27
|
-
command.append_arg('label', opts[:label])
|
16
|
+
command = ip_address_label_delete(opts)
|
28
17
|
end
|
29
18
|
|
30
19
|
execute_shell(command)
|
@@ -33,6 +22,33 @@ module Kanrisuru
|
|
33
22
|
Parser::AddressLabel.parse(cmd, action, version)
|
34
23
|
end
|
35
24
|
end
|
25
|
+
|
26
|
+
def ip_address_label_delete(opts)
|
27
|
+
command = Kanrisuru::Command.new('ip addrlabel del')
|
28
|
+
command.append_arg('prefix', opts[:prefix])
|
29
|
+
command.append_arg('dev', opts[:dev])
|
30
|
+
command.append_arg('label', opts[:label])
|
31
|
+
command
|
32
|
+
end
|
33
|
+
|
34
|
+
def ip_address_label_add(opts)
|
35
|
+
command = Kanrisuru::Command.new('ip addrlabel add')
|
36
|
+
command.append_arg('prefix', opts[:prefix])
|
37
|
+
command.append_arg('dev', opts[:dev])
|
38
|
+
command.append_arg('label', opts[:label])
|
39
|
+
command
|
40
|
+
end
|
41
|
+
|
42
|
+
def ip_address_label_flush(_opts)
|
43
|
+
Kanrisuru::Command.new('ip addrlabel flush')
|
44
|
+
end
|
45
|
+
|
46
|
+
def ip_address_label_show(_opts, version)
|
47
|
+
command = Kanrisuru::Command.new('ip')
|
48
|
+
command.append_flag('-json') if version >= IPROUTE2_JSON_VERSION
|
49
|
+
command << 'addrlabel list'
|
50
|
+
command
|
51
|
+
end
|
36
52
|
end
|
37
53
|
end
|
38
54
|
end
|