-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into quinteros
- Loading branch information
Showing
14 changed files
with
235 additions
and
92 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
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
16 changes: 16 additions & 0 deletions
16
db/migrate/20230919143746_remove_vim_strings_from_miq_queue.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,16 @@ | ||
class RemoveVimStringsFromMiqQueue < ActiveRecord::Migration[6.1] | ||
disable_ddl_transaction! | ||
include MigrationHelper | ||
|
||
class MiqQueue < ActiveRecord::Base | ||
end | ||
|
||
def up | ||
regex_replace_column_value(MiqQueue, 'args', '!ruby/string:VimString', '!ruby/string:String') | ||
regex_replace_column_value(MiqQueue, 'args', '!ruby/hash-with-ivars:VimHash', '!ruby/hash-with-ivars:Hash') | ||
end | ||
|
||
# this is very old, not rolling back | ||
def down | ||
end | ||
end |
34 changes: 34 additions & 0 deletions
34
db/migrate/20231018141450_add_cpu_cores_columns_to_resource_pools.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 @@ | ||
class AddCpuCoresColumnsToResourcePools < ActiveRecord::Migration[6.0] | ||
class ResourcePool < ActiveRecord::Base | ||
include ActiveRecord::IdRegions | ||
self.inheritance_column = :_type_disabled | ||
end | ||
|
||
def up | ||
add_column :resource_pools, :cpu_cores_available, :float | ||
add_column :resource_pools, :cpu_cores_reserve, :float | ||
add_column :resource_pools, :cpu_cores_limit, :float | ||
|
||
say_with_time('Removing non-applicable data from IbmCloud::PowerVirtualServer resource pools') do | ||
ResourcePool.in_my_region.where(:type => %w[ManageIQ::Providers::IbmCloud::PowerVirtualServers::CloudManager::ResourcePool]).update_all( | ||
:cpu_shares => nil, | ||
:cpu_reserve => nil, | ||
:cpu_limit => nil | ||
) | ||
end | ||
|
||
say_with_time('Removing non-applicable data from IbmPowerHmc resource pools') do | ||
ResourcePool.in_my_region.where(:type => %w[ManageIQ::Providers::IbmPowerHmc::InfraManager::ProcessorResourcePool]).update_all( | ||
:cpu_shares => nil, | ||
:cpu_reserve => nil, | ||
:cpu_limit => nil | ||
) | ||
end | ||
end | ||
|
||
def down | ||
remove_column :resource_pools, :cpu_cores_available | ||
remove_column :resource_pools, :cpu_cores_reserve | ||
remove_column :resource_pools, :cpu_cores_limit | ||
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
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
54 changes: 54 additions & 0 deletions
54
spec/migrations/20230919143746_remove_vim_strings_from_miq_queue_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,54 @@ | ||
require_migration | ||
|
||
# This is mostly necessary for data migrations, so feel free to delete this | ||
# file if you do no need it. | ||
describe RemoveVimStringsFromMiqQueue do | ||
let(:miq_queue_stub) { migration_stub(:MiqQueue) } | ||
|
||
migration_context :up do | ||
it "converts VimStrings to Strings" do | ||
queue_args = <<~CONTEXT | ||
--- | ||
- :event_type: DrsMigrateVM_Task | ||
:chain_id: &1 !ruby/string:VimString | ||
str: '12345678' | ||
xsiType: :SOAP::SOAPInt | ||
vimType: | ||
:is_task: true | ||
:source: VC | ||
:message: &3 !ruby/string:VimString | ||
str: 'Task: Migrate virtual machine' | ||
xsiType: :SOAP::SOAPString | ||
vimType: | ||
:timestamp: &2 !ruby/string:VimString | ||
str: '2022-10-06T06:40:59.901255Z' | ||
xsiType: :SOAP::SOAPDateTime | ||
vimType: | ||
:full_data: !ruby/hash-with-ivars:VimHash | ||
elements: | ||
key: !ruby/string:VimString | ||
str: '12345678' | ||
xsiType: :SOAP::SOAPInt | ||
vimType: | ||
chainId: *1 | ||
createdTime: *2 | ||
userName: !ruby/string:VimString | ||
str: '' | ||
xsiType: :SOAP::SOAPString | ||
vimType: | ||
CONTEXT | ||
|
||
queue_item = miq_queue_stub.create!( | ||
:args => queue_args | ||
) | ||
|
||
migrate | ||
queue_item.reload | ||
|
||
args = YAML.safe_load(queue_item.args, :permitted_classes => [Symbol, Date, String, Hash], :aliases => true) | ||
arg = args.first | ||
expect(arg.class).to eq(Hash) | ||
expect(arg[:chain_id].class).to eq(String) | ||
end | ||
end | ||
end |
Oops, something went wrong.