def __init__(self, resource_group=None, load_balancer_name=None, api_version=constants.API_VER_NETWORK, logger=None, _ctx=ctx): resource_group = resource_group or \ utils.get_resource_group(_ctx=_ctx) load_balancer_name = load_balancer_name or \ utils.get_resource_name_ref( constants.REL_CONTAINED_IN_LB, 'load_balancer_name', _ctx=_ctx) Resource.__init__( self, 'Backend Address Pool', '/{0}/{1}/{2}/{3}'.format( 'resourceGroups/{0}'.format(resource_group), 'providers/Microsoft.Network', 'loadBalancers/{0}'.format(load_balancer_name), 'backendAddressPools' ), api_version=api_version, logger=logger, _ctx=_ctx)
def test_accepted(self, mock): '''Test for ACCEPTED with proper headers''' name = 'Virtual Machine' res_name = 'testvm' endpoint = '/{0}/{1}/{2}'.format( 'resourceGroups/test_resource_group', 'providers/Microsoft.Compute', 'virtualMachines') headers = { 'location': 'https://test.com/test', 'x-ms-request-id': 'test-id-string', 'retry-after': '1' } self.mock_endpoints(mock, endpoint, res_name, json={'response': 'ok'}, status_code=httplib.ACCEPTED, headers=headers) res = Resource( name, endpoint, api_version=constants.API_VER_COMPUTE, logger=self.log) self.assertEqual(res.name, name) self.assertEqual(res.endpoint, endpoint) res.get(name=res_name) self.assertEqual( self.ctx.instance.runtime_properties.get('async_op'), headers)
def test_accepted(self, mock): '''Test for ACCEPTED with proper headers''' name = 'Virtual Machine' res_name = 'testvm' endpoint = '/{0}/{1}/{2}'.format('resourceGroups/test_resource_group', 'providers/Microsoft.Compute', 'virtualMachines') headers = { 'location': 'https://test.com/test', 'x-ms-request-id': 'test-id-string', 'retry-after': '1' } self.mock_endpoints(mock, endpoint, res_name, json={'response': 'ok'}, status_code=httplib.ACCEPTED, headers=headers) res = Resource(name, endpoint, api_version=constants.API_VER_COMPUTE, logger=self.log) self.assertEqual(res.name, name) self.assertEqual(res.endpoint, endpoint) res.get(name=res_name) self.assertEqual(self.ctx.instance.runtime_properties.get('async_op'), headers)
def __init__(self, api_version=constants.API_VER_RESOURCES, logger=None, _ctx=ctx): Resource.__init__(self, 'Resource Group', '/resourceGroups', api_version=api_version, logger=logger, _ctx=_ctx)
def __init__(self, api_version=constants.API_VER_RESOURCES, logger=None, _ctx=ctx): Resource.__init__( self, 'Resource Group', '/resourceGroups', api_version=api_version, logger=logger, _ctx=_ctx)
def __init__(self, resource_group=None, api_version=constants.API_VER_COMPUTE, logger=None, _ctx=ctx): resource_group = resource_group or \ utils.get_resource_group(_ctx=_ctx) Resource.__init__(self, 'Availability Set', '/{0}/{1}'.format( 'resourceGroups/{0}'.format(resource_group), 'providers/Microsoft.Compute/availabilitySets'), api_version=api_version, logger=logger, _ctx=_ctx)
def __init__(self, resource_group=None, api_version=constants.API_VER_NETWORK, logger=None, _ctx=ctx): resource_group = resource_group or \ utils.get_resource_group(_ctx=_ctx) Resource.__init__(self, 'Public IP Address', '/{0}/{1}'.format( 'resourceGroups/{0}'.format(resource_group), 'providers/Microsoft.Network/publicIPAddresses'), api_version=api_version, logger=logger, _ctx=_ctx)
def __init__(self, resource_group=None, api_version=constants.API_VER_STORAGE, logger=None, _ctx=ctx): resource_group = resource_group or \ utils.get_resource_group(_ctx=_ctx) Resource.__init__(self, 'Storage Account', '/{0}/{1}'.format( 'resourceGroups/{0}'.format(resource_group), 'providers/Microsoft.Storage/storageAccounts'), api_version=api_version, logger=logger, _ctx=_ctx)
def test_good_get(self, mock): '''Test for a successful get request''' name = 'Virtual Machine' res_name = 'testvm' endpoint = '/{0}/{1}/{2}'.format('resourceGroups/test_resource_group', 'providers/Microsoft.Compute', 'virtualMachines') self.mock_endpoints(mock, endpoint, res_name, json={'response': 'ok'}) res = Resource(name, endpoint, api_version=constants.API_VER_COMPUTE, logger=self.log) self.assertEqual(res.name, name) self.assertEqual(res.endpoint, endpoint) data = res.get(name=res_name) self.assertTrue(isinstance(data, dict))
def __init__(self, resource_group=None, api_version=constants.API_VER_COMPUTE, logger=None, _ctx=ctx): resource_group = resource_group or \ utils.get_resource_group(_ctx=_ctx) Resource.__init__(self, 'Virtual Machine', '/{0}/{1}/{2}'.format( 'resourceGroups/{0}'.format(resource_group), 'providers/Microsoft.Compute', 'virtualMachines'), api_version=api_version, logger=logger, _ctx=_ctx)
def __init__(self, resource_group=None, api_version=constants.API_VER_STORAGE, logger=None, _ctx=ctx): resource_group = resource_group or \ utils.get_resource_group(_ctx=_ctx) Resource.__init__( self, 'Storage Account', '/{0}/{1}'.format( 'resourceGroups/{0}'.format(resource_group), 'providers/Microsoft.Storage/storageAccounts' ), api_version=api_version, logger=logger, _ctx=_ctx)
def __init__(self, resource_group=None, api_version=constants.API_VER_COMPUTE, logger=None, _ctx=ctx): resource_group = resource_group or \ utils.get_resource_group(_ctx=_ctx) Resource.__init__( self, 'Availability Set', '/{0}/{1}'.format( 'resourceGroups/{0}'.format(resource_group), 'providers/Microsoft.Compute/availabilitySets' ), api_version=api_version, logger=logger, _ctx=_ctx)
def __init__(self, resource_group=None, api_version=constants.API_VER_NETWORK, logger=None, _ctx=ctx): resource_group = resource_group or \ utils.get_resource_group(_ctx=_ctx) Resource.__init__( self, 'Public IP Address', '/{0}/{1}'.format( 'resourceGroups/{0}'.format(resource_group), 'providers/Microsoft.Network/publicIPAddresses' ), api_version=api_version, logger=logger, _ctx=_ctx)
def __init__(self, resource_group=None, api_version=constants.API_VER_COMPUTE, logger=None, _ctx=ctx): resource_group = resource_group or \ utils.get_resource_group(_ctx=_ctx) Resource.__init__( self, 'Virtual Machine', '/{0}/{1}/{2}'.format( 'resourceGroups/{0}'.format(resource_group), 'providers/Microsoft.Compute', 'virtualMachines' ), api_version=api_version, logger=logger, _ctx=_ctx)
def __init__(self, resource_group=None, route_table=None, api_version=constants.API_VER_NETWORK, logger=None, _ctx=ctx): resource_group = resource_group or \ utils.get_resource_group(_ctx=_ctx) route_table = route_table or \ utils.get_route_table(_ctx=_ctx) Resource.__init__(self, 'Route', '/{0}/{1}/{2}/{3}'.format( 'resourceGroups/{0}'.format(resource_group), 'providers/Microsoft.Network', 'routeTables/{0}'.format(route_table), 'routes'), api_version=api_version, logger=logger, _ctx=_ctx)
def test_good_get(self, mock): '''Test for a successful get request''' name = 'Virtual Machine' res_name = 'testvm' endpoint = '/{0}/{1}/{2}'.format( 'resourceGroups/test_resource_group', 'providers/Microsoft.Compute', 'virtualMachines') self.mock_endpoints(mock, endpoint, res_name, json={'response': 'ok'}) res = Resource( name, endpoint, api_version=constants.API_VER_COMPUTE, logger=self.log) self.assertEqual(res.name, name) self.assertEqual(res.endpoint, endpoint) data = res.get(name=res_name) self.assertTrue(isinstance(data, dict))
def __init__(self, resource_group=None, virtual_machine=None, api_version=constants.API_VER_COMPUTE, logger=None, _ctx=ctx): resource_group = resource_group or \ utils.get_resource_group(_ctx=_ctx) virtual_machine = virtual_machine or \ utils.get_rel_node_name(constants.REL_VMX_CONTAINED_IN_VM) Resource.__init__(self, 'Virtual Machine Extension', '/{0}/{1}/{2}/{3}'.format( 'resourceGroups/{0}'.format(resource_group), 'providers/Microsoft.Compute', 'virtualMachines/{0}'.format(virtual_machine), 'extensions'), api_version=api_version, logger=logger, _ctx=_ctx)
def __init__(self, resource_group=None, virtual_network=None, api_version=constants.API_VER_NETWORK, logger=None, _ctx=ctx): resource_group = resource_group or \ utils.get_resource_group(_ctx=_ctx) virtual_network = virtual_network or \ utils.get_virtual_network(_ctx=_ctx) Resource.__init__(self, 'Subnet', '/{0}/{1}/{2}/{3}'.format( 'resourceGroups/{0}'.format(resource_group), 'providers/Microsoft.Network', 'virtualNetworks/{0}'.format(virtual_network), 'subnets'), api_version=api_version, logger=logger, _ctx=_ctx)
def __init__(self, resource_group=None, network_security_group=None, api_version=constants.API_VER_NETWORK, logger=None, _ctx=ctx): resource_group = resource_group or \ utils.get_resource_group(_ctx=_ctx) network_security_group = network_security_group or \ utils.get_network_security_group(_ctx=_ctx) Resource.__init__( self, 'Network Security Rule', '/{0}/{1}/{2}/{3}'.format( 'resourceGroups/{0}'.format(resource_group), 'providers/Microsoft.Network', 'networkSecurityGroups/{0}'.format(network_security_group), 'securityRules'), api_version=api_version, logger=logger, _ctx=_ctx)
def __init__(self, resource_group=None, network_interface_card=None, api_version=constants.API_VER_NETWORK, logger=None, _ctx=ctx): resource_group = resource_group or \ utils.get_resource_group(_ctx=_ctx) network_interface_card = network_interface_card or \ _ctx.node.properties.get('network_interface_card_name') Resource.__init__( self, 'IP Configuration', '/{0}/{1}/{2}/{3}'.format( 'resourceGroups/{0}'.format(resource_group), 'providers/Microsoft.Network/', 'networkInterfaces/{0}'.format(network_interface_card), 'ipConfigurations'), api_version=api_version, logger=logger, _ctx=_ctx)
def __init__(self, resource_group=None, network_security_group=None, api_version=constants.API_VER_NETWORK, logger=None, _ctx=ctx): resource_group = resource_group or \ utils.get_resource_group(_ctx=_ctx) network_security_group = network_security_group or \ utils.get_network_security_group(_ctx=_ctx) Resource.__init__( self, 'Network Security Rule', '/{0}/{1}/{2}/{3}'.format( 'resourceGroups/{0}'.format(resource_group), 'providers/Microsoft.Network', 'networkSecurityGroups/{0}'.format(network_security_group), 'securityRules' ), api_version=api_version, logger=logger, _ctx=_ctx)
def __init__(self, resource_group=None, virtual_network=None, api_version=constants.API_VER_NETWORK, logger=None, _ctx=ctx): resource_group = resource_group or \ utils.get_resource_group(_ctx=_ctx) virtual_network = virtual_network or \ utils.get_virtual_network(_ctx=_ctx) Resource.__init__( self, 'Subnet', '/{0}/{1}/{2}/{3}'.format( 'resourceGroups/{0}'.format(resource_group), 'providers/Microsoft.Network', 'virtualNetworks/{0}'.format(virtual_network), 'subnets' ), api_version=api_version, logger=logger, _ctx=_ctx)
def __init__(self, resource_group=None, network_interface_card=None, api_version=constants.API_VER_NETWORK, logger=None, _ctx=ctx): resource_group = resource_group or \ utils.get_resource_group(_ctx=_ctx) network_interface_card = network_interface_card or \ _ctx.node.properties.get('network_interface_card_name') Resource.__init__( self, 'IP Configuration', '/{0}/{1}/{2}/{3}'.format( 'resourceGroups/{0}'.format(resource_group), 'providers/Microsoft.Network/', 'networkInterfaces/{0}'.format(network_interface_card), 'ipConfigurations' ), api_version=api_version, logger=logger, _ctx=_ctx)
def __init__(self, resource_group=None, virtual_machine=None, api_version=constants.API_VER_COMPUTE, logger=None, _ctx=ctx): resource_group = resource_group or \ utils.get_resource_group(_ctx=_ctx) virtual_machine = virtual_machine or \ utils.get_rel_node_name(constants.REL_VMX_CONTAINED_IN_VM) Resource.__init__( self, 'Virtual Machine Extension', '/{0}/{1}/{2}/{3}'.format( 'resourceGroups/{0}'.format(resource_group), 'providers/Microsoft.Compute', 'virtualMachines/{0}'.format(virtual_machine), 'extensions' ), api_version=api_version, logger=logger, _ctx=_ctx)