Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: cloudify-incubator/cloudify-nsx-t-plugin
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.2.2
Choose a base ref
...
head repository: cloudify-incubator/cloudify-nsx-t-plugin
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 8 commits
  • 26 files changed
  • 1 contributor

Commits on Aug 25, 2020

  1. CZ-98 Add support for lookup the network for vm based on input provid… (

    #8)
    
    * CZ-98 Add support for lookup the network for vm based on input provided by user
    
    * CZ-98 Update logging message
    
    * CZ-98 Fix some issues and add support ip version checking
    
    * CZ-98 Update networks
    
    * CZ-98 Fix grapping ports for vifs
    
    * CZ-98 Update the fetching network process for nsxt server
    
    * CZ-98 Update network name to use id instead
    
    * CZ-98 Update Readme file
    mabuaisha authored Aug 25, 2020
    Copy the full SHA
    8efd1c8 View commit details

Commits on Aug 27, 2020

  1. Cz 97 use static binding between segment and server (#9)

    * CZ-97 Add support for static bindings between server and segments
    
    * CZ-97 Set unique id for segment instance
    
    * CZ-97 Bump version to 0.3.1
    
    * CZ-97 Fix issue with plugin sdk and static bindings
    
    * Add support for dhcp status binding
    
    * CZ-97 Fix flake8 issue
    
    * CZ-97 Update static binding code
    
    * CZ-97 Remove unused imports
    
    * CZ-97 Fix some issues
    
    * CZ-97 Fix issue with creating dhcp binding settings and handling errors
    
    * CZ-97 Fix some issues for plugin
    
    * CZ-97 Update resource deletion process
    
    * CZ-97 Update handling state for static binding
    
    * CZ-97 Update deletion process for static bindings
    
    * CZ-97 Add some fixes
    
    * CZ-97 Update the segment code
    mabuaisha authored Aug 27, 2020
    Copy the full SHA
    b63a69b View commit details
  2. Update readme file

    Mohammed AbuAisha committed Aug 27, 2020
    Copy the full SHA
    7c2a81f View commit details
  3. Update README.md

    mabuaisha authored Aug 27, 2020
    Copy the full SHA
    26965dd View commit details

Commits on Aug 29, 2020

  1. CZ-101 Change the address_server to string and update blueprint (#10)

    * CZ-101 Change the address_server to string and update blueprint
    
    * CZ-100 Retry instead of raise failure for fetching vm ports
    mabuaisha authored Aug 29, 2020
    Copy the full SHA
    9e6b5f2 View commit details

Commits on Oct 25, 2020

  1. Rd 282 add unit tests for nsxt plugin (#12)

    * RD-282: Add  unit tests for nsxt plugin
    
    * RD-282 Update circleci config file
    mabuaisha authored Oct 25, 2020
    Copy the full SHA
    c933a5a View commit details

Commits on Oct 26, 2020

  1. Update version and url (#13)

    mabuaisha authored Oct 26, 2020
    Copy the full SHA
    0c920c5 View commit details
  2. Update blueprint (#14)

    mabuaisha authored Oct 26, 2020
    Copy the full SHA
    ea78f0d View commit details
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -60,6 +60,7 @@ commands:
- run: |
~/venv/bin/pip install -Ur test-requirements.txt
~/venv/bin/pip install -Ur dev-requirements.txt
~/venv/bin/pip install -e .
- run: |
~/venv/bin/nosetests \
163 changes: 160 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -15,6 +15,14 @@ The plugin provides the following features for interacting with NSX-T API:
- Create Tier1 Gateway
- Delete Tier1 Gateway

4. Virtual Machine:
- List Virtual Machines
- List All Virtual Network Interface Associated with VM

5. DHCP Static Binding
- Create DHCP Static Binding
- Delete DHCP Static Binding

## Authentication with NSX-T

Each node template, has a `client_config` property which stores your account credentials.
@@ -59,6 +67,7 @@ Node instances of any of the types defined in this plugin are set with the follo
* `resource_config`: The resource configuration returned from resource creation



## Node Types

### **cloudify.nodes.nsx-t.DhcpServerConfig**
@@ -156,7 +165,6 @@ This node type refers to a Segment.
* `cloudify.relationships.nsx-t.segment_connected_to_dhcp_server_config`:
* `cloudify.nodes.nsx-t.DhcpServerConfig`: Depend on DHCP Server Config


### Segment Example

```yaml
@@ -224,7 +232,6 @@ This node type refers to a Tier1 Gateway.
* `children`: _List_: subtree for this type within policy tree containing nested elements.
* `tags`: _List_: Opaque identifiers meaningful to the API user


### Tier1 Example

```yaml
@@ -243,7 +250,157 @@ This node type refers to a Tier1 Gateway.
tier0_path:{ get_input: tier0_path }
```

Note: The configuration for the above resources are based on the NSX-T API documentation:
### **cloudify.types.nsx-t.inventory.VirtualMachine**

This node type refers to a Virtual Machine resource.

**Resource Config**
* `vm_id`: _String_. _Not required_. External VM ID.
* `vm_name`: _String_. _Not required_. The Name of VM.
* `network_id`: _String_. _Required_. The network id to get ips from.

### Runtime Properties

Beside the common runtime properties, the `VirtualMachine` node type also expose the following two runtime properties:
* `networks`: _Dict_. Dictionary of all virtual network interfaces attached to the current vm.

```json
{
"Network adapter 1":{
"device_key":"4000",
"device_name":"Network adapter 1",
"external_id":"502a627a-2b5a-0f27-ace9-44a9b66d9692-4000",
"host_id":"55174c3a-412e-4083-b2f1-cf2cd265ef5b",
"ip_address_info":[
{
"ip_addresses":[
"192.168.11.100",
"2001:ab8::250:56ff:feaa:9160",
"fe80::250:56ff:feaa:9160"
],
"source":"VM_TOOLS"
}
],
"lport_attachment_id":"3e660c66-7a8e-45a4-8c82-ffe3afcc7de2",
"mac_address":"00:50:56:aa:91:60",
"owner_vm_id":"502a627a-2b5a-0f27-ace9-44a9b66d9692",
"owner_vm_type":"REGULAR",
"vm_local_id_on_host":"49",
"_last_sync_time":1598369175580,
"display_name":"Network adapter 1",
"resource_type":"VirtualNetworkInterface",
"ipv4_addresses":[
"192.168.11.100"
],
"ipv6_addresses":[
"2001:ab8::250:56ff:feaa:9160",
"fe80::250:56ff:feaa:9160"
]
}
}
```

* The value of `network_id` is the exposed as runtime property with the following value:
```json
{
"device_key":"4001",
"device_name":"Network adapter 2",
"external_id":"502a479c-e3f4-2ace-daab-4d874e8cc8b6-4001",
"host_id":"55174c3a-412e-4083-b2f1-cf2cd265ef5b",
"ip_address_info":[
{
"ip_addresses":[
"192.168.234.100",
"fe80::250:56ff:feaa:34fd"
],
"source":"VM_TOOLS"
}
],
"lport_attachment_id":"a9e26ccb-eb63-4098-bb7d-a93b6257b33f",
"mac_address":"00:50:56:aa:34:fd",
"owner_vm_id":"502a479c-e3f4-2ace-daab-4d874e8cc8b6",
"owner_vm_type":"REGULAR",
"vm_local_id_on_host":"22",
"_last_sync_time":1597825357509,
"display_name":"Network adapter 2",
"resource_type":"VirtualNetworkInterface"
}
```

### VirtualMachine Example

```yaml
virtual_machine_inventory:
type: cloudify.nodes.nsx-t.inventory.VirtualMachine
properties:
client_config:
host: { get_input: host }
port: { get_input: port }
username: { get_input: username }
password: { get_input: password }
resource_config:
vm_name: { get_attribute: [ host, name ] }
network_id: { get_attribute: [ segment, id ] }
relationships:
- type: cloudify.relationships.nsx-t.inventory_connected_to_server
target: host
- type: cloudify.relationships.depends_on
target: segment
```

## Vsphere Server Relationships

We support a relationship called `cloudify.relationships.server_connected_to_segment`
that support dhcp static binding where a static ip attached to the server that has the following operations:

* `cloudify.interfaces.relationship_lifecycle.preconfigure`:
* `network_unique_id`: _String_. The uuid of segment must be passed which will be exposed as runtime property for Segment node
* `ip_v4_address`: _String_. The ip address v4 that is going to be assigned to the server.
* `ip_v6_address`: _String_. The ip address v6 that is going to be assigned to the server.

Notes:
1. One or both of `ip_v4_address`, `ip_v6_address` must be provided otherwise the operation will raise error
2. If `network_unique_id` is not provided, then plugin will try to lookup it internally.

* `cloudify.interfaces.relationship_lifecycle.unlink`: This operation will remove all the static dhcp binding created before

```yaml
host:
type: cloudify.vsphere.nodes.Server
properties:
client_config:
host: { get_input: host }
port: { get_input: port }
username: { get_input: username }
password: { get_input: password }
agent_config:
install_method: none
allowed_clusters: { get_input: allowed_clusters }
server:
name: { get_input: server_name }
template: { get_input: template }
cpus: 1
memory: 1024
networking:
connect_networks:
- name: { get_attribute: [ segment, name ] }
nsx_t_switch: { get_input: nsx_t_switch }
use_dhcp: true
relationships:
- type: cloudify.relationships.server_connected_to_segment
target: segment
target_interfaces:
cloudify.interfaces.relationship_lifecycle:
preconfigure:
inputs:
network_unique_id: { get_attribute: [ segment, unique_id ] }
ip_v4_address: { get_input: ip_address }
```

Notes: The configuration for the above resources are based on the NSX-T API documentation:
1. [Segment Endpoints](https://vdc-download.vmware.com/vmwb-repository/dcr-public/9e1c6bcc-85db-46b6-bc38-d6d2431e7c17/30af91b5-3a91-4d5d-8ed5-a7d806764a16/api_includes/policy_networking_connectivity_segment.html)
2. [DHCP Server Endpoints](https://vdc-download.vmware.com/vmwb-repository/dcr-public/9e1c6bcc-85db-46b6-bc38-d6d2431e7c17/30af91b5-3a91-4d5d-8ed5-a7d806764a16/api_includes/policy_networking_ip_management_dhcp_dhcp_server_configs.html)
3. [Tier1 Endpoints](https://vdc-download.vmware.com/vmwb-repository/dcr-public/9e1c6bcc-85db-46b6-bc38-d6d2431e7c17/30af91b5-3a91-4d5d-8ed5-a7d806764a16/api_includes/policy_networking_connectivity_tier-1_gateways_tier-1_gateways.html)
4. [Virtual Interface Endpoints](https://vdc-download.vmware.com/vmwb-repository/dcr-public/9e1c6bcc-85db-46b6-bc38-d6d2431e7c17/30af91b5-3a91-4d5d-8ed5-a7d806764a16/api_includes/system_administration_configuration_fabric_inventory_virtual_interfaces.html)
5. [Virtual Machines Endpoints](https://vdc-download.vmware.com/vmwb-repository/dcr-public/9e1c6bcc-85db-46b6-bc38-d6d2431e7c17/30af91b5-3a91-4d5d-8ed5-a7d806764a16/api_includes/method_ListVirtualMachines.html)
6. [DHCP Static Binding Endpoints](https://vdc-download.vmware.com/vmwb-repository/dcr-public/9e1c6bcc-85db-46b6-bc38-d6d2431e7c17/30af91b5-3a91-4d5d-8ed5-a7d806764a16/api_includes/method_CreateOrReplaceInfraSegmentDhcpStaticBinding.html)
47 changes: 45 additions & 2 deletions examples/blueprint.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
tosca_definitions_version: cloudify_dsl_1_3

imports:
- http://www.getcloudify.org/spec/cloudify/5.1.0.dev1/types.yaml
- http://www.getcloudify.org/spec/cloudify/5.1.0/types.yaml
- plugin:cloudify-nsx-t-plugin
- plugin:cloudify-vsphere-plugin

@@ -49,6 +49,14 @@ inputs:
type: string
default: Cluster

wait_ip:
type: boolean
default: true

ip_v4_address:
type: string
default: '192.168.11.95'

dsl_definitions:

client_config: &client_config
@@ -100,6 +108,7 @@ node_templates:
agent_config:
install_method: none
allowed_clusters: { get_input: allowed_clusters }
wait_ip: { get_input: wait_ip }
server:
name: { get_input: server_name }
template: { get_input: template }
@@ -111,5 +120,39 @@ node_templates:
nsx_t_switch: { get_input: nsx_t_switch }
use_dhcp: true
relationships:
- type: cloudify.relationships.depends_on
- type: cloudify.relationships.server_connected_to_segment
target: segment
target_interfaces:
cloudify.interfaces.relationship_lifecycle:
preconfigure:
inputs:
network_unique_id: { get_attribute: [ segment, unique_id ] }
ip_v4_address: { get_input: ip_v4_address }


virtual_machine_inventory:
type: cloudify.nodes.nsx-t.inventory.VirtualMachine
properties:
client_config: *client_config
resource_config:
vm_name: { get_attribute: [ host, name ] }
network_id: { get_attribute: [ segment, id ] }
relationships:
- type: cloudify.relationships.nsx-t.inventory_connected_to_server
target: host

outputs:
target_network:
value: { get_attribute: [ virtual_machine_inventory, { get_attribute: [ segment, id ] } ] }

networks:
value: { get_attribute: [ virtual_machine_inventory, networks ] }

server_mac_address:
value: { get_attribute: [ virtual_machine_inventory, { get_attribute: [ segment, id ] }, mac_address ] }

server_ipv4_address:
value: { get_attribute: [ virtual_machine_inventory, { get_attribute: [ segment, id ] }, ipv4_addresses, 0 ] }

server_ipv6_address:
value: { get_attribute: [ virtual_machine_inventory, { get_attribute: [ segment, id ] }, ipv6_addresses, 0 ] }
2 changes: 1 addition & 1 deletion nsx_t_plugin/decorators.py
Original file line number Diff line number Diff line change
@@ -35,8 +35,8 @@ def _decorator(func):
@wraps(func)
def wrapper(**kwargs):
_ctx = kwargs.pop('ctx', CloudifyContext)
_ctx = get_ctx_object(_ctx)
operation_name = _ctx.operation.name
_ctx = get_ctx_object(_ctx)
kwargs['nsx_t_resource'] = populate_nsx_t_instance_from_ctx(
class_decl,
_ctx,
6 changes: 3 additions & 3 deletions nsx_t_plugin/dhcp_server/dhcp_server_config.py
Original file line number Diff line number Diff line change
@@ -27,9 +27,9 @@ def _update_tier_1_gateway(client_config, tier1_gateway_id, dhcp_server_paths):
},
logger=ctx.logger
)
tier1_object = tier1.get()
tier1_object = tier1.get(to_dict=False)
tier1_object.dhcp_config_paths = dhcp_server_paths
tier1.update(tier1_object)
tier1.update(tier1_gateway_id, tier1_object)


def _link_dhcp_server_to_tier_1(client_config, tier1_gateway_id):
@@ -85,4 +85,4 @@ def stop(nsx_t_resource):

@with_nsx_t_client(DhcpServerConfig)
def delete(nsx_t_resource):
nsx_t_resource.delete()
nsx_t_resource.delete(nsx_t_resource.resource_id)
Loading