зеркало из https://github.com/Azure/ipam.git
Fixed filtering for vNet prefixes, completed all filter methods for Arrays, fixed IPv6 address space crash, and removed all unnecessary console logs
This commit is contained in:
Родитель
872ad72a93
Коммит
a5eee9510d
|
@ -31,20 +31,7 @@ resources
|
||||||
| project name, id, resource_group = resourceGroup, subscription_id = subscriptionId, tenant_id = tenantId, prefixes = properties.addressSpace.addressPrefixes
|
| project name, id, resource_group = resourceGroup, subscription_id = subscriptionId, tenant_id = tenantId, prefixes = properties.addressSpace.addressPrefixes
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# VNET = """
|
# This version gets both IPv4 and IPv6 vNET/Subnet address spaces
|
||||||
# resources
|
|
||||||
# | where type =~ 'Microsoft.Network/virtualNetworks'
|
|
||||||
# | project name, id, resource_group = resourceGroup, subscription_id = subscriptionId, tenant_id = tenantId, prefixes = properties.addressSpace.addressPrefixes
|
|
||||||
# | join kind = leftouter(
|
|
||||||
# resources
|
|
||||||
# | where type =~ 'Microsoft.Network/virtualNetworks'
|
|
||||||
# | mv-expand subnet = todynamic(properties.subnets)
|
|
||||||
# | summarize subnets = make_list(subnet.properties.addressPrefix) by id
|
|
||||||
# ) on id
|
|
||||||
# | project-away id1
|
|
||||||
# | project name, id, prefixes, subnets, resource_group, subscription_id, tenant_id
|
|
||||||
# """
|
|
||||||
|
|
||||||
# VNET = """
|
# VNET = """
|
||||||
# resources
|
# resources
|
||||||
# | where type =~ 'Microsoft.Network/virtualNetworks'
|
# | where type =~ 'Microsoft.Network/virtualNetworks'
|
||||||
|
@ -54,25 +41,31 @@ resources
|
||||||
# resources
|
# resources
|
||||||
# | where type =~ 'Microsoft.Network/virtualNetworks'
|
# | where type =~ 'Microsoft.Network/virtualNetworks'
|
||||||
# | mv-expand subnet = todynamic(properties.subnets)
|
# | mv-expand subnet = todynamic(properties.subnets)
|
||||||
# | extend subnet_details = pack("name", subnet.name, "prefix", tostring(subnet.properties.addressPrefix), "used", coalesce(array_length(subnet.properties.ipConfigurations), 0) + 5)
|
# | extend nameMap = dynamic({{'AzureFirewallSubnet': 'AFW', 'GatewaySubnet': 'VGW', 'AzureBastionSubnet': 'BAS'}})
|
||||||
|
# | extend nameResult = nameMap[tostring(subnet.name)]
|
||||||
|
# | extend appGwConfig = subnet.properties.applicationGatewayIPConfigurations
|
||||||
|
# | extend appGwResult = iff(isnotnull(appGwConfig), "AGW", appGwConfig)
|
||||||
|
# | extend subnetType = coalesce(nameResult, appGwResult)
|
||||||
|
# | extend subnet_details = pack("name", subnet.name, "prefix", tostring(subnet.properties.addressPrefix), "used", coalesce(array_length(subnet.properties.ipConfigurations), 0) + 5, "type", todynamic(subnetType))
|
||||||
# | summarize subnet_bag = make_bag(subnet_details) by tostring(subnet.id), id
|
# | summarize subnet_bag = make_bag(subnet_details) by tostring(subnet.id), id
|
||||||
# ) on id
|
# ) on id
|
||||||
# | join kind = leftouter(
|
# | join kind = leftouter(
|
||||||
# resources
|
# resources
|
||||||
# | where type =~ 'Microsoft.Network/virtualNetworks'
|
# | where type =~ 'Microsoft.Network/virtualNetworks'
|
||||||
# | mv-expand peering = properties.virtualNetworkPeerings
|
# | mv-expand peering = todynamic(properties.virtualNetworkPeerings)
|
||||||
# | extend peering_details = pack("name", peering.name, "remote_network", peering.properties.remoteVirtualNetwork.id, "state", peering.properties.peeringState)
|
# | extend peering_details = pack("name", peering.name, "remote_network", peering.properties.remoteVirtualNetwork.id, "state", peering.properties.peeringState)
|
||||||
# | summarize peering_bag = make_bag(peering_details) by tostring(peering.id), id
|
# | summarize peering_bag = make_bag(peering_details) by tostring(peering.id), id
|
||||||
# ) on id
|
# ) on id
|
||||||
# | summarize subnets = make_list(subnet_bag), peerings = make_list(peering_bag) by id, name, tostring(prefixes), resource_group, subscription_id, tenant_id, resv
|
# | summarize subnets = make_list(subnet_bag) by id, tostring(peering_bag), name, tostring(prefixes), resource_group, subscription_id, tenant_id, resv
|
||||||
# | project name, id, todynamic(prefixes), subnets, peerings, resource_group, subscription_id, tenant_id, todynamic(resv)
|
# | summarize peerings = make_list(todynamic(peering_bag)) by id, name, tostring(subnets), tostring(prefixes), resource_group, subscription_id, tenant_id, resv
|
||||||
|
# | project name, id, todynamic(prefixes), todynamic(subnets), peerings, resource_group, subscription_id, tenant_id, todynamic(resv)
|
||||||
# """
|
# """
|
||||||
|
|
||||||
VNET = """
|
VNET = """
|
||||||
resources
|
resources
|
||||||
| where type =~ 'Microsoft.Network/virtualNetworks'
|
| where type =~ 'Microsoft.Network/virtualNetworks'
|
||||||
| where subscriptionId !in~ {}
|
| where subscriptionId !in~ {}
|
||||||
| project name, id, resource_group = resourceGroup, subscription_id = subscriptionId, tenant_id = tenantId, prefixes = properties.addressSpace.addressPrefixes, resv = tostring(coalesce(tags['X-IPAM-RES-ID'], tags['ipam-res-id']))
|
| project name, id, resource_group = resourceGroup, subscription_id = subscriptionId, tenant_id = tenantId, prefixes = array_slice(properties.addressSpace.addressPrefixes, 0, 0), resv = tostring(coalesce(tags['X-IPAM-RES-ID'], tags['ipam-res-id']))
|
||||||
| join kind = leftouter(
|
| join kind = leftouter(
|
||||||
resources
|
resources
|
||||||
| where type =~ 'Microsoft.Network/virtualNetworks'
|
| where type =~ 'Microsoft.Network/virtualNetworks'
|
||||||
|
@ -82,7 +75,9 @@ resources
|
||||||
| extend appGwConfig = subnet.properties.applicationGatewayIPConfigurations
|
| extend appGwConfig = subnet.properties.applicationGatewayIPConfigurations
|
||||||
| extend appGwResult = iff(isnotnull(appGwConfig), "AGW", appGwConfig)
|
| extend appGwResult = iff(isnotnull(appGwConfig), "AGW", appGwConfig)
|
||||||
| extend subnetType = coalesce(nameResult, appGwResult)
|
| extend subnetType = coalesce(nameResult, appGwResult)
|
||||||
| extend subnet_details = pack("name", subnet.name, "prefix", tostring(subnet.properties.addressPrefix), "used", coalesce(array_length(subnet.properties.ipConfigurations), 0) + 5, "type", todynamic(subnetType))
|
| extend subnetPrefix = todynamic(subnet.properties.addressPrefix)
|
||||||
|
| extend subnetPrefixes = todynamic(subnet.properties.addressPrefixes)
|
||||||
|
| extend subnet_details = pack("name", subnet.name, "prefix", tostring(iff(isnotnull(subnetPrefixes), subnetPrefixes[0], subnetPrefix)), "used", coalesce(array_length(subnet.properties.ipConfigurations), 0) + 5, "type", todynamic(subnetType))
|
||||||
| summarize subnet_bag = make_bag(subnet_details) by tostring(subnet.id), id
|
| summarize subnet_bag = make_bag(subnet_details) by tostring(subnet.id), id
|
||||||
) on id
|
) on id
|
||||||
| join kind = leftouter(
|
| join kind = leftouter(
|
||||||
|
@ -97,13 +92,19 @@ resources
|
||||||
| project name, id, todynamic(prefixes), todynamic(subnets), peerings, resource_group, subscription_id, tenant_id, todynamic(resv)
|
| project name, id, todynamic(prefixes), todynamic(subnets), peerings, resource_group, subscription_id, tenant_id, todynamic(resv)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# This version gets both the IPv4 and IPv6 Subnet address space
|
||||||
# SUBNET = """
|
# SUBNET = """
|
||||||
# resources
|
# resources
|
||||||
# | where type =~ 'Microsoft.Network/virtualNetworks'
|
# | where type =~ 'Microsoft.Network/virtualNetworks'
|
||||||
# | where subscriptionId !in~ {}
|
# | where subscriptionId !in~ {}
|
||||||
# | mv-expand subnet = todynamic(properties.subnets)
|
# | mv-expand subnet = todynamic(properties.subnets)
|
||||||
# | extend subnet_size = array_length(subnet.properties.ipConfigurations)
|
# | extend subnet_size = array_length(subnet.properties.ipConfigurations)
|
||||||
# | project name = subnet.name, id = subnet.id, prefix = subnet.properties.addressPrefix, resource_group = resourceGroup, subscription_id = subscriptionId, tenant_id = tenantId,vnet_name = name, vnet_id = id, used = (iif(isnull(subnet_size), 0, subnet_size) + 5), appgw_config = subnet.properties.applicationGatewayIPConfigurations
|
# | extend nameMap = dynamic({{'AzureFirewallSubnet': 'AFW', 'GatewaySubnet': 'VGW', 'AzureBastionSubnet': 'BAS'}})
|
||||||
|
# | extend nameResult = nameMap[tostring(subnet.name)]
|
||||||
|
# | extend appGwConfig = subnet.properties.applicationGatewayIPConfigurations
|
||||||
|
# | extend appGwResult = iff(isnotnull(appGwConfig), "AGW", appGwConfig)
|
||||||
|
# | extend subnetType = coalesce(nameResult, appGwResult)
|
||||||
|
# | project name = subnet.name, id = subnet.id, prefix = subnet.properties.addressPrefix, resource_group = resourceGroup, subscription_id = subscriptionId, tenant_id = tenantId,vnet_name = name, vnet_id = id, used = (iif(isnull(subnet_size), 0, subnet_size) + 5), type = todynamic(subnetType)
|
||||||
# """
|
# """
|
||||||
|
|
||||||
SUBNET = """
|
SUBNET = """
|
||||||
|
@ -117,7 +118,9 @@ resources
|
||||||
| extend appGwConfig = subnet.properties.applicationGatewayIPConfigurations
|
| extend appGwConfig = subnet.properties.applicationGatewayIPConfigurations
|
||||||
| extend appGwResult = iff(isnotnull(appGwConfig), "AGW", appGwConfig)
|
| extend appGwResult = iff(isnotnull(appGwConfig), "AGW", appGwConfig)
|
||||||
| extend subnetType = coalesce(nameResult, appGwResult)
|
| extend subnetType = coalesce(nameResult, appGwResult)
|
||||||
| project name = subnet.name, id = subnet.id, prefix = subnet.properties.addressPrefix, resource_group = resourceGroup, subscription_id = subscriptionId, tenant_id = tenantId,vnet_name = name, vnet_id = id, used = (iif(isnull(subnet_size), 0, subnet_size) + 5), type = todynamic(subnetType)
|
| extend subnetPrefix = todynamic(subnet.properties.addressPrefix)
|
||||||
|
| extend subnetPrefixes = todynamic(subnet.properties.addressPrefixes)
|
||||||
|
| project name = subnet.name, id = subnet.id, prefix = tostring(iff(isnotnull(subnetPrefixes), subnetPrefixes[0], subnetPrefix)), resource_group = resourceGroup, subscription_id = subscriptionId, tenant_id = tenantId,vnet_name = name, vnet_id = id, used = (iif(isnull(subnet_size), 0, subnet_size) + 5), type = todynamic(subnetType)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
PRIVATE_ENDPOINT = """
|
PRIVATE_ENDPOINT = """
|
||||||
|
|
|
@ -25,6 +25,39 @@ import Shrug from "../../img/pam/Shrug";
|
||||||
import { TableContext } from "./TableContext";
|
import { TableContext } from "./TableContext";
|
||||||
import ItemDetails from "./Utils/Details";
|
import ItemDetails from "./Utils/Details";
|
||||||
|
|
||||||
|
const filterTypes = Object.assign({}, ReactDataGrid.defaultProps.filterTypes, {
|
||||||
|
array: {
|
||||||
|
name: 'array',
|
||||||
|
emptyValue: null,
|
||||||
|
operators: [
|
||||||
|
{
|
||||||
|
name: 'contains',
|
||||||
|
fn: ({ value, filterValue, data }) => {
|
||||||
|
return filterValue !== (null || '') ? value.join(",").includes(filterValue) : true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'notContains',
|
||||||
|
fn: ({ value, filterValue, data }) => {
|
||||||
|
return filterValue !== (null || '') ? !value.join(",").includes(filterValue) : true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'eq',
|
||||||
|
fn: ({ value, filterValue, data }) => {
|
||||||
|
return filterValue !== (null || '') ? value.includes(filterValue) : true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'neq',
|
||||||
|
fn: ({ value, filterValue, data }) => {
|
||||||
|
return filterValue !== (null || '') ? !value.includes(filterValue) : true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const openStyle = {
|
const openStyle = {
|
||||||
right: 0,
|
right: 0,
|
||||||
transition: "all 0.5s ease-in-out",
|
transition: "all 0.5s ease-in-out",
|
||||||
|
@ -117,7 +150,7 @@ export default function DiscoverTable(props) {
|
||||||
},[location, filterSettings]);
|
},[location, filterSettings]);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
stateData && setGridData(filter(stateData, filterData));
|
stateData && setGridData(filter(stateData, filterData, filterTypes));
|
||||||
},[stateData, filterData]);
|
},[stateData, filterData]);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
|
@ -178,6 +211,7 @@ export default function DiscoverTable(props) {
|
||||||
enableColumnAutosize={false}
|
enableColumnAutosize={false}
|
||||||
showColumnMenuGroupOptions={false}
|
showColumnMenuGroupOptions={false}
|
||||||
enableColumnFilterContextMenu={true}
|
enableColumnFilterContextMenu={true}
|
||||||
|
filterTypes={filterTypes}
|
||||||
columns={columnData}
|
columns={columnData}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
dataSource={gridData || []}
|
dataSource={gridData || []}
|
||||||
|
@ -191,3 +225,5 @@ export default function DiscoverTable(props) {
|
||||||
</TableContext.Provider>
|
</TableContext.Provider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// data.map((item) => Object.entries(item).reduce((obj, [k, v]) => { Array.isArray(v) ? obj[k] = v.join(", ") : obj[k] = v; return obj; }, {}));
|
||||||
|
|
|
@ -568,11 +568,6 @@ const Visualize = () => {
|
||||||
|
|
||||||
function setDataFocus(target) {
|
function setDataFocus(target) {
|
||||||
if(eChartsRef && !isEmpty(options.series)) {
|
if(eChartsRef && !isEmpty(options.series)) {
|
||||||
console.log("SET DATA FOCUS");
|
|
||||||
console.log(options);
|
|
||||||
console.log("TARGET");
|
|
||||||
console.log(target);
|
|
||||||
|
|
||||||
let newOptions = cloneDeep(options);
|
let newOptions = cloneDeep(options);
|
||||||
|
|
||||||
newOptions.title.show = target ? false : true;
|
newOptions.title.show = target ? false : true;
|
||||||
|
@ -580,11 +575,7 @@ const Visualize = () => {
|
||||||
|
|
||||||
eChartsRef.getEchartsInstance().setOption(newOptions);
|
eChartsRef.getEchartsInstance().setOption(newOptions);
|
||||||
|
|
||||||
console.log("NEW OPTIONS");
|
|
||||||
console.log(newOptions);
|
|
||||||
|
|
||||||
if(!target) {
|
if(!target) {
|
||||||
console.log("CLEARING LEGEND SELECT");
|
|
||||||
eChartsRef.getEchartsInstance().dispatchAction({
|
eChartsRef.getEchartsInstance().dispatchAction({
|
||||||
type: 'legendAllSelect'
|
type: 'legendAllSelect'
|
||||||
});
|
});
|
||||||
|
@ -593,7 +584,6 @@ const Visualize = () => {
|
||||||
type: 'legendInverseSelect'
|
type: 'legendInverseSelect'
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.log("SELECTING LEGEND TARGET");
|
|
||||||
eChartsRef.getEchartsInstance().dispatchAction({
|
eChartsRef.getEchartsInstance().dispatchAction({
|
||||||
type: 'legendSelect',
|
type: 'legendSelect',
|
||||||
name: target
|
name: target
|
||||||
|
|
|
@ -71,7 +71,7 @@ export default function EditVnets(props) {
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if(space && block) {
|
if(space && block) {
|
||||||
!refreshingState && setSelectionModel(block['vnets'].map(vnet => vnet.id));
|
!refreshingState && setSelectionModel(block['vnets'].reduce((obj, vnet) => (obj[vnet.id] = vnet, obj) ,{}));
|
||||||
}
|
}
|
||||||
}, [space, block, refreshingState]);
|
}, [space, block, refreshingState]);
|
||||||
|
|
||||||
|
@ -232,7 +232,7 @@ export default function EditVnets(props) {
|
||||||
enableColumnAutosize={false}
|
enableColumnAutosize={false}
|
||||||
showColumnMenuGroupOptions={false}
|
showColumnMenuGroupOptions={false}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
loading={refreshing}
|
loading={refreshing || refreshingState}
|
||||||
dataSource={vNets}
|
dataSource={vNets}
|
||||||
selected={selectionModel}
|
selected={selectionModel}
|
||||||
onSelectionChange={({selected}) => setSelectionModel(selected)}
|
onSelectionChange={({selected}) => setSelectionModel(selected)}
|
||||||
|
|
|
@ -79,7 +79,6 @@ export default function ConfigureIPAM() {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
const refresh = React.useCallback(() => {
|
const refresh = React.useCallback(() => {
|
||||||
console.log("REFRESH SPACES");
|
|
||||||
const request = {
|
const request = {
|
||||||
scopes: apiRequest.scopes,
|
scopes: apiRequest.scopes,
|
||||||
account: accounts[0],
|
account: accounts[0],
|
||||||
|
|
|
@ -296,6 +296,16 @@ export default function NavDrawer() {
|
||||||
return titleCase;
|
return titleCase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function GetInstanceType(target) {
|
||||||
|
var instanceType = typeof target;
|
||||||
|
|
||||||
|
if(instanceType === 'object') {
|
||||||
|
instanceType = Array.isArray(target) ? 'array': 'object';
|
||||||
|
}
|
||||||
|
|
||||||
|
return instanceType;
|
||||||
|
}
|
||||||
|
|
||||||
function objToFilter(data, header, path, exclusions) {
|
function objToFilter(data, header, path, exclusions) {
|
||||||
const searchObj = data.reduce((prev, curr) => {
|
const searchObj = data.reduce((prev, curr) => {
|
||||||
|
|
||||||
|
@ -310,6 +320,7 @@ export default function NavDrawer() {
|
||||||
searchKey: key,
|
searchKey: key,
|
||||||
noun: keyNoun,
|
noun: keyNoun,
|
||||||
comparator: Array.isArray(value) ? 'contains' : 'like',
|
comparator: Array.isArray(value) ? 'contains' : 'like',
|
||||||
|
type: GetInstanceType(value),
|
||||||
values: []
|
values: []
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -339,7 +350,7 @@ export default function NavDrawer() {
|
||||||
filter: {
|
filter: {
|
||||||
name: props.searchKey,
|
name: props.searchKey,
|
||||||
operator: 'contains',
|
operator: 'contains',
|
||||||
type: 'string',
|
type: props.type,
|
||||||
value: value
|
value: value
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -60,7 +60,6 @@ function Refresh() {
|
||||||
|
|
||||||
(async() => {
|
(async() => {
|
||||||
try {
|
try {
|
||||||
console.log("REFRESH ME...");
|
|
||||||
const response = await instance.acquireTokenSilent(request)
|
const response = await instance.acquireTokenSilent(request)
|
||||||
dispatch(getMeAsync(response.accessToken))
|
dispatch(getMeAsync(response.accessToken))
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -120,7 +120,7 @@ export const vnets = {
|
||||||
{ name: 'parentBlock', operator: 'contains', type: 'string', value: '' },
|
{ name: 'parentBlock', operator: 'contains', type: 'string', value: '' },
|
||||||
{ name: 'size', operator: 'gte', type: 'number', value: 0 },
|
{ name: 'size', operator: 'gte', type: 'number', value: 0 },
|
||||||
{ name: 'used', operator: 'gte', type: 'number', value: 0 },
|
{ name: 'used', operator: 'gte', type: 'number', value: 0 },
|
||||||
{ name: 'prefixes', operator: 'contains', type: 'string', value: '' }
|
{ name: 'prefixes', operator: 'contains', type: 'array', value: '' }
|
||||||
],
|
],
|
||||||
detailsMap: {
|
detailsMap: {
|
||||||
showProgress: true,
|
showProgress: true,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче