コード例 #1
0
    def __init__(self, zcc_url, ca_file=None):
        _url = urlparse.urlparse(zcc_url)

        _ssl_enabled = False

        if _url.scheme == 'https':
            _ssl_enabled = True
        elif ca_file:
            LOG.warning(
                "url is %(url)s which is not https "
                "but ca_file is configured to %(ca_file)s", {
                    'url': zcc_url,
                    'ca_file': ca_file
                })

        if _ssl_enabled and ca_file:
            self._conn = connector.ZVMConnector(_url.hostname,
                                                _url.port,
                                                ssl_enabled=_ssl_enabled,
                                                verify=ca_file)
        else:
            self._conn = connector.ZVMConnector(_url.hostname,
                                                _url.port,
                                                ssl_enabled=_ssl_enabled,
                                                verify=False)
コード例 #2
0
 def __init__(self, methodName='runTest'):
     super(ZVMConnectorTestCase, self).__init__(methodName)
     self.apibase = api_sample.APITestBase()
     self.restclient = connector.ZVMConnector(connection_type=CONN_REST,
                                              port=8888)
     self.sockclient = connector.ZVMConnector(connection_type=CONN_SOCKET)
     self.userid_rest = 'RESTT%03d' % (time.time() % 1000)
     self.userid_sock = 'SOCKT%03d' % (time.time() % 1000)
コード例 #3
0
ファイル: test_restclient.py プロジェクト: kevanlucc/feilong
 def __init__(self, methodName='runTest'):
     super(ZVMConnectorTestCase, self).__init__(methodName)
     rest_port = int(CONF.tests.restapi_url.split(':')[2].strip('/'))
     self.restclient = connector.ZVMConnector(connection_type=CONN_REST,
                                              port=rest_port)
     self.sockclient = connector.ZVMConnector(connection_type=CONN_SOCKET)
     self.userid_rest = 'RESTT%03d' % (time.time() % 1000)
     self.userid_sock = 'SOCKT%03d' % (time.time() % 1000)
     self.image_path = test_utils.TEST_IMAGE_LIST[0][1]
コード例 #4
0
    def __init__(self, zcc_url, ca_file=None):
        _url = urlparse.urlparse(zcc_url)

        _ssl_enabled = False

        if _url.scheme == 'https':
            _ssl_enabled = True
        elif ca_file:
            pass

        if _ssl_enabled and ca_file:
            self._conn = connector.ZVMConnector(_url.hostname, _url.port,
                                                ssl_enabled=_ssl_enabled,
                                                verify=ca_file, token_path="/etc/zvmsdk/token.dat")
        else:
            self._conn = connector.ZVMConnector(_url.hostname, _url.port,
                                                ssl_enabled=_ssl_enabled,
                                                verify=False, token_path="/etc/zvmsdk/token.dat")
コード例 #5
0
ファイル: utils.py プロジェクト: zhshuj/networking-zvm
    def __init__(self):
        _url = urlparse.urlparse(CONF.AGENT.cloud_connector_url)
        _ca_file = CONF.AGENT.zvm_cloud_connector_ca_file
        _token_file = CONF.AGENT.zvm_cloud_connector_token_file
        kwargs = {}
        if _url.scheme == 'https':
            kwargs['ssl_enabled'] = True
        else:
            kwargs['ssl_enabled'] = False

        if _token_file is not None:
            kwargs['token_path'] = _token_file

        if ((kwargs['ssl_enabled']) and (_ca_file is not None)):
            kwargs['verify'] = _ca_file
        else:
            kwargs['verify'] = False

        self._conn = connector.ZVMConnector(_url.hostname, _url.port, **kwargs)
コード例 #6
0
    def __init__(self):
        _url = urlparse.urlparse(CONF.zvm_cloud_connector_url)
        _ca_file = CONF.zvm_ca_file
        _token_path = CONF.zvm_token_path
        kwargs = {}
        # http or https
        if _url.scheme == 'https':
            kwargs['ssl_enabled'] = True
        else:
            kwargs['ssl_enabled'] = False

        # token file exist or not
        if _token_path:
            kwargs['token_path'] = _token_path

        # CA file exist or not
        if kwargs['ssl_enabled'] and _ca_file:
            kwargs['verify'] = _ca_file
        else:
            kwargs['verify'] = False

        self._conn = connector.ZVMConnector(_url.hostname, _url.port, **kwargs)
コード例 #7
0
 def __init__(self):
     self.client = connector.ZVMConnector(connection_type='socket',
                                          ip_addr=CONF.sdkserver.bind_addr,
                                          port=CONF.sdkserver.bind_port)
コード例 #8
0
ファイル: guest.py プロジェクト: wuhaijie-ibm/python-zvm-sdk
 def __init__(self):
     self.client = connector.ZVMConnector(connection_type='socket',
                                          ip_addr=CONF.sdkserver.bind_addr,
                                          port=CONF.sdkserver.bind_port)
     self.dd_semaphore = threading.BoundedSemaphore(
         value=CONF.wsgi.max_concurrent_deploy_capture)
コード例 #9
0
ファイル: del_vlan_v1s2.py プロジェクト: wngzhe/feilong
# Copyright 2017 IBM Corp.

from zvmconnector import connector
import os

print("Setup client: client=connector.ZVMConnector('9.60.18.170', 8080)\n")
client = connector.ZVMConnector('9.60.18.170', 8080)

print("Test: send_request('vswitch_get_list')")
list = client.send_request('vswitch_get_list')
print("Result: %s\n" % list)

GUEST_USERID = 'DEMOV1S2'

print(
    "Check generated image: send_request('guest_delete', '%s') % GUEST_USERID")
info = client.send_request('guest_delete', GUEST_USERID)
print('Result: %s\n' % info)

print(
    "Check generated image: send_request('image_query', '%s') % GUEST_USERID")
info = client.send_request('guest_get_definition_info', GUEST_USERID)
print('Result: %s\n' % info)

print('Completed\n')
コード例 #10
0
ファイル: create.py プロジェクト: wngzhe/feilong
GUEST_MEMORY = 1024         # in megabytes
GUEST_ROOT_DISK_SIZE = 3    # in gigabytes
DISK_POOL = 'ECKD:POOL3390'

# Image properties
IMAGE_PATH = '/data/rhel72eckd.img'
IMAGE_OS_VERSION = 'rhel7.2'

# Network properties
GUEST_IP_ADDR = '192.168.222.200'
GATEWAY = '192.168.222.1'
CIDR = '192.168.222.0/24'
VSWITCH_NAME = 'xcatvsw2'


sdk_client = connector.ZVMConnector(connection_type='rest', port='8080')


def terminate_guest(userid):
    """Destroy a virtual machine.

    Input parameters:
    :userid:   USERID of the guest, last 8 if length > 8
    """
    res = sdk_client.send_request('guest_delete', userid)
    if res and 'overallRC' in res and res['overallRC']:
        print("Error in guest_delete: %s" % res)


def describe_guest(userid):
    """Get virtual machine basic information.
コード例 #11
0
 def __init__(self):
     self.client = connector.ZVMConnector(CONF.sdkserver.bind_addr)
コード例 #12
0
 def __init__(self):
     self.client = connector.ZVMConnector(ip_addr='127.0.0.1',
                                          port=8888,
                                          connection_type='rest')
コード例 #13
0
""" 
sample code that deploys a VM.
"""

import os
import sys
import time

from zvmconnector import connector

client = connector.ZVMConnector(connection_type='rest', port=8080)


def delete_guest(userid):
    """ Destroy a virtual machine.

    Input parameters:
    :userid:            USERID of the guest, last 8 if length > 8
    """
    # Check if the guest exists.
    guest_list_info = client.send_request('guest_list')
    # the string 'userid' need to be coded as 'u'userid' in case of py2 interpreter.
    userid_1 = (unicode(userid, "utf-8") if sys.version[0] == '2' else userid)

    if userid_1 not in guest_list_info['output']:
        RuntimeError("Userid %s does not exist!" % userid)

    # Delete the guest.
    guest_delete_info = client.send_request('guest_delete', userid)

    if guest_delete_info['overallRC']: