예제 #1
0
    def fromfile(cls, name, branch, config, path=None):
        if not path:
            path = os.path.join(os.path.dirname(__file__),
                                os.pardir,
                                'deployment_templates/default.yaml')
        template = Config(path)[name]
        local_api = autoconfigure()
        chef = Chef(name, local_api, description=name)
        razor = razor_api(config['razor']['ip'])
        os_name = template['os']
        product = template['product']
        name = template['name']

        deployment = cls.deployment_config(template['os-features'],
                                           template['rpcs-features'], name,
                                           os_name, branch, config, chef,
                                           razor)
        for features in template['nodes']:
            node = cls.node_config(deployment, features, os_name, product,
                                   chef, razor, branch)
            deployment.nodes.append(node)

        return deployment
예제 #2
0
def get_private_ip(chef_node_addresses):
    #print "!!## -- Addresses: %s -- ##!!" % chef_node_addresses
    for k, v in chef_node_addresses:
        #print "!!## -- Key: %s -- Value: %s -- ##!!" % (k,v)
        for k2, v2 in v.iteritems():
            #print "!!## -- Key2: %s type(%s) -- Value2: %s type(%s) -- ##!!" % (k2, type(k2), v2, type(v2))
            if str(v2) == 'inet':
                #print "!!## -- Private IP: %s -- ##!!" % k
                return k

#############################################################
#Collect active models that match policy from given input
#############################################################

razor = razor_api(results.razor_ip)
policy = results.policy

print "!!## -- Tearing down and rebooting  '%s'  active models -- ##!!" % policy
print "!!## -- Display only: %s -- ##!!" % results.display_only

active_models = razor.simple_active_models(policy)

#print json.dumps(active_models, indent=4)

if active_models:
    for active in active_models:
        data = active_models[active]
        private_ip = data['eth1_ip']
        am_uuid = data['am_uuid']
        chef_name = "%s%s.%s" % (data['hostname_prefix'], data['bind_number'], data['domain'])
예제 #3
0
        name = "%s%s.%s" % (data['hostname_prefix'], data['bind_number'], data['domain'])
        return name
    except Exception, e:
        return ''

def get_root_pass(data):
    if 'root_password' in data:
        return data['root_password']
    else:
        return ''

#############################################################
#Collect active models that match policy from given input
#############################################################

razor = razor_api(results.razor_ip)
policy = results.policy
active_models = razor.simple_active_models(policy)
opencenter_user = results.opencenter_user
opencenter_password = results.opencenter_password
servers = []

if active_models:
    # Gather all of the active models for the policy and get information about them.
    for active in active_models:
        data = active_models[active]
        chef_name = get_chef_name(data)
        root_password = get_root_pass(data)

        with ChefAPI(results.chef_url, results.chef_client_pem, results.chef_client):
            node = Node(chef_name)
예제 #4
0
 def __init__(self, razor_ip='198.101.133.3'):
     self.razor = razor_api(razor_ip)
     self.chef = autoconfigure()
     self.chef.set_default()
예제 #5
0
 def enable_razor(self, razor_ip=''):
     if razor_ip != '':
         self.razor = razor_api(razor_ip)
예제 #6
0
import sys
import time
from chef import Search, Node, Client
from razor_api import razor_api
from server_helper import run_remote_ssh_cmd


razor_ip = '198.101.133.3'
razor = razor_api(razor_ip)


def build_computes(computes):
    # Run computes
    print "Making the compute nodes..."
    for compute in computes:
        compute_node = Node(compute)
        compute_node['in_use'] = "compute"
        compute_node.run_list = ["role[qa-single-compute]"]
        compute_node.save()

        print "Updating server...this may take some time"
        update_node(compute_node)

        if compute_node['platform_family'] == 'rhel':
            print "Platform is RHEL family, disabling iptables"
            disable_iptables(compute_node)

        # Run chef client twice
        print "Running chef-client on compute node: %s, this may take some time..." % compute
        run1 = run_chef_client(compute_node)
        if run1['success']: