当前位置: 首页>>代码示例>>Python>>正文


Python ovh.Client方法代码示例

本文整理汇总了Python中ovh.Client方法的典型用法代码示例。如果您正苦于以下问题:Python ovh.Client方法的具体用法?Python ovh.Client怎么用?Python ovh.Client使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ovh的用法示例。


在下文中一共展示了ovh.Client方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import ovh [as 别名]
# 或者: from ovh import Client [as 别名]
def __init__(self):
        ''' Construct inventory '''

        # Configuration file
        config_file = 'ovh_public_cloud.conf'
        current_path = os.path.dirname(os.path.abspath(__file__))

        # Configuration reading
        self.config = ConfigParser.RawConfigParser()
        self.config.read('%s/%s' % (current_path, config_file))

        # OVH API client
        self.api = ovh.Client(config_file='%s/%s' % (current_path, config_file))

        # Generate inventory
        self.generate() 
开发者ID:irongomme,项目名称:ansible_ovh_public_cloud,代码行数:18,代码来源:ovh_public_cloud.py

示例2: __init__

# 需要导入模块: import ovh [as 别名]
# 或者: from ovh import Client [as 别名]
def __init__(self, ovh_client=None):
        """
        Constructor
        :param ovh_client: the ovh client you want to use. If none use environment variable to initialize the ovh client.
        """

        if ovh_client is None:
            self.ovh_client = ovh.Client(endpoint=os.getenv('endpoint', 'ovh-eu'),
                                         application_key=os.getenv('application_key'),
                                         application_secret=os.getenv('application_secret'),
                                         consumer_key=os.getenv('consumer_key')
                                         )
        else:
            self.ovh_client = ovh_client

        if not InterfaceBase.logger:
            InterfaceBase.logger = logging.getLogger('InterfaceBase')
            InterfaceBase.logger.addHandler(logging.StreamHandler())

            if os.getenv('DEBUG'):
                InterfaceBase.logger.setLevel(logging.DEBUG)
            else:
                InterfaceBase.logger.setLevel(logging.INFO)
            self.logger = InterfaceBase.logger 
开发者ID:TraceSoftwareInternational,项目名称:ovh-ssl-iplb,代码行数:26,代码来源:InterfaceBase.py

示例3: __init__

# 需要导入模块: import ovh [as 别名]
# 或者: from ovh import Client [as 别名]
def __init__(self, appkey, appsecret, consumerkey="", endpoint='soyoustart-eu', ipxeBase="https://bootstrap.gig.tech/ipxe/master"):
        # if consumerkey=="":
        #     client = ovh.Client(endpoint=endpoint)
        #     ck = client.new_consumer_key_request()
        #     ck.add_recursive_rules(ovh.API_READ_WRITE, '/')
        print("OVH INIT")
        self.client = ovh.Client(
            endpoint=endpoint,
            application_key=appkey,
            application_secret=appsecret,
            consumer_key=consumerkey,
        )

        id = "ovhclient_%s" % consumerkey
        self.cache = j.data.cache.get(
            id=id,
            db=j.data.kvs.getRedisStore())
        self.ipxeBase = ipxeBase.rstrip("/") 
开发者ID:Jumpscale,项目名称:lib9,代码行数:20,代码来源:OVHFactory.py

示例4: getOvhClient

# 需要导入模块: import ovh [as 别名]
# 或者: from ovh import Client [as 别名]
def getOvhClient(ansibleModule):
    endpoint = ansibleModule.params.get('endpoint')
    application_key = ansibleModule.params.get('application_key')
    application_secret = ansibleModule.params.get('application_secret')
    consumer_key = ansibleModule.params.get('consumer_key')

    return ovh.Client(
        endpoint=endpoint,
        application_key=application_key,
        application_secret=application_secret,
        consumer_key=consumer_key
    ) 
开发者ID:YoLoveLife,项目名称:DevOps,代码行数:14,代码来源:ovh_ip_loadbalancing_backend.py

示例5: get_ck_validation

# 需要导入模块: import ovh [as 别名]
# 或者: from ovh import Client [as 别名]
def get_ck_validation(endpoint, application_key, application_secret):
    """Return a validation request with full access to the API."""
    client = ovh.Client(endpoint=endpoint, application_key=application_key,
                        application_secret=application_secret)
    ck = client.new_consumer_key_request()
    ck.add_recursive_rules(ovh.API_READ_WRITE, '/')
    validation = ck.request()

    return validation 
开发者ID:ovh,项目名称:ovh-cli,代码行数:11,代码来源:utils.py

示例6: get_ovh_client

# 需要导入模块: import ovh [as 别名]
# 或者: from ovh import Client [as 别名]
def get_ovh_client(self):
        """Get the OVH client."""
        try:
            client = ovh.Client()
        except InvalidRegion:
            self.error('The configuration was not found.')
            self.error('Please use `ovh setup init` to create it.')
            self.exit()

        return client 
开发者ID:ovh,项目名称:ovh-cli,代码行数:12,代码来源:context.py

示例7: get_credentials

# 需要导入模块: import ovh [as 别名]
# 或者: from ovh import Client [as 别名]
def get_credentials():
    """This function is used to obtain an authentication token.
    It should only be called once."""
    client = ovh.Client()
    access_rules = [
        {'method': 'GET', 'path': '/cloud/*'},
        {'method': 'PUT', 'path': '/cloud/*'},
        {'method': 'POST', 'path': '/cloud/*'},
        {'method': 'DELETE', 'path': '/cloud/*'},
    ]
    validation = client.request_consumerkey(access_rules)
    print("Your consumer key is {}".format(validation['consumerKey']))
    print("Please visit {} to validate".format(validation['validationUrl'])) 
开发者ID:captnbp,项目名称:mypaas,代码行数:15,代码来源:ovh_vrack.py

示例8: get_credentials

# 需要导入模块: import ovh [as 别名]
# 或者: from ovh import Client [as 别名]
def get_credentials():
    """This function is used to obtain an authentication token.
    It should only be called once."""
    client = ovh.Client()
    access_rules = [
        {'method': 'GET', 'path': '/domain/*'},
        {'method': 'PUT', 'path': '/domain/*'},
        {'method': 'POST', 'path': '/domain/*'},
        {'method': 'DELETE', 'path': '/domain/*'},
    ]
    validation = client.request_consumerkey(access_rules)
    print("Your consumer key is {}".format(validation['consumerKey']))
    print("Please visit {} to validate".format(validation['validationUrl'])) 
开发者ID:captnbp,项目名称:mypaas,代码行数:15,代码来源:ovh_dns.py

示例9: get_ovh_client

# 需要导入模块: import ovh [as 别名]
# 或者: from ovh import Client [as 别名]
def get_ovh_client(key, secret, consumer):
    """Get an ovh client
    """
    client = ovh.Client(
            endpoint='ovh-eu',
            application_key=key,
            application_secret=secret,
            consumer_key=consumer,
    )
    return client 
开发者ID:samjy,项目名称:acmeclient,代码行数:12,代码来源:ovh_challenger.py

示例10: __init__

# 需要导入模块: import ovh [as 别名]
# 或者: from ovh import Client [as 别名]
def __init__(self, id, endpoint, application_key, application_secret,
                 consumer_key, *args, **kwargs):
        self.log = logging.getLogger('OvhProvider[{}]'.format(id))
        self.log.debug('__init__: id=%s, endpoint=%s, application_key=%s, '
                       'application_secret=***, consumer_key=%s', id, endpoint,
                       application_key, consumer_key)
        super(OvhProvider, self).__init__(id, *args, **kwargs)
        self._client = ovh.Client(
            endpoint=endpoint,
            application_key=application_key,
            application_secret=application_secret,
            consumer_key=consumer_key,
        ) 
开发者ID:github,项目名称:octodns,代码行数:15,代码来源:ovh.py

示例11: main

# 需要导入模块: import ovh [as 别名]
# 或者: from ovh import Client [as 别名]
def main():
    module = AnsibleModule(
        argument_spec = dict(
            description = dict(required=True),
            project_name = dict(required=True),
            state = dict(required=True),
        )
    )

    # Get parameters
    description = module.params.get('description')
    project_name = module.params.get('project_name')
    state = module.params.get('state')

    # Connect to OVH API
    client = ovh.Client()
   #checking Cloud projects
    result2 = client.get('/cloud/project')
    project_exist = False
    for project_id in result2:
	    project = client.get('/cloud/project/{}'.format(project_id))
	    if project_name == project['description']:
	        project_exist = True
		break
    #get vrack
    vrack_exist = False
    result2 = client.get('/vrack')
    if not result2:
        # create vrack
        create_vrack= client.post('/order/vrack/new')
        orderid=create_vrack['orderId']
        #pay vrack order by order Id
        vrack_pay = client.post('/me/order/{}/payWithRegisteredPaymentMean'.format(orderid),paymentMean='fidelityAccount')
        # check vrack order status
        order_stat_vrack = client.get('/me/order/{}/status'.format(orderid))
        counter=0
        while (order_stat_vrack!='delivered') and (counter!=5):  # This constructs an infinite loop
           counter+=1
	   order_stat_vrack = client.get('/me/order/{}/status'.format(orderid))
           time.sleep(40)

        if counter == 5:
           print 'Vrack creation timeout'
           exit
        if order_stat_vrack=='delivered':
            vrack_status='DONE'
            vrack_id = client.get('/vrack')
            vrack_details = client.get('/vrack/{}'.format(vrack_id))
            module.exit_json(changed=True, vrack=vrack_id)
    else:
        vrack_exist= True
        #check vrack details
        for vracks_id in result2:
            vrack_details = client.get('/vrack/{}'.format(vracks_id))
            vrack_id=vracks_id
    	    print ('There is an available vrack:{}'.format(vrack_id))
            module.exit_json(changed=False, vrack=vrack_id)
    	    break
