def main():
    s = NsxClient(nsxraml_file,
                  nsxmanager,
                  nsx_username,
                  nsx_password,
                  debug=False)

    prep_response = cluster_prep(s, 'domain-c26')
    s.view_response(prep_response)
    wait_for_job_completion(s,
                            prep_response['objectId'],
                            completion_status='COMPLETED')
vdn_scope_dict_list = [scope_dict for scope_dict in vdn_scopes['vdnScopes'].items()]
vdn_scope = [scope[1]['objectId'] for scope in vdn_scope_dict_list if scope[1]['name'] == TRANSPORT_ZONE][0]

# get a template dict for the lswitch create
lswitch_create_dict = client_session.extract_resource_body_schema('logicalSwitches', 'create')
client_session.view_body_dict(lswitch_create_dict)

# fill the details for the new lswitch in the body dict
lswitch_create_dict['virtualWireCreateSpec']['controlPlaneMode'] = 'UNICAST_MODE'
lswitch_create_dict['virtualWireCreateSpec']['name'] = 'TestLogicalSwitch1'
lswitch_create_dict['virtualWireCreateSpec']['tenantId'] = 'Tenant1'

# create new lswitch
new_ls = client_session.create('logicalSwitches', uri_parameters={'scopeId': vdn_scope},
                               request_body_dict=lswitch_create_dict)
client_session.view_response(new_ls)

# list all logical switches
all_lswitches = client_session.read('logicalSwitchesGlobal')
client_session.view_response(all_lswitches)

# list all logical switches in transport Zone
tz_lswitches = client_session.read('logicalSwitches', uri_parameters={'scopeId': vdn_scope})
client_session.view_response(tz_lswitches)

# Read the properties of the new logical switch
new_ls_props = client_session.read('logicalSwitch', uri_parameters={'virtualWireID': new_ls['objectId']})
client_session.view_response(new_ls_props)

time.sleep(5)
Exemple #3
0
lswitch_id3 = 'blaar'

# find the objectId of the Scope with the name of the Transport Zone
vdn_scopes = client_session.read('vdnScopes', 'read')['body']
vdn_scope_dict_list = [
    scope_dict for scope_dict in vdn_scopes['vdnScopes'].items()
]
vdn_scope = [
    scope[1]['objectId'] for scope in vdn_scope_dict_list
    if scope[1]['name'] == TRANSPORT_ZONE
][0]

# Read the properties of the logical switch
new_ls_props = client_session.read(
    'logicalSwitch', uri_parameters={'virtualWireID': lswitch_id1})
client_session.view_response(new_ls_props)

# Read the property of an not existing virtual wire ID
try:
    new_ls_props = client_session.read(
        'logicalSwitch', uri_parameters={'virtualWireID': lswitch_id2})
    client_session.view_response(new_ls_props)
except NsxError as e:
    print "### caught exception !!!!"
    print e.status, e.msg

# Try to read properties using a invalid virtual wire Id
try:
    new_ls_props = client_session.read(
        'logicalSwitch', uri_parameters={'virtualWireID': lswitch_id3})
    client_session.view_response(new_ls_props)
TRANSPORT_ZONE = 'TZ1'

client_session = NsxClient(nsxraml_file, nsxmanager, nsx_username, nsx_password, debug=True, fail_mode='raise')

lswitch_id1 = 'virtualwire-237'
lswitch_id2 = 'virtualwire-999'
lswitch_id3 = 'blaar'

# find the objectId of the Scope with the name of the Transport Zone
vdn_scopes = client_session.read('vdnScopes', 'read')['body']
vdn_scope_dict_list = [scope_dict for scope_dict in vdn_scopes['vdnScopes'].items()]
vdn_scope = [scope[1]['objectId'] for scope in vdn_scope_dict_list if scope[1]['name'] == TRANSPORT_ZONE][0]

# Read the properties of the logical switch
new_ls_props = client_session.read('logicalSwitch', uri_parameters={'virtualWireID': lswitch_id1})
client_session.view_response(new_ls_props)

