def add_server(server_ip,
               server_name,
               config_id,
               profile='DNS_DHCP_SERVER_60',
               properties='password=bluecat|connected=true|upgrade=False'):
    """
    Add server
    :param server_ip: server ip
    :param server_name: server name
    :param config_id: configuration id
    :param profile: ADONIS_1200, ADONIS_XMB3
    :param properties: contain password, servicesIPv4Address...
    :return: server_id
    """
    try:
        properties = parse_properties(properties)
        server_id = g.user.get_api()._api_client.service.addServer(
            config_id, server_name, server_ip, server_name.replace("_", ""),
            profile, properties)
        start = time.time()
        max_timeout = 30
        while time.time() - start < max_timeout:
            try:
                g.user.logger.debug(
                    f"Check time out add server {server_name} server_ip {server_ip}"
                )
                return g.user.get_api().get_entity_by_id(server_id).get_id()
            except PortalException as exception:
                if 'No such entity exists.:%d' % server_id in exception.get_message(
                ):
                    pass
                else:
                    raise exception
    except WebFault as exception:
        raise BAMException(safe_str(exception))
Beispiel #2
0
def migrate_xml(api, workflow_dir):
    upload_migration_xml(api, workflow_dir, 'temporary.xml')
    try:
        api._api_client.service.migrateFile('temporary.xml')
    except WebFault as e:
        raise BAMException(str(e))
    return
def denyMACAddress(configuration, macaddr):
    try:
        configuration._api_client.service.denyMACAddress(
            configuration.get_id(), macaddr)
    except WebFault as e:
        print('Exception at denyMACAddress(%s)' % util.safe_str(e))
        raise BAMException(safe_str(e))
Beispiel #4
0
def get_deployment_options(entity, option_types, server_id):
    options = []
    try:
        options = entity._api_client.getDeploymentOptions(entity.get_id(), option_types, server_id)
    except GeneralError as e:
        print('Exception at get_deployment_options(%s)' % util.safe_str(e))
        raise BAMException(safe_str(e))
    return options
def get_server_by_name(config_id, server_name):
    """
    Get server by name
    :param config_id: id of configuration
    :param server_name: name of server
    :return:
    """
    try:
        server = g.user.get_api()._api_client.service.getEntityByName(
            config_id, server_name, entity.Entity.Server)
        g.user.logger.debug("Server: {}".format(server))
    except WebFault as exception:
        raise BAMException(safe_str(exception))
    return server