# import module snippets 
开发者ID:captnbp,项目名称:mypaas,代码行数:61,代码来源:ovh_vrack.py

示例12: main

# 需要导入模块: import ovh [as 别名]
# 或者: from ovh import Client [as 别名]
def main():
    module = AnsibleModule(
        argument_spec = dict(
            description = dict(required=True),
            voucher = dict(required=False),
            state = dict(default='present', choices=['present', 'absent']),
        )
    )

    # Get parameters
    description = module.params.get('description')
    voucher = module.params.get('voucher')
    state = module.params.get('state')

    # Connect to OVH API
    client = ovh.Client()

    # Check that the project exists
    projects = client.get('/cloud/project')
    project_exist = False
    for project_id in projects:
        project = client.get('/cloud/project/{}'.format(project_id))
        if description == project['description']:
            project_exist = True
            break
	
    # Remove a project
    if state == 'absent':
        if not project_exist:
            module.exit_json(changed=False)
        else:
            # Remove the project
            client.delete('/cloud/project/{}'.format(project_id))
            module.exit_json(changed=True)

    # Add a project, no update
    if state == 'present':
        if not project_exist:
            newproject = client.post('/cloud/createProject'.format(project), description=description, voucher=voucher)
            module.exit_json(changed=True, project=newproject)
        else:
            module.exit_json(changed=False, project=project)

# import module snippets 
开发者ID:captnbp,项目名称:mypaas,代码行数:46,代码来源:ovh_cloud_project.py

示例13: main

# 需要导入模块: import ovh [as 别名]
# 或者: from ovh import Client [as 别名]
def main():
    module = AnsibleModule(
        argument_spec = dict(
            name = dict(required=False),
            project_name = dict(required=True),
            description = dict(required=False),
            region = dict(required=True),
            state = dict(default='present', choices=['present', 'absent', 'reset']),
        )
    )

    # Get parameters
    name = module.params.get('name')
    project_name = module.params.get('project_name')
    description = module.params.get('description')
    region = module.params.get('region')
    state = module.params.get('state')

    # Connect to OVH API
    client = ovh.Client()

    # Check that the project exists and get its id
    projects = client.get('/cloud/project')
    project_exist = False
    for project_id in projects:
        project = client.get('/cloud/project/{}'.format(project_id))
        if project_name == project['description']:
            project_exist = True
            break
    if not project_exist:
        module.fail_json(msg='Project {} does not exist'.format(project))
	
    # Check if the user exists
    users = client.get('/cloud/project/{}/user'.format(project_id))
    user_exist = False
    for user in users:
        if name == user['username']:
            user_exist = True
            break
        elif description == user['description']:
            user_exist = True
            break
    if user_exist:
        openrc = client.get('/cloud/project/{}/user/{}/openrc'.format(project_id,user['id']), region=region )
        os_auth_url = re.search('export OS_AUTH_URL=(.*)\n', openrc['content'], re.IGNORECASE).group(1)
        os_tenant_id = re.search('export OS_TENANT_ID=(.*)\n', openrc['content'], re.IGNORECASE).group(1)
        os_tenant_name = re.search('export OS_TENANT_NAME=\"(.*)\"\n', openrc['content'], re.IGNORECASE).group(1)
        os_username = re.search('export OS_USERNAME=\"(.*)\"\n', openrc['content'], re.IGNORECASE).group(1)
        os_region = re.search('export OS_REGION_NAME=\"(.*)\"\n', openrc['content'], re.IGNORECASE).group(1)
        module.exit_json(changed=False, openrc={ 'os_auth_url': os_auth_url, 'os_tenant_id': os_tenant_id, 'os_tenant_name': os_tenant_name, 'os_username': os_username, 'os_region': os_region })
    else:
        module.fail_json(msg="User {} with description {} not found".format(name, description))

# import module snippets 
开发者ID:captnbp,项目名称:mypaas,代码行数:56,代码来源:ovh_openrc.py


注:本文中的ovh.Client方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。