# Read the property of an not existing virtual wire ID
try:
    new_ls_props = client_session.read('logicalSwitch', uri_parameters={'virtualWireID': lswitch_id2})
    client_session.view_response(new_ls_props)
except NsxError as e:
    print "### caught exception !!!!"
    print e.status, e.msg


# Try to read properties using a invalid virtual wire Id
try:
    new_ls_props = client_session.read('logicalSwitch', uri_parameters={'virtualWireID': lswitch_id3})
    client_session.view_response(new_ls_props)
except NsxError as e:
Exemple #5
0
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
# TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.

__author__ = 'yfauser'

from nsxramlclient.client import NsxClient
from config import *

client_session = NsxClient(nsxraml_file, nsxmanager, nsx_username, nsx_password, debug=False)

# Get specific scope Information
response_scope1 = client_session.read('vdnScope', uri_parameters={'scopeId': 'vdnscope-1'})
client_session.view_response(response_scope1)

# Get all scopes
response_all_scopes = client_session.read('vdnScopes')
client_session.view_response(response_all_scopes)

# Add a scope
create_body = client_session.extract_resource_body_schema('vdnScopes', 'create')
client_session.view_body_dict(create_body)

create_body['vdnScope']['clusters']['cluster']['cluster']

#create_response = client_session.create('vdnScopes', request_body_dict=create_body)

#TODO: Complete the tests for Scopes
Exemple #6
0
__author__ = 'yfauser'

from tests.config import *
from nsxramlclient.client import NsxClient
import time

client_session = NsxClient(nsxraml_file,
                           nsxmanager,
                           nsx_username,
                           nsx_password,
                           debug=False)

# Change the fabric UDP Port to different values (VXLAN standard value)
update_udp_port_response = client_session.update(
    'vdnConfigUDPUpdate', uri_parameters={'portNumber': '4789'})
client_session.view_response(update_udp_port_response)

time.sleep(5)

# Get the configured UDP Port for VXLAN in the Fabric
upd_port_response = client_session.read('vdnConfigUDP')
client_session.view_response(upd_port_response)

time.sleep(5)

# change the UDP Port back to the NSX Default
update_udp_port_response = client_session.update(
    'vdnConfigUDPUpdate', uri_parameters={'portNumber': '8472'})
client_session.view_response(update_udp_port_response)
def main():
    s = NsxClient(nsxraml_file, nsxmanager, nsx_username, nsx_password, debug=False)

    prep_response = cluster_prep(s, 'domain-c26')
    s.view_response(prep_response)
    wait_for_job_completion(s, prep_response['objectId'], completion_status='COMPLETED')
Exemple #8
0
vdn_scope_dict_list = [scope_dict for scope_dict in vdn_scopes['vdnScopes'].items()]
vdn_scope = [scope[1]['objectId'] for scope in vdn_scope_dict_list if scope[1]['name'] == TRANSPORT_ZONE][0]

# get a template dict for the lswitch create
lswitch_create_dict = client_session.extract_resource_body_example('logicalSwitches', 'create')
client_session.view_body_dict(lswitch_create_dict)

# fill the details for the new lswitch in the body dict
lswitch_create_dict['virtualWireCreateSpec']['controlPlaneMode'] = 'UNICAST_MODE'
lswitch_create_dict['virtualWireCreateSpec']['name'] = 'TestLogicalSwitch1'
lswitch_create_dict['virtualWireCreateSpec']['tenantId'] = 'Tenant1'

# create new lswitch
new_ls = client_session.create('logicalSwitches', uri_parameters={'scopeId': vdn_scope},
                               request_body_dict=lswitch_create_dict)
client_session.view_response(new_ls)

# list all logical switches
all_lswitches = client_session.read('logicalSwitchesGlobal')
client_session.view_response(all_lswitches)

# list all logical switches in transport Zone
tz_lswitches = client_session.read('logicalSwitches', uri_parameters={'scopeId': vdn_scope})
client_session.view_response(tz_lswitches)

# Read the properties of the new logical switch
new_ls_props = client_session.read('logicalSwitch', uri_parameters={'virtualWireID': new_ls['objectId']})
client_session.view_response(new_ls_props)

time.sleep(5)