-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extend NetworkManager inventory #9
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class ManageIQ::Providers::AzureStack::NetworkManager::CloudNetwork < ::CloudNetwork | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class ManageIQ::Providers::AzureStack::NetworkManager::CloudSubnet < ::CloudSubnet | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class ManageIQ::Providers::AzureStack::NetworkManager::NetworkPort < ::NetworkPort | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,6 +100,9 @@ | |
"type": "Microsoft.Network/virtualNetworks", | ||
"name": "[variables('virtualNetworkName')]", | ||
"location": "[variables('location')]", | ||
"dependsOn": [ | ||
"[variables('networkSecurityGroupName')]" | ||
], | ||
"properties": { | ||
"addressSpace": { | ||
"addressPrefixes": [ | ||
|
@@ -110,7 +113,10 @@ | |
{ | ||
"name": "[variables('subnetName')]", | ||
"properties": { | ||
"addressPrefix": "[variables('subnetPrefix')]" | ||
"addressPrefix": "[variables('subnetPrefix')]", | ||
"networkSecurityGroup": { | ||
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]" | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Awesome 👍 |
||
} | ||
} | ||
] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,10 @@ | |
let(:security_group) { SecurityGroup.find_by(:name => 'demoSecurityGroup') } | ||
let(:flavor) { Flavor.find_by(:ems_ref => 'standard_a1') } | ||
|
||
let(:network) { CloudNetwork.find_by(:name => 'demoNetwork') } | ||
let(:subnet) { CloudSubnet.find_by(:name => 'demoSubnet') } | ||
let(:network_port) { NetworkPort.find_by(:name => 'demoNic0') } | ||
|
||
let(:saving_strategy) { :recursive } | ||
let(:saver_strategy) { :default } | ||
let(:use_ar) { true } | ||
|
@@ -67,6 +71,9 @@ def assert_inventory | |
assert_specific_flavor | ||
assert_specific_vm | ||
assert_specific_orchestration_stack | ||
assert_specific_network | ||
assert_specific_subnet | ||
assert_specific_network_port | ||
assert_security_group | ||
end | ||
|
||
|
@@ -76,6 +83,9 @@ def assert_table_counts | |
expect(AvailabilityZone.count).to eq(1) | ||
expect(Vm.count).to eq(1) | ||
expect(Flavor.count).to eq(70) | ||
expect(CloudNetwork.count).to eq(1) | ||
expect(CloudSubnet.count).to eq(1) | ||
expect(NetworkPort.count).to eq(1) | ||
expect(SecurityGroup.count).to eq(1) | ||
expect(OrchestrationStack.count).to eq(1) | ||
end | ||
|
@@ -143,6 +153,39 @@ def assert_specific_orchestration_stack | |
) | ||
end | ||
|
||
def assert_specific_network | ||
expect(network).not_to be_nil | ||
expect(ems_ref_suffix(network.ems_ref)).to match(%r{^/providers/microsoft.network/virtualnetworks/[^/]+$}) | ||
|
||
expect(network.cloud_subnets).not_to be_nil | ||
expect(network.cloud_subnets.size).to eq(1) | ||
end | ||
|
||
def assert_specific_subnet | ||
expect(subnet).not_to be_nil | ||
expect(ems_ref_suffix(subnet.ems_ref)).to match(%r{^/providers/microsoft.network/virtualnetworks/[^/]+/subnets/[^/]+$}) | ||
|
||
expect(subnet.cloud_network).to eq(network) | ||
|
||
assert_security_groups_binding(subnet) | ||
end | ||
|
||
def assert_specific_network_port | ||
expect(network_port).not_to be_nil | ||
expect(ems_ref_suffix(network_port.ems_ref)).to match(%r{^/providers/microsoft.network/networkinterfaces/[^/]+$}) | ||
expect(network_port.mac_address).to eq('001DD8B70047') | ||
|
||
expect(network_port.device).to eq(vm) | ||
|
||
assert_security_groups_binding(network_port) | ||
end | ||
|
||
def assert_security_groups_binding(entity) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like this DRY approach you took here 👍 |
||
expect(entity.security_groups).not_to be_nil | ||
expect(entity.security_groups.size).to eq(1) | ||
expect(entity.security_groups.first).to eq(security_group) | ||
end | ||
|
||
def assert_security_group | ||
expect(security_group).not_to be_nil | ||
expect(ems_ref_suffix(security_group.ems_ref)).to match(%r{^/providers/microsoft.network/networksecuritygroups/[^/]+$}) | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we need utility function here because we're just filling in a simple relation. I'd go with a simple IF statement at the top instead:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is exactly how I used to have it initially, when I hooked
security_groups
to network ports only. But then I needed the same logic for subnets and I thought it made sense to extract it to a helper function (note that this is also mirrored by theassert_security_groups_binding
which is used in bothassert_specific_subnet
andassert_specific_network_port
).I did modify the helper itself to make use of
&.
when accessing entity's security group though 👍