<commit_before>---
title: Scoped MacPoolManager
category: api
authors: mkolesni, mmucha, moti, mpavlik
wiki_category: Api
wiki_title: Features/Scoped MacPoolManager
wiki_revision_count: 36
wiki_last_updated: 2015-01-14
---

# Scoped MacPoolManager

__TOC__

## Summary

Previously there was sole pool of MACs, it's mac ranges for this pool could/can be configured via engine-config.

This holds true, but aside from that, now is possible, not required, to define separate MAC pool for each "scope".

Currently a data center is considered to be a "scope", later maybe finer control will be possible.

## Owner

Name: <NAME>

Email: <<EMAIL>>

## Benefit to oVirt

Definition of domains from which MAC addresses will be allocated for each "scope". Potential ability to change *scope*.

## Comments

*   Specifying MAC pool ranges for given "scope" is optional, not required. If not specified, the default, engine-wide pool will be used.
*   When specifying mac ranges for one pool, all potential MAC range overlaps/intersections are removed. But currently NO checks are done to detect duplicates among mac ranges related to different "scopes".
*   All defined "scoped" pools are initialized during startup, just like default MAC pool. When creating new data center/updating/removing "scoped" MAC pool is created/altered/removed in respect to that.
*   When updated mac ranges for given "scope", notice, that MAC addresses currently will not get reassigned. Used MACs assigned from previous range definition will be added as manually specified MACs
*   When specified mac ranges for given "scope", where there wasn't any definition previously, allocated MAC from default pool will not be moved to "scoped" one until next engine restart. Other way, when removing "scoped" mac pool definition, all MACs from this pool will be moved to default one.
*   While ranges definition may differ per "scope", other variables -- 'MaxMacsCountInPool' and 'AllowDuplicateMacAddresses' are still system wide.

## Gui

![](MacPoolRangesOnDataCenter.png "MacPoolRangesOnDataCenter.png")

[File:MacPoolRangesOnDataCenter.png|screenshot](File:MacPoolRangesOnDataCenter.png|screenshot)

## Implementation details

While we're just talking about data center "scopes", it's possible that fine grained "scope" will be requested, or user could decide which "scope" he/she/... wants. To allow that, data center "scope" manipulation is done like this:

Notice that implementation of scopeFor() methods etc. can switch by configuration whether/which "scope" will be used.

### initialization of scope

command adding new data center will contain following code

      ScopedMacPoolManager.requireScopeFor().storagePool(storagePool)

where storagePool is newly created storage pool.

### modification of scope

let's say, that storage pool already exist, but without specified mac pool ranges, so after db is updated, new pool has to be created for it.

      ScopedMacPoolManager.updateScopeFor().storagePool(storagePool)

### removal of scope

      ScopedMacPoolManager.updateScopeFor().storagePool(storagePoolID)

### manipulating with pool

formerly code to remove macs was:

      MacPoolManager.getInstance().freeMacs(macsToRemove);

now we have to specify from \*where\* we want them to be removed:

      ScopedMacPoolManager.scopeFor().storagePool(storagePoolId).freeMacs(macsToRemove);

which will decide which storagePool is appropriate for your request and frees macs from it. When you're super-sure you want to use default storagePool, you can use

      ScopedMacPoolManager.defaultScope().storagePool(storagePoolId).freeMacs(macsToRemove); 

<Category:Api> <Category:Feature>
<commit_msg>Updated Scoped MacPoolManager<commit_after>---
title: Scoped MacPoolManager
category: api
authors: mkolesni, mmucha, moti, mpavlik
wiki_category: Api
wiki_title: Features/Scoped MacPoolManager
wiki_revision_count: 36
wiki_last_updated: 2015-01-14
---

# Scoped MacPoolManager

__TOC__

## Summary

Previously there was sole pool of MACs, it's mac ranges for this pool could/can be configured via engine-config.

This holds true, but aside from that, now is possible, not required, to define separate MAC pool for each "scope".

Currently a data center is considered to be a "scope", later maybe finer control will be possible.

## Owner

Name: <NAME>

Email: <<EMAIL>>

## Benefit to oVirt

Definition of domains from which MAC addresses will be allocated for each "scope". Potential ability to change *scope*.

## Comments

*   Specifying MAC pool ranges for given "scope" is optional, not required. If not specified, the default, engine-wide pool will be used.
*   When specifying mac ranges for one pool, all potential MAC range overlaps/intersections are removed. But currently NO checks are done to detect duplicates among mac ranges related to different "scopes".
*   All defined "scoped" pools are initialized during startup, just like default MAC pool. When creating new data center/updating/removing "scoped" MAC pool is created/altered/removed in respect to that.
*   When updated mac ranges for given "scope", notice, that MAC addresses currently will not get reassigned. Used MACs assigned from previous range definition will be added as manually specified MACs
*   When specified mac ranges for given "scope", where there wasn't any definition previously, allocated MAC from default pool will not be moved to "scoped" one until next engine restart. Other way, when removing "scoped" mac pool definition, all MACs from this pool will be moved to default one.
*   While ranges definition may differ per "scope", other variables -- 'MaxMacsCountInPool' and 'AllowDuplicateMacAddresses' are still system wide.

## Gui

Style of entering mac pool ranges is hardly ideal, but it should suffice at first. ![](MacPoolRangesOnDataCenter.png "fig:MacPoolRangesOnDataCenter.png")

## Implementation details

While we're just talking about data center "scopes", it's possible that fine grained "scope" will be requested, or user could decide which "scope" he/she/... wants. To allow that, data center "scope" manipulation is done like this:

Notice that implementation of scopeFor() methods etc. can switch by configuration whether/which "scope" will be used.

### initialization of scope

command adding new data center will contain following code

      ScopedMacPoolManager.requireScopeFor().storagePool(storagePool)

where storagePool is newly created storage pool.

### modification of scope

let's say, that storage pool already exist, but without specified mac pool ranges, so after db is updated, new pool has to be created for it.

      ScopedMacPoolManager.updateScopeFor().storagePool(storagePool)

### removal of scope

      ScopedMacPoolManager.updateScopeFor().storagePool(storagePoolID)

### manipulating with pool

formerly code to remove macs was:

      MacPoolManager.getInstance().freeMacs(macsToRemove);

now we have to specify from \*where\* we want them to be removed:

      ScopedMacPoolManager.scopeFor().storagePool(storagePoolId).freeMacs(macsToRemove);

which will decide which storagePool is appropriate for your request and frees macs from it. When you're super-sure you want to use default storagePool, you can use

      ScopedMacPoolManager.defaultScope().storagePool(storagePoolId).freeMacs(macsToRemove); 

<Category:Api> <Category:Feature>

{'fraction_non_alphanumeric': 0.06704746362029104, 'fraction_numerical': 0.0027199782401740786, 'mean_word_length': 4.906827309236948, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5701797', 'n_tokens_mistral': 1947, 'n_tokens_neox': 1867, 'n_words': 904}