-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding physical switch power operations
- Loading branch information
1 parent
9f987c8
commit 7c5d32e
Showing
5 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
app/models/manageiq/providers/lenovo/physical_infra_manager/physical_switch.rb
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
module ManageIQ::Providers | ||
class Lenovo::PhysicalInfraManager::PhysicalSwitch < ::PhysicalSwitch | ||
include_concern 'Operations' | ||
end | ||
end |
34 changes: 34 additions & 0 deletions
34
app/models/manageiq/providers/lenovo/physical_infra_manager/physical_switch/operations.rb
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,34 @@ | ||
# | ||
# Has the Power Operation methods for Physical Switches | ||
# | ||
module ManageIQ::Providers::Lenovo::PhysicalInfraManager::PhysicalSwitch::Operations | ||
extend ActiveSupport::Concern | ||
|
||
# | ||
# Restarts the physical switch. | ||
# it does the `power_cycle_soft` operation. | ||
# | ||
def restart | ||
change_resource_state(:power_cycle_soft_switch) | ||
end | ||
|
||
private | ||
|
||
# | ||
# Sends the power operation for a Switch. | ||
# | ||
# @param [symbol] verb - the operation that must be sent | ||
# | ||
# @return the LXCA response | ||
# | ||
def change_resource_state(verb) | ||
$lenovo_log.info("The :#{verb} for Physical Switch with uuid: #{uid_ems} is in progress") | ||
|
||
ems = ExtManagementSystem.find(ems_id) | ||
response = ems.connect.send(verb, uid_ems) | ||
|
||
$lenovo_log.info("The :#{verb} for Physical Switch with uuid: #{uid_ems} is completed") | ||
|
||
response | ||
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,4 @@ | ||
FactoryGirl.define do | ||
factory :lenovo_physical_switch, :class => ManageIQ::Providers::Lenovo::PhysicalInfraManager::PhysicalSwitch do | ||
end | ||
end |
36 changes: 36 additions & 0 deletions
36
spec/models/manageiq/providers/lenovo/physical_infra_manager/physical_switch_spec.rb
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,36 @@ | ||
describe ManageIQ::Providers::Lenovo::PhysicalInfraManager::PhysicalSwitch do | ||
context 'power operations' do | ||
let(:physical_switch) do | ||
physical_infra_manager = FactoryGirl.create( | ||
:physical_infra, | ||
:name => "LXCA", | ||
:hostname => "10.243.9.123", | ||
:port => "443", | ||
:ipaddress => "https://10.243.9.123" | ||
) | ||
|
||
auth = FactoryGirl.create( | ||
:authentication, | ||
:userid => "admin", | ||
:password => "password", | ||
:authtype => "default" | ||
) | ||
|
||
physical_infra_manager.authentications = [auth] | ||
|
||
FactoryGirl.create( | ||
:lenovo_physical_switch, | ||
:name => "Physical_Switch", | ||
:uid_ems => "27997dba5dba11e89c2dfa7ae01bbebc", | ||
:ext_management_system => physical_infra_manager | ||
) | ||
end | ||
|
||
it 'should restart the physical switch' do | ||
VCR.use_cassette("#{described_class.name.underscore}_restart") do | ||
response = physical_switch.restart | ||
expect(response.status).to eq(200) | ||
end | ||
end | ||
end | ||
end |
65 changes: 65 additions & 0 deletions
65
...cr_cassettes/manageiq/providers/lenovo/physical_infra_manager/physical_switch_restart.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.