class main(): #variables admin_ip = '192.168.124.10' admin_port = '3000' user = '******' password = '******' target_node = "d08-00-27-20-36-b0.test.org" deployment_name = 'newTestDeployment' #create a session session = cb2_Api(admin_ip, admin_port, user, password) #create a new deployment deploy = Deployment() deploy.name = deployment_name deploy = session.create(deploy) #get/set the target node targetNode = session.get(session.get(Node({"name":target_node}))) targetNode.deployment_id = deploy.id node = session.update(targetNode) node.pretty_print() #create a node role & assign it to the node created above nodeRole = Node_Role() nodeRole.node_id = targetNode.id nodeRole.role_id = '6' nodeRole = session.update(nodeRole) nodeRole.pretty_print() #commit the deployment session.commit_deployment(deploy.id)
class main(): session = cb2_Api("192.168.124.10", "3000", "crowbar", "crowbar") list_methods = { 'get_nodes', 'get_snapshots', 'get_deployments', 'get_deployment_roles', #'get_interfaces', #NOT CURRENTLY AVAILABLE 'get_users', 'get_node_roles', 'get_barclamps', 'get_groups', #'get_dhcpdatabases', #NOT CURRENTLY AVAILABLE 'get_attributes', 'get_jigs', } for method in list_methods: print "--- Checking list method " + method + " --- " ls = getattr(session, method)() if len(ls) > 0: for each in ls: print " -- checking object of type " + str( each.__class__) + " generic get" remote = session.get(each) # .. this is not pretty i know, but else we ll get random errors (not sure what triggers the timestamp to be updated) if str(each.__class__.__name__) == 'User': each.updated_at = each.updated_at[:-4] remote.updated_at = remote.updated_at[:-4] if remote.__dict__ == each.__dict__: remote.pretty_print() print " PASS" else: print " FAIL" print " local object instance :" each.pretty_print() print " remote object instance :" remote.pretty_print() raise AssertionError else: print "empty list back, doesn't look right" raise AssertionError print "That's all folks"