-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* security rules basic structure #207 * security rules spec * security rules create and delete functionality * Fix sanity and doc * security rules update functionality * security rules info module * add integraioson test * security rules spec fixes * security rules spec fixes * security rules spec fixes * security rules spec fixes, rule update functionality * security rules requirements fixes * fix sanity * security rules requirements and spec generation fixes * security rules requirements and spec generation fixes * Add integration test * sanity fix * Add integration tests * security rules requirements and spec generation fixes * sanity fix * Add integration test * ad_rule -> vdi_rule * update protocols spec, ability to delete rule * update protocols spec * updates for protocols spec * updates for protocols spec * Fix integration test * updates for isolation rule * updates for app, ad quarantine rules * fix integraton * Nutanix Image Module (#211) * Image ansible module for creating images in PC * Image placement policy module and its info module (#214) * Image placement policy module * Add functionality to deattach all the categories from vm using flag remove_categories (#216) * Add functionality to remove all categories from vm * Update docs * Vm example minor fix * list functionality for address/service groups * black and isort fixes * black and isort fixes * black and isort fixes * black and isort fixes * update requirements * fixes * ADGroup fixes * ADGroup fixes * remove default values for fields which are updatable * Doc fix * allow all updates * allow all updates * Common spec for categories mapping * Formatting * Formatting changes * formatting * formatting * flake8 changes * Sanity fix * config changes * Update categories in tests * categories mapping * categories mapping optimizations * default_internal_policy fixes * default_internal_policy fixes * fixes for target categories updating * Fix tests * fixes for rules description * remove categories mapping and prject reference * Fix tests * fix integration * flake8 fix * black and isort fixes * black and isort fixes * examples fixes * isolation rule docs fixes * fix sanity * galaxy file changes * sanity fix * docs fixes * vm's create ova and clone example fixes * fix sanity * fix sanity * doc fixes * doc fixes * Setup config changes * fix test * Security info module fix * doc fix * Lint fixes * setup config changes * quarantine rule uuid changes * sanity fix * Update and info module for static routes (#221) Static routes module and info module * UUID changes * Changes for sanity and config * sanity fix * static routes minor formatting * setup config changes * formatting * Fix bug dynamic inventory bug due to load_params * changelog and readme updates * Docs changes * Change log changes * Update docs * Docs update * Minor fix Co-authored-by: Gevorg-Khachatryaan <Gevorg1050.1> Co-authored-by: alaa-bish <[email protected]> Co-authored-by: Gevorg Khachatryan <[email protected]> Co-authored-by: Yannick Struyf <[email protected]>
- Loading branch information
1 parent
8a8f0e5
commit f4174ea
Showing
75 changed files
with
6,147 additions
and
61 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# This file is part of Ansible | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
from __future__ import absolute_import, division, print_function | ||
|
||
__metaclass__ = type | ||
|
||
from .prism import Prism | ||
|
||
|
||
class AddressGroup(Prism): | ||
def __init__(self, module): | ||
resource_type = "/address_groups" | ||
super(AddressGroup, self).__init__(module, resource_type=resource_type) | ||
|
||
def get_uuid(self, value, key="name", raise_error=True, no_response=False): | ||
data = {"filter": "{0}=={1}".format(key, value), "length": 1} | ||
resp = self.list(data, raise_error=raise_error, no_response=no_response) | ||
entities = resp.get("entities") if resp else None | ||
if entities: | ||
for entity in entities: | ||
if entity["address_group"]["name"] == value: | ||
return entity["uuid"] | ||
return None | ||
|
||
|
||
# Helper functions | ||
|
||
|
||
def get_address_uuid(config, module): | ||
if "name" in config: | ||
address_group = AddressGroup(module) | ||
name = config["name"] | ||
uuid = address_group.get_uuid(name) | ||
if not uuid: | ||
error = "Address {0} not found.".format(name) | ||
return None, error | ||
elif "uuid" in config: | ||
uuid = config["uuid"] | ||
else: | ||
error = "Config {0} doesn't have name or uuid key".format(config) | ||
return None, error | ||
|
||
return uuid, None |
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,75 @@ | ||
# This file is part of Ansible | ||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
from __future__ import absolute_import, division, print_function | ||
|
||
from copy import deepcopy | ||
|
||
from .prism import Prism | ||
from .spec.categories_mapping import CategoriesMapping | ||
|
||
__metaclass__ = type | ||
|
||
|
||
class ImagePlacementPolicy(Prism): | ||
def __init__(self, module): | ||
resource_type = "/images/placement_policies" | ||
super(ImagePlacementPolicy, self).__init__(module, resource_type=resource_type) | ||
self.build_spec_methods = { | ||
"name": self._build_spec_name, | ||
"desc": self._build_spec_desc, | ||
"categories": CategoriesMapping.build_categories_mapping_spec, | ||
"remove_categories": CategoriesMapping.build_remove_all_categories_spec, | ||
"placement_type": self._build_spec_placement_type, | ||
"image_categories": self._build_spec_image_categories, | ||
"cluster_categories": self._build_spec_cluster_categories, | ||
} | ||
|
||
def _get_default_spec(self): | ||
return deepcopy( | ||
{ | ||
"api_version": "3.1.0", | ||
"metadata": { | ||
"kind": "image_placement_policy", | ||
}, | ||
"spec": { | ||
"name": None, | ||
"resources": { | ||
"image_entity_filter": { | ||
"params": {}, | ||
"type": "CATEGORIES_MATCH_ANY", | ||
}, | ||
"cluster_entity_filter": { | ||
"params": {}, | ||
"type": "CATEGORIES_MATCH_ANY", | ||
}, | ||
}, | ||
}, | ||
} | ||
) | ||
|
||
def _build_spec_name(self, payload, name): | ||
payload["spec"]["name"] = name | ||
return payload, None | ||
|
||
def _build_spec_desc(self, payload, desc): | ||
payload["spec"]["description"] = desc | ||
return payload, None | ||
|
||
def _build_spec_placement_type(self, payload, type): | ||
if type == "hard": | ||
payload["spec"]["resources"]["placement_type"] = "EXACTLY" | ||
else: | ||
payload["spec"]["resources"]["placement_type"] = "AT_LEAST" | ||
return payload, None | ||
|
||
def _build_spec_image_categories(self, payload, category_mappings): | ||
payload["spec"]["resources"]["image_entity_filter"][ | ||
"params" | ||
] = category_mappings | ||
return payload, None | ||
|
||
def _build_spec_cluster_categories(self, payload, category_mappings): | ||
payload["spec"]["resources"]["cluster_entity_filter"][ | ||
"params" | ||
] = category_mappings | ||
return payload, None |
Oops, something went wrong.